From 7c2f53a4b2444013666bdc880f85df22edb2f284 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 19 Nov 2011 08:15:33 +0100 Subject: [PATCH] Fix focus flick, event calling too much times client_focus, and remove useless functions --- src/client.c | 14 ++++++++------ src/client.h | 49 ++----------------------------------------------- src/event.c | 23 ++++------------------- src/tag.c | 7 ++----- 4 files changed, 16 insertions(+), 77 deletions(-) diff --git a/src/client.c b/src/client.c index 7994d08..b863fff 100644 --- a/src/client.c +++ b/src/client.c @@ -325,7 +325,7 @@ client_grabbuttons(struct client *c, bool focused) #define _XTEXT() \ if((xt = ((f >> 1) - (w >> 1) - PAD)) < 0) \ - xt = 0; + xt = 1; void client_frame_update(struct client *c, struct colpair *cp) { @@ -335,7 +335,7 @@ client_frame_update(struct client *c, struct colpair *cp) if(c->titlebar && c->title) { struct client *cc; - int f, n = 1, xt, w = draw_textw(c->theme, c->title); + int y, f, n = 1, xt, w = draw_textw(c->theme, c->title); c->titlebar->fg = cp->fg; c->titlebar->bg = cp->bg; @@ -344,15 +344,17 @@ client_frame_update(struct client *c, struct colpair *cp) if(cc->tabmaster == c) ++n; + f = (c->geo.w - (c->border * (n - 1))) / n; + barwin_reparent(c->titlebar, c->frame); barwin_move(c->titlebar, 0, 0); - barwin_resize(c->titlebar, (f = (c->geo.w / n)), c->tbarw); + barwin_resize(c->titlebar, f, c->tbarw); barwin_refresh_color(c->titlebar); _XTEXT(); draw_text(c->titlebar->dr, c->theme, xt, - TEXTY(c->theme, c->tbarw), cp->fg, c->title); + (y = TEXTY(c->theme, c->tbarw)), cp->fg, c->title); barwin_refresh(c->titlebar); /* Tabbing case, multiple titlebar in frame */ @@ -375,11 +377,11 @@ client_frame_update(struct client *c, struct colpair *cp) barwin_refresh_color(cc->titlebar); draw_text(cc->titlebar->dr, c->theme, xt, - TEXTY(c->theme, c->tbarw), c->ncol.fg, cc->title); + y, c->ncol.fg, cc->title); barwin_refresh(cc->titlebar); - x += f + 1; + x += f + c->border; } } } diff --git a/src/client.h b/src/client.h index 77a86e8..712f48a 100644 --- a/src/client.h +++ b/src/client.h @@ -89,20 +89,9 @@ client_prev(struct client *c) } static inline struct client* -clien_tab_next(struct client *c) +client_tab_next(struct client *c) { - struct client *cc; - - if(c->flags & (CLIENT_TABBED | CLIENT_TABMASTER)) - SLIST_FOREACH(cc, &c->tag->clients, tnext) - { - if(c == cc) - continue; - if(c->tabmaster == c || c->tabmaster == c->tabmaster) - return cc; - } - - return NULL; + return (c->flags & CLIENT_TABBED ? c->tabmaster : c); } static inline void @@ -119,38 +108,4 @@ client_unmap(struct client *c) ewmh_set_wm_state(c->win, IconicState); } -static inline void -client_tab_slave(struct client *c) -{ - struct geo g = { W->xmaxw + c->geo.x, W->xmaxh + c->geo.y, c->geo.w, c->geo.h }; - - c->flags &= ~CLIENT_TABMASTER; - c->flags |= CLIENT_TABBED; - - c->geo = c->tgeo = g; - - client_unmap(c); -} - -static inline void -client_tab_master(struct client *c) -{ - struct client *cc; - - c->flags |= CLIENT_TABMASTER; - c->flags &= ~CLIENT_TABBED; - - client_moveresize(c, &c->tabmaster->geo); - client_map(c); - client_tab_slave(c->tabmaster); - - /* Parent tabbed client take new master as tabmaster */ - SLIST_FOREACH(cc, &c->tag->clients, tnext) - if(cc->tabmaster == c->tabmaster) - cc->tabmaster = c; - - c->tabmaster->tabmaster = c; - c->tabmaster = NULL; -} - #endif /* CLIENT_H */ diff --git a/src/event.c b/src/event.c index 6a514be..be0af7b 100644 --- a/src/event.c +++ b/src/event.c @@ -51,7 +51,7 @@ event_enternotify(XEvent *e) { if(c->flags & CLIENT_IGNORE_ENTER) c->flags ^= CLIENT_IGNORE_ENTER; - else + else if(c != W->client) client_focus(c); } } @@ -112,7 +112,9 @@ event_destroynotify(XEvent *e) static void event_focusin(XEvent *e) { - if(W->client && e->xfocus.window != W->client->win) + if(W->client + && e->xfocus.window != W->client->win + && e->xfocus.window != W->client->frame) client_focus(W->client); } @@ -188,22 +190,6 @@ event_unmapnotify(XEvent *e) client_remove(c); } -static void -event_motionnotify(XEvent *e) -{ - XMotionEvent *ev = &e->xmotion; - struct client *c; - - /* - * Check client window and tag frame to get focused - * window with mouse motion - */ - if((c = client_gb_win(ev->subwindow)) - || (c = client_gb_frame(ev->subwindow))) - if(c != c->tag->sel) - client_focus(c); -} - static void event_keypress(XEvent *e) { @@ -259,7 +245,6 @@ event_init(void) /*event_handle[MapNotify] = event_mapnotify;*/ event_handle[MapRequest] = event_maprequest; event_handle[MappingNotify] = event_mappingnotify; - event_handle[MotionNotify] = event_motionnotify; event_handle[PropertyNotify] = event_propertynotify; /*event_handle[ReparentNotify] = event_reparentnotify;*/ /*event_handle[SelectionClear] = event_selectionclearevent;*/ diff --git a/src/tag.c b/src/tag.c index 48faa35..afe999b 100644 --- a/src/tag.c +++ b/src/tag.c @@ -57,10 +57,7 @@ tag_screen(struct screen *s, struct tag *t) if(!(c->flags & CLIENT_TABBED)) client_map(c); - if(t->sel->flags & CLIENT_TABBED) - t->sel = t->sel->tabmaster; - - client_focus(t->sel); + client_focus( client_tab_next(t->sel)); } s->seltag = t; @@ -89,7 +86,7 @@ tag_client(struct tag *t, struct client *c) SLIST_REMOVE(&c->tag->clients, c, client, tnext); if(c->tag->sel == c || W->client == c) - client_focus(client_next(c)); + client_focus( client_tab_next( client_next(c))); } c->flags &= ~CLIENT_RULED;