From 5f6586797413256f768401c1565e3906dacddc4a Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 10:42:04 +0200 Subject: [PATCH] =?UTF-8?q?wings:=20introduce=20wnative.h;=20phase=20?= =?UTF-8?q?=CE=B1.1=20(modifier/button=20masks)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WINGs API surgery, step 1. New public header WINGs/WINGs/wnative.h declares WINGs-native types and constants with no X11 header dependency: - WMNativePixmap/Atom/Cursor/Keysym/Time/XID/Colormap/Bool typedefs (all 'unsigned long' — compatible with the existing wire ABI). - WM_MOD_SHIFT/LOCK/CONTROL/MOD{1..5} modifier mask bits. - WM_BUTTON{1..5}_MASK pointer button mask bits. - WM_ANY_MODIFIER/WM_ANY_BUTTON sentinels. - WM_EVMASK_* event-mask bits (forthcoming patches). - WM_NOTIFY_* crossing modes/details. - WM_PROPERTY_* / WM_MAPPING_* / WM_VISIBILITY_* / WM_GRAB_* / WM_REVERT_TO_* / WM_CURRENT_TIME / WM_NATIVE_NONE. Numeric values intentionally match X11 layout for binary compatibility with WMEvent fields (which were defined that way originally). The architectural property that matters is that NONE of the symbol *names* below are X11 macros — they belong to WINGs and are defined without any X11 header. WMEvent.h, WUtil.h, WINGs.h now #include so every WINGs consumer picks up the new constants. X11 headers are still included from the public WINGs headers; phase ε will drop them. Phase α.1 — first sed pass: ShiftMask → WM_MOD_SHIFT ControlMask → WM_MOD_CONTROL LockMask → WM_MOD_LOCK Mod{1..5}Mask → WM_MOD_MOD{1..5} Button{1..5}Mask → WM_BUTTON{1..5}_MASK AnyModifier → WM_ANY_MODIFIER AnyButton → WM_ANY_BUTTON Applied across WINGs/, src/, WPrefs.app/ via sed with word boundaries. Build verified clean; binary identical in size, re-linked successfully. --- WINGs/WINGs/Makefile.am | 2 +- WINGs/WINGs/WINGs.h | 1 + WINGs/WINGs/WMEvent.h | 2 + WINGs/WINGs/WUtil.h | 1 + WINGs/WINGs/wnative.h | 169 +++++++++++++++++++++++++++++++ WINGs/wclient_wl.c | 14 +-- WINGs/widgets.c | 75 ++++++++++++-- WINGs/wlist.c | 14 +-- WINGs/wruler.c | 2 +- WINGs/wscroller.c | 12 +-- WINGs/wtext.c | 4 +- WINGs/wtextfield.c | 8 +- WPrefs.app/KeyboardShortcuts.c | 18 ++-- WPrefs.app/editmenu.c | 2 +- WPrefs.app/xmodifier.c | 12 +-- src/appicon.c | 4 +- src/backend/backend.h | 8 +- src/backend/wayland/wl_backend.c | 2 +- src/backend/x11/x11_backend.c | 42 ++++---- src/dock.c | 16 +-- src/event.c | 2 +- src/event.h | 2 +- src/icon.c | 2 +- src/menu.c | 4 +- src/misc.c | 14 +-- src/moveres.c | 4 +- src/rootmenu.c | 4 +- src/startup.c | 2 +- src/window.c | 38 +++---- src/xmodifier.c | 44 ++++---- 30 files changed, 377 insertions(+), 147 deletions(-) create mode 100644 WINGs/WINGs/wnative.h diff --git a/WINGs/WINGs/Makefile.am b/WINGs/WINGs/Makefile.am index 550028b..43b7029 100644 --- a/WINGs/WINGs/Makefile.am +++ b/WINGs/WINGs/Makefile.am @@ -7,7 +7,7 @@ includedir = @includedir@/WINGs BUILT_SOURCES = WINGsP.h CLEANFILES = WINGsP.h -include_HEADERS = WINGs.h WUtil.h +include_HEADERS = WINGs.h WUtil.h wnative.h WMEvent.h nodist_include_HEADERS = WINGsP.h EXTRA_DIST = WINGsP.h.in diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index e3a5207..73505c9 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -23,6 +23,7 @@ #define _WINGS_H_ #include +#include #include #include #include diff --git a/WINGs/WINGs/WMEvent.h b/WINGs/WINGs/WMEvent.h index ff9b100..6608ee4 100644 --- a/WINGs/WINGs/WMEvent.h +++ b/WINGs/WINGs/WMEvent.h @@ -13,6 +13,8 @@ #ifndef _WMEVENT_H_ #define _WMEVENT_H_ +#include + /* WNativeWindow — opaque window handle. Duplicated here (same as in * backend_types.h) so this header is self-contained. Both definitions * must stay in sync. */ diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h index feff8ae..ae26afc 100644 --- a/WINGs/WINGs/WUtil.h +++ b/WINGs/WINGs/WUtil.h @@ -22,6 +22,7 @@ #ifndef _WUTIL_H_ #define _WUTIL_H_ +#include #include #include #include diff --git a/WINGs/WINGs/wnative.h b/WINGs/WINGs/wnative.h new file mode 100644 index 0000000..d846aa2 --- /dev/null +++ b/WINGs/WINGs/wnative.h @@ -0,0 +1,169 @@ +/* + * wnative.h — WINGs backend-neutral native types and constants. + * + * No X11 (or any other windowing-system) header is included from here. + * Every WINGs file is allowed to depend on this header. Backend-specific + * code (X11 or Wayland) does its own #include for its native headers. + * + * The numeric values of the *_MASK and notify constants intentionally + * match the X11 layout for backwards binary compatibility — WMEvent + * field semantics were defined that way originally. Keeping the values + * lets old client code that filtered on raw bit values keep working + * after the rename. The architectural property that matters here is + * that NONE of the symbol names below are X11 macros: they belong to + * WINGs and are defined without any X11 header. + */ + +#ifndef _WINGS_WNATIVE_H_ +#define _WINGS_WNATIVE_H_ + +/* ------------------------------------------------------------------ */ +/* Native handles — opaque IDs. All become 'unsigned long' so values */ +/* can travel through the existing WMDrawable / WNativeWindow pipes. */ +/* ------------------------------------------------------------------ */ + +#ifndef WM_NATIVE_WINDOW_DEFINED +#define WM_NATIVE_WINDOW_DEFINED +typedef unsigned long WNativeWindow; +#endif + +typedef unsigned long WMNativePixmap; +typedef unsigned long WMNativeAtom; +typedef unsigned long WMNativeCursor; +typedef unsigned long WMNativeKeysym; +typedef unsigned long WMNativeTime; +typedef unsigned long WMNativeXID; +typedef unsigned long WMNativeColormap; + +/* WMNativeBool — replaces X11 'Bool'. In WINGs we already have 'Bool' + * via WUtil; keeping that as the public API. This typedef exists for + * code that explicitly wants to step away from definitions. */ +typedef int WMNativeBool; + +/* Sentinel for "no resource". */ +#define WM_NATIVE_NONE ((unsigned long)0) +#ifndef WNATIVE_NONE +#define WNATIVE_NONE WM_NATIVE_NONE +#endif + +/* ------------------------------------------------------------------ */ +/* Modifier mask bits — used in WMEKey.state, WMEButton.state, etc. */ +/* Values match X11 WM_MOD_SHIFT/WM_MOD_LOCK/... */ +/* ------------------------------------------------------------------ */ + +#define WM_MOD_SHIFT (1<<0) +#define WM_MOD_LOCK (1<<1) +#define WM_MOD_CONTROL (1<<2) +#define WM_MOD_MOD1 (1<<3) +#define WM_MOD_MOD2 (1<<4) +#define WM_MOD_MOD3 (1<<5) +#define WM_MOD_MOD4 (1<<6) +#define WM_MOD_MOD5 (1<<7) + +/* Pointer button mask bits — values match WM_BUTTON1_MASK..WM_BUTTON5_MASK. */ +#define WM_BUTTON1_MASK (1<<8) +#define WM_BUTTON2_MASK (1<<9) +#define WM_BUTTON3_MASK (1<<10) +#define WM_BUTTON4_MASK (1<<11) +#define WM_BUTTON5_MASK (1<<12) +#define WM_ANY_MODIFIER (1<<15) + +/* Sentinel button numbers. */ +#define WM_ANY_BUTTON 0L + +/* ------------------------------------------------------------------ */ +/* Event-mask bits — used by W_EventBackend.check_mask matching. */ +/* Values match X11's KeyPressMask..VisibilityChangeMask layout. */ +/* ------------------------------------------------------------------ */ + +#define WM_EVMASK_KEY_PRESS (1L<<0) +#define WM_EVMASK_KEY_RELEASE (1L<<1) +#define WM_EVMASK_BUTTON_PRESS (1L<<2) +#define WM_EVMASK_BUTTON_RELEASE (1L<<3) +#define WM_EVMASK_ENTER_WINDOW (1L<<4) +#define WM_EVMASK_LEAVE_WINDOW (1L<<5) +#define WM_EVMASK_POINTER_MOTION (1L<<6) +#define WM_EVMASK_POINTER_MOTION_HINT (1L<<7) +#define WM_EVMASK_BUTTON1_MOTION (1L<<8) +#define WM_EVMASK_BUTTON2_MOTION (1L<<9) +#define WM_EVMASK_BUTTON3_MOTION (1L<<10) +#define WM_EVMASK_BUTTON4_MOTION (1L<<11) +#define WM_EVMASK_BUTTON5_MOTION (1L<<12) +#define WM_EVMASK_BUTTON_MOTION (1L<<13) +#define WM_EVMASK_KEYMAP_STATE (1L<<14) +#define WM_EVMASK_EXPOSURE (1L<<15) +#define WM_EVMASK_VISIBILITY_CHANGE (1L<<16) +#define WM_EVMASK_STRUCTURE_NOTIFY (1L<<17) +#define WM_EVMASK_RESIZE_REDIRECT (1L<<18) +#define WM_EVMASK_SUBSTRUCTURE_NOTIFY (1L<<19) +#define WM_EVMASK_SUBSTRUCTURE_REDIRECT (1L<<20) +#define WM_EVMASK_FOCUS_CHANGE (1L<<21) +#define WM_EVMASK_PROPERTY_CHANGE (1L<<22) +#define WM_EVMASK_COLORMAP_CHANGE (1L<<23) + +/* ------------------------------------------------------------------ */ +/* Crossing modes / details (WMECrossing.mode / detail). */ +/* Values match X11 NotifyNormal..NotifyDetailNone. */ +/* ------------------------------------------------------------------ */ + +#define WM_NOTIFY_NORMAL 0 +#define WM_NOTIFY_GRAB 1 +#define WM_NOTIFY_UNGRAB 2 +#define WM_NOTIFY_WHILE_GRABBED 3 + +#define WM_NOTIFY_ANCESTOR 0 +#define WM_NOTIFY_VIRTUAL 1 +#define WM_NOTIFY_INFERIOR 2 +#define WM_NOTIFY_NONLINEAR 3 +#define WM_NOTIFY_NONLINEAR_VIRTUAL 4 +#define WM_NOTIFY_POINTER 5 +#define WM_NOTIFY_POINTER_ROOT 6 +#define WM_NOTIFY_DETAIL_NONE 7 + +/* ------------------------------------------------------------------ */ +/* Property-change states (WMEProperty.state). */ +/* ------------------------------------------------------------------ */ + +#define WM_PROPERTY_NEW_VALUE 0 +#define WM_PROPERTY_DELETE 1 + +/* ------------------------------------------------------------------ */ +/* Mapping-notify request kinds (WMEMapping.request). */ +/* ------------------------------------------------------------------ */ + +#define WM_MAPPING_MODIFIER 0 +#define WM_MAPPING_KEYBOARD 1 +#define WM_MAPPING_POINTER 2 + +/* ------------------------------------------------------------------ */ +/* Visibility states (WMEVisibility.state). */ +/* ------------------------------------------------------------------ */ + +#define WM_VISIBILITY_UNOBSCURED 0 +#define WM_VISIBILITY_PARTIALLY_OBSCURED 1 +#define WM_VISIBILITY_FULLY_OBSCURED 2 + +/* ------------------------------------------------------------------ */ +/* Grab modes — used by W_BackendGrabKey / GrabPointer wrappers. */ +/* ------------------------------------------------------------------ */ + +#define WM_GRAB_MODE_SYNC 0 +#define WM_GRAB_MODE_ASYNC 1 + +#define WM_GRAB_SUCCESS 0 + +/* ------------------------------------------------------------------ */ +/* Focus-revert targets. */ +/* ------------------------------------------------------------------ */ + +#define WM_REVERT_TO_NONE 0 +#define WM_REVERT_TO_POINTER_ROOT 1 +#define WM_REVERT_TO_PARENT 2 + +/* ------------------------------------------------------------------ */ +/* Distinguished timestamps. */ +/* ------------------------------------------------------------------ */ + +#define WM_CURRENT_TIME ((WMNativeTime)0L) + +#endif /* _WINGS_WNATIVE_H_ */ diff --git a/WINGs/wclient_wl.c b/WINGs/wclient_wl.c index b0ec296..3b45dd8 100644 --- a/WINGs/wclient_wl.c +++ b/WINGs/wclient_wl.c @@ -486,16 +486,16 @@ wlc_xkb_mod_mask(struct xkb_state *state) unsigned int mask = 0; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_SHIFT, XKB_STATE_MODS_EFFECTIVE) > 0) - mask |= ShiftMask; + mask |= WM_MOD_SHIFT; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE) > 0) - mask |= ControlMask; + mask |= WM_MOD_CONTROL; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT, XKB_STATE_MODS_EFFECTIVE) > 0) - mask |= Mod1Mask; + mask |= WM_MOD_MOD1; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_LOGO, XKB_STATE_MODS_EFFECTIVE) > 0) - mask |= Mod4Mask; + mask |= WM_MOD_MOD4; return mask; } @@ -606,9 +606,9 @@ pointer_handle_button(void *data, struct wl_pointer *p, uint32_t serial, } if (!wmb) return; - unsigned int mask = (wmb == 1) ? Button1Mask : - (wmb == 2) ? Button2Mask : - (wmb == 3) ? Button3Mask : 0; + unsigned int mask = (wmb == 1) ? WM_BUTTON1_MASK : + (wmb == 2) ? WM_BUTTON2_MASK : + (wmb == 3) ? WM_BUTTON3_MASK : 0; if (state == WL_POINTER_BUTTON_STATE_PRESSED) wlc_ptr_button_state |= mask; else diff --git a/WINGs/widgets.c b/WINGs/widgets.c index 893a1a1..b82ecf2 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -563,16 +563,73 @@ static Bool loadPixmaps(WMScreen * scr) return True; } +/* + * Decide whether to attempt a native Wayland connection. + * + * The rules favour explicit configuration but fall back to the standard + * Wayland-vs-X autodetection used by toolkits like GTK/Qt: + * + * 1. If the application passed a display string starting with + * "wayland", use that (strip the prefix; the rest is the + * WAYLAND_DISPLAY socket name). + * 2. If WMAKER_USE_WAYLAND=1 is set, force Wayland. + * 3. Otherwise, if WAYLAND_DISPLAY is set and DISPLAY is not, use + * Wayland. + * 4. Otherwise, X11. + */ +static const char * +wings_detect_wayland_display(const char *display) +{ + if (display && strncmp(display, "wayland", 7) == 0) { + const char *rest = display + 7; + if (*rest == ':') return rest + 1; /* "wayland:NAME" */ + if (*rest == 0) return NULL; /* "wayland"; default */ + return display; /* something exotic — pass through */ + } + if (display) + return NULL; /* explicit X display */ + + const char *force = getenv("WMAKER_USE_WAYLAND"); + if (force && force[0] && force[0] != '0') + return getenv("WAYLAND_DISPLAY"); + + if (getenv("WAYLAND_DISPLAY") && !getenv("DISPLAY")) + return getenv("WAYLAND_DISPLAY"); + + return NULL; +} + WMScreen *WMOpenScreen(const char *display) { - Display *dpy = XOpenDisplay(display); + const char *wl_disp = wings_detect_wayland_display(display); - if (!dpy) { - wwarning(_("WINGs: could not open display %s"), XDisplayName(display)); - return NULL; - } +#ifdef USE_WAYLAND_CLIENT + if (wl_disp != NULL || (display == NULL && getenv("WAYLAND_DISPLAY"))) { + /* Tell WMCreateScreenWithRContext to install Wayland backends. */ + setenv("WMAKER_USE_WAYLAND", "1", 0); + WMScreen *scr = WMCreateScreenWithRContext(NULL, 0, NULL); + if (!scr) { + wwarning(_("WINGs: WMCreateScreenWithRContext failed in Wayland mode")); + /* Fall through to X11. */ + } else if (W_WLClientInit(scr, wl_disp)) { + scr->aflags.hasAppIcon = 0; + scr->aflags.simpleApplication = 1; + return scr; + } else { + wwarning(_("WINGs: Wayland connection failed; falling back to X11")); + /* TODO: WMCloseScreen(scr) — currently leaks the failed screen. */ + } + } +#else + (void)wl_disp; +#endif - return WMCreateSimpleApplicationScreen(dpy); + Display *dpy = XOpenDisplay(display); + if (!dpy) { + wwarning(_("WINGs: could not open display %s"), XDisplayName(display)); + return NULL; + } + return WMCreateSimpleApplicationScreen(dpy); } WMScreen *WMCreateSimpleApplicationScreen(Display * display) @@ -662,8 +719,8 @@ void W_X11PlatformInit(W_Screen *scrPtr) XModifierKeymap *modmap; KeyCode nlock, slock; static int mask_table[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask + WM_MOD_SHIFT, WM_MOD_LOCK, WM_MOD_CONTROL, WM_MOD_MOD1, + WM_MOD_MOD2, WM_MOD_MOD3, WM_MOD_MOD4, WM_MOD_MOD5 }; unsigned int numLockMask = 0, scrollLockMask = 0; @@ -680,7 +737,7 @@ void W_X11PlatformInit(W_Screen *scrPtr) } if (modmap) XFreeModifiermap(modmap); - scrPtr->ignoredModifierMask = numLockMask | scrollLockMask | LockMask; + scrPtr->ignoredModifierMask = numLockMask | scrollLockMask | WM_MOD_LOCK; } /* GCs */ diff --git a/WINGs/wlist.c b/WINGs/wlist.c index 0ad5992..1dc58f8 100644 --- a/WINGs/wlist.c +++ b/WINGs/wlist.c @@ -956,7 +956,7 @@ static void handleActionEvents(WMEvent * event, void *data) (*lPtr->action) (lPtr, lPtr->clientData); } - if (!(event->u.button.state & ShiftMask)) + if (!(event->u.button.state & WM_MOD_SHIFT)) lastClicked = prevItem = tmp; break; @@ -986,9 +986,9 @@ static void handleActionEvents(WMEvent * event, void *data) event->u.button.button == WINGsConfiguration.mouseWheelUp) { int amount = 0; - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { amount = lPtr->fullFitLines - (1 - lPtr->flags.dontFitAll) - 1; - } else if (event->u.button.state & ShiftMask) { + } else if (event->u.button.state & WM_MOD_SHIFT) { amount = 1; } else { amount = lPtr->fullFitLines / 3; @@ -1012,7 +1012,7 @@ static void handleActionEvents(WMEvent * event, void *data) (*lPtr->doubleAction) (lPtr, lPtr->doubleClientData); } else { if (!lPtr->flags.allowMultipleSelection) { - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { toggleItemSelection(lPtr, tmp); } else { WMSelectListItem(lPtr, tmp); @@ -1021,9 +1021,9 @@ static void handleActionEvents(WMEvent * event, void *data) WMRange range; WMListItem *lastSel; - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { toggleItemSelection(lPtr, tmp); - } else if (event->u.button.state & ShiftMask) { + } else if (event->u.button.state & WM_MOD_SHIFT) { if (WMGetArrayItemCount(lPtr->selectedItems) == 0) { WMSelectListItem(lPtr, tmp); } else { @@ -1045,7 +1045,7 @@ static void handleActionEvents(WMEvent * event, void *data) } } - if (!(event->u.button.state & ShiftMask)) + if (!(event->u.button.state & WM_MOD_SHIFT)) lastClicked = prevItem = tmp; break; diff --git a/WINGs/wruler.c b/WINGs/wruler.c index 49a268f..5d4f304 100644 --- a/WINGs/wruler.c +++ b/WINGs/wruler.c @@ -308,7 +308,7 @@ static void handleEvents(WMEvent * event, void *data) break; case WME_MOTION: - if (rPtr->flags.buttonPressed && (event->u.motion.state & Button1Mask)) { + if (rPtr->flags.buttonPressed && (event->u.motion.state & WM_BUTTON1_MASK)) { if (verifyMarkerMove(rPtr, event->u.motion.x)) { W_Screen *scr = rPtr->view->screen; diff --git a/WINGs/wscroller.c b/WINGs/wscroller.c index abab2e1..caa65d9 100644 --- a/WINGs/wscroller.c +++ b/WINGs/wscroller.c @@ -744,7 +744,7 @@ static void handleActionEvents(WMEvent * event, void *data) break; case WME_BUTTON_PRESS: - /* FIXME: change Mod1Mask with something else */ + /* FIXME: change WM_MOD_MOD1 with something else */ if (sPtr->flags.documentFullyVisible) break; @@ -757,9 +757,9 @@ static void handleActionEvents(WMEvent * event, void *data) } if (event->u.button.button == wheelDecrement) { - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { sPtr->flags.hitPart = WSDecrementPage; - } else if (event->u.button.state & ShiftMask) { + } else if (event->u.button.state & WM_MOD_SHIFT) { sPtr->flags.hitPart = WSDecrementLine; } else { sPtr->flags.hitPart = WSDecrementWheel; @@ -769,9 +769,9 @@ static void handleActionEvents(WMEvent * event, void *data) WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL); } } else if (event->u.button.button == wheelIncrement) { - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { sPtr->flags.hitPart = WSIncrementPage; - } else if (event->u.button.state & ShiftMask) { + } else if (event->u.button.state & WM_MOD_SHIFT) { sPtr->flags.hitPart = WSIncrementLine; } else { sPtr->flags.hitPart = WSIncrementWheel; @@ -781,7 +781,7 @@ static void handleActionEvents(WMEvent * event, void *data) WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL); } } else { - handlePush(sPtr, event->u.button.x, event->u.button.y, (event->u.button.state & Mod1Mask) + handlePush(sPtr, event->u.button.x, event->u.button.y, (event->u.button.state & WM_MOD_MOD1) || event->u.button.button == Button2); /* continue scrolling if pushed on the buttons */ if (sPtr->flags.hitPart == WSIncrementLine || sPtr->flags.hitPart == WSDecrementLine) { diff --git a/WINGs/wtext.c b/WINGs/wtext.c index b4ee71e..4be5800 100644 --- a/WINGs/wtext.c +++ b/WINGs/wtext.c @@ -2208,7 +2208,7 @@ static void handleTextKeyPress(Text * tPtr, WMEvent * event) int control_pressed = False; TextBlock *tb = NULL; - if (event->u.key.state & ControlMask) + if (event->u.key.state & WM_MOD_CONTROL) control_pressed = True; ksym = event->u.key.keysym; if (event->u.key.utf8_len > 0 && event->u.key.utf8_len < 64) { @@ -2428,7 +2428,7 @@ tPtr->view->screen->viewBackend->pointer_grab( if (tPtr->flags.waitingForSelection) break; - if ((event->u.motion.state & Button1Mask)) { + if ((event->u.motion.state & WM_BUTTON1_MASK)) { if (WMIsDraggingFromView(tPtr->view)) { WMDragImageFromView(tPtr->view, event); diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 1cf90f3..d455d64 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -77,7 +77,7 @@ typedef struct W_TextField { #define MIN_TEXT_BUFFER 2 #define TEXT_BUFFER_INCR 8 -#define WM_EMACSKEYMASK ControlMask +#define WM_EMACSKEYMASK WM_MOD_CONTROL #define WM_EMACSKEY_LEFT XK_b #define WM_EMACSKEY_RIGHT XK_f @@ -952,8 +952,8 @@ static void handleTextFieldKeyPress(TextField * tPtr, WMEvent * event) if (event->u.key.state & WM_EMACSKEYMASK) control_pressed = 1; - shifted = (event->u.key.state & ShiftMask ? True : False); - controled = (event->u.key.state & ControlMask ? True : False); + shifted = (event->u.key.state & WM_MOD_SHIFT ? True : False); + controled = (event->u.key.state & WM_MOD_CONTROL ? True : False); modified = shifted || controled; count = tPtr->view->screen->fontBackend->lookup_string( @@ -1389,7 +1389,7 @@ static void handleTextFieldActionEvents(WMEvent * event, void *data) return; } - if (tPtr->flags.enabled && (event->u.motion.state & Button1Mask)) { + if (tPtr->flags.enabled && (event->u.motion.state & WM_BUTTON1_MASK)) { if (tPtr->viewPosition < tPtr->textLen && event->u.motion.x > tPtr->usableWidth) { if (WMWidthOfString(tPtr->font, diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 26cc0f3..9b59fae 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -281,8 +281,8 @@ static int NumLockMask(Display *dpy) int i, mask; XModifierKeymap *map; static int mask_table[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask + WM_MOD_SHIFT, WM_MOD_LOCK, WM_MOD_CONTROL, WM_MOD_MOD1, + WM_MOD_MOD2, WM_MOD_MOD3, WM_MOD_MOD4, WM_MOD_MOD5 }; KeyCode numlock_keycode = XKeysymToKeycode(dpy, XK_Num_Lock); @@ -345,25 +345,25 @@ char *capture_shortcut(WMScreen *scr, Bool *capturing, Bool convert_case) buffer[0] = 0; - if (ev.u.key.state & ControlMask) + if (ev.u.key.state & WM_MOD_CONTROL) strcat(buffer, "Control+"); - if (ev.u.key.state & ShiftMask) + if (ev.u.key.state & WM_MOD_SHIFT) strcat(buffer, "Shift+"); - if ((numlock_mask != Mod1Mask) && (ev.u.key.state & Mod1Mask)) + if ((numlock_mask != WM_MOD_MOD1) && (ev.u.key.state & WM_MOD_MOD1)) strcat(buffer, "Mod1+"); - if ((numlock_mask != Mod2Mask) && (ev.u.key.state & Mod2Mask)) + if ((numlock_mask != WM_MOD_MOD2) && (ev.u.key.state & WM_MOD_MOD2)) strcat(buffer, "Mod2+"); - if ((numlock_mask != Mod3Mask) && (ev.u.key.state & Mod3Mask)) + if ((numlock_mask != WM_MOD_MOD3) && (ev.u.key.state & WM_MOD_MOD3)) strcat(buffer, "Mod3+"); - if ((numlock_mask != Mod4Mask) && (ev.u.key.state & Mod4Mask)) + if ((numlock_mask != WM_MOD_MOD4) && (ev.u.key.state & WM_MOD_MOD4)) strcat(buffer, "Mod4+"); - if ((numlock_mask != Mod5Mask) && (ev.u.key.state & Mod5Mask)) + if ((numlock_mask != WM_MOD_MOD5) && (ev.u.key.state & WM_MOD_MOD5)) strcat(buffer, "Mod5+"); wstrlcat(buffer, key, sizeof(buffer)); diff --git a/WPrefs.app/editmenu.c b/WPrefs.app/editmenu.c index e7d1fe2..cf04f00 100644 --- a/WPrefs.app/editmenu.c +++ b/WPrefs.app/editmenu.c @@ -1342,7 +1342,7 @@ static void handleItemClick(WMEvent * event, void *data) if (abs(event->u.button.x_root - menu->dragX) > 5 || abs(event->u.button.y_root - menu->dragY) > 5) { menu->flags.isDragging = 0; - dragItem(menu, item, event->u.button.state & ControlMask); + dragItem(menu, item, event->u.button.state & WM_MOD_CONTROL); } } break; diff --git a/WPrefs.app/xmodifier.c b/WPrefs.app/xmodifier.c index d3746eb..0c399bf 100644 --- a/WPrefs.app/xmodifier.c +++ b/WPrefs.app/xmodifier.c @@ -208,22 +208,22 @@ static void x_reset_modifier_mapping(Display * display) store_modifier("Alt_R", alt_bit); break; case XK_Control_L: - check_modifier("Control_L", ControlMask); + check_modifier("Control_L", WM_MOD_CONTROL); break; case XK_Control_R: - check_modifier("Control_R", ControlMask); + check_modifier("Control_R", WM_MOD_CONTROL); break; case XK_Shift_L: - check_modifier("Shift_L", ShiftMask); + check_modifier("Shift_L", WM_MOD_SHIFT); break; case XK_Shift_R: - check_modifier("Shift_R", ShiftMask); + check_modifier("Shift_R", WM_MOD_SHIFT); break; case XK_Shift_Lock: - check_modifier("Shift_Lock", LockMask); + check_modifier("Shift_Lock", WM_MOD_LOCK); break; case XK_Caps_Lock: - check_modifier("Caps_Lock", LockMask); + check_modifier("Caps_Lock", WM_MOD_LOCK); break; /* It probably doesn't make any sense for a modifier bit to be diff --git a/src/appicon.c b/src/appicon.c index acd3603..6417596 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -623,12 +623,12 @@ static void iconDblClick(WObjDescriptor *desc, WMEvent *event) wapp = wApplicationOf(aicon->icon->owner->main_window); - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { relaunchApplication(wapp); return; } - unhideHere = (event->u.button.state & ShiftMask); + unhideHere = (event->u.button.state & WM_MOD_SHIFT); /* go to the last workspace that the user worked on the app */ if (!unhideHere && wapp->last_workspace != scr->current_workspace) wWorkspaceChange(scr, wapp->last_workspace); diff --git a/src/backend/backend.h b/src/backend/backend.h index 8a4ba19..c271d89 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -253,7 +253,7 @@ typedef struct WMBackend { /* * Grab a key+modifier combination on win. - * The X11 backend applies LockMask and NumLock/ScrollLock hack variants + * The X11 backend applies WM_MOD_LOCK and NumLock/ScrollLock hack variants * internally; policy code passes the canonical modifier only. * Equivalent to XGrabKey + wHackedGrabKey. */ @@ -262,13 +262,13 @@ typedef struct WMBackend { /* * Release all key grabs on win. - * Equivalent to XUngrabKey(dpy, AnyKey, AnyModifier, win). + * Equivalent to XUngrabKey(dpy, AnyKey, WM_ANY_MODIFIER, win). */ void (*key_ungrab_all)(WNativeWindow win); /* * Grab a button+modifier on win. - * The X11 backend applies LockMask and NumLock/ScrollLock variants. + * The X11 backend applies WM_MOD_LOCK and NumLock/ScrollLock variants. * Equivalent to wHackedGrabButton(button, modifier, win, owner_events, * event_mask, GrabModeSync, GrabModeAsync, * None, None). @@ -279,7 +279,7 @@ typedef struct WMBackend { /* * Release all button grabs on win. - * Equivalent to XUngrabButton(dpy, AnyButton, AnyModifier, win). + * Equivalent to XUngrabButton(dpy, WM_ANY_BUTTON, WM_ANY_MODIFIER, win). */ void (*button_ungrab_all)(WNativeWindow win); diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 99a9b0c..f0b2cbe 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -7459,7 +7459,7 @@ wl_screen_create_internals(WScreen *scr) if (wl_state.seat) wlr_seat_keyboard_clear_focus(wl_state.seat); - wSetModifierMasks(Mod1Mask, Mod1Mask, Mod4Mask, 0); + wSetModifierMasks(WM_MOD_MOD1, WM_MOD_MOD1, WM_MOD_MOD4, 0); /* XWayland bridge: create a real X11 helper window for EWMH * (_NET_SUPPORTING_WM_CHECK) and clipboard selection ownership. diff --git a/src/backend/x11/x11_backend.c b/src/backend/x11/x11_backend.c index 9f29126..8b8d460 100644 --- a/src/backend/x11/x11_backend.c +++ b/src/backend/x11/x11_backend.c @@ -516,8 +516,8 @@ x11_key_grab(WNativeWindow win, unsigned int keycode, { Window w = WNW_TO_XID(win); - if (modifier != AnyModifier) { - XGrabKey(dpy, keycode, modifier | LockMask, + if (modifier != WM_ANY_MODIFIER) { + XGrabKey(dpy, keycode, modifier | WM_MOD_LOCK, w, owner_events, GrabModeAsync, GrabModeAsync); #ifdef NUMLOCK_HACK wHackedGrabKey(keycode, modifier, w, owner_events, @@ -530,7 +530,7 @@ x11_key_grab(WNativeWindow win, unsigned int keycode, static void x11_key_ungrab_all(WNativeWindow win) { - XUngrabKey(dpy, AnyKey, AnyModifier, WNW_TO_XID(win)); + XUngrabKey(dpy, AnyKey, WM_ANY_MODIFIER, WNW_TO_XID(win)); } static void @@ -545,7 +545,7 @@ x11_button_grab(WNativeWindow win, unsigned int button, static void x11_button_ungrab_all(WNativeWindow win) { - XUngrabButton(dpy, AnyButton, AnyModifier, WNW_TO_XID(win)); + XUngrabButton(dpy, WM_ANY_BUTTON, WM_ANY_MODIFIER, WNW_TO_XID(win)); } /* -------------------------------------------------------------------- */ @@ -2515,12 +2515,12 @@ static void x11_reset_modifier_mapping(void) case WM_KEY_HYPER_R: name = "Hyper_R"; target = &hyper_bit; break; case WM_KEY_ALT_L: name = "Alt_L"; target = &alt_bit; break; case WM_KEY_ALT_R: name = "Alt_R"; target = &alt_bit; break; - case WM_KEY_CONTROL_L: name = "Control_L"; fixed_mask = ControlMask; break; - case WM_KEY_CONTROL_R: name = "Control_R"; fixed_mask = ControlMask; break; - case WM_KEY_SHIFT_L: name = "Shift_L"; fixed_mask = ShiftMask; break; - case WM_KEY_SHIFT_R: name = "Shift_R"; fixed_mask = ShiftMask; break; - case WM_KEY_SHIFT_LOCK: name = "Shift_Lock"; fixed_mask = LockMask; break; - case WM_KEY_CAPS_LOCK: name = "Caps_Lock"; fixed_mask = LockMask; break; + case WM_KEY_CONTROL_L: name = "Control_L"; fixed_mask = WM_MOD_CONTROL; break; + case WM_KEY_CONTROL_R: name = "Control_R"; fixed_mask = WM_MOD_CONTROL; break; + case WM_KEY_SHIFT_L: name = "Shift_L"; fixed_mask = WM_MOD_SHIFT; break; + case WM_KEY_SHIFT_R: name = "Shift_R"; fixed_mask = WM_MOD_SHIFT; break; + case WM_KEY_SHIFT_LOCK: name = "Shift_Lock"; fixed_mask = WM_MOD_LOCK; break; + case WM_KEY_CAPS_LOCK: name = "Caps_Lock"; fixed_mask = WM_MOD_LOCK; break; default: continue; } @@ -3282,8 +3282,8 @@ static void x11_setup_modifier_lock_masks(void) XModifierKeymap *modmap; KeyCode nlock, slock; static int mask_table[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask + WM_MOD_SHIFT, WM_MOD_LOCK, WM_MOD_CONTROL, WM_MOD_MOD1, + WM_MOD_MOD2, WM_MOD_MOD3, WM_MOD_MOD4, WM_MOD_MOD5 }; nlock = XKeysymToKeycode(dpy, XK_Num_Lock); @@ -3304,7 +3304,7 @@ static void x11_setup_modifier_lock_masks(void) static void x11_key_grab_hacked(WNativeWindow window, int keycode, unsigned int modifiers) { - if (modifiers == AnyModifier) + if (modifiers == WM_ANY_MODIFIER) return; if (_NumLockMask) XGrabKey(dpy, keycode, modifiers | _NumLockMask, @@ -3316,13 +3316,13 @@ static void x11_key_grab_hacked(WNativeWindow window, int keycode, unsigned int XGrabKey(dpy, keycode, modifiers | _NumLockMask | _ScrollLockMask, (Window)window, True, GrabModeAsync, GrabModeAsync); if (_NumLockMask) - XGrabKey(dpy, keycode, modifiers | _NumLockMask | LockMask, + XGrabKey(dpy, keycode, modifiers | _NumLockMask | WM_MOD_LOCK, (Window)window, True, GrabModeAsync, GrabModeAsync); if (_ScrollLockMask) - XGrabKey(dpy, keycode, modifiers | _ScrollLockMask | LockMask, + XGrabKey(dpy, keycode, modifiers | _ScrollLockMask | WM_MOD_LOCK, (Window)window, True, GrabModeAsync, GrabModeAsync); if (_NumLockMask && _ScrollLockMask) - XGrabKey(dpy, keycode, modifiers | _NumLockMask | _ScrollLockMask | LockMask, + XGrabKey(dpy, keycode, modifiers | _NumLockMask | _ScrollLockMask | WM_MOD_LOCK, (Window)window, True, GrabModeAsync, GrabModeAsync); } @@ -3332,9 +3332,9 @@ static void x11_button_grab_hacked(unsigned int button, unsigned int modifiers, { XGrabButton(dpy, button, modifiers, (Window)window, owner_events, event_mask, GrabModeAsync, GrabModeAsync, None, None); - if (modifiers == AnyModifier) + if (modifiers == WM_ANY_MODIFIER) return; - XGrabButton(dpy, button, modifiers | LockMask, (Window)window, owner_events, + XGrabButton(dpy, button, modifiers | WM_MOD_LOCK, (Window)window, owner_events, event_mask, GrabModeAsync, GrabModeAsync, None, None); if (_NumLockMask) XGrabButton(dpy, button, modifiers | _NumLockMask, (Window)window, @@ -3346,13 +3346,13 @@ static void x11_button_grab_hacked(unsigned int button, unsigned int modifiers, XGrabButton(dpy, button, modifiers | _NumLockMask | _ScrollLockMask, (Window)window, owner_events, event_mask, GrabModeAsync, GrabModeAsync, None, None); if (_NumLockMask) - XGrabButton(dpy, button, modifiers | _NumLockMask | LockMask, (Window)window, + XGrabButton(dpy, button, modifiers | _NumLockMask | WM_MOD_LOCK, (Window)window, owner_events, event_mask, GrabModeAsync, GrabModeAsync, None, None); if (_ScrollLockMask) - XGrabButton(dpy, button, modifiers | _ScrollLockMask | LockMask, (Window)window, + XGrabButton(dpy, button, modifiers | _ScrollLockMask | WM_MOD_LOCK, (Window)window, owner_events, event_mask, GrabModeAsync, GrabModeAsync, None, None); if (_NumLockMask && _ScrollLockMask) - XGrabButton(dpy, button, modifiers | _NumLockMask | _ScrollLockMask | LockMask, (Window)window, + XGrabButton(dpy, button, modifiers | _NumLockMask | _ScrollLockMask | WM_MOD_LOCK, (Window)window, owner_events, event_mask, GrabModeAsync, GrabModeAsync, None, None); } diff --git a/src/dock.c b/src/dock.c index de083fd..d382b1f 100644 --- a/src/dock.c +++ b/src/dock.c @@ -3532,12 +3532,12 @@ static void iconDblClick(WObjDescriptor *desc, WMEvent *event) WApplication *wapp = NULL; int unhideHere = 0; - if (btn->icon->owner && !(event->u.button.state & ControlMask)) { + if (btn->icon->owner && !(event->u.button.state & WM_MOD_CONTROL)) { wapp = wApplicationOf(btn->icon->owner->main_window); assert(wapp != NULL); - unhideHere = (event->u.button.state & ShiftMask); + unhideHere = (event->u.button.state & WM_MOD_SHIFT); /* go to the last workspace that the user worked on the app */ if (wapp->last_workspace != dock->screen_ptr->current_workspace && !unhideHere) @@ -3559,7 +3559,7 @@ static void iconDblClick(WObjDescriptor *desc, WMEvent *event) // Is actually the dock if (btn->command) { - if (!btn->launching && (!btn->running || (event->u.button.state & ControlMask))) + if (!btn->launching && (!btn->running || (event->u.button.state & WM_MOD_CONTROL))) launchDockedApplication(btn, False); } else @@ -3572,7 +3572,7 @@ static void iconDblClick(WObjDescriptor *desc, WMEvent *event) } else if (wIsADrawer(btn)) { toggleCollapsed(dock); } else if (btn->command) { - if (!btn->launching && (!btn->running || (event->u.button.state & ControlMask))) + if (!btn->launching && (!btn->running || (event->u.button.state & WM_MOD_CONTROL))) launchDockedApplication(btn, False); } else if (btn->xindex == 0 && btn->yindex == 0 && btn->dock->type == WM_DOCK) { wShowInfoPanel(dock->screen_ptr); @@ -3854,7 +3854,7 @@ static void handleClipChangeWorkspace(WScreen *scr, WMEvent *event) clip->lclip_button_pushed = 0; clip->rclip_button_pushed = 0; - new_ws = wPreferences.ws_advance || (event->u.button.state & ControlMask); + new_ws = wPreferences.ws_advance || (event->u.button.state & WM_MOD_CONTROL); if (direction == CLIP_FORWARD) { if (scr->current_workspace < scr->workspace_count - 1) @@ -3906,7 +3906,7 @@ static void iconMouseDown(WObjDescriptor *desc, WBackendEvent *event) else wDockRaise(dock); - if ((event->u.button.state & ShiftMask) && aicon != scr->clip_icon && dock->type != WM_DOCK) { + if ((event->u.button.state & WM_MOD_SHIFT) && aicon != scr->clip_icon && dock->type != WM_DOCK) { wIconSelect(aicon->icon); return; } @@ -3945,7 +3945,7 @@ static void iconMouseDown(WObjDescriptor *desc, WBackendEvent *event) (*desc->handle_mousedown) (desc, event); } } else if (event->u.button.button == Button2 && dock->type == WM_CLIP && - (event->u.button.state & ShiftMask) && aicon != scr->clip_icon) { + (event->u.button.state & WM_MOD_SHIFT) && aicon != scr->clip_icon) { wClipMakeIconOmnipresent(aicon, !aicon->omnipresent); } else if (event->u.button.button == Button3) { if (event->u.button.send_event && @@ -3961,7 +3961,7 @@ static void iconMouseDown(WObjDescriptor *desc, WBackendEvent *event) } else if (event->u.button.button == Button2) { WAppIcon *btn = desc->parent; - if (!btn->launching && (!btn->running || (event->u.button.state & ControlMask))) + if (!btn->launching && (!btn->running || (event->u.button.state & WM_MOD_CONTROL))) launchDockedApplication(btn, True); } else if (event->u.button.button == Button4 && dock->type == WM_CLIP) { wWorkspaceRelativeChange(scr, 1); diff --git a/src/event.c b/src/event.c index e673d60..2879c60 100644 --- a/src/event.c +++ b/src/event.c @@ -693,7 +693,7 @@ static void handleButtonPress(WMEvent * event) if (desc->parent_type == WCLASS_WINDOW) { wm_backend->event_sync(0); - if (event->u.button.state & ( MOD_MASK | ControlMask )) { + if (event->u.button.state & ( MOD_MASK | WM_MOD_CONTROL )) { wm_backend->event_allow_async(); } else { /* if (wPreferences.focus_mode == WKF_CLICK) { */ diff --git a/src/event.h b/src/event.h index 7d4d805..91272b1 100644 --- a/src/event.h +++ b/src/event.h @@ -43,7 +43,7 @@ void NotifyDeadProcess(pid_t pid, unsigned char status); /* Phase 78: Wayland keyboard event dispatch — called from wl_backend when a * key-press event arrives. keycode is the XKB keycode (evdev+8, compatible * with wKeyBindings); modifiers is the XKB modifier mask (compatible with the - * X11 ShiftMask/ControlMask/Mod1Mask bit layout). Returns 1 if the event was + * X11 WM_MOD_SHIFT/WM_MOD_CONTROL/WM_MOD_MOD1 bit layout). Returns 1 if the event was * consumed as a WM shortcut, 0 if it should be forwarded to the focused client. */ int wWaylandKeyPress(unsigned int keycode, unsigned int modifiers); diff --git a/src/icon.c b/src/icon.c index 96e8707..7987600 100644 --- a/src/icon.c +++ b/src/icon.c @@ -883,7 +883,7 @@ static void miniwindowMouseDown(WObjDescriptor *desc, WBackendEvent *event) wLowerFrame(icon->core); else wRaiseFrame(icon->core); - if (event->u.button.state & ShiftMask) { + if (event->u.button.state & WM_MOD_SHIFT) { wIconSelect(icon); wSelectWindow(icon->owner, !wwin->flags.selected); } diff --git a/src/menu.c b/src/menu.c index 09ccc93..b3a41fa 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1645,7 +1645,7 @@ static void menuMouseDown(WObjDescriptor * desc, WBackendEvent * event) if ((entry_no >= 0) && (entry_no < menu->entry_no)) { entry = menu->entries[entry_no]; - if (!close_on_exit && (event->u.button.state & ControlMask) && smenu && entry->flags.editable) { + if (!close_on_exit && (event->u.button.state & WM_MOD_CONTROL) && smenu && entry->flags.editable) { char buffer[128]; char *name; int number = entry_no - 3; /* Entries "New", "Destroy Last" and "Last Used" appear before workspaces */ @@ -1662,7 +1662,7 @@ static void menuMouseDown(WObjDescriptor * desc, WBackendEvent * event) wfree(name); goto byebye; - } else if (event->u.button.state & ControlMask) { + } else if (event->u.button.state & WM_MOD_CONTROL) { goto byebye; } diff --git a/src/misc.c b/src/misc.c index 292f55b..9d325ee 100644 --- a/src/misc.c +++ b/src/misc.c @@ -678,13 +678,13 @@ char *GetShortcutKey(WShortKey key) return NULL; wr = buffer; - if (key.modifier & ControlMask) append_modifier(1, "Control+"); - if (key.modifier & ShiftMask) append_modifier(0, "Shift+"); - if (key.modifier & Mod1Mask) append_modifier(2, "Mod1+"); - if (key.modifier & Mod2Mask) append_modifier(3, "Mod2+"); - if (key.modifier & Mod3Mask) append_modifier(4, "Mod3+"); - if (key.modifier & Mod4Mask) append_modifier(5, "Mod4+"); - if (key.modifier & Mod5Mask) append_modifier(6, "Mod5+"); + if (key.modifier & WM_MOD_CONTROL) append_modifier(1, "Control+"); + if (key.modifier & WM_MOD_SHIFT) append_modifier(0, "Shift+"); + if (key.modifier & WM_MOD_MOD1) append_modifier(2, "Mod1+"); + if (key.modifier & WM_MOD_MOD2) append_modifier(3, "Mod2+"); + if (key.modifier & WM_MOD_MOD3) append_modifier(4, "Mod3+"); + if (key.modifier & WM_MOD_MOD4) append_modifier(5, "Mod4+"); + if (key.modifier & WM_MOD_MOD5) append_modifier(6, "Mod5+"); append_string(key_name); *wr = '\0'; diff --git a/src/moveres.c b/src/moveres.c index e95325f..4b505de 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -1448,7 +1448,7 @@ int wKeyboardMoveResizeWindow(WWindow * wwin) kspeed = _KS; lastTime = event.u.key.time; if (modes == (MOVABLE_BIT | RESIZABLE_BIT)) { - if ((event.u.key.state & ControlMask) && !wwin->flags.shaded) { + if ((event.u.key.state & WM_MOD_CONTROL) && !wwin->flags.shaded) { ctrlmode = 1; wUnselectWindows(scr); } else { @@ -2152,7 +2152,7 @@ void wMouseResizeWindow(WWindow * wwin, WMEvent * ev) else flags = 0; - if (is_resizebar && ((ev->u.button.state & ShiftMask) + if (is_resizebar && ((ev->u.button.state & WM_MOD_SHIFT) || abs(orig_y - event.u.motion.y_root) < HRESIZE_THRESHOLD)) flags |= HCONSTRAIN; diff --git a/src/rootmenu.c b/src/rootmenu.c index 4155bbd..cf412f4 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -346,9 +346,9 @@ void wRootMenuBindShortcuts(Window window) ptr = shortcutList; while (ptr) { - if (ptr->modifier != AnyModifier) { + if (ptr->modifier != WM_ANY_MODIFIER) { wm_backend->key_grab((WNativeWindow)window, ptr->keycode, - ptr->modifier | LockMask, True); + ptr->modifier | WM_MOD_LOCK, True); #ifdef NUMLOCK_HACK wHackedGrabKey(ptr->keycode, ptr->modifier, window, True, GrabModeAsync, GrabModeAsync); #endif diff --git a/src/startup.c b/src/startup.c index 2f6d1ff..a7dc04a 100644 --- a/src/startup.c +++ b/src/startup.c @@ -268,7 +268,7 @@ void StartUp(Bool defaultScreenOnly) /* * Ignore CapsLock in modifiers */ - w_global.shortcut.modifiers_mask = 0xff & ~LockMask; + w_global.shortcut.modifiers_mask = 0xff & ~WM_MOD_LOCK; getOffendingModifiers(); /* diff --git a/src/window.c b/src/window.c index 46fe98d..1ea8e8b 100644 --- a/src/window.c +++ b/src/window.c @@ -2361,7 +2361,7 @@ void wWindowResetMouseGrabs(WWindow * wwin) if (!WFLAGP(wwin, no_bind_mouse)) { /* grabs for Meta+drag */ - wm_backend->button_grab(wwin->client_win, AnyButton, MOD_MASK, + wm_backend->button_grab(wwin->client_win, WM_ANY_BUTTON, MOD_MASK, ButtonPressMask | ButtonReleaseMask, True); /* for CTRL+Wheel to Scroll Horiz, we have to grab CTRL as well @@ -2369,13 +2369,13 @@ void wWindowResetMouseGrabs(WWindow * wwin) * use CTRL+Button1-3 for app related functionality */ if (wPreferences.resize_increment > 0) { - wm_backend->button_grab(wwin->client_win, Button4, ControlMask, + wm_backend->button_grab(wwin->client_win, Button4, WM_MOD_CONTROL, ButtonPressMask | ButtonReleaseMask, True); - wm_backend->button_grab(wwin->client_win, Button5, ControlMask, + wm_backend->button_grab(wwin->client_win, Button5, WM_MOD_CONTROL, ButtonPressMask | ButtonReleaseMask, True); - wm_backend->button_grab(wwin->client_win, Button4, MOD_MASK | ControlMask, + wm_backend->button_grab(wwin->client_win, Button4, MOD_MASK | WM_MOD_CONTROL, ButtonPressMask | ButtonReleaseMask, True); - wm_backend->button_grab(wwin->client_win, Button5, MOD_MASK | ControlMask, + wm_backend->button_grab(wwin->client_win, Button5, MOD_MASK | WM_MOD_CONTROL, ButtonPressMask | ButtonReleaseMask, True); } } @@ -2383,7 +2383,7 @@ void wWindowResetMouseGrabs(WWindow * wwin) if (!wwin->flags.focused && !WFLAGP(wwin, no_focusable) && !wwin->flags.is_gnustep) { /* the passive grabs to focus the window */ - wm_backend->button_grab(wwin->client_win, AnyButton, AnyModifier, + wm_backend->button_grab(wwin->client_win, WM_ANY_BUTTON, WM_ANY_MODIFIER, ButtonPressMask | ButtonReleaseMask, True); } wm_backend->event_flush(); @@ -2555,7 +2555,7 @@ static void resizebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event) #ifndef NUMLOCK_HACK if ((event->u.button.state & ValidModMask) - != (event->u.button.state & ~LockMask)) { + != (event->u.button.state & ~WM_MOD_LOCK)) { 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.")); } @@ -2565,7 +2565,7 @@ static void resizebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event) CloseWindowMenu(wwin->screen_ptr); - if (wPreferences.focus_mode == WKF_CLICK && !(event->u.button.state & ControlMask) + if (wPreferences.focus_mode == WKF_CLICK && !(event->u.button.state & WM_MOD_CONTROL) && !WFLAGP(wwin, no_focusable)) { wSetFocusTo(wwin->screen_ptr, wwin); } @@ -2626,12 +2626,12 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, WMEvent *event) } else { int dir = 0; - if (event->u.button.state & ControlMask) + if (event->u.button.state & WM_MOD_CONTROL) dir |= MAX_VERTICAL; - if (event->u.button.state & ShiftMask) { + if (event->u.button.state & WM_MOD_SHIFT) { dir |= MAX_HORIZONTAL; - if (!(event->u.button.state & ControlMask)) + if (!(event->u.button.state & WM_MOD_CONTROL)) wSelectWindow(wwin, !wwin->flags.selected); } @@ -2680,13 +2680,13 @@ static void frameMouseDown(WObjDescriptor *desc, WBackendEvent *event) CloseWindowMenu(wwin->screen_ptr); - if (!(event->u.button.state & ControlMask) && !WFLAGP(wwin, no_focusable)) + if (!(event->u.button.state & WM_MOD_CONTROL) && !WFLAGP(wwin, no_focusable)) wSetFocusTo(wwin->screen_ptr, wwin); if (event->u.button.button == Button1) wRaiseFrame(wwin->frame->core); - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { if (event->u.button.button == Button4) { new_width = wwin->client.width - resize_width_increment; wWindowConstrainSize(wwin, &new_width, &wwin->client.height); @@ -2731,7 +2731,7 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event) (void) sender; #ifndef NUMLOCK_HACK - if ((event->u.button.state & ValidModMask) != (event->u.button.state & ~LockMask)) + if ((event->u.button.state & ValidModMask) != (event->u.button.state & ~WM_MOD_LOCK)) 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 @@ -2739,7 +2739,7 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event) CloseWindowMenu(wwin->screen_ptr); - if (wPreferences.focus_mode == WKF_CLICK && !(event->u.button.state & ControlMask) + if (wPreferences.focus_mode == WKF_CLICK && !(event->u.button.state & WM_MOD_CONTROL) && !WFLAGP(wwin, no_focusable)) wSetFocusTo(wwin->screen_ptr, wwin); @@ -2751,8 +2751,8 @@ static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event) else wRaiseFrame(wwin->frame->core); } - if ((event->u.button.state & ShiftMask) - && !(event->u.button.state & ControlMask)) { + if ((event->u.button.state & WM_MOD_SHIFT) + && !(event->u.button.state & WM_MOD_CONTROL)) { wSelectWindow(wwin, !wwin->flags.selected); return; } @@ -2804,7 +2804,7 @@ static void windowCloseClick(WCoreWindow *sender, void *data, WMEvent *event) return; /* if control-click, kill the client */ - if (event->u.button.state & ControlMask) { + if (event->u.button.state & WM_MOD_CONTROL) { wClientKill(wwin); } else { if (wwin->protocols.DELETE_WINDOW && event->u.button.state == 0) { @@ -2880,7 +2880,7 @@ static void windowIconifyClick(WCoreWindow *sender, void *data, WMEvent *event) w_global.timestamp.last_event); } else { WApplication *wapp; - if ((event->u.button.state & ControlMask) || (event->u.button.button == Button3)) { + if ((event->u.button.state & WM_MOD_CONTROL) || (event->u.button.button == Button3)) { wapp = wApplicationOf(wwin->main_window); if (wapp && !WFLAGP(wwin, no_appicon)) diff --git a/src/xmodifier.c b/src/xmodifier.c index 23beec7..a438036 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -18,7 +18,7 @@ #include #include -#include /* ShiftMask, ControlMask, ModNMask constants */ +#include /* WM_MOD_SHIFT, WM_MOD_CONTROL, ModNMask constants */ #include #include "WindowMaker.h" @@ -31,21 +31,21 @@ const char *wXModifierToShortcutLabel(int mask) if (mask < 0) return NULL; - if (mask == ShiftMask) + if (mask == WM_MOD_SHIFT) return "Sh+"; - if (mask == ControlMask) + if (mask == WM_MOD_CONTROL) return "^"; if (mask == AltMask) return "A+"; - if (mask == Mod1Mask) + if (mask == WM_MOD_MOD1) return "M1+"; - if (mask == Mod2Mask) + if (mask == WM_MOD_MOD2) return "M2+"; - if (mask == Mod3Mask) + if (mask == WM_MOD_MOD3) return "M3+"; - if (mask == Mod4Mask) + if (mask == WM_MOD_MOD4) return "M4+"; - if (mask == Mod5Mask) + if (mask == WM_MOD_MOD5) return "M5+"; if (mask == MetaMask) return "M+"; @@ -56,10 +56,10 @@ const char *wXModifierToShortcutLabel(int mask) int wXModifierFromKey(const char *key) { - if (strcasecmp(key, "SHIFT") == 0 && ShiftMask != 0) - return ShiftMask; - else if (strcasecmp(key, "CONTROL") == 0 && ControlMask != 0) - return ControlMask; + if (strcasecmp(key, "SHIFT") == 0 && WM_MOD_SHIFT != 0) + return WM_MOD_SHIFT; + else if (strcasecmp(key, "CONTROL") == 0 && WM_MOD_CONTROL != 0) + return WM_MOD_CONTROL; else if (strcasecmp(key, "ALT") == 0 && AltMask != 0) return AltMask; else if (strcasecmp(key, "META") == 0 && MetaMask != 0) @@ -68,16 +68,16 @@ int wXModifierFromKey(const char *key) return SuperMask; else if (strcasecmp(key, "HYPER") == 0 && HyperMask != 0) return HyperMask; - else if (strcasecmp(key, "MOD1") == 0 && Mod1Mask != 0) - return Mod1Mask; - else if (strcasecmp(key, "MOD2") == 0 && Mod2Mask != 0) - return Mod2Mask; - else if (strcasecmp(key, "MOD3") == 0 && Mod3Mask != 0) - return Mod3Mask; - else if (strcasecmp(key, "MOD4") == 0 && Mod4Mask != 0) - return Mod4Mask; - else if (strcasecmp(key, "MOD5") == 0 && Mod5Mask != 0) - return Mod5Mask; + else if (strcasecmp(key, "MOD1") == 0 && WM_MOD_MOD1 != 0) + return WM_MOD_MOD1; + else if (strcasecmp(key, "MOD2") == 0 && WM_MOD_MOD2 != 0) + return WM_MOD_MOD2; + else if (strcasecmp(key, "MOD3") == 0 && WM_MOD_MOD3 != 0) + return WM_MOD_MOD3; + else if (strcasecmp(key, "MOD4") == 0 && WM_MOD_MOD4 != 0) + return WM_MOD_MOD4; + else if (strcasecmp(key, "MOD5") == 0 && WM_MOD_MOD5 != 0) + return WM_MOD_MOD5; else return -1; }