mirror of
https://github.com/gryf/wmaker.git
synced 2026-03-21 02:43:32 +01:00
wmaker: add support for _NET_WM_MOVERESIZE
This patch adds support for _NET_WM_MOVERESIZE hint as defined in EWMH which allows a window without decorations to manage itself (moving/resizing). The purpose is to fix the issue mentioned at https://github.com/window-maker/wmaker/issues/20 Tested with VS Code, Google Chrome, Steam and Discord. Specs are available at https://specifications.freedesktop.org/wm/1.5/ar01s04.html#id-1.5.4
This commit is contained in:
committed by
Carlos R. Mafra
parent
ef1a504898
commit
6d0953bc22
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "wconfig.h"
|
||||
#include "wmspec.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@@ -1916,7 +1917,7 @@ int wMouseMoveWindow(WWindow * wwin, XEvent * ev)
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event.xbutton.button != ev->xbutton.button)
|
||||
if (!wwin->moveresize.active && (event.xbutton.button != ev->xbutton.button))
|
||||
break;
|
||||
|
||||
if (started) {
|
||||
@@ -1964,6 +1965,10 @@ int wMouseMoveWindow(WWindow * wwin, XEvent * ev)
|
||||
WMUnmapWidget(scr->gview);
|
||||
}
|
||||
}
|
||||
if (wwin->moveresize.active) {
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
wwin->moveresize.active = 0;
|
||||
}
|
||||
done = True;
|
||||
break;
|
||||
|
||||
@@ -2101,8 +2106,13 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
||||
wwarning("internal error: tryein");
|
||||
return;
|
||||
}
|
||||
orig_x = ev->xbutton.x_root;
|
||||
orig_y = ev->xbutton.y_root;
|
||||
if (ev->type == MotionNotify) {
|
||||
orig_x = ev->xmotion.x_root;
|
||||
orig_y = ev->xmotion.y_root;
|
||||
} else {
|
||||
orig_x = ev->xbutton.x_root;
|
||||
orig_y = ev->xbutton.y_root;
|
||||
}
|
||||
|
||||
started = 0;
|
||||
wUnselectWindows(scr);
|
||||
@@ -2113,6 +2123,29 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
||||
shiftl = XKeysymToKeycode(dpy, XK_Shift_L);
|
||||
shiftr = XKeysymToKeycode(dpy, XK_Shift_R);
|
||||
|
||||
if (wwin->moveresize.active) {
|
||||
int direction = wwin->moveresize.resize_edge;
|
||||
|
||||
res = 0;
|
||||
is_resizebar = 0;
|
||||
if (direction == _NET_WM_MOVERESIZE_SIZE_TOP)
|
||||
res |= UP;
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_BOTTOM)
|
||||
res |= DOWN;
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_LEFT)
|
||||
res |= LEFT;
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_RIGHT)
|
||||
res |= RIGHT;
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_TOPLEFT)
|
||||
res |= (UP | LEFT);
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_TOPRIGHT)
|
||||
res |= (UP | RIGHT);
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)
|
||||
res |= (DOWN | LEFT);
|
||||
else if (direction == _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT)
|
||||
res |= (DOWN | RIGHT);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
WMMaskEvent(dpy, KeyPressMask | ButtonMotionMask
|
||||
| ButtonReleaseMask | PointerMotionHintMask | ButtonPressMask | ExposureMask, &event);
|
||||
@@ -2269,7 +2302,7 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event.xbutton.button != ev->xbutton.button)
|
||||
if (!wwin->moveresize.active && (event.xbutton.button != ev->xbutton.button))
|
||||
break;
|
||||
|
||||
if (started) {
|
||||
@@ -2291,6 +2324,11 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
||||
wWindowConfigure(wwin, fx, fy, fw, fh - vert_border);
|
||||
wWindowSynthConfigureNotify(wwin);
|
||||
}
|
||||
if (wwin->moveresize.active) {
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
wwin->moveresize.active = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user