From 196aeb1ce15e1804363a99e181a685e42ef02a7b Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 6 May 2022 16:32:59 +0800 Subject: [PATCH] linux: minor fixes of the xcb usage Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/utils_linux.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/utils_linux.cpp b/src/core/utils_linux.cpp index 5a809f2..d7bae28 100644 --- a/src/core/utils_linux.cpp +++ b/src/core/utils_linux.cpp @@ -55,7 +55,10 @@ using Display = struct _XDisplay; [[maybe_unused]] static constexpr const auto _NET_WM_MOVERESIZE_SIZE_LEFT = 7; [[maybe_unused]] static constexpr const auto _NET_WM_MOVERESIZE_MOVE = 8; -[[maybe_unused]] static constexpr const char WM_MOVERESIZE_OPERATION_NAME[] = "_NET_WM_MOVERESIZE"; +[[maybe_unused]] static constexpr const char _NET_WM_MOVERESIZE_ATOM_NAME[] = "_NET_WM_MOVERESIZE\0"; + +[[maybe_unused]] static constexpr const auto _NET_WM_SENDEVENT_MASK = + (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY); [[maybe_unused]] static constexpr const char GTK_THEME_NAME_ENV_VAR[] = "GTK_THEME"; [[maybe_unused]] static constexpr const char GTK_THEME_NAME_PROP[] = "gtk-theme-name"; @@ -267,7 +270,7 @@ static inline void xev.event_x = localPos.x(); xev.event_y = localPos.y(); xev.same_screen = true; - xcb_send_event(connection, false, rootWindow, XCB_EVENT_MASK_STRUCTURE_NOTIFY, + xcb_send_event(connection, false, rootWindow, _NET_WM_SENDEVENT_MASK, reinterpret_cast(&xev)); xcb_flush(connection); } @@ -284,7 +287,7 @@ static inline void Q_ASSERT(connection); static const xcb_atom_t netMoveResize = [connection]() -> xcb_atom_t { const xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, false, - qstrlen(WM_MOVERESIZE_OPERATION_NAME), WM_MOVERESIZE_OPERATION_NAME); + qstrlen(_NET_WM_MOVERESIZE_ATOM_NAME), _NET_WM_MOVERESIZE_ATOM_NAME); xcb_intern_atom_reply_t * const reply = xcb_intern_atom_reply(connection, cookie, nullptr); Q_ASSERT(reply); const xcb_atom_t atom = reply->atom; @@ -307,8 +310,7 @@ static inline void // First we need to ungrab the pointer that may have been // automatically grabbed by Qt on ButtonPressEvent. xcb_ungrab_pointer(connection, x11_appTime()); - xcb_send_event(connection, false, rootWindow, - (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), + xcb_send_event(connection, false, rootWindow, _NET_WM_SENDEVENT_MASK, reinterpret_cast(&xev)); xcb_flush(connection); }