diff --git a/src/bar/Bar.cpp b/src/bar/Bar.cpp index 559635a..fd42b36 100644 --- a/src/bar/Bar.cpp +++ b/src/bar/Bar.cpp @@ -34,6 +34,27 @@ int64_t barMainThread() { Debug::log(LOG, "Bar init Phase 1 done."); + // Init atoms + // get atoms + for (auto& ATOM : HYPRATOMS) { + xcb_intern_atom_cookie_t cookie = xcb_intern_atom(g_pWindowManager->DisplayConnection, 0, ATOM.first.length(), ATOM.first.c_str()); + xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(g_pWindowManager->DisplayConnection, cookie, NULL); + + if (!reply) { + Debug::log(ERR, "Atom failed: " + ATOM.first); + continue; + } + + ATOM.second = reply->atom; + } + + Debug::log(LOG, "Atoms done."); + + g_pWindowManager->EWMHConnection = (xcb_ewmh_connection_t*)malloc(sizeof(xcb_ewmh_connection_t)); + xcb_ewmh_init_atoms_replies(g_pWindowManager->EWMHConnection, xcb_ewmh_init_atoms(g_pWindowManager->DisplayConnection, g_pWindowManager->EWMHConnection), nullptr); + + Debug::log(LOG, "Bar init EWMH done."); + // Init randr for monitors. g_pWindowManager->setupRandrMonitors(); @@ -140,6 +161,10 @@ void CStatusBar::setup(int MonitorID) { 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, g_pWindowManager->Screen->root_visual, XCB_CW_EVENT_MASK, values); + // Set the state to dock to avoid some issues + xcb_atom_t dockAtom[] = { HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] }; + xcb_ewmh_set_wm_window_type(g_pWindowManager->EWMHConnection, m_iWindowID, 1, dockAtom); + // map xcb_map_window(g_pWindowManager->DisplayConnection, m_iWindowID); diff --git a/src/windowManager.hpp b/src/windowManager.hpp index db8e393..f4543f7 100644 --- a/src/windowManager.hpp +++ b/src/windowManager.hpp @@ -21,8 +21,9 @@ class CWindowManager { public: - xcb_connection_t* DisplayConnection; - xcb_screen_t* Screen; + xcb_connection_t* DisplayConnection = nullptr; + xcb_ewmh_connection_t* EWMHConnection = nullptr; // Bar uses this + xcb_screen_t* Screen = nullptr; xcb_drawable_t Drawable; uint32_t Values[3]; @@ -121,7 +122,7 @@ public: inline std::unique_ptr g_pWindowManager = std::make_unique(); -inline std::map HYPRATOMS = { +inline std::map HYPRATOMS = { HYPRATOM("_NET_SUPPORTED"), HYPRATOM("_NET_SUPPORTING_WM_CHECK"), HYPRATOM("_NET_WM_NAME"), @@ -179,5 +180,4 @@ inline std::map HYPRATOMS = { HYPRATOM("_NET_FRAME_EXTENTS"), HYPRATOM("_MOTIF_WM_HINTS"), HYPRATOM("WM_CHANGE_STATE"), - HYPRATOM("MANAGER") -}; + HYPRATOM("MANAGER")};