diff options
author | Ken Moore <moorekou@gmail.com> | 2015-11-12 14:25:06 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-11-12 14:25:06 -0500 |
commit | ac4dd2a253d5e7aa5972d80d49cf643ac0111e6a (patch) | |
tree | 76514186dd518c14203f812917a02ec0dd50a8fb /libLumina | |
parent | Remove a geometry-match condition when re-loading the desktop canvas's. This ... (diff) | |
download | lumina-ac4dd2a253d5e7aa5972d80d49cf643ac0111e6a.tar.gz lumina-ac4dd2a253d5e7aa5972d80d49cf643ac0111e6a.tar.bz2 lumina-ac4dd2a253d5e7aa5972d80d49cf643ac0111e6a.zip |
Add a couple more XCB EWMH functions. One change required a re-definition of an enumeration (WINDOWSTATE -> WINDOWVISIBILITY), so I fixed the usage of that enum in the lumina-desktop project as well.
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaX11.cpp | 133 | ||||
-rw-r--r-- | libLumina/LuminaX11.h | 12 |
2 files changed, 139 insertions, 6 deletions
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index a5592c8e..d9dab41c 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -287,13 +287,13 @@ QList<int> LXCB::WindowFrameGeometry(WId win){ } // === WindowState() === -LXCB::WINDOWSTATE LXCB::WindowState(WId win){ +LXCB::WINDOWVISIBILITY LXCB::WindowState(WId win){ if(DEBUG){ qDebug() << "XCB: WindowState()"; } if(win==0){ return IGNORE; } xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); if(cookie.sequence == 0){ return IGNORE; } xcb_ewmh_get_atoms_reply_t states; - WINDOWSTATE cstate = IGNORE; + WINDOWVISIBILITY cstate = IGNORE; //First Check for special states (ATTENTION in particular); if( 1 == xcb_ewmh_get_wm_state_reply(&EWMH, cookie, &states, NULL) ){ for(unsigned int i=0; i<states.atoms_len; i++){ @@ -1581,9 +1581,134 @@ void LXCB::WM_Set_Desktop(WId win, int num){ } // _NET_WM_WINDOW_TYPE - +QList<LXCB::WINDOWTYPE> LXCB::WM_Get_Window_Type(WId win){ + // Note: This will silently discard any unknown/non-standard window type flags + // The client should ensure to set at least one standardized type flag per the specifications. + QList<LXCB::WINDOWTYPE> out; + xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_window_type_unchecked(&EWMH, win); + xcb_ewmh_get_atoms_reply_t reply; + if(1==xcb_ewmh_get_wm_window_type_reply(&EWMH, cookie, &reply, NULL) ){ + for(unsigned int i=0; i<reply.atoms_len; i++){ + if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_DESKTOP){ out << LXCB::DESKTOP; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_DOCK){ out << LXCB::DOCK; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_TOOLBAR){ out << LXCB::TOOLBAR; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_MENU){ out << LXCB::MENU; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_UTILITY){ out << LXCB::UTILITY; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_SPLASH){ out << LXCB::SPLASH; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_DIALOG){ out << LXCB::DIALOG; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_DROPDOWN_MENU){ out << LXCB::DROPDOWN_MENU; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_POPUP_MENU){ out << LXCB::POPUP_MENU; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_TOOLTIP){ out << LXCB::TOOLTIP; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_NOTIFICATION){ out << LXCB::NOTIFICATION; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_COMBO){ out << LXCB::COMBO; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_DND){ out << LXCB::DND; } + else if(reply.atoms[i]==EWMH._NET_WM_WINDOW_TYPE_NORMAL){ out << LXCB::NORMALTYPE; } + } + } + return out; +} + +void LXCB::WM_Set_Window_Type(WId win, QList<LXCB::WINDOWTYPE> list){ + //Convert to the XCB format + xcb_atom_t array[list.length()]; + for(int i=0; i<list.length(); i++){ + switch(list[i]){ + case LXCB::DESKTOP: + array[i] = EWMH._NET_WM_WINDOW_TYPE_DESKTOP; break; + case LXCB::DOCK: + array[i] = EWMH._NET_WM_WINDOW_TYPE_DOCK; break; + case LXCB::TOOLBAR: + array[i] = EWMH._NET_WM_WINDOW_TYPE_TOOLBAR; break; + case LXCB::MENU: + array[i] = EWMH._NET_WM_WINDOW_TYPE_MENU; break; + case LXCB::UTILITY: + array[i] = EWMH._NET_WM_WINDOW_TYPE_UTILITY; break; + case LXCB::SPLASH: + array[i] = EWMH._NET_WM_WINDOW_TYPE_SPLASH; break; + case LXCB::DIALOG: + array[i] = EWMH._NET_WM_WINDOW_TYPE_DIALOG; break; + case LXCB::DROPDOWN_MENU: + array[i] = EWMH._NET_WM_WINDOW_TYPE_DROPDOWN_MENU; break; + case LXCB::POPUP_MENU: + array[i] = EWMH._NET_WM_WINDOW_TYPE_POPUP_MENU; break; + case LXCB::TOOLTIP: + array[i] = EWMH._NET_WM_WINDOW_TYPE_TOOLTIP; break; + case LXCB::NOTIFICATION: + array[i] = EWMH._NET_WM_WINDOW_TYPE_NOTIFICATION; break; + case LXCB::COMBO: + array[i] = EWMH._NET_WM_WINDOW_TYPE_COMBO; break; + case LXCB::DND: + array[i] = EWMH._NET_WM_WINDOW_TYPE_DND; break; + default: + array[i] = EWMH._NET_WM_WINDOW_TYPE_NORMAL; + } + } + //Now set the property + xcb_ewmh_set_wm_window_type(&EWMH, win, list.length(), array); +} + // _NET_WM_STATE - +QList<LXCB::WINDOWSTATE> LXCB::WM_Get_Window_States(WId win){ + QList<LXCB::WINDOWSTATE> out; + xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); + xcb_ewmh_get_atoms_reply_t reply; + if(1==xcb_ewmh_get_wm_state_reply(&EWMH, cookie, &reply, NULL) ){ + for(unsigned int i=0; i<reply.atoms_len; i++){ + if(reply.atoms[i]==EWMH._NET_WM_STATE_MODAL){ out << LXCB::MODAL; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_STICKY){ out << LXCB::STICKY; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_MAXIMIZED_VERT){ out << LXCB::MAX_VERT; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_MAXIMIZED_HORZ){ out << LXCB::MAX_HORZ; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_SHADED){ out << LXCB::SHADED; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_SKIP_TASKBAR){ out << LXCB::SKIP_TASKBAR; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_SKIP_PAGER){ out << LXCB::SKIP_PAGER; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_HIDDEN){ out << LXCB::HIDDEN; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_FULLSCREEN){ out << LXCB::FULLSCREEN; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_ABOVE){ out << LXCB::KEEP_ABOVE; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_BELOW){ out << LXCB::KEEP_BELOW; } + else if(reply.atoms[i]==EWMH._NET_WM_STATE_DEMANDS_ATTENTION){ out << LXCB::DEMANDS_ATTENTION; } + //else if(reply.atoms[i]==EWMH._NET_WM_STATE_FOCUSED){ out << LXCB::FOCUSED; } + } + } + return out; +} + +void LXCB::WM_Set_Window_States(WId win, QList<LXCB::WINDOWSTATE> list){ + //Convert to the XCB format + xcb_atom_t array[list.length()]; + for(int i=0; i<list.length(); i++){ + switch(list[i]){ + case LXCB::MODAL: + array[i] = EWMH._NET_WM_STATE_MODAL; break; + case LXCB::STICKY: + array[i] = EWMH._NET_WM_STATE_STICKY; break; + case LXCB::MAX_VERT: + array[i] = EWMH._NET_WM_STATE_MAXIMIZED_VERT; break; + case LXCB::MAX_HORZ: + array[i] = EWMH._NET_WM_STATE_MAXIMIZED_HORZ; break; + case LXCB::SHADED: + array[i] = EWMH._NET_WM_STATE_SHADED; break; + case LXCB::SKIP_TASKBAR: + array[i] = EWMH._NET_WM_STATE_SKIP_TASKBAR; break; + case LXCB::SKIP_PAGER: + array[i] = EWMH._NET_WM_STATE_SKIP_PAGER; break; + case LXCB::HIDDEN: + array[i] = EWMH._NET_WM_STATE_HIDDEN; break; + case LXCB::FULLSCREEN: + array[i] = EWMH._NET_WM_STATE_FULLSCREEN; break; + case LXCB::KEEP_ABOVE: + array[i] = EWMH._NET_WM_STATE_ABOVE; break; + case LXCB::KEEP_BELOW: + array[i] = EWMH._NET_WM_STATE_BELOW; break; + case LXCB::DEMANDS_ATTENTION: + array[i] = EWMH._NET_WM_STATE_DEMANDS_ATTENTION; break; + //case LXCB::FOCUSED: + //array[i] = EWMH._NET_WM_STATE_FOCUSED; break; + } + } + //Now set the property + xcb_ewmh_set_wm_state(&EWMH, win, list.length(), array); +} + // _NET_WM_ALLOWED_ACTIONS // _NET_WM_STRUT diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index 6ec8ca32..426b86ab 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -39,15 +39,18 @@ class LXCB{ public: - enum WINDOWSTATE {IGNORE, INVISIBLE, VISIBLE, ACTIVE, ATTENTION}; //note that this in order of priority + enum WINDOWVISIBILITY {IGNORE, INVISIBLE, VISIBLE, ACTIVE, ATTENTION}; //note that this in order of priority enum ICCCM_STATE {WITHDRAWN, NORMAL, ICONIC}; enum GRAVITY {FORGET=0, NW=1, N=2, NE=3, W=4, CENTER=5, E=6, SW=7, S=8, SE=9, STATIC=10}; enum STACK_FLAG {ABOVE=0, BELOW=1, TOP_IF=2, BOTTOM_IF=3, OPPOSITE=4}; + enum WINDOWTYPE {DESKTOP, DOCK, TOOLBAR, MENU, UTILITY, SPLASH, DIALOG, DROPDOWN_MENU, POPUP_MENU, TOOLTIP, NOTIFICATION, COMBO, DND, NORMALTYPE}; + enum WINDOWSTATE {MODAL, STICKY, MAX_VERT, MAX_HORZ, SHADED, SKIP_TASKBAR, SKIP_PAGER, HIDDEN, FULLSCREEN, KEEP_ABOVE, KEEP_BELOW, DEMANDS_ATTENTION}; //Now enums which can have multiple values at once (Use the plural form for the QFlags) enum ICCCM_PROTOCOL {TAKE_FOCUS = 0x0, DELETE_WINDOW = 0x1}; //any combination Q_DECLARE_FLAGS(ICCCM_PROTOCOLS, ICCCM_PROTOCOL); enum MOVERESIZE_WINDOW_FLAG { X=0x0, Y=0x1, WIDTH=0x2, HEIGHT=0x3}; Q_DECLARE_FLAGS(MOVERESIZE_WINDOW_FLAGS, MOVERESIZE_WINDOW_FLAG); + xcb_ewmh_connection_t EWMH; //This is where all the screen info and atoms are located @@ -71,7 +74,7 @@ public: unsigned int WindowWorkspace(WId); //The workspace the window is on QRect WindowGeometry(WId win, bool includeFrame = true); //the geometry of the window (frame excluded) QList<int> WindowFrameGeometry(WId win); //Returns: [top,bottom,left,right] sizes of the frame - WINDOWSTATE WindowState(WId win); //Visible state of window + LXCB::WINDOWVISIBILITY WindowState(WId win); //Visible state of window QString WindowVisibleIconName(WId win); //_NET_WM_VISIBLE_ICON_NAME QString WindowIconName(WId win); //_NET_WM_ICON_NAME QString WindowVisibleName(WId win); //_NET_WM_VISIBLE_NAME @@ -261,8 +264,13 @@ public: void WM_Set_Desktop(WId win, int num); //use -1 to set it for all desktops // _NET_WM_WINDOW_TYPE + // Note: While this returns a list, they are ordered by priority for WM usage (use the first one known about) + QList<LXCB::WINDOWTYPE> WM_Get_Window_Type(WId win); + void WM_Set_Window_Type(WId win, QList<LXCB::WINDOWTYPE> list); // _NET_WM_STATE + QList<LXCB::WINDOWSTATE> WM_Get_Window_States(WId win); + void WM_Set_Window_States(WId win, QList<LXCB::WINDOWSTATE> list); // _NET_WM_ALLOWED_ACTIONS |