input: For serial generation get the display from the compositor

This removes the use of wl_client_get_display() where the client is
derived from the focussed resource. This starts the removal of the
assumption of a single resource on a client that would be notified about
events on the focussed surface.
dev
Rob Bradford 11 years ago committed by Kristian Høgsberg
parent 4384a24a9e
commit 880ebc7ed9
  1. 5
      src/bindings.c
  2. 3
      src/data-device.c
  3. 20
      src/input.c
  4. 9
      src/shell.c

@ -155,11 +155,10 @@ binding_key(struct weston_keyboard_grab *grab,
struct binding_keyboard_grab *b =
container_of(grab, struct binding_keyboard_grab, grab);
struct wl_resource *resource;
struct wl_client *client;
struct wl_display *display;
enum wl_keyboard_key_state state = state_w;
uint32_t serial;
struct weston_keyboard *keyboard = grab->keyboard;
struct wl_display *display = keyboard->seat->compositor->wl_display;
resource = grab->keyboard->focus_resource;
if (key == b->key) {
@ -170,8 +169,6 @@ binding_key(struct weston_keyboard_grab *grab,
free(b);
}
} else if (resource) {
client = wl_resource_get_client(resource);
display = wl_client_get_display(client);
serial = wl_display_next_serial(display);
wl_keyboard_send_key(resource, serial, time, key, state);
}

@ -210,7 +210,7 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
{
struct weston_pointer *pointer = drag->grab.pointer;
struct wl_resource *resource, *offer = NULL;
struct wl_display *display;
struct wl_display *display = pointer->seat->compositor->wl_display;
uint32_t serial;
if (drag->focus_resource) {
@ -232,7 +232,6 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
if (!resource)
return;
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
if (drag->data_source)

@ -137,12 +137,11 @@ default_grab_button(struct weston_pointer_grab *grab,
struct wl_resource *resource;
uint32_t serial;
enum wl_pointer_button_state state = state_w;
struct wl_display *display;
struct wl_display *display = compositor->wl_display;
wl_fixed_t sx, sy;
resource = pointer->focus_resource;
if (resource) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_pointer_send_button(resource, serial, time, button, state_w);
}
@ -170,11 +169,10 @@ default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
int touch_id, wl_fixed_t sx, wl_fixed_t sy)
{
struct weston_touch *touch = grab->touch;
struct wl_display *display;
struct wl_display *display = touch->seat->compositor->wl_display;
uint32_t serial;
if (touch->focus_resource && touch->focus) {
display = wl_client_get_display(wl_resource_get_client(touch->focus_resource));
serial = wl_display_next_serial(display);
wl_touch_send_down(touch->focus_resource, serial, time,
touch->focus->resource,
@ -187,11 +185,10 @@ default_grab_touch_up(struct weston_touch_grab *grab,
uint32_t time, int touch_id)
{
struct weston_touch *touch = grab->touch;
struct wl_display *display;
struct wl_display *display = touch->seat->compositor->wl_display;
uint32_t serial;
if (touch->focus_resource) {
display = wl_client_get_display(wl_resource_get_client(touch->focus_resource));
serial = wl_display_next_serial(display);
wl_touch_send_up(touch->focus_resource, serial, time, touch_id);
}
@ -221,12 +218,11 @@ default_grab_key(struct weston_keyboard_grab *grab,
{
struct weston_keyboard *keyboard = grab->keyboard;
struct wl_resource *resource;
struct wl_display *display;
struct wl_display *display = keyboard->seat->compositor->wl_display;
uint32_t serial;
resource = keyboard->focus_resource;
if (resource) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_key(resource, serial, time, key, state);
}
@ -423,12 +419,11 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
{
struct weston_keyboard *kbd = pointer->seat->keyboard;
struct wl_resource *resource, *kr;
struct wl_display *display;
struct wl_display *display = pointer->seat->compositor->wl_display;
uint32_t serial;
resource = pointer->focus_resource;
if (resource && pointer->focus != surface) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_pointer_send_leave(resource, serial,
pointer->focus->resource);
@ -440,7 +435,6 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
if (resource &&
(pointer->focus != surface ||
pointer->focus_resource != resource)) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
if (kbd) {
kr = find_resource_for_surface(&kbd->resource_list,
@ -471,12 +465,11 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
struct weston_surface *surface)
{
struct wl_resource *resource;
struct wl_display *display;
struct wl_display *display = keyboard->seat->compositor->wl_display;
uint32_t serial;
if (keyboard->focus_resource && keyboard->focus != surface) {
resource = keyboard->focus_resource;
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_leave(resource, serial,
keyboard->focus->resource);
@ -488,7 +481,6 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
if (resource &&
(keyboard->focus != surface ||
keyboard->focus_resource != resource)) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_modifiers(resource, serial,
keyboard->modifiers.mods_depressed,

@ -2056,13 +2056,12 @@ popup_grab_button(struct weston_pointer_grab *grab,
struct wl_resource *resource;
struct shell_seat *shseat =
container_of(grab, struct shell_seat, popup_grab.grab);
struct wl_display *display;
struct wl_display *display = shseat->seat->compositor->wl_display;
enum wl_pointer_button_state state = state_w;
uint32_t serial;
resource = grab->pointer->focus_resource;
if (resource) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_get_serial(display);
wl_pointer_send_button(resource, serial, time, button, state);
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
@ -4125,8 +4124,9 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
uint32_t key, uint32_t state)
{
struct debug_binding_grab *db = (struct debug_binding_grab *) grab;
struct weston_compositor *ec = db->seat->compositor;
struct wl_display *display = ec->wl_display;
struct wl_resource *resource;
struct wl_display *display;
uint32_t serial;
int send = 0, terminate = 0;
int check_binding = 1;
@ -4161,8 +4161,6 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
}
if (check_binding) {
struct weston_compositor *ec = db->seat->compositor;
if (weston_compositor_run_debug_binding(ec, db->seat, time,
key, state)) {
/* We ran a binding so swallow the press and keep the
@ -4182,7 +4180,6 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
resource = grab->keyboard->focus_resource;
if (resource) {
display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_key(resource, serial, time, key, state);
}

Loading…
Cancel
Save