Merge pull request #869 from psychon/x11-cleanups

Some changes to the x11 backend
This commit is contained in:
emersion 2018-04-15 11:11:00 +02:00 committed by GitHub
commit 1db8667cea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 26 deletions

View file

@ -65,18 +65,16 @@ void x11_output_layout_get_box(struct wlr_x11_backend *backend,
box->height = max_y - min_y; box->height = max_y - min_y;
} }
static bool handle_x11_event(struct wlr_x11_backend *x11, static void handle_x11_event(struct wlr_x11_backend *x11,
xcb_generic_event_t *event) { xcb_generic_event_t *event) {
if (x11_handle_input_event(x11, event)) { x11_handle_input_event(x11, event);
return false;
}
switch (event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) { switch (event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) {
case XCB_EXPOSE: { case XCB_EXPOSE: {
xcb_expose_event_t *ev = (xcb_expose_event_t *)event; xcb_expose_event_t *ev = (xcb_expose_event_t *)event;
struct wlr_x11_output *output = struct wlr_x11_output *output =
x11_output_from_window_id(x11, ev->window); x11_output_from_window_id(x11, ev->window);
if (output != NULL) { if (output != NULL && !output->wlr_output.frame_pending) {
wlr_output_send_frame(&output->wlr_output); wlr_output_send_frame(&output->wlr_output);
} }
break; break;
@ -103,8 +101,6 @@ static bool handle_x11_event(struct wlr_x11_backend *x11,
break; break;
} }
} }
return false;
} }
static int x11_event(int fd, uint32_t mask, void *data) { static int x11_event(int fd, uint32_t mask, void *data) {
@ -117,11 +113,8 @@ static int x11_event(int fd, uint32_t mask, void *data) {
xcb_generic_event_t *e; xcb_generic_event_t *e;
while ((e = xcb_poll_for_event(x11->xcb_conn))) { while ((e = xcb_poll_for_event(x11->xcb_conn))) {
bool quit = handle_x11_event(x11, e); handle_x11_event(x11, e);
free(e); free(e);
if (quit) {
break;
}
} }
return 0; return 0;

View file

@ -56,7 +56,7 @@ static void x11_handle_pointer_position(struct wlr_x11_output *output,
x11->time = time; x11->time = time;
} }
bool x11_handle_input_event(struct wlr_x11_backend *x11, void x11_handle_input_event(struct wlr_x11_backend *x11,
xcb_generic_event_t *event) { xcb_generic_event_t *event) {
switch (event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) { switch (event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) {
case XCB_KEY_PRESS: case XCB_KEY_PRESS:
@ -73,7 +73,7 @@ bool x11_handle_input_event(struct wlr_x11_backend *x11,
// TODO use xcb-xkb for more precise modifiers state? // TODO use xcb-xkb for more precise modifiers state?
wlr_keyboard_notify_key(&x11->keyboard, &key); wlr_keyboard_notify_key(&x11->keyboard, &key);
x11->time = ev->time; x11->time = ev->time;
return true; return;
} }
case XCB_BUTTON_PRESS: { case XCB_BUTTON_PRESS: {
xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event; xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event;
@ -110,19 +110,17 @@ bool x11_handle_input_event(struct wlr_x11_backend *x11,
wlr_signal_emit_safe(&x11->pointer.events.button, &button); wlr_signal_emit_safe(&x11->pointer.events.button, &button);
} }
x11->time = ev->time; x11->time = ev->time;
return true; return;
} }
case XCB_MOTION_NOTIFY: { case XCB_MOTION_NOTIFY: {
xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)event; xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)event;
struct wlr_x11_output *output = struct wlr_x11_output *output =
x11_output_from_window_id(x11, ev->event); x11_output_from_window_id(x11, ev->event);
if (output == NULL) { if (output != NULL) {
return false;
}
x11_handle_pointer_position(output, ev->event_x, ev->event_y, ev->time); x11_handle_pointer_position(output, ev->event_x, ev->event_y, ev->time);
return true; }
return;
} }
default: default:
#ifdef WLR_HAS_XCB_XKB #ifdef WLR_HAS_XCB_XKB
@ -131,13 +129,11 @@ bool x11_handle_input_event(struct wlr_x11_backend *x11,
(xcb_xkb_state_notify_event_t *)event; (xcb_xkb_state_notify_event_t *)event;
wlr_keyboard_notify_modifiers(&x11->keyboard, ev->baseMods, wlr_keyboard_notify_modifiers(&x11->keyboard, ev->baseMods,
ev->latchedMods, ev->lockedMods, ev->lockedGroup); ev->latchedMods, ev->lockedMods, ev->lockedGroup);
return true; return;
} }
#endif #endif
break; break;
} }
return false;
} }
const struct wlr_input_device_impl input_device_impl = { 0 }; const struct wlr_input_device_impl input_device_impl = { 0 };

View file

@ -114,9 +114,8 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
wl_list_length(&x11->outputs) + 1); wl_list_length(&x11->outputs) + 1);
parse_xcb_setup(wlr_output, x11->xcb_conn); parse_xcb_setup(wlr_output, x11->xcb_conn);
uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; uint32_t mask = XCB_CW_EVENT_MASK;
uint32_t values[2] = { uint32_t values[] = {
x11->screen->white_pixel,
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |

View file

@ -79,7 +79,7 @@ void x11_output_layout_get_box(struct wlr_x11_backend *backend,
const struct wlr_input_device_impl input_device_impl; const struct wlr_input_device_impl input_device_impl;
bool x11_handle_input_event(struct wlr_x11_backend *x11, void x11_handle_input_event(struct wlr_x11_backend *x11,
xcb_generic_event_t *event); xcb_generic_event_t *event);
void x11_update_pointer_position(struct wlr_x11_output *output, void x11_update_pointer_position(struct wlr_x11_output *output,
xcb_timestamp_t time); xcb_timestamp_t time);