change codename
[awesome.git] / banning.c
blobdf54ef94ff24e13616be07899ba6eed71d8ba12e
1 /*
2 * banning.c - client banning management
4 * Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "banning.h"
23 #include "client.h"
24 #include "titlebar.h"
25 #include "screen.h"
27 /** Reban windows following current selected tags.
28 * \param screen The screen to arrange.
30 void
31 banning_need_update(screen_t *screen)
33 /* We update the complete banning only once per main loop to avoid
34 * excessive updates... */
35 screen->need_lazy_banning = true;
37 /* But if a client will be banned in our next update we unfocus it now. */
38 foreach(_c, globalconf.clients)
40 client_t *c = *_c;
42 /* we don't touch other screens windows */
43 if(!client_isvisible(c, screen) && c->screen == screen)
44 client_ban_unfocus(c);
48 static void
49 reban(screen_t *screen)
51 if (!screen->need_lazy_banning)
52 return;
54 screen->need_lazy_banning = false;
56 client_ignore_enterleave_events();
58 foreach(_c, globalconf.clients)
60 client_t *c = *_c;
62 /* Restore titlebar before client, so geometry is ok again. */
63 if(titlebar_isvisible(c, screen))
64 titlebar_unban(c->titlebar);
66 if(client_isvisible(c, screen))
67 client_unban(c);
70 /* Some people disliked the short flicker of background, so we first unban everything.
71 * Afterwards we ban everything we don't want. This should avoid that. */
72 foreach(_c, globalconf.clients)
74 client_t *c = *_c;
76 if(!titlebar_isvisible(c, screen) && c->screen == screen)
77 titlebar_ban(c->titlebar);
79 /* we don't touch other screens windows */
80 if(!client_isvisible(c, screen) && c->screen == screen)
81 client_ban(c);
84 client_restore_enterleave_events();
87 /** Check all screens if they need to rebanned
89 void
90 banning_refresh(void)
92 foreach(screen, globalconf.screens)
93 reban(screen);
96 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80