From ebd5faf993fd3ea8f6e929df6f3288cfa1d4b752 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 5 Jan 2015 14:31:43 -0500 Subject: Clean up the Panel/Taskmanager XCB usage quite a bit. Now the panel is "seen" by fluxbox when a window is maximized, and the task manager works with the highly asynchronous XCB events. --- libLumina/LuminaX11.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'libLumina/LuminaX11.cpp') diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index cb0655e2..e73f124c 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -875,6 +875,17 @@ unsigned int LXCB::CurrentWorkspace(){ return wkspace; } +// === ActiveWindow() === +WId LXCB::ActiveWindow(){ + xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window_unchecked(&EWMH, 0); + xcb_window_t actwin; + if(1 == xcb_ewmh_get_active_window_reply(&EWMH, cookie, &actwin, NULL) ){ + return actwin; + }else{ + return 0; //invalid ID/failure + } +} + // === RegisterVirtualRoots() === void LXCB::RegisterVirtualRoots(QList roots){ //First convert the QList into the proper format @@ -1084,6 +1095,86 @@ void LXCB::SetAsSticky(WId win){ xcb_flush(QX11Info::connection()); //apply it right away*/ } +// === SetAsPanel() === +void LXCB::SetAsPanel(WId win){ + //Disable Input focus (panel activation ruins task manager window detection routines) + // - Disable Input flag in WM_HINTS + xcb_icccm_wm_hints_t hints; + qDebug() << " - Disable WM_HINTS input flag"; + xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(QX11Info::connection(), win); + qDebug() << " -- got cookie"; + if(1 == xcb_icccm_get_wm_hints_reply(QX11Info::connection(), cookie, &hints, NULL) ){ + qDebug() << " -- Set no inputs flag"; + xcb_icccm_wm_hints_set_input(&hints, False); //set no input focus + xcb_icccm_set_wm_hints(QX11Info::connection(), win, &hints); //save hints back to window + qDebug() << " -- Free the hints structure"; + free(&hints); //free up hints structure + } + // - Remove WM_TAKE_FOCUS from the WM_PROTOCOLS for the window + // - - Generate the necessary atoms + qDebug() << " - Generate WM_PROTOCOLS and WM_TAKE_FOCUS atoms"; + xcb_atom_t WM_PROTOCOLS, WM_TAKE_FOCUS; //the two atoms needed + xcb_intern_atom_reply_t *preply = xcb_intern_atom_reply(QX11Info::connection(), \ + xcb_intern_atom(QX11Info::connection(), 0, 12, "WM_PROTOCOLS"), NULL); + xcb_intern_atom_reply_t *freply = xcb_intern_atom_reply(QX11Info::connection(), \ + xcb_intern_atom(QX11Info::connection(), 0, 13, "WM_TAKE_FOCUS"), NULL); + bool gotatoms = false; + if(preply && freply){ + WM_PROTOCOLS = preply->atom; + WM_TAKE_FOCUS = freply->atom; + free(preply); + free(freply); + gotatoms = true; + qDebug() << " -- success"; + } + // - - Now update the protocols for the window + if(gotatoms){ //requires the atoms + qDebug() << " - Get WM_PROTOCOLS"; + xcb_icccm_get_wm_protocols_reply_t proto; + if( 1 == xcb_icccm_get_wm_protocols_reply(QX11Info::connection(), \ + xcb_icccm_get_wm_protocols_unchecked(QX11Info::connection(), win, WM_PROTOCOLS), \ + &proto, NULL) ){ + + //Found the current protocols, see if it has the focus atom set + //remove the take focus atom and re-save them + bool needremove = false; + //Note: This first loop is required so that we can initialize the modified list with a valid size + qDebug() << " -- Check current protocols"; + for(unsigned int i=0; i