コード例 #1
0
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
}
コード例 #2
0
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
}
コード例 #3
0
bool raiseWindow(QWidget *w, unsigned)
#endif
{
    Event e(EventRaiseWindow, w);
    if (e.process())
        return false;
#ifdef USE_KDE
    /* info.currentDesktop is 0 when iconified :(
    also onAllDesktops is 0 when Objekt isn't
    shown already */
#if KDE_IS_VERSION(3,2,0)
    KWin::WindowInfo info = KWin::windowInfo(w->winId());
    if ((!info.onAllDesktops()) || (desk == 0)) {
        if (desk == 0) desk = KWin::currentDesktop();
        KWin::setOnDesktop(w->winId(), desk);
    }
#else
    KWin::Info info = KWin::info(w->winId());
    if ((!info.onAllDesktops) || (desk == 0)) {
        if (desk == 0) desk = KWin::currentDesktop();
        KWin::setOnDesktop(w->winId(), desk);
    }
#endif
#endif
    w->show();
    w->showNormal();
    w->raise();
    return true;
}
コード例 #4
0
bool raiseWindow(QWidget *w, unsigned)
#endif
{
    Event e(EventRaiseWindow, w);
    if (e.process())
        return false;
#ifdef USE_KDE
    /* info.currentDesktop is 0 when iconified :(
    also onAllDesktops is 0 when Objekt isn't
    shown already */
#if KDE_IS_VERSION(3,2,0)
    KWin::WindowInfo info = KWin::windowInfo(w->winId());
    if ((!info.onAllDesktops()) || (desk == 0)) {
        if (desk == 0) desk = KWin::currentDesktop();
        KWin::setOnDesktop(w->winId(), desk);
    }
#else
    KWin::Info info = KWin::info(w->winId());
    if ((!info.onAllDesktops) || (desk == 0)) {
        if (desk == 0) desk = KWin::currentDesktop();
        KWin::setOnDesktop(w->winId(), desk);
    }
#endif
#endif
    w->show();
    w->showNormal();
    w->raise();
#ifdef WIN32
    AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(),NULL), GetCurrentThreadId(), TRUE);
    SetForegroundWindow(w->winId());
    SetFocus(w->winId());
    AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(),NULL), GetCurrentThreadId(), FALSE);
#endif
    return true;
}
コード例 #5
0
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);
        }
    }
}
コード例 #6
0
KSystemTray::KSystemTray(QWidget *parent, const char *name) : QLabel(parent, name, WType_TopLevel)
{
#ifdef Q_WS_X11
    QXEmbed::initialize();
#endif

    d = new KSystemTrayPrivate;
    d->actionCollection = new KActionCollection(this);

#ifdef Q_WS_X11
    KWin::setSystemTrayWindowFor(winId(), parent ? parent->topLevelWidget()->winId() : qt_xrootwin());
#endif
    setBackgroundMode(X11ParentRelative);
    setBackgroundOrigin(WindowOrigin);
    hasQuit = 0;
    menu = new KPopupMenu(this);
    menu->insertTitle(kapp->miniIcon(), kapp->caption());
    move(-1000, -1000);
    KStdAction::quit(this, SLOT(maybeQuit()), d->actionCollection);

    if(parentWidget())
    {
        new KAction(i18n("Minimize"), KShortcut(), this, SLOT(minimizeRestoreAction()), d->actionCollection, "minimizeRestore");
#ifdef Q_WS_X11
        KWin::WindowInfo info = KWin::windowInfo(parentWidget()->winId());
        d->on_all_desktops = info.onAllDesktops();
#else
        d->on_all_desktops = false;
#endif
    }
    else
    {
        d->on_all_desktops = false;
    }
    setCaption(KGlobal::instance()->aboutData()->programName());
    setAlignment(alignment() | Qt::AlignVCenter | Qt::AlignHCenter);
}
コード例 #7
0
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();
}