25 #include <X11/Xatom.h>
27 #include <X11/Xutil.h>
28 #include <X11/cursorfont.h>
30 # include <X11/extensions/Xrender.h>
43 # include <EGL/eglext.h>
49 #ifdef WITH_X11_XINPUT
50 # include <X11/extensions/XInput2.h>
54 #include <X11/Xresource.h>
91 # define HOST_NAME_MAX 64
102 #define _NET_WM_STATE_REMOVE 0
103 #define _NET_WM_STATE_ADD 1
108 static XVisualInfo *x11_visualinfo_from_egl(Display *display)
111 XVisualInfo vinfo_template;
112 vinfo_template.screen = DefaultScreen(display);
113 return XGetVisualInfo(display, VisualScreenMask, &vinfo_template, &num_visuals);
121 GLXFBConfig *fbconfig)
123 int glx_major, glx_minor, glx_version;
131 if (!glXQueryVersion(display, &glx_major, &glx_minor)) {
133 "%s:%d: X11 glXQueryVersion() failed, "
134 "verify working openGL system!\n",
140 glx_version = glx_major * 100 + glx_minor;
141 # ifndef WITH_X11_ALPHA
145 # ifdef WITH_X11_ALPHA
146 if (needAlpha && glx_version >= 103 &&
147 (glXChooseFBConfig || (glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddressARB(
148 (
const GLubyte *)
"glXChooseFBConfig")) !=
NULL) &&
149 (glXGetVisualFromFBConfig ||
150 (glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddressARB(
151 (
const GLubyte *)
"glXGetVisualFromFBConfig")) !=
NULL)) {
156 GLXFBConfig *fbconfigs = glXChooseFBConfig(
157 display, DefaultScreen(display), glx_attribs, &nbfbconfig);
161 if (nbfbconfig > 0) {
163 for (
int i = 0; i < nbfbconfig; i++) {
164 XVisualInfo *visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]);
170 XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual);
173 if (pict_format->direct.alphaMask <= 0)
177 *fbconfig = fbconfigs[i];
192 XVisualInfo *visual = glXChooseVisual(display, DefaultScreen(display), glx_attribs);
196 if (visual !=
NULL) {
203 "%s:%d: X11 glXChooseVisual() failed, "
204 "verify working openGL system!\n",
223 const bool is_dialog,
224 const bool stereoVisual,
225 const bool exclusive,
226 const bool alphaBackground,
234 m_invalid_window(false),
235 m_empty_cursor(None),
236 m_custom_cursor(None),
237 m_visible_cursor(None),
238 m_taskbar(
"blender.desktop"),
243 #
if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
246 m_valid_setup(false),
247 m_is_debug_context(is_debug)
251 m_visualInfo = x11_visualinfo_from_egl(m_display);
252 (void)alphaBackground;
255 m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig);
259 XVisualInfo tmp = {0};
261 m_visualInfo = XGetVisualInfo(m_display, 0, &tmp, &n);
265 if (m_visualInfo ==
NULL) {
266 fprintf(stderr,
"initial window could not find the GLX extension\n");
270 unsigned int xattributes_valuemask = 0;
272 XSetWindowAttributes xattributes;
273 memset(&xattributes, 0,
sizeof(xattributes));
275 xattributes_valuemask |= CWBorderPixel;
276 xattributes.border_pixel = 0;
280 xattributes_valuemask |= CWEventMask;
281 xattributes.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
282 EnterWindowMask | LeaveWindowMask | ButtonPressMask |
283 ButtonReleaseMask | PointerMotionMask | FocusChangeMask |
284 PropertyChangeMask | KeymapStateMask;
287 xattributes_valuemask |= CWOverrideRedirect;
288 xattributes.override_redirect = True;
291 xattributes_valuemask |= CWColormap;
292 xattributes.colormap = XCreateColormap(
293 m_display, RootWindow(m_display, m_visualInfo->screen), m_visualInfo->visual, AllocNone);
296 m_window = XCreateWindow(m_display,
297 RootWindow(m_display, m_visualInfo->screen),
305 m_visualInfo->visual,
306 xattributes_valuemask,
326 XChangeProperty(m_display,
332 (
unsigned char *)atoms,
356 if (is_dialog && parentWindow) {
363 XSizeHints *xsizehints = XAllocSizeHints();
364 xsizehints->flags = PPosition | PSize | PMinSize | PMaxSize;
365 xsizehints->x =
left;
367 xsizehints->width =
width;
368 xsizehints->height =
height;
369 xsizehints->min_width = 320;
370 xsizehints->min_height = 240;
371 xsizehints->max_width = 65535;
372 xsizehints->max_height = 65535;
373 XSetWMNormalHints(m_display, m_window, xsizehints);
379 XClassHint *xclasshint = XAllocClassHint();
380 const int len = strlen(title) + 1;
381 char *wmclass = (
char *)malloc(
sizeof(
char) *
len);
382 memcpy(wmclass, title,
len *
sizeof(
char));
383 xclasshint->res_name = wmclass;
384 xclasshint->res_class = wmclass;
385 XSetClassHint(m_display, m_window, xclasshint);
407 XSetWMProtocols(m_display, m_window, atoms, natom);
413 XWMHints *xwmhints = XAllocWMHints();
414 xwmhints->initial_state = NormalState;
416 xwmhints->flags = InputHint | StateHint;
417 XSetWMHints(display, m_window, xwmhints);
423 Atom _NET_WM_ICON = XInternAtom(m_display,
"_NET_WM_ICON", False);
424 XChangeProperty(m_display,
436 Atom _NET_WM_PID = XInternAtom(m_display,
"_NET_WM_PID", False);
437 pid_t pid = getpid();
438 XChangeProperty(m_display,
444 (
unsigned char *)&pid,
452 XTextProperty text_prop;
454 gethostname(hostname,
sizeof(hostname));
455 hostname[
sizeof(hostname) - 1] =
'\0';
456 text_array[0] = hostname;
458 XStringListToTextProperty(text_array, 1, &text_prop);
459 XSetWMClientMachine(m_display, m_window, &text_prop);
460 XFree(text_prop.value);
463 #ifdef WITH_X11_XINPUT
464 refreshXInputDevices();
469 m_valid_setup =
true;
476 XMapRaised(m_display, m_window);
479 XMapWindow(m_display, m_window);
482 XLowerWindow(m_display, m_window);
490 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
491 static Bool destroyICCallback(XIC , XPointer
ptr, XPointer )
502 bool GHOST_WindowX11::createX11_XIC()
504 XIM xim = m_system->getX11_XIM();
509 destroy.callback = (XICProc)destroyICCallback;
510 destroy.client_data = (XPointer)&m_xic;
511 m_xic = XCreateIC(xim,
517 XIMPreeditNothing | XIMStatusNothing,
528 unsigned long fevent;
529 XGetICValues(m_xic, XNFilterEvents, &fevent,
NULL);
530 XSelectInput(m_display,
532 ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask |
533 EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask |
534 PointerMotionMask | FocusChangeMask | PropertyChangeMask | KeymapStateMask |
540 #ifdef WITH_X11_XINPUT
541 void GHOST_WindowX11::refreshXInputDevices()
543 if (m_system->m_xinput_version.present) {
544 std::vector<XEventClass> xevents;
546 for (GHOST_SystemX11::GHOST_TabletX11 &xtablet : m_system->GetXTablets()) {
553 DeviceMotionNotify(xtablet.Device, xtablet.MotionEvent, ev);
555 xevents.push_back(ev);
556 DeviceButtonPress(xtablet.Device, xtablet.PressEvent, ev);
558 xevents.push_back(ev);
559 ProximityIn(xtablet.Device, xtablet.ProxInEvent, ev);
561 xevents.push_back(ev);
562 ProximityOut(xtablet.Device, xtablet.ProxOutEvent, ev);
564 xevents.push_back(ev);
567 XSelectExtensionEvent(m_display, m_window, xevents.data(), (
int)xevents.size());
585 Atom name = XInternAtom(m_display,
"_NET_WM_NAME", 0);
586 Atom utf8str = XInternAtom(m_display,
"UTF8_STRING", 0);
587 XChangeProperty(m_display,
593 (
const unsigned char *)title,
598 XStoreName(m_display, m_window, title);
607 XFetchName(m_display, m_window, &name);
608 std::string title = name ? name :
"untitled";
623 int x_return, y_return;
624 unsigned int w_return, h_return, border_w_return, depth_return;
627 XGetGeometry(m_display,
647 XWindowChanges values;
648 unsigned int value_mask = CWWidth;
649 values.width =
width;
650 XConfigureWindow(m_display, m_window, value_mask, &values);
657 XWindowChanges values;
658 unsigned int value_mask = CWHeight;
660 XConfigureWindow(m_display, m_window, value_mask, &values);
666 XWindowChanges values;
667 unsigned int value_mask = CWWidth | CWHeight;
668 values.width =
width;
670 XConfigureWindow(m_display, m_window, value_mask, &values);
684 XTranslateCoordinates(
685 m_display, RootWindow(m_display, m_visualInfo->screen), m_window, inX, inY, &ax, &ay, &temp);
698 XTranslateCoordinates(
699 m_display, m_window, RootWindow(m_display, m_visualInfo->screen), inX, inY, &ax, &ay, &temp);
707 Atom atom_window_type = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE", False);
708 Atom atom_dialog = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE_DIALOG", False);
711 XChangeProperty(m_display,
717 (
unsigned char *)&atom_dialog,
719 XSetTransientForHint(m_display, m_window, parentWindow->m_window);
728 XChangeProperty(m_display,
734 (
unsigned char *)&hints,
740 void GHOST_WindowX11::icccmSetState(
int state)
744 if (
state != IconicState)
747 xev.xclient.type = ClientMessage;
748 xev.xclient.serial = 0;
749 xev.xclient.send_event = True;
750 xev.xclient.display = m_display;
751 xev.xclient.window = m_window;
752 xev.xclient.format = 32;
754 xev.xclient.data.l[0] =
state;
755 XSendEvent(m_display,
756 RootWindow(m_display, m_visualInfo->screen),
758 SubstructureNotifyMask | SubstructureRedirectMask,
762 int GHOST_WindowX11::icccmGetState(
void)
const
768 unsigned long bytes_after, num_ret;
774 ret = XGetWindowProperty(m_display,
785 ((
unsigned char **)&prop_ret));
786 if ((
ret == Success) && (prop_ret !=
NULL) && (num_ret == 2)) {
787 st = prop_ret->state;
800 void GHOST_WindowX11::netwmMaximized(
bool set)
804 xev.xclient.type = ClientMessage;
805 xev.xclient.serial = 0;
806 xev.xclient.send_event = True;
807 xev.xclient.window = m_window;
809 xev.xclient.format = 32;
818 xev.xclient.data.l[3] = 0;
819 xev.xclient.data.l[4] = 0;
820 XSendEvent(m_display,
821 RootWindow(m_display, m_visualInfo->screen),
823 SubstructureRedirectMask | SubstructureNotifyMask,
827 bool GHOST_WindowX11::netwmIsMaximized(
void)
const
830 unsigned long bytes_after, num_ret, i;
837 ret = XGetWindowProperty(m_display,
848 (
unsigned char **)&prop_ret);
849 if ((
ret == Success) && (prop_ret) && (format_ret == 32)) {
851 for (i = 0; i < num_ret; i++) {
870 void GHOST_WindowX11::netwmFullScreen(
bool set)
874 xev.xclient.type = ClientMessage;
875 xev.xclient.serial = 0;
876 xev.xclient.send_event = True;
877 xev.xclient.window = m_window;
879 xev.xclient.format = 32;
887 xev.xclient.data.l[2] = 0;
888 xev.xclient.data.l[3] = 0;
889 xev.xclient.data.l[4] = 0;
890 XSendEvent(m_display,
891 RootWindow(m_display, m_visualInfo->screen),
893 SubstructureRedirectMask | SubstructureNotifyMask,
897 bool GHOST_WindowX11::netwmIsFullScreen(
void)
const
900 unsigned long bytes_after, num_ret, i;
907 ret = XGetWindowProperty(m_display,
918 (
unsigned char **)&prop_ret);
919 if ((
ret == Success) && (prop_ret) && (format_ret == 32)) {
920 for (i = 0; i < num_ret; i++) {
933 void GHOST_WindowX11::motifFullScreen(
bool set)
943 XChangeProperty(m_display,
949 (
unsigned char *)&hints,
953 bool GHOST_WindowX11::motifIsFullScreen(
void)
const
956 unsigned long bytes_after, num_ret;
963 st = XGetWindowProperty(m_display,
974 (
unsigned char **)&prop_ret);
975 if ((st == Success) && prop_ret) {
993 state = icccmGetState();
998 if ((
state == IconicState) || (
state == WithdrawnState))
1000 else if (netwmIsFullScreen() == True)
1002 else if (motifIsFullScreen() == True)
1004 else if (netwmIsMaximized() == True)
1012 bool is_max, is_full, is_motif_full;
1015 if (
state == (
int)cur_state)
1023 is_max = netwmIsMaximized();
1024 is_full = netwmIsFullScreen();
1031 is_motif_full = motifIsFullScreen();
1034 state = m_normal_state;
1038 netwmMaximized(False);
1039 if (is_full == True)
1040 netwmFullScreen(False);
1041 if (is_motif_full == True)
1042 motifFullScreen(False);
1043 icccmSetState(NormalState);
1055 m_normal_state = cur_state;
1058 netwmMaximized(False);
1059 if (is_full == False)
1060 netwmFullScreen(True);
1061 if (is_motif_full == False)
1062 motifFullScreen(True);
1074 if (is_full == True)
1075 netwmFullScreen(False);
1076 if (is_motif_full == True)
1077 motifFullScreen(False);
1078 if (is_max == False)
1079 netwmMaximized(True);
1088 icccmSetState(IconicState);
1098 XWindowAttributes attr;
1105 XRaiseWindow(m_display, m_window);
1107 atom = XInternAtom(m_display,
"_NET_ACTIVE_WINDOW", True);
1114 xev.xclient.type = ClientMessage;
1115 xev.xclient.serial = 0;
1116 xev.xclient.send_event = True;
1117 xev.xclient.window = m_window;
1118 xev.xclient.message_type = atom;
1120 xev.xclient.format = 32;
1121 xev.xclient.data.l[0] = 1;
1122 xev.xclient.data.l[1] = CurrentTime;
1123 xev.xclient.data.l[2] = m_window;
1124 xev.xclient.data.l[3] = 0;
1125 xev.xclient.data.l[4] = 0;
1127 root = RootWindow(m_display, m_visualInfo->screen);
1128 eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
1130 XSendEvent(m_display, root, False, eventmask, &xev);
1133 XGetWindowAttributes(m_display, m_window, &attr);
1136 if (attr.map_state == IsViewable)
1137 XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
1141 XLowerWindow(m_display, m_window);
1153 Atom atom_window_type = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE", False);
1154 Atom atom_dialog = XInternAtom(m_display,
"_NET_WM_WINDOW_TYPE_DIALOG", False);
1157 unsigned long bytes_after, num_ret;
1160 int format_ret,
ret;
1164 ret = XGetWindowProperty(m_display,
1175 (
unsigned char **)&prop_ret);
1176 if ((
ret == Success) && (prop_ret) && (format_ret == 32)) {
1177 if (prop_ret[0] == atom_dialog) {
1204 if (m_invalid_window ==
false) {
1206 m_invalid_window =
true;
1219 m_invalid_window =
false;
1229 std::map<unsigned int, Cursor>::iterator it = m_standard_cursors.begin();
1230 for (; it != m_standard_cursors.end(); ++it) {
1231 XFreeCursor(m_display, it->second);
1234 if (m_empty_cursor) {
1235 XFreeCursor(m_display, m_empty_cursor);
1237 if (m_custom_cursor) {
1238 XFreeCursor(m_display, m_custom_cursor);
1241 if (m_valid_setup) {
1242 static Atom Primary_atom, Clipboard_atom;
1243 Window p_owner, c_owner;
1245 Primary_atom = XInternAtom(m_display,
"PRIMARY", False);
1246 Clipboard_atom = XInternAtom(m_display,
"CLIPBOARD", False);
1248 p_owner = XGetSelectionOwner(m_display, Primary_atom);
1249 c_owner = XGetSelectionOwner(m_display, Clipboard_atom);
1251 if (p_owner == m_window) {
1252 XSetSelectionOwner(m_display, Primary_atom, None, CurrentTime);
1254 if (c_owner == m_window) {
1255 XSetSelectionOwner(m_display, Clipboard_atom, None, CurrentTime);
1260 XFree(m_visualInfo);
1263 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
1270 delete m_dropTarget;
1275 if (m_valid_setup) {
1276 XDestroyWindow(m_display, m_window);
1294 #if defined(WITH_GL_PROFILE_CORE)
1296 const char *version_major = (
char *)glewGetString(GLEW_VERSION_MAJOR);
1297 if (version_major !=
NULL && version_major[0] ==
'1') {
1298 fprintf(stderr,
"Error: GLEW version 2.0 and above is required.\n");
1304 const int profile_mask =
1306 # if defined(WITH_GL_PROFILE_CORE)
1307 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
1308 # elif defined(WITH_GL_PROFILE_COMPAT)
1309 EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
1314 # if defined(WITH_GL_PROFILE_CORE)
1315 GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
1316 # elif defined(WITH_GL_PROFILE_COMPAT)
1317 GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
1325 for (
int minor = 5; minor >= 0; --minor) {
1329 EGLNativeWindowType(m_window),
1330 EGLNativeDisplayType(m_display),
1335 (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
1342 (GLXFBConfig)m_fbconfig,
1347 (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
1351 if (
context->initializeDrawingContext())
1359 EGLNativeWindowType(m_window),
1360 EGLNativeDisplayType(m_display),
1365 (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
1372 (GLXFBConfig)m_fbconfig,
1377 (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
1381 if (
context->initializeDrawingContext())
1387 fprintf(stderr,
"Error! Unsupported graphics card or driver.\n");
1389 "A graphics card and driver with support for OpenGL 3.3 or higher is required.\n");
1390 fprintf(stderr,
"The program will now close.\n");
1400 unsigned int xcursor_id;
1404 xcursor_id = XC_question_arrow;
1407 xcursor_id = XC_watch;
1410 xcursor_id = XC_xterm;
1413 xcursor_id = XC_crosshair;
1416 xcursor_id = XC_sb_v_double_arrow;
1419 xcursor_id = XC_sb_h_double_arrow;
1422 xcursor_id = XC_top_side;
1425 xcursor_id = XC_bottom_side;
1428 xcursor_id = XC_left_side;
1431 xcursor_id = XC_right_side;
1434 xcursor_id = XC_top_left_corner;
1437 xcursor_id = XC_top_right_corner;
1440 xcursor_id = XC_bottom_right_corner;
1443 xcursor_id = XC_bottom_left_corner;
1453 xcursor = m_standard_cursors[xcursor_id];
1456 xcursor = XCreateFontCursor(m_display, xcursor_id);
1458 m_standard_cursors[xcursor_id] = xcursor;
1464 Cursor GHOST_WindowX11::getEmptyCursor()
1466 if (!m_empty_cursor) {
1472 blank = XCreateBitmapFromData(
1473 m_display, RootWindow(m_display, m_visualInfo->screen),
data, 1, 1);
1475 m_empty_cursor = XCreatePixmapCursor(m_display, blank, blank, &dummy, &dummy, 0, 0);
1476 XFreePixmap(m_display, blank);
1479 return m_empty_cursor;
1487 if (m_visible_cursor) {
1488 xcursor = m_visible_cursor;
1495 xcursor = getEmptyCursor();
1498 XDefineCursor(m_display, m_window, xcursor);
1514 #ifdef GHOST_X11_GRAB
1515 XGrabPointer(m_display,
1518 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
1536 #if defined(WITH_X11_XINPUT) && defined(USE_X11_XINPUT_WARP)
1537 if ((m_system->m_xinput_version.present) &&
1538 (m_system->m_xinput_version.major_version >= 2)) {
1540 if (XIGetClientPointer(m_display, None, &device_id) != False) {
1541 XIWarpPointer(m_display, device_id, None, None, 0, 0, 0, 0, 0, 0);
1547 XWarpPointer(m_display, None, None, 0, 0, 0, 0, 0, 0);
1560 #ifdef GHOST_X11_GRAB
1561 XUngrabPointer(m_display, CurrentTime);
1577 m_visible_cursor = xcursor;
1579 XDefineCursor(m_display, m_window, xcursor);
1588 return getStandardCursor(shape, xcursor);
1599 Colormap colormap = DefaultColormap(m_display, m_visualInfo->screen);
1600 Pixmap bitmap_pix, mask_pix;
1603 if (XAllocNamedColor(m_display, colormap,
"White", &fg, &fg) == 0)
1605 if (XAllocNamedColor(m_display, colormap,
"Black", &bg, &bg) == 0)
1608 if (m_custom_cursor) {
1609 XFreeCursor(m_display, m_custom_cursor);
1612 bitmap_pix = XCreateBitmapFromData(m_display, m_window, (
char *)bitmap, sizex, sizey);
1613 mask_pix = XCreateBitmapFromData(m_display, m_window, (
char *)
mask, sizex, sizey);
1615 m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
1616 XDefineCursor(m_display, m_window, m_custom_cursor);
1619 m_visible_cursor = m_custom_cursor;
1621 XFreePixmap(m_display, bitmap_pix);
1622 XFreePixmap(m_display, mask_pix);
1624 XFreeColors(m_display, colormap, &fg.pixel, 1, 0
L);
1625 XFreeColors(m_display, colormap, &bg.pixel, 1, 0
L);
1634 int x_return, y_return;
1635 unsigned int w_return, h_return, border_w_return, depth_return;
1637 XGetGeometry(m_display,
1653 err = XGrabKeyboard(m_display, m_window, False, GrabModeAsync, GrabModeAsync, CurrentTime);
1654 if (
err != GrabSuccess)
1655 printf(
"XGrabKeyboard failed %d\n",
err);
1657 err = XGrabPointer(m_display,
1660 PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
1666 if (
err != GrabSuccess)
1667 printf(
"XGrabPointer failed %d\n",
err);
1674 XUngrabKeyboard(m_display, CurrentTime);
1675 XUngrabPointer(m_display, CurrentTime);
1683 char *resMan = XResourceManagerString(m_display);
1685 XrmDatabase xrdb = XrmGetStringDatabase(resMan);
1690 int success = XrmGetResource(xrdb,
"Xft.dpi",
"Xft.Dpi", &
type, &val);
1691 if (success &&
type) {
1692 if (strcmp(
type,
"String") == 0) {
1693 return atoi((
char *)val.addr);
1697 XrmDestroyDatabase(xrdb);
1701 XWindowAttributes attr;
1702 if (!XGetWindowAttributes(m_display, m_window, &attr)) {
1707 Screen *screen = attr.screen;
1708 int pixelWidth = WidthOfScreen(screen);
1709 int pixelHeight = HeightOfScreen(screen);
1710 int mmWidth = WidthMMOfScreen(screen);
1711 int mmHeight = HeightMMOfScreen(screen);
1713 double pixelDiagonal =
sqrt((pixelWidth * pixelWidth) + (pixelHeight * pixelHeight));
1714 double mmDiagonal =
sqrt((mmWidth * mmWidth) + (mmHeight * mmHeight));
1715 float inchDiagonal = mmDiagonal * 0.039f;
1716 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
unsigned int GHOST_TUns32
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
unsigned short GHOST_TUns16
GHOST_TDrawingContextType
@ GHOST_kDrawingContextTypeOpenGL
@ GHOST_kWindowOrderBottom
unsigned char GHOST_TUns8
static XVisualInfo * x11_visualinfo_from_glx(Display *display, bool stereoVisual, bool needAlpha, GLXFBConfig *fbconfig)
#define _NET_WM_STATE_REMOVE
#define _NET_WM_STATE_ADD
_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 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)
GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
void addDirtyWindow(GHOST_WindowX11 *bad_wind)
Atom _NET_WM_STATE_MAXIMIZED_VERT
Atom _NET_WM_STATE_FULLSCREEN
struct GHOST_SystemX11::@1233 m_atom
Atom _NET_WM_STATE_MAXIMIZED_HORZ
GHOST_TSuccess getCursorPosition(GHOST_TInt32 &x, GHOST_TInt32 &y) const
void set_progress(double progress)
void set_progress_enabled(bool enabled)
GHOST_TSuccess setClientHeight(GHOST_TUns32 height)
GHOST_TSuccess setDialogHints(GHOST_WindowX11 *parentWindow)
GHOST_WindowX11(GHOST_SystemX11 *system, Display *display, const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 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)
GHOST_TSuccess setClientWidth(GHOST_TUns32 width)
GHOST_TUns16 getDPIHint()
void setTitle(const char *title)
GHOST_TWindowState m_post_state
GHOST_TSuccess setOrder(GHOST_TWindowOrder order)
GHOST_TSuccess endProgressBar()
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape)
GHOST_TSuccess endFullScreen() const
void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
void getClientBounds(GHOST_Rect &bounds) const
GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type)
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode)
std::string getTitle() const
GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height)
void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 &outX, GHOST_TInt32 &outY) 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 setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
GHOST_TSuccess beginFullScreen() const
GHOST_TSuccess setProgressBar(float progress)
GHOST_Rect m_cursorGrabBounds
GHOST_TGrabCursorMode m_cursorGrab
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type)
GHOST_TSuccess releaseNativeHandles()
GHOST_TInt32 m_cursorGrabInitPos[2]
virtual bool getValid() const
void setCursorGrabAccum(GHOST_TInt32 x, GHOST_TInt32 y)
GHOST_TStandardCursor getCursorShape() const
struct SELECTID_Context context
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)