forked from awesomeWM/awesome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
117 lines (104 loc) · 3.38 KB
/
Copy pathstack.c
File metadata and controls
117 lines (104 loc) · 3.38 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* stack.c - window stack management
*
* Copyright © 2008-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 "awesome.h"
#include "stack.h"
#include "objects/window.h"
static void
stack_window_remove(window_t *window)
{
window_array_find_and_remove(&window->parent->childrens, window);
}
/** Push the window at the beginning of the window stack.
* \param window The window to push.
*/
static void
stack_window_push(window_t *window)
{
stack_window_remove(window);
window_array_push(&window->parent->childrens, window);
}
/** Push the window at the end of the window stack.
* \param window The window to push.
*/
static void
stack_window_append(window_t *window)
{
stack_window_remove(window);
window_array_append(&window->parent->childrens, window);
}
/** Put window on bottom of the stack.
* \param L The Lua VM state.
* \param window The window to raise.
*/
void
stack_window_lower(lua_State *L, window_t *window)
{
stack_window_push(window);
window_emit_signal_noret(L, window, "lower", 0);
}
/** Put window on top of the stack.
* \param L The Lua VM state.
* \param window The window to lower.
*/
void
stack_window_raise(lua_State *L, window_t *window)
{
/* Push window on top of the stack. */
stack_window_append(window);
window_emit_signal_noret(L, window, "raise", 0);
}
/** Restack windows.
* \todo It might be worth stopping to restack everyone and only stack `c'
* relatively to the first matching in the list.
*/
static int
stack_refresh(lua_State *L)
{
window_t *window = luaA_checkudata(L, 1, &window_class);
xcb_window_t next = XCB_NONE;
if(window->parent)
for(int layer = INT8_MIN; layer <= INT8_MAX; layer++)
foreach(node, window->parent->childrens)
if((*node)->layer == layer)
{
xcb_configure_window(_G_connection, (*node)->window,
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
(uint32_t[]) { next, XCB_STACK_MODE_ABOVE });
next = (*node)->window;
}
return 0;
}
static int
luaA_stack_window_remove(lua_State *L)
{
window_t *window = luaA_checkudata(L, 1, &window_class);
if(!window->window)
stack_window_remove(window);
return 0;
}
void
stack_init(lua_State *L)
{
luaA_class_connect_signal(L, &window_class, "property::layer", stack_refresh);
luaA_class_connect_signal(L, &window_class, "raise", stack_refresh);
luaA_class_connect_signal(L, &window_class, "lower", stack_refresh);
luaA_class_connect_signal(L, &window_class, "property::window", luaA_stack_window_remove);
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80