diff options
author | Ken Moore <ken@ixsystems.com> | 2017-08-27 11:29:43 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-08-27 11:29:43 -0400 |
commit | 39c9a096ef2bee1e224561ed5daa6a63a9018b36 (patch) | |
tree | 320766d6583e8fcb9682412d79246182a19c38c2 | |
parent | Add 3 simple window arrangements to Lumina 2. (diff) | |
download | lumina-39c9a096ef2bee1e224561ed5daa6a63a9018b36.tar.gz lumina-39c9a096ef2bee1e224561ed5daa6a63a9018b36.tar.bz2 lumina-39c9a096ef2bee1e224561ed5daa6a63a9018b36.zip |
A bunch more work on Lumina 2 mouse focus settings and such.
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.cpp | 51 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.h | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEventFilter.cpp | 5 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEventFilter.h | 1 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeWindowSystem.cpp | 29 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeWindowSystem.h | 1 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.cpp | 8 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootWindow-mgmt.cpp | 2 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/LSession.cpp | 7 |
9 files changed, 94 insertions, 14 deletions
diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.cpp b/src-qt5/core/libLumina/NativeEmbedWidget.cpp index 9fac4f1a..41a036a2 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.cpp +++ b/src-qt5/core/libLumina/NativeEmbedWidget.cpp @@ -12,6 +12,7 @@ #include <xcb/xproto.h> #include <xcb/xcb_aux.h> +#include <xcb/xcb_event.h> #include <xcb/xcb_image.h> #include <xcb/composite.h> #include <X11/extensions/Xdamage.h> @@ -19,7 +20,7 @@ #define DISABLE_COMPOSITING false inline void registerClientEvents(WId id){ - uint32_t value_list[1] = {XCB_EVENT_MASK_PROPERTY_CHANGE + uint32_t value_list[1] = { (XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION @@ -28,7 +29,7 @@ inline void registerClientEvents(WId id){ | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY - | XCB_EVENT_MASK_ENTER_WINDOW + | XCB_EVENT_MASK_ENTER_WINDOW) }; xcb_change_window_attributes(QX11Info::connection(), id, XCB_CW_EVENT_MASK, value_list); } @@ -60,6 +61,7 @@ void NativeEmbedWidget::hideWindow(){ void NativeEmbedWidget::showWindow(){ xcb_map_window(QX11Info::connection(), WIN->id()); + reregisterEvents(); QTimer::singleShot(0,this, SLOT(repaintWindow())); } @@ -89,6 +91,7 @@ QImage NativeEmbedWidget::windowImage(QRect geom){ NativeEmbedWidget::NativeEmbedWidget(QWidget *parent) : QWidget(parent){ WIN = 0; //nothing embedded yet paused = false; + this->setMouseTracking(true); //this->setSizeIncrement(2,2); } @@ -265,12 +268,54 @@ void NativeEmbedWidget::paintEvent(QPaintEvent *ev){ } +void NativeEmbedWidget::enterEvent(QEvent *ev){ + QWidget::enterEvent(ev); + //this->grabMouse(); //xcb_grab_pointer_unchecked(QX11Info::connection(), ); +} + +void NativeEmbedWidget::leaveEvent(QEvent *ev){ + QWidget::leaveEvent(ev); + //this->releaseMouse(); //xcb_ungrab_pointer(QX11Info::connection(), XCB_CURRENT_TIME); +} + bool NativeEmbedWidget::nativeEvent(const QByteArray &eventType, void *message, long *result){ /*if(eventType=="xcb_generic_event_t" && WIN!=0){ //Convert to known event type (for X11 systems) xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message); + //qDebug() << "Got Embed Window Event:" << xcb_event_get_label(ev->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) << xcb_event_get_request_label(ev->response_type); + uint32_t mask = 0; + switch( ev->response_type & XCB_EVENT_RESPONSE_TYPE_MASK){ + case XCB_BUTTON_PRESS: + //This is a mouse button press + mask = XCB_EVENT_MASK_BUTTON_PRESS; + break; + case XCB_BUTTON_RELEASE: + //This is a mouse button release + //qDebug() << "Button Release Event"; + mask = XCB_EVENT_MASK_BUTTON_RELEASE; + break; + case XCB_MOTION_NOTIFY: + //This is a mouse movement event + mask = XCB_EVENT_MASK_POINTER_MOTION; + break; + case XCB_ENTER_NOTIFY: + //This is a mouse movement event when mouse goes over a new window + mask = XCB_EVENT_MASK_ENTER_WINDOW; + break; + case XCB_LEAVE_NOTIFY: + //This is a mouse movement event when mouse goes leaves a window + mask = XCB_EVENT_MASK_LEAVE_WINDOW; + break; + default: + mask = 0; + } + //Now forward this event on to the embedded window - xcb_send_event(QX11Info::connection(), true, WIN->id(), EVENT_MASK, ev); + if(mask!=0){ + qDebug() << " - Got a mouse event"; + xcb_send_event(QX11Info::connection(), true, WIN->id(),mask, (char*) ev); + return true; + } }*/ return false; } diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.h b/src-qt5/core/libLumina/NativeEmbedWidget.h index 523ff790..7e129fa3 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.h +++ b/src-qt5/core/libLumina/NativeEmbedWidget.h @@ -43,9 +43,9 @@ public: bool detachWindow(); bool isEmbedded(); //status of the embed +public slots: void raiseWindow(); -public slots: //Pause/resume void pause(); void resume(); @@ -59,6 +59,8 @@ protected: void showEvent(QShowEvent *ev); void hideEvent(QHideEvent *ev); void paintEvent(QPaintEvent *ev); + void enterEvent(QEvent *ev); + void leaveEvent(QEvent *ev); bool nativeEvent(const QByteArray &eventType, void *message, long *result); }; diff --git a/src-qt5/core/libLumina/NativeEventFilter.cpp b/src-qt5/core/libLumina/NativeEventFilter.cpp index df44c7fb..a2016402 100644 --- a/src-qt5/core/libLumina/NativeEventFilter.cpp +++ b/src-qt5/core/libLumina/NativeEventFilter.cpp @@ -81,6 +81,9 @@ inline void ParsePropertyEvent(xcb_property_notify_event_t *ev, NativeEventFilte //} obj->emit WindowPropertyChanged(ev->window, prop); }else{ + //Quick re-check of the simple properties (nothing like the icon or other graphics) + obj->emit WindowPropertiesChanged(ev->window, QList<NativeWindow::Property>() << NativeWindow::Title + << NativeWindow::ShortTitle << NativeWindow::Workspace ); //qDebug() << "Unknown Property Change:" << ev->window << ev->atom; } } @@ -98,7 +101,7 @@ inline void ParseClientMessageEvent(xcb_client_message_event_t *ev, NativeEventF else if(ev->type==EWMH._NET_WM_STATE){ prop = NativeWindow::States; } if(prop!=NativeWindow::None){ - //if(DEBUG){ + //if(DEBUG){ qDebug() << "Detected Property Change Request:" << ev->window << prop; //} if(val.isNull()){ obj->emit WindowPropertyChanged(ev->window, prop); } else{ obj->emit RequestWindowPropertyChange(ev->window, prop, val); } diff --git a/src-qt5/core/libLumina/NativeEventFilter.h b/src-qt5/core/libLumina/NativeEventFilter.h index 2b184f99..a3be3ef1 100644 --- a/src-qt5/core/libLumina/NativeEventFilter.h +++ b/src-qt5/core/libLumina/NativeEventFilter.h @@ -34,6 +34,7 @@ signals: void WindowCreated(WId); void WindowDestroyed(WId); void WindowPropertyChanged(WId, NativeWindow::Property); + void WindowPropertiesChanged(WId, QList<NativeWindow::Property>); void WindowPropertyChanged(WId, NativeWindow::Property, QVariant); void WindowPropertiesChanged(WId, QList<NativeWindow::Property>, QList<QVariant>); void RequestWindowPropertyChange(WId, NativeWindow::Property, QVariant); diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp index e1478b41..cd2459d3 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.cpp +++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp @@ -255,7 +255,7 @@ NativeWindow* NativeWindowSystem::findWindow(WId id, bool checkRelated){ //qDebug() << "Find Window:" << id; for(int i=0; i<NWindows.length(); i++){ if(id==NWindows[i]->id() ){ return NWindows[i]; } - else if(id==NWindows[i]->frameId() ){ qDebug() << "Matched Frame:" << id; return NWindows[i]; } + else if(id==NWindows[i]->frameId() ){ return NWindows[i]; } //if(checkRelated && NWindows[i]->isRelatedTo(id)){ return NWindows[i]; } //else if(!checkRelated && id==NWindows[i]->id()){ return NWindows[i]; } } @@ -498,7 +498,7 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native } uint16_t mask = 0; mask = mask | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y; - qDebug() << "Configure window Geometry:" << sz; + //qDebug() << "Configure window Geometry:" << sz; xcb_configure_window_aux(QX11Info::connection(), win->id(), mask, &valList); } if(props.contains(NativeWindow::Name)){ @@ -667,7 +667,7 @@ int NativeWindowSystem::currentWorkspace(){ //NativeWindowEventFilter interactions void NativeWindowSystem::NewWindowDetected(WId id){ //Make sure this can be managed first - if(findWindow(id, false) != 0){ qDebug() << "Window Already Managed!!!!"; findWindow(id,false)->setProperty(NativeWindow::Visible, true, true); return; } //already managed + if(findWindow(id, false) != 0){ findWindow(id,false)->setProperty(NativeWindow::Visible, true, true); return; } //already managed xcb_get_window_attributes_cookie_t cookie = xcb_get_window_attributes(QX11Info::connection(), id); xcb_get_window_attributes_reply_t *attr = xcb_get_window_attributes_reply(QX11Info::connection(), cookie, NULL); if(attr == 0){ return; } //could not get attributes of window @@ -679,7 +679,7 @@ void NativeWindowSystem::NewWindowDetected(WId id){ registerClientEvents(win->id()); NWindows << win; UpdateWindowProperties(win, NativeWindow::allProperties()); - qDebug() << "New Window [& associated ID's]:" << win->id() << win->frameId() << win->property(NativeWindow::RelatedWindows); + qDebug() << "New Window [& associated ID's]:" << win->id() << win->property(NativeWindow::Name).toString(); //Now setup the connections with this window connect(win, SIGNAL(RequestClose(WId)), this, SLOT(RequestClose(WId)) ); connect(win, SIGNAL(RequestKill(WId)), this, SLOT(RequestKill(WId)) ); @@ -744,6 +744,27 @@ void NativeWindowSystem::WindowPropertyChanged(WId id, NativeWindow::Property pr if(win==0){ win = findTrayWindow(id); } if(win!=0){ UpdateWindowProperties(win, QList<NativeWindow::Property>() << prop); + }else if(prop != 0){ + //Could not find the window for a specific property with an undefined value + // - update this property for all the windows just in case + for(int i=0; i<NWindows.length(); i++){ + UpdateWindowProperties( NWindows[i], QList<NativeWindow::Property>() << prop); + } + } +} + +void NativeWindowSystem::WindowPropertiesChanged(WId id, QList<NativeWindow::Property> props){ + //NOTE: This is triggered by the NativeEventFilter - not by changes to the NativeWindow objects themselves + NativeWindow *win = findWindow(id); + if(win==0){ win = findTrayWindow(id); } + if(win!=0){ + UpdateWindowProperties(win, props); + }else{ + //Could not find the window for a specific property with an undefined value + // - update this property for all the windows just in case + for(int i=0; i<NWindows.length(); i++){ + UpdateWindowProperties( NWindows[i], props); + } } } diff --git a/src-qt5/core/libLumina/NativeWindowSystem.h b/src-qt5/core/libLumina/NativeWindowSystem.h index 97208c2f..b67ecc94 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.h +++ b/src-qt5/core/libLumina/NativeWindowSystem.h @@ -105,6 +105,7 @@ public slots: void NewTrayWindowDetected(WId); //will automatically create the new NativeWindow object void WindowCloseDetected(WId); //will update the lists and make changes if needed void WindowPropertyChanged(WId, NativeWindow::Property); //will rescan the window and update the object as needed + void WindowPropertiesChanged(WId, QList<NativeWindow::Property>); void WindowPropertyChanged(WId, NativeWindow::Property, QVariant); //will save that property/value to the right object void WindowPropertiesChanged(WId, QList<NativeWindow::Property>, QList<QVariant>); void RequestPropertyChange(WId, NativeWindow::Property, QVariant); diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp index a42f866a..fba02e96 100644 --- a/src-qt5/core/libLumina/RootSubWindow.cpp +++ b/src-qt5/core/libLumina/RootSubWindow.cpp @@ -192,6 +192,7 @@ void RootSubWindow::initWindowFrame(){ maxB->setCursor(Qt::ArrowCursor); otherM->setCursor(Qt::ArrowCursor); titleLabel->setCursor(Qt::ArrowCursor); + WinWidget->setCursor(Qt::ArrowCursor); //Now all the stylesheet options this->setObjectName("WindowFrame"); closeB->setObjectName("Button_Close"); @@ -294,6 +295,7 @@ void RootSubWindow::toggleSticky(){ } void RootSubWindow::activate(){ + WinWidget->raiseWindow(); WIN->requestProperty(NativeWindow::Active, true, true); } @@ -501,8 +503,8 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){ //Check for a right-click event //qDebug() << "Frame Mouse Release Event"; QFrame::mouseReleaseEvent(ev); - WinWidget->raiseWindow(); //need to ensure the native window is always on top of this frame if( (activeState==Normal) && (titleBar->geometry().contains(ev->pos())) && (ev->button()==Qt::RightButton) ){ + WinWidget->raiseWindow();//need to ensure the native window is always on top of this frame but under the menu otherM->popup(ev->globalPos()); return; } @@ -511,7 +513,9 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){ activeState = Normal; QApplication::restoreOverrideCursor(); setMouseCursor( getStateAtPoint(ev->pos()) ); - if(QFrame::mouseGrabber() == this){ this->releaseMouse(); activate(); } + if(QFrame::mouseGrabber() == this){ this->releaseMouse(); } + activate(); + QTimer::singleShot(0, WinWidget, SLOT(raiseWindow()) ); } void RootSubWindow::leaveEvent(QEvent *ev){ diff --git a/src-qt5/core/libLumina/RootWindow-mgmt.cpp b/src-qt5/core/libLumina/RootWindow-mgmt.cpp index 525e43be..24ea639b 100644 --- a/src-qt5/core/libLumina/RootWindow-mgmt.cpp +++ b/src-qt5/core/libLumina/RootWindow-mgmt.cpp @@ -46,6 +46,8 @@ void RootWindow::arrangeWindows(RootSubWindow *primary, QString type, bool prima if(type=="center"){ QPoint ct = desktopArea.center(); winlist[i]->setGeometry( ct.x()-(geom.width()/2), ct.y()-(geom.height()/2), geom.width(), geom.height()); + }else if(type=="snap"){ + }else if(type=="single_max"){ winlist[i]->setGeometry( desktopArea.x(), desktopArea.y(), desktopArea.width(), desktopArea.height()); }else if(type=="under-mouse"){ diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index c6f79584..bee12180 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -38,9 +38,9 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu this->setOrganizationName("LuminaDesktopEnvironment"); this->setQuitOnLastWindowClosed(false); //since the LDesktop's are not necessarily "window"s //Enable a few of the simple effects by default - this->setEffectEnabled( Qt::UI_AnimateMenu, true); - this->setEffectEnabled( Qt::UI_AnimateCombo, true); - this->setEffectEnabled( Qt::UI_AnimateTooltip, true); + //this->setEffectEnabled( Qt::UI_AnimateMenu, true); + //this->setEffectEnabled( Qt::UI_AnimateCombo, true); + //this->setEffectEnabled( Qt::UI_AnimateTooltip, true); this->setAttribute(Qt::AA_UseDesktopOpenGL); this->setAttribute(Qt::AA_UseHighDpiPixmaps); //allow pixmaps to be scaled up as well as down @@ -231,6 +231,7 @@ void LSession::setupGlobalConnections(){ connect(Lumina::NEF, SIGNAL(WindowCreated(WId)), Lumina::NWS, SLOT(NewWindowDetected(WId))); connect(Lumina::NEF, SIGNAL(WindowDestroyed(WId)), Lumina::NWS, SLOT(WindowCloseDetected(WId))); connect(Lumina::NEF, SIGNAL(WindowPropertyChanged(WId, NativeWindow::Property)), Lumina::NWS, SLOT(WindowPropertyChanged(WId, NativeWindow::Property))); + connect(Lumina::NEF, SIGNAL(WindowPropertiesChanged(WId, QList<NativeWindow::Property>)), Lumina::NWS, SLOT(WindowPropertiesChanged(WId, QList<NativeWindow::Property>)) ); connect(Lumina::NEF, SIGNAL(WindowPropertyChanged(WId, NativeWindow::Property, QVariant)), Lumina::NWS, SLOT(WindowPropertyChanged(WId, NativeWindow::Property, QVariant))); connect(Lumina::NEF, SIGNAL(WindowPropertiesChanged(WId, QList<NativeWindow::Property>, QList<QVariant>)), Lumina::NWS, SLOT(WindowPropertiesChanged(WId, QList<NativeWindow::Property>, QList<QVariant>)) ); connect(Lumina::NEF, SIGNAL(RequestWindowPropertyChange(WId, NativeWindow::Property, QVariant)), Lumina::NWS, SLOT(RequestPropertyChange(WId, NativeWindow::Property, QVariant))); |