void KSystemTray::minimizeRestore(bool restore) { QWidget *pw = parentWidget(); if(!pw) return; #ifdef Q_WS_X11 KWin::WindowInfo info = KWin::windowInfo(pw->winId(), NET::WMGeometry | NET::WMDesktop); if(restore) { if(d->on_all_desktops) KWin::setOnAllDesktops(pw->winId(), true); else KWin::setCurrentDesktop(info.desktop()); pw->move(info.geometry().topLeft()); // avoid placement policies pw->show(); pw->raise(); KWin::activateWindow(pw->winId()); } else { d->on_all_desktops = info.onAllDesktops(); pw->hide(); } #endif }
EXPORT void saveGeometry(QWidget *w, Data geo[5]) { if (w == NULL) return; QPoint pos = w->pos(); QSize size = w->size(); geo[0].value = pos.x(); geo[1].value = pos.y(); geo[2].value = size.width(); geo[3].value = size.height(); #ifdef WIN32 if (GetWindowLongA(w->winId(), GWL_EXSTYLE) & WS_EX_TOOLWINDOW){ int dc = GetSystemMetrics(SM_CYCAPTION); int ds = GetSystemMetrics(SM_CYSMCAPTION); geo[1].value += dc - ds; geo[3].value -= (dc - ds) * 2; } #endif #ifdef USE_KDE #if KDE_IS_VERSION(3,1,94) KWin::WindowInfo info = KWin::windowInfo(w->winId()); geo[4].value = info.desktop(); if (info.onAllDesktops()) geo[4].value = (unsigned)(-1); #else KWin::Info info = KWin::info(w->winId()); geo[4].value = info.desktop; if (info.onAllDesktops) geo[4].value = (unsigned)(-1); #endif #endif }
KWin::WindowInfo* KPager::info( WId win ) { KWin::WindowInfo* info = m_windows[win]; if (!info ) { info = new KWin::WindowInfo( KWin::windowInfo( win ) ); if( !info->valid() || info->desktop() == 0 ) { delete info; return NULL; // window no longer valid } m_windows.insert( (long) win, info ); } return info; }
void KPager::slotWindowRemoved( WId win ) { KWin::WindowInfo* inf = m_windows[win]; if (inf) { bool onAllDesktops = inf->onAllDesktops(); int desktop = inf->desktop(); m_windows.remove( (long)win ); Desktop::removeCachedPixmap(win); for (int i = 1; i <= (int) m_desktops.count(); ++i) { if (onAllDesktops || desktop == i) m_desktops[i-1]->repaint(false); } } }
void KPager::slotWindowChanged( WId win , unsigned int prop) { bool repaint=false; KWin::WindowInfo* inf = m_windows[win]; if (!inf) { inf=info(win); prop=0; // info already calls KWin::info, so there's no need // to update anything else. repaint=true; }; bool onAllDesktops = inf ? inf->onAllDesktops() : false; int desktop = inf ? inf->desktop() : 0; if (prop) { m_windows.remove( (long) win ); inf = info( win ); } if((prop & ~( NET::WMName | NET::WMVisibleName )) != 0 ) repaint = true; if (repaint) for ( int i=1; i <= (int) m_desktops.count(); ++i) { if ((inf && (inf->isOnDesktop(i))) || onAllDesktops || desktop == i ) { m_desktops[i-1]->repaint(false); } } // redrawDesktops(); }