11 #include <X11/Xutil.h>
12 #include <X11/cursorfont.h>
14 # include <X11/extensions/Xrender.h>
28 # include <EGL/eglext.h>
34 #ifdef WITH_X11_XINPUT
35 # include <X11/extensions/XInput2.h>
39 #include <X11/Xresource.h>
76 # define HOST_NAME_MAX 64
87 #define _NET_WM_STATE_REMOVE 0
88 #define _NET_WM_STATE_ADD 1
93 static XVisualInfo *x11_visualinfo_from_egl(Display *display)
96 XVisualInfo vinfo_template;
97 vinfo_template.screen = DefaultScreen(display);
98 return XGetVisualInfo(display, VisualScreenMask, &vinfo_template, &num_visuals);
106 GLXFBConfig *fbconfig)
108 int glx_major, glx_minor, glx_version;
116 if (!glXQueryVersion(display, &glx_major, &glx_minor)) {
118 "%s:%d: X11 glXQueryVersion() failed, "
119 "verify working openGL system!\n",
125 glx_version = glx_major * 100 + glx_minor;
126 # ifndef WITH_X11_ALPHA
130 # ifdef WITH_X11_ALPHA
131 if (needAlpha && glx_version >= 103 &&
132 (glXChooseFBConfig || (glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddressARB(
133 (
const GLubyte *)
"glXChooseFBConfig")) !=
nullptr) &&
134 (glXGetVisualFromFBConfig ||
135 (glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddressARB(
136 (
const GLubyte *)
"glXGetVisualFromFBConfig")) !=
nullptr)) {
141 GLXFBConfig *fbconfigs = glXChooseFBConfig(
142 display, DefaultScreen(display), glx_attribs, &nbfbconfig);
146 if (nbfbconfig > 0) {
148 for (
int i = 0; i < nbfbconfig; i++) {
149 XVisualInfo *visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]);
155 XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual);
158 if (pict_format->direct.alphaMask <= 0)
162 *fbconfig = fbconfigs[i];
177 XVisualInfo *visual = glXChooseVisual(display, DefaultScreen(display), glx_attribs);
181 if (visual !=
nullptr) {
188 "%s:%d: X11 glXChooseVisual() failed, "
189 "verify working openGL system!\n",
208 const bool is_dialog,
209 const bool stereoVisual,
210 const bool exclusive,
211 const bool alphaBackground,
215 m_visualInfo(nullptr),
219 m_invalid_window(false),
220 m_empty_cursor(
None),
221 m_custom_cursor(
None),
222 m_visible_cursor(
None),
223 m_taskbar(
"blender.desktop"),
225 m_dropTarget(nullptr),
228 #
if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
231 m_valid_setup(false),
232 m_is_debug_context(is_debug)
236 m_visualInfo = x11_visualinfo_from_egl(m_display);
237 (
void)alphaBackground;
240 m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig);
244 XVisualInfo tmp = {
nullptr};
246 m_visualInfo = XGetVisualInfo(m_display, 0, &tmp, &n);
250 if (m_visualInfo ==
nullptr) {
251 fprintf(stderr,
"initial window could not find the GLX extension\n");
255 unsigned int xattributes_valuemask = 0;
257 XSetWindowAttributes xattributes;
258 memset(&xattributes, 0,
sizeof(xattributes));
260 xattributes_valuemask |= CWBorderPixel;
261 xattributes.border_pixel = 0;
265 xattributes_valuemask |= CWEventMask;
266 xattributes.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
267 EnterWindowMask | LeaveWindowMask | ButtonPressMask |
268 ButtonReleaseMask | PointerMotionMask | FocusChangeMask |
269 PropertyChangeMask | KeymapStateMask;
272 xattributes_valuemask |= CWOverrideRedirect;
273 xattributes.override_redirect = True;
276 xattributes_valuemask |= CWColormap;
277 xattributes.colormap = XCreateColormap(
278 m_display, RootWindow(m_display, m_visualInfo->screen), m_visualInfo->visual, AllocNone);
281 m_window = XCreateWindow(m_display,
282 RootWindow(m_display, m_visualInfo->screen),
290 m_visualInfo->visual,
291 xattributes_valuemask,
311 XChangeProperty(m_display,
317 (
unsigned char *)atoms,
341 if (is_dialog && parentWindow) {
348 XSizeHints *xsizehints = XAllocSizeHints();
349 xsizehints->flags = PPosition | PSize | PMinSize | PMaxSize;
350 xsizehints->x =
left;
352 xsizehints->width =
width;
353 xsizehints->height =
height;
354 xsizehints->min_width = 320;
355 xsizehints->min_height = 240;
356 xsizehints->max_width = 65535;
357 xsizehints->max_height = 65535;
358 XSetWMNormalHints(m_display, m_window, xsizehints);
364 XClassHint *xclasshint = XAllocClassHint();
365 const int len = strlen(title) + 1;
366 char *wmclass = (
char *)malloc(
sizeof(
char) *
len);
367 memcpy(wmclass, title,
len *
sizeof(
char));
368 xclasshint->res_name = wmclass;
369 xclasshint->res_class = wmclass;
370 XSetClassHint(m_display, m_window, xclasshint);
392 XSetWMProtocols(m_display, m_window, atoms, natom);
398 XWMHints *xwmhints = XAllocWMHints();
399 xwmhints->initial_state = NormalState;
401 xwmhints->flags = InputHint | StateHint;
402 XSetWMHints(display, m_window, xwmhints);
408 Atom _NET_WM_ICON = XInternAtom(m_display,
"_NET_WM_ICON", False);
409 XChangeProperty(m_display,
421 Atom _NET_WM_PID = XInternAtom(m_display,
"_NET_WM_PID", False);
422 pid_t pid = getpid();
423 XChangeProperty(m_display,
429 (
unsigned char *)&pid,
437 XTextProperty text_prop;
439 gethostname(hostname,
sizeof(hostname));
440 hostname[
sizeof(hostname) - 1] =
'\0';
441 text_array[0] = hostname;
443 XStringListToTextProperty(text_array, 1, &text_prop);
444 XSetWMClientMachine(m_display, m_window, &text_prop);
445 XFree(text_prop.value);
448 #ifdef WITH_X11_XINPUT
449 refreshXInputDevices();
454 m_valid_setup =
true;
461 XMapRaised(m_display, m_window);
464 XMapWindow(m_display, m_window);
467 XLowerWindow(m_display, m_window);
475 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
476 static Bool destroyICCallback(XIC , XPointer
ptr, XPointer )
481 *(XIC *)
ptr =
nullptr;
487 bool GHOST_WindowX11::createX11_XIC()
489 XIM xim = m_system->getX11_XIM();
494 destroy.callback = (XICProc)destroyICCallback;
495 destroy.client_data = (XPointer)&m_xic;
496 m_xic = XCreateIC(xim,
502 XIMPreeditNothing | XIMStatusNothing,
513 unsigned long fevent;
514 XGetICValues(m_xic, XNFilterEvents, &fevent,
nullptr);
515 XSelectInput(m_display,
517 ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
518 EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask |
519 PointerMotionMask | FocusChangeMask | PropertyChangeMask | KeymapStateMask |
525 #ifdef WITH_X11_XINPUT
526 void GHOST_WindowX11::refreshXInputDevices()
528 if (m_system->m_xinput_version.present) {
529 std::vector<XEventClass> xevents;
531 for (GHOST_SystemX11::GHOST_TabletX11 &xtablet : m_system->GetXTablets()) {
538 DeviceMotionNotify(xtablet.Device, xtablet.MotionEvent, ev);
540 xevents.push_back(ev);
541 DeviceButtonPress(xtablet.Device, xtablet.PressEvent, ev);
543 xevents.push_back(ev);
544 ProximityIn(xtablet.Device, xtablet.ProxInEvent, ev);
546 xevents.push_back(ev);
547 ProximityOut(xtablet.Device, xtablet.ProxOutEvent, ev);
549 xevents.push_back(ev);
552 XSelectExtensionEvent(m_display, m_window, xevents.data(), (
int)xevents.size());
570 Atom name = XInternAtom(m_display,
"_NET_WM_NAME", 0);
571 Atom utf8str = XInternAtom(m_display,
"UTF8_STRING", 0);
572 XChangeProperty(m_display,
578 (
const unsigned char *)title,
583 XStoreName(m_display, m_window, title);
590 char *name =
nullptr;
592 XFetchName(m_display, m_window, &name);
593 std::string title = name ? name :
"untitled";
608 int x_return, y_return;
609 unsigned int w_return, h_return, border_w_return, depth_return;
612 XGetGeometry(m_display,
632 XWindowChanges values;
633 unsigned int value_mask = CWWidth;
634 values.width =
width;
635 XConfigureWindow(m_display, m_window, value_mask, &values);
642 XWindowChanges values;
643 unsigned int value_mask = CWHeight;
645 XConfigureWindow(m_display, m_window, value_mask, &values);
651 XWindowChanges values;
652 unsigned int value_mask = CWWidth | CWHeight;
653 values.width =
width;
655 XConfigureWindow(m_display, m_window, value_mask, &values);
666 XTranslateCoordinates(
667 m_display, RootWindow(m_display, m_visualInfo->screen), m_window, 0, 0, &ax, &ay, &temp);
677 XTranslateCoordinates(
678 m_display, m_window, RootWindow(m_display, m_visualInfo->screen), inX, inY, &ax, &ay, &temp);
686 Atom atom_window_type = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE", False);
687 Atom atom_dialog = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE_DIALOG", False);
690 XChangeProperty(m_display,
696 (
unsigned char *)&atom_dialog,
698 XSetTransientForHint(m_display, m_window, parentWindow->m_window);
707 XChangeProperty(m_display,
713 (
unsigned char *)&hints,
719 void GHOST_WindowX11::icccmSetState(
int state)
723 if (
state != IconicState) {
727 xev.xclient.type = ClientMessage;
728 xev.xclient.serial = 0;
729 xev.xclient.send_event = True;
730 xev.xclient.display = m_display;
731 xev.xclient.window = m_window;
732 xev.xclient.format = 32;
734 xev.xclient.data.l[0] =
state;
735 XSendEvent(m_display,
736 RootWindow(m_display, m_visualInfo->screen),
738 SubstructureNotifyMask | SubstructureRedirectMask,
742 int GHOST_WindowX11::icccmGetState()
const
748 unsigned long bytes_after, num_ret;
754 ret = XGetWindowProperty(m_display,
765 ((
unsigned char **)&prop_ret));
766 if ((
ret == Success) && (prop_ret !=
nullptr) && (num_ret == 2)) {
767 st = prop_ret->state;
780 void GHOST_WindowX11::netwmMaximized(
bool set)
784 xev.xclient.type = ClientMessage;
785 xev.xclient.serial = 0;
786 xev.xclient.send_event = True;
787 xev.xclient.window = m_window;
789 xev.xclient.format = 32;
800 xev.xclient.data.l[3] = 0;
801 xev.xclient.data.l[4] = 0;
802 XSendEvent(m_display,
803 RootWindow(m_display, m_visualInfo->screen),
805 SubstructureRedirectMask | SubstructureNotifyMask,
809 bool GHOST_WindowX11::netwmIsMaximized()
const
812 unsigned long bytes_after, num_ret, i;
819 ret = XGetWindowProperty(m_display,
830 (
unsigned char **)&prop_ret);
831 if ((
ret == Success) && (prop_ret) && (format_ret == 32)) {
833 for (i = 0; i < num_ret; i++) {
853 void GHOST_WindowX11::netwmFullScreen(
bool set)
857 xev.xclient.type = ClientMessage;
858 xev.xclient.serial = 0;
859 xev.xclient.send_event = True;
860 xev.xclient.window = m_window;
862 xev.xclient.format = 32;
872 xev.xclient.data.l[2] = 0;
873 xev.xclient.data.l[3] = 0;
874 xev.xclient.data.l[4] = 0;
875 XSendEvent(m_display,
876 RootWindow(m_display, m_visualInfo->screen),
878 SubstructureRedirectMask | SubstructureNotifyMask,
882 bool GHOST_WindowX11::netwmIsFullScreen()
const
885 unsigned long bytes_after, num_ret, i;
892 ret = XGetWindowProperty(m_display,
903 (
unsigned char **)&prop_ret);
904 if ((
ret == Success) && (prop_ret) && (format_ret == 32)) {
905 for (i = 0; i < num_ret; i++) {
919 void GHOST_WindowX11::motifFullScreen(
bool set)
925 hints.decorations = 0;
928 hints.decorations = 1;
931 XChangeProperty(m_display,
937 (
unsigned char *)&hints,
941 bool GHOST_WindowX11::motifIsFullScreen()
const
944 unsigned long bytes_after, num_ret;
951 st = XGetWindowProperty(m_display,
962 (
unsigned char **)&prop_ret);
963 if ((
st == Success) && prop_ret) {
965 if (!prop_ret->decorations) {
983 state = icccmGetState();
988 if (
ELEM(
state, IconicState, WithdrawnState)) {
991 else if (netwmIsFullScreen() == True) {
994 else if (motifIsFullScreen() == True) {
997 else if (netwmIsMaximized() == True) {
1006 bool is_max, is_full, is_motif_full;
1009 if (
state == (
int)cur_state) {
1018 is_max = netwmIsMaximized();
1019 is_full = netwmIsFullScreen();
1026 is_motif_full = motifIsFullScreen();
1029 state = m_normal_state;
1033 if (is_max == True) {
1034 netwmMaximized(False);
1036 if (is_full == True) {
1037 netwmFullScreen(False);
1039 if (is_motif_full == True) {
1040 motifFullScreen(False);
1042 icccmSetState(NormalState);
1055 m_normal_state = cur_state;
1057 if (is_max == True) {
1058 netwmMaximized(False);
1060 if (is_full == False) {
1061 netwmFullScreen(True);
1063 if (is_motif_full == False) {
1064 motifFullScreen(True);
1078 if (is_full == True) {
1079 netwmFullScreen(False);
1081 if (is_motif_full == True) {
1082 motifFullScreen(False);
1084 if (is_max == False) {
1085 netwmMaximized(True);
1095 icccmSetState(IconicState);
1105 XWindowAttributes attr;
1112 XRaiseWindow(m_display, m_window);
1114 atom = XInternAtom(m_display,
"_NET_ACTIVE_WINDOW", True);
1121 xev.xclient.type = ClientMessage;
1122 xev.xclient.serial = 0;
1123 xev.xclient.send_event = True;
1124 xev.xclient.
window = m_window;
1125 xev.xclient.message_type = atom;
1127 xev.xclient.format = 32;
1128 xev.xclient.data.l[0] = 1;
1129 xev.xclient.data.l[1] = CurrentTime;
1130 xev.xclient.data.l[2] = m_window;
1131 xev.xclient.data.l[3] = 0;
1132 xev.xclient.data.l[4] = 0;
1134 root = RootWindow(m_display, m_visualInfo->screen);
1135 eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
1137 XSendEvent(m_display, root, False, eventmask, &xev);
1140 XGetWindowAttributes(m_display, m_window, &attr);
1143 if (attr.map_state == IsViewable) {
1144 XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
1149 XLowerWindow(m_display, m_window);
1161 Atom atom_window_type = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE", False);
1162 Atom atom_dialog = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE_DIALOG", False);
1165 unsigned long bytes_after, num_ret;
1168 int format_ret,
ret;
1172 ret = XGetWindowProperty(m_display,
1183 (
unsigned char **)&prop_ret);
1184 if ((
ret == Success) && (prop_ret) && (format_ret == 32)) {
1185 if (prop_ret[0] == atom_dialog) {
1212 if (m_invalid_window ==
false) {
1214 m_invalid_window =
true;
1227 m_invalid_window =
false;
1237 std::map<unsigned int, Cursor>::iterator it = m_standard_cursors.begin();
1238 for (; it != m_standard_cursors.end(); ++it) {
1239 XFreeCursor(m_display, it->second);
1242 if (m_empty_cursor) {
1243 XFreeCursor(m_display, m_empty_cursor);
1245 if (m_custom_cursor) {
1246 XFreeCursor(m_display, m_custom_cursor);
1249 if (m_valid_setup) {
1250 static Atom Primary_atom, Clipboard_atom;
1253 Primary_atom = XInternAtom(m_display,
"PRIMARY", False);
1254 Clipboard_atom = XInternAtom(m_display,
"CLIPBOARD", False);
1256 p_owner = XGetSelectionOwner(m_display, Primary_atom);
1257 c_owner = XGetSelectionOwner(m_display, Clipboard_atom);
1259 if (p_owner == m_window) {
1260 XSetSelectionOwner(m_display, Primary_atom,
None, CurrentTime);
1262 if (c_owner == m_window) {
1263 XSetSelectionOwner(m_display, Clipboard_atom,
None, CurrentTime);
1268 XFree(m_visualInfo);
1271 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
1278 delete m_dropTarget;
1283 if (m_valid_setup) {
1284 XDestroyWindow(m_display, m_window);
1302 #if defined(WITH_GL_PROFILE_CORE)
1304 const char *version_major = (
char *)glewGetString(GLEW_VERSION_MAJOR);
1305 if (version_major !=
nullptr && version_major[0] ==
'1') {
1306 fprintf(stderr,
"Error: GLEW version 2.0 and above is required.\n");
1312 const int profile_mask =
1314 # if defined(WITH_GL_PROFILE_CORE)
1315 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
1316 # elif defined(WITH_GL_PROFILE_COMPAT)
1317 EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
1322 # if defined(WITH_GL_PROFILE_CORE)
1323 GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
1324 # elif defined(WITH_GL_PROFILE_COMPAT)
1325 GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
1333 for (
int minor = 5; minor >= 0; --minor) {
1338 EGLNativeWindowType(m_window),
1339 EGLNativeDisplayType(m_display),
1344 (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
1351 (GLXFBConfig)m_fbconfig,
1356 (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
1360 if (
context->initializeDrawingContext()) {
1369 EGLNativeWindowType(m_window),
1370 EGLNativeDisplayType(m_display),
1375 (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
1382 (GLXFBConfig)m_fbconfig,
1387 (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
1391 if (
context->initializeDrawingContext()) {
1397 fprintf(stderr,
"Error! Unsupported graphics card or driver.\n");
1399 "A graphics card and driver with support for OpenGL 3.3 or higher is required.\n");
1400 fprintf(stderr,
"The program will now close.\n");
1410 unsigned int xcursor_id;
1414 xcursor_id = XC_question_arrow;
1417 xcursor_id = XC_watch;
1420 xcursor_id = XC_xterm;
1423 xcursor_id = XC_crosshair;
1426 xcursor_id = XC_sb_v_double_arrow;
1429 xcursor_id = XC_sb_h_double_arrow;
1432 xcursor_id = XC_top_side;
1435 xcursor_id = XC_bottom_side;
1438 xcursor_id = XC_left_side;
1441 xcursor_id = XC_right_side;
1444 xcursor_id = XC_top_left_corner;
1447 xcursor_id = XC_top_right_corner;
1450 xcursor_id = XC_bottom_right_corner;
1453 xcursor_id = XC_bottom_left_corner;
1463 xcursor = m_standard_cursors[xcursor_id];
1466 xcursor = XCreateFontCursor(m_display, xcursor_id);
1468 m_standard_cursors[xcursor_id] = xcursor;
1474 Cursor GHOST_WindowX11::getEmptyCursor()
1476 if (!m_empty_cursor) {
1482 blank = XCreateBitmapFromData(
1483 m_display, RootWindow(m_display, m_visualInfo->screen),
data, 1, 1);
1485 m_empty_cursor = XCreatePixmapCursor(m_display, blank, blank, &dummy, &dummy, 0, 0);
1486 XFreePixmap(m_display, blank);
1489 return m_empty_cursor;
1497 if (m_visible_cursor) {
1498 xcursor = m_visible_cursor;
1505 xcursor = getEmptyCursor();
1508 XDefineCursor(m_display, m_window, xcursor);
1525 #ifdef GHOST_X11_GRAB
1526 XGrabPointer(m_display,
1529 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
1547 #if defined(WITH_X11_XINPUT) && defined(USE_X11_XINPUT_WARP)
1548 if ((m_system->m_xinput_version.present) &&
1549 (m_system->m_xinput_version.major_version >= 2)) {
1551 if (XIGetClientPointer(m_display,
None, &device_id) != False) {
1552 XIWarpPointer(m_display, device_id,
None,
None, 0, 0, 0, 0, 0, 0);
1558 XWarpPointer(m_display,
None,
None, 0, 0, 0, 0, 0, 0);
1571 #ifdef GHOST_X11_GRAB
1572 XUngrabPointer(m_display, CurrentTime);
1588 m_visible_cursor = xcursor;
1590 XDefineCursor(m_display, m_window, xcursor);
1599 return getStandardCursor(shape, xcursor);
1610 Colormap colormap = DefaultColormap(m_display, m_visualInfo->screen);
1611 Pixmap bitmap_pix, mask_pix;
1614 if (XAllocNamedColor(m_display, colormap,
"White", &fg, &fg) == 0) {
1617 if (XAllocNamedColor(m_display, colormap,
"Black", &bg, &bg) == 0) {
1621 if (m_custom_cursor) {
1622 XFreeCursor(m_display, m_custom_cursor);
1625 bitmap_pix = XCreateBitmapFromData(m_display, m_window, (
char *)bitmap, sizex, sizey);
1626 mask_pix = XCreateBitmapFromData(m_display, m_window, (
char *)
mask, sizex, sizey);
1628 m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
1629 XDefineCursor(m_display, m_window, m_custom_cursor);
1632 m_visible_cursor = m_custom_cursor;
1634 XFreePixmap(m_display, bitmap_pix);
1635 XFreePixmap(m_display, mask_pix);
1637 XFreeColors(m_display, colormap, &fg.pixel, 1, 0
L);
1638 XFreeColors(m_display, colormap, &bg.pixel, 1, 0
L);
1647 int x_return, y_return;
1648 unsigned int w_return, h_return, border_w_return, depth_return;
1650 XGetGeometry(m_display,
1666 err = XGrabKeyboard(m_display, m_window, False, GrabModeAsync, GrabModeAsync, CurrentTime);
1667 if (
err != GrabSuccess) {
1668 printf(
"XGrabKeyboard failed %d\n",
err);
1671 err = XGrabPointer(m_display,
1674 PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
1680 if (
err != GrabSuccess) {
1681 printf(
"XGrabPointer failed %d\n",
err);
1689 XUngrabKeyboard(m_display, CurrentTime);
1690 XUngrabPointer(m_display, CurrentTime);
1698 char *resMan = XResourceManagerString(m_display);
1700 XrmDatabase xrdb = XrmGetStringDatabase(resMan);
1702 char *
type =
nullptr;
1705 int success = XrmGetResource(xrdb,
"Xft.dpi",
"Xft.Dpi", &
type, &val);
1706 if (success &&
type) {
1707 if (strcmp(
type,
"String") == 0) {
1708 return atoi((
char *)val.addr);
1712 XrmDestroyDatabase(xrdb);
1716 XWindowAttributes attr;
1717 if (!XGetWindowAttributes(m_display, m_window, &attr)) {
1722 Screen *screen = attr.screen;
1723 int pixelWidth = WidthOfScreen(screen);
1724 int pixelHeight = HeightOfScreen(screen);
1725 int mmWidth = WidthMMOfScreen(screen);
1726 int mmHeight = HeightMMOfScreen(screen);
1728 double pixelDiagonal =
sqrt((pixelWidth * pixelWidth) + (pixelHeight * pixelHeight));
1729 double mmDiagonal =
sqrt((mmWidth * mmWidth) + (mmHeight * mmHeight));
1730 float inchDiagonal = mmDiagonal * 0.039f;
1731 int dpi = pixelDiagonal / inchDiagonal;
void BLI_kdtree_nd_() free(KDTree *tree)
#define GHOST_OPENGL_EGL_CONTEXT_FLAGS
#define GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY
int GHOST_X11_GL_GetAttributes(int *attribs, int attribs_max, bool is_stereo_visual, bool need_alpha, bool for_fb_config)
#define GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_GLX_CONTEXT_FLAGS
static const unsigned long BLENDER_ICONS_WM_X11[]
@ GHOST_kWindowStateMinimized
@ GHOST_kWindowStateMaximized
@ GHOST_kWindowStateNormal
@ GHOST_kWindowStateFullScreen
@ 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
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
GHOST_TDrawingContextType
@ GHOST_kDrawingContextTypeOpenGL
@ GHOST_kWindowOrderBottom
static XVisualInfo * x11_visualinfo_from_glx(Display *display, bool stereoVisual, bool needAlpha, GLXFBConfig *fbconfig)
#define _NET_WM_STATE_REMOVE
struct { long flags MotifWmHints
#define _NET_WM_STATE_ADD
_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 type
_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 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
_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 GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
void addDirtyWindow(GHOST_WindowX11 *bad_wind)
Atom _NET_WM_STATE_MAXIMIZED_VERT
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y)
Atom _NET_WM_STATE_FULLSCREEN
struct GHOST_SystemX11::@1294 m_atom
Atom _NET_WM_STATE_MAXIMIZED_HORZ
void set_progress(double progress)
void set_progress_enabled(bool enabled)
GHOST_TSuccess setDialogHints(GHOST_WindowX11 *parentWindow)
void setTitle(const char *title)
GHOST_TWindowState m_post_state
GHOST_TSuccess setOrder(GHOST_TWindowOrder order)
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_TSuccess endProgressBar()
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape)
GHOST_TSuccess endFullScreen() const
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 *parentWindow, GHOST_TDrawingContextType type=GHOST_kDrawingContextTypeNone, const bool is_dialog=false, const bool stereoVisual=false, const bool exclusive=false, const bool alphaBackground=false, const bool is_debug=false)
void getClientBounds(GHOST_Rect &bounds) const
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height)
GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type)
GHOST_TSuccess setWindowCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode)
std::string getTitle() const
GHOST_TSuccess setState(GHOST_TWindowState state)
GHOST_TSuccess setWindowCursorVisibility(bool visible)
GHOST_TWindowState getState() const
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape)
GHOST_TSuccess invalidate()
void getWindowBounds(GHOST_Rect &bounds) const
GHOST_TSuccess setClientWidth(uint32_t width)
GHOST_TSuccess beginFullScreen() const
GHOST_TSuccess setClientHeight(uint32_t height)
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_TSuccess setProgressBar(float progress)
GHOST_Rect m_cursorGrabBounds
void setCursorGrabAccum(int32_t x, int32_t y)
GHOST_TGrabCursorMode m_cursorGrab
int32_t m_cursorGrabInitPos[2]
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type)
GHOST_TSuccess releaseNativeHandles()
virtual bool getValid() const
GHOST_TStandardCursor getCursorShape() const
SyclQueue void void size_t num_bytes void
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)