1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

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.
This commit is contained in:
Johann Haarhoff
2009-10-11 21:36:46 +02:00
committed by Carlos R. Mafra
parent 781b663341
commit a063338175
4 changed files with 64 additions and 4 deletions

View File

@@ -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 ****************/

View File

@@ -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 */

View File

@@ -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,

View File

@@ -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);
}
}