static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle, jboolean resizable) { Window parent = (Window)parent_handle; Window win; XSetWindowAttributes attribs; unsigned int attribmask; XVisualInfo vis_info; if ( !XMatchVisualInfo(disp, screen, DefaultDepth(disp, screen), TrueColor, &vis_info) ) { throwException(env, "Failed to acquire X visual."); return false; } cmap = XCreateColormap(disp, parent, vis_info.visual, AllocNone); if (!checkXError(env, disp)) { return false; } attribs.colormap = cmap; attribs.border_pixel = 0; attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; attribmask = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel; if (isLegacyFullscreen(window_mode)) { attribmask |= CWOverrideRedirect; attribs.override_redirect = True; } win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info.depth, InputOutput, vis_info.visual, attribmask, &attribs); current_depth = vis_info.depth; current_visual = vis_info.visual; if (!checkXError(env, disp)) { XFreeColormap(disp, cmap); return false; } if (undecorated) { // Use Motif decoration hint property and hope the window manager respects them setDecorations(disp, win, 0); } if (RootWindow(disp, screen) == parent_handle) { // only set hints when Display.setParent isn't used updateWindowBounds(disp, win, x, y, width, height, JNI_TRUE, resizable); updateWindowHints(env, disp, win); } #define NUM_ATOMS 1 Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/}; XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False), XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); } if (!checkXError(env, disp)) { destroyWindow(env, disp, win); return 0; } return win; }
static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, int rgb_size, char *mask_data, int mask_size, int width, int height) { freeIconPixmap(disp); current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, rgb_size, width, height, ZPixmap, current_depth); if ((*env)->ExceptionCheck(env)) return; current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, mask_size, width, height, XYPixmap, 1); if ((*env)->ExceptionCheck(env)) { freeIconPixmap(disp); return; } updateWindowHints(env, disp, window); }