KWindowSystem

kwindowsystem.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "kwindowsystem.h"
7 #include "kstartupinfo.h"
8 #include "kwindowsystem_dummy_p.h"
9 #include "kwindowsystemplugininterface_p.h"
10 #include "pluginwrapper_p.h"
11 
12 #include <config-kwindowsystem.h>
13 
14 #include <QGuiApplication>
15 #include <QMetaMethod>
16 #include <QPixmap>
17 #include <QPluginLoader>
18 #include <QTimer>
19 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 62)
20 #include <QWidget>
21 #endif
22 #include <QWindow>
23 #if KWINDOWSYSTEM_HAVE_X11
24 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
25 #include <private/qtx11extras_p.h>
26 #else
27 #include <QX11Info>
28 #endif
29 #endif
30 
31 // QPoint and QSize all have handy / operators which are useful for scaling, positions and sizes for high DPI support
32 // QRect does not, so we create one for internal purposes within this class
33 inline QRect operator/(const QRect &rectangle, qreal factor)
34 {
35  return QRect(rectangle.topLeft() / factor, rectangle.size() / factor);
36 }
37 
38 class KWindowSystemStaticContainer
39 {
40 public:
41  KWindowSystemStaticContainer()
42  {
43  d.reset(KWindowSystemPluginWrapper::self().createWindowSystem());
44 
46  kwm.moveToThread(QCoreApplication::instance()->thread());
47  }
48  }
49  KWindowSystemPrivate *xcbPlugin()
50  {
51  if (xcbPrivate.isNull()) {
52  QPluginLoader loader(QStringLiteral(XCB_PLUGIN_PATH));
53  QScopedPointer<KWindowSystemPluginInterface> xcbPlugin(qobject_cast<KWindowSystemPluginInterface *>(loader.instance()));
54  if (!xcbPlugin.isNull()) {
55  xcbPrivate.reset(xcbPlugin->createWindowSystem());
56  }
57  }
58  return xcbPrivate.data();
59  }
60  KWindowSystem kwm;
63 };
64 
65 Q_GLOBAL_STATIC(KWindowSystemStaticContainer, g_kwmInstanceContainer)
66 
67 KWindowSystemPrivate::~KWindowSystemPrivate()
68 {
69 }
70 
71 QPixmap KWindowSystemPrivate::iconFromNetWinInfo(int width, int height, bool scale, int flags, NETWinInfo *info)
72 {
73  Q_UNUSED(width)
74  Q_UNUSED(height)
75  Q_UNUSED(scale)
76  Q_UNUSED(flags)
77  Q_UNUSED(info)
78  return QPixmap();
79 }
80 
81 QList<WId> KWindowSystemPrivateDummy::windows()
82 {
83  return QList<WId>();
84 }
85 
86 QList<WId> KWindowSystemPrivateDummy::stackingOrder()
87 {
88  return QList<WId>();
89 }
90 
91 WId KWindowSystemPrivateDummy::activeWindow()
92 {
93  return 0;
94 }
95 
96 void KWindowSystemPrivateDummy::activateWindow(WId win, long time)
97 {
98  Q_UNUSED(win)
99  Q_UNUSED(time)
100 }
101 
102 void KWindowSystemPrivateDummy::forceActiveWindow(WId win, long time)
103 {
104  Q_UNUSED(win)
105  Q_UNUSED(time)
106 }
107 
108 void KWindowSystemPrivateDummy::demandAttention(WId win, bool set)
109 {
110  Q_UNUSED(win)
111  Q_UNUSED(set)
112 }
113 
114 bool KWindowSystemPrivateDummy::compositingActive()
115 {
116  return KWindowSystem::isPlatformWayland();
117 }
118 
119 int KWindowSystemPrivateDummy::currentDesktop()
120 {
121  return 0;
122 }
123 
124 int KWindowSystemPrivateDummy::numberOfDesktops()
125 {
126  return 0;
127 }
128 
129 void KWindowSystemPrivateDummy::setCurrentDesktop(int desktop)
130 {
131  Q_UNUSED(desktop)
132 }
133 
134 void KWindowSystemPrivateDummy::setOnAllDesktops(WId win, bool b)
135 {
136  Q_UNUSED(win)
137  Q_UNUSED(b)
138 }
139 
140 void KWindowSystemPrivateDummy::setOnDesktop(WId win, int desktop)
141 {
142  Q_UNUSED(win)
143  Q_UNUSED(desktop)
144 }
145 
146 void KWindowSystemPrivateDummy::setOnActivities(WId win, const QStringList &activities)
147 {
148  Q_UNUSED(win)
149  Q_UNUSED(activities)
150 }
151 
152 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
153 WId KWindowSystemPrivateDummy::transientFor(WId window)
154 {
155  Q_UNUSED(window)
156  return 0;
157 }
158 
159 WId KWindowSystemPrivateDummy::groupLeader(WId window)
160 {
161  Q_UNUSED(window)
162  return 0;
163 }
164 #endif
165 
166 QPixmap KWindowSystemPrivateDummy::icon(WId win, int width, int height, bool scale, int flags)
167 {
168  Q_UNUSED(win)
169  Q_UNUSED(width)
170  Q_UNUSED(height)
171  Q_UNUSED(scale)
172  Q_UNUSED(flags)
173  return QPixmap();
174 }
175 
176 void KWindowSystemPrivateDummy::setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon)
177 {
178  Q_UNUSED(win)
179  Q_UNUSED(icon)
180  Q_UNUSED(miniIcon)
181 }
182 
183 void KWindowSystemPrivateDummy::setType(WId win, NET::WindowType windowType)
184 {
185  Q_UNUSED(win)
186  Q_UNUSED(windowType)
187 }
188 
189 void KWindowSystemPrivateDummy::setState(WId win, NET::States state)
190 {
191  Q_UNUSED(win)
192  Q_UNUSED(state)
193 }
194 
195 void KWindowSystemPrivateDummy::clearState(WId win, NET::States state)
196 {
197  Q_UNUSED(win)
198  Q_UNUSED(state)
199 }
200 
201 void KWindowSystemPrivateDummy::minimizeWindow(WId win)
202 {
203  Q_UNUSED(win)
204 }
205 
206 void KWindowSystemPrivateDummy::unminimizeWindow(WId win)
207 {
208  Q_UNUSED(win)
209 }
210 
211 void KWindowSystemPrivateDummy::raiseWindow(WId win)
212 {
213  Q_UNUSED(win)
214 }
215 
216 void KWindowSystemPrivateDummy::lowerWindow(WId win)
217 {
218  Q_UNUSED(win)
219 }
220 
221 bool KWindowSystemPrivateDummy::icccmCompliantMappingState()
222 {
223  return false;
224 }
225 
226 QRect KWindowSystemPrivateDummy::workArea(int desktop)
227 {
228  Q_UNUSED(desktop)
229  return QRect();
230 }
231 
232 QRect KWindowSystemPrivateDummy::workArea(const QList<WId> &excludes, int desktop)
233 {
234  Q_UNUSED(excludes)
235  Q_UNUSED(desktop)
236  return QRect();
237 }
238 
239 QString KWindowSystemPrivateDummy::desktopName(int desktop)
240 {
241  Q_UNUSED(desktop)
242  return QString();
243 }
244 
245 void KWindowSystemPrivateDummy::setDesktopName(int desktop, const QString &name)
246 {
247  Q_UNUSED(desktop)
248  Q_UNUSED(name)
249 }
250 
251 bool KWindowSystemPrivateDummy::showingDesktop()
252 {
253  return false;
254 }
255 
256 void KWindowSystemPrivateDummy::setShowingDesktop(bool showing)
257 {
258  Q_UNUSED(showing);
259 }
260 
261 void KWindowSystemPrivateDummy::setUserTime(WId win, long time)
262 {
263  Q_UNUSED(win)
264  Q_UNUSED(time)
265 }
266 
267 void KWindowSystemPrivateDummy::setExtendedStrut(WId win,
268  int left_width,
269  int left_start,
270  int left_end,
271  int right_width,
272  int right_start,
273  int right_end,
274  int top_width,
275  int top_start,
276  int top_end,
277  int bottom_width,
278  int bottom_start,
279  int bottom_end)
280 {
281  Q_UNUSED(win)
282  Q_UNUSED(left_width)
283  Q_UNUSED(left_start)
284  Q_UNUSED(left_end)
285  Q_UNUSED(right_width)
286  Q_UNUSED(right_start)
287  Q_UNUSED(right_end)
288  Q_UNUSED(top_width)
289  Q_UNUSED(top_start)
290  Q_UNUSED(top_end)
291  Q_UNUSED(bottom_width)
292  Q_UNUSED(bottom_start)
293  Q_UNUSED(bottom_end)
294 }
295 
296 void KWindowSystemPrivateDummy::setStrut(WId win, int left, int right, int top, int bottom)
297 {
298  Q_UNUSED(win)
299  Q_UNUSED(left)
300  Q_UNUSED(right)
301  Q_UNUSED(top)
302  Q_UNUSED(bottom)
303 }
304 
305 bool KWindowSystemPrivateDummy::allowedActionsSupported()
306 {
307  return false;
308 }
309 
310 QString KWindowSystemPrivateDummy::readNameProperty(WId window, unsigned long atom)
311 {
312  Q_UNUSED(window)
313  Q_UNUSED(atom)
314  return QString();
315 }
316 
317 void KWindowSystemPrivateDummy::allowExternalProcessWindowActivation(int pid)
318 {
319  Q_UNUSED(pid)
320 }
321 
322 void KWindowSystemPrivateDummy::setBlockingCompositing(WId window, bool active)
323 {
324  Q_UNUSED(window)
325  Q_UNUSED(active)
326 }
327 
328 bool KWindowSystemPrivateDummy::mapViewport()
329 {
330  return false;
331 }
332 
333 int KWindowSystemPrivateDummy::viewportToDesktop(const QPoint &pos)
334 {
335  Q_UNUSED(pos)
336  return 0;
337 }
338 
339 int KWindowSystemPrivateDummy::viewportWindowToDesktop(const QRect &r)
340 {
341  Q_UNUSED(r)
342  return 0;
343 }
344 
345 QPoint KWindowSystemPrivateDummy::desktopToViewport(int desktop, bool absolute)
346 {
347  Q_UNUSED(desktop)
348  Q_UNUSED(absolute)
349  return QPoint();
350 }
351 
352 QPoint KWindowSystemPrivateDummy::constrainViewportRelativePosition(const QPoint &pos)
353 {
354  Q_UNUSED(pos)
355  return QPoint();
356 }
357 
358 void KWindowSystemPrivateDummy::connectNotify(const QMetaMethod &signal)
359 {
360  Q_UNUSED(signal)
361 }
362 
364 {
365  return &(g_kwmInstanceContainer()->kwm);
366 }
367 
368 KWindowSystemPrivate *KWindowSystem::d_func()
369 {
370  return g_kwmInstanceContainer()->d.data();
371 }
372 
373 void KWindowSystem::connectNotify(const QMetaMethod &signal)
374 {
376  d->connectNotify(signal);
377  QObject::connectNotify(signal);
378 }
379 
381 {
383  return d->windows();
384 }
385 
386 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
388 {
389  return KWindowInfo(win, properties, properties2);
390 }
391 #endif
392 
394 {
395  return windows().contains(w);
396 }
397 
399 {
401  return d->stackingOrder();
402 }
403 
405 {
407  return d->currentDesktop();
408 }
409 
411 {
413  return d->numberOfDesktops();
414 }
415 
417 {
419  d->setCurrentDesktop(desktop);
420 }
421 
422 void KWindowSystem::setOnAllDesktops(WId win, bool b)
423 {
425  d->setOnAllDesktops(win, b);
426 }
427 
428 void KWindowSystem::setOnDesktop(WId win, int desktop)
429 {
431  d->setOnDesktop(win, desktop);
432 }
433 
434 void KWindowSystem::setOnActivities(WId win, const QStringList &activities)
435 {
437  d->setOnActivities(win, activities);
438 }
439 
441 {
443  return d->activeWindow();
444 }
445 
446 void KWindowSystem::activateWindow(WId win, long time)
447 {
449  d->activateWindow(win, time);
450 }
451 
453 {
454  // If it's not yet exposed, there's nothing to activate
455  if (!win->isExposed())
456  return;
457 
458  activateWindow(win->winId(), time);
459 }
460 
461 void KWindowSystem::forceActiveWindow(WId win, long time)
462 {
464  d->forceActiveWindow(win, time);
465 }
466 
467 void KWindowSystem::demandAttention(WId win, bool set)
468 {
470  d->demandAttention(win, set);
471 }
472 
473 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
475 {
477  return d->transientFor(win);
478 }
479 
480 void KWindowSystem::setMainWindow(QWidget *subWidget, WId mainWindowId)
481 {
482  // Set the WA_NativeWindow attribute to force the creation of the QWindow.
483  // Without this QWidget::windowHandle() returns 0.
484  subWidget->setAttribute(Qt::WA_NativeWindow, true);
485  QWindow *subWindow = subWidget->windowHandle();
486  Q_ASSERT(subWindow);
487  setMainWindow(subWindow, mainWindowId);
488 }
489 #endif
490 
491 void KWindowSystem::setMainWindow(QWindow *subWindow, WId mainWindowId)
492 {
493  QWindow *mainWindow = QWindow::fromWinId(mainWindowId);
494  if (mainWindow) { // foreign windows not supported on all platforms
495  subWindow->setTransientParent(mainWindow);
496 
497  // mainWindow is not the child of any object, so make sure it gets deleted at some point
498  connect(subWindow, &QObject::destroyed, mainWindow, &QObject::deleteLater);
499  }
500 }
501 
502 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
504 {
506  return d->groupLeader(win);
507 }
508 #endif
509 
510 QPixmap KWindowSystem::icon(WId win, int width, int height, bool scale)
511 {
512  return icon(win, width, height, scale, NETWM | WMHints | ClassHint | XApp);
513 }
514 
515 QPixmap KWindowSystem::icon(WId win, int width, int height, bool scale, int flags)
516 {
518  return d->icon(win, width, height, scale, flags);
519 }
520 
521 QPixmap KWindowSystem::icon(WId win, int width, int height, bool scale, int flags, NETWinInfo *info)
522 {
524  width *= qApp->devicePixelRatio();
525  height *= qApp->devicePixelRatio();
526 #if KWINDOWSYSTEM_HAVE_X11
527  if (info) {
528  if (isPlatformX11()) {
529  // this is the xcb plugin, we can just delegate
530  return d->iconFromNetWinInfo(width, height, scale, flags, info);
531  } else {
532  // other platform plugin, load xcb plugin to delegate to it
533  if (KWindowSystemPrivate *p = g_kwmInstanceContainer()->xcbPlugin()) {
534  return p->iconFromNetWinInfo(width, height, scale, flags, info);
535  }
536  }
537  }
538 #else
539  Q_UNUSED(info)
540 #endif
541  return d->icon(win, width, height, scale, flags);
542 }
543 
544 void KWindowSystem::setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon)
545 {
547  d->setIcons(win, icon, miniIcon);
548 }
549 
550 void KWindowSystem::setType(WId win, NET::WindowType windowType)
551 {
553  d->setType(win, windowType);
554 }
555 
557 {
559  d->setState(win, state);
560 }
561 
563 {
565  d->clearState(win, state);
566 }
567 
569 {
571  d->minimizeWindow(win);
572 }
573 
575 {
577  d->unminimizeWindow(win);
578 }
579 
580 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
581 void KWindowSystem::minimizeWindow(WId win, bool animation)
582 {
583  Q_UNUSED(animation)
584  minimizeWindow(win);
585 }
586 #endif
587 
588 #if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(5, 0)
589 void KWindowSystem::unminimizeWindow(WId win, bool animation)
590 {
591  Q_UNUSED(animation)
592  unminimizeWindow(win);
593 }
594 #endif
595 
597 {
599  d->raiseWindow(win);
600 }
601 
603 {
605  d->lowerWindow(win);
606 }
607 
609 {
611  return d->compositingActive();
612 }
613 
615 {
617  return d->workArea(desktop) / qApp->devicePixelRatio();
618 }
619 
620 QRect KWindowSystem::workArea(const QList<WId> &exclude, int desktop)
621 {
623  return d->workArea(exclude, desktop) / qApp->devicePixelRatio();
624 }
625 
627 {
629  return d->desktopName(desktop);
630 }
631 
632 void KWindowSystem::setDesktopName(int desktop, const QString &name)
633 {
635  d->setDesktopName(desktop, name);
636 }
637 
639 {
641  return d->showingDesktop();
642 }
643 
645 {
647  return d->setShowingDesktop(showing);
648 }
649 
650 void KWindowSystem::setUserTime(WId win, long time)
651 {
653  d->setUserTime(win, time);
654 }
655 
657  int left_width,
658  int left_start,
659  int left_end,
660  int right_width,
661  int right_start,
662  int right_end,
663  int top_width,
664  int top_start,
665  int top_end,
666  int bottom_width,
667  int bottom_start,
668  int bottom_end)
669 {
671  const qreal dpr = qApp->devicePixelRatio();
672  d->setExtendedStrut(win,
673  left_width * dpr,
674  left_start * dpr,
675  left_end * dpr,
676  right_width * dpr,
677  right_start * dpr,
678  right_end * dpr,
679  top_width * dpr,
680  top_start * dpr,
681  top_end * dpr,
682  bottom_width * dpr,
683  bottom_start * dpr,
684  bottom_end * dpr);
685 }
686 
687 void KWindowSystem::setStrut(WId win, int left, int right, int top, int bottom)
688 {
690  const qreal dpr = qApp->devicePixelRatio();
691  d->setStrut(win, left * dpr, right * dpr, top * dpr, bottom * dpr);
692 }
693 
695 {
697  return d->icccmCompliantMappingState();
698 }
699 
701 {
703  return d->allowedActionsSupported();
704 }
705 
706 QString KWindowSystem::readNameProperty(WId win, unsigned long atom)
707 {
709  return d->readNameProperty(win, atom);
710 }
711 
713 {
715  d->allowExternalProcessWindowActivation(pid);
716 }
717 
718 void KWindowSystem::setBlockingCompositing(WId window, bool active)
719 {
721  d->setBlockingCompositing(window, active);
722 }
723 
725 {
727  return d->mapViewport();
728 }
729 
731 {
733  return d->viewportToDesktop(p / qApp->devicePixelRatio());
734 }
735 
737 {
739  return d->viewportWindowToDesktop(r / qApp->devicePixelRatio());
740 }
741 
742 QPoint KWindowSystem::desktopToViewport(int desktop, bool absolute)
743 {
745  return d->desktopToViewport(desktop, absolute);
746 }
747 
749 {
751  return d->constrainViewportRelativePosition(pos / qApp->devicePixelRatio());
752 }
753 
754 static inline KWindowSystem::Platform initPlatform()
755 {
756  auto platformName = QGuiApplication::platformName();
757  if (platformName == QLatin1String("flatpak")) {
758  // here we cannot know what is the actual windowing system, let's try it's env variable
759  const auto flatpakPlatform = QString::fromLocal8Bit(qgetenv("QT_QPA_FLATPAK_PLATFORM"));
760  if (!flatpakPlatform.isEmpty()) {
761  platformName = flatpakPlatform;
762  }
763  }
764 #if KWINDOWSYSTEM_HAVE_X11
765  if (platformName == QLatin1String("xcb")) {
767  }
768 #endif
769  if (platformName.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
771  }
773 }
774 
776 {
777  static Platform s_platform = initPlatform();
778  return s_platform;
779 }
780 
781 bool KWindowSystem::isPlatformX11()
782 {
783  return platform() == Platform::X11;
784 }
785 
786 bool KWindowSystem::isPlatformWayland()
787 {
788  return platform() == Platform::Wayland;
789 }
790 
792 {
793  // clang-format off
794  // TODO: move to a new KWindowSystemPrivate interface
795 #if KWINDOWSYSTEM_HAVE_X11
796  if (isPlatformX11()) {
797  const QByteArray startupId = QX11Info::nextStartupId();
798  if (!startupId.isEmpty()) {
799  KStartupInfo::setNewStartupId(window, startupId);
800  }
801  } else
802 #else
803  Q_UNUSED(window);
804 #endif
805  if (isPlatformWayland()) {
806  const QString token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN");
807  if (!token.isEmpty()) {
809  qunsetenv("XDG_ACTIVATION_TOKEN");
810  }
811  }
812  // clang-format on
813 }
814 
815 void KWindowSystem::requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id)
816 {
818  auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(d);
819  if (!dv2) {
820  // Ensure that xdgActivationTokenArrived is always emitted asynchronously
821  QTimer::singleShot(0, [serial] {
823  });
824 
825  return;
826  }
827  dv2->requestToken(win, serial, app_id);
828 }
829 
831 {
833  auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(d);
834  if (!dv2) {
835  return;
836  }
837  dv2->setCurrentToken(token);
838 }
839 
841 {
843  auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(d);
844  if (!dv2) {
845  return 0;
846  }
847  return dv2->lastInputSerial(window);
848 }
Platform
Enum describing the windowing system platform used by the QGuiApplication.
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 bool allowedActionsSupported()
Returns true if the WM announces which actions it allows for windows.
static void setOnDesktop(WId win, int desktop)
Moves window win to desktop desktop.
@ Unknown
A platform unknown to the application is used.
static Q_INVOKABLE void setCurrentXdgActivationToken(const QString &token)
Sets the token that will be used when activateWindow is called next.
static void setMainWindow(QWindow *subwindow, WId mainwindow)
Sets the parent window of subwindow to be mainwindow.
QPoint topLeft() const const
static void setDesktopName(int desktop, const QString &name)
Sets the name of the specified desktop.
CaseInsensitive
QSize size() const const
Q_EMITQ_EMIT
static bool showingDesktop()
Returns the state of showing the desktop.
This class provides information about a given window in the platform specific windowing system.
Definition: kwindowinfo.h:62
static QPoint constrainViewportRelativePosition(const QPoint &pos)
static void setBlockingCompositing(WId window, bool active)
Sets whether the client wishes to block compositing (for better performance)
@ X11
The xcb/X11 windowing system platorm.
static int viewportWindowToDesktop(const QRect &r)
static KWindowInfo windowInfo(WId win, NET::Properties properties, NET::Properties2 properties2=NET::Properties2())
Returns information about window win.
static WId groupLeader(WId window)
Returns the leader window for the group the given window is in, if any.
static void setCurrentDesktop(int desktop)
Convenience function to set the current desktop to desktop.
bool isExposed() const const
@ ClassHint
load icon after getting name from the classhint
static void setOnAllDesktops(WId win, bool b)
Sets window win to be present on all virtual desktops if is true.
void setAttribute(Qt::WidgetAttribute attribute, bool on)
static void raiseWindow(WId win)
Raises the given window.
bool contains(const T &value) const const
static QPixmap icon(WId win, int width=-1, int height=-1, bool scale=false)
Returns an icon for window win.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Q_GLOBAL_STATIC(Internal::StaticControl, s_instance) class ControlPrivate
void destroyed(QObject *obj)
void deleteLater()
static void setUserTime(WId win, long time)
Sets user timestamp time on window win.
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 forceActiveWindow(WId win, long time=0)
Sets window win to be the active window.
QString fromLocal8Bit(const char *str, int size)
static int numberOfDesktops()
Returns the number of virtual desktops.
static void unminimizeWindow(WId win)
Unminimizes the window with id win.
void xdgActivationTokenArrived(int serial, const QString &token)
Activation token to pass to the client.
static Q_INVOKABLE quint32 lastInputSerial(QWindow *window)
Offers the seat's current serial.
@ WMHints
read from WMHints property
@ NETWM
read from property from the window manager specification
bool isEmpty() const const
QCoreApplication * instance()
WId winId() const const
static void setState(WId win, NET::States state)
Sets the state of window win to state.
static void lowerWindow(WId win)
Lowers the given window.
static bool icccmCompliantMappingState()
static void clearState(WId win, NET::States state)
Clears the state of window win from state.
static void setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon)
Sets an icon and a miniIcon on window win.
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 setShowingDesktop(bool showing)
Sets the state of the "showing desktop" mode of the window manager.
static KWindowSystem * self()
Access to the singleton instance.
QWindow * fromWinId(WId id)
static Q_INVOKABLE void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id)
Requests an xdg_activation_v1 token for a specific window.
Convenience access to certain properties and features of the window manager.
Definition: kwindowsystem.h:44
QWindow * windowHandle() const const
bool isEmpty() const const
static bool hasWId(WId id)
Test to see if id still managed at present.
static void updateStartupId(QWindow *window)
Updates the platform-specific startup id, if any.
static Platform platform()
Returns the Platform used by the QGuiApplication.
static QList< WId > windows()
Returns the list of all toplevel windows currently managed by the window manager in the order of crea...
Common API for application window properties/protocols.
Definition: netwm.h:944
static int currentDesktop()
Returns the current virtual desktop.
static QPoint desktopToViewport(int desktop, bool absolute)
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 QList< WId > stackingOrder()
Returns the list of all toplevel windows currently managed by the window manager in the current stack...
static void setNewStartupId(QWindow *window, const QByteArray &startup_id)
Use this function if the application got a request with startup notification from outside (for exampl...
static bool mapViewport()
static void setType(WId win, NET::WindowType windowType)
Sets the type of window win to windowType.
static WId transientFor(WId window)
Returns the WM_TRANSIENT_FOR property for the given window, i.e.
static void allowExternalProcessWindowActivation(int pid=-1)
Allows a window from another process to raise and activate itself.
static WId activeWindow()
Returns the currently active window, or 0 if no window is active.
static QString desktopName(int desktop)
Returns the name of the specified desktop.
virtual void connectNotify(const QMetaMethod &signal)
static void setOnActivities(WId win, const QStringList &activities)
Moves window win to activities activities.
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...
@ Wayland
The Wayland windowing system platform.
static void activateWindow(WId win, long time=0)
Requests that window win is activated.
static int viewportToDesktop(const QPoint &pos)
static bool compositingActive()
Returns true if a compositing manager is running (i.e.
WA_NativeWindow
WindowType
Window type.
Definition: netwm_def.h:357
Q_D(Todo)
@ XApp
load the standard X icon (last fallback)
static void minimizeWindow(WId win)
Minimizes the window with id win.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri May 20 2022 04:13:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.