From fbb36877dc4982b621ea4215038f1f1af13ac331 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Thu, 8 Apr 2010 12:33:52 +0200 Subject: [PATCH] EWMH: Improve _NET_WM_STATE_FULLSCREEN management --- src/ewmh.c | 9 ++++----- src/launcher.c | 20 ++++++++++++-------- src/structs.h | 3 ++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/ewmh.c b/src/ewmh.c index e881d87..f424bea 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -301,7 +301,7 @@ ewmh_manage_net_wm_state(long data_l[], Client *c) /* Manage _NET_WM_STATE_FULLSCREEN */ if(data_l[1] == net_atom[net_wm_state_fullscreen]) { - if(data_l[0] == _NET_WM_STATE_ADD && !(c->flags & FSSFlag)) + if(data_l[0] == _NET_WM_STATE_ADD) { c->screen = screen_get_with_geo(c->geo.x, c->geo.y); client_unmap(c); @@ -318,17 +318,16 @@ ewmh_manage_net_wm_state(long data_l[], Client *c) c->ogeo = c->geo; c->flags |= (FSSFlag | MaxFlag); - - client_raise(c); - client_focus(c); } - else if(data_l[0] == _NET_WM_STATE_REMOVE && (c->flags & FSSFlag)) + else if(data_l[0] == _NET_WM_STATE_REMOVE) { c->flags &= ~(FSSFlag | MaxFlag); client_map(c); XReparentWindow(dpy, c->win, c->frame, BORDH, TBARH); client_moveresize(c, c->tmp_geo, False); } + XRaiseWindow(dpy, c->win); + client_focus(c); } /* Manage _NET_WM_STATE_DEMANDS_ATTENTION */ else if(data_l[1] == net_atom[net_wm_state_demands_attention]) diff --git a/src/launcher.c b/src/launcher.c index 394bf05..208f7ff 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -76,8 +76,12 @@ launcher_execute(Launcher *launcher) /* First draw of the cursor */ XSetForeground(dpy, gc, getcolor(infobar[selscreen].bar->fg)); - XDrawLine(dpy, bw->dr, gc, textw(launcher->prompt) + textw(" "), - 2, textw(launcher->prompt) + textw(" "), INFOBARH - 4); + /*XDrawLine(dpy, bw->dr, gc, 1 + textw(launcher->prompt) + textw(" "), + , 1 + textw(launcher->prompt) + textw(" "), INFOBARH - 4); + */ + XDrawLine(dpy, bw->dr, gc, + 1 + textw(launcher->prompt) + textw(" ") + textw(buf), 2, + 1 + textw(launcher->prompt) + textw(" ") + textw(buf), INFOBARH - 4); barwin_refresh(bw); @@ -111,14 +115,14 @@ launcher_execute(Launcher *launcher) { if(histpos >= launcher->nhisto) histpos = 0; - strcpy(buf, launcher->histo[launcher->nhisto - ++histpos]); + strncpy(buf, launcher->histo[launcher->nhisto - ++histpos], sizeof(buf)); pos = strlen(buf); } break; case XK_Down: if(launcher->nhisto && histpos > 0 && histpos < launcher->nhisto) { - strcpy(buf, launcher->histo[launcher->nhisto - --histpos]); + strncpy(buf, launcher->histo[launcher->nhisto - --histpos], sizeof(buf)); pos = strlen(buf); } break; @@ -126,15 +130,15 @@ launcher_execute(Launcher *launcher) case XK_Return: spawn("%s %s", launcher->command, buf); /* Histo */ - if(launcher->nhisto + 1 > 128) + if(launcher->nhisto + 1 > HISTOLEN) { for(i = launcher->nhisto - 1; i > 1; --i) - strcpy(launcher->histo[i], launcher->histo[i - 1]); + strncpy(launcher->histo[i], launcher->histo[i - 1], sizeof(launcher->histo[i])); launcher->nhisto = 0; } /* Store in histo array */ - strcpy(launcher->histo[launcher->nhisto++], buf); + strncpy(launcher->histo[launcher->nhisto++], buf, sizeof(buf)); my_guitar_gently_wheeps = 0; break; @@ -195,7 +199,7 @@ launcher_execute(Launcher *launcher) default: lastwastab = False; - strncat(buf, tmp, sizeof(buf)); + strncat(buf, tmp, sizeof(tmp)); ++pos; break; } diff --git a/src/structs.h b/src/structs.h index 6683788..112b1e3 100644 --- a/src/structs.h +++ b/src/structs.h @@ -38,6 +38,7 @@ #define NBUTTON 8 #define MAXTAG 36 #define NUM_OF_LAYOUT 10 +#define HISTOLEN 128 /* Clients flags definition */ #define FreeFlag (1 << 1) @@ -301,7 +302,7 @@ typedef struct char *name; char *prompt; char *command; - char histo[128][512]; + char histo[HISTOLEN][512]; uint nhisto; } Launcher;