change codename
[awesome.git] / layout.c
blobd7196322289a8d10051179fd9e42891cd8030fd1
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(screen_t *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);
51 if(client_isvisible(c, screen))
52 client_unban(c);
55 /* Some people disliked the short flicker of background, so we first unban everything.
56 * Afterwards we ban everything we don't want. This should avoid that. */
57 foreach(_c, globalconf.clients)
59 client_t *c = *_c;
61 if(!titlebar_isvisible(c, screen) && c->screen == screen)
62 titlebar_ban(c->titlebar);
64 /* we don't touch other screens windows */
65 if(!client_isvisible(c, screen) && c->screen == screen)
66 client_ban(c);
69 /* Reset status before calling arrange hook.
70 * This is needed if you call a function that relies
71 * on need_arrange while arrange is in progress.
73 screen->need_arrange = false;
75 /* call hook */
76 if(globalconf.hooks.arrange != LUA_REFNIL)
78 lua_pushnumber(globalconf.L, screen_array_indexof(&globalconf.screens, screen) + 1);
79 luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
82 /* Now, we want to receive EnterNotify and LeaveNotify events back. */
83 select_input_val[0] = CLIENT_SELECT_INPUT_EVENT_MASK;
84 foreach(c, globalconf.clients)
85 xcb_change_window_attributes(globalconf.connection,
86 (*c)->win,
87 XCB_CW_EVENT_MASK,
88 select_input_val);
91 /** Refresh the screen disposition
92 * \return true if the screen was arranged, false otherwise
94 void
95 layout_refresh(void)
97 foreach(screen, globalconf.screens)
98 if(screen->need_arrange)
99 arrange(screen);
102 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80