diff options
Diffstat (limited to 'src-qt5/core')
9 files changed, 181 insertions, 103 deletions
diff --git a/src-qt5/core/libLumina/LuminaX11.cpp b/src-qt5/core/libLumina/LuminaX11.cpp index dd98d12c..563f035e 100644 --- a/src-qt5/core/libLumina/LuminaX11.cpp +++ b/src-qt5/core/libLumina/LuminaX11.cpp @@ -959,7 +959,7 @@ QPixmap LXCB::TrayImage(WId win){ if(pix.isNull()){ pix = scrnlist[0]->grabWindow(win); } - return pix; + return pix; //NOTE: Code below here saved for reference later (as necessary) // ------------------------------- diff --git a/src-qt5/core/libLumina/LuminaX11.h b/src-qt5/core/libLumina/LuminaX11.h index 2f66ce06..453d3443 100644 --- a/src-qt5/core/libLumina/LuminaX11.h +++ b/src-qt5/core/libLumina/LuminaX11.h @@ -100,25 +100,25 @@ public: enum WINDOWSTATE {S_MODAL, S_STICKY, S_MAX_VERT, S_MAX_HORZ, S_SHADED, S_SKIP_TASKBAR, S_SKIP_PAGER, S_HIDDEN, S_FULLSCREEN, S_ABOVE, S_BELOW, S_ATTENTION}; enum WINDOWACTION {A_MOVE, A_RESIZE, A_MINIMIZE, A_SHADE, A_STICK, A_MAX_VERT, A_MAX_HORZ, A_FULLSCREEN, A_CHANGE_DESKTOP, A_CLOSE, A_ABOVE, A_BELOW}; //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 + enum ICCCM_PROTOCOL {TAKE_FOCUS = 0x0, DELETE_WINDOW = 0x1}; //any combination Q_DECLARE_FLAGS(ICCCM_PROTOCOLS, ICCCM_PROTOCOL); enum SIZE_HINT { US_POSITION=1<<0, US_SIZE=1<<1, P_POSITION=1<<2, P_SIZE=1<<3, P_MIN_SIZE=1<<4, P_MAX_SIZE=1<<5, P_RESIZE_INC=1<<6, P_ASPECT=1<<7, BASE_SIZE=1<<8, P_WIN_GRAVITY=1<<9 }; Q_DECLARE_FLAGS(SIZE_HINTS, SIZE_HINT); 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 LXCB(); ~LXCB(); - + //== Main Interface functions == // General Information QList<WId> WindowList(bool rawlist = false); //list all non-Lumina windows (rawlist -> all workspaces) unsigned int CurrentWorkspace(); unsigned int NumberOfWorkspaces(); WId ActiveWindow(); //fetch the ID for the currently active window - + //Session Modification bool CheckDisableXinerama(); //returns true if Xinerama was initially set but now disabled void RegisterVirtualRoots(QList<WId> roots); @@ -139,13 +139,13 @@ public: bool WindowIsMaximized(WId win); int WindowIsFullscreen(WId win); //Returns the screen number if the window is fullscreen (or -1) QIcon WindowIcon(WId win); //_NET_WM_ICON - + //Window Modification // - SubStructure simplifications (not commonly used) void SelectInput(WId win, bool isEmbed = false); //XSelectInput replacement (to see window events) uint GenerateDamageID(WId); void paintRoot(QRect area, const QPixmap *pix); - + // - General Window Modifications void SetAsSticky(WId); //Stick to all workspaces void SetDisableWMActions(WId); //Disable WM control (shortcuts/automatic functions) @@ -161,13 +161,13 @@ public: void ResizeWindow(WId win, int width, int height); void ResizeWindow(WId win, QSize sz){ ResizeWindow(win, sz.width(), sz.height()); } //overload for simplicity void ReserveLocation(WId win, QRect geom, QString loc); - + //Window Embedding/Detaching (for system tray) //void SetWindowBackground(QWidget *parent, QRect area, WId client); uint EmbedWindow(WId win, WId container); //returns the damage ID (or 0 for an error) bool UnembedWindow(WId win); QPixmap TrayImage(WId win); - + //System Tray Management WId startSystemTray(int screen = 0); //Startup the system tray (returns window ID for tray) void closeSystemTray(WId); //Close the system tray @@ -179,16 +179,16 @@ public: void WM_CloseWindow(WId win, bool force = false); void WM_ShowWindow(WId win); void WM_HideWindow(WId win); - + WId WM_CreateWindow(WId parent = 0); - + // WM Utility Functions QList<WId> WM_RootWindows(); //return all windows which have root as the parent bool WM_ManageWindow(WId win, bool needsmap = true); //return whether the window is/should be managed QRect WM_Window_Geom(WId win); //Return the current window geometry void setupEventsForFrame(WId frame); bool setupEventsForRoot(WId root = 0); - + // ICCCM Standards (older standards) // -- WM_NAME QString WM_ICCCM_GetName(WId win); @@ -212,13 +212,13 @@ public: icccm_size_hints WM_ICCCM_GetNormalHints(WId win); //most values in structure are -1 if not set //void WM_ICCCM_SetNormalHints(WId win, icccm_size_hints hints); // -- WM_HINTS (contains WM_STATE) - + // -- WM_PROTOCOLS ICCCM_PROTOCOLS WM_ICCCM_GetProtocols(WId win); void WM_ICCCM_SetProtocols(WId win, ICCCM_PROTOCOLS flags); - + //NET_WM Standards (newer standards) - + // -- ROOT WINDOW PROPERTIES // _NET_SUPPORTED void WM_Set_Root_Supported(); //set the atom list of supported features on the root window @@ -226,192 +226,192 @@ public: // Note: client list ordered oldest->newest, stacking list ordered bottom->top QList<WId> WM_Get_Client_List(bool stacking = false); void WM_Set_Client_List(QList<WId> list, bool stacking=false); - + // _NET_NUMBER_OF_DESKTOPS // Note: This is the number of virtual workspaces, not monitors unsigned int WM_Get_Number_Desktops(); //return value equals 0 for errors void WM_SetNumber_Desktops(unsigned int number); //should be at least 1 - + // _NET_DESKTOP_GEOMETRY // Note: This property is the combined size and/or bounding rectangle of all monitors // The definition works well for single-monitors, but gets really fuzzy for multiple monitors QSize WM_Get_Desktop_Geometry(); void WM_Set_Desktop_Geometry(QSize); - + // _NET_DESKTOP_VIEWPORT - // Note: This is the X/Y origin of the viewport for each monitor + // Note: This is the X/Y origin of the viewport for each monitor // Thi is normally (0,0) , unless desktop larger than monitor supports QList<QPoint> WM_Get_Desktop_Viewport(); void WM_Set_Desktop_Viewport(QList<QPoint> list); - + // _NET_CURRENT_DESKTOP // Note: Current workspace number. Range = 0 to (_NET_NUMBER_OF_DESKTOPS - 1) int WM_Get_Current_Desktop(); //Returns -1 for errors void WM_Set_Current_Desktop(unsigned int num); - + // _NET_DESKTOP_NAMES QStringList WM_Get_Desktop_Names(); void WM_Set_Desktop_Names(QStringList list); - + // _NET_ACTIVE_WINDOW WId WM_Get_Active_Window(); void WM_Set_Active_Window(WId win); - + // _NET_WORKAREA // Note: The workarea is the recangle for each monitor where no space is reserved // This accounts for any STRUT's that are set, within the current VIEWPORT QList<QRect> WM_Get_Workarea(); void WM_Set_Workarea(QList<QRect> list); - + // _NET_SUPPORTING_WM_CHECK // Note: This needs to be set on two windows: root -> child, and child->child // So the "set" function will do both at the same time // The child window also needs the _NET_WM_NAME set to the window manager name WId WM_Get_Supporting_WM(WId win); void WM_Set_Supporting_WM(WId child); - + // _NET_VIRTUAL_ROOTS QList<WId> WM_Get_Virtual_Roots(); void WM_Set_Virtual_Roots(QList<WId> list); - + // _NET_DESKTOP_LAYOUT // NOTE: Skip this implementation for now - is supposed to be set by a pager (not the WM) // and the WM can choose to use/ignore it as necessary. // (Just use the current XRandR layout instead of this setting/property) - + // _NET_SHOWING_DESKTOP // Note: This is true/false depending on whether the WM is hiding all windows to show the desktop only bool WM_Get_Showing_Desktop(); void WM_Set_Showing_Desktop(bool show); - + // -- ROOT WINDOW MESSAGES/REQUESTS (for non-WM usage) // _NET_CLOSE_WINDOW void WM_Request_Close_Window(WId win); - + // _NET_MOVERESIZE_WINDOW // Note: Used for finalized movement/resize operations void WM_Request_MoveResize_Window(WId win, QRect geom, bool fromuser = false, LXCB::GRAVITY grav = LXCB::STATIC, LXCB::MOVERESIZE_WINDOW_FLAGS flags = LXCB::MOVERESIZE_WINDOW_FLAGS(LXCB::X | LXCB::Y | LXCB::WIDTH | LXCB::HEIGHT) ); - - // _NET_WM_MOVERESIZE + + // _NET_WM_MOVERESIZE // Note: Used for interactive clicks/changes to a window size/position // There are known race conditions/issues with this X format - so skip it for now (11/12/15) - + // _NET_RESTACK_WINDOW // Note: Send a request to re-stack a window (win) with respect to another window (sibling) // based on the flag to determine how the stack order should be changed void WM_Request_Restack_Window(WId win, WId sibling, LXCB::STACK_FLAG flag); - + // _NET_REQUEST_FRAME_EXTENTS // Note: This is used by client windows to get the _NET_FRAME_EXTENTS property pre-set // by the WM before the window is actually mapped (just an estimate of the frame at least) void WM_Request_Frame_Extents(WId win); - + // -- WINDOW PROPERTIES // _NET_SUPPORTED void WM_Set_Window_Supported(WId win); //set the atom list of supported features on the given window - + // _NET_WM_NAME QString WM_Get_Name(WId win); void WM_Set_Name(WId win, QString txt); - + // _NET_WM_VISIBLE_NAME QString WM_Get_Visible_Name(WId win); void WM_Set_Visible_Name(WId win, QString txt); - + // _NET_WM_ICON_NAME QString WM_Get_Icon_Name(WId win); void WM_Set_Icon_Name(WId win, QString txt); - + // _NET_WM_VISIBLE_ICON_NAME QString WM_Get_Visible_Icon_Name(WId win); void WM_Set_Visible_Icon_Name(WId win, QString txt); - + // _NET_WM_DESKTOP // Note: This refers to the virtual workspace, not the monitor/screen number int WM_Get_Desktop(WId win); //returns -1 if window on all desktops 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 QList<LXCB::WINDOWACTION> WM_Get_Window_Actions(WId win); void WM_Set_Window_Actions(WId win, QList<LXCB::WINDOWACTION> list); - + // _NET_WM_STRUT QList<unsigned int> WM_Get_Window_Strut(WId win); //Returns: [left,right,top,bottom] margins in pixels (always length 4) void WM_Set_Window_Strut(WId win, QList<unsigned int> margins); //Input: [left, right, top, bottom] - must be length 4 - + // _NET_WM_STRUT_PARTIAL QList<strut_geom> WM_Get_Window_Strut_Partial(WId win); //Returns: [left,right,top,bottom] struts void WM_Set_Window_Strut_Partial(WId win, QList<strut_geom> struts); //Input: [left,right,top,bottom] - must be length 4 - + // _NET_WM_ICON_GEOMETRY QRect WM_Get_Icon_Geometry(WId win); void WM_Set_Icon_Geometry(WId win, QRect geom); - + // _NET_WM_ICON // Note: Don't write a "Set" routine for this - is handled on the client side and not the WM/DE side QIcon WM_Get_Icon(WId win); - + // _NET_WM_PID // Note: Don't write a "Set" routine for this - is handled on the client side and not the WM/DE side unsigned int WM_Get_Pid(WId win); - + // _NET_WM_HANDLED_ICONS - // Note: Probably not going to need this - is used by pagers exclusively to tell the WM + // Note: Probably not going to need this - is used by pagers exclusively to tell the WM // not to provide task manager icons (not needed for an integrated WM/DE combination) bool WM_Get_Handled_Icons(WId win); void WM_Set_Handled_Icons(WId win, bool set); - + // _NET_WM_USER_TIME // Note: The user time property on a client window is supposed to be updated on user activity, // allowing the WM to be able to distinguish user activity from automated window actions unsigned int WM_Get_User_Time(WId win); void WM_Set_User_Time(WId win, unsigned int xtime); - + // _NET_WM_USER_TIME_WINDOW - // This returns the window to watch for time update events, + // This returns the window to watch for time update events, // instead of constantly polling all the (toplevel?) windows for the app // IGNORED - xcb_ewmh library does not appear to have valid support for this property yet (11/13/15) //WId WM_Get_User_Time_WIndow(WId win); //void WM_Set_User_Time_Window(WId win, WId utwin); - + // _NET_FRAME_EXTENTS QList<unsigned int> WM_Get_Frame_Extents(WId win); //Returns: [left,right,top,bottom] margins in pixels (always length 4) void WM_Set_Frame_Extents(WId win, QList<unsigned int> margins); //Input: [left, right, top, bottom] - must be length 4 - + // _NET_WM_OPAQUE_REGION // NOT SUPPORTED - missing in xcb_ewmh library (11/13/15) - + // _NET_WM_BYPASS_COMPOSITOR // NOT SUPPORTED - missing in xcb_ewmh library (11/13/15) - + // === SPECIAL WM PROTOCOLS (EWMH) === // _NET_WM_PING // Note: Used to determine if a window/app is hung before killing the process (with PID) // The client window should respond instantly if it is still active (waiting on user input for instance) void WM_Send_Ping(WId win); - + // _NET_WM_SYNC_REQUEST uint64_t WM_Get_Sync_Request_Counter(WId win); //void WM_Set_Sync_Request_Counter(WId win, uint64_t count); - + // _NET_WM_FULLSCREEN_MONITORS QList<unsigned int> WM_Get_Fullscreen_Monitors(WId win); //Returns: [top,bottom,left,right] monitor numbers for window to use when fullscreen void WM_Set_Fullscreen_Montors(WId win, QList<unsigned int> list); //Input: [top,bottom,left,right] monitor numbers - + // _NET_WM_CM_S(n) // Note: This is used to check/register the compositing manager for the current X screen (#n) WId WM_Get_CM_Owner(); void WM_Set_CM_Owner(WId win); - + //============ // RANDR Functions (directly reading changing monitor outputs) //============ diff --git a/src-qt5/core/lumina-desktop-unified/main.cpp b/src-qt5/core/lumina-desktop-unified/main.cpp index 3cf35e50..798c2fec 100644 --- a/src-qt5/core/lumina-desktop-unified/main.cpp +++ b/src-qt5/core/lumina-desktop-unified/main.cpp @@ -8,7 +8,7 @@ #include "global-includes.h" #include "LSession.h" -#define DEBUG 1 +#define DEBUG 0 int main(int argc, char ** argv) { diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp index 45aa1101..6c3c7adf 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp @@ -327,6 +327,10 @@ void NativeWindowObject::requestPing(){ emit RequestPing(winid); } +void NativeWindowObject::requestActivate(){ + requestProperty(NativeWindowObject::Active, true); +} + // ==== PRIVATE ==== void NativeWindowObject::emitSinglePropChanged(NativeWindowObject::Property prop){ //Simple switch to emit the QML-usable signals as properties are changed diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h index c1851d0e..e4efeef7 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h @@ -39,8 +39,8 @@ public: enum State{ S_MODAL, S_STICKY, S_MAX_VERT, S_MAX_HORZ, S_SHADED, S_SKIP_TASKBAR, S_SKIP_PAGER, S_HIDDEN, S_FULLSCREEN, S_ABOVE, S_BELOW, S_ATTENTION }; enum Type{T_DESKTOP, T_DOCK, T_TOOLBAR, T_MENU, T_UTILITY, T_SPLASH, T_DIALOG, T_DROPDOWN_MENU, T_POPUP_MENU, T_TOOLTIP, T_NOTIFICATION, T_COMBO, T_DND, T_NORMAL }; enum Action {A_MOVE, A_RESIZE, A_MINIMIZE, A_SHADE, A_STICK, A_MAX_VERT, A_MAX_HORZ, A_FULLSCREEN, A_CHANGE_DESKTOP, A_CLOSE, A_ABOVE, A_BELOW}; - enum Location { TOP_LEFT, TOP, TOP_RIGHT, RIGHT, BOTTOM_RIGHT, BOTTOM, BOTTOM_LEFT, LEFT }; - Q_ENUM(Location) + enum Location { TOP_LEFT, TOP, TOP_RIGHT, RIGHT, BOTTOM_RIGHT, BOTTOM, BOTTOM_LEFT, LEFT }; + Q_ENUM(Location) enum Property{ /*QVariant Type*/ None=0, /*null*/ @@ -124,6 +124,7 @@ public slots: Q_INVOKABLE void requestClose(); //ask the app to close the window (may/not depending on activity) Q_INVOKABLE void requestKill(); //ask the WM to kill the app associated with this window (harsh - only use if not responding) Q_INVOKABLE void requestPing(); //ask the app if it is still active (a WindowNotResponding signal will get sent out if there is no reply); + Q_INVOKABLE void requestActivate(); private: QHash <NativeWindowObject::Property, QVariant> hash; diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeEmbedWidget.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeEmbedWidget.h index 24579308..0cce4fdb 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeEmbedWidget.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeEmbedWidget.h @@ -6,37 +6,72 @@ //=========================================== #ifndef _DESKTOP_WINDOW_EMBED_WIDGET_H #define _DESKTOP_WINDOW_EMBED_WIDGET_H + #include <global-includes.h> -class NativeEmbedWidget : public QObject{ +#define USE_QWINDOW_EMBED 1 + +class EmbedWidget : public QWidget { Q_OBJECT private: - QWidget *embedW; - QWindow *_window; NativeWindowObject *WIN; -private slots: - void visibleChanged(bool show){ WIN->setProperty(NativeWindowObject::Visible, show); } - void windowTitleChanged(QString title){ WIN->setProperty(NativeWindowObject::Title, title); } - void heightChanged(int val){ qDebug() << "Got Wndow Height change:" << val; } //WIN->setProperty(NativeWindowObject::Size, QSize(WIN->property(NativeWindowObject::Size).toSize().width(),val) ); } - void widthChanged(int val){ qDebug() << "Got Wndow Width change:" << val; } // WIN->setProperty(NativeWindowObject::Size, QSize(val, WIN->property(NativeWindowObject::Size).toSize().height()) ); } - void xChanged(int val){ qDebug() << "Got Window X changed:" << val; } - void yChanged(int val){ qDebug() << "Got Window Y changed:" << val; } +public: + EmbedWidget(NativeWindowObject *win, QWidget* parent) : QWidget(parent){ + WIN = win; + } + ~EmbedWidget(){} + +public slots: + void submitNewGeom(){ + QRect global_geom = QRect( this->mapToGlobal(QPoint(0,0)), this->size() ); + WIN->setGeometryNow(global_geom); + } + +protected: + void resizeEvent(QResizeEvent *ev){ + QWidget::resizeEvent(ev); + submitNewGeom(); + } + /*void moveEvent(QMoveEvent *ev){ + QWidget::moveEvent(ev); + submitNewGeom(); + }*/ + void hideEvent(QHideEvent *ev){ + QWidget::hideEvent(ev); + qDebug() << "Hide Event"; + WIN->requestProperty(NativeWindowObject::Visible, false); + } + void showEvent(QShowEvent *ev){ + QWidget::showEvent(ev); + qDebug() << "ShowEvent"; + WIN->requestProperty(NativeWindowObject::Visible, true); + } + void enterEvent(QEvent *ev){ + QWidget::enterEvent(ev); + qDebug() << "enter event"; + } + void paintEvent(QPaintEvent *){ + //Never paint anything with this widget + } + +}; +class NativeEmbedWidget : public QObject { + Q_OBJECT +private: + QWidget *embedW; + NativeWindowObject *WIN; public: NativeEmbedWidget(QWidget *parent, NativeWindowObject *obj) : QObject(parent){ WIN = obj; - _window = QWindow::fromWinId(WIN->id()); - //embedW = new QWidget(parent); - embedW = QWidget::createWindowContainer(_window, parent); - //Setup all the internal connections - connect(_window, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool)) ); - connect(_window, SIGNAL(windowTitleChanged(const QString&)), this, SLOT(windowTitleChanged(const QString&)) ); - connect(_window, SIGNAL(widthChanged(int)), this, SLOT(widthChanged(int)) ); - connect(_window, SIGNAL(heightChanged(int)), this, SLOT(heightChanged(int)) ); - connect(_window, SIGNAL(xChanged(int)), this, SLOT(xChanged(int)) ); - connect(_window, SIGNAL(yChanged(int)), this, SLOT(yChanged(int)) ); + if(USE_QWINDOW_EMBED){ + QWindow* _window = QWindow::fromWinId(WIN->id()); + embedW = QWidget::createWindowContainer(_window, parent); + }else{ + embedW = new EmbedWidget(WIN, parent); + } } ~NativeEmbedWidget(){} @@ -44,7 +79,8 @@ public: QRect geometry(){ return embedW->geometry(); } public slots: - void activateWindow(){ QTimer::singleShot(0, _window, SLOT(requestActivate())); } + void activateWindow(){ WIN->requestActivate(); } //QTimer::singleShot(0, WIN, SLOT(requestActivate())); } + void windowFrameMoved(){} }; diff --git a/src-qt5/core/lumina-desktop-unified/src-events/NativeEventFilter.cpp b/src-qt5/core/lumina-desktop-unified/src-events/NativeEventFilter.cpp index 507bcb9a..ee3bb239 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/NativeEventFilter.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeEventFilter.cpp @@ -224,7 +224,7 @@ bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message, break; //============================== case XCB_DESTROY_NOTIFY: - //qDebug() << "Window Closed Event:" << ((xcb_destroy_notify_event_t *)ev)->window; + qDebug() << "Window Closed Event:" << ((xcb_destroy_notify_event_t *)ev)->window; obj->emit WindowDestroyed( ((xcb_destroy_notify_event_t *) ev)->window ); break; //============================== diff --git a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp index 2afdd8c2..e11ed752 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp @@ -37,13 +37,13 @@ #define URGENCYHINT (1L << 8) //For window urgency detection #define ROOT_WIN_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \ - XCB_EVENT_MASK_BUTTON_PRESS | \ - XCB_EVENT_MASK_STRUCTURE_NOTIFY | \ - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \ - XCB_EVENT_MASK_POINTER_MOTION | \ - XCB_EVENT_MASK_PROPERTY_CHANGE | \ + XCB_EVENT_MASK_BUTTON_PRESS | \ + XCB_EVENT_MASK_STRUCTURE_NOTIFY | \ + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \ + XCB_EVENT_MASK_POINTER_MOTION | \ + XCB_EVENT_MASK_PROPERTY_CHANGE | \ XCB_EVENT_MASK_FOCUS_CHANGE | \ - XCB_EVENT_MASK_ENTER_WINDOW) + XCB_EVENT_MASK_ENTER_WINDOW) #define NORMAL_WIN_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | \ XCB_EVENT_MASK_BUTTON_RELEASE | \ @@ -384,14 +384,9 @@ void NativeWindowSystem::UpdateWindowProperties(NativeWindowObject* win, QList< QIcon icon; if(win == findTrayWindow(win->id())){ //Tray Icon Window - QPixmap pix; - //Get the current QScreen (for XCB->Qt conversion) - QList<QScreen*> scrnlist = QApplication::screens(); - //Try to grab the given window directly with Qt - for(int i=0; i<scrnlist.length() && pix.isNull(); i++){ - pix = scrnlist[i]->grabWindow(win->id()); - } - icon.addPixmap(pix); + icon.addPixmap( GetTrayWindowImage(win) ); + qDebug() << "Loaded Tray Icon" << !icon.isNull(); + }else{ //Standard window //Fetch the _NET_WM_ICON for the window and return it as a QIcon @@ -678,6 +673,47 @@ QImage NativeWindowSystem::GetWindowImage(NativeWindowObject* win){ //win->setProperty(NativeWindowObject::WinImage, QVariant::fromValue<QImage>(img) ); } +QPixmap NativeWindowSystem::GetTrayWindowImage(NativeWindowObject *win){ + QPixmap pix; + + //Get the current QScreen (for XCB->Qt conversion) + QList<QScreen*> scrnlist = QApplication::screens(); + if(scrnlist.isEmpty()){ return pix; } + + //Try to grab the given window directly with Qt + pix = scrnlist[0]->grabWindow(win->id()); + if(!pix.isNull()){ + //done - go ahead and return the image + return pix; + } + + //Now try the more complicated XCB read mechanisms + // ------------------------------- + //First get the pixmap from the XCB compositing layer (since the tray images are redirected there) + xcb_pixmap_t pixmap = xcb_generate_id(QX11Info::connection()); + xcb_composite_name_window_pixmap(QX11Info::connection(), win->id(), pixmap); + //Get the sizing information about the pixmap + xcb_get_geometry_cookie_t Gcookie = xcb_get_geometry_unchecked(QX11Info::connection(), pixmap); + xcb_get_geometry_reply_t *Greply = xcb_get_geometry_reply(QX11Info::connection(), Gcookie, NULL); + if(Greply==0){ qDebug() << "[Tray Image] - Geom Fetch Error:"; return QPixmap(); } //Error in geometry detection + + //Now convert the XCB pixmap into an XCB image + xcb_get_image_cookie_t GIcookie = xcb_get_image_unchecked(QX11Info::connection(), XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap, 0, 0, Greply->width, Greply->height, 0xffffffff); + xcb_get_image_reply_t *GIreply = xcb_get_image_reply(QX11Info::connection(), GIcookie, NULL); + if(GIreply==0){ qDebug() << "[Tray Image] - Image Convert Error:"; return QPixmap(); } //Error in conversion + uint8_t *GIdata = xcb_get_image_data(GIreply); + uint32_t BPL = xcb_get_image_data_length(GIreply) / Greply->height; //bytes per line + //Now convert the XCB image into a Qt Image + QImage image(const_cast<uint8_t *>(GIdata), Greply->width, Greply->height, BPL, QImage::Format_ARGB32_Premultiplied); + //Free the various data structures + free(GIreply); //done with get image reply + xcb_free_pixmap(QX11Info::connection(), pixmap); //done with the raw pixmap + free(Greply); //done with geom reply + + return pix; + +} + // === PUBLIC SLOTS === //These are the slots which are typically only used by the desktop system itself or the NativeEventFilter void NativeWindowSystem::RegisterVirtualRoot(WId id){ @@ -861,12 +897,12 @@ void NativeWindowSystem::NewTrayWindowDetected(WId id){ void NativeWindowSystem::WindowCloseDetected(WId id){ NativeWindowObject *win = findWindow(id, false); if(win==0){ win = findWindow(id, true); } - //qDebug() << "Got Window Closed" << id << win; - //qDebug() << "Old Window List:" << NWindows.length(); + qDebug() << "Got Window Closed" << id << win; + qDebug() << "Old Window List:" << NWindows.length(); if(win!=0){ NWindows.removeAll(win); win->emit WindowClosed(id); - //qDebug() << "Visible Window Closed!!!"; + qDebug() << "Visible Window Closed!!!"; emit WindowClosed(); win->deleteLater(); }else{ @@ -878,7 +914,7 @@ void NativeWindowSystem::WindowCloseDetected(WId id){ win->deleteLater(); } } - //qDebug() << " - Now:" << NWindows.length(); + qDebug() << " - Now:" << NWindows.length(); } void NativeWindowSystem::WindowPropertyChanged(WId id, NativeWindowObject::Property prop){ diff --git a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h index 405d3bc3..d3cbc591 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h +++ b/src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h @@ -64,6 +64,7 @@ public: void SetupNewWindow(NativeWindowObject *win); QImage GetWindowImage(NativeWindowObject *win); + QPixmap GetTrayWindowImage(NativeWindowObject *win); NativeWindowSystem(); ~NativeWindowSystem(); |