forked from awesomeWM/awesome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanning.c
More file actions
74 lines (63 loc) · 2.63 KB
/
Copy pathbanning.c
File metadata and controls
74 lines (63 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* banning.c - ewindow banning management
*
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "banning.h"
#include "objects/client.h"
#include "objects/tag.h"
/** True if the banning on this screen needs to be updated */
static bool need_lazy_banning;
static int
banning_need_update(lua_State *L)
{
/* We update the complete banning only once per main loop to avoid
* excessive updates... */
need_lazy_banning = true;
/* But if an ewindow will be banned in our next update we unfocus it now. */
foreach(ewindow, _G_ewindows)
if(ewindow_isvisible(*ewindow))
window_ban_unfocus((window_t *) *ewindow);
return 0;
}
void
banning_init(lua_State *L)
{
luaA_class_connect_signal(L, (lua_class_t *) &ewindow_class, "property::minimized", banning_need_update);
luaA_class_connect_signal(L, (lua_class_t *) &ewindow_class, "property::visible", banning_need_update);
luaA_class_connect_signal(L, (lua_class_t *) &ewindow_class, "property::sticky", banning_need_update);
luaA_class_connect_signal(L, (lua_class_t *) &ewindow_class, "tagged", banning_need_update);
luaA_class_connect_signal(L, (lua_class_t *) &ewindow_class, "untagged", banning_need_update);
luaA_class_connect_signal(L, &tag_class, "property::selected", banning_need_update);
luaA_class_connect_signal(L, &tag_class, "property::attached", banning_need_update);
}
void
banning_refresh(void)
{
if(!need_lazy_banning)
return;
foreach(ewindow, _G_ewindows)
if(ewindow_isvisible(*ewindow))
window_unban((window_t *) *ewindow);
/* Some people disliked the short flicker of background, so we first unban everything.
* Afterwards we ban everything we don't want. This should avoid that. */
foreach(ewindow, _G_ewindows)
if(!ewindow_isvisible(*ewindow))
window_ban((window_t *) *ewindow);
need_lazy_banning = false;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80