From: Johann Haarhoff Date: Sun, 11 Oct 2009 19:36:46 +0000 (+0200) Subject: Mod+Wheel Window Resize X-Git-Tag: wmaker-0.94.0-crm~40 X-Git-Url: https://repo.or.cz/w/wmaker-crm.git/commitdiff_plain/a063338175511c4e6af211cef9f2c8a555d7cb44 Mod+Wheel Window Resize This patch adds the ability to resize windows with the mouse wheel while holding the Mod key. This currently ignores wWindowConstrainSize until I can figure out a way to repeatably resize windows with fixed size increments (like xterm) using this method. This also adds a slider to WPrefs to choose the increment with which the wheel will resize a window. --- diff --git a/WPrefs.app/WindowHandling.c b/WPrefs.app/WindowHandling.c index 708d80e2..e33eb4cf 100644 --- a/WPrefs.app/WindowHandling.c +++ b/WPrefs.app/WindowHandling.c @@ -53,6 +53,10 @@ typedef struct _Panel { WMButton *miconB; WMButton *mdockB; + WMLabel *resizeL; + WMLabel *resizeTextL; + WMSlider *resizeS; + WMFrame *opaqF; WMButton *opaqB; @@ -111,6 +115,22 @@ static void resistanceCallback(WMWidget * w, void *data) } } +static void resizeCallback(WMWidget * w, void *data) +{ + _Panel *panel = (_Panel *) data; + char buffer[64]; + int i; + + i = WMGetSliderValue(panel->resizeS); + + if (i == 0) + WMSetLabelText(panel->resizeL, "OFF"); + else { + sprintf(buffer, "%i", i); + WMSetLabelText(panel->resizeL, buffer); + } +} + static int getPlacement(char *str) { if (!str) @@ -163,6 +183,10 @@ static void showData(_Panel * panel) WMSetSliderValue(panel->resS, x); resistanceCallback(NULL, panel); + x = GetIntegerForKey("ResizeIncrement"); + WMSetSliderValue(panel->resizeS, x); + resizeCallback(NULL, panel); + WMSetButtonSelected(panel->tranB, GetBoolForKey("OpenTransientOnOwnerWorkspace")); WMSetButtonSelected(panel->opaqB, GetBoolForKey("OpaqueMove")); @@ -192,6 +216,7 @@ static void storeData(_Panel * panel) arr = WMCreatePLArray(WMCreatePLString(x), WMCreatePLString(y), NULL); SetObjectForKey(arr, "WindowPlaceOrigin"); SetIntegerForKey(WMGetSliderValue(panel->resS), "EdgeResistance"); + SetIntegerForKey(WMGetSliderValue(panel->resizeS), "ResizeIncrement"); SetBoolForKey(WMGetButtonSelected(panel->resrB), "Attraction"); WMReleasePropList(arr); } @@ -341,15 +366,31 @@ static void createPanel(Panel * p) panel->miconB = WMCreateSwitchButton(panel->maxiF); WMResizeWidget(panel->miconB, 190, 30); - WMMoveWidget(panel->miconB, 10, 18); + WMMoveWidget(panel->miconB, 10, 12); WMSetButtonText(panel->miconB, _("...do not cover icons")); panel->mdockB = WMCreateSwitchButton(panel->maxiF); WMResizeWidget(panel->mdockB, 190, 30); - WMMoveWidget(panel->mdockB, 10, 53); + WMMoveWidget(panel->mdockB, 10, 35); WMSetButtonText(panel->mdockB, _("...do not cover dock")); + panel->resizeS = WMCreateSlider(panel->maxiF); + WMResizeWidget(panel->resizeS, 50, 15); + WMMoveWidget(panel->resizeS, 10, 70); + WMSetSliderMinValue(panel->resizeS, 0); + WMSetSliderMaxValue(panel->resizeS, 100); + WMSetSliderAction(panel->resizeS, resizeCallback, panel); + + panel->resizeL = WMCreateLabel(panel->maxiF); + WMResizeWidget(panel->resizeL, 30, 15); + WMMoveWidget(panel->resizeL, 60, 70); + + panel->resizeTextL = WMCreateLabel(panel->maxiF); + WMSetLabelText(panel->resizeTextL, "Mod+Wheel\nresize increment"); + WMResizeWidget(panel->resizeTextL, 110, 30); + WMMoveWidget(panel->resizeTextL, 90, 62); + WMMapSubwidgets(panel->maxiF); /**************** Edge Resistance ****************/ diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 780afbf1..0c3839fa 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -466,6 +466,7 @@ typedef struct WPreferences { signed char shade_speed; int edge_resistance; + int resize_increment; char attract; unsigned int workspace_border_size; /* Size in pixels of the workspace border */ diff --git a/src/defaults.c b/src/defaults.c index 58c823d0..25e65f13 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -468,6 +468,8 @@ WDefaultEntry optionList[] = { &wPreferences.help_balloon, getBool, NULL}, {"EdgeResistance", "30", NULL, &wPreferences.edge_resistance, getInt, NULL}, + {"ResizeIncrement", "32", NULL, + &wPreferences.resize_increment, getInt, NULL}, {"Attraction", "NO", NULL, &wPreferences.attract, getBool, NULL}, {"DisableBlinking", "NO", NULL, diff --git a/src/window.c b/src/window.c index 62407767..0b68df50 100644 --- a/src/window.c +++ b/src/window.c @@ -2966,6 +2966,11 @@ static void titlebarDblClick(WCoreWindow * sender, void *data, XEvent * event) static void frameMouseDown(WObjDescriptor * desc, XEvent * event) { WWindow *wwin = desc->parent; + unsigned int new_width; + unsigned int new_height; + unsigned int resize_increment; + + resize_increment = wPreferences.resize_increment; event->xbutton.state &= ValidModMask; @@ -2990,10 +2995,21 @@ static void frameMouseDown(WObjDescriptor * desc, XEvent * event) #endif return; } - if (event->xbutton.button == Button3) + if (event->xbutton.button == Button3) { wMouseResizeWindow(wwin, event); - else if (event->xbutton.button == Button1 || event->xbutton.button == Button2) + } 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); + 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); + 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); + } XUngrabPointer(dpy, CurrentTime); } }