File viewport-kwininfo.diff of Package kdelibs3
--- kdecore/kwinmodule.cpp
+++ kdecore/kwinmodule.cpp
@@ -39,6 +39,7 @@
static unsigned long windows_properties[ 2 ] = { NET::ClientList | NET::ClientListStacking |
NET::NumberOfDesktops |
NET::DesktopGeometry |
+ NET::DesktopViewport |
NET::CurrentDesktop |
NET::DesktopNames |
NET::ActiveWindow |
@@ -49,6 +50,7 @@
static unsigned long desktop_properties[ 2 ] = {
NET::NumberOfDesktops |
NET::DesktopGeometry |
+ NET::DesktopViewport |
NET::CurrentDesktop |
NET::DesktopNames |
NET::ActiveWindow |
@@ -106,8 +108,10 @@
void updateStackingOrder();
bool removeStrutWindow( WId );
-};
+ QSize numberOfViewports(int desktop) const;
+ QPoint currentViewport(int desktop) const;
+};
KWinModule::KWinModule( QObject* parent )
: QObject( parent, "kwin_module" )
@@ -176,6 +180,22 @@
return d->systemTrayWindows;
}
+QSize KWinModulePrivate::numberOfViewports(int desktop) const
+{
+ NETSize netdesktop = desktopGeometry(desktop);
+
+ return QSize(netdesktop.width / QApplication::desktop()->width(),
+ netdesktop.height / QApplication::desktop()->height());
+}
+
+QPoint KWinModulePrivate::currentViewport(int desktop) const
+{
+ NETPoint netviewport = desktopViewport(desktop);
+
+ return QPoint(1+(netviewport.x / QApplication::desktop()->width()),
+ 1+(netviewport.y / QApplication::desktop()->height()));
+}
+
bool KWinModulePrivate::x11Event( XEvent * ev )
{
if ( ev->xany.window == qt_xrootwin() ) {
@@ -192,6 +212,15 @@
if (( m[ PROTOCOLS ] & ActiveWindow ) && activeWindow() != old_active_window )
for ( QPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit )
emit (*mit)->activeWindowChanged( activeWindow() );
+ if ( m[ PROTOCOLS ] & DesktopViewport ) {
+ for ( QPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit )
+ emit (*mit)->currentDesktopViewportChanged(currentDesktop(),
+ currentViewport(currentDesktop()));
+ }
+ if ( m[ PROTOCOLS ] & DesktopGeometry ) {
+ for ( QPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit )
+ emit (*mit)->desktopGeometryChanged(currentDesktop());
+ }
if ( m[ PROTOCOLS ] & DesktopNames )
for ( QPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit )
emit (*mit)->desktopNamesChanged();
@@ -224,7 +253,7 @@
}
if ( (dirty[ NETWinInfo::PROTOCOLS ] & NET::WMStrut) != 0 ) {
removeStrutWindow( ev->xany.window );
- if ( !possibleStrutWindows.findIndex( ev->xany.window ) != -1 )
+ if ( possibleStrutWindows.findIndex( ev->xany.window ) == -1 )
possibleStrutWindows.append( ev->xany.window );
}
if ( dirty[ NETWinInfo::PROTOCOLS ] || dirty[ NETWinInfo::PROTOCOLS2 ] ) {
@@ -325,6 +354,16 @@
return d->numberOfDesktops();
}
+QSize KWinModule::numberOfViewports(int desktop) const
+{
+ return d->numberOfViewports(desktop);
+}
+
+QPoint KWinModule::currentViewport(int desktop) const
+{
+ return d->currentViewport(desktop);
+}
+
WId KWinModule::activeWindow() const
{
return d->activeWindow();
--- kdecore/kwinmodule.h
+++ kdecore/kwinmodule.h
@@ -152,6 +152,21 @@
int numberOfDesktops() const;
/**
+ * Returns the number of viewports in x and y direction
+ * on the virtual desktop.
+ * @return the number of virtual desktops
+ * @since 3.5.5
+ **/
+ QSize numberOfViewports(int desktop) const;
+
+ /**
+ * Returns the current viewport on the given virtual desktop
+ * @return the number of virtual desktops
+ * @since 3.5.5
+ **/
+ QPoint currentViewport(int desktop) const;
+
+ /**
* Returns the currently active window, or 0 if no window is active.
* @return the window id of the active window, or 0 if no window is
* active
@@ -193,7 +208,7 @@
* @param name the new name for the desktop
**/
void setDesktopName( int desktop, const QString& name );
-
+
/**
* Returns the state of showing the desktop.
* @since 3.5
@@ -308,16 +323,28 @@
* @param id the id of the window
*/
void windowChanged(WId id);
-
+
/**
* The state of showing the desktop has changed.
* @since 3.5
*/
void showingDesktopChanged( bool showing );
+ /**
+ * The state of showing the desktop has changed.
+ * @since 3.5.5
+ */
+ void desktopGeometryChanged(int desktop);
+
+ /**
+ * The viewport position has changed
+ * @since 3.5
+ */
+ void currentDesktopViewportChanged(int desktop, const QPoint& viewport);
+
protected:
virtual void connectNotify( const char* signal );
-
+
private:
void init(int);
--- kdecore/kwin.cpp
+++ kdecore/kwin.cpp
@@ -656,6 +656,16 @@
#endif
}
+void KWin::setCurrentDesktopViewport( int desktop, QPoint viewport )
+{
+#ifdef Q_WS_X11
+ NETRootInfo info( qt_xdisplay(), NET::CurrentDesktop );
+ NETPoint netview;
+ netview.x = viewport.x();
+ netview.y = viewport.y();
+ info.setDesktopViewport( desktop, netview );
+#endif
+}
void KWin::iconifyWindow( WId win, bool animation)
{
--- kdecore/kwin.h
+++ kdecore/kwin.h
@@ -391,6 +391,14 @@
static void setCurrentDesktop( int desktop );
/**
+ * Convenience function to set the current viewport to @p viewport.
+ * See NETRootInfo.
+ * @param desktop the number of the new desktop
+ * @param desktop the number of the new viewport
+ */
+ static void setCurrentDesktopViewport( int desktop, QPoint viewport );
+
+ /**
* Iconifies a window. Compatible to XIconifyWindow but has an
* additional parameter @p animation.
*