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:
committed by
Carlos R. Mafra
parent
781b663341
commit
a063338175
@@ -53,6 +53,10 @@ typedef struct _Panel {
|
|||||||
WMButton *miconB;
|
WMButton *miconB;
|
||||||
WMButton *mdockB;
|
WMButton *mdockB;
|
||||||
|
|
||||||
|
WMLabel *resizeL;
|
||||||
|
WMLabel *resizeTextL;
|
||||||
|
WMSlider *resizeS;
|
||||||
|
|
||||||
WMFrame *opaqF;
|
WMFrame *opaqF;
|
||||||
WMButton *opaqB;
|
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)
|
static int getPlacement(char *str)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (!str)
|
||||||
@@ -163,6 +183,10 @@ static void showData(_Panel * panel)
|
|||||||
WMSetSliderValue(panel->resS, x);
|
WMSetSliderValue(panel->resS, x);
|
||||||
resistanceCallback(NULL, panel);
|
resistanceCallback(NULL, panel);
|
||||||
|
|
||||||
|
x = GetIntegerForKey("ResizeIncrement");
|
||||||
|
WMSetSliderValue(panel->resizeS, x);
|
||||||
|
resizeCallback(NULL, panel);
|
||||||
|
|
||||||
WMSetButtonSelected(panel->tranB, GetBoolForKey("OpenTransientOnOwnerWorkspace"));
|
WMSetButtonSelected(panel->tranB, GetBoolForKey("OpenTransientOnOwnerWorkspace"));
|
||||||
|
|
||||||
WMSetButtonSelected(panel->opaqB, GetBoolForKey("OpaqueMove"));
|
WMSetButtonSelected(panel->opaqB, GetBoolForKey("OpaqueMove"));
|
||||||
@@ -192,6 +216,7 @@ static void storeData(_Panel * panel)
|
|||||||
arr = WMCreatePLArray(WMCreatePLString(x), WMCreatePLString(y), NULL);
|
arr = WMCreatePLArray(WMCreatePLString(x), WMCreatePLString(y), NULL);
|
||||||
SetObjectForKey(arr, "WindowPlaceOrigin");
|
SetObjectForKey(arr, "WindowPlaceOrigin");
|
||||||
SetIntegerForKey(WMGetSliderValue(panel->resS), "EdgeResistance");
|
SetIntegerForKey(WMGetSliderValue(panel->resS), "EdgeResistance");
|
||||||
|
SetIntegerForKey(WMGetSliderValue(panel->resizeS), "ResizeIncrement");
|
||||||
SetBoolForKey(WMGetButtonSelected(panel->resrB), "Attraction");
|
SetBoolForKey(WMGetButtonSelected(panel->resrB), "Attraction");
|
||||||
WMReleasePropList(arr);
|
WMReleasePropList(arr);
|
||||||
}
|
}
|
||||||
@@ -341,15 +366,31 @@ static void createPanel(Panel * p)
|
|||||||
|
|
||||||
panel->miconB = WMCreateSwitchButton(panel->maxiF);
|
panel->miconB = WMCreateSwitchButton(panel->maxiF);
|
||||||
WMResizeWidget(panel->miconB, 190, 30);
|
WMResizeWidget(panel->miconB, 190, 30);
|
||||||
WMMoveWidget(panel->miconB, 10, 18);
|
WMMoveWidget(panel->miconB, 10, 12);
|
||||||
WMSetButtonText(panel->miconB, _("...do not cover icons"));
|
WMSetButtonText(panel->miconB, _("...do not cover icons"));
|
||||||
|
|
||||||
panel->mdockB = WMCreateSwitchButton(panel->maxiF);
|
panel->mdockB = WMCreateSwitchButton(panel->maxiF);
|
||||||
WMResizeWidget(panel->mdockB, 190, 30);
|
WMResizeWidget(panel->mdockB, 190, 30);
|
||||||
WMMoveWidget(panel->mdockB, 10, 53);
|
WMMoveWidget(panel->mdockB, 10, 35);
|
||||||
|
|
||||||
WMSetButtonText(panel->mdockB, _("...do not cover dock"));
|
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);
|
WMMapSubwidgets(panel->maxiF);
|
||||||
|
|
||||||
/**************** Edge Resistance ****************/
|
/**************** Edge Resistance ****************/
|
||||||
|
|||||||
@@ -466,6 +466,7 @@ typedef struct WPreferences {
|
|||||||
signed char shade_speed;
|
signed char shade_speed;
|
||||||
|
|
||||||
int edge_resistance;
|
int edge_resistance;
|
||||||
|
int resize_increment;
|
||||||
char attract;
|
char attract;
|
||||||
|
|
||||||
unsigned int workspace_border_size; /* Size in pixels of the workspace border */
|
unsigned int workspace_border_size; /* Size in pixels of the workspace border */
|
||||||
|
|||||||
@@ -468,6 +468,8 @@ WDefaultEntry optionList[] = {
|
|||||||
&wPreferences.help_balloon, getBool, NULL},
|
&wPreferences.help_balloon, getBool, NULL},
|
||||||
{"EdgeResistance", "30", NULL,
|
{"EdgeResistance", "30", NULL,
|
||||||
&wPreferences.edge_resistance, getInt, NULL},
|
&wPreferences.edge_resistance, getInt, NULL},
|
||||||
|
{"ResizeIncrement", "32", NULL,
|
||||||
|
&wPreferences.resize_increment, getInt, NULL},
|
||||||
{"Attraction", "NO", NULL,
|
{"Attraction", "NO", NULL,
|
||||||
&wPreferences.attract, getBool, NULL},
|
&wPreferences.attract, getBool, NULL},
|
||||||
{"DisableBlinking", "NO", NULL,
|
{"DisableBlinking", "NO", NULL,
|
||||||
|
|||||||
20
src/window.c
20
src/window.c
@@ -2966,6 +2966,11 @@ static void titlebarDblClick(WCoreWindow * sender, void *data, XEvent * event)
|
|||||||
static void frameMouseDown(WObjDescriptor * desc, XEvent * event)
|
static void frameMouseDown(WObjDescriptor * desc, XEvent * event)
|
||||||
{
|
{
|
||||||
WWindow *wwin = desc->parent;
|
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;
|
event->xbutton.state &= ValidModMask;
|
||||||
|
|
||||||
@@ -2990,10 +2995,21 @@ static void frameMouseDown(WObjDescriptor * desc, XEvent * event)
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event->xbutton.button == Button3)
|
if (event->xbutton.button == Button3) {
|
||||||
wMouseResizeWindow(wwin, event);
|
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);
|
wMouseMoveWindow(wwin, event);
|
||||||
|
}
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user