KWin
Loading...
Searching...
No Matches
x11_standalone_edge.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2011 Arthur Arlt <a.arlt@stud.uni-heidelberg.de>
6 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
7
8 Since the functionality provided in this class has been moved from
9 class Workspace, it is not clear who exactly has written the code.
10 The list below contains the copyright holders of the class Workspace.
11
12 SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
13 SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
14 SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
15
16 SPDX-License-Identifier: GPL-2.0-or-later
17*/
18#include "x11_standalone_edge.h"
19#include "atoms.h"
20#include "cursor.h"
21
22namespace KWin
23{
24
26 : Edge(parent)
27 , m_window(XCB_WINDOW_NONE)
28 , m_approachWindow(XCB_WINDOW_NONE)
29{
30}
31
35
37{
38 createWindow();
39 createApproachWindow();
41}
42
44{
45 m_window.reset();
46 m_approachWindow.reset();
47}
48
49void WindowBasedEdge::createWindow()
50{
51 if (m_window.isValid()) {
52 return;
53 }
54 const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
55 const uint32_t values[] = {
56 true,
57 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION};
58 m_window.create(geometry(), XCB_WINDOW_CLASS_INPUT_ONLY, mask, values);
59 m_window.map();
60 // Set XdndAware on the windows, so that DND enter events are received (#86998)
61 xcb_atom_t version = 4; // XDND version
62 xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, m_window,
63 atoms->xdnd_aware, XCB_ATOM_ATOM, 32, 1, (unsigned char *)(&version));
64}
65
66void WindowBasedEdge::createApproachWindow()
67{
68 if (!activatesForPointer()) {
69 return;
70 }
71 if (m_approachWindow.isValid()) {
72 return;
73 }
74 if (!approachGeometry().isValid()) {
75 return;
76 }
77 const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
78 const uint32_t values[] = {
79 true,
80 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION};
81 m_approachWindow.create(approachGeometry(), XCB_WINDOW_CLASS_INPUT_ONLY, mask, values);
82 m_approachWindow.map();
83}
84
86{
87 m_window.setGeometry(geometry());
88 if (m_approachWindow.isValid()) {
89 m_approachWindow.setGeometry(approachGeometry());
90 }
91}
92
94{
95 if (!activatesForPointer()) {
96 return;
97 }
98 m_approachWindow.unmap();
99 Cursor *cursor = Cursors::self()->mouse();
100 m_cursorPollingConnection = connect(cursor, &Cursor::posChanged, this, &WindowBasedEdge::updateApproaching);
101 cursor->startMousePolling();
102}
103
105{
106 if (!m_cursorPollingConnection) {
107 return;
108 }
109 disconnect(m_cursorPollingConnection);
110 m_cursorPollingConnection = QMetaObject::Connection();
112 m_approachWindow.map();
113}
114
116{
117 if (!isReserved()) {
118 return;
119 }
120 if (isBlocked()) {
121 m_window.unmap();
122 m_approachWindow.unmap();
123 } else {
124 m_window.map();
125 m_approachWindow.map();
126 }
127}
128
129}
130
131#include "moc_x11_standalone_edge.cpp"
Xcb::Atom xdnd_aware
Definition atoms.h:43
Replacement for QCursor.
Definition cursor.h:102
void startMousePolling()
Definition cursor.cpp:283
void posChanged(const QPointF &pos)
void stopMousePolling()
Definition cursor.cpp:291
static Cursors * self()
Definition cursor.cpp:35
Cursor * mouse() const
Definition cursor.h:266
bool isBlocked() const
Definition screenedge.h:516
bool isReserved() const
Definition screenedge.h:476
void updateApproaching(const QPointF &point)
bool activatesForPointer() const
const QRect & geometry() const
Definition screenedge.h:496
const QRect & approachGeometry() const
Definition screenedge.h:501
Class for controlling screen edges.
Definition screenedge.h:222
void doStartApproaching() override
WindowBasedEdge(ScreenEdges *parent)
void create(const QRectF &geometry, uint32_t mask=0, const uint32_t *values=nullptr, xcb_window_t parent=rootWindow())
Definition xcbutils.h:1726
void setGeometry(const QRectF &geometry)
Definition xcbutils.h:1748
void reset(xcb_window_t window=XCB_WINDOW_NONE, bool destroy=true)
Definition xcbutils.h:1741
bool isValid() const
Definition xcbutils.h:1710
constexpr int version
KWIN_EXPORT xcb_connection_t * connection()
Definition xcb.h:19
KWIN_EXPORT Atoms * atoms
Definition main.cpp:74