From 07343c21f1a8bc14d626f4664e00afa95ab4308a Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 2 Mar 2007 23:40:24 -0500 Subject: [PATCH] Improved fullscreen support (far from finished). Minor focus improvements. Changed copyright info. --- Makefile | 1 + TODO | 1 - area.c | 1 + bar.c | 1 + client.c | 85 ++++++++++++++++++++++++++++------------------------ column.c | 1 + event.c | 90 +++++++++++++++++++++++++++++--------------------------- frame.c | 11 ++++--- main.c | 3 +- mouse.c | 3 +- view.c | 13 ++++---- 11 files changed, 112 insertions(+), 98 deletions(-) diff --git a/Makefile b/Makefile index 6f5e1d89..1bc529ce 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ # window manager improved 2 - window manager improved 2 # (C)opyright MMVI Anselm R. Garbe +# (C)opyright MMVI-MMVII Kris Maglione .POSIX: include config.mk diff --git a/TODO b/TODO index 4629ecf0..c0ed7f60 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ 3.6 * Working grab boxes -* Border based resizals * Grow(and shrink?) ctl commands * Switch to mk for building diff --git a/area.c b/area.c index f1dbac76..1a12a650 100644 --- a/area.c +++ b/area.c @@ -1,4 +1,5 @@ /* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" diff --git a/bar.c b/bar.c index 6b1d868f..0e45099a 100644 --- a/bar.c +++ b/bar.c @@ -1,4 +1,5 @@ /* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" diff --git a/client.c b/client.c index 84fb0889..0a02e29c 100644 --- a/client.c +++ b/client.c @@ -1,4 +1,5 @@ /* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" @@ -84,6 +85,51 @@ create_client(Window w, XWindowAttributes *wa) { return c; } +static int +dummy_error_handler(Display *dpy, XErrorEvent *error) { + return 0; +} + +void +destroy_client(Client *c) { + char *dummy; + Client **tc; + XEvent ev; + + XGrabServer(blz.dpy); + /* In case the client is already unmapped */ + XSetErrorHandler(dummy_error_handler); + + for(tc=&client; *tc; tc=&(*tc)->next) + if(*tc == c) { + *tc = c->next; + break; + } + + dummy = nil; + update_client_views(c, &dummy); + + unmap_client(c, WithdrawnState); + gravitate_client(c, True); + reparent_client(c, blz.root, c->rect.x, c->rect.y); + + XFreeGC(blz.dpy, c->gc); + XDestroyWindow(blz.dpy, c->framewin); + XSync(blz.dpy, False); + + XSetErrorHandler(wmii_error_handler); + XUngrabServer(blz.dpy); + flush_masked_events(EnterWindowMask); + + while(XCheckMaskEvent(blz.dpy, StructureNotifyMask, &ev)) + if(ev.type != UnmapNotify || ev.xunmap.window != c->win) + if(handler[ev.type]) + handler[ev.type](&ev); + + write_event("DestroyClient 0x%x\n", c->win); + free(c); +} + void manage_client(Client *c) { XTextProperty tags = { 0 }; @@ -472,45 +518,6 @@ gravitate_client(Client *c, Bool invert) { c->rect.y += dy; } -static int -dummy_error_handler(Display *dpy, XErrorEvent *error) { - return 0; -} - -void -destroy_client(Client *c) { - char *dummy; - Client **tc; - - XGrabServer(blz.dpy); - /* In case the client is already unmapped */ - XSetErrorHandler(dummy_error_handler); - - for(tc=&client; *tc; tc=&(*tc)->next) - if(*tc == c) { - *tc = c->next; - break; - } - - dummy = nil; - update_client_views(c, &dummy); - - unmap_client(c, WithdrawnState); - gravitate_client(c, True); - reparent_client(c, blz.root, c->rect.x, c->rect.y); - - XFreeGC(blz.dpy, c->gc); - XDestroyWindow(blz.dpy, c->framewin); - XSync(blz.dpy, False); - - XSetErrorHandler(wmii_error_handler); - XUngrabServer(blz.dpy); - flush_masked_events(EnterWindowMask); - - write_event("DestroyClient 0x%x\n", c->win); - free(c); -} - void apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign sticky) { XSizeHints *s; diff --git a/column.c b/column.c index f1a999b4..dd146a11 100644 --- a/column.c +++ b/column.c @@ -1,4 +1,5 @@ /* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" diff --git a/event.c b/event.c index 34258412..964a808e 100644 --- a/event.c +++ b/event.c @@ -1,4 +1,5 @@ /* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" @@ -102,13 +103,7 @@ configurerequest(XEvent *e) { if(c) { f = c->sel; - if(0 && verbose) - fprintf(stderr, "Configure: %s\n\ta: x=%d y=%d w=%d h=%d\n", - c->name, c->rect.x, c->rect.y, c->rect.width, c->rect.height); gravitate_client(c, True); - if(0 && verbose) - fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n", - c->rect.x, c->rect.y, c->rect.width, c->rect.height); if(ev->value_mask & CWX) c->rect.x = ev->x; if(ev->value_mask & CWY) @@ -119,13 +114,17 @@ configurerequest(XEvent *e) { c->rect.height = ev->height; if(ev->value_mask & CWBorderWidth) c->border = ev->border_width; - if(0 && verbose) - fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n", - c->rect.x, c->rect.y, c->rect.width, c->rect.height); gravitate_client(c, False); - if(0 && verbose) - fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n", - c->rect.x, c->rect.y, c->rect.width, c->rect.height); + + if((c->rect.height == screen->rect.height) + &&(c->rect.width == screen->rect.width)) { + c->fullscreen = True; + if(c->sel) { + if(!c->sel->area->floating) + send_to_area(c->sel->view->area, c->sel); + restack_view(c->sel->view); + } + } if(c->sel->area->floating) frect=&c->sel->rect; @@ -137,11 +136,8 @@ configurerequest(XEvent *e) { frect->x -= def.border; frect->width += 2 * def.border; frect->height += frame_delta_h(); - if(0 && verbose) - fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n", - frect->x, frect->y, frect->width, frect->height); - if(c->sel->area->floating) + if(c->sel->area->floating || c->fullscreen) resize_client(c, frect); else configure_client(c); @@ -203,6 +199,17 @@ leavenotify(XEvent *e) { } } +void +print_focus(Client *c, char *to) { + if(verbose) { + fprintf(stderr, "screen->focus: %p => %p\n", + screen->focus, c); + fprintf(stderr, "\t%s => %s\n", + screen->focus ? screen->focus->name : "", + to); + } +} + static void focusin(XEvent *e) { Client *c, *old; @@ -216,6 +223,7 @@ focusin(XEvent *e) { if(!((ev->detail == NotifyNonlinear) ||(ev->detail == NotifyNonlinearVirtual) + ||(ev->detail == NotifyVirtual) ||(ev->detail == NotifyInferior) ||(ev->detail == NotifyAncestor))) return; @@ -225,29 +233,24 @@ focusin(XEvent *e) { c = client_of_win(ev->window); old = screen->focus; if(c) { - if(verbose) { - fprintf(stderr, "screen->focus: %p => %p\n", screen->focus, c); - fprintf(stderr, "\t%s => %s\n", (screen->focus ? screen->focus->name : nil), - c->name); - } + print_focus(c, c->name); if(ev->mode == NotifyGrab) screen->hasgrab = c; screen->focus = c; - update_client_grab(c); - if(c->sel) - draw_frame(c->sel); - if(old && old->sel) - draw_frame(old->sel); - }else if(ev->window == screen->barwin) { - if(verbose) { - fprintf(stderr, "screen->focus: %p => %p\n", screen->focus, c); - fprintf(stderr, "\t%s => %s\n", (screen->focus ? screen->focus->name : nil), - ""); + if(c != old) { + update_client_grab(c); + if(c->sel) + draw_frame(c->sel); + if(old && old->sel) + draw_frame(old->sel); } + }else if(ev->window == screen->barwin) { + print_focus(nil, ""); screen->focus = nil; }else if(ev->mode == NotifyGrab) { - c = screen->focus; - if(c) { + if((c = screen->focus)) { + /* Some unmanaged window has focus */ + print_focus(&c_magic, ""); screen->focus = &c_magic; if(c->sel) draw_frame(c->sel); @@ -269,16 +272,20 @@ focusout(XEvent *e) { c = client_of_win(ev->window); if(c) { if(ev->mode == NotifyWhileGrabbed) { - if(screen->focus && screen->hasgrab != screen->focus) + if((screen->focus) + &&(screen->hasgrab != screen->focus)) screen->hasgrab = screen->focus; if(screen->hasgrab == c) return; + }else if(ev->mode != NotifyGrab) { + if(screen->focus == c) { + print_focus(&c_magic, ""); + screen->focus = &c_magic; + } + update_client_grab(c); + if(c->sel) + draw_frame(c->sel); } - if(screen->focus == c) - screen->focus = &c_magic; - update_client_grab(c); - if(c->sel) - draw_frame(c->sel); } } @@ -298,7 +305,6 @@ expose(XEvent *e) { static void keypress(XEvent *e) { - XEvent me; XKeyEvent *ev = &e->xkey; Frame *f; KeySym k = 0; @@ -315,9 +321,6 @@ keypress(XEvent *e) { buf[n] = 0; } else { - while(XCheckMaskEvent(blz.dpy, FocusChangeMask, &me)) - if(me.xfocus.mode != NotifyGrab) - handler[me.type](&me); kpress(blz.root, ev->state, (KeyCode) ev->keycode); } } @@ -376,6 +379,7 @@ unmapnotify(XEvent *e) { if(!c->unmapped--) destroy_client(c); } + void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, [ButtonRelease] = buttonrelease, diff --git a/frame.c b/frame.c index 7fe985d6..1ffd4bb0 100644 --- a/frame.c +++ b/frame.c @@ -1,4 +1,4 @@ -/* (C)opyright MMIV-MMVI Anselm R. Garbe +/* (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" @@ -87,9 +87,6 @@ resize_frame(Frame *f, XRectangle *r) { c = f->client; stickycorner = get_sticky(&f->rect, r); - if(c->fullscreen) - send_to_area(f->area->view->area, f); - f->rect = *r; f->crect = *r; apply_sizehints(c, &f->crect, f->area->floating, True, stickycorner); @@ -118,10 +115,12 @@ resize_frame(Frame *f, XRectangle *r) { if(f->area->floating) { if(c->fullscreen) { + f->crect.width = screen->rect.width; + f->crect.height = screen->rect.height; + f->rect = f->crect; + client2frame(&f->rect); f->rect.x = -def.border; f->rect.y = -labelh(&def.font); - f->rect.width = screen->rect.width + 2 * def.border; - f->rect.height = screen->rect.height + frame_delta_h(); }else check_frame_constraints(&f->rect); } diff --git a/main.c b/main.c index 6bfaa767..5c28474e 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,5 @@ /* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" @@ -20,7 +21,7 @@ static Bool check_other_wm; static int (*x_error_handler) (Display *, XErrorEvent *); -static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n"; +static char version[] = "wmiiwm - " VERSION ", (C)opyright MMVI-MMVII Kris Maglione\n"; static struct sigaction sa; static void diff --git a/mouse.c b/mouse.c index b49dda40..e6c43907 100644 --- a/mouse.c +++ b/mouse.c @@ -1,5 +1,4 @@ -/* (C)opyright MMIV-MMVI Anselm R. Garbe - * (C)opyright MMVI Kris Maglione +/* (C)opyright MMVI Kris Maglione * See LICENSE file for license details. */ #include "wmii.h" diff --git a/view.c b/view.c index ca6d7577..f24285cf 100644 --- a/view.c +++ b/view.c @@ -1,5 +1,5 @@ -/* - * (C)opyright MMIV-MMVI Anselm R. Garbe +/* (C)opyright MMIV-MMVI Anselm R. Garbe + * (C)opyright MMVI-MMVII Kris Maglione * See LICENSE file for license details. */ @@ -171,7 +171,8 @@ restack_view(View *v) { i = 0; n = 0; - for(c=client; c; c=c->next, i++); + for(c=client; c; c=c->next) + i++; if(i >= winssz) { winssz = 2 * i; wins = erealloc(wins, sizeof(Window) * winssz); @@ -179,17 +180,17 @@ restack_view(View *v) { for(f=v->area->stack; f; f=f->snext) if(f->client->fullscreen) - wins[n++] = f->client->framewin;; + wins[n++] = f->client->framewin; wins[n++] = screen->barwin; for(f=v->area->stack; f; f=f->snext) if(!f->client->fullscreen) - wins[n++] = f->client->framewin;; + wins[n++] = f->client->framewin; for(a=v->area->next; a; a=a->next) { if(a->frame) { wins[n++] = a->sel->client->framewin; for(f=a->frame; f; f=f->anext) if(f != a->sel) - wins[n++] = f->client->framewin;; + wins[n++] = f->client->framewin; } } if(n)