Quoth Johann Haarhoff,
Some applications (like xterm) like to be resized in fixed-size
increments (multiples of terminal lines). If you do not respect this,
you will get some blank space below the last terminal line which can
look a bit confusing. wWindowConstrainSize() talks to the app and will
return the closest width and height to what you requested, but taking
into account the fixed-size increments.
Try this patch. By querying the window-specified resize increments
in the same way that wWindowConstrainSize() does we can ensure that
the resize works properly.
This is a useful feature. I already have shortcut keys to grow and
shrink my urxvt windows so I could definitely use this for other windows.
Some ideas which might be worth working on:
* Respecting the aspect ratio of the window while resizing.
* Scaling the resize by the desired increment where the window does
constrain its size. So if you set the increment to 100 in WPrefs and
and xterm wants to resize by 15x7 then what would actually happen is
that it would resize by 90x42.
* Keyboard support. I don't have a mousewheel. I don't even have
a mouse. I've been using the hotkeys on my Wacom tablet to simulate
mousewheel events for testing this.
If I'm on the right lines with this patch I'll try to devote some
time to the other things.
>From 28979cc578abaa3433f21c94831e05fdfd6aed59 Mon Sep 17 00:00:00 2001
From: Iain Patterson <[email protected]>
Date: Mon, 12 Oct 2009 10:24:55 +0100
Subject: [PATCH] Respect size hints when resizing with wheel.
Use height and width increment when wheel resizing if size hints are
set on a window and meaningful height and width increments are
specified.
Windows which don't care about their resize increments will have height
and width increments set to 1. For these windows - and windows without
resize hints at all - use the setting configured with ResizeIncrement.
---
src/window.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/window.c b/src/window.c
index 57b51b4..5f1e53c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2860,9 +2860,17 @@ static void frameMouseDown(WObjDescriptor *desc, XEvent *event)
WWindow *wwin = desc->parent;
unsigned int new_width;
unsigned int new_height;
- unsigned int resize_increment;
+ unsigned int resize_width_increment = 0;
+ unsigned int resize_height_increment = 0;
- resize_increment = wPreferences.resize_increment;
+ if (wwin->normal_hints) {
+ resize_width_increment = wwin->normal_hints->width_inc;
+ resize_height_increment = wwin->normal_hints->height_inc;
+ }
+ if (resize_width_increment <= 1 && resize_height_increment <= 1) {
+ resize_width_increment = wPreferences.resize_increment;
+ resize_height_increment = wPreferences.resize_increment;
+ }
event->xbutton.state &= ValidModMask;
@@ -2887,14 +2895,14 @@ static void frameMouseDown(WObjDescriptor *desc, XEvent *event)
if (event->xbutton.button == Button3) {
wMouseResizeWindow(wwin, event);
} else if (event->xbutton.button == Button4) {
- new_width = wwin->client.width - resize_increment;
- new_height = wwin->client.height - resize_increment;
- //wWindowConstrainSize(wwin, &new_width,&new_height);
+ new_width = wwin->client.width - resize_width_increment;
+ new_height = wwin->client.height - resize_height_increment;
+ wWindowConstrainSize(wwin, &new_width,&new_height);
wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, new_width, new_height);
} else if (event->xbutton.button == Button5) {
- new_width = wwin->client.width + resize_increment;
- new_height = wwin->client.height + resize_increment;
- //wWindowConstrainSize(wwin, &new_width,&new_height);
+ new_width = wwin->client.width + resize_width_increment;
+ new_height = wwin->client.height + resize_height_increment;
+ wWindowConstrainSize(wwin, &new_width,&new_height);
wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, new_width, new_height);
} else if (event->xbutton.button == Button1 || event->xbutton.button == Button2) {
wMouseMoveWindow(wwin, event);
--
1.6.3.1