button: change copy method
[awesome.git] / layout.c
blobe1c7f49af0f766840afaf158b9a29f8230f9f0ef
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 client_update_strut_positions(screen);
71 /* Reset status before calling arrange hook.
72 * This is needed if you call a function that relies
73 * on need_arrange while arrange is in progress.
75 screen->need_arrange = false;
77 /* call hook */
78 if(globalconf.hooks.arrange != LUA_REFNIL)
80 lua_pushnumber(globalconf.L, screen_array_indexof(&globalconf.screens, screen) + 1);
81 luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
84 /* Now, we want to receive EnterNotify and LeaveNotify events back. */
85 select_input_val[0] = CLIENT_SELECT_INPUT_EVENT_MASK;
86 foreach(c, globalconf.clients)
87 xcb_change_window_attributes(globalconf.connection,
88 (*c)->win,
89 XCB_CW_EVENT_MASK,
90 select_input_val);
93 /** Refresh the screen disposition
94 * \return true if the screen was arranged, false otherwise
96 void
97 layout_refresh(void)
99 foreach(screen, globalconf.screens)
100 if(screen->need_arrange)
101 arrange(screen);
104 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80