moveres: replace XEvent with WMEvent in move/resize functions
wMouseMoveWindow and wMouseResizeWindow took XEvent* but were being passed WMEvent* via casts. The XEvent union layout differs completely from WMEvent, so ev->xmotion.x_root read garbage — causing the window to jump to a wrong position and the move to become uncontrollable. Changed both functions to take WMEvent*, accessing ev->u.button fields directly. Removes all XEvent references from the core policy layer (zero backend-specific types in the middle).
This commit is contained in:
parent
c47fc49290
commit
57536b9991
|
|
@ -42,10 +42,10 @@
|
|||
|
||||
void wSetFocusTo(WScreen *scr, WWindow *wwin);
|
||||
|
||||
int wMouseMoveWindow(WWindow *wwin, XEvent *ev);
|
||||
int wMouseMoveWindow(WWindow *wwin, WMEvent *ev);
|
||||
int wKeyboardMoveResizeWindow(WWindow *wwin);
|
||||
|
||||
void wMouseResizeWindow(WWindow *wwin, XEvent *ev);
|
||||
void wMouseResizeWindow(WWindow *wwin, WMEvent *ev);
|
||||
|
||||
void wShadeWindow(WWindow *wwin);
|
||||
void wUnshadeWindow(WWindow *wwin);
|
||||
|
|
|
|||
|
|
@ -1692,7 +1692,7 @@ int wKeyboardMoveResizeWindow(WWindow * wwin)
|
|||
* The position display configuration may be changed.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
int wMouseMoveWindow(WWindow * wwin, XEvent * ev)
|
||||
int wMouseMoveWindow(WWindow * wwin, WMEvent * ev)
|
||||
{
|
||||
WScreen *scr = wwin->screen_ptr;
|
||||
WMEvent event;
|
||||
|
|
@ -1719,8 +1719,8 @@ int wMouseMoveWindow(WWindow * wwin, XEvent * ev)
|
|||
|
||||
initMoveData(wwin, &moveData);
|
||||
|
||||
moveData.mouseX = ev->xmotion.x_root;
|
||||
moveData.mouseY = ev->xmotion.y_root;
|
||||
moveData.mouseX = ev->u.button.x_root;
|
||||
moveData.mouseY = ev->u.button.y_root;
|
||||
|
||||
if (!wwin->flags.selected) {
|
||||
/* this window is not selected, unselect others and move only wwin */
|
||||
|
|
@ -1845,8 +1845,8 @@ int wMouseMoveWindow(WWindow * wwin, XEvent * ev)
|
|||
} else {
|
||||
warped = 0;
|
||||
}
|
||||
} else if (abs(ev->xmotion.x_root - event.u.motion.x_root) >= MOVE_THRESHOLD
|
||||
|| abs(ev->xmotion.y_root - event.u.motion.y_root) >= MOVE_THRESHOLD) {
|
||||
} else if (abs(ev->u.button.x_root - event.u.motion.x_root) >= MOVE_THRESHOLD
|
||||
|| abs(ev->u.button.y_root - event.u.motion.y_root) >= MOVE_THRESHOLD) {
|
||||
|
||||
if (wwin->flags.maximized) {
|
||||
if (wPreferences.drag_maximized_window == DRAGMAX_RESTORE) {
|
||||
|
|
@ -1895,7 +1895,7 @@ int wMouseMoveWindow(WWindow * wwin, XEvent * ev)
|
|||
break;
|
||||
|
||||
case WME_BUTTON_RELEASE:
|
||||
if (event.u.button.button != ev->xbutton.button)
|
||||
if (event.u.button.button != ev->u.button.button)
|
||||
break;
|
||||
|
||||
if (started) {
|
||||
|
|
@ -2028,7 +2028,7 @@ static int getResizeDirection(WWindow * wwin, int x, int y, int dy, int flags)
|
|||
return dir;
|
||||
}
|
||||
|
||||
void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
||||
void wMouseResizeWindow(WWindow * wwin, WMEvent * ev)
|
||||
{
|
||||
WMEvent event;
|
||||
WScreen *scr = wwin->screen_ptr;
|
||||
|
|
@ -2042,7 +2042,7 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
|||
int fh = wwin->frame->core->height;
|
||||
int fx = wwin->frame_x;
|
||||
int fy = wwin->frame_y;
|
||||
int is_resizebar = (wwin->frame->resizebar && ev->xany.window == wwin->frame->resizebar->window);
|
||||
int is_resizebar = (wwin->frame->resizebar && ev->u.button.window == wwin->frame->resizebar->window);
|
||||
int orig_x, orig_y;
|
||||
int started;
|
||||
int dw, dh;
|
||||
|
|
@ -2068,8 +2068,8 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
|||
wwarning("internal error: tryein");
|
||||
return;
|
||||
}
|
||||
orig_x = ev->xbutton.x_root;
|
||||
orig_y = ev->xbutton.y_root;
|
||||
orig_x = ev->u.button.x_root;
|
||||
orig_y = ev->u.button.y_root;
|
||||
|
||||
started = 0;
|
||||
wUnselectWindows(scr);
|
||||
|
|
@ -2152,7 +2152,7 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
|||
else
|
||||
flags = 0;
|
||||
|
||||
if (is_resizebar && ((ev->xbutton.state & ShiftMask)
|
||||
if (is_resizebar && ((ev->u.button.state & ShiftMask)
|
||||
|| abs(orig_y - event.u.motion.y_root) < HRESIZE_THRESHOLD))
|
||||
flags |= HCONSTRAIN;
|
||||
|
||||
|
|
@ -2235,7 +2235,7 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
|
|||
break;
|
||||
|
||||
case WME_BUTTON_RELEASE:
|
||||
if (event.u.button.button != ev->xbutton.button)
|
||||
if (event.u.button.button != ev->u.button.button)
|
||||
break;
|
||||
|
||||
if (started) {
|
||||
|
|
|
|||
11
src/window.c
11
src/window.c
|
|
@ -2590,10 +2590,10 @@ static void resizebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event)
|
|||
|
||||
if (event->u.button.state & MOD_MASK) {
|
||||
/* move the window */
|
||||
wMouseMoveWindow(wwin, (XEvent*)event);
|
||||
wMouseMoveWindow(wwin, event);
|
||||
wm_backend->pointer_ungrab(0);
|
||||
} else {
|
||||
wMouseResizeWindow(wwin, (XEvent*)event);
|
||||
wMouseResizeWindow(wwin, event);
|
||||
wm_backend->pointer_ungrab(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -2666,7 +2666,6 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, WMEvent *event)
|
|||
|
||||
static void frameMouseDown(WObjDescriptor *desc, WBackendEvent *event)
|
||||
{
|
||||
XEvent *xev = event->_x11_raw;
|
||||
WWindow *wwin = desc->parent;
|
||||
unsigned int new_width, w_scale;
|
||||
unsigned int new_height, h_scale;
|
||||
|
|
@ -2715,7 +2714,7 @@ static void frameMouseDown(WObjDescriptor *desc, WBackendEvent *event)
|
|||
return;
|
||||
}
|
||||
if (event->u.button.button == Button3) {
|
||||
wMouseResizeWindow(wwin, xev);
|
||||
wMouseResizeWindow(wwin, event);
|
||||
} else if (event->u.button.button == Button4) {
|
||||
new_height = wwin->client.height - resize_height_increment;
|
||||
wWindowConstrainSize(wwin, &wwin->client.width, &new_height);
|
||||
|
|
@ -2725,7 +2724,7 @@ static void frameMouseDown(WObjDescriptor *desc, WBackendEvent *event)
|
|||
wWindowConstrainSize(wwin, &wwin->client.width, &new_height);
|
||||
wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, wwin->client.width, new_height);
|
||||
} else if (event->u.button.button == Button1 || event->u.button.button == Button2) {
|
||||
wMouseMoveWindow(wwin, xev);
|
||||
wMouseMoveWindow(wwin, event);
|
||||
}
|
||||
wm_backend->pointer_ungrab(0);
|
||||
}
|
||||
|
|
@ -2772,7 +2771,7 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event)
|
|||
}
|
||||
|
||||
/* move the window */
|
||||
wMouseMoveWindow(wwin, (XEvent*)event);
|
||||
wMouseMoveWindow(wwin, event);
|
||||
|
||||
wm_backend->pointer_ungrab(0);
|
||||
} else if (event->u.button.button == Button3 && event->u.button.state == 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue