static void winopen(void) { XWMHints *wmhints; XClassHint *classhint; xdpy = XOpenDisplay(nil); if (!xdpy) winerror(&gapp, fz_throw("could not open display")); XA_TARGETS = XInternAtom(xdpy, "TARGETS", False); XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False); XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False); xscr = DefaultScreen(xdpy); ximage_init(xdpy, xscr, DefaultVisual(xdpy, xscr)); xcarrow = XCreateFontCursor(xdpy, XC_left_ptr); xchand = XCreateFontCursor(xdpy, XC_hand2); xcwait = XCreateFontCursor(xdpy, XC_watch); xbgcolor.red = 0x7000; xbgcolor.green = 0x7000; xbgcolor.blue = 0x7000; xshcolor.red = 0x4000; xshcolor.green = 0x4000; xshcolor.blue = 0x4000; XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor); XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor); xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy), 10, 10, 200, 100, 1, ximage_get_depth(), InputOutput, ximage_get_visual(), 0, nil); XSetWindowColormap(xdpy, xwin, ximage_get_colormap()); XSelectInput(xdpy, xwin, StructureNotifyMask | ExposureMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask); mapped = 0; xgc = XCreateGC(xdpy, xwin, 0, nil); XDefineCursor(xdpy, xwin, xcarrow); wmhints = XAllocWMHints(); if (wmhints) { wmhints->flags = IconPixmapHint; wmhints->icon_pixmap = XCreateBitmapFromData(xdpy, xwin, (char *) gs_l_xbm_bits, gs_l_xbm_width, gs_l_xbm_height); if (wmhints->icon_pixmap) { XSetWMHints(xdpy, xwin, wmhints); } XFree(wmhints); } classhint = XAllocClassHint(); if (classhint) { classhint->res_name = "mupdf"; classhint->res_class = "MuPDF"; XSetClassHint(xdpy, xwin, classhint); XFree(classhint); } x11fd = ConnectionNumber(xdpy); }
static void winopen(void) { XWMHints *wmhints; XClassHint *classhint; xdpy = XOpenDisplay(NULL); if (!xdpy) fz_throw(gapp.ctx, "cannot open display"); XA_CLIPBOARD = XInternAtom(xdpy, "CLIPBOARD", False); XA_TARGETS = XInternAtom(xdpy, "TARGETS", False); XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False); XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False); WM_DELETE_WINDOW = XInternAtom(xdpy, "WM_DELETE_WINDOW", False); NET_WM_STATE = XInternAtom(xdpy, "_NET_WM_STATE", False); NET_WM_STATE_FULLSCREEN = XInternAtom(xdpy, "_NET_WM_STATE_FULLSCREEN", False); xscr = DefaultScreen(xdpy); ximage_init(xdpy, xscr, DefaultVisual(xdpy, xscr)); xcarrow = XCreateFontCursor(xdpy, XC_left_ptr); xchand = XCreateFontCursor(xdpy, XC_hand2); xcwait = XCreateFontCursor(xdpy, XC_watch); xccaret = XCreateFontCursor(xdpy, XC_xterm); xbgcolor.red = 0x7000; xbgcolor.green = 0x7000; xbgcolor.blue = 0x7000; xshcolor.red = 0x4000; xshcolor.green = 0x4000; xshcolor.blue = 0x4000; XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor); XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor); xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy), 10, 10, 200, 100, 0, ximage_get_depth(), InputOutput, ximage_get_visual(), 0, NULL); if (xwin == None) fz_throw(gapp.ctx, "cannot create window"); XSetWindowColormap(xdpy, xwin, ximage_get_colormap()); XSelectInput(xdpy, xwin, StructureNotifyMask | ExposureMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask); mapped = 0; xgc = XCreateGC(xdpy, xwin, 0, NULL); XDefineCursor(xdpy, xwin, xcarrow); wmhints = XAllocWMHints(); if (wmhints) { wmhints->flags = IconPixmapHint | IconMaskHint; xicon = XCreateBitmapFromData(xdpy, xwin, (char*)mupdf_icon_bitmap_16_bits, mupdf_icon_bitmap_16_width, mupdf_icon_bitmap_16_height); xmask = XCreateBitmapFromData(xdpy, xwin, (char*)mupdf_icon_bitmap_16_mask_bits, mupdf_icon_bitmap_16_mask_width, mupdf_icon_bitmap_16_mask_height); if (xicon && xmask) { wmhints->icon_pixmap = xicon; wmhints->icon_mask = xmask; XSetWMHints(xdpy, xwin, wmhints); } XFree(wmhints); } classhint = XAllocClassHint(); if (classhint) { classhint->res_name = "mupdf"; classhint->res_class = "MuPDF"; XSetClassHint(xdpy, xwin, classhint); XFree(classhint); } XSetWMProtocols(xdpy, xwin, &WM_DELETE_WINDOW, 1); x11fd = ConnectionNumber(xdpy); }
void winopen(void) { XWMHints *hints; xdpy = XOpenDisplay(nil); if (!xdpy) winerror(&gapp, "could not open display."); XA_TARGETS = XInternAtom(xdpy, "TARGETS", False); XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False); XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False); xscr = DefaultScreen(xdpy); ximage_init(xdpy, xscr, DefaultVisual(xdpy, xscr)); xcarrow = XCreateFontCursor(xdpy, XC_left_ptr); xchand = XCreateFontCursor(xdpy, XC_hand2); xcwait = XCreateFontCursor(xdpy, XC_watch); xbgcolor.red = 0x7000; xbgcolor.green = 0x7000; xbgcolor.blue = 0x7000; xshcolor.red = 0x4000; xshcolor.green = 0x4000; xshcolor.blue = 0x4000; XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor); XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor); xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy), 10, 10, 200, 100, 1, ximage_get_depth(), InputOutput, ximage_get_visual(), 0, nil); XSetWindowColormap(xdpy, xwin, ximage_get_colormap()); XSelectInput(xdpy, xwin, StructureNotifyMask | ExposureMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask); mapped = 0; xgc = XCreateGC(xdpy, xwin, 0, nil); XDefineCursor(xdpy, xwin, xcarrow); hints = XAllocWMHints(); if (hints) { hints->flags = IconPixmapHint; hints->icon_pixmap = XCreateBitmapFromData(xdpy, xwin, gs_l_xbm_bits, gs_l_xbm_width, gs_l_xbm_height); if (hints->icon_pixmap) { XSetWMHints(xdpy, xwin, hints); } XFree(hints); } }