예제 #1
0
파일: window.cpp 프로젝트: agateau/switcha
void Window::showAgain() {
	mLineEdit->clear();
	mView->clear();

	updateWindowInfoList();

	WindowInfoList::ConstIterator
		it = mWindowInfoList.begin(),
		end = mWindowInfoList.end();
	
	for (; it!=end; ++it) {
		KWin::WindowInfo info = *it;
		QListViewItem* item = new QListViewItem(mView, info.visibleName());
		QPixmap pix = KWin::icon(info.win(), 16, 16, true);
		item->setPixmap(0, pix);
	}

	if (!mWindowInfoList.empty()) {
		mView->setSelected(mView->firstChild(), true);
	}

	QRect rect = QApplication::desktop()->availableGeometry();
	int width = mView->columnWidth(0) + 30;
	int height = 300;
	move(
		rect.left() + (rect.width() - width) / 2,
		rect.top() + (rect.height() - height) / 2
		);
	resize(width, height);
	show();
	KWin::forceActiveWindow(winId());
}
bool RKWardApplication::x11EventFilter (XEvent *e) {
	if (detect_x11_creations) {
		if (e->type == CreateNotify) {
			if (e->xcreatewindow.parent == qt_xrootwin ()) {
				KWin::WindowInfo info = KWin::windowInfo (e->xcreatewindow.window);
				// at this point, we used to check, whether this window has some name or another. This heuristic allowed to sieve out helper windows of the window manager. However, since R 2.8.0, sometimes the window is mapped, before it has been give a name.
				// Now we rely on the fact (we hope it *is* a fact), that the device window is always the first one created.
				if ((info.windowType (0xFFFF) != 0) && (!created_window)) {
					created_window = e->xcreatewindow.window;
					return true;
				}
			} else {
				RK_ASSERT (false);
			}
		}
	}

	if (e->type == PropertyNotify) {
		if (e->xproperty.atom == wm_name_property) {
			if (name_watchers_list.contains (e->xproperty.window)) {
				KWin::WindowInfo wininfo = KWin::windowInfo (e->xproperty.window);
				name_watchers_list[e->xproperty.window]->setCaption (wininfo.name ());
				return true;
			}
		}
	}

	return KApplication::x11EventFilter (e);
}
예제 #3
0
KWin::WindowInfo *Desktop::windowAtPosition(const QPoint &p, QPoint *internalpos)
{
	QRect r;
	const QValueList<WId> &list(pager()->kwin()->stackingOrder());
	if (list.count() <= 0)
		return 0L;

	for (QValueList<WId>::ConstIterator it = list.fromLast(); ; --it)
	{
		KWin::WindowInfo* info = pager()->info( *it );
		if (shouldPaintWindow(info))
		{
			r=info->geometry();
			convertRectS2P(r);
			if (r.contains(p))
			{
				if (internalpos)
				{
					internalpos->setX(p.x()-r.x());
					internalpos->setY(p.y()-r.y());
				}
				return info;
			}
		}

		if (it == list.begin())
			break;
	}
	return 0L;
}
예제 #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
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;
}
예제 #6
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
}
예제 #7
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
}
예제 #8
0
void KPager::slotWindowAdded( WId win)
{
    KWin::WindowInfo* inf = info( win );
    if (!inf)
        return; // never should be here

    for ( int i=1; i <= (int) m_desktops.count(); ++i)
    {
        if ( inf->isOnDesktop( i ))
            m_desktops[i-1]->repaint(false);
    }
}
예제 #9
0
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;
}
예제 #10
0
파일: window.cpp 프로젝트: agateau/switcha
void Window::switchToWindow(QListViewItem* item) {
	QString itemName = item->text(0);

	WindowInfoList::ConstIterator
		it = mWindowInfoList.begin(),
		end = mWindowInfoList.end();
	
	for (; it!=end; ++it) {
		KWin::WindowInfo info = *it;
		if (info.visibleName() == itemName) {
			hide();
			KWin::forceActiveWindow(info.win());
			return;
		}
	}
}
예제 #11
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);
        }
    }
}
예제 #12
0
void Desktop::mousePressEvent( QMouseEvent * ev)
{
    bool showWindows= KPagerConfigDialog::m_showWindows;
    if (ev->button()==LeftButton){
	pressPos = ev->pos();
    }
    else if ((ev->button()==MidButton)&&(showWindows))
	startDrag(ev->pos());
    else if (ev->button()==RightButton) {
	QPoint pos;
	KWin::WindowInfo *info = windowAtPosition(ev->pos(), &pos);
	if ( info && showWindows )
	    pager()->showPopupMenu(info->win(), mapToGlobal(ev->pos()));
	else
	    pager()->showPopupMenu(0, mapToGlobal(ev->pos()));
    }
}
예제 #13
0
파일: window.cpp 프로젝트: agateau/switcha
void Window::updateWindowInfoList() {
	KWinModule kwinModule;
	typedef QValueList<WId> WIdList;
	const WIdList & list = kwinModule.windows();

	WIdList::ConstIterator
		it = list.begin(),
		end = list.end();

	mWindowInfoList.clear();
	for (; it!=end; ++it) {
		KWin::WindowInfo info = KWin::windowInfo(*it);
		NET::WindowType type = info.windowType(NET::AllTypesMask);
		if (type != NET::Desktop && type != NET::Dock && type != NET::Menu) {
			mWindowInfoList << info;
		}
	}
}
예제 #14
0
void Desktop::mouseReleaseEvent( QMouseEvent *ev )
{
/** Note that mouseReleaseEvent is not called when releasing the mouse
 to drop a window in this desktop */
  if (ev->button()==LeftButton)
  {
    bool showWindows= KPagerConfigDialog::m_showWindows;
    QPoint pos;
    KWin::setCurrentDesktop(m_desk);
    if (showWindows)
    {
      KWin::WindowInfo *info = windowAtPosition(ev->pos(), &pos);
      if (info)
      {
	KWin::forceActiveWindow(info->win());

	//	    if ( static_cast<WindowDrawMode>( KPagerConfigDialog::m_windowDrawMode ) == Pixmap )
	//		m_windowPixmapsDirty.replace(info->win,true);
      }
    }
  }
}
예제 #15
0
/**
 * Show/hide playlist global shortcut and PlayerWindow PlaylistButton connect to this slot
 * RULES:
 * 1. hidden & iconified -> deiconify & show @n
 * 2. hidden & deiconified -> show @n
 * 3. shown & iconified -> deiconify @n
 * 4. shown & deiconified -> hide @n
 * 5. don't hide if there is no tray icon or playerWindow. todo (I can't be arsed) @n
 *
 * @note isMinimized() can only be true if the window isShown()
 * this has taken me hours to get right, change at your peril!
 * there are more contingencies than you can believe
 */
