diff options
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.cpp | 30 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.h | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeWindowSystem.cpp | 25 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.cpp | 7 |
4 files changed, 49 insertions, 17 deletions
diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.cpp b/src-qt5/core/libLumina/NativeEmbedWidget.cpp index 68ba44a4..9fac4f1a 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.cpp +++ b/src-qt5/core/libLumina/NativeEmbedWidget.cpp @@ -18,11 +18,9 @@ #define DISABLE_COMPOSITING false -#define NORMAL_WIN_EVENT_MASK () - - inline void registerClientEvents(WId id){ - uint32_t value_list[1] = {XCB_EVENT_MASK_BUTTON_PRESS + 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 | XCB_EVENT_MASK_BUTTON_MOTION @@ -31,7 +29,7 @@ inline void registerClientEvents(WId id){ | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW - | XCB_EVENT_MASK_PROPERTY_CHANGE}; + }; xcb_change_window_attributes(QX11Info::connection(), id, XCB_CW_EVENT_MASK, value_list); } @@ -147,6 +145,11 @@ bool NativeEmbedWidget::isEmbedded(){ return (WIN!=0); } +void NativeEmbedWidget::raiseWindow(){ + uint32_t val = XCB_STACK_MODE_ABOVE; + xcb_configure_window(QX11Info::connection(), WIN->id(), XCB_CONFIG_WINDOW_STACK_MODE, &val); +} + // ============== // PUBLIC SLOTS // ============== @@ -208,6 +211,11 @@ void NativeEmbedWidget::repaintWindow(){ }else{ qDebug() << "Got Null Image!!"; } this->parentWidget()->update(); } + +void NativeEmbedWidget::reregisterEvents(){ + if(WIN!=0){ registerClientEvents(WIN->id()); } +} + // ============== // PROTECTED // ============== @@ -236,7 +244,7 @@ void NativeEmbedWidget::paintEvent(QPaintEvent *ev){ //else if(this->size() != winImage.size()){ QTimer::singleShot(0, this, SLOT(repaintWindow()) ); return; } //Need to paint the image from the window onto the widget as an overlay QRect geom = ev->rect(); //atomic updates - geom.adjust(-10,-10,10,10); //add an additional few pixels in each direction to be painted + //geom.adjust(-10,-10,10,10); //add an additional few pixels in each direction to be painted geom = geom.intersected(QRect(0,0,this->width(), this->height())); //ensure intersection with actual window if( !QRect(QPoint(0,0),winImage.size()).contains(geom) ){ QTimer::singleShot(0,this, SLOT(repaintWindow()) );return; } QPainter P(this); @@ -256,3 +264,13 @@ void NativeEmbedWidget::paintEvent(QPaintEvent *ev){ // Since this is an embedded image - we fully expect there to be transparency all/most of the 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); + //Now forward this event on to the embedded window + xcb_send_event(QX11Info::connection(), true, WIN->id(), EVENT_MASK, ev); + }*/ + return false; +} diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.h b/src-qt5/core/libLumina/NativeEmbedWidget.h index 65e03c51..523ff790 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.h +++ b/src-qt5/core/libLumina/NativeEmbedWidget.h @@ -43,7 +43,7 @@ public: bool detachWindow(); bool isEmbedded(); //status of the embed - + void raiseWindow(); public slots: //Pause/resume @@ -52,12 +52,14 @@ public slots: void resyncWindow(); void repaintWindow(); + void reregisterEvents(); protected: void resizeEvent(QResizeEvent *ev); void showEvent(QShowEvent *ev); void hideEvent(QHideEvent *ev); void paintEvent(QPaintEvent *ev); + bool nativeEvent(const QByteArray &eventType, void *message, long *result); }; #endif diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp index ea170b98..e1478b41 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.cpp +++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp @@ -45,7 +45,6 @@ #define ROOT_WIN_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \ XCB_EVENT_MASK_BUTTON_PRESS | \ XCB_EVENT_MASK_STRUCTURE_NOTIFY | \ - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \ XCB_EVENT_MASK_POINTER_MOTION | \ XCB_EVENT_MASK_PROPERTY_CHANGE | \ @@ -60,8 +59,9 @@ XCB_EVENT_MASK_STRUCTURE_NOTIFY | \ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \ - XCB_EVENT_MASK_ENTER_WINDOW| \ - XCB_EVENT_MASK_PROPERTY_CHANGE) + XCB_EVENT_MASK_ENTER_WINDOW | \ + XCB_EVENT_MASK_PROPERTY_CHANGE | \ + XCB_EVENT_MASK_FOCUS_CHANGE) inline void registerClientEvents(WId id){ uint32_t value_list[1] = {NORMAL_WIN_EVENT_MASK}; @@ -524,10 +524,20 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native if(props.contains(NativeWindow::Active)){ //Only one window can be "Active" at a time - so only do anything if this window wants to be active if(vals[props.indexOf(NativeWindow::Active)].toBool() ){ - xcb_ewmh_set_active_window(&obj->EWMH, QX11Info::appScreen(), (win->frameId()==0 ?win->id() : win->frameId())); + //Lower the currently active window (invisible window) to the bottom of the stack + xcb_window_t cactive; + if( 1 == xcb_ewmh_get_active_window_reply( &obj->EWMH, + xcb_ewmh_get_active_window_unchecked(&obj->EWMH, QX11Info::appScreen()), + &cactive, NULL) ){ + uint32_t val = XCB_STACK_MODE_BELOW; + xcb_configure_window(QX11Info::connection(), cactive, XCB_CONFIG_WINDOW_STACK_MODE, &val); + } + + xcb_ewmh_set_active_window(&obj->EWMH, QX11Info::appScreen(), win->id() ); //Also send the active window a message to take input focus + xcb_set_input_focus(QX11Info::connection(), XCB_INPUT_FOCUS_PARENT, win->id(), XCB_CURRENT_TIME); //Send the window a WM_TAKE_FOCUS message - xcb_client_message_event_t event; +/* xcb_client_message_event_t event; event.response_type = XCB_CLIENT_MESSAGE; event.format = 32; event.window = win->id(); @@ -540,6 +550,7 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native xcb_send_event(QX11Info::connection(), 0, win->id(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event); xcb_flush(QX11Info::connection()); +*/ } } @@ -625,7 +636,7 @@ void NativeWindowSystem::setRoot_desktopWorkarea(QList<QRect> list){ } void NativeWindowSystem::setRoot_activeWindow(WId win){ - xcb_ewmh_set_active_window(&obj->EWMH, QX11Info::appScreen(), win); + /*xcb_ewmh_set_active_window(&obj->EWMH, QX11Info::appScreen(), win); //Also send the active window a message to take input focus //Send the window a WM_TAKE_FOCUS message xcb_client_message_event_t event; @@ -640,7 +651,7 @@ void NativeWindowSystem::setRoot_activeWindow(WId win){ event.data.data32[4] = 0; xcb_send_event(QX11Info::connection(), 0, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event); - xcb_flush(QX11Info::connection()); + xcb_flush(QX11Info::connection());*/ } int NativeWindowSystem::currentWorkspace(){ diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp index 6341f923..68fdde5c 100644 --- a/src-qt5/core/libLumina/RootSubWindow.cpp +++ b/src-qt5/core/libLumina/RootSubWindow.cpp @@ -294,7 +294,7 @@ void RootSubWindow::toggleSticky(){ } void RootSubWindow::activate(){ - WIN->requestProperty(NativeWindow::Active, true); + WIN->requestProperty(NativeWindow::Active, true, true); } //Mouse Interactivity @@ -394,6 +394,7 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList void RootSubWindow::mousePressEvent(QMouseEvent *ev){ activate(); this->raise(); + WinWidget->raiseWindow(); //qDebug() << "Frame Mouse Press Event"; offset.setX(0); offset.setY(0); if(activeState != Normal){ return; } // do nothing - already in a state of grabbed mouse @@ -414,7 +415,7 @@ void RootSubWindow::mousePressEvent(QMouseEvent *ev){ } void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){ - activate(); //make sure this window is "Active" + //activate(); //make sure this window is "Active" on mouse over if(activeState == Normal){ setMouseCursor( getStateAtPoint(ev->pos()) ); //just update the mouse cursor }else{ @@ -508,7 +509,7 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){ activeState = Normal; QApplication::restoreOverrideCursor(); setMouseCursor( getStateAtPoint(ev->pos()) ); - if(QFrame::mouseGrabber() == this){ this->releaseMouse(); } + if(QFrame::mouseGrabber() == this){ this->releaseMouse(); activate(); } } void RootSubWindow::leaveEvent(QEvent *ev){ |