mirror of git://git.suckless.org/dwm
changed how manage client works
This commit is contained in:
parent
16c67f32d6
commit
005362043d
51
client.c
51
client.c
|
@ -3,6 +3,7 @@
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
|
@ -36,10 +37,10 @@ update_client_name(Client *c)
|
||||||
XFree(name.value);
|
XFree(name.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
void
|
||||||
create_client(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c, **l;
|
||||||
XSetWindowAttributes twa;
|
XSetWindowAttributes twa;
|
||||||
long msize;
|
long msize;
|
||||||
|
|
||||||
|
@ -68,24 +69,44 @@ create_client(Window w, XWindowAttributes *wa)
|
||||||
DefaultDepth(dpy, screen), CopyFromParent,
|
DefaultDepth(dpy, screen), CopyFromParent,
|
||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
XFlush(dpy);
|
|
||||||
|
|
||||||
#if 0
|
for(l=&clients; *l; l=&(*l)->next);
|
||||||
for(t=&client, i=0; *t; t=&(*t)->next, i++);
|
c->next = *l; /* *l == nil */
|
||||||
c->next = *t; /* *t == nil */
|
*l = c;
|
||||||
*t = c;
|
|
||||||
#endif
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
manage(Client *c)
|
|
||||||
{
|
|
||||||
XMapRaised(dpy, c->win);
|
XMapRaised(dpy, c->win);
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dummy_error_handler(Display *dpy, XErrorEvent *error)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unmanage(Client *c)
|
||||||
|
{
|
||||||
|
Client **l;
|
||||||
|
|
||||||
|
XGrabServer(dpy);
|
||||||
|
XSetErrorHandler(dummy_error_handler);
|
||||||
|
|
||||||
|
XUnmapWindow(dpy, c->win);
|
||||||
|
XDestroyWindow(dpy, c->title);
|
||||||
|
|
||||||
|
for(l=&clients; *l && *l != c; l=&(*l)->next);
|
||||||
|
eassert(*l == c);
|
||||||
|
*l = c->next;
|
||||||
|
free(c);
|
||||||
|
|
||||||
|
XFlush(dpy);
|
||||||
|
XSetErrorHandler(error_handler);
|
||||||
|
XUngrabServer(dpy);
|
||||||
|
/*flush_masked_events(EnterWindowMask); ? */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getclient(Window w)
|
getclient(Window w)
|
||||||
{
|
{
|
||||||
|
|
14
event.c
14
event.c
|
@ -159,12 +159,8 @@ maprequest(XEvent *e)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(!client_of_win(ev->window))*/
|
if(!getclient(ev->window))
|
||||||
/*manage(create_client(ev->window, &wa));*/
|
manage(ev->window, &wa);
|
||||||
XMapRaised(dpy, ev->window);
|
|
||||||
XMoveResizeWindow(dpy, ev->window, rect.x, rect.y, rect.width, rect.height - barrect.height);
|
|
||||||
XSetInputFocus(dpy, ev->window, RevertToPointerRoot, CurrentTime);
|
|
||||||
XFlush(dpy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -185,11 +181,9 @@ propertynotify(XEvent *e)
|
||||||
static void
|
static void
|
||||||
unmapnotify(XEvent *e)
|
unmapnotify(XEvent *e)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XUnmapEvent *ev = &e->xunmap;
|
XUnmapEvent *ev = &e->xunmap;
|
||||||
|
|
||||||
if((c = client_of_win(ev->window)))
|
if((c = getclient(ev->window)))
|
||||||
destroy_client(c);
|
unmanage(c);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
9
wm.c
9
wm.c
|
@ -20,19 +20,18 @@ Atom net_atom[NetLast];
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
XRectangle rect, barrect;
|
XRectangle rect, barrect;
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
Client *clients = NULL;
|
|
||||||
|
|
||||||
char *bartext, tag[256];
|
char *bartext, tag[256];
|
||||||
int screen, sel_screen;
|
int screen, sel_screen;
|
||||||
|
|
||||||
/* draw structs */
|
|
||||||
Brush brush = {0};
|
Brush brush = {0};
|
||||||
|
Client *clients = NULL;
|
||||||
|
|
||||||
enum { WM_PROTOCOL_DELWIN = 1 };
|
enum { WM_PROTOCOL_DELWIN = 1 };
|
||||||
|
|
||||||
static Bool other_wm_running;
|
static Bool other_wm_running;
|
||||||
static int (*x_error_handler) (Display *, XErrorEvent *);
|
|
||||||
static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
|
static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
|
||||||
|
static int (*x_error_handler) (Display *, XErrorEvent *);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage()
|
usage()
|
||||||
|
@ -56,7 +55,7 @@ scan_wins()
|
||||||
if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||||
continue;
|
continue;
|
||||||
if(wa.map_state == IsViewable)
|
if(wa.map_state == IsViewable)
|
||||||
manage(create_client(wins[i], &wa));
|
manage(wins[i], &wa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(wins)
|
if(wins)
|
||||||
|
@ -69,7 +68,7 @@ scan_wins()
|
||||||
* Other types of errors call Xlib's default error handler, which
|
* Other types of errors call Xlib's default error handler, which
|
||||||
* calls exit().
|
* calls exit().
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
error_handler(Display *dpy, XErrorEvent *error)
|
error_handler(Display *dpy, XErrorEvent *error)
|
||||||
{
|
{
|
||||||
if(error->error_code == BadWindow
|
if(error->error_code == BadWindow
|
||||||
|
|
5
wm.h
5
wm.h
|
@ -65,8 +65,8 @@ extern void run(char *arg);
|
||||||
extern void quit(char *arg);
|
extern void quit(char *arg);
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
extern Client *create_client(Window w, XWindowAttributes *wa);
|
extern void manage(Window w, XWindowAttributes *wa);
|
||||||
extern void manage(Client *c);
|
void unmanage(Client *c);
|
||||||
extern Client * getclient(Window w);
|
extern Client * getclient(Window w);
|
||||||
|
|
||||||
/* key.c */
|
/* key.c */
|
||||||
|
@ -74,3 +74,4 @@ extern void update_keys();
|
||||||
extern void keypress(XEvent *e);
|
extern void keypress(XEvent *e);
|
||||||
|
|
||||||
/* wm.c */
|
/* wm.c */
|
||||||
|
extern int error_handler(Display *dpy, XErrorEvent *error);
|
||||||
|
|
Loading…
Reference in New Issue