Blender V5.0
GHOST_SystemX11.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#pragma once
11
12#include <X11/XKBlib.h> /* Allow detectable auto-repeat. */
13#include <X11/Xlib.h>
14
15#include "../GHOST_Types.h"
16#include "GHOST_System.hh"
17
18/* For tablets. */
19#ifdef WITH_X11_XINPUT
20# include <X11/extensions/XInput.h>
21
22/* Disable XINPUT warp, currently not implemented by XORG for multi-head display.
23 * (see comment in XSERVER `Xi/xiwarppointer.c` -> `FIXME: panoramix stuff is missing` ~ v1.13.4)
24 * If this is supported we can add back XINPUT for warping (fixing #48901).
25 * For now disable (see #50383). */
26// # define USE_X11_XINPUT_WARP
27#endif
28
29#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
30# define GHOST_X11_RES_NAME "Blender" /* res_name */
31# define GHOST_X11_RES_CLASS "Blender" /* res_class */
32#endif
33
34/* generic error handlers */
35int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *event);
37
38#define GHOST_X11_ERROR_HANDLERS_OVERRIDE(var) \
39 struct { \
40 XErrorHandler handler; \
41 XIOErrorHandler handler_io; \
42 } var = { \
43 XSetErrorHandler(GHOST_X11_ApplicationErrorHandler), \
44 XSetIOErrorHandler(GHOST_X11_ApplicationIOErrorHandler), \
45 }
46
47#define GHOST_X11_ERROR_HANDLERS_RESTORE(var) \
48 { \
49 (void)XSetErrorHandler(var.handler); \
50 (void)XSetIOErrorHandler(var.handler_io); \
51 } \
52 ((void)0)
53
54class GHOST_WindowX11;
55
61 public:
66
68
72 ~GHOST_SystemX11() override;
73
74 GHOST_TSuccess init() override;
75
79
85 uint64_t getMilliSeconds() const override;
86
91 uint8_t getNumDisplays() const override;
92
97 void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
98
103 void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
104
121 GHOST_IWindow *createWindow(const char *title,
123 int32_t top,
124 uint32_t width,
125 uint32_t height,
127 GHOST_GPUSettings gpu_settings,
128 const bool exclusive = false,
129 const bool is_dialog = false,
130 const GHOST_IWindow *parent_window = nullptr) override;
131
138
145
151 bool processEvents(bool waitForEvent) override;
152
154
156
162 GHOST_TSuccess getPixelAtCursor(float r_color[3]) const override;
163
170
176 GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
177
178 GHOST_TCapabilityFlag getCapabilities() const override;
179
184
185 void addDirtyWindow(GHOST_WindowX11 *bad_wind);
186
190
192 {
193 return display_;
194 }
195
196#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
197 XIM getX11_XIM()
198 {
199 return xim_;
200 }
201#endif
202
208 uint64_t ms_from_input_time(const Time timestamp) const;
209
211 void getClipboard_xcout(const XEvent *evt,
212 Atom sel,
213 Atom target,
214 unsigned char **txt,
215 unsigned long *len,
216 unsigned int *context) const;
217
223 char *getClipboard(bool selection) const override;
224
230 void putClipboard(const char *buffer, bool selection) const override;
231
241 GHOST_TSuccess showMessageBox(const char *title,
242 const char *message,
243 const char *help_label,
244 const char *continue_label,
245 const char *link,
246 GHOST_DialogOptions dialog_options) const override;
247#ifdef WITH_XDND
259 static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType,
260 GHOST_TDragnDropTypes draggedObjectType,
261 GHOST_IWindow *window,
262 int mouseX,
263 int mouseY,
264 void *data);
265#endif
266
271 {
272 return 0;
273 }
274
275#ifdef WITH_X11_XINPUT
276 typedef struct GHOST_TabletX11 {
278 XDevice *Device;
279 XID ID;
280
281 int MotionEvent;
282 int ProxInEvent;
283 int ProxOutEvent;
284 int PressEvent;
285
286 int PressureLevels;
287 int XtiltLevels, YtiltLevels;
288 } GHOST_TabletX11;
289
290 std::vector<GHOST_TabletX11> &GetXTablets()
291 {
292 return xtablets_;
293 }
294#endif // WITH_X11_XINPUT
295
296 struct {
313
314 /* Atoms for Selection, copy & paste. */
316 Atom STRING;
319 Atom TEXT;
323 Atom INCR;
325#ifdef WITH_X11_XINPUT
326 Atom TABLET;
327#endif
329
330#ifdef WITH_X11_XINPUT
331 XExtensionVersion xinput_version_;
332#endif
333
334 private:
335 Display *display_;
336
338 XkbDescRec *xkb_descr_;
339
340#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
341 XIM xim_;
342#endif
343
344#ifdef WITH_X11_XINPUT
345 /* Tablet devices */
346 std::vector<GHOST_TabletX11> xtablets_;
347#endif
348
350 std::vector<GHOST_WindowX11 *> dirty_windows_;
351
353 char keyboard_vector_[32];
354
359 Time last_warp_x_;
360 Time last_warp_y_;
361
362 /* Detect auto-repeat glitch. */
363 unsigned int last_release_keycode_;
364 Time last_release_time_;
365
366#ifdef WITH_X11_XINPUT
368 Time last_key_time_;
369#endif
370
371 uint keycode_last_repeat_key_;
372
377
378#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
379 bool openX11_IM();
380#endif
381
382#ifdef WITH_X11_XINPUT
383 void clearXInputDevices();
384 void refreshXInputDevices();
385#endif
386
387 GHOST_WindowX11 *findGhostWindow(Window xwind) const;
388
389 void processEvent(XEvent *xe);
390
391 Time lastEventTime(Time default_time);
392
393 bool generateWindowExposeEvents();
394};
unsigned int uint
bool processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr user_data)
#define Window
#define Display
int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *event)
int GHOST_X11_ApplicationIOErrorHandler(Display *display)
GHOST_TWindowState
GHOST_TEventType
GHOST_TTabletMode
GHOST_TCapabilityFlag
GHOST_TSuccess
Definition GHOST_Types.h:57
GHOST_TDragnDropTypes
GHOST_TConsoleWindowState
GHOST_DialogOptions
BMesh const char void * data
unsigned long long int uint64_t
char * getClipboard(bool selection) const override
void putClipboard(const char *buffer, bool selection) const override
void getClipboard_xcout(const XEvent *evt, Atom sel, Atom target, unsigned char **txt, unsigned long *len, unsigned int *context) const
~GHOST_SystemX11() override
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpu_settings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parent_window=nullptr) override
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override
void addDirtyWindow(GHOST_WindowX11 *bad_wind)
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override
GHOST_TCapabilityFlag getCapabilities() const override
bool processEvents(bool waitForEvent) override
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override
uint8_t getNumDisplays() const override
GHOST_TSuccess disposeContext(GHOST_IContext *context) override
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpu_settings) override
uint64_t ms_from_input_time(const Time timestamp) const
Display * getXDisplay()
bool setConsoleWindowState(GHOST_TConsoleWindowState) override
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override
struct GHOST_SystemX11::@164270272260354005033176304166017055252265157316 atom_
GHOST_TSuccess init() override
GHOST_TSuccess showMessageBox(const char *title, const char *message, const char *help_label, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options) const override
uint64_t getMilliSeconds() const override
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const override
uint top
static ulong state[N]
static int left
Definition DNA_ID.h:414
uint len