1 /*
2     KWin - the KDE window manager
3     This file is part of the KDE project.
4 
5     SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
6     SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org>
7     SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
8     SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 #include "drag.h"
11 
12 #include "atoms.h"
13 
14 namespace KWin
15 {
16 namespace Xwl
17 {
18 
Drag(QObject * parent)19 Drag::Drag(QObject *parent)
20     : QObject(parent)
21 {
22 }
23 
~Drag()24 Drag::~Drag()
25 {
26 }
27 
sendClientMessage(xcb_window_t target,xcb_atom_t type,xcb_client_message_data_t * data)28 void Drag::sendClientMessage(xcb_window_t target, xcb_atom_t type, xcb_client_message_data_t *data)
29 {
30     xcb_client_message_event_t event {
31         XCB_CLIENT_MESSAGE, // response_type
32         32,         // format
33         0,          // sequence
34         target,     // window
35         type,       // type
36         *data,      // data
37     };
38     static_assert(sizeof(event) == 32, "Would leak stack data otherwise");
39 
40     xcb_connection_t *xcbConn = kwinApp()->x11Connection();
41     xcb_send_event(xcbConn,
42                    0,
43                    target,
44                    XCB_EVENT_MASK_NO_EVENT,
45                    reinterpret_cast<const char *>(&event));
46     xcb_flush(xcbConn);
47 }
48 
49 } // namespace Xwl
50 } // namespace KWin
51