broadway: use 'click-to-focus' approach instead of 'focus-follows-mouse'

The broadway backend would move the focus from one window to another based on
where the mouse was (i.e. 'focus-follows-mouse' approach). Handling the focus
this wait didn't play well with widgets which rely on focus-in-event and
focus-out-event, like the GtkEntry when using a completion popup window, see
e.g:
  https://bugzilla.gnome.org/show_bug.cgi?id=708984

So instead, setup broadway to require a click in a window to move the focus
(i.e. 'click-to-focus' approach):

 * The implicit GDK_FOCUS_CHANGE events that were generated upon reception of
   BROADWAY_EVENT_ENTER or BROADWAY_EVENT_LEAVE are removed.

 * The broadway daemon will now keep track of which is the focused window

 * Whenever the daemon detects an incoming BROADWAY_EVENT_BUTTON_PRESS, it will
   trigger the focused window switch, which sends a new BROADWAY_EVENT_FOCUS to
   the client, specifying which windows holds the focus.

 * Upon reception of a BROADWAY_EVENT_FOCUS, the client will generate a new
   GDK_FOCUS_CHANGE.

 * gdk_broadway_window_focus() was also implemented, which now requests the
   focus to the broadway server using a new BROADWAY_REQUEST_FOCUS_WINDOW.

This is based on an initial patch from Aleksander Morgado <aleksander@lanedo.com>.
This commit is contained in:
Alexander Larsson
2013-11-12 12:03:50 +01:00
parent f50a3af1b7
commit ddade66496
8 changed files with 83 additions and 19 deletions

View File

@ -21,7 +21,8 @@ typedef enum {
BROADWAY_EVENT_UNGRAB_NOTIFY = 'u',
BROADWAY_EVENT_CONFIGURE_NOTIFY = 'w',
BROADWAY_EVENT_DELETE_NOTIFY = 'W',
BROADWAY_EVENT_SCREEN_SIZE_CHANGED = 'd'
BROADWAY_EVENT_SCREEN_SIZE_CHANGED = 'd',
BROADWAY_EVENT_FOCUS = 'f'
} BroadwayEventType;
typedef enum {
@ -104,6 +105,11 @@ typedef struct {
gint32 id;
} BroadwayInputDeleteNotify;
typedef struct {
BroadwayInputBaseMsg base;
gint32 id;
} BroadwayInputFocusMsg;
typedef union {
BroadwayInputBaseMsg base;
BroadwayInputPointerMsg pointer;
@ -115,6 +121,7 @@ typedef union {
BroadwayInputConfigureNotify configure_notify;
BroadwayInputDeleteNotify delete_notify;
BroadwayInputScreenResizeNotify screen_resize_notify;
BroadwayInputFocusMsg focus;
} BroadwayInputMsg;
typedef enum {
@ -129,7 +136,8 @@ typedef enum {
BROADWAY_REQUEST_UPDATE,
BROADWAY_REQUEST_MOVE_RESIZE,
BROADWAY_REQUEST_GRAB_POINTER,
BROADWAY_REQUEST_UNGRAB_POINTER
BROADWAY_REQUEST_UNGRAB_POINTER,
BROADWAY_REQUEST_FOCUS_WINDOW
} BroadwayRequestType;
typedef struct {
@ -141,7 +149,7 @@ typedef struct {
typedef struct {
BroadwayRequestBase base;
guint32 id;
} BroadwayRequestDestroyWindow, BroadwayRequestShowWindow, BroadwayRequestHideWindow;
} BroadwayRequestDestroyWindow, BroadwayRequestShowWindow, BroadwayRequestHideWindow, BroadwayRequestFocusWindow;
typedef struct {
BroadwayRequestBase base;
@ -213,6 +221,7 @@ typedef union {
BroadwayRequestGrabPointer grab_pointer;
BroadwayRequestUngrabPointer ungrab_pointer;
BroadwayRequestTranslate translate;
BroadwayRequestFocusWindow focus_window;
} BroadwayRequest;
typedef enum {