Blender  V2.93
GHOST_SystemX11.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
25 #pragma once
26 
27 #include <X11/XKBlib.h> /* Allow detectable auto-repeat. */
28 #include <X11/Xlib.h>
29 
30 #include "../GHOST_Types.h"
31 #include "GHOST_System.h"
32 
33 // For tablets
34 #ifdef WITH_X11_XINPUT
35 # include <X11/extensions/XInput.h>
36 
37 /* Disable XINPUT warp, currently not implemented by Xorg for multi-head display.
38  * (see comment in XSERVER `Xi/xiwarppointer.c` -> `FIXME: panoramix stuff is missing` ~ v1.13.4)
39  * If this is supported we can add back XINPUT for warping (fixing T48901).
40  * For now disable (see T50383). */
41 // # define USE_X11_XINPUT_WARP
42 #endif
43 
44 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
45 # define GHOST_X11_RES_NAME "Blender" /* res_name */
46 # define GHOST_X11_RES_CLASS "Blender" /* res_class */
47 #endif
48 
49 /* generic error handlers */
50 int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *theEvent);
51 int GHOST_X11_ApplicationIOErrorHandler(Display *display);
52 
53 #define GHOST_X11_ERROR_HANDLERS_OVERRIDE(var) \
54  struct { \
55  XErrorHandler handler; \
56  XIOErrorHandler handler_io; \
57  } var = { \
58  XSetErrorHandler(GHOST_X11_ApplicationErrorHandler), \
59  XSetIOErrorHandler(GHOST_X11_ApplicationIOErrorHandler), \
60  }
61 
62 #define GHOST_X11_ERROR_HANDLERS_RESTORE(var) \
63  { \
64  (void)XSetErrorHandler(var.handler); \
65  (void)XSetIOErrorHandler(var.handler_io); \
66  } \
67  ((void)0)
68 
69 class GHOST_WindowX11;
70 
76 class GHOST_SystemX11 : public GHOST_System {
77  public:
84 
89 
91 
102 
107  GHOST_TUns8 getNumDisplays() const;
108 
114 
120 
138  GHOST_IWindow *createWindow(const char *title,
145  GHOST_GLSettings glSettings,
146  const bool exclusive = false,
147  const bool is_dialog = false,
148  const GHOST_IWindow *parentWindow = 0);
149 
156 
163 
169  bool processEvents(bool waitForEvent);
170 
172 
174 
181 
187  GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const;
188 
194  void addDirtyWindow(GHOST_WindowX11 *bad_wind);
195 
200  Display *getXDisplay()
201  {
202  return m_display;
203  }
204 
205 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
206  XIM getX11_XIM()
207  {
208  return m_xim;
209  }
210 #endif
211 
213  void getClipboard_xcout(const XEvent *evt,
214  Atom sel,
215  Atom target,
216  unsigned char **txt,
217  unsigned long *len,
218  unsigned int *context) const;
219 
225  GHOST_TUns8 *getClipboard(bool selection) const;
226 
232  void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
233 
243  GHOST_TSuccess showMessageBox(const char *title,
244  const char *message,
245  const char *help_label,
246  const char *continue_label,
247  const char *link,
248  GHOST_DialogOptions dialog_options) const;
249 #ifdef WITH_XDND
261  static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType,
262  GHOST_TDragnDropTypes draggedObjectType,
263  GHOST_IWindow *window,
264  int mouseX,
265  int mouseY,
266  void *data);
267 #endif
268 
272  int toggleConsole(int /*action*/)
273  {
274  return 0;
275  }
276 
277 #ifdef WITH_X11_XINPUT
278  typedef struct GHOST_TabletX11 {
279  GHOST_TTabletMode mode;
280  XDevice *Device;
281  XID ID;
282 
283  int MotionEvent;
284  int ProxInEvent;
285  int ProxOutEvent;
286  int PressEvent;
287 
288  int PressureLevels;
289  int XtiltLevels, YtiltLevels;
290  } GHOST_TabletX11;
291 
292  std::vector<GHOST_TabletX11> &GetXTablets()
293  {
294  return m_xtablets;
295  }
296 #endif // WITH_X11_XINPUT
297 
298  struct {
305  Atom WM_STATE;
315 
316  /* Atoms for Selection, copy & paste. */
317  Atom TARGETS;
318  Atom STRING;
320  Atom TEXT;
321  Atom CLIPBOARD;
322  Atom PRIMARY;
323  Atom XCLIP_OUT;
324  Atom INCR;
326 #ifdef WITH_X11_XINPUT
327  Atom TABLET;
328 #endif
330 
331 #ifdef WITH_X11_XINPUT
332  XExtensionVersion m_xinput_version;
333 #endif
334 
335  private:
336  Display *m_display;
337 
339  XkbDescRec *m_xkb_descr;
340 
341 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
342  XIM m_xim;
343 #endif
344 
345 #ifdef WITH_X11_XINPUT
346  /* Tablet devices */
347  std::vector<GHOST_TabletX11> m_xtablets;
348 #endif
349 
351  std::vector<GHOST_WindowX11 *> m_dirty_windows;
352 
354  GHOST_TUns64 m_start_time;
355 
357  char m_keyboard_vector[32];
358 
363  Time m_last_warp_x;
364  Time m_last_warp_y;
365 
366  /* Detect auto-repeat glitch. */
367  unsigned int m_last_release_keycode;
368  Time m_last_release_time;
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
Definition: BLI_sys_types.h:83
struct ID ID
int GHOST_X11_ApplicationIOErrorHandler(Display *display)
int GHOST_X11_ApplicationErrorHandler(Display *display, XErrorEvent *theEvent)
GHOST_TWindowState
Definition: GHOST_Types.h:144
unsigned int GHOST_TUns32
Definition: GHOST_Types.h:64
unsigned long long GHOST_TUns64
Definition: GHOST_Types.h:86
GHOST_TEventType
Definition: GHOST_Types.h:177
int GHOST_TInt32
Definition: GHOST_Types.h:63
GHOST_TTabletMode
Definition: GHOST_Types.h:100
GHOST_TDrawingContextType
Definition: GHOST_Types.h:156
char GHOST_TInt8
Definition: GHOST_Types.h:59
GHOST_TSuccess
Definition: GHOST_Types.h:91
GHOST_TDragnDropTypes
Definition: GHOST_Types.h:477
unsigned char GHOST_TUns8
Definition: GHOST_Types.h:60
GHOST_DialogOptions
Definition: GHOST_Types.h:76
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Time
Definition: device.h:293
GHOST_TSuccess disposeContext(GHOST_IContext *context)
GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
void getClipboard_xcout(const XEvent *evt, Atom sel, Atom target, unsigned char **txt, unsigned long *len, unsigned int *context) const
GHOST_IContext * createOffscreenContext(GHOST_GLSettings glSettings)
void addDirtyWindow(GHOST_WindowX11 *bad_wind)
GHOST_TSuccess init()
void getAllDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
Atom _NET_WM_STATE_MAXIMIZED_VERT
GHOST_IWindow * createWindow(const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=0)
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const
GHOST_TUns64 getMilliSeconds() const
Display * getXDisplay()
bool processEvents(bool waitForEvent)
GHOST_TUns8 getNumDisplays() const
struct GHOST_SystemX11::@1233 m_atom
GHOST_TUns8 * getClipboard(bool selection) const
int toggleConsole(int)
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
Atom _NET_WM_STATE_MAXIMIZED_HORZ
GHOST_TSuccess getCursorPosition(GHOST_TInt32 &x, GHOST_TInt32 &y) const
void getMainDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
void putClipboard(GHOST_TInt8 *buffer, bool selection) const
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
static ulong state[N]
static int left
struct SELECTID_Context context
Definition: select_engine.c:47
uint len