Blender V4.3
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
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);
36int GHOST_X11_ApplicationIOErrorHandler(Display *display);
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:
68
72 ~GHOST_SystemX11() override;
73
74 GHOST_TSuccess init() override;
75
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,
122 int32_t left,
123 int32_t top,
124 uint32_t width,
125 uint32_t height,
127 GHOST_GPUSettings gpuSettings,
128 const bool exclusive = false,
129 const bool is_dialog = false,
130 const GHOST_IWindow *parentWindow = nullptr) override;
131
138
145
151 bool processEvents(bool waitForEvent) override;
152
153 GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override;
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
185 void addDirtyWindow(GHOST_WindowX11 *bad_wind);
186
191 Display *getXDisplay()
192 {
193 return m_display;
194 }
195
196#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
197 XIM getX11_XIM()
198 {
199 return m_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 m_xtablets;
293 }
294#endif // WITH_X11_XINPUT
295
296 struct {
313
314 /* Atoms for Selection, copy & paste. */
316 Atom STRING;
318 Atom TEXT;
322 Atom INCR;
324#ifdef WITH_X11_XINPUT
325 Atom TABLET;
326#endif
328
329#ifdef WITH_X11_XINPUT
330 XExtensionVersion m_xinput_version;
331#endif
332
333 private:
334 Display *m_display;
335
337 XkbDescRec *m_xkb_descr;
338
339#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
340 XIM m_xim;
341#endif
342
343#ifdef WITH_X11_XINPUT
344 /* Tablet devices */
345 std::vector<GHOST_TabletX11> m_xtablets;
346#endif
347
349 std::vector<GHOST_WindowX11 *> m_dirty_windows;
350
352 char m_keyboard_vector[32];
353
358 Time m_last_warp_x;
359 Time m_last_warp_y;
360
361 /* Detect auto-repeat glitch. */
362 unsigned int m_last_release_keycode;
363 Time m_last_release_time;
364
365#ifdef WITH_X11_XINPUT
367 Time m_last_key_time;
368#endif
369
370 uint m_keycode_last_repeat_key;
371
377#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
378 bool openX11_IM();
379#endif
380
381#ifdef WITH_X11_XINPUT
382 void clearXInputDevices();
383 void refreshXInputDevices();
384#endif
385
386 GHOST_WindowX11 *findGhostWindow(Window xwind) const;
387
388 void processEvent(XEvent *xe);
389
390 Time lastEventTime(Time default_time);
391
392 bool generateWindowExposeEvents();
393};
unsigned int uint
struct ID ID
int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *event)
int GHOST_X11_ApplicationIOErrorHandler(Display *display)
GHOST_TWindowState
GHOST_TEventType
GHOST_TTabletMode
GHOST_TCapabilityFlag
Definition GHOST_Types.h:96
GHOST_TSuccess
Definition GHOST_Types.h:87
GHOST_TDragnDropTypes
GHOST_TConsoleWindowState
GHOST_DialogOptions
Definition GHOST_Types.h:80
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_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override
void addDirtyWindow(GHOST_WindowX11 *bad_wind)
struct GHOST_SystemX11::@1504 m_atom
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpuSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=nullptr) 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
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
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpuSettings) override
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
int len
static ulong state[N]
unsigned int uint32_t
Definition stdint.h:80
signed int int32_t
Definition stdint.h:77
unsigned char uint8_t
Definition stdint.h:78
unsigned __int64 uint64_t
Definition stdint.h:90