mirror of https://github.com/i3/i3lock.git
make event loop simpler (Thanks to Jamey Sharp)
As explained in Jamey’s post on the XCB mailing list, the event loop can/should be written in a more simple way than it was before in xcb-event. See: <AANLkTinhIM320wUjSeHkBTVk4ysBuiSZkvfs8pMLVykO@mail.gmail.com> or http://lists.freedesktop.org/archives/xcb/2010-July/006292.htmlpull/1/head
parent
6a52ba8bea
commit
9d19a8bb53
6
i3lock.c
6
i3lock.c
|
@ -324,7 +324,11 @@ int main(int argc, char *argv[]) {
|
|||
dpms_turn_off_screen(conn);
|
||||
|
||||
while ((event = xcb_wait_for_event(conn))) {
|
||||
int type = x_event_type(event);
|
||||
if (event->response_type == 0)
|
||||
errx(1, "XCB: Invalid event received");
|
||||
|
||||
/* Strip off the highest bit (set if the event is generated) */
|
||||
int type = (event->response_type & 0x7F);
|
||||
|
||||
if (type == XCB_EXPOSE) {
|
||||
handle_expose_event();
|
||||
|
|
17
xcb.c
17
xcb.c
|
@ -27,23 +27,6 @@ static uint32_t get_colorpixel(char *hex) {
|
|||
return (rgb16[0] << 16) + (rgb16[1] << 8) + rgb16[2];
|
||||
}
|
||||
|
||||
int x_event_type(xcb_generic_event_t *event) {
|
||||
/* TODO: comment */
|
||||
assert(event->response_type != 1);
|
||||
|
||||
if (event->response_type == 0) {
|
||||
fprintf(stderr, "error\n");
|
||||
exit(1);
|
||||
}
|
||||
int type = event->response_type;
|
||||
assert(type < 256);
|
||||
/* strip the highest bit (TODO: why?) */
|
||||
type &= 0x7F;
|
||||
assert(type >= 2);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
xcb_visualtype_t *get_root_visual_type(xcb_screen_t *screen) {
|
||||
xcb_visualtype_t *visual_type = NULL;
|
||||
xcb_depth_iterator_t depth_iter;
|
||||
|
|
1
xcb.h
1
xcb.h
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
int x_event_type(xcb_generic_event_t *event);
|
||||
xcb_visualtype_t *get_root_visual_type(xcb_screen_t *s);
|
||||
xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, char *color);
|
||||
void grab_pointer_and_keyboard(xcb_connection_t *conn, xcb_screen_t *screen);
|
||||
|
|
Loading…
Reference in New Issue