diff options
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r-- | src-qt5/core/libLumina/LDesktopUtils.cpp | 2 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LIconCache.cpp | 39 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LIconCache.h | 3 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.cpp | 21 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEmbedWidget.cpp | 42 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeEventFilter.cpp | 31 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeWindow.h | 32 | ||||
-rw-r--r-- | src-qt5/core/libLumina/NativeWindowSystem.cpp | 11 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.cpp | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.h | 1 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootWindow-mgmt.cpp | 27 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootWindow.cpp | 13 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootWindow.h | 5 |
13 files changed, 166 insertions, 65 deletions
diff --git a/src-qt5/core/libLumina/LDesktopUtils.cpp b/src-qt5/core/libLumina/LDesktopUtils.cpp index 4454d29b..b79f777d 100644 --- a/src-qt5/core/libLumina/LDesktopUtils.cpp +++ b/src-qt5/core/libLumina/LDesktopUtils.cpp @@ -16,7 +16,7 @@ static QStringList fav; QString LDesktopUtils::LuminaDesktopVersion(){ - QString ver = "1.3.1"; + QString ver = "1.3.2"; #ifdef GIT_VERSION ver.append( QString(" (Git Revision: %1)").arg(GIT_VERSION) ); #endif diff --git a/src-qt5/core/libLumina/LIconCache.cpp b/src-qt5/core/libLumina/LIconCache.cpp index 38367cef..70c360fb 100644 --- a/src-qt5/core/libLumina/LIconCache.cpp +++ b/src-qt5/core/libLumina/LIconCache.cpp @@ -55,9 +55,9 @@ QString LIconCache::findFile(QString icon){ if(icon.isEmpty()){ return ""; } //Get the currently-set theme QString cTheme = QIcon::themeName(); - if(cTheme.isEmpty()){ - QIcon::setThemeName("material-design-light"); - cTheme = "material-design-light"; + if(cTheme.isEmpty()){ + QIcon::setThemeName("material-design-light"); + cTheme = "material-design-light"; } //Make sure the current search paths correspond to this theme if( QDir::searchPaths("icontheme").filter("/"+cTheme+"/").isEmpty() ){ @@ -80,7 +80,7 @@ QString LIconCache::findFile(QString icon){ fall << getChildIconDirs(paths[i]+"hicolor"); //XDG fallback (apps add to this) } //Now load all the icon theme dependencies in order (Theme1 -> Theme2 -> Theme3 -> Fallback) - + //fall << LOS::AppPrefix()+"share/pixmaps"; //always use this as well as a final fallback QDir::setSearchPaths("icontheme", theme); QDir::setSearchPaths("default", oxy); @@ -121,6 +121,10 @@ QString LIconCache::findFile(QString icon){ void LIconCache::loadIcon(QAbstractButton *button, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + button->setIcon( iconFromTheme(icon)); + return ; + } //See if the icon has already been loaded into the HASH bool needload = !HASH.contains(icon); if(!needload){ @@ -138,6 +142,10 @@ void LIconCache::loadIcon(QAbstractButton *button, QString icon, bool noThumb){ void LIconCache::loadIcon(QAction *action, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + action->setIcon( iconFromTheme(icon)); + return ; + } //See if the icon has already been loaded into the HASH bool needload = !HASH.contains(icon); if(!needload){ @@ -155,6 +163,10 @@ void LIconCache::loadIcon(QAction *action, QString icon, bool noThumb){ void LIconCache::loadIcon(QLabel *label, QString icon, bool noThumb){ if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + label->setPixmap( iconFromTheme(icon).pixmap(label->sizeHint()) ); + return ; + } //See if the icon has already been loaded into the HASH bool needload = !HASH.contains(icon); if(!needload){ @@ -164,7 +176,7 @@ void LIconCache::loadIcon(QLabel *label, QString icon, bool noThumb){ //Need to load the icon icon_data idata; if(HASH.contains(icon)){ idata = HASH.value(icon); } - else { idata = createData(icon); + else { idata = createData(icon); if(idata.fullpath.isEmpty()){ return; } //nothing to do } idata.pendingLabels << QPointer<QLabel>(label); //save this QLabel for later @@ -183,6 +195,8 @@ void LIconCache::clearIconTheme(){ QIcon LIconCache::loadIcon(QString icon, bool noThumb){ if(icon.isEmpty()){ return QIcon(); } + if(isThemeIcon(icon)){ return iconFromTheme(icon); } + if(HASH.contains(icon)){ if(!HASH[icon].icon.isNull()){ return HASH[icon].icon; } else if(!HASH[icon].thumbnail.isNull() && !noThumb){ return HASH[icon].thumbnail; } @@ -217,7 +231,7 @@ QStringList LIconCache::getChildIconDirs(QString path){ QDir D(path); QStringList out; QStringList dirs = D.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - if(!dirs.isEmpty() && (dirs.contains("32x32") || dirs.contains("scalable")) ){ + if(!dirs.isEmpty() && (dirs.contains("32x32") || dirs.contains("scalable")) ){ //Need to sort these directories by image size //qDebug() << " - Parent:" << parent << "Dirs:" << dirs; for(int i=0; i<dirs.length(); i++){ @@ -290,6 +304,19 @@ void LIconCache::ReadFile(LIconCache *obj, QString id, QString path){ obj->emit InternalIconLoaded(id, cdt, BA); } +bool LIconCache::isThemeIcon(QString id){ + return (!id.contains("/") && !id.contains(".") && !id.contains("libreoffice") ); +} + +QIcon LIconCache::iconFromTheme(QString id){ + QIcon ico = QIcon::fromTheme(id); + if(ico.isNull()){ + //icon missing in theme? run the old icon-finder system + ico = QIcon(findFile(id)); + } + return ico; +} + // === PRIVATE SLOTS === void LIconCache::IconLoaded(QString id, QDateTime sync, QByteArray *data){ //qDebug() << "Icon Loaded:" << id << HASH.contains(id); diff --git a/src-qt5/core/libLumina/LIconCache.h b/src-qt5/core/libLumina/LIconCache.h index f58a5510..428ffcab 100644 --- a/src-qt5/core/libLumina/LIconCache.h +++ b/src-qt5/core/libLumina/LIconCache.h @@ -67,6 +67,9 @@ private: void startReadFile(QString id, QString path); void ReadFile(LIconCache *obj, QString id, QString path); + bool isThemeIcon(QString id); + QIcon iconFromTheme(QString id); + private slots: void IconLoaded(QString id, QDateTime sync, QByteArray *data); diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index 8da39564..01b3305e 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -723,7 +723,7 @@ QList<XDGDesktop*> LXDG::sortDesktopNames(QList<XDGDesktop*> apps){ //Sort the list by name of the application QHash<QString, XDGDesktop*> sorter; for(int i=0; i<apps.length(); i++){ - sorter.insert(apps[i]->name.toLower(), apps[i]); + sorter.insert(apps[i]->name.toLower(), apps[i]); } QStringList keys = sorter.keys(); keys.sort(); @@ -746,16 +746,25 @@ void LXDG::setEnvironmentVars(){ } QIcon LXDG::findIcon(QString iconName, QString fallback){ + //With the addition of the Lumina theme engine (8/3/17), switch back to using the Qt icon from theme method for apps + QIcon tmp; + if(!iconName.contains("libreoffice")){ //libreoffice is stupid - their svg icons are un-renderable with Qt + tmp = QIcon::fromTheme(iconName); + if(tmp.isNull()){ tmp = QIcon::fromTheme(fallback); } + } + if(!tmp.isNull()){ return tmp; } //found one in the theme + + //NOTE: This was re-written on 11/10/15 to avoid using the QIcon::fromTheme() framework // -- Too many issues with SVG files and/or search paths with the built-in system - + //Check if the icon is an absolute path and exists bool DEBUG =false; if(DEBUG){ qDebug() << "[LXDG] Find icon for:" << iconName; } if(QFile::exists(iconName) && iconName.startsWith("/")){ return QIcon(iconName); } else if(iconName.startsWith("/")){ iconName.section("/",-1); } //Invalid absolute path, just look for the icon //Check if the icon is actually given - if(iconName.isEmpty()){ + if(iconName.isEmpty()){ if(fallback.isEmpty()){ return QIcon(); } else{ return LXDG::findIcon(fallback, ""); } } @@ -763,9 +772,9 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ if(DEBUG){ qDebug() << "[LXDG] Start search for icon"; } //Get the currently-set theme QString cTheme = QIcon::themeName(); - if(cTheme.isEmpty()){ - QIcon::setThemeName("material-design-light"); - cTheme = "material-design-light"; + if(cTheme.isEmpty()){ + QIcon::setThemeName("material-design-light"); + cTheme = "material-design-light"; } //Make sure the current search paths correspond to this theme if( QDir::searchPaths("icontheme").filter("/"+cTheme+"/").isEmpty() ){ diff --git a/src-qt5/core/libLumina/NativeEmbedWidget.cpp b/src-qt5/core/libLumina/NativeEmbedWidget.cpp index ed0fd89c..487d1040 100644 --- a/src-qt5/core/libLumina/NativeEmbedWidget.cpp +++ b/src-qt5/core/libLumina/NativeEmbedWidget.cpp @@ -16,6 +16,8 @@ #include <xcb/composite.h> #include <X11/extensions/Xdamage.h> +#define DISABLE_COMPOSITING true + #define NORMAL_WIN_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | \ XCB_EVENT_MASK_BUTTON_RELEASE | \ XCB_EVENT_MASK_POINTER_MOTION | \ @@ -27,6 +29,7 @@ XCB_EVENT_MASK_ENTER_WINDOW| \ XCB_EVENT_MASK_PROPERTY_CHANGE) + inline void registerClientEvents(WId id){ uint32_t value_list[1] = {NORMAL_WIN_EVENT_MASK}; xcb_change_window_attributes(QX11Info::connection(), id, XCB_CW_EVENT_MASK, value_list); @@ -62,15 +65,14 @@ void NativeEmbedWidget::showWindow(){ } QImage NativeEmbedWidget::windowImage(QRect geom){ - //if(paused){ return QImage(); } //Pull the XCB pixmap out of the compositing layer xcb_pixmap_t pix = xcb_generate_id(QX11Info::connection()); xcb_composite_name_window_pixmap(QX11Info::connection(), WIN->id(), pix); - if(pix==0){ return QImage(); } + if(pix==0){ qDebug() << "Got blank pixmap!"; return QImage(); } //Convert this pixmap into a QImage xcb_image_t *ximg = xcb_image_get(QX11Info::connection(), pix, geom.x(), geom.y(), geom.width(), geom.height(), ~0, XCB_IMAGE_FORMAT_Z_PIXMAP); - if(ximg == 0){ return QImage(); } + if(ximg == 0){ qDebug() << "Got blank image!"; return QImage(); } QImage img(ximg->data, ximg->width, ximg->height, ximg->stride, QImage::Format_ARGB32_Premultiplied); img = img.copy(); //detach this image from the XCB data structures xcb_image_destroy(ximg); @@ -111,23 +113,26 @@ bool NativeEmbedWidget::embedWindow(NativeWindow *window){ xcb_send_event(QX11Info::connection(), 0, WIN->id(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event); */ //Now setup any redirects and return - xcb_composite_redirect_window(QX11Info::connection(), WIN->id(), XCB_COMPOSITE_REDIRECT_MANUAL); //XCB_COMPOSITE_REDIRECT_[MANUAL/AUTOMATIC]); - xcb_composite_redirect_subwindows(QX11Info::connection(), WIN->id(), XCB_COMPOSITE_REDIRECT_MANUAL); //XCB_COMPOSITE_REDIRECT_[MANUAL/AUTOMATIC]); - - //Now create/register the damage handler - // -- XCB (Note: The XCB damage registration is completely broken at the moment - 9/15/15, Ken Moore) - // -- Retested 6/29/17 (no change) Ken Moore - //xcb_damage_damage_t dmgID = xcb_generate_id(QX11Info::connection()); //This is a typedef for a 32-bit unsigned integer - //xcb_damage_create(QX11Info::connection(), dmgID, WIN->id(), XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES); - // -- XLib (Note: This is only used because the XCB routine above does not work - needs to be fixed upstream in XCB itself). - Damage dmgID = XDamageCreate(QX11Info::display(), WIN->id(), XDamageReportRawRectangles); - - WIN->addDamageID( (uint) dmgID); //save this for later + if(!DISABLE_COMPOSITING){ + xcb_composite_redirect_window(QX11Info::connection(), WIN->id(), XCB_COMPOSITE_REDIRECT_MANUAL); //XCB_COMPOSITE_REDIRECT_[MANUAL/AUTOMATIC]); + xcb_composite_redirect_subwindows(QX11Info::connection(), WIN->id(), XCB_COMPOSITE_REDIRECT_MANUAL); //XCB_COMPOSITE_REDIRECT_[MANUAL/AUTOMATIC]); + + //Now create/register the damage handler + // -- XCB (Note: The XCB damage registration is completely broken at the moment - 9/15/15, Ken Moore) + // -- Retested 6/29/17 (no change) Ken Moore + //xcb_damage_damage_t dmgID = xcb_generate_id(QX11Info::connection()); //This is a typedef for a 32-bit unsigned integer + //xcb_damage_create(QX11Info::connection(), dmgID, WIN->id(), XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES); + // -- XLib (Note: This is only used because the XCB routine above does not work - needs to be fixed upstream in XCB itself). + Damage dmgID = XDamageCreate(QX11Info::display(), WIN->id(), XDamageReportRawRectangles); + + WIN->addDamageID( (uint) dmgID); //save this for later + } WIN->addFrameWinID(this->winId()); connect(WIN, SIGNAL(VisualChanged()), this, SLOT(repaintWindow()) ); //make sure we repaint the widget on visual change registerClientEvents(WIN->id()); registerClientEvents(this->winId()); + qDebug() << "Events Registered:" << WIN->id() << this->winId(); return true; } @@ -185,16 +190,17 @@ void NativeEmbedWidget::resyncWindow(){ xcb_configure_window(QX11Info::connection(), WIN->id(), mask, valList); xcb_flush(QX11Info::connection()); syncWinSize(); - QTimer::singleShot(0, this, SLOT(repaintWindow()) ); + QTimer::singleShot(10, this, SLOT(repaintWindow()) ); } void NativeEmbedWidget::repaintWindow(){ + if(DISABLE_COMPOSITING){ return; } //qDebug() << "Update Window Image:" << !paused; if(paused){ return; } QImage tmp = windowImage( QRect(QPoint(0,0), this->size()) ); if(!tmp.isNull()){ winImage = tmp; - }//else{ qDebug() << "Got Null Image!!"; } + }else{ qDebug() << "Got Null Image!!"; } this->parentWidget()->update(); } // ============== @@ -218,7 +224,7 @@ void NativeEmbedWidget::hideEvent(QHideEvent *ev){ } void NativeEmbedWidget::paintEvent(QPaintEvent *ev){ - if(WIN==0){ QWidget::paintEvent(ev); return; } + if(WIN==0 || DISABLE_COMPOSITING){ QWidget::paintEvent(ev); return; } else if( winImage.isNull() ){ /*QTimer::singleShot(0, this, SLOT(repaintWindow()) );*/ return; } else if(paused){ return; } //else if(this->size()!=winSize){ QTimer::singleShot(0,this, SLOT(syncWinSize())); return; } //do not paint here - waiting to re-sync the sizes diff --git a/src-qt5/core/libLumina/NativeEventFilter.cpp b/src-qt5/core/libLumina/NativeEventFilter.cpp index d6c2da50..354dbe76 100644 --- a/src-qt5/core/libLumina/NativeEventFilter.cpp +++ b/src-qt5/core/libLumina/NativeEventFilter.cpp @@ -65,7 +65,7 @@ static xcb_ewmh_connection_t EWMH; static xcb_atom_t _NET_SYSTEM_TRAY_OPCODE = 0; inline void ParsePropertyEvent(xcb_property_notify_event_t *ev, NativeEventFilter *obj){ - //qDebug() << "Got Property Event:" << ev->window << ev->atom; + qDebug() << "Got Property Event:" << ev->window << ev->atom; NativeWindow::Property prop = NativeWindow::None; //Now determine which properties are getting changed, and update the native window as appropriate if(ev->atom == EWMH._NET_WM_NAME){ prop = NativeWindow::Title; } @@ -76,13 +76,36 @@ inline void ParsePropertyEvent(xcb_property_notify_event_t *ev, NativeEventFilte else if( ev->atom == EWMH._NET_WM_STATE){ prop = NativeWindow::States; } //Send out the signal if necessary if(prop!=NativeWindow::None){ - if(DEBUG){ qDebug() << "Detected Property Change:" << ev->window << prop; } + //if(DEBUG){ + qDebug() << "Detected Property Change:" << ev->window << prop; + //} obj->emit WindowPropertyChanged(ev->window, prop); }else{ //qDebug() << "Unknown Property Change:" << ev->window << ev->atom; } } +inline void ParseClientMessageEvent(xcb_client_message_event_t *ev, NativeEventFilter *obj){ + NativeWindow::Property prop = NativeWindow::None; + QVariant val; + if(ev->type==EWMH._NET_WM_NAME){ prop = NativeWindow::Title; } + else if(ev->type==EWMH._NET_WM_ICON){ prop = NativeWindow::Icon; } + else if(ev->type==EWMH._NET_WM_ICON_NAME){ prop = NativeWindow::ShortTitle; } + else if(ev->type==EWMH._NET_WM_DESKTOP){ + prop = NativeWindow::Workspace; + val = QVariant( (int) ev->data.data32[0] ); + }else if(ev->type==EWMH._NET_WM_WINDOW_TYPE){ prop = NativeWindow::WinTypes; } + else if(ev->type==EWMH._NET_WM_STATE){ prop = NativeWindow::States; } + + if(prop!=NativeWindow::None){ + //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); } + } + +} + //Constructor for the Event Filter wrapper NativeEventFilter::NativeEventFilter() : QObject(){ @@ -222,7 +245,9 @@ bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message, //addTrayApp( ((xcb_client_message_event_t*)ev)->data.data32[2] ); } //Ignore the System Tray messages at the moment - } + }else if(((xcb_client_message_event_t*)ev)->window != QX11Info::appRootWindow()){ + ParseClientMessageEvent((xcb_client_message_event_t*)ev, obj); + } break; //============================== case XCB_CONFIGURE_NOTIFY: diff --git a/src-qt5/core/libLumina/NativeWindow.h b/src-qt5/core/libLumina/NativeWindow.h index 47359b7d..d04815ce 100644 --- a/src-qt5/core/libLumina/NativeWindow.h +++ b/src-qt5/core/libLumina/NativeWindow.h @@ -30,22 +30,22 @@ public: enum Property{ /*QVariant Type*/ None=0, /*null*/ - MinSize, /*QSize*/ - MaxSize, /*QSize*/ - Size, /*QSize*/ - GlobalPos, /*QPoint*/ - Title, /*QString*/ - ShortTitle, /*QString*/ - Icon, /*QIcon*/ - Name, /*QString*/ - Workspace, /*int*/ - States, /*QList<NativeWindow::State> : Current state of the window */ - WinTypes, /*QList<NativeWindow::Type> : Current type of window (typically does not change)*/ - WinActions, /*QList<NativeWindow::Action> : Current actions that the window allows (Managed/set by the WM)*/ - FrameExtents, /*QList<int> : [Left, Right, Top, Bottom] in pixels */ - RelatedWindows, /* QList<WId> - better to use the "isRelatedTo(WId)" function instead of reading this directly*/ - Active, /*bool*/ - Visible /*bool*/ + MinSize=1, /*QSize*/ + MaxSize=2, /*QSize*/ + Size=3, /*QSize*/ + GlobalPos=4, /*QPoint*/ + Title=5, /*QString*/ + ShortTitle=6, /*QString*/ + Icon=7, /*QIcon*/ + Name=8, /*QString*/ + Workspace=9, /*int*/ + States=10, /*QList<NativeWindow::State> : Current state of the window */ + WinTypes=11, /*QList<NativeWindow::Type> : Current type of window (typically does not change)*/ + WinActions=12, /*QList<NativeWindow::Action> : Current actions that the window allows (Managed/set by the WM)*/ + FrameExtents=13, /*QList<int> : [Left, Right, Top, Bottom] in pixels */ + RelatedWindows=14, /* QList<WId> - better to use the "isRelatedTo(WId)" function instead of reading this directly*/ + Active=15, /*bool*/ + Visible=16 /*bool*/ }; static QList<NativeWindow::Property> allProperties(){ diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp index e0f3fe91..71e95a0e 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.cpp +++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp @@ -254,7 +254,8 @@ void NativeWindowSystem::stop(){ NativeWindow* NativeWindowSystem::findWindow(WId id, bool checkRelated){ //qDebug() << "Find Window:" << id; for(int i=0; i<NWindows.length(); i++){ - if(id==NWindows[i]->id() || id==NWindows[i]->frameId() ){ return NWindows[i]; } + if(id==NWindows[i]->id() ){ return NWindows[i]; } + else if(id==NWindows[i]->frameId() ){ qDebug() << "Matched Frame:" << id; return NWindows[i]; } //if(checkRelated && NWindows[i]->isRelatedTo(id)){ return NWindows[i]; } //else if(!checkRelated && id==NWindows[i]->id()){ return NWindows[i]; } } @@ -496,7 +497,7 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native valList.y = win->property(NativeWindow::GlobalPos).toPoint().y(); }*/ uint16_t mask = 0; - mask = mask | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y; + mask = mask | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;// | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y; qDebug() << "Configure window Geometry:" << sz; xcb_configure_window_aux(QX11Info::connection(), win->id(), mask, &valList); } @@ -667,7 +668,7 @@ void NativeWindowSystem::NewWindowDetected(WId id){ registerClientEvents(win->id()); NWindows << win; UpdateWindowProperties(win, NativeWindow::allProperties()); - qDebug() << "New Window [& associated ID's]:" << win->id() << win->property(NativeWindow::RelatedWindows); + qDebug() << "New Window [& associated ID's]:" << win->id() << win->frameId() << win->property(NativeWindow::RelatedWindows); //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)) ); @@ -707,13 +708,13 @@ void NativeWindowSystem::NewTrayWindowDetected(WId id){ void NativeWindowSystem::WindowCloseDetected(WId id){ NativeWindow *win = findWindow(id, false); - qDebug() << "Got Window Closed" << id << win; + //qDebug() << "Got Window Closed" << id << win; //qDebug() << "Old Window List:" << NWindows.length(); if(win!=0){ NWindows.removeAll(win); //RequestReparent(id, QX11Info::appRootWindow(), QPoint(0,0)); win->emit WindowClosed(id); - qDebug() << "Visible Window Closed!!!"; + //qDebug() << "Visible Window Closed!!!"; //win->deleteLater(); }else{ win = findTrayWindow(id); diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp index 322e524f..6341f923 100644 --- a/src-qt5/core/libLumina/RootSubWindow.cpp +++ b/src-qt5/core/libLumina/RootSubWindow.cpp @@ -41,6 +41,10 @@ WId RootSubWindow::id(){ return WIN->id(); } +NativeWindow* RootSubWindow::nativeWindow(){ + return WIN; +} + // === PRIVATE === RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset){ //Note: pt should be in widget-relative coordinates, not global diff --git a/src-qt5/core/libLumina/RootSubWindow.h b/src-qt5/core/libLumina/RootSubWindow.h index 079a6201..0af77009 100644 --- a/src-qt5/core/libLumina/RootSubWindow.h +++ b/src-qt5/core/libLumina/RootSubWindow.h @@ -29,6 +29,7 @@ public: ~RootSubWindow(); WId id(); + NativeWindow* nativeWindow(); private: //Window status diff --git a/src-qt5/core/libLumina/RootWindow-mgmt.cpp b/src-qt5/core/libLumina/RootWindow-mgmt.cpp index e00ce9ce..00b3e336 100644 --- a/src-qt5/core/libLumina/RootWindow-mgmt.cpp +++ b/src-qt5/core/libLumina/RootWindow-mgmt.cpp @@ -19,16 +19,31 @@ void RootWindow::arrangeWindows(RootSubWindow *primary, QString type){ // ================ // Public slots for starting the arrangement routine(s) above // ================ -void RootWindow::ArrangeWindows(WId *primary, QString type){ - +void RootWindow::ArrangeWindows(WId primary, QString type){ + RootSubWindow* win = windowForId(primary); + if(type.isEmpty()){ type = ""; } //grab the default arrangement format + arrangeWindows(win, type); } -void RootWindow::TileWindows(WId *primary, QString type){ - +void RootWindow::TileWindows(WId primary, QString type){ + RootSubWindow* win = windowForId(primary); + if(type.isEmpty()){ type = ""; } //grab the default arrangement format for tiling + arrangeWindows(win, type); } -void RootWindow::CheckWindowPosition(WId, bool newwindow){ +void RootWindow::CheckWindowPosition(WId id, bool newwindow){ //used after a "drop" to validate/snap/re-arrange window(s) as needed // if "newwindow" is true, then this is the first-placement routine for a window before it initially appears - + RootSubWindow* win = windowForId(id); + if(win==0){ return; } //invalid window + QRect geom = win->nativeWindow()->geometry(); + bool changed = false; + //Make sure it is on the screen (quick check) + if(geom.x() < 0){ changed = true; geom.moveLeft(0); } + if(geom.y() < 0){ changed = true; geom.moveTop(0); } + if(geom.width() < 20){ changed = true; geom.setWidth(100); } + if(geom.height() < 20){ changed = true; geom.setHeight(100); } + if(changed){ win->setGeometry(geom); } + //Now run it through the window arrangement routine + ArrangeWindows(id); } diff --git a/src-qt5/core/libLumina/RootWindow.cpp b/src-qt5/core/libLumina/RootWindow.cpp index 596755df..48c37c86 100644 --- a/src-qt5/core/libLumina/RootWindow.cpp +++ b/src-qt5/core/libLumina/RootWindow.cpp @@ -100,6 +100,14 @@ void RootWindow::updateScreenPixmap(screeninfo *info){ info->wallpaper = pix; } +RootSubWindow* RootWindow::windowForId(WId id){ + RootSubWindow *tmp = 0; + for(int i=0; i<WINDOWS.length() && tmp==0; i++){ + if(WINDOWS[i]->id() == id){ tmp = WINDOWS[i]; } + } + return tmp; +} + // === PUBLIC SLOTS === void RootWindow::ResizeRoot(){ if(DEBUG){ qDebug() << "Resize Root..."; } @@ -202,6 +210,7 @@ void RootWindow::CloseWindow(WId win){ // === PROTECTED === void RootWindow::paintEvent(QPaintEvent *ev){ //qDebug() << "RootWindow: PaintEvent:" << ev->rect(); //<< QDateTime::currentDateTime()->toString(QDateTime::ShortDate); + QWidget::paintEvent(ev); bool found = false; QPainter painter(this); QRect geom = ev->rect(); @@ -214,7 +223,7 @@ void RootWindow::paintEvent(QPaintEvent *ev){ } } painter.end(); - if(!found){ + /*if(!found){ QWidget::paintEvent(ev); - } + }*/ } diff --git a/src-qt5/core/libLumina/RootWindow.h b/src-qt5/core/libLumina/RootWindow.h index 2fd76cea..9b1334dc 100644 --- a/src-qt5/core/libLumina/RootWindow.h +++ b/src-qt5/core/libLumina/RootWindow.h @@ -50,6 +50,7 @@ private: //Window Management QList<RootSubWindow*> WINDOWS; + RootSubWindow* windowForId(WId id); void arrangeWindows(RootSubWindow *primary = 0, QString type = ""); public slots: @@ -61,8 +62,8 @@ public slots: void CloseWindow(WId); //automatically connected for any new native window //Window arrangement functions - defined in "RootWindow-mgmt.cpp" - void ArrangeWindows(WId *primary = 0, QString type = ""); - void TileWindows(WId *primary = 0, QString type = ""); + void ArrangeWindows(WId primary = 0, QString type = ""); + void TileWindows(WId primary = 0, QString type = ""); void CheckWindowPosition(WId, bool newwindow = false); //used after a "drop" to validate/snap/re-arrange window(s) as needed private slots: |