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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
diff --git a/src/common.h b/src/common.h
index 978acf7..bcffb81 100644
--- a/src/common.h
+++ b/src/common.h
@@ -186,9 +186,9 @@ typedef struct session {
/// Width of root window.
int root_width;
/// Current desktop number of root window
- // int root_desktop_num;
+ int root_desktop_num;
/// Desktop switch direction
- // int root_desktop_switch_direction;
+ int root_desktop_switch_direction;
/// X Composite overlay window.
xcb_window_t overlay;
/// The target window for debug mode
diff --git a/src/compfy.c b/src/compfy.c
index 975bfaf..d5dcc54 100644
--- a/src/compfy.c
+++ b/src/compfy.c
@@ -597,13 +597,13 @@ static void configure_root(session_t *ps) {
ps->root_width = r->width;
ps->root_height = r->height;
- // auto prop = x_get_prop(ps->c, ps->root, ps->atoms->a_NET_CURRENT_DESKTOP,
- // 1L, XCB_ATOM_CARDINAL, 32);
+ auto prop = x_get_prop(ps->c, ps->root, ps->atoms->a_NET_CURRENT_DESKTOP,
+ 1L, XCB_ATOM_CARDINAL, 32);
- // ps->root_desktop_switch_direction = 0;
- // if (prop.nitems) {
- // ps->root_desktop_num = (int)*prop.c32;
- // }
+ ps->root_desktop_switch_direction = 0;
+ if (prop.nitems) {
+ ps->root_desktop_num = (int)*prop.c32;
+ }
rebuild_screen_reg(ps);
rebuild_shadow_exclude_reg(ps);
@@ -1752,7 +1752,7 @@ static void draw_callback_impl(EV_P_ session_t *ps, int revents attr_unused) {
}
if (!animation_running) {
ps->animation_time = 0L;
- // ps->root_desktop_switch_direction = 0;
+ ps->root_desktop_switch_direction = 0;
}
// TODO(yshui) Investigate how big the X critical section needs to be. There are
diff --git a/src/config.c b/src/config.c
index deca6ad..45da9a0 100644
--- a/src/config.c
+++ b/src/config.c
@@ -759,6 +759,8 @@ enum wm_support parse_wm_support(const char *src) {
return WM_SUPPORT_HERB;
} else if (strcmp(src, "dwm") == 0) {
return WM_SUPPORT_DWM;
+ } else if (strcmp(src, "bspwm") == 0) {
+ return WM_SUPPORT_BSPWM;
} else if (strcmp(src, "legacy") == 0) {
return WM_SUPPORT_LEGACY;
}
diff --git a/src/config.h b/src/config.h
index 4276203..fe03eca 100644
--- a/src/config.h
+++ b/src/config.h
@@ -49,8 +49,8 @@ enum open_window_animation {
OPEN_WINDOW_ANIMATION_SLIDE_DOWN,
OPEN_WINDOW_ANIMATION_SLIDE_LEFT,
OPEN_WINDOW_ANIMATION_SLIDE_RIGHT,
- // OPEN_WINDOW_ANIMATION_SLIDE_IN,
- // OPEN_WINDOW_ANIMATION_SLIDE_OUT,
+ OPEN_WINDOW_ANIMATION_SLIDE_IN,
+ OPEN_WINDOW_ANIMATION_SLIDE_OUT,
OPEN_WINDOW_ANIMATION_INVALID,
};
@@ -59,6 +59,7 @@ enum wm_support {
WM_SUPPORT_AWESOME,
WM_SUPPORT_HERB,
WM_SUPPORT_DWM,
+ WM_SUPPORT_BSPWM,
WM_SUPPORT_LEGACY,
WM_SUPPORT_INVALID,
};
diff --git a/src/event.c b/src/event.c
index acbc82d..bf5bd1d 100644
--- a/src/event.c
+++ b/src/event.c
@@ -450,15 +450,15 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t
if (ps->root == ev->window) {
// If desktop number property changes
- // if (ev->atom == ps->atoms->a_NET_CURRENT_DESKTOP) {
- // auto prop = x_get_prop(ps->c, ps->root, ps->atoms->a_NET_CURRENT_DESKTOP,
- // 1L, XCB_ATOM_CARDINAL, 32);
-
- // if (prop.nitems) {
- // ps->root_desktop_switch_direction = ((int)*prop.c32) - ps->root_desktop_num;
- // ps->root_desktop_num = (int)*prop.c32;
- // }
- // }
+ if (ev->atom == ps->atoms->a_NET_CURRENT_DESKTOP) {
+ auto prop = x_get_prop(ps->c, ps->root, ps->atoms->a_NET_CURRENT_DESKTOP,
+ 1L, XCB_ATOM_CARDINAL, 32);
+
+ if (prop.nitems) {
+ ps->root_desktop_switch_direction = ((int)*prop.c32) - ps->root_desktop_num;
+ ps->root_desktop_num = (int)*prop.c32;
+ }
+ }
if (ps->o.use_ewmh_active_win && ps->atoms->a_NET_ACTIVE_WINDOW == ev->atom) {
// to update focus
diff --git a/src/win.c b/src/win.c
index 4d96bb7..df3af08 100644
--- a/src/win.c
+++ b/src/win.c
@@ -484,13 +484,9 @@ static void init_animation(session_t *ps, struct managed_win *w) {
if (ps->o.wintype_option[w->window_type].animation < OPEN_WINDOW_ANIMATION_INVALID)
animation = ps->o.wintype_option[w->window_type].animation;
- // if (ps->root_desktop_switch_direction != 0) {
- // if (ps->o.animation_for_workspace_switch_in == OPEN_WINDOW_ANIMATION_AUTO) {
- // animation = OPEN_WINDOW_ANIMATION_SLIDE_IN;
- // } else {
- // animation = ps->o.animation_for_workspace_switch_in;
- // }
- // }
+ if (ps->root_desktop_switch_direction != 0) {
+ animation = OPEN_WINDOW_ANIMATION_SLIDE_IN;
+ }
if (c2_match(ps, w, ps->o.animation_open_blacklist, NULL)) {
animation = OPEN_WINDOW_ANIMATION_NONE;
@@ -553,28 +549,16 @@ static void init_animation(session_t *ps, struct managed_win *w) {
w->animation_h = w->pending_g.height;
break;
}
- // case OPEN_WINDOW_ANIMATION_SLIDE_IN: {
- // w->animation_center_x = w->pending_g.x + w->pending_g.width * 0.5;
- // w->animation_center_y = w->pending_g.y + w->pending_g.height * 0.5 -
- // ps->root_height *
- // ((ps->root_desktop_switch_direction < 0 &&
- // ps->root_desktop_switch_direction >= -1) ||
- // ps->root_desktop_switch_direction > 1?1:-1);
- // w->animation_w = w->pending_g.width;
- // w->animation_h = w->pending_g.height;
- // break;
- // }
- // case OPEN_WINDOW_ANIMATION_SLIDE_OUT: {
- // w->animation_dest_center_x = w->pending_g.x + w->pending_g.width * 0.5;
- // w->animation_dest_center_y = w->pending_g.y + w->pending_g.height * 0.5 -
- // ps->root_height *
- // ((ps->root_desktop_switch_direction < 0 &&
- // ps->root_desktop_switch_direction >= -1) ||
- // ps->root_desktop_switch_direction > 1?-1:1);
- // w->animation_dest_w = w->pending_g.width;
- // w->animation_dest_h = w->pending_g.height;
- // break;
- // }
+ case OPEN_WINDOW_ANIMATION_SLIDE_IN: {
+ w->animation_center_x = w->pending_g.x + w->pending_g.width * 0.5 +
+ ps->root_width *
+ (ps->root_desktop_switch_direction < 0?-1:1);
+
+ w->animation_center_y = w->pending_g.y + w->pending_g.height * 0.5;
+ w->animation_w = w->pending_g.width;
+ w->animation_h = w->pending_g.height;
+ break;
+ }
case OPEN_WINDOW_ANIMATION_INVALID: assert(false); break;
}
}
@@ -599,10 +583,10 @@ static void init_animation_unmap(session_t *ps, struct managed_win *w) {
animation = OPEN_WINDOW_ANIMATION_SLIDE_RIGHT;
else if (animation == OPEN_WINDOW_ANIMATION_SLIDE_RIGHT)
animation = OPEN_WINDOW_ANIMATION_SLIDE_LEFT;
- // else if (animation == OPEN_WINDOW_ANIMATION_SLIDE_IN)
- // animation = OPEN_WINDOW_ANIMATION_SLIDE_OUT;
- // else if (animation == OPEN_WINDOW_ANIMATION_SLIDE_OUT)
- // animation = OPEN_WINDOW_ANIMATION_SLIDE_IN;
+ else if (animation == OPEN_WINDOW_ANIMATION_SLIDE_IN)
+ animation = OPEN_WINDOW_ANIMATION_SLIDE_OUT;
+ else if (animation == OPEN_WINDOW_ANIMATION_SLIDE_OUT)
+ animation = OPEN_WINDOW_ANIMATION_SLIDE_IN;
} else {
animation = ps->o.animation_for_unmap_window;
@@ -611,12 +595,9 @@ static void init_animation_unmap(session_t *ps, struct managed_win *w) {
animation = ps->o.wintype_option[w->window_type].animation_unmap;
}
- // if (ps->root_desktop_switch_direction != 0) {
- // if (ps->o.animation_for_workspace_switch_out == OPEN_WINDOW_ANIMATION_AUTO)
- // animation = OPEN_WINDOW_ANIMATION_SLIDE_OUT;
- // else
- // animation = ps->o.animation_for_workspace_switch_out;
- // }
+ if (ps->root_desktop_switch_direction != 0) {
+ animation = OPEN_WINDOW_ANIMATION_SLIDE_OUT;
+ }
if (c2_match(ps, w, ps->o.animation_unmap_blacklist, NULL)) {
animation = OPEN_WINDOW_ANIMATION_NONE;
@@ -679,28 +660,15 @@ static void init_animation_unmap(session_t *ps, struct managed_win *w) {
w->animation_dest_h = w->pending_g.height;
break;
}
- // case OPEN_WINDOW_ANIMATION_SLIDE_IN: {
- // w->animation_center_x = w->pending_g.x + w->pending_g.width * 0.5;
- // w->animation_center_y = w->pending_g.y + w->pending_g.height * 0.5 -
- // ps->root_height *
- // ((ps->root_desktop_switch_direction < 0 &&
- // ps->root_desktop_switch_direction >= -1) ||
- // ps->root_desktop_switch_direction > 1?1:-1);
- // w->animation_w = w->pending_g.width;
- // w->animation_h = w->pending_g.height;
- // break;
- // }
- // case OPEN_WINDOW_ANIMATION_SLIDE_OUT: {
- // w->animation_dest_center_x = w->pending_g.x + w->pending_g.width * 0.5;
- // w->animation_dest_center_y = w->pending_g.y + w->pending_g.height * 0.5 -
- // ps->root_height *
- // ((ps->root_desktop_switch_direction < 0 &&
- // ps->root_desktop_switch_direction >= -1) ||
- // ps->root_desktop_switch_direction > 1?-1:1);
- // w->animation_dest_w = w->pending_g.width;
- // w->animation_dest_h = w->pending_g.height;
- // break;
- // }
+ case OPEN_WINDOW_ANIMATION_SLIDE_OUT: {
+ w->animation_dest_center_x = w->pending_g.x + w->pending_g.width * 0.5 -
+ ps->root_width *
+ (ps->root_desktop_switch_direction < 0?-1:1);
+ w->animation_dest_center_y = w->pending_g.y + w->pending_g.height * 0.5;
+ w->animation_dest_w = w->pending_g.width;
+ w->animation_dest_h = w->pending_g.height;
+ break;
+ }
case OPEN_WINDOW_ANIMATION_INVALID: assert(false); break;
}
}
@@ -1133,11 +1101,11 @@ double win_calc_opacity_target(session_t *ps, const struct managed_win *w) {
return 0;
}
if (w->state == WSTATE_UNMAPPING || w->state == WSTATE_DESTROYING) {
- // if (ps->root_desktop_switch_direction)
- // return w->opacity;
+// if (ps->root_desktop_switch_direction)
+// return w->opacity;
- return 0;
- }
+ return 0;
+ }
// Try obeying opacity property and window type opacity firstly
if (w->has_opacity_prop) {
opacity = ((double)w->opacity_prop) / OPAQUE;
|