Remove XEvent from frame callbacks (titlebar, resizebar, buttons)

All WFrameWindow callbacks (on_mousedown_titlebar, on_dblclick_titlebar,
on_mousedown_resizebar, on_click_left, on_click_right, on_dblclick_right)
now take WMEvent* instead of XEvent*. This fixes the crash when clicking
the menu titlebar in Wayland mode (_x11_raw was NULL).

Affected files: framewin.h, framewin.c, menu.c, window.c, dialog.c,
winspector.c. All verified X11-free with nm.
This commit is contained in:
Levi Neely 2026-05-13 17:27:02 +02:00
parent b248dd04a7
commit f2dfe4a4d0
6 changed files with 85 additions and 87 deletions

View File

@ -1146,7 +1146,7 @@ typedef struct {
static InfoPanel *infoPanel = NULL;
static void destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
static void destroyInfoPanel(WCoreWindow *foo, void *data, WMEvent *event)
{
/* Parameter not used, but tell the compiler that it is ok */
(void) foo;
@ -1513,7 +1513,7 @@ typedef struct {
static LegalPanel *legalPanel = NULL;
static void destroyLegalPanel(WCoreWindow * foo, void *data, XEvent * event)
static void destroyLegalPanel(WCoreWindow * foo, void *data, WMEvent * event)
{
/* Parameter not used, but tell the compiler that it is ok */
(void) foo;

View File

@ -1140,27 +1140,25 @@ static void handleButtonExpose(WObjDescriptor * desc, WBackendEvent * event)
static void titlebarMouseDown(WObjDescriptor * desc, WBackendEvent * event)
{
XEvent *xev = event->_x11_raw;
WFrameWindow *fwin = desc->parent;
WCoreWindow *titlebar = desc->self;
if (IsDoubleClick(fwin->core->screen_ptr, event)) {
if (fwin->on_dblclick_titlebar)
(*fwin->on_dblclick_titlebar) (titlebar, fwin->child, xev);
(*fwin->on_dblclick_titlebar) (titlebar, fwin->child, event);
} else {
if (fwin->on_mousedown_titlebar)
(*fwin->on_mousedown_titlebar) (titlebar, fwin->child, xev);
(*fwin->on_mousedown_titlebar) (titlebar, fwin->child, event);
}
}
static void resizebarMouseDown(WObjDescriptor * desc, WBackendEvent * event)
{
XEvent *xev = event->_x11_raw;
WFrameWindow *fwin = desc->parent;
WCoreWindow *resizebar = desc->self;
if (fwin->on_mousedown_resizebar)
(*fwin->on_mousedown_resizebar) (resizebar, fwin->child, xev);
(*fwin->on_mousedown_resizebar) (resizebar, fwin->child, event);
}
static void buttonMouseDown(WObjDescriptor * desc, WBackendEvent * event)
@ -1177,7 +1175,7 @@ static void buttonMouseDown(WObjDescriptor * desc, WBackendEvent * event)
if (IsDoubleClick(fwin->core->screen_ptr, event)) {
if (button == fwin->right_button && fwin->on_dblclick_right)
(*fwin->on_dblclick_right) (button, fwin->child, xev);
(*fwin->on_dblclick_right) (button, fwin->child, event);
return;
}
@ -1230,10 +1228,10 @@ static void buttonMouseDown(WObjDescriptor * desc, WBackendEvent * event)
if (execute) {
if (button == fwin->left_button) {
if (fwin->on_click_left)
(*fwin->on_click_left) (button, fwin->child, (XEvent *)ev._x11_raw);
(*fwin->on_click_left) (button, fwin->child, &ev);
} else if (button == fwin->right_button) {
if (fwin->on_click_right)
(*fwin->on_click_right) (button, fwin->child, (XEvent *)ev._x11_raw);
(*fwin->on_click_right) (button, fwin->child, &ev);
}
#ifdef XKB_BUTTON_HINT
else if (button == fwin->language_button) {

View File

@ -99,18 +99,18 @@ typedef struct WFrameWindow {
void *child;
/* callbacks */
void (*on_click_left)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_click_left)(WCoreWindow *sender, void *data, WMEvent *event);
#ifdef XKB_BUTTON_HINT
void (*on_click_language)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_click_language)(WCoreWindow *sender, void *data, WMEvent *event);
#endif
void (*on_click_right)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_dblclick_right)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_click_right)(WCoreWindow *sender, void *data, WMEvent *event);
void (*on_dblclick_right)(WCoreWindow *sender, void *data, WMEvent *event);
void (*on_mousedown_titlebar)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_dblclick_titlebar)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_mousedown_titlebar)(WCoreWindow *sender, void *data, WMEvent *event);
void (*on_dblclick_titlebar)(WCoreWindow *sender, void *data, WMEvent *event);
void (*on_mousedown_resizebar)(WCoreWindow *sender, void *data, XEvent *event);
void (*on_mousedown_resizebar)(WCoreWindow *sender, void *data, WMEvent *event);
struct {
unsigned int state:2; /* 3 possible states */

View File

@ -66,9 +66,9 @@ MENU_SCROLL_STEPS_US, MENU_SCROLL_DELAY_US}};
static void menuMouseDown(WObjDescriptor * desc, WBackendEvent * event);
static void menuExpose(WObjDescriptor * desc, WBackendEvent * event);
static void menuTitleDoubleClick(WCoreWindow * sender, void *data, XEvent * event);
static void menuTitleMouseDown(WCoreWindow * sender, void *data, XEvent * event);
static void menuCloseClick(WCoreWindow * sender, void *data, XEvent * event);
static void menuTitleDoubleClick(WCoreWindow * sender, void *data, WMEvent * event);
static void menuTitleMouseDown(WCoreWindow * sender, void *data, WMEvent * event);
static void menuCloseClick(WCoreWindow * sender, void *data, WMEvent * event);
static void updateTexture(WMenu * menu);
static int saveMenuRecurs(WMPropList * menus, WScreen * scr, WMenu * menu);
static int restoreMenuRecurs(WScreen *scr, WMPropList *menus, WMenu *menu, const char *path);
@ -1964,7 +1964,7 @@ static void changeMenuLevels(WMenu * menu, int lower)
}
}
static void menuTitleDoubleClick(WCoreWindow * sender, void *data, XEvent * event)
static void menuTitleDoubleClick(WCoreWindow * sender, void *data, WMEvent * event)
{
WMenu *menu = data;
int lower;
@ -1972,7 +1972,7 @@ static void menuTitleDoubleClick(WCoreWindow * sender, void *data, XEvent * even
/* Parameter not used, but tell the compiler that it is ok */
(void) sender;
if (event->xbutton.state & MOD_MASK) {
if (event->u.button.state & MOD_MASK) {
if (menu->flags.lowered) {
lower = 0;
} else {
@ -1991,13 +1991,13 @@ static void menuTitleDoubleClick(WCoreWindow * sender, void *data, XEvent * even
}
}
static void menuTitleMouseDown(WCoreWindow * sender, void *data, XEvent * event)
static void menuTitleMouseDown(WCoreWindow * sender, void *data, WMEvent * event)
{
WMenu *menu = data;
WMenu *tmp;
WMEvent ev;
int x = menu->frame_x, y = menu->frame_y;
int dx = event->xbutton.x_root, dy = event->xbutton.y_root;
int dx = event->u.button.x_root, dy = event->u.button.y_root;
int i, lower;
Bool started;
@ -2008,10 +2008,10 @@ static void menuTitleMouseDown(WCoreWindow * sender, void *data, XEvent * event)
if (menu->flags.brother)
return;
if (event->xbutton.button != Button1 && event->xbutton.button != Button2)
if (event->u.button.button != Button1 && event->u.button.button != Button2)
return;
if (event->xbutton.state & MOD_MASK) {
if (event->u.button.state & MOD_MASK) {
wLowerFrame(menu->frame->core);
lower = 1;
} else {
@ -2083,7 +2083,7 @@ static void menuTitleMouseDown(WCoreWindow * sender, void *data, XEvent * event)
break;
case WME_BUTTON_RELEASE:
if (ev.u.button.button != event->xbutton.button)
if (ev.u.button.button != event->u.button.button)
break;
wm_backend->pointer_ungrab(0);
return;
@ -2106,7 +2106,7 @@ static void menuTitleMouseDown(WCoreWindow * sender, void *data, XEvent * event)
* cascade list.
*----------------------------------------------------------------------
*/
static void menuCloseClick(WCoreWindow * sender, void *data, XEvent * event)
static void menuCloseClick(WCoreWindow * sender, void *data, WMEvent * event)
{
WMenu *menu = (WMenu *) data;
WMenu *parent = menu->parent;

View File

@ -80,19 +80,19 @@ static void setupGNUstepHints(WWindow *wwin, GNUstepWMAttributes *gs_hints);
static void frameMouseDown(WObjDescriptor *desc, WBackendEvent *event);
/* close button */
static void windowCloseClick(WCoreWindow *sender, void *data, XEvent *event);
static void windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event);
static void windowCloseClick(WCoreWindow *sender, void *data, WMEvent *event);
static void windowCloseDblClick(WCoreWindow *sender, void *data, WMEvent *event);
/* iconify button */
static void windowIconifyClick(WCoreWindow *sender, void *data, XEvent *event);
static void windowIconifyClick(WCoreWindow *sender, void *data, WMEvent *event);
#ifdef XKB_BUTTON_HINT
static void windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event);
#endif
static void titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event);
static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event);
static void resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event);
static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event);
static void titlebarDblClick(WCoreWindow *sender, void *data, WMEvent *event);
static void resizebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event);
static void release_wwindowstate(WWindowState *wstate);
@ -2564,7 +2564,7 @@ void wWindowSetOmnipresent(WWindow *wwin, Bool flag)
WMPostNotificationName(WMNChangedState, wwin, "omnipresent");
}
static void resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
static void resizebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event)
{
WWindow *wwin = data;
@ -2572,26 +2572,26 @@ static void resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
(void) sender;
#ifndef NUMLOCK_HACK
if ((event->xbutton.state & ValidModMask)
!= (event->xbutton.state & ~LockMask)) {
if ((event->u.button.state & ValidModMask)
!= (event->u.button.state & ~LockMask)) {
wwarning(_("The NumLock, ScrollLock or similar key seems to be turned on. "
"Turn it off or some mouse actions and keyboard shortcuts will not work."));
}
#endif
event->xbutton.state &= w_global.shortcut.modifiers_mask;
event->u.button.state &= w_global.shortcut.modifiers_mask;
CloseWindowMenu(wwin->screen_ptr);
if (wPreferences.focus_mode == WKF_CLICK && !(event->xbutton.state & ControlMask)
if (wPreferences.focus_mode == WKF_CLICK && !(event->u.button.state & ControlMask)
&& !WFLAGP(wwin, no_focusable)) {
wSetFocusTo(wwin->screen_ptr, wwin);
}
if (event->xbutton.button == Button1)
if (event->u.button.button == Button1)
wRaiseFrame(wwin->frame->core);
if (event->xbutton.window != wwin->frame->resizebar->window) {
if (event->u.button.window != wwin->frame->resizebar->window) {
if (!wm_backend->pointer_grab(wwin->frame->resizebar->window, WNATIVE_NONE,
ButtonMotionMask | ButtonReleaseMask | ButtonPressMask,
WCUR_NONE, 1, 0)) {
@ -2599,27 +2599,27 @@ static void resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
}
}
if (event->xbutton.state & MOD_MASK) {
if (event->u.button.state & MOD_MASK) {
/* move the window */
wMouseMoveWindow(wwin, event);
wMouseMoveWindow(wwin, (XEvent*)event);
wm_backend->pointer_ungrab(0);
} else {
wMouseResizeWindow(wwin, event);
wMouseResizeWindow(wwin, (XEvent*)event);
wm_backend->pointer_ungrab(0);
}
}
static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
static void titlebarDblClick(WCoreWindow *sender, void *data, WMEvent *event)
{
WWindow *wwin = data;
/* Parameter not used, but tell the compiler that it is ok */
(void) sender;
event->xbutton.state &= w_global.shortcut.modifiers_mask;
event->u.button.state &= w_global.shortcut.modifiers_mask;
if (event->xbutton.button == Button1 ) {
if (event->xbutton.state == 0 ) {
if (event->u.button.button == Button1 ) {
if (event->u.button.state == 0 ) {
if (!WFLAGP(wwin, no_shadeable) & !wPreferences.double_click_fullscreen) {
/* shade window */
if (wwin->flags.shaded)
@ -2632,7 +2632,7 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
if (wPreferences.double_click_fullscreen) {
int dir = 0;
if (event->xbutton.state == 0) {
if (event->u.button.state == 0) {
/* maximize window full screen*/
dir |= (MAX_VERTICAL|MAX_HORIZONTAL);
int ndir = dir ^ wwin->flags.maximized;
@ -2644,12 +2644,12 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
} else {
int dir = 0;
if (event->xbutton.state & ControlMask)
if (event->u.button.state & ControlMask)
dir |= MAX_VERTICAL;
if (event->xbutton.state & ShiftMask) {
if (event->u.button.state & ShiftMask) {
dir |= MAX_HORIZONTAL;
if (!(event->xbutton.state & ControlMask))
if (!(event->u.button.state & ControlMask))
wSelectWindow(wwin, !wwin->flags.selected);
}
@ -2663,14 +2663,14 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
wUnmaximizeWindow(wwin);
}
}
} else if (event->xbutton.button == Button3) {
if (event->xbutton.state & MOD_MASK)
} else if (event->u.button.button == Button3) {
if (event->u.button.state & MOD_MASK)
wHideOtherApplications(wwin);
} else if (event->xbutton.button == Button2) {
} else if (event->u.button.button == Button2) {
wSelectWindow(wwin, !wwin->flags.selected);
} else if (event->xbutton.button == W_getconf_mouseWheelUp()) {
} else if (event->u.button.button == W_getconf_mouseWheelUp()) {
wShadeWindow(wwin);
} else if (event->xbutton.button == W_getconf_mouseWheelDown()) {
} else if (event->u.button.button == W_getconf_mouseWheelDown()) {
wUnshadeWindow(wwin);
}
}
@ -2742,7 +2742,7 @@ static void frameMouseDown(WObjDescriptor *desc, WBackendEvent *event)
}
}
static void titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event)
{
WWindow *wwin = (WWindow *) data;
@ -2750,32 +2750,32 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
(void) sender;
#ifndef NUMLOCK_HACK
if ((event->xbutton.state & ValidModMask) != (event->xbutton.state & ~LockMask))
if ((event->u.button.state & ValidModMask) != (event->u.button.state & ~LockMask))
wwarning(_("The NumLock, ScrollLock or similar key seems to be turned on. "
"Turn it off or some mouse actions and keyboard shortcuts will not work."));
#endif
event->xbutton.state &= w_global.shortcut.modifiers_mask;
event->u.button.state &= w_global.shortcut.modifiers_mask;
CloseWindowMenu(wwin->screen_ptr);
if (wPreferences.focus_mode == WKF_CLICK && !(event->xbutton.state & ControlMask)
if (wPreferences.focus_mode == WKF_CLICK && !(event->u.button.state & ControlMask)
&& !WFLAGP(wwin, no_focusable))
wSetFocusTo(wwin->screen_ptr, wwin);
if (event->xbutton.button == Button1 || event->xbutton.button == Button2) {
if (event->u.button.button == Button1 || event->u.button.button == Button2) {
if (event->xbutton.button == Button1) {
if (event->xbutton.state & MOD_MASK)
if (event->u.button.button == Button1) {
if (event->u.button.state & MOD_MASK)
wLowerFrame(wwin->frame->core);
else
wRaiseFrame(wwin->frame->core);
}
if ((event->xbutton.state & ShiftMask)
&& !(event->xbutton.state & ControlMask)) {
if ((event->u.button.state & ShiftMask)
&& !(event->u.button.state & ControlMask)) {
wSelectWindow(wwin, !wwin->flags.selected);
return;
}
if (event->xbutton.window != wwin->frame->titlebar->window
if (event->u.button.window != wwin->frame->titlebar->window
&& !wm_backend->pointer_grab(wwin->frame->titlebar->window, WNATIVE_NONE,
ButtonMotionMask | ButtonReleaseMask | ButtonPressMask,
WCUR_NONE, 0, 0)) {
@ -2783,50 +2783,50 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
}
/* move the window */
wMouseMoveWindow(wwin, event);
wMouseMoveWindow(wwin, (XEvent*)event);
wm_backend->pointer_ungrab(0);
} else if (event->xbutton.button == Button3 && event->xbutton.state == 0
} else if (event->u.button.button == Button3 && event->u.button.state == 0
&& !wwin->flags.internal_window && !WCHECK_STATE(WSTATE_MODAL)) {
WObjDescriptor *desc;
if (event->xbutton.window != wwin->frame->titlebar->window
if (event->u.button.window != wwin->frame->titlebar->window
&& !wm_backend->pointer_grab(wwin->frame->titlebar->window, WNATIVE_NONE,
ButtonMotionMask | ButtonReleaseMask | ButtonPressMask,
WCUR_NONE, 0, 0)) {
return;
}
OpenWindowMenu(wwin, event->xbutton.x_root, wwin->frame_y + wwin->frame->top_width, False);
OpenWindowMenu(wwin, event->u.button.x_root, wwin->frame_y + wwin->frame->top_width, False);
/* allow drag select */
desc = &wwin->screen_ptr->window_menu->menu->descriptor;
event->xany.send_event = True;
{ WBackendEvent bev; x11_translate_event(event, &bev); (*desc->handle_mousedown) (desc, &bev); }
event->u.button.send_event = True;
(*desc->handle_mousedown)(desc, event);
wm_backend->pointer_ungrab(0);
}
}
static void windowCloseClick(WCoreWindow *sender, void *data, XEvent *event)
static void windowCloseClick(WCoreWindow *sender, void *data, WMEvent *event)
{
WWindow *wwin = data;
/* Parameter not used, but tell the compiler that it is ok */
(void) sender;
event->xbutton.state &= w_global.shortcut.modifiers_mask;
event->u.button.state &= w_global.shortcut.modifiers_mask;
CloseWindowMenu(wwin->screen_ptr);
if (event->xbutton.button < Button1 || event->xbutton.button > Button3)
if (event->u.button.button < Button1 || event->u.button.button > Button3)
return;
/* if control-click, kill the client */
if (event->xbutton.state & ControlMask) {
if (event->u.button.state & ControlMask) {
wClientKill(wwin);
} else {
if (wwin->protocols.DELETE_WINDOW && event->xbutton.state == 0) {
if (wwin->protocols.DELETE_WINDOW && event->u.button.state == 0) {
/* send delete message */
wClientSendProtocol(wwin, w_global.atom.wm.delete_window,
w_global.timestamp.last_event);
@ -2834,7 +2834,7 @@ static void windowCloseClick(WCoreWindow *sender, void *data, XEvent *event)
}
}
static void windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event)
static void windowCloseDblClick(WCoreWindow *sender, void *data, WMEvent *event)
{
WWindow *wwin = data;
@ -2843,7 +2843,7 @@ static void windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event)
CloseWindowMenu(wwin->screen_ptr);
if (event->xbutton.button < Button1 || event->xbutton.button > Button3)
if (event->u.button.button < Button1 || event->u.button.button > Button3)
return;
/* send delete message */
@ -2880,31 +2880,31 @@ static void windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event)
}
#endif
static void windowIconifyClick(WCoreWindow *sender, void *data, XEvent *event)
static void windowIconifyClick(WCoreWindow *sender, void *data, WMEvent *event)
{
WWindow *wwin = data;
/* Parameter not used, but tell the compiler that it is ok */
(void) sender;
event->xbutton.state &= w_global.shortcut.modifiers_mask;
event->u.button.state &= w_global.shortcut.modifiers_mask;
CloseWindowMenu(wwin->screen_ptr);
if (event->xbutton.button < Button1 || event->xbutton.button > Button3)
if (event->u.button.button < Button1 || event->u.button.button > Button3)
return;
if (wwin->protocols.MINIATURIZE_WINDOW && event->xbutton.state == 0) {
if (wwin->protocols.MINIATURIZE_WINDOW && event->u.button.state == 0) {
wClientSendProtocol(wwin, w_global.atom.gnustep.wm_miniaturize_window,
w_global.timestamp.last_event);
} else {
WApplication *wapp;
if ((event->xbutton.state & ControlMask) || (event->xbutton.button == Button3)) {
if ((event->u.button.state & ControlMask) || (event->u.button.button == Button3)) {
wapp = wApplicationOf(wwin->main_window);
if (wapp && !WFLAGP(wwin, no_appicon))
wHideApplication(wapp);
} else if (event->xbutton.state == 0) {
} else if (event->u.button.state == 0) {
wIconifyWindow(wwin);
}
}

View File

@ -351,7 +351,7 @@ static void freeInspector(InspectorPanel *panel)
wfree(panel);
}
static void destroyInspector(WCoreWindow *foo, void *data, XEvent *event)
static void destroyInspector(WCoreWindow *foo, void *data, WMEvent *event)
{
InspectorPanel *panel, *tmp;