On 30/06/2016 16:01, Olivier Fourdan wrote:
xdh-shell's xdg-popup takes a serial, if the serial doesn't match the
compositor would dismiss the popup.

Currently, weston checks for pointer and touch serials, but popups can
also be triggered by keyboard shortcuts.

If a user activates a menu without any previous pointer ineraction with
the client, weston would dismiss the xdg-popup because the keyboard
serial would not match the popup serial.

Signed-off-by: Olivier Fourdan <[email protected]>
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=768017
---

This patch is superseded by the libweston-desktop port. There is still work to do to get a perfect grab, if you want to help. :-)

Cheers,


 desktop-shell/shell.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c125d55..fdab394 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -230,7 +230,7 @@ struct shell_seat {
                struct wl_list surfaces_list;
                struct wl_client *client;
                int32_t initial_up;
-               enum { POINTER, TOUCH } type;
+               enum { KEYBOARD, POINTER, TOUCH } type;
        } popup_grab;
 };

@@ -3467,12 +3467,15 @@ add_popup_grab(struct shell_surface *shsurf,
                } else if (type == TOUCH) {
                        shseat->popup_grab.touch_grab.interface =
                                &touch_popup_grab_interface;
+               } else if (type == KEYBOARD) {
+                       shseat->popup_grab.grab.interface =
+                               &popup_grab_interface;
                }

                wl_list_insert(&shseat->popup_grab.surfaces_list,
                               &shsurf->popup.grab_link);

-               if (type == POINTER) {
+               if (type == POINTER || type == KEYBOARD) {
                        weston_pointer_start_grab(pointer,
                                                  &shseat->popup_grab.grab);
                } else if (type == TOUCH) {
@@ -3504,7 +3507,7 @@ remove_popup_grab(struct shell_surface *shsurf)
        wl_list_remove(&shsurf->popup.grab_link);
        wl_list_init(&shsurf->popup.grab_link);
        if (wl_list_empty(&shseat->popup_grab.surfaces_list)) {
-               if (shseat->popup_grab.type == POINTER) {
+               if (shseat->popup_grab.type == POINTER || 
shseat->popup_grab.type == KEYBOARD) {
                        
weston_pointer_end_grab(shseat->popup_grab.grab.pointer);
                        shseat->popup_grab.grab.interface = NULL;
                } else if (shseat->popup_grab.type == TOUCH) {
@@ -3521,6 +3524,7 @@ shell_map_popup(struct shell_surface *shsurf)
        struct weston_view *parent_view = get_default_view(shsurf->parent);
        struct weston_pointer *pointer = weston_seat_get_pointer(shseat->seat);
        struct weston_touch *touch = weston_seat_get_touch(shseat->seat);
+       struct weston_keyboard *keyboard = 
weston_seat_get_keyboard(shseat->seat);

        shsurf->surface->output = parent_view->output;
        shsurf->view->output = parent_view->output;
@@ -3537,6 +3541,10 @@ shell_map_popup(struct shell_surface *shsurf)
                   touch->grab_serial == shsurf->popup.serial) {
                if (add_popup_grab(shsurf, shseat, TOUCH) != 0)
                        return -1;
+       } else if (keyboard &&
+                  keyboard->grab_serial == shsurf->popup.serial) {
+               if (add_popup_grab(shsurf, shseat, KEYBOARD) != 0)
+                       return -1;
        } else {
                shell_surface_send_popup_done(shsurf);
                shseat->popup_grab.client = NULL;



--

Quentin “Sardem FF7” Glidic
_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to