KWindowSystem

platforms/osx/kwindowsystem.cpp
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2007 Laurent Montel <[email protected]>
4  SPDX-FileCopyrightText: 2008 Marijn Kruisselbrink <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8 
9 #include "kwindowsystem.h"
10 #include "kwindowinfo_mac_p.h"
11 
12 #include <KXErrorHandler>
13 #include <QBitmap>
14 #include <QDebug>
15 #include <QDesktopWidget>
16 #include <QDialog>
17 
18 #include <Carbon/Carbon.h>
19 
20 // Uncomment the following line to enable the experimental (and not fully functional) window tracking code. Without this
21 // only the processes/applications are tracked, not the individual windows. This currently is quite broken as I can't
22 // seem to be able to convince the build system to generate a mov file from both the public header file, and also for this
23 // private class
24 // #define EXPERIMENTAL_WINDOW_TRACKING
25 
26 static bool operator<(const ProcessSerialNumber &a, const ProcessSerialNumber &b)
27 {
28  if (a.lowLongOfPSN != b.lowLongOfPSN) {
29  return a.lowLongOfPSN < b.lowLongOfPSN;
30  }
31  return a.highLongOfPSN < b.highLongOfPSN;
32 }
33 
34 class KWindowSystemPrivate : QObject
35 {
36 #ifdef EXPERIMENTAL_WINDOW_TRACKING
37  Q_OBJECT
38 #endif
39 public:
40  KWindowSystemPrivate();
41 
42  QMap<WId, KWindowInfo> windows;
43  QList<WId> winids; // bah, because KWindowSystem::windows() returns a const reference, we need to keep this separate...
44  QMap<pid_t, AXObserverRef> newWindowObservers;
45  QMap<pid_t, AXObserverRef> windowClosedObservers;
47 #ifdef EXPERIMENTAL_WINDOW_TRACKING
48  QList<KWindowInfo> nonProcessedWindows;
49 #endif
50 
51  EventTargetRef m_eventTarget;
52  EventHandlerUPP m_eventHandler;
53  EventTypeSpec m_eventType[2];
54  EventHandlerRef m_curHandler;
55 
56  void applicationLaunched(const ProcessSerialNumber &psn);
57  void applicationTerminated(const ProcessSerialNumber &psn);
58 
59  bool m_noEmit;
60  bool waitingForTimer;
61 
62 #ifdef EXPERIMENTAL_WINDOW_TRACKING
63  void newWindow(AXUIElementRef element, void *windowInfoPrivate);
64  void windowClosed(AXUIElementRef element, void *windowInfoPrivate);
65 #endif
66 
67  static KWindowSystemPrivate *self()
68  {
69  return KWindowSystem::s_d_func();
70  }
71 #ifdef EXPERIMENTAL_WINDOW_TRACKING
72 public Q_SLOTS:
73  void tryRegisterProcess();
74 #endif
75 };
76 
77 class KWindowSystemStaticContainer
78 {
79 public:
80  KWindowSystemStaticContainer()
81  : d(new KWindowSystemPrivate)
82  {
83  }
84  KWindowSystem kwm;
85  KWindowSystemPrivate *d;
86 };
87 
88 KWINDOWSYSTEM_GLOBAL_STATIC(KWindowSystemStaticContainer, g_kwmInstanceContainer)
89 
90 static OSStatus applicationEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
91 {
92  KWindowSystemPrivate *d = (KWindowSystemPrivate *)inUserData;
93 
94  UInt32 kind;
95 
96  kind = GetEventKind(inEvent);
97  ProcessSerialNumber psn;
98  if (GetEventParameter(inEvent, kEventParamProcessID, typeProcessSerialNumber, nullptr, sizeof psn, nullptr, &psn) != noErr) {
99  kWarning() << "Error getting event parameter in application event";
100  return eventNotHandledErr;
101  }
102 
103  if (kind == kEventAppLaunched) {
104  d->applicationLaunched(psn);
105  } else if (kind == kEventAppTerminated) {
106  d->applicationTerminated(psn);
107  }
108 
109  return noErr;
110 }
111 
112 #ifdef EXPERIMENTAL_WINDOW_TRACKING
113 static void windowClosedObserver(AXObserverRef observer, AXUIElementRef element, CFStringRef notification, void *refcon)
114 {
115  KWindowSystemPrivate::self()->windowClosed(element, refcon);
116 }
117 
118 static void newWindowObserver(AXObserverRef observer, AXUIElementRef element, CFStringRef notification, void *refcon)
119 {
120  KWindowSystemPrivate::self()->newWindow(element, refcon);
121 }
122 #endif
123 
124 KWindowSystemPrivate::KWindowSystemPrivate()
125  : QObject(0)
126  , m_noEmit(true)
127  , waitingForTimer(false)
128 {
129  // find all existing windows
130  ProcessSerialNumber psn = {0, kNoProcess};
131  while (GetNextProcess(&psn) == noErr) {
132  qDebug() << "calling appLaunched for " << psn.lowLongOfPSN << ":" << psn.highLongOfPSN;
133  applicationLaunched(psn);
134  }
135 
136  m_noEmit = false;
137 
138 #ifdef Q_OS_MAC32
139  // register callbacks for application launches/quits
140  m_eventTarget = GetApplicationEventTarget();
141  m_eventHandler = NewEventHandlerUPP(applicationEventHandler);
142  m_eventType[0].eventClass = kEventClassApplication;
143  m_eventType[0].eventKind = kEventAppLaunched;
144  m_eventType[1].eventClass = kEventClassApplication;
145  m_eventType[1].eventKind = kEventAppTerminated;
146  if (InstallEventHandler(m_eventTarget, m_eventHandler, 2, m_eventType, this, &m_curHandler) != noErr) {
147  qDebug() << "Installing event handler failed!\n";
148  }
149 #else
150 #warning port me to Mac64
151 #endif
152 }
153 
154 void KWindowSystemPrivate::applicationLaunched(const ProcessSerialNumber &psn)
155 {
156 #ifdef Q_OS_MAC32
157  qDebug() << "new app: " << psn.lowLongOfPSN << ":" << psn.highLongOfPSN;
158  ProcessInfoRec pinfo;
159  FSSpec appSpec;
160  pinfo.processInfoLength = sizeof pinfo;
161  pinfo.processName = 0;
162  pinfo.processAppSpec = &appSpec;
163  GetProcessInformation(&psn, &pinfo);
164  if ((pinfo.processMode & modeOnlyBackground) != 0) {
165  return;
166  }
167  // found a process, create a pseudo-window for it
168 
169  KWindowInfo winfo(0, 0);
170  windows[winfo.win()] = winfo;
171  winids.append(winfo.win());
172  winfo.d->setProcessSerialNumber(psn);
173  pid_t pid = winfo.d->pid();
174  processes[psn] = winfo.win();
175  qDebug() << " pid:" << pid;
176  AXUIElementRef app = AXUIElementCreateApplication(pid);
177  winfo.d->setAxElement(app);
178  if (!m_noEmit) {
179  Q_EMIT KWindowSystem::self()->windowAdded(winfo.win());
180  }
181 
182 #ifdef EXPERIMENTAL_WINDOW_TRACKING
183  // create an observer and listen for new window events
184  AXObserverRef observer, newObserver;
185  OSStatus err;
186  if (AXObserverCreate(pid, windowClosedObserver, &observer) == noErr) {
187  CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), kCFRunLoopCommonModes);
188  windowClosedObservers[pid] = observer;
189  }
190  if ((err = AXObserverCreate(pid, newWindowObserver, &newObserver)) == noErr) {
191  CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(newObserver), kCFRunLoopCommonModes);
192  newWindowObservers[pid] = newObserver;
193  if ((err = AXObserverAddNotification(newObserver, app, kAXWindowCreatedNotification, winfo.d)) != noErr) {
194  qDebug() << "Error " << err << " adding notification to observer";
195  // adding notifier failed, apparently app isn't responding to accesability messages yet
196  // try it one more time later, and for now just return
197  QTimer::singleShot(500, this, SLOT(tryRegisterProcess()));
198  nonProcessedWindows.append(winfo);
199  return;
200  } else {
201  qDebug() << "Added notification and observer";
202  }
203  } else {
204  qDebug() << "Error creating observer";
205  }
206 
207  CFIndex windowsInApp;
208  AXUIElementGetAttributeValueCount(app, kAXWindowsAttribute, &windowsInApp);
209  CFArrayRef array;
210  AXUIElementCopyAttributeValue(app, kAXWindowsAttribute, (CFTypeRef *)&array);
211  for (CFIndex j = 0; j < windowsInApp; j++) {
212  AXUIElementRef win = (AXUIElementRef)CFArrayGetValueAtIndex(array, j);
213  newWindow(win, winfo.d);
214  }
215 #endif
216 #else
217 #warning Port me to Mac64
218 #endif
219 }
220 
221 #ifdef EXPERIMENTAL_WINDOW_TRACKING
222 void KWindowSystemPrivate::tryRegisterProcess()
223 {
224  qDebug() << "Single-shot timer, trying to register processes";
225  while (!nonProcessedWindows.empty()) {
226  KWindowInfo winfo = nonProcessedWindows.takeLast();
227  pid_t pid = winfo.d->pid();
228  AXUIElementRef app = winfo.d->axElement();
229  ProcessSerialNumber psn = winfo.d->psn();
230 
231  // create an observer and listen for new window events
232  AXObserverRef observer;
233  OSStatus err;
234  observer = newWindowObservers[pid];
235  if ((err = AXObserverAddNotification(observer, app, kAXWindowCreatedNotification, winfo.d)) != noErr) {
236  qDebug() << "Error " << err << " adding notification to observer";
237  } else {
238  qDebug() << "Added notification and observer";
239  }
240 
241  observer = windowClosedObservers[pid];
242 
243  CFIndex windowsInApp;
244  AXUIElementGetAttributeValueCount(app, kAXWindowsAttribute, &windowsInApp);
245  CFArrayRef array;
246  AXUIElementCopyAttributeValue(app, kAXWindowsAttribute, (CFTypeRef *)&array);
247  for (CFIndex j = 0; j < windowsInApp; j++) {
248  AXUIElementRef win = (AXUIElementRef)CFArrayGetValueAtIndex(array, j);
249  newWindow(win, winfo.d);
250  }
251  }
252 }
253 #endif
254 
255 void KWindowSystemPrivate::applicationTerminated(const ProcessSerialNumber &psn)
256 {
257  qDebug() << "Terminated PSN: " << psn.lowLongOfPSN << ":" << psn.highLongOfPSN;
258  WId id = processes[psn];
259  if (windows.contains(id)) {
260  KWindowInfo winfo = windows[id];
261  foreach (KWindowInfo::Private *wi, winfo.d->children) {
262  winids.removeAll(wi->win);
264  }
265  winids.removeAll(id);
267  }
268 }
269 
270 #ifdef EXPERIMENTAL_WINDOW_TRACKING
271 void KWindowSystemPrivate::windowClosed(AXUIElementRef element, void *refcon)
272 {
273  qDebug() << "Received window closed notification";
274 
275  KWindowInfo::Private *wind = (KWindowInfo::Private *)refcon; // window being closed
276  KWindowInfo::Private *parent = wind->parent;
277  parent->children.removeAll(wind);
278  winids.removeAll(wind->win);
279  if (!m_noEmit) {
281  }
282 }
283 
284 void KWindowSystemPrivate::newWindow(AXUIElementRef win, void *refcon)
285 {
286  qDebug() << "Received new window notification";
287 
288  KWindowInfo::Private *winfod = (KWindowInfo::Private *)refcon;
289  pid_t pid = winfod->pid();
290  ProcessSerialNumber psn = winfod->psn();
291  AXObserverRef observer = windowClosedObservers[pid];
292 
293  KWindowInfo win2(0, 0);
294  // listen for closed events for this window
295  if (AXObserverAddNotification(observer, win, kAXUIElementDestroyedNotification, win2.d) != noErr) {
296  // when we can't receive close events, the window should not be added
297  qDebug() "error adding closed observer to window.";
298  return;
299  }
300 
301  windows[win2.win()] = win2;
302  winids.append(win2.win());
303  win2.d->setProcessSerialNumber(psn);
304  win2.d->setAxElement(win);
305  winfod->children.append(win2.d);
306  win2.d->parent = winfod;
307  if (!m_noEmit) {
308  Q_EMIT KWindowSystem::self()->windowAdded(win2.win());
309  }
310 }
311 #endif
312 
314 {
315  return &(g_kwmInstanceContainer->kwm);
316 }
317 
318 KWindowSystemPrivate *KWindowSystem::s_d_func()
319 {
320  return g_kwmInstanceContainer->d;
321 }
322 
324 {
325  KWindowSystemPrivate *d = KWindowSystem::s_d_func();
326  return d->winids;
327 }
328 
329 bool KWindowSystem::hasWId(WId id)
330 {
331  KWindowSystemPrivate *d = KWindowSystem::s_d_func();
332  return d->windows.contains(id);
333 }
334 
335 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
336 KWindowInfo KWindowSystem::windowInfo(WId win, unsigned long properties, unsigned long properties2)
337 {
338  KWindowSystemPrivate *d = KWindowSystem::s_d_func();
339  if (d->windows.contains(win)) {
340  return d->windows[win];
341  } else {
342  return KWindowInfo(win, properties, properties2);
343  }
344 }
345 #endif
346 
348 {
349  // TODO
350  QList<WId> lst;
351  qDebug() << "QList<WId> KWindowSystem::stackingOrder() isn't yet implemented!";
352  return lst;
353 }
354 
356 {
357  // return something
358  qDebug() << "WId KWindowSystem::activeWindow() isn't yet implemented!";
359  return 0;
360 }
361 
362 void KWindowSystem::activateWindow(WId win, long time)
363 {
364  // TODO
365  qDebug() << "KWindowSystem::activateWindow( WId win, long time )isn't yet implemented!";
366  KWindowSystemPrivate *d = KWindowSystem::s_d_func();
367  if (d->windows.contains(win)) {
368  ProcessSerialNumber psn = d->windows[win].d->psn();
369  SetFrontProcess(&psn);
370  }
371 }
372 
373 void KWindowSystem::forceActiveWindow(WId win, long time)
374 {
375  // TODO
376  qDebug() << "KWindowSystem::forceActiveWindow( WId win, long time ) isn't yet implemented!";
377  activateWindow(win, time);
378 }
379 
380 void KWindowSystem::demandAttention(WId win, bool set)
381 {
382  // TODO
383  qDebug() << "KWindowSystem::demandAttention( WId win, bool set ) isn't yet implemented!";
384 }
385 
387 {
388  return true;
389 }
390 
392 {
393  return 1;
394 }
395 
397 {
398  return 1;
399 }
400 
401 void KWindowSystem::setCurrentDesktop(int desktop)
402 {
403  qDebug() << "KWindowSystem::setCurrentDesktop( int desktop ) isn't yet implemented!";
404  // TODO
405 }
406 
407 void KWindowSystem::setOnAllDesktops(WId win, bool b)
408 {
409  qDebug() << "KWindowSystem::setOnAllDesktops( WId win, bool b ) isn't yet implemented!";
410  // TODO
411 }
412 
413 void KWindowSystem::setOnDesktop(WId win, int desktop)
414 {
415  // TODO
416  qDebug() << "KWindowSystem::setOnDesktop( WId win, int desktop ) isn't yet implemented!";
417 }
418 
419 void KWindowSystem::setMainWindow(QWidget *subwindow, WId id)
420 {
421  qDebug() << "KWindowSystem::setMainWindow( QWidget*, WId ) isn't yet implemented!";
422  // TODO
423 }
424 
425 QPixmap KWindowSystem::icon(WId win, int width, int height, bool scale)
426 {
427  if (hasWId(win)) {
428  KWindowInfo info = windowInfo(win, 0);
429  if (!info.d->loadedData) {
430  info.d->updateData();
431  }
432  IconRef icon;
433  SInt16 label;
434 #ifdef Q_OS_MAC32
435  OSErr err = GetIconRefFromFile(&info.d->iconSpec, &icon, &label);
436 #else
437  OSStatus err = GetIconRefFromFileInfo(&info.d->iconSpec, 0, 0, kIconServicesCatalogInfoMask, 0, kIconServicesNormalUsageFlag, &icon, &label);
438 #endif
439  if (err != noErr) {
440  qDebug() << "Error getting icon from application";
441  return QPixmap();
442  } else {
443  QPixmap ret(width, height);
444  ret.fill(QColor(0, 0, 0, 0));
445 
446  CGRect rect = CGRectMake(0, 0, width, height);
447 
448  CGContextRef ctx = qt_mac_cg_context(&ret);
449  CGAffineTransform old_xform = CGContextGetCTM(ctx);
450  CGContextConcatCTM(ctx, CGAffineTransformInvert(old_xform));
451  CGContextConcatCTM(ctx, CGAffineTransformIdentity);
452 
453  ::RGBColor b;
454  b.blue = b.green = b.red = 255 * 255;
455  PlotIconRefInContext(ctx, &rect, kAlignNone, kTransformNone, &b, kPlotIconRefNormalFlags, icon);
456  CGContextRelease(ctx);
457 
458  ReleaseIconRef(icon);
459  return ret;
460  }
461  } else {
462  qDebug() << "QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale ) isn't yet implemented for local windows!";
463  return QPixmap();
464  }
465 }
466 
467 QPixmap KWindowSystem::icon(WId win, int width, int height, bool scale, int flags)
468 {
469  return icon(win, width, height, scale);
470  // qDebug() << "QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale, int flags ) isn't yet implemented!";
471 }
472 
473 void KWindowSystem::setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon)
474 {
475  // TODO
476  qDebug() << "KWindowSystem::setIcons( WId win, const QPixmap& icon, const QPixmap& miniIcon ) isn't yet implemented!";
477 }
478 
479 void KWindowSystem::setType(WId winid, NET::WindowType windowType)
480 {
481 #ifdef Q_OS_MAC32
482  // not supported for 'global' windows; only for windows in the current process
483  if (hasWId(winid)) {
484  return;
485  }
486 
487  static WindowGroupRef desktopGroup = 0;
488  static WindowGroupRef dockGroup = 0;
489 
490  WindowRef win = HIViewGetWindow((HIViewRef)winid);
491  // TODO: implement other types than Desktop and Dock
492  if (windowType != NET::Desktop && windowType != NET::Dock) {
493  qDebug() << "setType( WId win, NET::WindowType windowType ) isn't yet implemented for the type you requested!";
494  }
495  if (windowType == NET::Desktop) {
496  if (!desktopGroup) {
497  CreateWindowGroup(0, &desktopGroup);
498  SetWindowGroupLevel(desktopGroup, kCGDesktopIconWindowLevel);
499  }
500  SetWindowGroup(win, desktopGroup);
501  } else if (windowType == NET::Dock) {
502  if (!dockGroup) {
503  CreateWindowGroup(0, &dockGroup);
504  SetWindowGroupLevel(dockGroup, kCGDockWindowLevel);
505  }
506  SetWindowGroup(win, dockGroup);
507  ChangeWindowAttributes(win, kWindowNoTitleBarAttribute, kWindowNoAttributes);
508  }
509 #else
510 #warning port me to Mac64
511 #endif
512 }
513 
514 void KWindowSystem::setState(WId win, NET::States state)
515 {
516  // TODO
517  qDebug() << "KWindowSystem::setState( WId win, unsigned long state ) isn't yet implemented!";
518 }
519 
520 void KWindowSystem::clearState(WId win, NET::States state)
521 {
522  // TODO
523  qDebug() << "KWindowSystem::clearState( WId win, unsigned long state ) isn't yet implemented!";
524 }
525 
526 void KWindowSystem::minimizeWindow(WId win, bool animation)
527 {
528  // TODO
529  qDebug() << "KWindowSystem::minimizeWindow( WId win, bool animation) isn't yet implemented!";
530 }
531 
532 void KWindowSystem::unminimizeWindow(WId win, bool animation)
533 {
534  // TODO
535  qDebug() << "KWindowSystem::unminimizeWindow( WId win, bool animation ) isn't yet implemented!";
536 }
537 
538 void KWindowSystem::raiseWindow(WId win)
539 {
540  // TODO
541  qDebug() << "KWindowSystem::raiseWindow( WId win ) isn't yet implemented!";
542 }
543 
544 void KWindowSystem::lowerWindow(WId win)
545 {
546  // TODO
547  qDebug() << "KWindowSystem::lowerWindow( WId win ) isn't yet implemented!";
548 }
549 
551 {
552  return false;
553 }
554 
555 QRect KWindowSystem::workArea(int desktop)
556 {
557  // TODO
558  qDebug() << "QRect KWindowSystem::workArea( int desktop ) isn't yet implemented!";
559  return QRect();
560 }
561 
562 QRect KWindowSystem::workArea(const QList<WId> &exclude, int desktop)
563 {
564  // TODO
565  qDebug() << "QRect KWindowSystem::workArea( const QList<WId>& exclude, int desktop ) isn't yet implemented!";
566  return QRect();
567 }
568 
570 {
571  return tr("Desktop %1").arg(desktop);
572 }
573 
574 void KWindowSystem::setDesktopName(int desktop, const QString &name)
575 {
576  qDebug() << "KWindowSystem::setDesktopName( int desktop, const QString& name ) isn't yet implemented!";
577  // TODO
578 }
579 
581 {
582  return false;
583 }
584 
585 void KWindowSystem::setUserTime(WId win, long time)
586 {
587  qDebug() << "KWindowSystem::setUserTime( WId win, long time ) isn't yet implemented!";
588  // TODO
589 }
590 
592  int left_width,
593  int left_start,
594  int left_end,
595  int right_width,
596  int right_start,
597  int right_end,
598  int top_width,
599  int top_start,
600  int top_end,
601  int bottom_width,
602  int bottom_start,
603  int bottom_end)
604 {
605  qDebug() << "KWindowSystem::setExtendedStrut isn't yet implemented!";
606  // TODO
607 }
608 
609 void KWindowSystem::setStrut(WId win, int left, int right, int top, int bottom)
610 {
611  qDebug() << "KWindowSystem::setStrut isn't yet implemented!";
612  // TODO
613 }
614 
616 {
617  return false;
618 }
619 
620 QString KWindowSystem::readNameProperty(WId window, unsigned long atom)
621 {
622  // TODO
623  qDebug() << "QString KWindowSystem::readNameProperty( WId window, unsigned long atom ) isn't yet implemented!";
624  return QString();
625 }
626 
627 void KWindowSystem::connectNotify(const char *signal)
628 {
629  qDebug() << "connectNotify( const char* signal ) isn't yet implemented!";
630  // TODO
631 }
632 
634 {
635  // Needed on mac ?
636 }
637 
638 void KWindowSystem::setBlockingCompositing(WId window, bool active)
639 {
640  // TODO
641  qDebug() << "setBlockingCompositing( WId window, bool active ) isn't yet implemented!";
642 }
643 
644 #include "moc_kwindowsystem.cpp"
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...
static void lowerWindow(WId win)
Lowers the given window.
static void setMainWindow(QWindow *subwindow, WId mainwindow)
Sets the parent window of subwindow to be mainwindow.
static QString desktopName(int desktop)
Returns the name of the specified desktop.
Convenience access to certain properties and features of the window manager.
Definition: kwindowsystem.h:44
static void setOnDesktop(WId win, int desktop)
Moves window win to desktop desktop.
const QObjectList & children() const const
This class provides information about a given window in the platform specific windowing system...
Definition: kwindowinfo.h:62
static void setUserTime(WId win, long time)
Sets user timestamp time on window win.
static void raiseWindow(WId win)
Raises the given window.
static void forceActiveWindow(WId win, long time=0)
Sets window win to be the active window.
static void setType(WId win, NET::WindowType windowType)
Sets the type of window win to windowType.
QString tr(const char *sourceText, const char *disambiguation, int n)
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 left_width ranging from left_start to left_end on the left edge...
static void clearState(WId win, NET::States state)
Clears the state of window win from state.
static void activateWindow(WId win, long time=0)
Requests that window win is activated.
static int currentDesktop()
Returns the current virtual desktop.
static KWindowInfo windowInfo(WId win, NET::Properties properties, NET::Properties2 properties2=NET::Properties2())
Returns information about window win.
void append(const T &value)
static WId activeWindow()
Returns the currently active window, or 0 if no window is active.
indicates a desktop feature.
Definition: netwm_def.h:372
WindowType
Window type.
Definition: netwm_def.h:357
static bool icccmCompliantMappingState()
Q_OBJECTQ_OBJECT
QString label(StandardShortcut id)
static void setBlockingCompositing(WId window, bool active)
Sets whether the client wishes to block compositing (for better performance)
void windowAdded(WId id)
A window has been added.
int removeAll(const T &value)
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...
static void unminimizeWindow(WId win)
Unminimizes the window with id win.
static void setCurrentDesktop(int desktop)
Convenience function to set the current desktop to desktop.
static void setState(WId win, NET::States state)
Sets the state of window win to state.
static QRect workArea(int desktop=-1)
Returns the workarea for the specified desktop, or the current work area if no desktop has been speci...
static void setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon)
Sets an icon and a miniIcon on window win.
void windowRemoved(WId id)
A window has been removed.
bool contains(const T &value) const const
static KWindowSystem * self()
Access to the singleton instance.
static void allowExternalProcessWindowActivation(int pid=-1)
Allows a window from another process to raise and activate itself.
static void minimizeWindow(WId win)
Minimizes the window with id win.
WId win() const
Returns the window identifier.
static QList< WId > windows()
Returns the list of all toplevel windows currently managed by the window manager in the order of crea...
static bool hasWId(WId id)
Test to see if id still managed at present.
static bool showingDesktop()
Returns the state of showing the desktop.
indicates a dock or panel feature
Definition: netwm_def.h:376
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...
static void setOnAllDesktops(WId win, bool b)
Sets window win to be present on all virtual desktops if is true.
static int numberOfDesktops()
Returns the number of virtual desktops.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
static bool allowedActionsSupported()
Returns true if the WM announces which actions it allows for windows.
static bool compositingActive()
Returns true if a compositing manager is running (i.e.
static QPixmap icon(WId win, int width=-1, int height=-1, bool scale=false)
Returns an icon for window win.
Q_SLOTSQ_SLOTS
QObject * parent() const const
static QList< WId > stackingOrder()
Returns the list of all toplevel windows currently managed by the window manager in the current stack...
Q_EMITQ_EMIT
static void setDesktopName(int desktop, const QString &name)
Sets the name of the specified desktop.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 22:41:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.