void PlaylistWindow::showHide() //SLOT
{

    const KWin::WindowInfo info = KWin::windowInfo( winId() );
    const uint desktop = KWin::currentDesktop();
    const bool isOnThisDesktop = info.isOnDesktop( desktop );
    const bool isShaded = false;

    if( isShaded )
    {
        KWin::clearState( winId(), NET::Shaded );
        setShown( true );
    }

    if( !isOnThisDesktop )
    {
        KWin::setOnDesktop( winId(), desktop );
        setShown( true );
    }
    else if( !info.isMinimized() && !isShaded ) setShown( !isShown() );

    if( isShown() ) KWin::deIconifyWindow( winId() );
}
예제 #16
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);
}
예제 #17
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();
}
예제 #18
0
void KSysTrayCmd::setTargetWindow( const KWin::WindowInfo &info )
{
  disconnect( kwinmodule, SIGNAL(windowAdded(WId)), this, SLOT(windowAdded(WId)) );
  connect( kwinmodule, SIGNAL(windowChanged(WId)), SLOT(windowChanged(WId)) );
  win = info.win();
  KWin::setSystemTrayWindowFor( winId(), win );
  refresh();
  show();

  if ( isVisible )
    KWin::activateWindow( win );
  else
    hideWindow();

  // Always on top ?
  if (onTop)
  {
    KWin::setState(win, NET::StaysOnTop);
  }
}
예제 #19
0
void KWindowListMenu::init()
{
    int i, d;
    i = 0;

    int nd = twin_module->numberOfDesktops();
    int cd = twin_module->currentDesktop();
    WId active_window = twin_module->activeWindow();

    // Make sure the popup is not too wide, otherwise clicking in the middle of kdesktop
    // wouldn't leave any place for the popup, and release would activate some menu entry.    
    int maxwidth = kapp->desktop()->screenGeometry( this ).width() / 2 - 100;

    clear();
    map.clear();

    int unclutter = insertItem( i18n("Unclutter Windows"),
                                this, TQT_SLOT( slotUnclutterWindows() ) );
    int cascade = insertItem( i18n("Cascade Windows"),
                              this, TQT_SLOT( slotCascadeWindows() ) );

    // if we only have one desktop we won't be showing titles, so put a separator in
    if (nd == 1)
    {
        insertSeparator();
    }


    TQValueList<KWin::WindowInfo> windows;
    for (TQValueList<WId>::ConstIterator it = twin_module->windows().begin();
         it != twin_module->windows().end(); ++it) {
         windows.append( KWin::windowInfo( *it, NET::WMDesktop ));
    }
    bool show_all_desktops_group = ( nd > 1 );
    for (d = 1; d <= nd + (show_all_desktops_group ? 1 : 0); d++) {
        bool on_all_desktops = ( d > nd );
	int items = 0;

	if (!active_window && d == cd)
	    setItemChecked(1000 + d, true);

        NameSortedInfoList list;
        list.setAutoDelete(true);

	for (TQValueList<KWin::WindowInfo>::ConstIterator it = windows.begin();
             it != windows.end(); ++it) {
	    if (((*it).desktop() == d) || (on_all_desktops && (*it).onAllDesktops())
                || (!show_all_desktops_group && (*it).onAllDesktops())) {
	        list.inSort(new KWin::WindowInfo( (*it).win(),
                    NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType,
                    NET::WM2GroupLeader | NET::WM2TransientFor ));
            }
        }

        for (KWin::WindowInfo* info = list.first(); info; info = list.next(), ++i)
        {
            TQString itemText = KStringHandler::cPixelSqueeze(info->visibleNameWithState(), fontMetrics(), maxwidth);
            NET::WindowType windowType = info->windowType( NET::NormalMask | NET::DesktopMask
                | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
                | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask );
            if ( (windowType == NET::Normal || windowType == NET::Unknown
                    || (windowType == NET::Dialog && standaloneDialog( info, list )))
                && !(info->state() & NET::SkipTaskbar) ) {
                TQPixmap pm = KWin::icon(info->win(), 16, 16, true );
                items++;

                // ok, we have items on this desktop, let's show the title
                if ( items == 1 && nd > 1 )
                {
                    if( !on_all_desktops )
                        insertTitle(twin_module->desktopName( d ), 1000 + d);
                    else
                        insertTitle(i18n("On All Desktops"), 2000 );
                }

                // Avoid creating unwanted accelerators.
                itemText.replace('&', TQString::fromLatin1("&&"));
                insertItem( pm, itemText, i);
                map.insert(i, info->win());
                if (info->win() == active_window)
                    setItemChecked(i, true);
            }
        }

        if (d == cd)
        {
            setItemEnabled(unclutter, items > 0);
            setItemEnabled(cascade, items > 0);
        }
    }

    // no windows?
    if (i == 0)
    {
        if (nd > 1)
        {
            // because we don't have any titles, nor a separator
            insertSeparator();
        }

        setItemEnabled(insertItem(i18n("No Windows")), false);
    }
}
예제 #20
0
bool PlaylistWindow::isReallyShown() const
{
    const KWin::WindowInfo info = KWin::windowInfo( winId() );
    return isShown() && !info.isMinimized() && info.isOnDesktop( KWin::currentDesktop() );
}