Skip to content

Commit

Permalink
broadway: Send focus out events
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlarsson committed Nov 13, 2013
1 parent 6917746 commit ca89f5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion gdk/broadway/broadway-protocol.h
Expand Up @@ -122,7 +122,8 @@ typedef struct {

typedef struct {
BroadwayInputBaseMsg base;
gint32 id;
gint32 new_id;
gint32 old_id;
} BroadwayInputFocusMsg;

typedef union {
Expand Down
9 changes: 5 additions & 4 deletions gdk/broadway/broadway-server.c
Expand Up @@ -1545,15 +1545,16 @@ broadway_server_focus_window (BroadwayServer *server,
if (server->focused_window_id == new_focused_window)
return;

/* Keep track of the new focused window */
server->focused_window_id = new_focused_window;

memset (&focus_msg, 0, sizeof (focus_msg));
focus_msg.base.type = BROADWAY_EVENT_FOCUS;
focus_msg.base.time = broadway_server_get_last_seen_time (server);
focus_msg.focus.id = new_focused_window;
focus_msg.focus.old_id = server->focused_window_id;
focus_msg.focus.new_id = new_focused_window;

broadway_events_got_input (&focus_msg, -1);

/* Keep track of the new focused window */
server->focused_window_id = new_focused_window;
}

guint32
Expand Down
12 changes: 11 additions & 1 deletion gdk/broadway/gdkeventsource.c
Expand Up @@ -345,7 +345,17 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
break;

case BROADWAY_EVENT_FOCUS:
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.old_id));
if (window)
{
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (window);
event->focus_change.in = FALSE;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, message->base.serial);
}
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.new_id));
if (window)
{
event = gdk_event_new (GDK_FOCUS_CHANGE);
Expand Down

0 comments on commit ca89f5a

Please sign in to comment.