Improved fullscreen support (far from finished). Minor focus improvements. Changed copyright info.

This commit is contained in:
Kris Maglione 2007-03-02 23:40:24 -05:00
parent 4ecc7f5ea6
commit 07343c21f1
11 changed files with 112 additions and 98 deletions

View File

@ -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

1
TODO
View File

@ -1,6 +1,5 @@
3.6
* Working grab boxes
* Border based resizals
* Grow(and shrink?) ctl commands
* Switch to mk for building

1
area.c
View File

@ -1,4 +1,5 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details.
*/
#include "wmii.h"

1
bar.c
View File

@ -1,4 +1,5 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details.
*/
#include "wmii.h"

View File

@ -1,4 +1,5 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* 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;

View File

@ -1,4 +1,5 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details.
*/
#include "wmii.h"

90
event.c
View File

@ -1,4 +1,5 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* 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 : "<nil>",
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),
"<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, "<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, "<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, "<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,

11
frame.c
View File

@ -1,4 +1,4 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
/* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* 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);
}

3
main.c
View File

@ -1,4 +1,5 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* 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

View File

@ -1,5 +1,4 @@
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI Kris Maglione <fbsdaemon@gmail.com>
/* (C)opyright MMVI Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details.
*/
#include "wmii.h"

13
view.c
View File

@ -1,5 +1,5 @@
/*
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
* 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)