Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
spectrwm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use UINT32_MAX in xcb_get_property for atoms.
[spectrwm.git]
/
spectrwm.c
diff --git
a/spectrwm.c
b/spectrwm.c
index
0816f0e
..
28ad85f
100644
(file)
--- a/
spectrwm.c
+++ b/
spectrwm.c
@@
-720,7
+720,6
@@
map_window_raised(xcb_window_t win)
XCB_CONFIG_WINDOW_STACK_MODE, &val);
xcb_map_window(conn, win);
XCB_CONFIG_WINDOW_STACK_MODE, &val);
xcb_map_window(conn, win);
- xcb_flush(conn);
}
xcb_atom_t
}
xcb_atom_t
@@
-843,33
+842,33
@@
teardown_ewmh(void)
void
ewmh_autoquirk(struct ws_win *win)
{
void
ewmh_autoquirk(struct ws_win *win)
{
- int i;
- unsigned long n;
- xcb_atom_t type;
+ uint32_t i, n;
+ xcb_atom_t *type;
xcb_get_property_cookie_t c;
xcb_get_property_reply_t *r;
c = xcb_get_property(conn, False, win->id,
xcb_get_property_cookie_t c;
xcb_get_property_reply_t *r;
c = xcb_get_property(conn, False, win->id,
- ewmh[_NET_WM_WINDOW_TYPE].atom, XCB_ATOM_ATOM, 0, (~0L));
+ ewmh[_NET_WM_WINDOW_TYPE].atom, XCB_ATOM_ATOM, 0, UINT32_MAX);
r = xcb_get_property_reply(conn, c, NULL);
if (!r)
return;
r = xcb_get_property_reply(conn, c, NULL);
if (!r)
return;
- n = xcb_get_property_value_length(r);
+ n = xcb_get_property_value_length(r);
+ type = xcb_get_property_value(r);
+
for (i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
- type = *((xcb_atom_t *)xcb_get_property_value(r));
- if (type == ewmh[_NET_WM_WINDOW_TYPE_NORMAL].atom)
+ if (type[i] == ewmh[_NET_WM_WINDOW_TYPE_NORMAL].atom)
break;
break;
- if (type == ewmh[_NET_WM_WINDOW_TYPE_DOCK].atom ||
- type == ewmh[_NET_WM_WINDOW_TYPE_TOOLBAR].atom ||
- type == ewmh[_NET_WM_WINDOW_TYPE_UTILITY].atom) {
+ if (type[i] == ewmh[_NET_WM_WINDOW_TYPE_DOCK].atom ||
+ type[i] == ewmh[_NET_WM_WINDOW_TYPE_TOOLBAR].atom ||
+ type[i] == ewmh[_NET_WM_WINDOW_TYPE_UTILITY].atom) {
win->floating = 1;
win->quirks = SWM_Q_FLOAT | SWM_Q_ANYWHERE;
break;
}
win->floating = 1;
win->quirks = SWM_Q_FLOAT | SWM_Q_ANYWHERE;
break;
}
- if (type == ewmh[_NET_WM_WINDOW_TYPE_SPLASH].atom ||
- type == ewmh[_NET_WM_WINDOW_TYPE_DIALOG].atom) {
+ if (type[i] == ewmh[_NET_WM_WINDOW_TYPE_SPLASH].atom ||
+ type[i] == ewmh[_NET_WM_WINDOW_TYPE_DIALOG].atom) {
win->floating = 1;
win->quirks = SWM_Q_FLOAT;
break;
win->floating = 1;
win->quirks = SWM_Q_FLOAT;
break;
@@
-1033,7
+1032,7
@@
ewmh_get_win_state(struct ws_win *win)
win->ewmh_flags |= SWM_F_MANUAL;
c = xcb_get_property(conn, False, win->id, ewmh[_NET_WM_STATE].atom,
win->ewmh_flags |= SWM_F_MANUAL;
c = xcb_get_property(conn, False, win->id, ewmh[_NET_WM_STATE].atom,
- XCB_ATOM_ATOM, 0, (~0L));
+ XCB_ATOM_ATOM, 0, UINT32_MAX);
r = xcb_get_property_reply(conn, c, NULL);
if (!r)
return;
r = xcb_get_property_reply(conn, c, NULL);
if (!r)
return;
@@
-1114,7
+1113,7
@@
void mappingnotify(xcb_mapping_notify_event_t *);
void maprequest(xcb_map_request_event_t *);
void propertynotify(xcb_property_notify_event_t *);
void unmapnotify(xcb_unmap_notify_event_t *);
void maprequest(xcb_map_request_event_t *);
void propertynotify(xcb_property_notify_event_t *);
void unmapnotify(xcb_unmap_notify_event_t *);
-void visibilitynotify(xcb_visibility_notify_event_t *);
+/*void visibilitynotify(xcb_visibility_notify_event_t *);*/
void clientmessage(xcb_client_message_event_t *);
void screenchange(xcb_randr_screen_change_notify_event_t *);
void clientmessage(xcb_client_message_event_t *);
void screenchange(xcb_randr_screen_change_notify_event_t *);
@@
-1777,6
+1776,8
@@
bar_toggle(struct swm_region *r, union arg *args)
stack();
/* must be after stack */
bar_update();
stack();
/* must be after stack */
bar_update();
+
+ xcb_flush(conn);
}
void
}
void
@@
-1966,6
+1967,8
@@
version(struct swm_region *r, union arg *args)
else
strlcpy(bar_vertext, "", sizeof bar_vertext);
bar_update();
else
strlcpy(bar_vertext, "", sizeof bar_vertext);
bar_update();
+
+ xcb_flush(conn);
}
void
}
void
@@
-2570,6
+2573,8
@@
switchws(struct swm_region *r, union arg *args)
if (unmap_old)
TAILQ_FOREACH(win, &old_ws->winlist, entry)
unmap_window(win);
if (unmap_old)
TAILQ_FOREACH(win, &old_ws->winlist, entry)
unmap_window(win);
+
+ xcb_flush(conn);
}
void
}
void
@@
-2774,6
+2779,8
@@
swapwin(struct swm_region *r, union arg *args)
sort_windows(wl);
stack();
sort_windows(wl);
stack();
+
+ xcb_flush(conn);
}
void
}
void
@@
-2962,6
+2969,8
@@
focus(struct swm_region *r, union arg *args)
}
focus_magic(winfocus);
}
focus_magic(winfocus);
+
+ xcb_flush(conn);
}
void
}
void
@@
-3591,6
+3600,8
@@
send_to_ws(struct swm_region *r, union arg *args)
stack();
bar_update();
stack();
bar_update();
+
+ xcb_flush(conn);
}
void
}
void
@@
-3613,6
+3624,8
@@
raise_toggle(struct swm_region *r, union arg *args)
/* bring floaters back to top */
if (r->ws->always_raise == 0)
stack();
/* bring floaters back to top */
if (r->ws->always_raise == 0)
stack();
+
+ xcb_flush(conn);
}
void
}
void
@@
-3629,6
+3642,8
@@
iconify(struct swm_region *r, union arg *args)
r->ws->focus = NULL;
a.id = SWM_ARG_ID_FOCUSCUR;
focus(r, &a);
r->ws->focus = NULL;
a.id = SWM_ARG_ID_FOCUSCUR;
focus(r, &a);
+
+ xcb_flush(conn);
}
char *
}
char *
@@
-3701,6
+3716,7
@@
uniconify(struct swm_region *r, union arg *args)
}
fclose(lfile);
}
fclose(lfile);
+ xcb_flush(conn);
}
void
}
void
@@
-3843,6
+3859,8
@@
search_win(struct swm_region *r, union arg *args)
}
fclose(lfile);
}
fclose(lfile);
+
+ xcb_flush(conn);
}
void
}
void
@@
-4035,6
+4053,8
@@
wkill(struct swm_region *r, union arg *args)
else
if (r->ws->focus->can_delete)
client_msg(r->ws->focus, adelete);
else
if (r->ws->focus->can_delete)
client_msg(r->ws->focus, adelete);
+
+ xcb_flush(conn);
}
}
@@
-4095,6
+4115,8
@@
floating_toggle(struct swm_region *r, union arg *args)
a.id = SWM_ARG_ID_FOCUSCUR;
focus(win->ws->r, &a);
}
a.id = SWM_ARG_ID_FOCUSCUR;
focus(win->ws->r, &a);
}
+
+ xcb_flush(conn);
}
void
}
void
@@
-4167,7
+4189,7
@@
resize(struct ws_win *win, union arg *args)
struct swm_region *r = NULL;
int resize_step = 0;
struct swm_geometry g;
struct swm_region *r = NULL;
int resize_step = 0;
struct swm_geometry g;
- int top = 0, left = 0, buttonrelease;
+ int top = 0, left = 0, resizing;
int dx, dy;
unsigned int shape; /* cursor style */
xcb_cursor_t cursor;
int dx, dy;
unsigned int shape; /* cursor style */
xcb_cursor_t cursor;
@@
-4185,7
+4207,7
@@
resize(struct ws_win *win, union arg *args)
if (win->ewmh_flags & EWMH_F_FULLSCREEN)
return;
if (win->ewmh_flags & EWMH_F_FULLSCREEN)
return;
- DNPRINTF(SWM_D_MOUSE, "resize: window: 0x%x, floating: %s, "
+ DNPRINTF(SWM_D_EVENT, "resize: window: 0x%x, floating: %s, "
"transient: 0x%x\n", win->id, YESNO(win->floating),
win->transient);
"transient: 0x%x\n", win->id, YESNO(win->floating),
win->transient);
@@
-4269,15
+4291,16
@@
resize(struct ws_win *win, union arg *args)
}
xcb_flush(conn);
}
xcb_flush(conn);
- buttonrelease = 0;
- while ((evt = xcb_poll_for_event(conn)) && buttonrelease != 1) {
+ resizing = 1;
+ while ((evt = xcb_wait_for_event(conn)) && resizing) {
/*
XMaskEvent(display, MOUSEMASK | ExposureMask |
SubstructureRedirectMask, &ev);
*/
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
/*
XMaskEvent(display, MOUSEMASK | ExposureMask |
SubstructureRedirectMask, &ev);
*/
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
- buttonrelease = 1;
+ DNPRINTF(SWM_D_EVENT, "resize: BUTTON_RELEASE\n");
+ resizing = 0;
break;
case XCB_MOTION_NOTIFY:
mne = (xcb_motion_notify_event_t *)evt;
break;
case XCB_MOTION_NOTIFY:
mne = (xcb_motion_notify_event_t *)evt;
@@
-4351,6
+4374,7
@@
resize(struct ws_win *win, union arg *args)
xcb_close_font(conn, cursor_font);
free(gpr);
free(xpr);
xcb_close_font(conn, cursor_font);
free(gpr);
free(xpr);
+ DNPRINTF(SWM_D_EVENT, "resize: done\n");
}
void
}
void
@@
-4372,7
+4396,7
@@
void
move(struct ws_win *win, union arg *args)
{
xcb_timestamp_t timestamp = 0;
move(struct ws_win *win, union arg *args)
{
xcb_timestamp_t timestamp = 0;
- int move_step = 0, buttonrelease;
+ int move_step = 0, moving;
struct swm_region *r = NULL;
xcb_font_t cursor_font;
xcb_cursor_t cursor;
struct swm_region *r = NULL;
xcb_font_t cursor_font;
xcb_cursor_t cursor;
@@
-4389,7
+4413,7
@@
move(struct ws_win *win, union arg *args)
if (win->ewmh_flags & EWMH_F_FULLSCREEN)
return;
if (win->ewmh_flags & EWMH_F_FULLSCREEN)
return;
- DNPRINTF(SWM_D_MOUSE, "move: window: 0x%x, floating: %s, transient: "
+ DNPRINTF(SWM_D_EVENT, "move: window: 0x%x, floating: %s, transient: "
"0x%x\n", win->id, YESNO(win->floating), win->transient);
/* in max_stack mode should only move transients */
"0x%x\n", win->id, YESNO(win->floating), win->transient);
/* in max_stack mode should only move transients */
@@
-4463,15
+4487,12
@@
move(struct ws_win *win, union arg *args)
}
xcb_flush(conn);
}
xcb_flush(conn);
- buttonrelease = 0;
- while ((evt = xcb_poll_for_event(conn)) && buttonrelease != 1) {
- /*
- XMaskEvent(display, MOUSEMASK | ExposureMask |
- SubstructureRedirectMask, &ev);
- */
+ moving = 1;
+ while ((evt = xcb_wait_for_event(conn)) && moving) {
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
- buttonrelease = 1;
+ DNPRINTF(SWM_D_EVENT, "move: BUTTON_RELEASE\n");
+ moving = 0;
break;
case XCB_MOTION_NOTIFY:
mne = (xcb_motion_notify_event_t *)evt;
break;
case XCB_MOTION_NOTIFY:
mne = (xcb_motion_notify_event_t *)evt;
@@
-4502,6
+4523,7
@@
move(struct ws_win *win, union arg *args)
xcb_free_cursor(conn, cursor);
xcb_close_font(conn, cursor_font);
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
xcb_free_cursor(conn, cursor);
xcb_close_font(conn, cursor_font);
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
+ DNPRINTF(SWM_D_EVENT, "move: done\n");
}
void
}
void
@@
-6682,7
+6704,8
@@
buttonpress(xcb_button_press_event_t *e)
struct ws_win *win;
int i, action;
struct ws_win *win;
int i, action;
- DNPRINTF(SWM_D_EVENT, "buttonpress: window 0x%x\n", e->event);
+ DNPRINTF(SWM_D_EVENT, "buttonpress: window 0x%x, detail: %u\n",
+ e->event, e->detail);
if ((win = find_window(e->event)) == NULL)
return;
if ((win = find_window(e->event)) == NULL)
return;
@@
-7060,26
+7083,16
@@
unmapnotify(xcb_unmap_notify_event_t *e)
/* resend unmap because we ated it */
xcb_unmap_window(conn, e->window);
/* resend unmap because we ated it */
xcb_unmap_window(conn, e->window);
+ xcb_flush(conn);
}
}
}
}
-void
+/*void
visibilitynotify(xcb_visibility_notify_event_t *e)
{
visibilitynotify(xcb_visibility_notify_event_t *e)
{
- int i, num_screens;
- struct swm_region *r;
-
DNPRINTF(SWM_D_EVENT, "visibilitynotify: window: 0x%x\n",
e->window);
DNPRINTF(SWM_D_EVENT, "visibilitynotify: window: 0x%x\n",
e->window);
-
- if (e->state == XCB_VISIBILITY_UNOBSCURED) {
- num_screens = xcb_setup_roots_length(xcb_get_setup(conn));
- for (i = 0; i < num_screens; i++)
- TAILQ_FOREACH(r, &screens[i].rl, entry)
- if (e->window == WINID(r->bar))
- bar_update();
- }
-}
+}*/
void
clientmessage(xcb_client_message_event_t *e)
void
clientmessage(xcb_client_message_event_t *e)
@@
-7094,18
+7107,18
@@
clientmessage(xcb_client_message_event_t *e)
DNPRINTF(SWM_D_EVENT, "clientmessage: window: 0x%x, type: %u\n",
e->window, e->type);
DNPRINTF(SWM_D_EVENT, "clientmessage: window: 0x%x, type: %u\n",
e->window, e->type);
- if (e->response_type == ewmh[_NET_ACTIVE_WINDOW].atom) {
+ if (e->type == ewmh[_NET_ACTIVE_WINDOW].atom) {
DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_ACTIVE_WINDOW\n");
focus_win(win);
}
DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_ACTIVE_WINDOW\n");
focus_win(win);
}
- if (e->response_type == ewmh[_NET_CLOSE_WINDOW].atom) {
+ if (e->type == ewmh[_NET_CLOSE_WINDOW].atom) {
DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_CLOSE_WINDOW\n");
if (win->can_delete)
client_msg(win, adelete);
else
xcb_kill_client(conn, win->id);
}
DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_CLOSE_WINDOW\n");
if (win->can_delete)
client_msg(win, adelete);
else
xcb_kill_client(conn, win->id);
}
- if (e->response_type == ewmh[_NET_MOVERESIZE_WINDOW].atom) {
+ if (e->type == ewmh[_NET_MOVERESIZE_WINDOW].atom) {
DNPRINTF(SWM_D_EVENT,
"clientmessage: _NET_MOVERESIZE_WINDOW\n");
if (win->floating) {
DNPRINTF(SWM_D_EVENT,
"clientmessage: _NET_MOVERESIZE_WINDOW\n");
if (win->floating) {
@@
-7126,7
+7139,7
@@
clientmessage(xcb_client_message_event_t *e)
config_win(win, NULL);
}
}
config_win(win, NULL);
}
}
- if (e->response_type == ewmh[_NET_WM_STATE].atom) {
+ if (e->type == ewmh[_NET_WM_STATE].atom) {
DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_WM_STATE\n");
ewmh_update_win_state(win, e->data.data32[1], e->data.data32[0]);
if (e->data.data32[2])
DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_WM_STATE\n");
ewmh_update_win_state(win, e->data.data32[1], e->data.data32[0]);
if (e->data.data32[2])
@@
-7571,6
+7584,11
@@
void
event_handle(xcb_generic_event_t *evt)
{
uint8_t type = XCB_EVENT_RESPONSE_TYPE(evt);
event_handle(xcb_generic_event_t *evt)
{
uint8_t type = XCB_EVENT_RESPONSE_TYPE(evt);
+
+ DNPRINTF(SWM_D_EVENT, "XCB Event: %s(%d)\n",
+ xcb_event_get_label(XCB_EVENT_RESPONSE_TYPE(evt)),
+ XCB_EVENT_RESPONSE_TYPE(evt));
+
switch (type) {
#define EVENT(type, callback) case type: callback((void *)evt); return
EVENT(0, event_error);
switch (type) {
#define EVENT(type, callback) case type: callback((void *)evt); return
EVENT(0, event_error);
@@
-7606,7
+7624,7
@@
event_handle(xcb_generic_event_t *evt)
/*EVENT(XCB_SELECTION_NOTIFY, );*/
/*EVENT(XCB_SELECTION_REQUEST, );*/
EVENT(XCB_UNMAP_NOTIFY, unmapnotify);
/*EVENT(XCB_SELECTION_NOTIFY, );*/
/*EVENT(XCB_SELECTION_REQUEST, );*/
EVENT(XCB_UNMAP_NOTIFY, unmapnotify);
- EVENT(XCB_VISIBILITY_NOTIFY, visibilitynotify);
+ /*EVENT(XCB_VISIBILITY_NOTIFY, visibilitynotify);*/
#undef EVENT
}
if (type - xrandr_eventbase == XCB_RANDR_SCREEN_CHANGE_NOTIFY)
#undef EVENT
}
if (type - xrandr_eventbase == XCB_RANDR_SCREEN_CHANGE_NOTIFY)
@@
-7686,8
+7704,7
@@
main(int argc, char *argv[])
/* flush all events */
while ((evt = xcb_poll_for_event(conn))) {
/* flush all events */
while ((evt = xcb_poll_for_event(conn))) {
- uint8_t type = XCB_EVENT_RESPONSE_TYPE(evt);
- if (type == 0)
+ if (XCB_EVENT_RESPONSE_TYPE(evt) == 0)
event_handle(evt);
free(evt);
}
event_handle(evt);
free(evt);
}
@@
-7771,9
+7788,6
@@
noconfig:
while (running) {
while ((evt = xcb_poll_for_event(conn))) {
while (running) {
while ((evt = xcb_poll_for_event(conn))) {
- DNPRINTF(SWM_D_EVENT, "XCB Event: %s(%d)\n",
- xcb_event_get_label(XCB_EVENT_RESPONSE_TYPE(evt)),
- XCB_EVENT_RESPONSE_TYPE(evt));
if (running == 0)
goto done;
event_handle(evt);
if (running == 0)
goto done;
event_handle(evt);