#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xft/Xft.h>
+#include <X11/extensions/Xinerama.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
XSelectInput(x->display, x->self, evmask);
}
+static void x11_mkdialog(XConf* x, int width, int height, int evmask) {
+ x11_mkwin(x, width, height, evmask);
+ Atom WindowType = XInternAtom(x->display, "_NET_WM_WINDOW_TYPE", False);
+ Atom DialogType = XInternAtom(x->display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+ XChangeProperty(x->display, x->self, WindowType, XA_ATOM, 32, PropModeReplace, (unsigned char*)&DialogType, 1);
+}
+
+static int x11_getptr(XConf* x, int* ptrx, int* ptry) {
+ Window root = 0, child = 0;
+ int winx = 0, winy = 0, mask = 0;
+ return XQueryPointer(x->display, x->self, &root, &child, ptrx, ptry, &winx, &winy, (unsigned int*)&mask);
+}
+
+static void x11_centerwin(XConf* x) {
+ int ptrx = 0, ptry = 0;
+ (void)x11_getptr(x, &ptrx, &ptry);
+ int nscreens = 0;
+ XineramaScreenInfo* p_screens = XineramaQueryScreens(x->display, &nscreens);
+ for (int i = 0; i < nscreens; i++) {
+ int minx = p_screens[i].x_org,
+ maxx = p_screens[i].x_org + p_screens[i].width,
+ miny = p_screens[i].y_org,
+ maxy = p_screens[i].y_org + p_screens[i].height;
+ if (minx <= ptrx && ptrx <= maxx && miny <= ptry && ptry <= maxy) {
+ XMoveWindow(x->display, x->self,
+ p_screens[i].width/2 - x->width/2,
+ p_screens[i].height/2 - x->height/2);
+ break;
+ }
+ }
+}
+
static void x11_init_gc(XConf* x) {
/* set input methods */
if ((x->xim = XOpenIM(x->display, 0, 0, 0)))