wm.c
changeset 3 e969f3575b7a
parent 2 a79188fe4a40
child 5 e5018cae273f
equal deleted inserted replaced
2:a79188fe4a40 3:e969f3575b7a
    11 #include <X11/Xatom.h>
    11 #include <X11/Xatom.h>
    12 #include <X11/Xproto.h>
    12 #include <X11/Xproto.h>
    13 
    13 
    14 #include "wm.h"
    14 #include "wm.h"
    15 
    15 
       
    16 /* X structs */
    16 Display *dpy;
    17 Display *dpy;
    17 Window root;
    18 Window root;
    18 XRectangle rect;
    19 XRectangle rect;
    19 int screen, sel_screen;
    20 Pixmap pmap;
    20 Atom wm_atom[WMLast];
    21 Atom wm_atom[WMLast];
    21 Atom net_atom[NetLast];
    22 Atom net_atom[NetLast];
    22 Cursor cursor[CurLast];
    23 Cursor cursor[CurLast];
       
    24 
       
    25 int screen, sel_screen;
    23 unsigned int kmask, numlock_mask;
    26 unsigned int kmask, numlock_mask;
    24 Pixmap pmap;
    27 
       
    28 /* draw structs */
       
    29 Brush brush = {0};
    25 
    30 
    26 enum { WM_PROTOCOL_DELWIN = 1 };
    31 enum { WM_PROTOCOL_DELWIN = 1 };
    27 
    32 
    28 static Bool other_wm_running;
    33 static Bool other_wm_running;
    29 static int (*x_error_handler) (Display *, XErrorEvent *);
    34 static int (*x_error_handler) (Display *, XErrorEvent *);
   206 	/* check if another WM is already running */
   211 	/* check if another WM is already running */
   207 	other_wm_running = False;
   212 	other_wm_running = False;
   208 	XSetErrorHandler(startup_error_handler);
   213 	XSetErrorHandler(startup_error_handler);
   209 	/* this causes an error if some other WM is running */
   214 	/* this causes an error if some other WM is running */
   210 	XSelectInput(dpy, root, SubstructureRedirectMask);
   215 	XSelectInput(dpy, root, SubstructureRedirectMask);
   211 	XSync(dpy, False);
   216 	XFlush(dpy);
   212 
   217 
   213 	if(other_wm_running)
   218 	if(other_wm_running)
   214 		error("gridwm: another window manager is already running\n");
   219 		error("gridwm: another window manager is already running\n");
   215 
   220 
   216 	rect.x = rect.y = 0;
   221 	rect.x = rect.y = 0;
   244 
   249 
   245 	wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
   250 	wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
   246 	wa.cursor = cursor[CurNormal];
   251 	wa.cursor = cursor[CurNormal];
   247 	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
   252 	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
   248 
   253 
       
   254 	/* style */
       
   255 	loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
       
   256 	loadfont(dpy, &brush.font, FONT);
       
   257 
   249 	scan_wins();
   258 	scan_wins();
   250 
   259 
   251 	cleanup();
   260 	cleanup();
   252 	XCloseDisplay(dpy);
   261 	XCloseDisplay(dpy);
   253 
   262