Changeset View
Standalone View
intern/ghost/intern/GHOST_WindowX11.cpp
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| #if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX) | #if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX) | ||||
| # include <strings.h> | # include <strings.h> | ||||
| #endif | #endif | ||||
| #include <cstring> | #include <cstring> | ||||
| #include <cstdio> | #include <cstdio> | ||||
| #include <unistd.h> | |||||
| #include <algorithm> | #include <algorithm> | ||||
| #include <string> | #include <string> | ||||
| /* For obscure full screen mode stuff | /* For obscure full screen mode stuff | ||||
| * lifted verbatim from blut. */ | * lifted verbatim from blut. */ | ||||
| typedef struct { | typedef struct { | ||||
| long flags; | long flags; | ||||
| long functions; | long functions; | ||||
| long decorations; | long decorations; | ||||
| long input_mode; | long input_mode; | ||||
| } MotifWmHints; | } MotifWmHints; | ||||
| #define MWM_HINTS_DECORATIONS (1L << 1) | #define MWM_HINTS_DECORATIONS (1L << 1) | ||||
| #ifndef MAXHOSTNAMELEN | |||||
Severin: Is this really needed? I mean, is it possible that this has been defined before at all? | |||||
kevindietrichUnsubmitted Not Done Inline ActionsIt is defined in some old version of /usr/include/netdb.h, just being careful here but I guess we can remove it as netdb.h doesn't seem to be included in GHOST at all. kevindietrich: It is defined in some old version of /usr/include/netdb.h, just being careful here but I guess… | |||||
sergeyUnsubmitted Not Done Inline ActionsDon't really think we need global define for this. Can do local define or evn just inline constant with proper sizeof(). sergey: Don't really think we need global define for this. Can do local define or evn just inline… | |||||
| # define MAXHOSTNAMELEN 256 | |||||
| #endif | |||||
| // #define GHOST_X11_GRAB | // #define GHOST_X11_GRAB | ||||
| /* | /* | ||||
| * A Client can't change the window property, that is | * A Client can't change the window property, that is | ||||
| * the work of the window manager. In case, we send | * the work of the window manager. In case, we send | ||||
| * a ClientMessage to the RootWindow with the property | * a ClientMessage to the RootWindow with the property | ||||
| * and the Action (WM-spec define this): | * and the Action (WM-spec define this): | ||||
| ▲ Show 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | #endif | ||||
| /* set the icon */ | /* set the icon */ | ||||
| Atom _NET_WM_ICON = XInternAtom(m_display, "_NET_WM_ICON", False); | Atom _NET_WM_ICON = XInternAtom(m_display, "_NET_WM_ICON", False); | ||||
| XChangeProperty(m_display, m_window, _NET_WM_ICON, XA_CARDINAL, | XChangeProperty(m_display, m_window, _NET_WM_ICON, XA_CARDINAL, | ||||
| 32, PropModeReplace, (unsigned char *)BLENDER_ICON_48x48x32, | 32, PropModeReplace, (unsigned char *)BLENDER_ICON_48x48x32, | ||||
| BLENDER_ICON_48x48x32[0] * BLENDER_ICON_48x48x32[1] + 2); | BLENDER_ICON_48x48x32[0] * BLENDER_ICON_48x48x32[1] + 2); | ||||
| /* done setting the icon */ | /* done setting the icon */ | ||||
| /* set the process ID */ | |||||
| Atom _NET_WM_PID = XInternAtom(m_display, "_NET_WM_PID", False); | |||||
| pid_t pid = getpid(); | |||||
| XChangeProperty(m_display, m_window, _NET_WM_PID, XA_CARDINAL, | |||||
| 32, PropModeReplace, (unsigned char *)&pid, 1); | |||||
| /* done setting the process ID */ | |||||
sergeyUnsubmitted Not Done Inline Actionsnot really happy with this, it's kinda clear already you're done with pid. Same for client machine. sergey: not really happy with this, it's kinda clear already you're done with pid. Same for client… | |||||
| /* set WM_CLIENT_MACHINE */ | |||||
| char name[MAXHOSTNAMELEN]; | |||||
| char *hostname[1]; | |||||
sergeyUnsubmitted Not Done Inline ActionsNaming could be improved IMO. sergey: Naming could be improved IMO. | |||||
kevindietrichUnsubmitted Not Done Inline ActionsDo you have a suggestion here? Maybe use "buffer" instead of "name" and keep "hostname" as is? kevindietrich: Do you have a suggestion here? Maybe use "buffer" instead of "name" and keep "hostname" as is? | |||||
| XTextProperty text_prop; | |||||
| gethostname(name, MAXHOSTNAMELEN); | |||||
| name[MAXHOSTNAMELEN - 1] = '\0'; | |||||
SeverinUnsubmitted Not Done Inline Actionscould be name[strlen(name)] = '\0'; Severin: could be `name[strlen(name)] = '\0';` | |||||
kevindietrichUnsubmitted Not Done Inline ActionsMAXHOSTNAMELEN - 1 is faster ;). I know it won't be a bottleneck but still :). We'll see what others think. kevindietrich: `MAXHOSTNAMELEN - 1` is faster ;). I know it won't be a bottleneck but still :). We'll see what… | |||||
sergeyUnsubmitted Not Done Inline ActionsYou can not use strlen here if it's not guaranteed to be NULL-terminated. So just use buffer size-1 here. sergey: You can not use `strlen` here if it's not guaranteed to be NULL-terminated. So just use buffer… | |||||
| hostname[0] = name; | |||||
| XStringListToTextProperty(hostname, 1, &text_prop); | |||||
SeverinUnsubmitted Not Done Inline ActionsThe "1" stands for the list elements in hostname, right? Normally I'd prefer to calculate this generically, but I think in this case it should be fine to leave it hardcoded. Someone who messes around with this code should know when this has to be updated ;) If we decided to not go for the hardcoded way we could use XStringListToTextProperty(hostname, (sizeof(hostname) / sizeof(char *)), &text_prop); Severin: The "1" stands for the list elements in hostname, right? Normally I'd prefer to calculate this… | |||||
sergeyUnsubmitted Not Done Inline ActionsDon't see it's needed, it's always expected to be 1. Could add assert for that. sergey: Don't see it's needed, it's always expected to be 1. Could add assert for that. | |||||
| XSetWMClientMachine(m_display, m_window, &text_prop); | |||||
| XFree(text_prop.value); | |||||
| /* done setting WM_CLIENT_MACHINE */ | |||||
| #ifdef WITH_X11_XINPUT | #ifdef WITH_X11_XINPUT | ||||
| initXInputDevices(); | initXInputDevices(); | ||||
| m_tabletData.Active = GHOST_kTabletModeNone; | m_tabletData.Active = GHOST_kTabletModeNone; | ||||
| #endif | #endif | ||||
| /* now set up the rendering context. */ | /* now set up the rendering context. */ | ||||
| if (setDrawingContextType(type) == GHOST_kSuccess) { | if (setDrawingContextType(type) == GHOST_kSuccess) { | ||||
| ▲ Show 20 Lines • Show All 1,065 Lines • Show Last 20 Lines | |||||
Is this really needed? I mean, is it possible that this has been defined before at all?