awful.widget.taglist: remove needless taglist_squares conditions
[awesome.git] / layout.c
blob87dca76ace6726e62b245dd62afce32c2e3befef
1 /*
2 * layout.c - layout management
4 * Copyright © 2007-2008 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 "layout.h"
23 #include "tag.h"
24 #include "window.h"
25 #include "screen.h"
26 #include "titlebar.h"
28 /** Arrange windows following current selected layout
29 * \param screen the screen to arrange
31 static void
32 arrange(int screen)
34 uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) };
36 foreach(_c, globalconf.clients)
38 client_t *c = *_c;
39 /* Bob Marley v2:
40 * While we arrange, we do not want to receive EnterNotify or LeaveNotify
41 * events, or we would get spurious events. */
42 xcb_change_window_attributes(globalconf.connection,
43 c->win,
44 XCB_CW_EVENT_MASK,
45 select_input_val);
47 /* Restore titlebar before client, so geometry is ok again. */
48 if(titlebar_isvisible(c, screen))
49 titlebar_unban(c->titlebar);
50 else if(c->screen == screen)
51 titlebar_ban(c->titlebar);
53 if(client_isvisible(c, screen))
54 client_unban(c);
55 /* we don't touch other screens windows */
56 else if(c->screen == screen)
57 client_ban(c);
60 client_update_strut_positions(screen);
62 /* Reset status before calling arrange hook.
63 * This is needed if you call a function that relies
64 * on need_arrange while arrange is in progress.
66 globalconf.screens[screen].need_arrange = false;
68 /* call hook */
69 if(globalconf.hooks.arrange != LUA_REFNIL)
71 lua_pushnumber(globalconf.L, screen + 1);
72 luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
75 /* Now, we want to receive EnterNotify and LeaveNotify events back. */
76 select_input_val[0] = CLIENT_SELECT_INPUT_EVENT_MASK;
77 foreach(c, globalconf.clients)
78 xcb_change_window_attributes(globalconf.connection,
79 (*c)->win,
80 XCB_CW_EVENT_MASK,
81 select_input_val);
84 /** Refresh the screen disposition
85 * \return true if the screen was arranged, false otherwise
87 void
88 layout_refresh(void)
90 int screen;
92 for(screen = 0; screen < globalconf.nscreen; screen++)
93 if(globalconf.screens[screen].need_arrange)
94 arrange(screen);
97 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80