aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-06-06 11:27:51 -0400
committerKen Moore <ken@ixsystems.com>2018-06-06 11:27:51 -0400
commit2f04b6230720e61533ce3527bf26e94ed3d93467 (patch)
treebdc5fe0239b1a5786a3a5054c885986a1dad82ab /src-qt5/core/lumina-desktop-unified
parentFix up the crash on resize. (diff)
downloadlumina-2f04b6230720e61533ce3527bf26e94ed3d93467.tar.gz
lumina-2f04b6230720e61533ce3527bf26e94ed3d93467.tar.bz2
lumina-2f04b6230720e61533ce3527bf26e94ed3d93467.zip
Get more of the tray icon reading put together.
Cleanup some whitespace and turn off some debugging
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
-rw-r--r--src-qt5/core/lumina-desktop-unified/main.cpp2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp4
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h5
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/NativeEmbedWidget.h78
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/NativeEventFilter.cpp2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.cpp72
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/NativeWindowSystem.h1
7 files changed, 121 insertions, 43 deletions
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();
bgstack15