KWin
Loading...
Searching...
No Matches
ge_event_mem_mover.h
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: 2018 Martin Flöser <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include <xcb/xcb.h>
12
13#include <cstring>
14
15namespace KWin
16{
17
19{
20public:
21 GeEventMemMover(xcb_generic_event_t *event)
22 : m_event(reinterpret_cast<xcb_ge_generic_event_t *>(event))
23 {
24 // xcb event structs contain stuff that wasn't on the wire, the full_sequence field
25 // adds an extra 4 bytes and generic events cookie data is on the wire right after the standard 32 bytes.
26 // Move this data back to have the same layout in memory as it was on the wire
27 // and allow casting, overwriting the full_sequence field.
28 memmove((char *)m_event + 32, (char *)m_event + 36, m_event->length * 4);
29 }
31 {
32 // move memory layout back, so that Qt can do the same without breaking
33 memmove((char *)m_event + 36, (char *)m_event + 32, m_event->length * 4);
34 }
35
37 {
38 return m_event;
39 }
40
41private:
43};
44
45}
xcb_ge_generic_event_t * operator->() const
GeEventMemMover(xcb_generic_event_t *event)