• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • windowmanagement
kwindowsystem_x11.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the KDE libraries
3  Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org)
4  Copyright (C) 2007 Lubos Lunak (l.lunak@kde.org)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "kwindowsystem.h"
23 
24 #include <kiconloader.h>
25 #include <klocale.h>
26 #include <kdebug.h>
27 #include <ksystemeventfilter.h>
28 #include <kxerrorhandler.h>
29 #include <kxutils.h>
30 #include <netwm.h>
31 #include <QtGui/QApplication>
32 #include <QtGui/QBitmap>
33 #include <QDesktopWidget>
34 #include <QtGui/QDialog>
35 #include <QtDBus/QtDBus>
36 #include <QtGui/QX11Info>
37 #include <X11/Xatom.h>
38 
39 #include <config.h>
40 
41 #ifdef HAVE_XFIXES
42 #include <X11/extensions/Xfixes.h>
43 #endif
44 
45 class KWindowSystemStaticContainer {
46 public:
47  KWindowSystemStaticContainer() : d(0) {}
48  KWindowSystem kwm;
49  KWindowSystemPrivate* d;
50 };
51 
52 
53 K_GLOBAL_STATIC(KWindowSystemStaticContainer, g_kwmInstanceContainer)
54 
55 static Atom net_wm_cm;
56 static void create_atoms( Display* dpy = QX11Info::display() );
57 
58 static unsigned long windows_properties[ 2 ] = { NET::ClientList | NET::ClientListStacking |
59  NET::Supported |
60  NET::NumberOfDesktops |
61  NET::DesktopGeometry |
62  NET::DesktopViewport |
63  NET::CurrentDesktop |
64  NET::DesktopNames |
65  NET::ActiveWindow |
66  NET::WorkArea,
67  NET::WM2ShowingDesktop };
68 
69 // ClientList and ClientListStacking is not per-window information, but a desktop information,
70 // so track it even with only INFO_BASIC
71 static unsigned long desktop_properties[ 2 ] = { NET::ClientList | NET::ClientListStacking |
72  NET::Supported |
73  NET::NumberOfDesktops |
74  NET::DesktopGeometry |
75  NET::DesktopViewport |
76  NET::CurrentDesktop |
77  NET::DesktopNames |
78  NET::ActiveWindow |
79  NET::WorkArea,
80  NET::WM2ShowingDesktop };
81 
82 class KWindowSystemPrivate
83  : public QWidget, public NETRootInfo
84 {
85 public:
86  KWindowSystemPrivate(int _what);
87  void activate();
88  QList<WId> windows;
89  QList<WId> stackingOrder;
90 
91  struct StrutData
92  {
93  StrutData( WId window_, const NETStrut& strut_, int desktop_ )
94  : window( window_ ), strut( strut_ ), desktop( desktop_ ) {}
95  StrutData() {} // for QValueList to be happy
96  WId window;
97  NETStrut strut;
98  int desktop;
99  };
100  QList<StrutData> strutWindows;
101  QList<WId> possibleStrutWindows;
102  bool strutSignalConnected;
103  bool compositingEnabled;
104  bool haveXfixes;
105  int what;
106  int xfixesEventBase;
107  bool mapViewport();
108 
109  void addClient(Window);
110  void removeClient(Window);
111 
112  bool x11Event( XEvent * ev );
113 
114  void updateStackingOrder();
115  bool removeStrutWindow( WId );
116 };
117 
118 KWindowSystemPrivate::KWindowSystemPrivate(int _what)
119  : QWidget(0),
120  NETRootInfo( QX11Info::display(),
121  _what >= KWindowSystem::INFO_WINDOWS ? windows_properties : desktop_properties,
122  2, -1, false ),
123  strutSignalConnected( false ),
124  haveXfixes( false ),
125  what( _what )
126 {
127  KSystemEventFilter::installEventFilter(this);
128  (void ) qApp->desktop(); //trigger desktop widget creation to select root window events
129 
130 #ifdef HAVE_XFIXES
131  int errorBase;
132  if ((haveXfixes = XFixesQueryExtension(QX11Info::display(), &xfixesEventBase, &errorBase))) {
133  create_atoms();
134  XFixesSelectSelectionInput(QX11Info::display(), winId(), net_wm_cm,
135  XFixesSetSelectionOwnerNotifyMask |
136  XFixesSelectionWindowDestroyNotifyMask |
137  XFixesSelectionClientCloseNotifyMask);
138  compositingEnabled = XGetSelectionOwner(QX11Info::display(), net_wm_cm) != None;
139  }
140 #endif
141 }
142 
143 // not virtual, but it's called directly only from init()
144 void KWindowSystemPrivate::activate()
145 {
146  NETRootInfo::activate();
147  updateStackingOrder();
148 }
149 
150 bool KWindowSystemPrivate::x11Event( XEvent * ev )
151 {
152  KWindowSystem* s_q = KWindowSystem::self();
153 
154 #ifdef HAVE_XFIXES
155  if ( ev->type == xfixesEventBase + XFixesSelectionNotify ) {
156  if ( ev->xany.window == winId() ) {
157  XFixesSelectionNotifyEvent *event = reinterpret_cast<XFixesSelectionNotifyEvent*>(ev);
158  bool haveOwner = event->owner != None;
159  if (compositingEnabled != haveOwner) {
160  compositingEnabled = haveOwner;
161  emit s_q->compositingChanged( compositingEnabled );
162  }
163  return true;
164  }
165  // Qt compresses XFixesSelectionNotifyEvents without caring about the actual window
166  // gui/kernel/qapplication_x11.cpp
167  // until that can be assumed fixed, we also react on events on the root (caused by Qts own compositing tracker)
168  if ( ev->xany.window == QX11Info::appRootWindow() ) {
169  XFixesSelectionNotifyEvent *event = reinterpret_cast<XFixesSelectionNotifyEvent*>(ev);
170  if (event->selection == net_wm_cm) {
171  bool haveOwner = event->owner != None;
172  if (compositingEnabled != haveOwner) {
173  compositingEnabled = haveOwner;
174  emit s_q->compositingChanged( compositingEnabled );
175  }
176  // NOTICE this is not our event, we just randomly captured it from Qt -> pass on
177  return false;
178  }
179  }
180  return false;
181  }
182 #endif
183 
184  if ( ev->xany.window == QX11Info::appRootWindow() ) {
185  int old_current_desktop = currentDesktop();
186  WId old_active_window = activeWindow();
187  int old_number_of_desktops = numberOfDesktops();
188  bool old_showing_desktop = showingDesktop();
189  unsigned long m[ 5 ];
190  NETRootInfo::event( ev, m, 5 );
191 
192  if (( m[ PROTOCOLS ] & CurrentDesktop ) && currentDesktop() != old_current_desktop )
193  emit s_q->currentDesktopChanged( currentDesktop() );
194  if (( m[ PROTOCOLS ] & DesktopViewport ) && mapViewport() && currentDesktop() != old_current_desktop )
195  emit s_q->currentDesktopChanged( currentDesktop() );
196  if (( m[ PROTOCOLS ] & ActiveWindow ) && activeWindow() != old_active_window )
197  emit s_q->activeWindowChanged( activeWindow() );
198  if ( m[ PROTOCOLS ] & DesktopNames )
199  emit s_q->desktopNamesChanged();
200  if (( m[ PROTOCOLS ] & NumberOfDesktops ) && numberOfDesktops() != old_number_of_desktops )
201  emit s_q->numberOfDesktopsChanged( numberOfDesktops() );
202  if (( m[ PROTOCOLS ] & DesktopGeometry ) && mapViewport() && numberOfDesktops() != old_number_of_desktops )
203  emit s_q->numberOfDesktopsChanged( numberOfDesktops() );
204  if ( m[ PROTOCOLS ] & WorkArea )
205  emit s_q->workAreaChanged();
206  if ( m[ PROTOCOLS ] & ClientListStacking ) {
207  updateStackingOrder();
208  emit s_q->stackingOrderChanged();
209  }
210  if(( m[ PROTOCOLS2 ] & WM2ShowingDesktop ) && showingDesktop() != old_showing_desktop ) {
211  emit s_q->showingDesktopChanged( showingDesktop());
212  }
213  } else if ( windows.contains( ev->xany.window ) ){
214  NETWinInfo ni( QX11Info::display(), ev->xany.window, QX11Info::appRootWindow(), 0 );
215  unsigned long dirty[ 2 ];
216  ni.event( ev, dirty, 2 );
217  if ( ev->type ==PropertyNotify ) {
218  if( ev->xproperty.atom == XA_WM_HINTS )
219  dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMIcon; // support for old icons
220  else if( ev->xproperty.atom == XA_WM_NAME )
221  dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMName; // support for old name
222  else if( ev->xproperty.atom == XA_WM_ICON_NAME )
223  dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMIconName; // support for old iconic name
224  }
225  if( mapViewport() && ( dirty[ NETWinInfo::PROTOCOLS ] & (NET::WMState | NET::WMGeometry) )) {
226  /* geometry change -> possible viewport change
227  * state change -> possible NET::Sticky change
228  */
229  dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMDesktop;
230  }
231  if ( (dirty[ NETWinInfo::PROTOCOLS ] & NET::WMStrut) != 0 ) {
232  removeStrutWindow( ev->xany.window );
233  if ( !possibleStrutWindows.contains( ev->xany.window ) )
234  possibleStrutWindows.append( ev->xany.window );
235  }
236  if ( dirty[ NETWinInfo::PROTOCOLS ] || dirty[ NETWinInfo::PROTOCOLS2 ] ) {
237  emit s_q->windowChanged( ev->xany.window );
238  emit s_q->windowChanged( ev->xany.window, dirty );
239  emit s_q->windowChanged( ev->xany.window, dirty[ NETWinInfo::PROTOCOLS ] );
240  if ( (dirty[ NETWinInfo::PROTOCOLS ] & NET::WMStrut) != 0 )
241  emit s_q->strutChanged();
242  }
243  }
244 
245  return false;
246 }
247 
248 bool KWindowSystemPrivate::removeStrutWindow( WId w )
249 {
250  for( QList< StrutData >::Iterator it = strutWindows.begin();
251  it != strutWindows.end();
252  ++it )
253  if( (*it).window == w ) {
254  strutWindows.erase( it );
255  return true;
256  }
257  return false;
258 }
259 
260 void KWindowSystemPrivate::updateStackingOrder()
261 {
262  stackingOrder.clear();
263  for ( int i = 0; i < clientListStackingCount(); i++ )
264  stackingOrder.append( clientListStacking()[i] );
265 }
266 
267 void KWindowSystemPrivate::addClient(Window w)
268 {
269  KWindowSystem* s_q = KWindowSystem::self();
270 
271  if ( (what >= KWindowSystem::INFO_WINDOWS) && !QWidget::find( w ) )
272  XSelectInput( QX11Info::display(), w, PropertyChangeMask | StructureNotifyMask );
273 
274  bool emit_strutChanged = false;
275 
276  if( strutSignalConnected ) {
277  NETWinInfo info( QX11Info::display(), w, QX11Info::appRootWindow(), NET::WMStrut | NET::WMDesktop );
278  NETStrut strut = info.strut();
279  if ( strut.left || strut.top || strut.right || strut.bottom ) {
280  strutWindows.append( StrutData( w, strut, info.desktop()));
281  emit_strutChanged = true;
282  }
283  } else
284  possibleStrutWindows.append( w );
285 
286  windows.append( w );
287  emit s_q->windowAdded( w );
288  if ( emit_strutChanged )
289  emit s_q->strutChanged();
290 }
291 
292 void KWindowSystemPrivate::removeClient(Window w)
293 {
294  KWindowSystem* s_q = KWindowSystem::self();
295 
296  bool emit_strutChanged = removeStrutWindow( w );
297  if( strutSignalConnected && possibleStrutWindows.contains( w )) {
298  NETWinInfo info( QX11Info::display(), w, QX11Info::appRootWindow(), NET::WMStrut );
299  NETStrut strut = info.strut();
300  if ( strut.left || strut.top || strut.right || strut.bottom ) {
301  emit_strutChanged = true;
302  }
303  }
304 
305  possibleStrutWindows.removeAll( w );
306  windows.removeAll( w );
307  emit s_q->windowRemoved( w );
308  if ( emit_strutChanged )
309  emit s_q->strutChanged();
310 }
311 
312 bool KWindowSystemPrivate::mapViewport()
313 {
314 // compiz claims support even though it doesn't use virtual desktops :(
315 // if( isSupported( NET::DesktopViewport ) && !isSupported( NET::NumberOfDesktops ))
316 
317 // this test is duplicated in KWindowSystem::mapViewport()
318  if( isSupported( NET::DesktopViewport ) && numberOfDesktops( true ) <= 1
319  && ( desktopGeometry( currentDesktop( true )).width > QApplication::desktop()->width()
320  || desktopGeometry( currentDesktop( true )).height > QApplication::desktop()->height()))
321  return true;
322  return false;
323 }
324 
325 static bool atoms_created = false;
326 
327 static Atom kde_wm_change_state;
328 static Atom _wm_protocols;
329 static Atom kwm_utf8_string;
330 
331 static void create_atoms( Display* dpy ) {
332  if (!atoms_created){
333  const int max = 20;
334  Atom* atoms[max];
335  const char* names[max];
336  Atom atoms_return[max];
337  int n = 0;
338 
339  atoms[n] = &kde_wm_change_state;
340  names[n++] = "_KDE_WM_CHANGE_STATE";
341 
342  atoms[n] = &_wm_protocols;
343  names[n++] = "WM_PROTOCOLS";
344 
345  atoms[n] = &kwm_utf8_string;
346  names[n++] = "UTF8_STRING";
347 
348  char net_wm_cm_name[ 100 ];
349  sprintf( net_wm_cm_name, "_NET_WM_CM_S%d", DefaultScreen( dpy ));
350  atoms[n] = &net_wm_cm;
351  names[n++] = net_wm_cm_name;
352 
353  // we need a const_cast for the shitty X API
354  XInternAtoms( dpy, const_cast<char**>(names), n, false, atoms_return );
355  for (int i = 0; i < n; i++ )
356  *atoms[i] = atoms_return[i];
357 
358  atoms_created = True;
359  }
360 }
361 
362 static void sendClientMessageToRoot(Window w, Atom a, long x, long y = 0, long z = 0 ){
363  XEvent ev;
364  long mask;
365 
366  memset(&ev, 0, sizeof(ev));
367  ev.xclient.type = ClientMessage;
368  ev.xclient.window = w;
369  ev.xclient.message_type = a;
370  ev.xclient.format = 32;
371  ev.xclient.data.l[0] = x;
372  ev.xclient.data.l[1] = y;
373  ev.xclient.data.l[2] = z;
374  mask = SubstructureRedirectMask;
375  XSendEvent(QX11Info::display(), QX11Info::appRootWindow(), False, mask, &ev);
376 }
377 
378 KWindowSystem* KWindowSystem::self()
379 {
380  return &(g_kwmInstanceContainer->kwm);
381 }
382 
383 
384 KWindowSystemPrivate* KWindowSystem::s_d_func()
385 {
386  return g_kwmInstanceContainer->d;
387 }
388 
389 
390 // optimalization - create KWindowSystemPrivate only when needed and only for what is needed
391 void KWindowSystem::connectNotify( const char* signal )
392 {
393  int what = INFO_BASIC;
394  if( QLatin1String( signal ) == SIGNAL(workAreaChanged()))
395  what = INFO_WINDOWS;
396  else if( QLatin1String( signal ) == SIGNAL(strutChanged()))
397  what = INFO_WINDOWS;
398  else if( QLatin1String( signal ) == QMetaObject::normalizedSignature(SIGNAL(windowChanged(WId,const ulong*))).constData())
399  what = INFO_WINDOWS;
400  else if( QLatin1String( signal ) == QMetaObject::normalizedSignature(SIGNAL(windowChanged(WId,uint))).constData())
401  what = INFO_WINDOWS;
402  else if( QLatin1String( signal ) == QMetaObject::normalizedSignature(SIGNAL(windowChanged(WId))).constData())
403  what = INFO_WINDOWS;
404 
405  init( what );
406  KWindowSystemPrivate* const s_d = s_d_func();
407  if( !s_d->strutSignalConnected && qstrcmp( signal, SIGNAL(strutChanged())) == 0 )
408  s_d->strutSignalConnected = true;
409 
410  QObject::connectNotify( signal );
411 }
412 
413 // WARNING
414 // you have to call s_d_func() again after calling this function if you want a valid pointer!
415 void KWindowSystem::init(int what)
416 {
417  KWindowSystemPrivate* const s_d = s_d_func();
418 
419  if (what >= INFO_WINDOWS)
420  what = INFO_WINDOWS;
421  else
422  what = INFO_BASIC;
423 
424  if ( !s_d )
425  {
426  g_kwmInstanceContainer->d = new KWindowSystemPrivate(what); // invalidates s_d
427  g_kwmInstanceContainer->d->activate();
428  }
429  else if (s_d->what < what)
430  {
431  delete s_d;
432  g_kwmInstanceContainer->d = new KWindowSystemPrivate(what); // invalidates s_d
433  g_kwmInstanceContainer->d->activate();
434  }
435 }
436 
437 const QList<WId>& KWindowSystem::windows()
438 {
439  init( INFO_BASIC );
440  return s_d_func()->windows;
441 }
442 
443 KWindowInfo KWindowSystem::windowInfo( WId win, unsigned long properties, unsigned long properties2 )
444 {
445  return KWindowInfo( win, properties, properties2 );
446 }
447 
448 bool KWindowSystem::hasWId(WId w)
449 {
450  init( INFO_BASIC );
451  return s_d_func()->windows.contains( w );
452 }
453 
454 QList<WId> KWindowSystem::stackingOrder()
455 {
456  init( INFO_BASIC );
457  return s_d_func()->stackingOrder;
458 }
459 
460 int KWindowSystem::currentDesktop()
461 {
462  if (!QX11Info::display())
463  return 1;
464 
465  if( mapViewport()) {
466  init( INFO_BASIC );
467  KWindowSystemPrivate* const s_d = s_d_func();
468  NETPoint p = s_d->desktopViewport( s_d->currentDesktop( true ));
469  return viewportToDesktop( QPoint( p.x, p.y ));
470  }
471 
472  KWindowSystemPrivate* const s_d = s_d_func();
473  if( s_d )
474  return s_d->currentDesktop( true );
475  NETRootInfo info( QX11Info::display(), NET::CurrentDesktop );
476  return info.currentDesktop( true );
477 }
478 
479 int KWindowSystem::numberOfDesktops()
480 {
481  if (!QX11Info::display())
482  return 1;
483 
484  if( mapViewport()) {
485  init( INFO_BASIC );
486  KWindowSystemPrivate* const s_d = s_d_func();
487  NETSize s = s_d->desktopGeometry( s_d->currentDesktop( true ));
488  return s.width / qApp->desktop()->width() * s.height / qApp->desktop()->height();
489  }
490 
491  KWindowSystemPrivate* const s_d = s_d_func();
492  if( s_d )
493  return s_d->numberOfDesktops( true );
494  NETRootInfo info( QX11Info::display(), NET::NumberOfDesktops );
495  return info.numberOfDesktops( true );
496 }
497 
498 void KWindowSystem::setCurrentDesktop( int desktop )
499 {
500  if( mapViewport()) {
501  init( INFO_BASIC );
502  KWindowSystemPrivate* const s_d = s_d_func();
503  NETRootInfo info( QX11Info::display(), 0 );
504  QPoint pos = desktopToViewport( desktop, true );
505  NETPoint p;
506  p.x = pos.x();
507  p.y = pos.y();
508  info.setDesktopViewport( s_d->currentDesktop( true ), p );
509  return;
510  }
511  NETRootInfo info( QX11Info::display(), 0 );
512  info.setCurrentDesktop( desktop, true );
513 }
514 
515 void KWindowSystem::setOnAllDesktops( WId win, bool b )
516 {
517  if( mapViewport()) {
518  if( b )
519  setState( win, NET::Sticky );
520  else
521  clearState( win, NET::Sticky );
522  return;
523  }
524  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), NET::WMDesktop );
525  if ( b )
526  info.setDesktop( NETWinInfo::OnAllDesktops, true );
527  else if ( info.desktop( true ) == NETWinInfo::OnAllDesktops ) {
528  NETRootInfo rinfo( QX11Info::display(), NET::CurrentDesktop );
529  info.setDesktop( rinfo.currentDesktop( true ), true );
530  }
531 }
532 
533 void KWindowSystem::setOnDesktop( WId win, int desktop )
534 {
535  if( mapViewport()) {
536  if( desktop == NET::OnAllDesktops )
537  return setOnAllDesktops( win, true );
538  else
539  clearState( win, NET::Sticky );
540  init( INFO_BASIC );
541  QPoint p = desktopToViewport( desktop, false );
542  Window dummy;
543  int x, y;
544  unsigned int w, h, b, dp;
545  XGetGeometry( QX11Info::display(), win, &dummy, &x, &y, &w, &h, &b, &dp );
546  // get global position
547  XTranslateCoordinates( QX11Info::display(), win, QX11Info::appRootWindow(), 0, 0, &x, &y, &dummy );
548  x += w / 2; // center
549  y += h / 2;
550  // transform to coordinates on the current "desktop"
551  x = x % qApp->desktop()->width();
552  y = y % qApp->desktop()->height();
553  if( x < 0 )
554  x = x + qApp->desktop()->width();
555  if( y < 0 )
556  y = y + qApp->desktop()->height();
557  x += p.x(); // move to given "desktop"
558  y += p.y();
559  x -= w / 2; // from center back to topleft
560  y -= h / 2;
561  p = constrainViewportRelativePosition( QPoint( x, y ));
562  int flags = ( NET::FromTool << 12 ) | ( 0x03 << 8 ) | 10; // from tool(?), x/y, static gravity
563  KWindowSystemPrivate* const s_d = s_d_func();
564  s_d->moveResizeWindowRequest( win, flags, p.x(), p.y(), w, h );
565  return;
566  }
567  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), NET::WMDesktop );
568  info.setDesktop( desktop, true );
569 }
570 
571 WId KWindowSystem::activeWindow()
572 {
573  KWindowSystemPrivate* const s_d = s_d_func();
574  if( s_d )
575  return s_d->activeWindow();
576  NETRootInfo info( QX11Info::display(), NET::ActiveWindow );
577  return info.activeWindow();
578 }
579 
580 void KWindowSystem::activateWindow( WId win, long time )
581 {
582  NETRootInfo info( QX11Info::display(), 0 );
583  if( time == 0 )
584  time = QX11Info::appUserTime();
585  info.setActiveWindow( win, NET::FromApplication, time,
586  qApp->activeWindow() ? qApp->activeWindow()->winId() : 0 );
587 }
588 
589 void KWindowSystem::forceActiveWindow( WId win, long time )
590 {
591  NETRootInfo info( QX11Info::display(), 0 );
592  if( time == 0 )
593  time = QX11Info::appTime();
594  info.setActiveWindow( win, NET::FromTool, time, 0 );
595 }
596 
597 void KWindowSystem::demandAttention( WId win, bool set )
598 {
599  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), NET::WMState );
600  info.setState( set ? NET::DemandsAttention : 0, NET::DemandsAttention );
601 }
602 
603 WId KWindowSystem::transientFor( WId win )
604 {
605  KXErrorHandler handler; // ignore badwindow
606  Window transient_for = None;
607  if( XGetTransientForHint( QX11Info::display(), win, &transient_for ))
608  return transient_for;
609  // XGetTransientForHint() did sync
610  return None;
611 }
612 
613 void KWindowSystem::setMainWindow( QWidget* subwindow, WId mainwindow )
614 {
615  subwindow->setAttribute( Qt::WA_X11BypassTransientForHint );
616  if( mainwindow != 0 )
617  XSetTransientForHint( QX11Info::display(), subwindow->winId(), mainwindow );
618  else
619  XDeleteProperty( QX11Info::display(), subwindow->winId(), XA_WM_TRANSIENT_FOR );
620 }
621 
622 WId KWindowSystem::groupLeader( WId win )
623 {
624  KXErrorHandler handler; // ignore badwindow
625  XWMHints *hints = XGetWMHints( QX11Info::display(), win );
626  Window window_group = None;
627  if ( hints )
628  {
629  if( hints->flags & WindowGroupHint )
630  window_group = hints->window_group;
631  XFree( reinterpret_cast< char* >( hints ));
632  }
633  // XGetWMHints() did sync
634  return window_group;
635 }
636 
637 QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale )
638 {
639  return icon( win, width, height, scale, NETWM | WMHints | ClassHint | XApp );
640 }
641 
642 
643 QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale, int flags )
644 {
645  KXErrorHandler handler; // ignore badwindow
646  QPixmap result;
647  if( flags & NETWM ) {
648  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), NET::WMIcon );
649  NETIcon ni = info.icon( width, height );
650  if ( ni.data && ni.size.width > 0 && ni.size.height > 0 ) {
651  QImage img( (uchar*) ni.data, (int) ni.size.width, (int) ni.size.height, QImage::Format_ARGB32 );
652  if ( scale && width > 0 && height > 0 &&img.size() != QSize( width, height ) && !img.isNull() )
653  img = img.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
654  if ( !img.isNull() )
655  result = QPixmap::fromImage( img );
656  return result;
657  }
658  }
659 
660  if( flags & WMHints ) {
661  Pixmap p = None;
662  Pixmap p_mask = None;
663 
664  XWMHints *hints = XGetWMHints(QX11Info::display(), win );
665  if (hints && (hints->flags & IconPixmapHint)){
666  p = hints->icon_pixmap;
667  }
668  if (hints && (hints->flags & IconMaskHint)){
669  p_mask = hints->icon_mask;
670  }
671  if (hints)
672  XFree((char*)hints);
673 
674  if (p != None){
675  QPixmap pm = KXUtils::createPixmapFromHandle( p, p_mask );
676  if ( scale && width > 0 && height > 0 && !pm.isNull()
677  && ( pm.width() != width || pm.height() != height) ){
678  result = QPixmap::fromImage( pm.toImage().scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
679  } else {
680  result = pm;
681  }
682  }
683  }
684 
685  // Since width can be any arbitrary size, but the icons cannot,
686  // take the nearest value for best results (ignoring 22 pixel
687  // icons as they don't exist for apps):
688  int iconWidth;
689  if( width < 24 )
690  iconWidth = 16;
691  else if( width < 40 )
692  iconWidth = 32;
693  else
694  iconWidth = 48;
695 
696  if( flags & ClassHint ) {
697  // Try to load the icon from the classhint if the app didn't specify
698  // its own:
699  if( result.isNull() ) {
700 
701  XClassHint hint;
702  if( XGetClassHint( QX11Info::display(), win, &hint ) ) {
703  QString className = hint.res_class;
704 
705  QPixmap pm = KIconLoader::global()->loadIcon( className.toLower(), KIconLoader::Small, iconWidth,
706  KIconLoader::DefaultState, QStringList(), 0, true );
707  if( scale && !pm.isNull() )
708  result = QPixmap::fromImage( pm.toImage().scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
709  else
710  result = pm;
711 
712  XFree( hint.res_name );
713  XFree( hint.res_class );
714  }
715  }
716  }
717 
718  if( flags & XApp ) {
719  // If the icon is still a null pixmap, load the icon for X applications
720  // as a last resort:
721  if ( result.isNull() ) {
722  QPixmap pm = KIconLoader::global()->loadIcon( "xorg", KIconLoader::Small, iconWidth,
723  KIconLoader::DefaultState, QStringList(), 0, true );
724  if( scale && !pm.isNull() )
725  result = QPixmap::fromImage( pm.toImage().scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
726  else
727  result = pm;
728  }
729  }
730  return result;
731 }
732 
733 void KWindowSystem::setIcons( WId win, const QPixmap& icon, const QPixmap& miniIcon )
734 {
735  if ( icon.isNull() )
736  return;
737  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), 0 );
738  QImage img = icon.toImage().convertToFormat( QImage::Format_ARGB32 );
739  NETIcon ni;
740  ni.size.width = img.size().width();
741  ni.size.height = img.size().height();
742  ni.data = (unsigned char *) img.bits();
743  info.setIcon( ni, true );
744  if ( miniIcon.isNull() )
745  return;
746  img = miniIcon.toImage().convertToFormat( QImage::Format_ARGB32 );
747  if ( img.isNull() )
748  return;
749  ni.size.width = img.size().width();
750  ni.size.height = img.size().height();
751  ni.data = (unsigned char *) img.bits();
752  info.setIcon( ni, false );
753 }
754 
755 void KWindowSystem::setType( WId win, NET::WindowType windowType )
756 {
757  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), 0 );
758  info.setWindowType( windowType );
759 }
760 
761 void KWindowSystem::setState( WId win, unsigned long state )
762 {
763  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), NET::WMState );
764  info.setState( state, state );
765 }
766 
767 void KWindowSystem::clearState( WId win, unsigned long state )
768 {
769  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), NET::WMState );
770  info.setState( 0, state );
771 }
772 
773 void KWindowSystem::minimizeWindow( WId win, bool animation)
774 {
775  if ( !animation )
776  {
777  create_atoms();
778  sendClientMessageToRoot( win, kde_wm_change_state, IconicState, 1 );
779  }
780  QX11Info inf;
781  XIconifyWindow( QX11Info::display(), win, inf.screen() );
782 }
783 
784 void KWindowSystem::unminimizeWindow( WId win, bool animation )
785 {
786  if ( !animation )
787  {
788  create_atoms();
789  sendClientMessageToRoot( win, kde_wm_change_state, NormalState, 1 );
790  }
791  XMapWindow( QX11Info::display(), win );
792 }
793 
794 void KWindowSystem::raiseWindow( WId win )
795 {
796  NETRootInfo info( QX11Info::display(), NET::Supported );
797  if( info.isSupported( NET::WM2RestackWindow ))
798  info.restackRequest( win, NET::FromTool, None, Above, QX11Info::appUserTime());
799  else
800  XRaiseWindow( QX11Info::display(), win );
801 }
802 
803 void KWindowSystem::lowerWindow( WId win )
804 {
805  NETRootInfo info( QX11Info::display(), NET::Supported );
806  if( info.isSupported( NET::WM2RestackWindow ))
807  info.restackRequest( win, NET::FromTool, None, Below, QX11Info::appUserTime());
808  else
809  XLowerWindow( QX11Info::display(), win );
810 }
811 
812 bool KWindowSystem::compositingActive()
813 {
814  if( QX11Info::display()) {
815  init( INFO_BASIC );
816  if (s_d_func()->haveXfixes) {
817  return s_d_func()->compositingEnabled;
818  } else {
819  create_atoms();
820  return XGetSelectionOwner( QX11Info::display(), net_wm_cm );
821  }
822  } else { // work even without QApplication instance
823  Display* dpy = XOpenDisplay( NULL );
824  create_atoms( dpy );
825  bool ret = XGetSelectionOwner( dpy, net_wm_cm ) != None;
826  XCloseDisplay( dpy );
827  return ret;
828  }
829 }
830 
831 QRect KWindowSystem::workArea( int desktop )
832 {
833  init( INFO_BASIC );
834  int desk = (desktop > 0 && desktop <= (int) s_d_func()->numberOfDesktops() ) ? desktop : currentDesktop();
835  if ( desk <= 0 )
836  return QApplication::desktop()->geometry();
837 
838  NETRect r = s_d_func()->workArea( desk );
839  if( r.size.width <= 0 || r.size.height <= 0 ) // not set
840  return QApplication::desktop()->geometry();
841 
842  return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height );
843 }
844 
845 QRect KWindowSystem::workArea( const QList<WId>& exclude, int desktop )
846 {
847  init( INFO_WINDOWS ); // invalidates s_d_func's return value
848  KWindowSystemPrivate* const s_d = s_d_func();
849 
850  QRect all = QApplication::desktop()->geometry();
851  QRect a = all;
852 
853  if (desktop == -1)
854  desktop = s_d->currentDesktop();
855 
856  QList<WId>::ConstIterator it1;
857  for( it1 = s_d->windows.constBegin(); it1 != s_d->windows.constEnd(); ++it1 ) {
858 
859  if(exclude.contains(*it1))
860  continue;
861 
862 // Kicker (very) extensively calls this function, causing hundreds of roundtrips just
863 // to repeatedly find out struts of all windows. Therefore strut values for strut
864 // windows are cached here.
865  NETStrut strut;
866  QList< KWindowSystemPrivate::StrutData >::Iterator it2 = s_d->strutWindows.begin();
867  for( ; it2 != s_d->strutWindows.end(); ++it2 )
868  if( (*it2).window == *it1 )
869  break;
870 
871  if( it2 != s_d->strutWindows.end()) {
872  if(!((*it2).desktop == desktop || (*it2).desktop == NETWinInfo::OnAllDesktops ))
873  continue;
874 
875  strut = (*it2).strut;
876  } else if( s_d->possibleStrutWindows.contains( *it1 ) ) {
877 
878  NETWinInfo info( QX11Info::display(), (*it1), QX11Info::appRootWindow(), NET::WMStrut | NET::WMDesktop);
879  strut = info.strut();
880  s_d->possibleStrutWindows.removeAll( *it1 );
881  s_d->strutWindows.append( KWindowSystemPrivate::StrutData( *it1, info.strut(), info.desktop()));
882 
883  if( !(info.desktop() == desktop || info.desktop() == NETWinInfo::OnAllDesktops) )
884  continue;
885  } else
886  continue; // not a strut window
887 
888  QRect r = all;
889  if ( strut.left > 0 )
890  r.setLeft( r.left() + (int) strut.left );
891  if ( strut.top > 0 )
892  r.setTop( r.top() + (int) strut.top );
893  if ( strut.right > 0 )
894  r.setRight( r.right() - (int) strut.right );
895  if ( strut.bottom > 0 )
896  r.setBottom( r.bottom() - (int) strut.bottom );
897 
898  a = a.intersect(r);
899  }
900  return a;
901 }
902 
903 QString KWindowSystem::desktopName( int desktop )
904 {
905  init( INFO_BASIC );
906  KWindowSystemPrivate* const s_d = s_d_func();
907 
908  bool isDesktopSane = (desktop > 0 && desktop <= (int) s_d->numberOfDesktops());
909  const char* name = s_d->desktopName( isDesktopSane ? desktop : currentDesktop() );
910 
911  if ( name && name[0] )
912  return QString::fromUtf8( name );
913 
914  return i18n("Desktop %1", desktop );
915 }
916 
917 void KWindowSystem::setDesktopName( int desktop, const QString& name )
918 {
919  KWindowSystemPrivate* const s_d = s_d_func();
920 
921  if (desktop <= 0 || desktop > (int) numberOfDesktops() )
922  desktop = currentDesktop();
923 
924  if( s_d ) {
925  s_d->setDesktopName( desktop, name.toUtf8().constData() );
926  return;
927  }
928 
929  NETRootInfo info( QX11Info::display(), 0 );
930  info.setDesktopName( desktop, name.toUtf8().constData() );
931 }
932 
933 bool KWindowSystem::showingDesktop()
934 {
935  init( INFO_BASIC );
936  return s_d_func()->showingDesktop();
937 }
938 
939 void KWindowSystem::setUserTime( WId win, long time )
940 {
941  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), 0 );
942  info.setUserTime( time );
943 }
944 
945 void KWindowSystem::setExtendedStrut( WId win, int left_width, int left_start, int left_end,
946  int right_width, int right_start, int right_end, int top_width, int top_start, int top_end,
947  int bottom_width, int bottom_start, int bottom_end )
948 {
949  NETWinInfo info( QX11Info::display(), win, QX11Info::appRootWindow(), 0 );
950  NETExtendedStrut strut;
951  strut.left_width = left_width;
952  strut.right_width = right_width;
953  strut.top_width = top_width;
954  strut.bottom_width = bottom_width;
955  strut.left_start = left_start;
956  strut.left_end = left_end;
957  strut.right_start = right_start;
958  strut.right_end = right_end;
959  strut.top_start = top_start;
960  strut.top_end = top_end;
961  strut.bottom_start = bottom_start;
962  strut.bottom_end = bottom_end;
963  info.setExtendedStrut( strut );
964  NETStrut oldstrut;
965  oldstrut.left = left_width;
966  oldstrut.right = right_width;
967  oldstrut.top = top_width;
968  oldstrut.bottom = bottom_width;
969  info.setStrut( oldstrut );
970 }
971 
972 void KWindowSystem::setStrut( WId win, int left, int right, int top, int bottom )
973 {
974  int w = XDisplayWidth( QX11Info::display(), DefaultScreen( QX11Info::display()));
975  int h = XDisplayHeight( QX11Info::display(), DefaultScreen( QX11Info::display()));
976  setExtendedStrut( win, left, 0, left != 0 ? w : 0, right, 0, right != 0 ? w : 0,
977  top, 0, top != 0 ? h : 0, bottom, 0, bottom != 0 ? h : 0 );
978 }
979 
980 bool KWindowSystem::icccmCompliantMappingState()
981 {
982  static enum { noidea, yes, no } wm_is_1_2_compliant = noidea;
983  if( wm_is_1_2_compliant == noidea ) {
984  NETRootInfo info( QX11Info::display(), NET::Supported );
985  wm_is_1_2_compliant = info.isSupported( NET::Hidden ) ? yes : no;
986  }
987  return wm_is_1_2_compliant == yes;
988 }
989 
990 bool KWindowSystem::allowedActionsSupported()
991 {
992  static enum { noidea, yes, no } wm_supports_allowed_actions = noidea;
993  if( wm_supports_allowed_actions == noidea ) {
994  NETRootInfo info( QX11Info::display(), NET::Supported );
995  wm_supports_allowed_actions = info.isSupported( NET::WM2AllowedActions ) ? yes : no;
996  }
997  return wm_supports_allowed_actions == yes;
998 }
999 
1000 QString KWindowSystem::readNameProperty( WId win, unsigned long atom )
1001 {
1002  XTextProperty tp;
1003  char **text = NULL;
1004  int count;
1005  QString result;
1006  if ( XGetTextProperty( QX11Info::display(), win, &tp, atom ) != 0 && tp.value != NULL ) {
1007  create_atoms();
1008 
1009  if ( tp.encoding == kwm_utf8_string ) {
1010  result = QString::fromUtf8 ( (const char*) tp.value );
1011  } else if ( XmbTextPropertyToTextList( QX11Info::display(), &tp, &text, &count) == Success &&
1012  text != NULL && count > 0 ) {
1013  result = QString::fromLocal8Bit( text[0] );
1014  } else if ( tp.encoding == XA_STRING )
1015  result = QString::fromLocal8Bit( (const char*) tp.value );
1016  if( text != NULL )
1017  XFreeStringList( text );
1018  XFree( tp.value );
1019  }
1020  return result;
1021 }
1022 
1023 void KWindowSystem::doNotManage( const QString& title )
1024 {
1025  QDBusInterface("org.kde.kwin", "/KWin", "org.kde.KWin", QDBusConnection::sessionBus())
1026  .call("doNotManage", title);
1027 }
1028 
1029 void KWindowSystem::allowExternalProcessWindowActivation( int pid )
1030 {
1031  // Normally supported by X11, but may depend on some window managers ?
1032  Q_UNUSED(pid)
1033 }
1034 
1035 void KWindowSystem::setBlockingCompositing( WId window, bool active )
1036 {
1037  NETWinInfo info( QX11Info::display(), window, QX11Info::appRootWindow(), 0 );
1038  info.setBlockingCompositing( active );
1039 }
1040 
1041 
1042 bool KWindowSystem::mapViewport()
1043 {
1044  KWindowSystemPrivate* const s_d = s_d_func();
1045  if( s_d )
1046  return s_d->mapViewport();
1047  // avoid creating KWindowSystemPrivate
1048  NETRootInfo infos( QX11Info::display(), NET::Supported );
1049  if( !infos.isSupported( NET::DesktopViewport ))
1050  return false;
1051  NETRootInfo info( QX11Info::display(), NET::NumberOfDesktops | NET::CurrentDesktop | NET::DesktopGeometry );
1052  if( info.numberOfDesktops( true ) <= 1
1053  && ( info.desktopGeometry( info.currentDesktop( true )).width > QApplication::desktop()->width()
1054  || info.desktopGeometry( info.currentDesktop( true )).height > QApplication::desktop()->height()))
1055  return true;
1056  return false;
1057 }
1058 
1059 int KWindowSystem::viewportToDesktop( const QPoint& p )
1060 {
1061  init( INFO_BASIC );
1062  KWindowSystemPrivate* const s_d = s_d_func();
1063  NETSize s = s_d->desktopGeometry( s_d->currentDesktop( true ));
1064  QSize vs = qApp->desktop()->size();
1065  int xs = s.width / vs.width();
1066  int x = p.x() < 0 ? 0 : p.x() >= s.width ? xs - 1 : p.x() / vs.width();
1067  int ys = s.height / vs.height();
1068  int y = p.y() < 0 ? 0 : p.y() >= s.height ? ys - 1 : p.y() / vs.height();
1069  return y * xs + x + 1;
1070 }
1071 
1072 int KWindowSystem::viewportWindowToDesktop( const QRect& r )
1073 {
1074  init( INFO_BASIC );
1075  KWindowSystemPrivate* const s_d = s_d_func();
1076  QPoint p = r.center();
1077  // make absolute
1078  p = QPoint( p.x() + s_d->desktopViewport( s_d->currentDesktop( true )).x,
1079  p.y() + s_d->desktopViewport( s_d->currentDesktop( true )).y );
1080  NETSize s = s_d->desktopGeometry( s_d->currentDesktop( true ));
1081  QSize vs = qApp->desktop()->size();
1082  int xs = s.width / vs.width();
1083  int x = p.x() < 0 ? 0 : p.x() >= s.width ? xs - 1 : p.x() / vs.width();
1084  int ys = s.height / vs.height();
1085  int y = p.y() < 0 ? 0 : p.y() >= s.height ? ys - 1 : p.y() / vs.height();
1086  return y * xs + x + 1;
1087 }
1088 
1089 QPoint KWindowSystem::desktopToViewport( int desktop, bool absolute )
1090 {
1091  init( INFO_BASIC );
1092  KWindowSystemPrivate* const s_d = s_d_func();
1093  NETSize s = s_d->desktopGeometry( s_d->currentDesktop( true ));
1094  QSize vs = qApp->desktop()->size();
1095  int xs = s.width / vs.width();
1096  int ys = s.height / vs.height();
1097  if( desktop <= 0 || desktop > xs * ys )
1098  return QPoint( 0, 0 );
1099  --desktop;
1100  QPoint ret( vs.width() * ( desktop % xs ), vs.height() * ( desktop / xs ));
1101  if( !absolute ) {
1102  ret = QPoint( ret.x() - s_d->desktopViewport( s_d->currentDesktop( true )).x,
1103  ret.y() - s_d->desktopViewport( s_d->currentDesktop( true )).y );
1104  if( ret.x() >= s.width )
1105  ret.setX( ret.x() - s.width );
1106  if( ret.x() < 0 )
1107  ret.setX( ret.x() + s.width );
1108  if( ret.y() >= s.height )
1109  ret.setY( ret.y() - s.height );
1110  if( ret.y() < 0 )
1111  ret.setY( ret.y() + s.height );
1112  }
1113  return ret;
1114 }
1115 
1116 QPoint KWindowSystem::constrainViewportRelativePosition( const QPoint& pos )
1117 {
1118  init( INFO_BASIC );
1119  KWindowSystemPrivate* const s_d = s_d_func();
1120  NETSize s = s_d->desktopGeometry( s_d->currentDesktop( true ));
1121  NETPoint c = s_d->desktopViewport( s_d->currentDesktop( true ));
1122  int x = ( pos.x() + c.x ) % s.width;
1123  int y = ( pos.y() + c.y ) % s.height;
1124  if( x < 0 )
1125  x += s.width;
1126  if( y < 0 )
1127  y += s.height;
1128  return QPoint( x - c.x, y - c.y );
1129 }
1130 
1131 #include "kwindowsystem.moc"
KWindowSystem::readNameProperty
static QString readNameProperty(WId window, unsigned long atom)
Function that reads and returns the contents of the given text property (WM_NAME, WM_ICON_NAME...
Definition: kwindowsystem_mac.cpp:602
Atom
unsigned long Atom
Definition: kapplication.h:29
QObject::className
const char * className() const
NETIcon
Simple icon class for NET classes.
Definition: netwm_def.h:121
NETRootInfo::numberOfDesktops
int numberOfDesktops(bool ignore_viewport=false) const
Returns the number of desktops.
Definition: netwm.cpp:2739
i18n
QString i18n(const char *text)
KIconLoader::DefaultState
The default state.
Definition: kiconloader.h:172
NETStrut
Definition: netwm_def.h:194
QRect::setBottom
void setBottom(int y)
QImage::convertToFormat
QImage convertToFormat(Format format, QFlags< Qt::ImageConversionFlag > flags) const
NET::WMName
Definition: netwm_def.h:631
NET::WorkArea
Definition: netwm_def.h:623
QWidget
KWindowSystem::desktopNamesChanged
void desktopNamesChanged()
Desktops have been renamed.
KWindowSystem::lowerWindow
static void lowerWindow(WId win)
Lowers the given window.
Definition: kwindowsystem_mac.cpp:536
KWindowSystem::KWindowSystemPrivate
friend class KWindowSystemPrivate
Definition: kwindowsystem.h:651
NETStrut::bottom
int bottom
Bottom border of the strut.
Definition: netwm_def.h:218
NET::ActiveWindow
Definition: netwm_def.h:622
QSize::width
int width() const
KWindowSystem::transientFor
static WId transientFor(WId window)
Returns the WM_TRANSIENT_FOR property for the given window, i.e.
Definition: kwindowsystem_x11.cpp:603
QMetaObject::normalizedSignature
QByteArray normalizedSignature(const char *method)
QPixmap::width
int width() const
NETExtendedStrut::bottom_width
int bottom_width
Bottom border of the strut, width and range.
Definition: netwm_def.h:178
KWindowSystem::compositingChanged
void compositingChanged(bool enabled)
Compositing was enabled or disabled.
kdebug.h
NET::CurrentDesktop
Definition: netwm_def.h:620
windows_properties
static unsigned long windows_properties[2]
Definition: kwindowsystem_x11.cpp:58
QRect::right
int right() const
KWindowSystem::desktopName
static QString desktopName(int desktop)
Returns the name of the specified desktop.
Definition: kwindowsystem_mac.cpp:561
NETIcon::data
unsigned char * data
Image data for the icon.
Definition: netwm_def.h:139
KIconLoader::global
static KIconLoader * global()
Returns the global icon loader initialized with the global KComponentData.
KWindowSystem
Convenience access to certain properties and features of the window manager.
Definition: kwindowsystem.h:55
KWindowSystem::setOnDesktop
static void setOnDesktop(WId win, int desktop)
Moves window win to desktop desktop.
Definition: kwindowsystem_mac.cpp:406
NETExtendedStrut::top_end
int top_end
Definition: netwm_def.h:173
KWindowSystem::viewportToDesktop
static int viewportToDesktop(const QPoint &pos)
Definition: kwindowsystem_x11.cpp:1059
QX11Info::appRootWindow
Qt::HANDLE appRootWindow(int screen)
mask
#define mask
NETStrut::right
int right
Right border of the strut.
Definition: netwm_def.h:208
NET::WM2ShowingDesktop
Definition: netwm_def.h:689
QX11Info::display
Display * display()
NETRootInfo::activate
void activate()
Window Managers must call this after creating the NETRootInfo object, and before using any other meth...
Definition: netwm.cpp:827
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
NETPoint::y
int y
y coordinate
Definition: netwm_def.h:52
NET::ClientList
Definition: netwm_def.h:615
KWindowSystem::windowInfo
static KWindowInfo windowInfo(WId win, unsigned long properties, unsigned long properties2=0)
Returns information about window win.
Definition: kwindowsystem_mac.cpp:330
QX11Info::screen
int screen() const
QSize::isNull
bool isNull() const
NET::Supported
Definition: netwm_def.h:614
KWindowSystem::viewportWindowToDesktop
static int viewportWindowToDesktop(const QRect &r)
Definition: kwindowsystem_x11.cpp:1072
KWindowSystem::XApp
load the standard X icon (last fallback)
Definition: kwindowsystem.h:271
QWidget::setAttribute
void setAttribute(Qt::WidgetAttribute attribute, bool on)
NETWinInfo::PROTOCOLS
Definition: netwm.h:835
NETExtendedStrut::bottom_end
int bottom_end
Definition: netwm_def.h:178
QPixmap::fromImage
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
KWindowInfo
Information about a window.
Definition: kwindowinfo.h:35
QDBusConnection::sessionBus
QDBusConnection sessionBus()
kiconloader.h
sendClientMessageToRoot
static void sendClientMessageToRoot(Window w, Atom a, long x, long y=0, long z=0)
Definition: kwindowsystem_x11.cpp:362
NETExtendedStrut
Partial strut class for NET classes.
Definition: netwm_def.h:152
NETRootInfo::currentDesktop
int currentDesktop(bool ignore_viewport=false) const
Returns the current desktop.
Definition: netwm.cpp:2746
QPoint
KWindowSystem::setUserTime
static void setUserTime(WId win, long time)
Sets user timestamp time on window win.
Definition: kwindowsystem_mac.cpp:577
QWidget::x11Event
virtual bool x11Event(XEvent *event)
QImage::isNull
bool isNull() const
KWindowSystem::raiseWindow
static void raiseWindow(WId win)
Raises the given window.
Definition: kwindowsystem_mac.cpp:530
KWindowSystem::forceActiveWindow
static void forceActiveWindow(WId win, long time=0)
Sets window win to be the active window.
Definition: kwindowsystem_mac.cpp:366
KWindowSystem::setType
static void setType(WId win, NET::WindowType windowType)
Sets the type of window win to windowType.
Definition: kwindowsystem_mac.cpp:473
KWindowSystem::clearState
static void clearState(WId win, unsigned long state)
Clears the state of window win from state.
Definition: kwindowsystem_mac.cpp:512
klocale.h
NETRootInfo
Common API for root window properties/protocols.
Definition: netwm.h:58
atoms_created
static bool atoms_created
Definition: kwindowsystem_x11.cpp:325
KWindowSystem::connectNotify
virtual void connectNotify(const char *signal)
Definition: kwindowsystem_mac.cpp:616
QDBusAbstractInterface::call
QDBusMessage call(const QString &method, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, const QVariant &arg7, const QVariant &arg8)
NETExtendedStrut::top_start
int top_start
Definition: netwm_def.h:173
QPoint::x
int x() const
QPoint::y
int y() const
NETStrut::left
int left
Left border of the strut.
Definition: netwm_def.h:203
QWidget::geometry
geometry
NET::Hidden
indicates that a window should not be visible on the screen (e.g.
Definition: netwm_def.h:475
NET::WMStrut
Definition: netwm_def.h:636
QX11Info::appTime
unsigned long appTime()
KWindowSystem::setExtendedStrut
static void setExtendedStrut(WId win, int left_width, int left_start, int left_end, int right_width, int right_start, int right_end, int top_width, int top_start, int top_end, int bottom_width, int bottom_start, int bottom_end)
Sets the strut of window win to to left width ranging from left_start to left_end on the left edge...
Definition: kwindowsystem_mac.cpp:583
QWidget::width
width
NET::WM2RestackWindow
Definition: netwm_def.h:681
None
KWindowSystem::activateWindow
static void activateWindow(WId win, long time=0)
Requests that window win is activated.
Definition: kwindowsystem_mac.cpp:355
QObject::name
const char * name() const
NET::FromApplication
indicates that the request comes from a normal application
Definition: netwm_def.h:718
QRect
KWindowSystem::currentDesktop
static int currentDesktop()
Returns the current virtual desktop.
Definition: kwindowsystem_mac.cpp:384
KWindowSystem::windowChanged
void windowChanged(WId id, const unsigned long *properties)
The window changed.
KIconLoader::loadIcon
QPixmap loadIcon(const QString &name, KIconLoader::Group group, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList(), QString *path_store=0L, bool canReturnNull=false) const
Loads an icon.
Definition: kiconloader.cpp:1100
KWindowSystem::doNotManage
static void doNotManage(const QString &title)
Informs kwin via dbus to not manage a window with the specified title.
Definition: kwindowsystem_mac.cpp:609
NETRect::size
NETSize size
Size of the rectangle.
Definition: netwm_def.h:106
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
KWindowSystem::activeWindow
static WId activeWindow()
Returns the currently active window, or 0 if no window is active.
Definition: kwindowsystem_mac.cpp:348
QString::fromUtf8
QString fromUtf8(const char *str, int size)
KWindowSystem::minimizeWindow
static void minimizeWindow(WId win, bool animation=true)
Iconifies a window.
Definition: kwindowsystem_mac.cpp:518
netwm.h
NETRootInfo::removeClient
virtual void removeClient(Window window)
A Client should subclass NETRootInfo and reimplement this function when it wants to know when a windo...
Definition: netwm.h:670
NETExtendedStrut::right_end
int right_end
Definition: netwm_def.h:168
KIconLoader::Small
Small icons, e.g. for buttons.
Definition: kiconloader.h:139
NET::WindowType
WindowType
Window type.
Definition: netwm_def.h:305
KWindowSystem::icccmCompliantMappingState
static bool icccmCompliantMappingState()
Definition: kwindowsystem_mac.cpp:542
QRect::top
int top() const
NETPoint::x
int x
x coordinate.
Definition: netwm_def.h:52
net_wm_cm
static Atom net_wm_cm
Definition: kwindowsystem_x11.cpp:55
NETIcon::size
NETSize size
Size of the icon.
Definition: netwm_def.h:132
QRect::setTop
void setTop(int y)
NET::DesktopGeometry
Definition: netwm_def.h:618
QRect::left
int left() const
kde_wm_change_state
static Atom kde_wm_change_state
Definition: kwindowsystem_x11.cpp:327
QX11Info::appUserTime
unsigned long appUserTime()
KWindowSystem::setBlockingCompositing
static void setBlockingCompositing(WId window, bool active)
Sets whether the client wishes to block compositing (for better performance)
Definition: kwindowsystem_mac.cpp:627
KWindowSystem::windowAdded
void windowAdded(WId id)
A window has been added.
NET::WMIcon
Definition: netwm_def.h:638
QByteArray::constData
const char * constData() const
NET::WMIconName
Definition: netwm_def.h:646
NETRect::pos
NETPoint pos
Position of the rectangle.
Definition: netwm_def.h:99
NETPoint
Simple point class for NET classes.
Definition: netwm_def.h:43
KWindowSystem::setStrut
static void setStrut(WId win, int left, int right, int top, int bottom)
Convenience function for setExtendedStrut() that automatically makes struts as wide/high as the scree...
Definition: kwindowsystem_mac.cpp:591
KXErrorHandler
This class simplifies handling of X errors.
Definition: kxerrorhandler.h:62
QRect::center
QPoint center() const
QWidget::winId
WId winId() const
KWindowSystem::ClassHint
load icon after getting name from the classhint
Definition: kwindowsystem.h:270
KWindowSystem::NETWM
read from property from the window manager specification
Definition: kwindowsystem.h:268
QString
QList< WId >
KWindowSystem::unminimizeWindow
static void unminimizeWindow(WId win, bool animation=true)
DeIconifies a window.
Definition: kwindowsystem_mac.cpp:524
NETExtendedStrut::top_width
int top_width
Top border of the strut, width and range.
Definition: netwm_def.h:173
kwm_utf8_string
static Atom kwm_utf8_string
Definition: kwindowsystem_x11.cpp:329
kxerrorhandler.h
ksystemeventfilter.h
QStringList
KWindowSystem::desktopToViewport
static QPoint desktopToViewport(int desktop, bool absolute)
Definition: kwindowsystem_x11.cpp:1089
KWindowSystem::constrainViewportRelativePosition
static QPoint constrainViewportRelativePosition(const QPoint &pos)
Definition: kwindowsystem_x11.cpp:1116
NETRootInfo::isSupported
bool isSupported(NET::Property property) const
Returns true if the given property is supported by the window manager.
Definition: netwm.cpp:2640
KWindowSystem::setCurrentDesktop
static void setCurrentDesktop(int desktop)
Convenience function to set the current desktop to desktop.
Definition: kwindowsystem_mac.cpp:394
QDBusInterface
QPixmap
QObject::connectNotify
virtual void connectNotify(const char *signal)
QString::toLower
QString toLower() const
KWindowSystem::workArea
static QRect workArea(int desktop=-1)
Returns the workarea for the specified desktop, or the current work area if no desktop has been speci...
Definition: kwindowsystem_mac.cpp:547
QPixmap::isNull
bool isNull() const
KWindowSystem::setState
static void setState(WId win, unsigned long state)
Sets the state of window win to state.
Definition: kwindowsystem_mac.cpp:506
QSize
KWindowSystem::showingDesktopChanged
void showingDesktopChanged(bool showing)
The state of showing the desktop has changed.
QPixmap::height
int height() const
KWindowSystem::setIcons
static void setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon)
Sets an icon and a miniIcon on window win.
Definition: kwindowsystem_mac.cpp:467
KWindowSystem::windowRemoved
void windowRemoved(WId id)
A window has been removed.
QList::contains
bool contains(const T &value) const
QImage
NETRect
Simple rectangle class for NET classes.
Definition: netwm_def.h:93
NETRootInfo::desktopGeometry
NETSize desktopGeometry(int desktop) const
Returns the desktop geometry size.
Definition: netwm.cpp:2680
KWindowSystem::self
static KWindowSystem * self()
Access to the singleton instance.
Definition: kwindowsystem_mac.cpp:308
KWindowSystem::setMainWindow
static void setMainWindow(QWidget *subwindow, WId mainwindow)
Sets the parent window of subwindow to be mainwindow.
Definition: kwindowsystem_mac.cpp:412
KWindowSystem::allowExternalProcessWindowActivation
static void allowExternalProcessWindowActivation(int pid=-1)
Allows a window from another process to raise and activate itself.
Definition: kwindowsystem_mac.cpp:622
KWindowSystem::workAreaChanged
void workAreaChanged()
The workarea has changed.
KWindowSystem::windows
static const QList< WId > & windows()
Returns the list of all toplevel windows currently managed by the window manager in the order of crea...
Definition: kwindowsystem_mac.cpp:318
QRect::setRight
void setRight(int x)
NET::FromTool
indicated that the request comes from pager or similar tool
Definition: netwm_def.h:722
KWindowSystem::currentDesktopChanged
void currentDesktopChanged(int desktop)
Switched to another virtual desktop.
KWindowSystem::hasWId
static bool hasWId(WId id)
Test to see if id still managed at present.
Definition: kwindowsystem_mac.cpp:324
KWindowSystem::mapViewport
static bool mapViewport()
Definition: kwindowsystem_x11.cpp:1042
KWindowSystem::WMHints
read from WMHints property
Definition: kwindowsystem.h:269
NET::DemandsAttention
there was an attempt to activate this window, but the window manager prevented this.
Definition: netwm_def.h:490
desktop_properties
static unsigned long desktop_properties[2]
Definition: kwindowsystem_x11.cpp:71
KWindowSystem::showingDesktop
static bool showingDesktop()
Returns the state of showing the desktop.
Definition: kwindowsystem_mac.cpp:572
KWindowSystem::stackingOrderChanged
void stackingOrderChanged()
Emitted when the stacking order of the window changed.
QLatin1String
QApplication::desktop
QDesktopWidget * desktop()
KWindowSystem::demandAttention
static void demandAttention(WId win, bool set=true)
When application finishes some operation and wants to notify the user about it, it can call demandAtt...
Definition: kwindowsystem_mac.cpp:373
Window
NETWinInfo::OnAllDesktops
static const int OnAllDesktops
Sentinel value to indicate that the client wishes to be visible on all desktops.
Definition: netwm.h:1335
QWidget::find
QWidget * find(WId id)
KWindowSystem::setOnAllDesktops
static void setOnAllDesktops(WId win, bool b)
Sets window win to be present on all virtual desktops if is true.
Definition: kwindowsystem_mac.cpp:400
KWindowSystem::numberOfDesktops
static int numberOfDesktops()
Returns the number of virtual desktops.
Definition: kwindowsystem_mac.cpp:389
KStandardGuiItem::properties
KGuiItem properties()
Returns the 'Properties' gui item.
Definition: kstandardguiitem.cpp:299
NETSize::width
int width
Width.
Definition: netwm_def.h:79
NETWinInfo::PROTOCOLS2
Definition: netwm.h:835
KStandardGuiItem::no
KGuiItem no()
Returns the 'No' gui item.
Definition: kstandardguiitem.cpp:123
NETRootInfo::addClient
virtual void addClient(Window window)
A Client should subclass NETRootInfo and reimplement this function when it wants to know when a windo...
Definition: netwm.h:662
QSize::height
int height() const
KWindowSystem::numberOfDesktopsChanged
void numberOfDesktopsChanged(int num)
The number of desktops changed.
create_atoms
static void create_atoms(Display *dpy=QX11Info::display())
Definition: kwindowsystem_x11.cpp:331
QRect::bottom
int bottom() const
KWindowSystem::allowedActionsSupported
static bool allowedActionsSupported()
Returns true if the WM announces which actions it allows for windows.
Definition: kwindowsystem_mac.cpp:597
NETExtendedStrut::right_start
int right_start
Definition: netwm_def.h:168
KWindowSystem::compositingActive
static bool compositingActive()
Returns true if a compositing manager is running (i.e.
Definition: kwindowsystem_mac.cpp:379
KSystemEventFilter::installEventFilter
void installEventFilter(QWidget *filter)
Installs a widget filter as a global X11 event filter.
Definition: ksystemeventfilter.cpp:146
NETExtendedStrut::right_width
int right_width
Right border of the strut, width and range.
Definition: netwm_def.h:168
QImage::size
QSize size() const
QPoint::setX
void setX(int x)
QPoint::setY
void setY(int y)
kwindowsystem.h
KWindowSystem::icon
static QPixmap icon(WId win, int width=-1, int height=-1, bool scale=false)
Returns an icon for window win.
Definition: kwindowsystem_mac.cpp:418
QRect::intersect
QRect intersect(const QRect &rectangle) const
NET::DesktopViewport
Definition: netwm_def.h:619
NETExtendedStrut::left_end
int left_end
Definition: netwm_def.h:163
NETExtendedStrut::bottom_start
int bottom_start
Definition: netwm_def.h:178
QImage::bits
uchar * bits()
NETWinInfo
Common API for application window properties/protocols.
Definition: netwm.h:829
NETSize::height
int height
Height.
Definition: netwm_def.h:79
NET::DesktopNames
Definition: netwm_def.h:621
NETExtendedStrut::left_width
int left_width
Left border of the strut, width and range.
Definition: netwm_def.h:163
NETRootInfo::event
void event(XEvent *event, unsigned long *properties, int properties_size)
This function takes the passed XEvent and returns an OR'ed list of NETRootInfo properties that have c...
Definition: netwm.cpp:1858
QPixmap::toImage
QImage toImage() const
KWindowSystem::strutChanged
void strutChanged()
Something changed with the struts, may or may not have changed the work area.
KWindowSystem::groupLeader
static WId groupLeader(WId window)
Returns the leader window for the group the given window is in, if any.
Definition: kwindowsystem_x11.cpp:622
NET::ClientListStacking
Definition: netwm_def.h:616
KWindowSystem::activeWindowChanged
void activeWindowChanged(WId id)
Hint that is active (= has focus) now.
NET::NumberOfDesktops
Definition: netwm_def.h:617
kxutils.h
KWindowSystem::stackingOrder
static QList< WId > stackingOrder()
Returns the list of all toplevel windows currently managed by the window manager in the current stack...
Definition: kwindowsystem_mac.cpp:340
NET::WMDesktop
Definition: netwm_def.h:633
KXUtils::createPixmapFromHandle
QPixmap createPixmapFromHandle(WId pixmap, WId pixmap_mask)
Creates a QPixmap that contains a copy of the pixmap given by the X handle pixmap and optionally also...
Definition: kxutils.cpp:39
QRect::setLeft
void setLeft(int x)
NETStrut::top
int top
Top border of the strut.
Definition: netwm_def.h:213
KStandardGuiItem::yes
KGuiItem yes()
Returns the 'Yes' gui item.
Definition: kstandardguiitem.cpp:118
QList::begin
iterator begin()
NET::WMState
Definition: netwm_def.h:635
NETExtendedStrut::left_start
int left_start
Definition: netwm_def.h:163
NET::OnAllDesktops
Definition: netwm_def.h:704
QWidget::height
height
QImage::scaled
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
NETSize
Simple size class for NET classes.
Definition: netwm_def.h:70
KWindowSystem::setDesktopName
static void setDesktopName(int desktop, const QString &name)
Sets the name of the specified desktop.
Definition: kwindowsystem_mac.cpp:566
NET::WMGeometry
Definition: netwm_def.h:648
QX11Info
NET::WM2AllowedActions
Definition: netwm_def.h:680
_wm_protocols
static Atom _wm_protocols
Definition: kwindowsystem_x11.cpp:328
NET::Sticky
indicates that the Window Manager SHOULD keep the window's position fixed on the screen, even when the virtual desktop scrolls.
Definition: netwm_def.h:437
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal