client: switch to xcb-icccm 0.3.3
[awesome.git] / layout.c
blobd4093dbcceb4002233661c295057772b41ef9b9f
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"
27 extern awesome_t globalconf;
29 /** Arrange windows following current selected layout
30 * \param screen the screen to arrange
32 static void
33 arrange(int screen)
35 client_t *c;
36 int phys_screen = screen_virttophys(screen);
37 xcb_query_pointer_cookie_t qp_c;
38 xcb_query_pointer_reply_t *qp_r;
40 for(c = globalconf.clients; c; c = c->next)
42 if(client_isvisible_exclude_banned(c, screen))
43 client_unban(c);
44 /* we don't touch other screens windows */
45 else if(c->screen == screen)
46 client_ban(c);
49 /* call hook */
50 if(globalconf.hooks.arrange != LUA_REFNIL)
52 lua_pushnumber(globalconf.L, screen + 1);
53 luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
56 qp_c = xcb_query_pointer_unchecked(globalconf.connection,
57 xutil_screen_get(globalconf.connection,
58 phys_screen)->root);
60 /* check that the mouse is on a window or not */
61 if((qp_r = xcb_query_pointer_reply(globalconf.connection, qp_c, NULL)))
63 if(qp_r->child == XCB_NONE || qp_r->root == qp_r->child)
64 window_root_buttons_grab(qp_r->root);
65 else if ((c = client_getbywin(qp_r->child)))
66 window_buttons_grab(c->win, qp_r->root, &c->buttons);
68 globalconf.pointer_x = qp_r->root_x;
69 globalconf.pointer_y = qp_r->root_y;
71 p_delete(&qp_r);
74 /* reset status */
75 globalconf.screens[screen].need_arrange = false;
78 /** Refresh the screen disposition
79 * \return true if the screen was arranged, false otherwise
81 void
82 layout_refresh(void)
84 int screen;
86 for(screen = 0; screen < globalconf.nscreen; screen++)
87 if(globalconf.screens[screen].need_arrange)
88 arrange(screen);
91 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80