Blender V5.3
GHOST_WindowX11.cc
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
8
9/* For standard X11 cursors */
10#include <X11/Xatom.h>
11#include <X11/Xmd.h>
12#include <X11/Xutil.h>
13#include <X11/cursorfont.h>
14
15#include "GHOST_Debug.hh"
16#include "GHOST_IconX11.hh"
17#include "GHOST_SystemX11.hh"
18#include "GHOST_Types.hh"
19#include "GHOST_WindowX11.hh"
20#include "GHOST_utildefines.hh"
21
22#ifdef WITH_XDND
23# include "GHOST_DropTargetX11.hh"
24#endif
25
26#ifdef WITH_OPENGL_BACKEND
27# include "GHOST_ContextEGL.hh"
28# include "GHOST_ContextGLX.hh"
29#endif
30#ifdef WITH_VULKAN_BACKEND
31# include "GHOST_ContextVK.hh"
32#endif
33
34/* For #XIWarpPointer. */
35#ifdef WITH_X11_XINPUT
36# include <X11/extensions/XInput2.h>
37#endif
38
39/* For DPI value. */
40#include <X11/Xresource.h>
41
42#include <cstdio>
43#include <cstring>
44
45/* For `gethostname`. */
46#include <unistd.h>
47
48#include <algorithm>
49#include <climits>
50#include <cmath>
51#include <string>
52
53/* For obscure full screen mode stuff
54 * lifted verbatim from blut. */
55
57 long flags;
61};
62
63enum {
66};
67enum {
68 MWM_FUNCTION_ALL = (1L << 0),
70 MWM_FUNCTION_MOVE = (1L << 2),
73 MWM_FUNCTION_CLOSE = (1L << 5),
74};
75
76#ifndef HOST_NAME_MAX
77# define HOST_NAME_MAX 64
78#endif
79
80// #define GHOST_X11_GRAB
81
82/*
83 * A Client can't change the window property, that is
84 * the work of the window manager. In case, we send
85 * a ClientMessage to the RootWindow with the property
86 * and the Action (WM-spec define this):
87 */
88#define _NET_WM_STATE_REMOVE 0
89#define _NET_WM_STATE_ADD 1
90// #define _NET_WM_STATE_TOGGLE 2 // UNUSED
91
92#ifdef WITH_OPENGL_BACKEND
93static XVisualInfo *get_x11_visualinfo(Display *display)
94{
95 int num_visuals;
96 XVisualInfo vinfo_template;
97 vinfo_template.screen = DefaultScreen(display);
98 return XGetVisualInfo(display, VisualScreenMask, &vinfo_template, &num_visuals);
99}
100#endif
101
103 Display *display,
104 const char *title,
105 int32_t left,
106 int32_t top,
107 uint32_t width,
108 uint32_t height,
110 GHOST_WindowX11 *parent_window,
112 const bool is_dialog,
113 const GHOST_ContextParams &context_params,
114 const bool exclusive,
115 const GHOST_GPUDevice &preferred_device)
116 : GHOST_Window(width, height, state, context_params, exclusive),
117 display_(display),
118 visual_info_(nullptr),
119 fbconfig_(nullptr),
120 normal_state_(GHOST_kWindowStateNormal),
121 system_(system),
122 invalid_window_(false),
123 empty_cursor_(None),
124 custom_cursor_(None),
125 visible_cursor_(None),
126#ifdef WITH_XDND
127 drop_target_(nullptr),
128#endif
129 tablet_data_(GHOST_TABLET_DATA_NONE),
130#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
131 xic_(nullptr),
132#endif
133 valid_setup_(false),
134 preferred_device_(preferred_device)
135{
136#ifdef WITH_OPENGL_BACKEND
137 if (type == GHOST_kDrawingContextTypeOpenGL) {
138 visual_info_ = get_x11_visualinfo(display_);
139 }
140 else
141#endif
142 {
143 XVisualInfo tmp = {nullptr};
144 int n;
145 visual_info_ = XGetVisualInfo(display_, 0, &tmp, &n);
146 }
147
148 /* caller needs to check 'getValid()' */
149 if (visual_info_ == nullptr) {
150 fprintf(stderr, "initial window could not find the GLX extension\n");
151 return;
152 }
153
154 uint xattributes_valuemask = 0;
155
156 XSetWindowAttributes xattributes;
157 memset(&xattributes, 0, sizeof(xattributes));
158
159 xattributes_valuemask |= CWBorderPixel;
160 xattributes.border_pixel = 0;
161
162 /* Specify which events we are interested in hearing. */
163
164 xattributes_valuemask |= CWEventMask;
165 xattributes.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
166 EnterWindowMask | LeaveWindowMask | ButtonPressMask |
167 ButtonReleaseMask | PointerMotionMask | FocusChangeMask |
168 PropertyChangeMask | KeymapStateMask;
169
170 if (exclusive) {
171 xattributes_valuemask |= CWOverrideRedirect;
172 xattributes.override_redirect = True;
173 }
174
175 xattributes_valuemask |= CWColormap;
176 xattributes.colormap = XCreateColormap(
177 display_, RootWindow(display_, visual_info_->screen), visual_info_->visual, AllocNone);
178
179 /* create the window! */
180 window_ = XCreateWindow(display_,
181 RootWindow(display_, visual_info_->screen),
182 left,
183 top,
184 width,
185 height,
186 0, /* no border. */
187 visual_info_->depth,
188 InputOutput,
189 visual_info_->visual,
190 xattributes_valuemask,
191 &xattributes);
192
193#ifdef WITH_XDND
194 /* initialize drop target for newly created window */
195 drop_target_ = new GHOST_DropTargetX11(this, system_);
196 GHOST_PRINT("Set drop target\n");
197#endif
198
200 Atom atoms[2];
201 int count = 0;
203 atoms[count++] = system_->atom_._NET_WM_STATE_MAXIMIZED_VERT;
204 atoms[count++] = system_->atom_._NET_WM_STATE_MAXIMIZED_HORZ;
205 }
206 else {
207 atoms[count++] = system_->atom_._NET_WM_STATE_FULLSCREEN;
208 }
209
210 XChangeProperty(display_,
211 window_,
212 system_->atom_._NET_WM_STATE,
213 XA_ATOM,
214 32,
215 PropModeReplace,
216 (uchar *)atoms,
217 count);
218 post_init_ = False;
219 }
220 /*
221 * One of the problem with WM-spec is that can't set a property
222 * to a window that isn't mapped. That is why we can't "just
223 * call setState" here.
224 *
225 * To fix this, we first need know that the window is really
226 * map waiting for the MapNotify event.
227 *
228 * So, post_init_ indicate that we need wait for the MapNotify
229 * event and then set the Window state to the post_state_.
230 */
232 post_init_ = True;
234 }
235 else {
236 post_init_ = False;
238 }
239
240 if (is_dialog && parent_window) {
241 setDialogHints(parent_window);
242 }
243
244 /* Create some hints for the window manager on how
245 * we want this window treated. */
246 {
247 XSizeHints *xsizehints = XAllocSizeHints();
248 xsizehints->flags = PPosition | PSize | PMinSize | PMaxSize;
249 xsizehints->x = left;
250 xsizehints->y = top;
251 xsizehints->width = width;
252 xsizehints->height = height;
253 xsizehints->min_width = 320; /* Size hints, could be made apart of the GHOST API. */
254 xsizehints->min_height = 240; /* Limits are also arbitrary, but should not allow 1x1 window. */
255 xsizehints->max_width = 65535;
256 xsizehints->max_height = 65535;
257 XSetWMNormalHints(display_, window_, xsizehints);
258 XFree(xsizehints);
259 }
260
261 /* XClassHint, title */
262 {
263 XClassHint *xclasshint = XAllocClassHint();
264/* See `GHOST_X11_RES_NAME` definition in GHOST_SystemX11.hh */
265#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
266 /* Safe as these are logically `const` (the values aren't manipulated). */
267 xclasshint->res_name = const_cast<char *>(GHOST_X11_RES_NAME);
268 xclasshint->res_class = const_cast<char *>(GHOST_X11_RES_CLASS);
269 XSetClassHint(display_, window_, xclasshint);
270#else
271 const int len = strlen(title) + 1;
272 char *wmclass = (char *)malloc(sizeof(char) * len);
273 memcpy(wmclass, title, len * sizeof(char));
274 xclasshint->res_name = wmclass;
275 xclasshint->res_class = wmclass;
276 XSetClassHint(display_, window_, xclasshint);
277 free(wmclass);
278#endif
279 XFree(xclasshint);
280 }
281
282 /* The basic for a good ICCCM "work" */
283 if (system_->atom_.WM_PROTOCOLS) {
284 Atom atoms[2];
285 int natom = 0;
286
287 if (system_->atom_.WM_DELETE_WINDOW) {
288 atoms[natom] = system_->atom_.WM_DELETE_WINDOW;
289 natom++;
290 }
291
292 if (system_->atom_.WM_TAKE_FOCUS && system_->window_focus_) {
293 atoms[natom] = system_->atom_.WM_TAKE_FOCUS;
294 natom++;
295 }
296
297 if (natom) {
298 // printf("Register atoms: %d\n", natom);
299 XSetWMProtocols(display_, window_, atoms, natom);
300 }
301 }
302
303 /* Set the window hints */
304 {
305 XWMHints *xwmhints = XAllocWMHints();
306 xwmhints->initial_state = NormalState;
307 xwmhints->input = (system_->window_focus_) ? True : False;
308 xwmhints->flags = InputHint | StateHint;
309 XSetWMHints(display, window_, xwmhints);
310 XFree(xwmhints);
311 }
312 /* Controlled via the `--no-window-frame` CLI argument and wont change at run-time.
313 * Set this once and never change. */
314 if (GHOST_ISystem::getUseWindowFrame() == false) {
315 motifShowWindowFrame(false);
316 }
317
318 /* set the icon */
319 {
320 Atom _NET_WM_ICON = XInternAtom(display_, "_NET_WM_ICON", False);
321 XChangeProperty(display_,
322 window_,
323 _NET_WM_ICON,
324 XA_CARDINAL,
325 32,
326 PropModeReplace,
327 (uchar *)BLENDER_ICONS_WM_X11,
328 ARRAY_SIZE(BLENDER_ICONS_WM_X11));
329 }
330
331 /* set the process ID (_NET_WM_PID) */
332 {
333 Atom _NET_WM_PID = XInternAtom(display_, "_NET_WM_PID", False);
334 pid_t pid = getpid();
335 XChangeProperty(
336 display_, window_, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, (uchar *)&pid, 1);
337 }
338
339 /* set the hostname (WM_CLIENT_MACHINE) */
340 {
341 char hostname[HOST_NAME_MAX];
342 char *text_array[1];
343 XTextProperty text_prop;
344
345 gethostname(hostname, sizeof(hostname));
346 hostname[sizeof(hostname) - 1] = '\0';
347 text_array[0] = hostname;
348
349 XStringListToTextProperty(text_array, 1, &text_prop);
350 XSetWMClientMachine(display_, window_, &text_prop);
351 XFree(text_prop.value);
352 }
353
354#ifdef WITH_X11_XINPUT
355 refreshXInputDevices();
356#endif
357
358 /* now set up the rendering context. */
360 valid_setup_ = true;
361 GHOST_PRINT("Created window\n");
362 }
363 else {
364#ifdef WITH_OPENGL_BACKEND
365 if (type == GHOST_kDrawingContextTypeOpenGL) {
366 const char *text =
367 "A graphics card and driver with support for OpenGL 4.3 or higher is "
368 "required.\n\nInstalling the latest driver for your graphics card might resolve the "
369 "issue.";
370 const char *help = "https://www.blender.org/download/requirements/";
371 system->showMessageBox(
372 "Unsupported hardware", text, "Learn More", "Close", help, GHOST_DialogError);
373 }
374#endif /* WITH_OPENGL_BACKEND */
375 XDestroyWindow(display_, window_);
376 window_ = None;
377 return;
378 }
379
380 setTitle(title);
381
382 if (exclusive && system->window_focus_) {
383 XMapRaised(display_, window_);
384 }
385 else {
386 XMapWindow(display_, window_);
387
388 if (!system->window_focus_) {
389 XLowerWindow(display_, window_);
390 }
391 }
392 GHOST_PRINT("Mapped window\n");
393
394 XFlush(display_);
395}
396
397#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
398static Bool destroyICCallback(XIC /*xic*/, XPointer ptr, XPointer /*data*/)
399{
400 GHOST_PRINT("XIM input context destroyed\n");
401
402 if (ptr) {
403 *(XIC *)ptr = nullptr;
404 }
405 /* Ignored by X11. */
406 return True;
407}
408
409bool GHOST_WindowX11::createX11_XIC()
410{
411 XIM xim = system_->getX11_XIM();
412 if (!xim) {
413 return false;
414 }
415
416 XICCallback destroy;
417 destroy.callback = (XICProc)destroyICCallback;
418 destroy.client_data = (XPointer)&xic_;
419 xic_ = XCreateIC(xim,
420 XNClientWindow,
421 window_,
422 XNFocusWindow,
423 window_,
424 XNInputStyle,
425 XIMPreeditNothing | XIMStatusNothing,
426 XNResourceName,
427 GHOST_X11_RES_NAME,
428 XNResourceClass,
429 GHOST_X11_RES_CLASS,
430 XNDestroyCallback,
431 &destroy,
432 nullptr);
433 if (!xic_) {
434 return false;
435 }
436
437 ulong fevent;
438 XGetICValues(xic_, XNFilterEvents, &fevent, nullptr);
439 XSelectInput(display_,
440 window_,
441 ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
442 EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask |
443 PointerMotionMask | FocusChangeMask | PropertyChangeMask | KeymapStateMask |
444 fevent);
445 return true;
446}
447#endif
448
449#ifdef WITH_X11_XINPUT
450void GHOST_WindowX11::refreshXInputDevices()
451{
452 if (system_->xinput_version_.present) {
453 std::vector<XEventClass> xevents;
454
455 for (GHOST_SystemX11::GHOST_TabletX11 &xtablet : system_->GetXTablets()) {
456 /* With modern XInput (XLIB 1.6.2 at least and/or EVDEV 2.9.0) and some 'no-name' tablets
457 * like 'UC-LOGIC Tablet WP5540U', we also need to 'select' ButtonPress for motion event,
458 * otherwise we do not get any tablet motion event once pen is pressed... See #43367.
459 */
460 XEventClass ev;
461
462 DeviceMotionNotify(xtablet.Device, xtablet.MotionEvent, ev);
463 if (ev) {
464 xevents.push_back(ev);
465 }
466 DeviceButtonPress(xtablet.Device, xtablet.PressEvent, ev);
467 if (ev) {
468 xevents.push_back(ev);
469 }
470 ProximityIn(xtablet.Device, xtablet.ProxInEvent, ev);
471 if (ev) {
472 xevents.push_back(ev);
473 }
474 ProximityOut(xtablet.Device, xtablet.ProxOutEvent, ev);
475 if (ev) {
476 xevents.push_back(ev);
477 }
478 }
479
480 XSelectExtensionEvent(display_, window_, xevents.data(), int(xevents.size()));
481 }
482}
483
484#endif /* WITH_X11_XINPUT */
485
487{
488 return window_;
489}
490
492{
493 return GHOST_Window::getValid() && valid_setup_;
494}
495
496void GHOST_WindowX11::setTitle(const char *title)
497{
498 Atom name = XInternAtom(display_, "_NET_WM_NAME", 0);
499 Atom utf8str = XInternAtom(display_, "UTF8_STRING", 0);
500 XChangeProperty(
501 display_, window_, name, utf8str, 8, PropModeReplace, (const uchar *)title, strlen(title));
502
503 /* This should convert to valid x11 string
504 * and getTitle would need matching change */
505 XStoreName(display_, window_, title);
506
507 XFlush(display_);
508}
509
510std::string GHOST_WindowX11::getTitle() const
511{
512 char *name = nullptr;
513
514 XFetchName(display_, window_, &name);
515 std::string title = name ? name : "untitled";
516 XFree(name);
517 return title;
518}
519
521{
522 /* Getting the window bounds under X11 is not
523 * really supported (nor should it be desired). */
524 getClientBounds(bounds);
525}
526
528{
529 Window root_return;
530 int x_return, y_return;
531 uint w_return, h_return, border_w_return, depth_return;
532 int32_t screen_x, screen_y;
533
534 XGetGeometry(display_,
535 window_,
536 &root_return,
537 &x_return,
538 &y_return,
539 &w_return,
540 &h_return,
541 &border_w_return,
542 &depth_return);
543
544 clientToScreen(0, 0, screen_x, screen_y);
545
546 bounds.l_ = screen_x;
547 bounds.r_ = bounds.l_ + w_return;
548 bounds.t_ = screen_y;
549 bounds.b_ = bounds.t_ + h_return;
550}
551
553{
554 XWindowChanges values;
555 uint value_mask = CWWidth;
556 values.width = width;
557 XConfigureWindow(display_, window_, value_mask, &values);
558
559 return GHOST_kSuccess;
560}
561
563{
564 XWindowChanges values;
565 uint value_mask = CWHeight;
566 values.height = height;
567 XConfigureWindow(display_, window_, value_mask, &values);
568 return GHOST_kSuccess;
569}
570
571GHOST_TSuccess GHOST_WindowX11::setClientSize(uint32_t width, uint32_t height)
572{
573 XWindowChanges values;
574 uint value_mask = CWWidth | CWHeight;
575 values.width = width;
576 values.height = height;
577 XConfigureWindow(display_, window_, value_mask, &values);
578 return GHOST_kSuccess;
579}
580
582{
583 int ax, ay;
584 Window temp;
585
586 /* Use (0, 0) instead of (inX, inY) to work around overflow of signed int16 in
587 * the implementation of this function. */
588 XTranslateCoordinates(
589 display_, RootWindow(display_, visual_info_->screen), window_, 0, 0, &ax, &ay, &temp);
590 outX = ax + inX;
591 outY = ay + inY;
592}
593
595{
596 int ax, ay;
597 Window temp;
598
599 XTranslateCoordinates(
600 display_, window_, RootWindow(display_, visual_info_->screen), inX, inY, &ax, &ay, &temp);
601 outX = ax;
602 outY = ay;
603}
604
606{
607
608 Atom atom_window_type = XInternAtom(display_, "_NET_WM_WINDOW_TYPE", False);
609 Atom atom_dialog = XInternAtom(display_, "_NET_WM_WINDOW_TYPE_DIALOG", False);
610 MotifWmHints hints = {0};
611
612 XChangeProperty(
613 display_, window_, atom_window_type, XA_ATOM, 32, PropModeReplace, (uchar *)&atom_dialog, 1);
614 XSetTransientForHint(display_, window_, parent_window->window_);
615
616 /* Disable minimizing of the window for now.
617 * Actually, most window managers disable minimizing and maximizing for dialogs, ignoring this.
618 * Leaving it here anyway in the hope it brings back maximizing on some window managers at least,
619 * we'd preferably have it even for dialog windows (e.g. file browser). */
623 XChangeProperty(display_,
624 window_,
625 system_->atom_._MOTIF_WM_HINTS,
626 system_->atom_._MOTIF_WM_HINTS,
627 32,
628 PropModeReplace,
629 (uchar *)&hints,
630 4);
631
632 return GHOST_kSuccess;
633}
634
635void GHOST_WindowX11::icccmSetState(int state)
636{
637 XEvent xev;
638
639 if (state != IconicState) {
640 return;
641 }
642
643 xev.xclient.type = ClientMessage;
644 xev.xclient.serial = 0;
645 xev.xclient.send_event = True;
646 xev.xclient.display = display_;
647 xev.xclient.window = window_;
648 xev.xclient.format = 32;
649 xev.xclient.message_type = system_->atom_.WM_CHANGE_STATE;
650 xev.xclient.data.l[0] = state;
651 XSendEvent(display_,
652 RootWindow(display_, visual_info_->screen),
653 False,
654 SubstructureNotifyMask | SubstructureRedirectMask,
655 &xev);
656}
657
658int GHOST_WindowX11::icccmGetState() const
659{
660 struct {
661 CARD32 state;
662 XID icon;
663 } *prop_ret;
664 ulong bytes_after, num_ret;
665 Atom type_ret;
666 int ret, format_ret;
667 CARD32 st;
668
669 prop_ret = nullptr;
670 ret = XGetWindowProperty(display_,
671 window_,
672 system_->atom_.WM_STATE,
673 0,
674 2,
675 False,
676 system_->atom_.WM_STATE,
677 &type_ret,
678 &format_ret,
679 &num_ret,
680 &bytes_after,
681 ((uchar **)&prop_ret));
682 if ((ret == Success) && (prop_ret != nullptr) && (num_ret == 2)) {
683 st = prop_ret->state;
684 }
685 else {
686 st = NormalState;
687 }
688
689 if (prop_ret) {
690 XFree(prop_ret);
691 }
692
693 return st;
694}
695
696void GHOST_WindowX11::netwmMaximized(bool set)
697{
698 XEvent xev;
699
700 xev.xclient.type = ClientMessage;
701 xev.xclient.serial = 0;
702 xev.xclient.send_event = True;
703 xev.xclient.window = window_;
704 xev.xclient.message_type = system_->atom_._NET_WM_STATE;
705 xev.xclient.format = 32;
706
707 if (set == True) {
708 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
709 }
710 else {
711 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
712 }
713
714 xev.xclient.data.l[1] = system_->atom_._NET_WM_STATE_MAXIMIZED_HORZ;
715 xev.xclient.data.l[2] = system_->atom_._NET_WM_STATE_MAXIMIZED_VERT;
716 xev.xclient.data.l[3] = 0;
717 xev.xclient.data.l[4] = 0;
718 XSendEvent(display_,
719 RootWindow(display_, visual_info_->screen),
720 False,
721 SubstructureRedirectMask | SubstructureNotifyMask,
722 &xev);
723}
724
725bool GHOST_WindowX11::netwmIsMaximized() const
726{
727 Atom *prop_ret;
728 ulong bytes_after, num_ret, i;
729 Atom type_ret;
730 bool st;
731 int format_ret, ret, count;
732
733 prop_ret = nullptr;
734 st = False;
735 ret = XGetWindowProperty(display_,
736 window_,
737 system_->atom_._NET_WM_STATE,
738 0,
739 INT_MAX,
740 False,
741 XA_ATOM,
742 &type_ret,
743 &format_ret,
744 &num_ret,
745 &bytes_after,
746 (uchar **)&prop_ret);
747 if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
748 count = 0;
749 for (i = 0; i < num_ret; i++) {
750 if (prop_ret[i] == system_->atom_._NET_WM_STATE_MAXIMIZED_HORZ) {
751 count++;
752 }
753 if (prop_ret[i] == system_->atom_._NET_WM_STATE_MAXIMIZED_VERT) {
754 count++;
755 }
756 if (count == 2) {
757 st = True;
758 break;
759 }
760 }
761 }
762
763 if (prop_ret) {
764 XFree(prop_ret);
765 }
766 return st;
767}
768
769void GHOST_WindowX11::netwmFullScreen(bool set)
770{
771 XEvent xev;
772
773 xev.xclient.type = ClientMessage;
774 xev.xclient.serial = 0;
775 xev.xclient.send_event = True;
776 xev.xclient.window = window_;
777 xev.xclient.message_type = system_->atom_._NET_WM_STATE;
778 xev.xclient.format = 32;
779
780 if (set == True) {
781 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
782 }
783 else {
784 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
785 }
786
787 xev.xclient.data.l[1] = system_->atom_._NET_WM_STATE_FULLSCREEN;
788 xev.xclient.data.l[2] = 0;
789 xev.xclient.data.l[3] = 0;
790 xev.xclient.data.l[4] = 0;
791 XSendEvent(display_,
792 RootWindow(display_, visual_info_->screen),
793 False,
794 SubstructureRedirectMask | SubstructureNotifyMask,
795 &xev);
796}
797
798bool GHOST_WindowX11::netwmIsFullScreen() const
799{
800 Atom *prop_ret;
801 ulong bytes_after, num_ret, i;
802 Atom type_ret;
803 bool st;
804 int format_ret, ret;
805
806 prop_ret = nullptr;
807 st = False;
808 ret = XGetWindowProperty(display_,
809 window_,
810 system_->atom_._NET_WM_STATE,
811 0,
812 INT_MAX,
813 False,
814 XA_ATOM,
815 &type_ret,
816 &format_ret,
817 &num_ret,
818 &bytes_after,
819 (uchar **)&prop_ret);
820 if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
821 for (i = 0; i < num_ret; i++) {
822 if (prop_ret[i] == system_->atom_._NET_WM_STATE_FULLSCREEN) {
823 st = True;
824 break;
825 }
826 }
827 }
828
829 if (prop_ret) {
830 XFree(prop_ret);
831 }
832 return st;
833}
834
835void GHOST_WindowX11::motifShowWindowFrame(bool set)
836{
837 MotifWmHints hints;
838
840 if (set == false) {
841 hints.decorations = 0;
842 }
843 else {
845 "Only allowed when the window frame is shown.");
846 hints.decorations = 1;
847 }
848
849 XChangeProperty(display_,
850 window_,
851 system_->atom_._MOTIF_WM_HINTS,
852 system_->atom_._MOTIF_WM_HINTS,
853 32,
854 PropModeReplace,
855 (uchar *)&hints,
856 4);
857}
858
859bool GHOST_WindowX11::motifIsShowWindowFrame() const
860{
861 MotifWmHints *prop_ret;
862 ulong bytes_after, num_ret;
863 Atom type_ret;
864 bool state;
865 int format_ret, st;
866
867 prop_ret = nullptr;
868 state = False;
869 st = XGetWindowProperty(display_,
870 window_,
871 system_->atom_._MOTIF_WM_HINTS,
872 0,
873 INT_MAX,
874 False,
875 system_->atom_._MOTIF_WM_HINTS,
876 &type_ret,
877 &format_ret,
878 &num_ret,
879 &bytes_after,
880 (uchar **)&prop_ret);
881 if ((st == Success) && prop_ret) {
882 if (prop_ret->flags & MWM_HINTS_DECORATIONS) {
883 if (!prop_ret->decorations) {
884 state = True;
885 }
886 }
887 }
888
889 if (prop_ret) {
890 XFree(prop_ret);
891 }
892 return state;
893}
894
895void GHOST_WindowX11::motifFullScreen(bool set)
896{
897 if (set == true || (GHOST_ISystem::getUseWindowFrame() == false)) {
898 motifShowWindowFrame(false);
899 }
900 else {
901 motifShowWindowFrame(true);
902 }
903}
904
905bool GHOST_WindowX11::motifIsFullScreen() const
906{
907 /* When false, the decorations can't be used to detect full-screen. */
908 if (GHOST_ISystem::getUseWindowFrame() == false) {
909 return false;
910 }
911 return motifIsShowWindowFrame();
912}
913
915{
916 GHOST_TWindowState state_ret;
917 int state;
918
919 state_ret = GHOST_kWindowStateNormal;
920 state = icccmGetState();
921 /*
922 * In the Iconic and Withdrawn state, the window
923 * is unmapped, so only need return a Minimized state.
924 */
925 if (ELEM(state, IconicState, WithdrawnState)) {
926 state_ret = GHOST_kWindowStateMinimized;
927 }
928 else if (netwmIsFullScreen() == True) {
930 }
931 else if (motifIsFullScreen() == True) {
933 }
934 else if (netwmIsMaximized() == True) {
935 state_ret = GHOST_kWindowStateMaximized;
936 }
937 return state_ret;
938}
939
941{
942 GHOST_TWindowState cur_state;
943 bool is_max, is_full, is_motif_full;
944
945 cur_state = getState();
946 if (state == int(cur_state)) {
947 return GHOST_kSuccess;
948 }
949
950 if (cur_state != GHOST_kWindowStateMinimized) {
951 /*
952 * The window don't have this property's
953 * if it's not mapped.
954 */
955 is_max = netwmIsMaximized();
956 is_full = netwmIsFullScreen();
957 }
958 else {
959 is_max = False;
960 is_full = False;
961 }
962
963 is_motif_full = motifIsFullScreen();
964
966 state = normal_state_;
967 }
968
970 if (is_max == True) {
971 netwmMaximized(False);
972 }
973 if (is_full == True) {
974 netwmFullScreen(False);
975 }
976 if (is_motif_full == True) {
977 motifFullScreen(False);
978 }
979 icccmSetState(NormalState);
980 return GHOST_kSuccess;
981 }
982
984 /*
985 * We can't change to full screen if the window
986 * isn't mapped.
987 */
988 if (cur_state == GHOST_kWindowStateMinimized) {
989 return GHOST_kFailure;
990 }
991
992 normal_state_ = cur_state;
993
994 if (is_max == True) {
995 netwmMaximized(False);
996 }
997 if (is_full == False) {
998 netwmFullScreen(True);
999 }
1000 if (is_motif_full == False) {
1001 motifFullScreen(True);
1002 }
1003 return GHOST_kSuccess;
1004 }
1005
1007 /*
1008 * We can't change to Maximized if the window
1009 * isn't mapped.
1010 */
1011 if (cur_state == GHOST_kWindowStateMinimized) {
1012 return GHOST_kFailure;
1013 }
1014
1015 if (is_full == True) {
1016 netwmFullScreen(False);
1017 }
1018 if (is_motif_full == True) {
1019 motifFullScreen(False);
1020 }
1021 if (is_max == False) {
1022 netwmMaximized(True);
1023 }
1024 return GHOST_kSuccess;
1025 }
1026
1028 /*
1029 * The window manager need save the current state of
1030 * the window (maximized, full screen, etc).
1031 */
1032 icccmSetState(IconicState);
1033 return GHOST_kSuccess;
1034 }
1035
1036 return GHOST_kFailure;
1037}
1038
1040{
1041 if (order == GHOST_kWindowOrderTop) {
1042 XWindowAttributes attr;
1043 Atom atom;
1044
1045 /* We use both #XRaiseWindow and #_NET_ACTIVE_WINDOW, since some
1046 * window managers ignore the former (e.g. KWIN from KDE) and others
1047 * don't implement the latter (e.g. FLUXBOX before 0.9.9). */
1048
1049 XRaiseWindow(display_, window_);
1050
1051 atom = XInternAtom(display_, "_NET_ACTIVE_WINDOW", True);
1052
1053 if (atom != None) {
1054 Window root;
1055 XEvent xev;
1056 long eventmask;
1057
1058 xev.xclient.type = ClientMessage;
1059 xev.xclient.serial = 0;
1060 xev.xclient.send_event = True;
1061 xev.xclient.window = window_;
1062 xev.xclient.message_type = atom;
1063
1064 xev.xclient.format = 32;
1065 xev.xclient.data.l[0] = 1;
1066 xev.xclient.data.l[1] = CurrentTime;
1067 xev.xclient.data.l[2] = window_;
1068 xev.xclient.data.l[3] = 0;
1069 xev.xclient.data.l[4] = 0;
1070
1071 root = RootWindow(display_, visual_info_->screen);
1072 eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
1073
1074 XSendEvent(display_, root, False, eventmask, &xev);
1075 }
1076
1077 XGetWindowAttributes(display_, window_, &attr);
1078
1079 /* Minimized windows give bad match error. */
1080 if (attr.map_state == IsViewable) {
1081 XSetInputFocus(display_, window_, RevertToPointerRoot, CurrentTime);
1082 }
1083 XFlush(display_);
1084 }
1085 else if (order == GHOST_kWindowOrderBottom) {
1086 XLowerWindow(display_, window_);
1087 XFlush(display_);
1088 }
1089 else {
1090 return GHOST_kFailure;
1091 }
1092
1093 return GHOST_kSuccess;
1094}
1095
1097{
1098 Atom atom_window_type = XInternAtom(display_, "_NET_WM_WINDOW_TYPE", False);
1099 Atom atom_dialog = XInternAtom(display_, "_NET_WM_WINDOW_TYPE_DIALOG", False);
1100
1101 Atom *prop_ret;
1102 ulong bytes_after, num_ret;
1103 Atom type_ret;
1104 bool st;
1105 int format_ret, ret;
1106
1107 prop_ret = nullptr;
1108 st = False;
1109 ret = XGetWindowProperty(display_,
1110 window_,
1111 atom_window_type,
1112 0,
1113 INT_MAX,
1114 False,
1115 XA_ATOM,
1116 &type_ret,
1117 &format_ret,
1118 &num_ret,
1119 &bytes_after,
1120 (uchar **)&prop_ret);
1121 if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
1122 if (prop_ret[0] == atom_dialog) {
1123 st = True;
1124 }
1125 }
1126
1127 if (prop_ret) {
1128 XFree(prop_ret);
1129 }
1130
1131 return st;
1132}
1133
1135{
1136 /* So the idea of this function is to generate an expose event
1137 * for the window.
1138 * Unfortunately X does not handle expose events for you and
1139 * it is the client's job to refresh the dirty part of the window.
1140 * We need to queue up invalidate calls and generate GHOST events
1141 * for them in the system.
1142 *
1143 * We implement this by setting a boolean in this class to concatenate
1144 * all such calls into a single event for this window.
1145 *
1146 * At the same time we queue the dirty windows in the system class
1147 * and generate events for them at the next processEvents call. */
1148
1149 if (invalid_window_ == false) {
1150 system_->addDirtyWindow(this);
1151 invalid_window_ = true;
1152 }
1153
1154 return GHOST_kSuccess;
1155}
1156
1161
1163{
1164 invalid_window_ = false;
1165}
1166
1168{
1169 std::map<uint, Cursor>::iterator it = standard_cursors_.begin();
1170 for (; it != standard_cursors_.end(); ++it) {
1171 XFreeCursor(display_, it->second);
1172 }
1173
1174 if (empty_cursor_) {
1175 XFreeCursor(display_, empty_cursor_);
1176 }
1177 if (custom_cursor_) {
1178 XFreeCursor(display_, custom_cursor_);
1179 }
1180
1181 if (valid_setup_) {
1182 static Atom Primary_atom, Clipboard_atom;
1183 Window p_owner, c_owner;
1184 /* Change the owner of the Atoms to None if we are the owner. */
1185 Primary_atom = XInternAtom(display_, "PRIMARY", False);
1186 Clipboard_atom = XInternAtom(display_, "CLIPBOARD", False);
1187
1188 p_owner = XGetSelectionOwner(display_, Primary_atom);
1189 c_owner = XGetSelectionOwner(display_, Clipboard_atom);
1190
1191 if (p_owner == window_) {
1192 XSetSelectionOwner(display_, Primary_atom, None, CurrentTime);
1193 }
1194 if (c_owner == window_) {
1195 XSetSelectionOwner(display_, Clipboard_atom, None, CurrentTime);
1196 }
1197 }
1198
1199 if (visual_info_) {
1200 XFree(visual_info_);
1201 }
1202
1203#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
1204 if (xic_) {
1205 XDestroyIC(xic_);
1206 }
1207#endif
1208
1209#ifdef WITH_XDND
1210 delete drop_target_;
1211#endif
1212
1214
1215 if (valid_setup_) {
1216 XDestroyWindow(display_, window_);
1217 }
1218}
1219
1221{
1222 switch (type) {
1223#ifdef WITH_VULKAN_BACKEND
1224 case GHOST_kDrawingContextTypeVulkan: {
1226 GHOST_kVulkanPlatformX11,
1227 window_,
1228 display_,
1229 nullptr,
1230 nullptr,
1231 nullptr,
1232 1,
1233 1,
1234 preferred_device_,
1235 &hdr_info_);
1236 if (context->initializeDrawingContext()) {
1237 return context;
1238 }
1239 delete context;
1240 return nullptr;
1241 }
1242#endif
1243
1244#ifdef WITH_OPENGL_BACKEND
1245 case GHOST_kDrawingContextTypeOpenGL: {
1246# ifdef USE_EGL
1247 /* Try to initialize an EGL context. */
1248 for (int minor = 6; minor >= 3; --minor) {
1250 this->system_,
1252 EGLNativeWindowType(window_),
1253 EGLNativeDisplayType(display_),
1254 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
1255 4,
1256 minor,
1258 (want_context_params_.is_debug ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
1260 EGL_OPENGL_API);
1261 if (context->initializeDrawingContext()) {
1262 return context;
1263 }
1264 delete context;
1265 }
1266 /* EGL initialization failed, try to fall back to a GLX context. */
1267# endif
1268
1269 for (int minor = 6; minor >= 3; --minor) {
1270 GHOST_Context *context = new GHOST_ContextGLX(
1272 window_,
1273 display_,
1274 (GLXFBConfig)fbconfig_,
1275 GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
1276 4,
1277 minor,
1279 (want_context_params_.is_debug ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
1281 if (context->initializeDrawingContext()) {
1282 return context;
1283 }
1284 delete context;
1285 }
1286 return nullptr;
1287 }
1288#endif
1289
1290 default:
1291 /* Unsupported backend. */
1292 return nullptr;
1293 }
1294}
1295
1296GHOST_TSuccess GHOST_WindowX11::getStandardCursor(GHOST_TStandardCursor g_cursor, Cursor &xcursor)
1297{
1298 uint xcursor_id;
1299
1300 switch (g_cursor) {
1302 xcursor_id = XC_question_arrow;
1303 break;
1305 xcursor_id = XC_watch;
1306 break;
1308 xcursor_id = XC_xterm;
1309 break;
1311 xcursor_id = XC_crosshair;
1312 break;
1314 xcursor_id = XC_sb_v_double_arrow;
1315 break;
1317 xcursor_id = XC_sb_h_double_arrow;
1318 break;
1320 xcursor_id = XC_top_side;
1321 break;
1323 xcursor_id = XC_bottom_side;
1324 break;
1326 xcursor_id = XC_left_side;
1327 break;
1329 xcursor_id = XC_right_side;
1330 break;
1332 xcursor_id = XC_top_left_corner;
1333 break;
1335 xcursor_id = XC_top_right_corner;
1336 break;
1338 xcursor_id = XC_bottom_right_corner;
1339 break;
1341 xcursor_id = XC_bottom_left_corner;
1342 break;
1344 xcursor = None;
1345 return GHOST_kSuccess;
1346 default:
1347 xcursor = None;
1348 return GHOST_kFailure;
1349 }
1350
1351 xcursor = standard_cursors_[xcursor_id];
1352
1353 if (!xcursor) {
1354 xcursor = XCreateFontCursor(display_, xcursor_id);
1355
1356 standard_cursors_[xcursor_id] = xcursor;
1357 }
1358
1359 return GHOST_kSuccess;
1360}
1361
1362Cursor GHOST_WindowX11::getEmptyCursor()
1363{
1364 if (!empty_cursor_) {
1365 Pixmap blank;
1366 XColor dummy = {0};
1367 char data[1] = {0};
1368
1369 /* make a blank cursor */
1370 blank = XCreateBitmapFromData(
1371 display_, RootWindow(display_, visual_info_->screen), data, 1, 1);
1372
1373 empty_cursor_ = XCreatePixmapCursor(display_, blank, blank, &dummy, &dummy, 0, 0);
1374 XFreePixmap(display_, blank);
1375 }
1376
1377 return empty_cursor_;
1378}
1379
1381{
1382 Cursor xcursor;
1383
1384 if (visible) {
1385 if (visible_cursor_) {
1386 xcursor = visible_cursor_;
1387 }
1388 else if (getStandardCursor(getCursorShape(), xcursor) == GHOST_kFailure) {
1389 getStandardCursor(getCursorShape(), xcursor);
1390 }
1391 }
1392 else {
1393 xcursor = getEmptyCursor();
1394 }
1395
1396 XDefineCursor(display_, window_, xcursor);
1397 XFlush(display_);
1398
1399 return GHOST_kSuccess;
1400}
1401
1403{
1404 if (mode != GHOST_kGrabDisable) {
1405 if (mode != GHOST_kGrabNormal) {
1406 system_->getCursorPosition(UNPACK2(cursor_grab_init_pos_));
1407 setCursorGrabAccum(0, 0);
1408
1409 if (mode == GHOST_kGrabHide) {
1411 }
1412 }
1413#ifdef GHOST_X11_GRAB
1414 XGrabPointer(display_,
1415 window_,
1416 False,
1417 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
1418 GrabModeAsync,
1419 GrabModeAsync,
1420 None,
1421 None,
1422 CurrentTime);
1423#endif
1424 }
1425 else {
1427 system_->setCursorPosition(UNPACK2(cursor_grab_init_pos_));
1428 }
1429
1431 /* use to generate a mouse move event, otherwise the last event
1432 * blender gets can be outside the screen causing menus not to show
1433 * properly unless the user moves the mouse */
1434
1435#if defined(WITH_X11_XINPUT) && defined(USE_X11_XINPUT_WARP)
1436 if ((system_->xinput_version_.present) && (system_->xinput_version_.major_version >= 2)) {
1437 int device_id;
1438 if (XIGetClientPointer(display_, None, &device_id) != False) {
1439 XIWarpPointer(display_, device_id, None, None, 0, 0, 0, 0, 0, 0);
1440 }
1441 }
1442 else
1443#endif
1444 {
1445 XWarpPointer(display_, None, None, 0, 0, 0, 0, 0, 0);
1446 }
1447 }
1448
1449 /* Perform this last so to workaround XWayland bug, see: #53004. */
1452 }
1453
1454 /* Almost works without but important
1455 * otherwise the mouse GHOST location can be incorrect on exit. */
1456 setCursorGrabAccum(0, 0);
1457 cursor_grab_bounds_.l_ = cursor_grab_bounds_.r_ = -1; /* disable */
1458#ifdef GHOST_X11_GRAB
1459 XUngrabPointer(display_, CurrentTime);
1460#endif
1461 }
1462
1463 XFlush(display_);
1464
1465 return GHOST_kSuccess;
1466}
1467
1469{
1470 Cursor xcursor;
1471 if (getStandardCursor(shape, xcursor) == GHOST_kFailure) {
1472 getStandardCursor(GHOST_kStandardCursorDefault, xcursor);
1473 }
1474
1475 visible_cursor_ = xcursor;
1476
1477 XDefineCursor(display_, window_, xcursor);
1478 XFlush(display_);
1479
1480 return GHOST_kSuccess;
1481}
1482
1484{
1485 Cursor xcursor;
1486 return getStandardCursor(shape, xcursor);
1487}
1488
1490 const uint8_t *mask,
1491 const int size[2],
1492 const int hot_spot[2],
1493 bool /*can_invert_color*/)
1494{
1495 Colormap colormap = DefaultColormap(display_, visual_info_->screen);
1496 Pixmap bitmap_pix, mask_pix;
1497 XColor fg, bg;
1498
1499 if (XAllocNamedColor(display_, colormap, "White", &fg, &fg) == 0) {
1500 return GHOST_kFailure;
1501 }
1502 if (XAllocNamedColor(display_, colormap, "Black", &bg, &bg) == 0) {
1503 return GHOST_kFailure;
1504 }
1505
1506 if (custom_cursor_) {
1507 XFreeCursor(display_, custom_cursor_);
1508 }
1509
1510 bitmap_pix = XCreateBitmapFromData(display_, window_, (char *)bitmap, size[0], size[1]);
1511 mask_pix = XCreateBitmapFromData(display_, window_, (char *)mask, size[0], size[1]);
1512
1513 custom_cursor_ = XCreatePixmapCursor(
1514 display_, bitmap_pix, mask_pix, &fg, &bg, hot_spot[0], hot_spot[1]);
1515 XDefineCursor(display_, window_, custom_cursor_);
1516 XFlush(display_);
1517
1518 visible_cursor_ = custom_cursor_;
1519
1520 XFreePixmap(display_, bitmap_pix);
1521 XFreePixmap(display_, mask_pix);
1522
1523 XFreeColors(display_, colormap, &fg.pixel, 1, 0L);
1524 XFreeColors(display_, colormap, &bg.pixel, 1, 0L);
1525
1526 return GHOST_kSuccess;
1527}
1528
1530{
1531 /* Early out if use of DPI scale is disabled. */
1532 if (!system_->native_pixel_) {
1533 return 96;
1534 }
1535
1536 /* Try to read DPI setting set using xrdb */
1537 char *resMan = XResourceManagerString(display_);
1538 if (resMan) {
1539 XrmDatabase xrdb = XrmGetStringDatabase(resMan);
1540 if (xrdb) {
1541 int dpi = -1;
1542 char *type = nullptr;
1543 XrmValue val;
1544
1545 int success = XrmGetResource(xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
1546 if (success && type) {
1547 if (STREQ(type, "String")) {
1548 dpi = atoi((const char *)val.addr);
1549 }
1550 }
1551 XrmDestroyDatabase(xrdb);
1552
1553 if (dpi != -1) {
1554 return dpi;
1555 }
1556 }
1557 }
1558
1559 /* Fall back to calculating DPI using X reported DPI, set using `xrandr --dpi`. */
1560 XWindowAttributes attr;
1561 if (!XGetWindowAttributes(display_, window_, &attr)) {
1562 /* Failed to get window attributes, return X11 default DPI */
1563 return 96;
1564 }
1565
1566 Screen *screen = attr.screen;
1567 int pixelWidth = WidthOfScreen(screen);
1568 int pixelHeight = HeightOfScreen(screen);
1569 int mmWidth = WidthMMOfScreen(screen);
1570 int mmHeight = HeightMMOfScreen(screen);
1571
1572 double pixelDiagonal = sqrt((pixelWidth * pixelWidth) + (pixelHeight * pixelHeight));
1573 double mmDiagonal = sqrt((mmWidth * mmWidth) + (mmHeight * mmHeight));
1574 float inchDiagonal = mmDiagonal * 0.039f;
1575 int dpi = pixelDiagonal / inchDiagonal;
1576 return dpi;
1577}
1578
1580{
1581 return GHOST_kFailure;
1582}
1583
#define GHOST_OPENGL_EGL_CONTEXT_FLAGS
#define GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_GLX_CONTEXT_FLAGS
#define Window
#define Display
#define GHOST_ASSERT(x, info)
#define GHOST_PRINT(x)
GHOST_TWindowState
@ GHOST_kWindowStateMinimized
@ GHOST_kWindowStateMaximized
@ GHOST_kWindowStateNormal
@ GHOST_kWindowStateFullScreen
GHOST_TStandardCursor
@ GHOST_kStandardCursorBottomLeftCorner
@ GHOST_kStandardCursorHelp
@ GHOST_kStandardCursorWait
@ GHOST_kStandardCursorTopSide
@ GHOST_kStandardCursorCrosshair
@ GHOST_kStandardCursorLeftRight
@ GHOST_kStandardCursorUpDown
@ GHOST_kStandardCursorBottomSide
@ GHOST_kStandardCursorTopLeftCorner
@ GHOST_kStandardCursorBottomRightCorner
@ GHOST_kStandardCursorDefault
@ GHOST_kStandardCursorRightSide
@ GHOST_kStandardCursorTopRightCorner
@ GHOST_kStandardCursorLeftSide
@ GHOST_kStandardCursorText
GHOST_TDrawingContextType
GHOST_TWindowOrder
@ GHOST_kWindowOrderTop
@ GHOST_kWindowOrderBottom
GHOST_TSuccess
@ GHOST_kFailure
@ GHOST_kSuccess
GHOST_TGrabCursorMode
@ GHOST_kGrabDisable
@ GHOST_kGrabHide
@ GHOST_kGrabNormal
@ GHOST_DialogError
#define _NET_WM_STATE_REMOVE
@ MWM_HINTS_DECORATIONS
@ MWM_HINTS_FUNCTIONS
@ MWM_FUNCTION_MINIMIZE
@ MWM_FUNCTION_RESIZE
@ MWM_FUNCTION_MAXIMIZE
@ MWM_FUNCTION_ALL
@ MWM_FUNCTION_MOVE
@ MWM_FUNCTION_CLOSE
#define HOST_NAME_MAX
#define _NET_WM_STATE_ADD
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
#define UNPACK2(a)
#define ELEM(...)
#define STREQ(a, b)
GHOST_ContextEGL(const GHOST_System *const system, const GHOST_ContextParams &context_params, EGLNativeWindowType nativeWindow, EGLNativeDisplayType nativeDisplay, EGLint contextProfileMask, EGLint contextMajorVersion, EGLint contextMinorVersion, EGLint contextFlags, EGLint contextResetNotificationStrategy, EGLenum api)
GHOST_ContextGLX(const GHOST_ContextParams &context_params, Window window, Display *display, GLXFBConfig fbconfig, int contextProfileMask, int contextMajorVersion, int contextMinorVersion, int contextFlags, int contextResetNotificationStrategy)
GHOST_ContextVK(const GHOST_ContextParams &context_params, GHOST_TVulkanPlatformType platform, Window window, Display *display, wl_surface *wayland_surface, wl_display *wayland_display, const GHOST_ContextVK_WindowInfo *wayland_window_info, int contextMajorVersion, int contextMinorVersion, const GHOST_GPUDevice &preferred_device, const GHOST_WindowHDRInfo *hdr_info_=nullptr)
GHOST_DropTargetX11(GHOST_WindowX11 *window, GHOST_SystemX11 *system)
static bool getUseWindowFrame()
int32_t t_
int32_t r_
int32_t b_
int32_t l_
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
GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type) override
GHOST_WindowX11(GHOST_SystemX11 *system, Display *display, const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_WindowX11 *parent_window, GHOST_TDrawingContextType type, const bool is_dialog, const GHOST_ContextParams &context_params, const bool exclusive, const GHOST_GPUDevice &preferred_device)
bool getValid() const override
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
GHOST_TSuccess setClientHeight(uint32_t height) override
void getWindowBounds(GHOST_Rect &bounds) const override
~GHOST_WindowX11() override
GHOST_TSuccess setState(GHOST_TWindowState state) override
GHOST_TSuccess endProgressBar() override
void getClientBounds(GHOST_Rect &bounds) const override
void setTitle(const char *title) override
std::string getTitle() const override
GHOST_TSuccess setClientWidth(uint32_t width) override
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override
GHOST_TSuccess setProgressBar(float progress) override
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape) override
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) override
GHOST_TSuccess setWindowCursorVisibility(bool visible) override
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
GHOST_TSuccess setWindowCustomCursorShape(const uint8_t *bitmap, const uint8_t *mask, const int size[2], const int hot_spot[2], bool can_invert_color) override
bool isDialog() const override
uint16_t getDPIHint() override
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override
GHOST_TSuccess invalidate() override
GHOST_TWindowState post_state_
GHOST_TSuccess setDialogHints(GHOST_WindowX11 *parent_window)
GHOST_TWindowState getState() const override
GHOST_ContextParams want_context_params_
void setCursorGrabAccum(int32_t x, int32_t y)
GHOST_TStandardCursor getCursorShape() const override
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) override
int32_t cursor_grab_init_pos_[2]
GHOST_TSuccess releaseNativeHandles()
bool getValid() const override
GHOST_Window(uint32_t width, uint32_t height, GHOST_TWindowState state, const GHOST_ContextParams &context_params, const bool exclusive=false)
GHOST_Rect cursor_grab_bounds_
GHOST_WindowHDRInfo hdr_info_
GHOST_TGrabCursorMode cursor_grab_
#define INT_MAX
#define sqrt
unsigned int uchar
if(state< num_states)
const int state
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
#define L
unsigned long ulong
Definition BKE_text.h:57
BMesh const char void * data