Send IPC window events for focus and title changes

This patch fixes ticket #1168 to extend the window IPC event mechanism
to send IPC events for window focus and title changes. The newly added
window events use the same format as the already established "new"
event.

Specifically this patch:

* Moves the ipc_send_window_event() function from src/manage.c into
  src/ipc.c and adds an argument for the change property of the event
* Updates src/manage.c to use the new function signature. To ensure
  that the "new" event does not send the same event data as the
  "focus" event, setting focus now happens after the "new" event
  has been sent
* Adds IPC focus event notification to src/x.c. To workaround a problem
  during window close when accessing the window name, a function has been
  added to query whether a window is actually attached to its parent. To
  avoid obsolete focus notification, a new field has been added to keep
  track of the focus without any interference by the click handling
* Adds IPC title event notification to src/handlers.c. To avoid
  obsolete title notification, a function has been added to determine
  whether a window title has actually changed
* Updates the IPC documentation to include the new events
* Updates testcases/t/205-ipc-windows.t to include the "focus" event
  in order to ensure the correct event sequence
* Adds two new unit tests, b/testcases/t/219-ipc-window-focus.t and
  b/testcases/t/220-ipc-window-title.t to ensure proper "focus" and
 "title" events
This commit is contained in:
Marco Hunsicker
2014-02-22 11:52:01 +01:00
committed by Michael Stapelberg
parent 07d583d780
commit 00ee86de79
9 changed files with 278 additions and 45 deletions

View File

@ -1,7 +1,7 @@
IPC interface (interprocess communication)
==========================================
Michael Stapelberg <michael@i3wm.org>
October 2012
February 2014
This document describes how to interface with i3 from a separate process. This
is useful for example to remote-control i3 (to write test cases for example) or
@ -632,7 +632,8 @@ mode (2)::
Sent whenever i3 changes its binding mode.
window (3)::
Sent when a client's window is successfully reparented (that is when i3
has finished fitting it into a container).
has finished fitting it into a container), when a window received input
focus or when a window title has been updated.
barconfig_update (4)::
Sent when the hidden_state or mode field in the barconfig of any bar
instance was updated.
@ -712,14 +713,14 @@ mode is simply named default.
=== window event
This event consists of a single serialized map containing a property
+change (string)+ which currently can indicate only that a new window
has been successfully reparented (the value will be "new").
+change (string)+ which indicates the type of the change ("focus", "new",
"title").
Additionally a +container (object)+ field will be present, which consists
of the window's parent container. Be aware that the container will hold
the initial name of the newly reparented window (e.g. if you run urxvt
with a shell that changes the title, you will still at this point get the
window title as "urxvt").
of the window's parent container. Be aware that for the "new" event, the
container will hold the initial name of the newly reparented window (e.g.
if you run urxvt with a shell that changes the title, you will still at
this point get the window title as "urxvt").
*Example:*
---------------------------