I figured there was a better way to do this, thanks for the suggestions :)
I submitted these more for comments than for "please merge as is" anyway,
so that's helpful. I'll play with it more when I get some spare time in a
couple weeks.
Thanks,
Kevin
On Tue, Nov 20, 2012 at 3:28 AM, Michael Stapelberg <michael@xxxxxxxx>wrote:
Hi Kevin,
Kevin Murphy <kemurphy.cmu@xxxxxxxxx> writes:
+/** Request the id and title of the focused window */I’d prefer this to be "GET_FOCUSED", just because getting the x11 focus
+#define I3_IPC_MESSAGE_TYPE_GET_FOCUS 8
is a trivial thing to do already for which you wouldn’t need window
manager support.
+ ipc_send_event("focus", I3_IPC_EVENT_FOCUS,Is there a reason why you don’t include the properties you send in
"{\"change\":\"window\"}");
GET_FOCUS replies right here? You could avoid one extra round-trip (and
race conditions!) with that.
+ if (con == focused)Same here.
+ ipc_send_event("focus", I3_IPC_EVENT_FOCUS,
"{\"change\":\"title\"}");
+ y(map_open);Is there a reason to not use dump_node? Actually, is there a reason to
+
+ ystr("id");
+ if (focused->window != NULL) {
+ y(integer, focused->window->id);
+ } else {
+ y(integer, focused->frame);
+ }
+
+ ystr("title");
+ if (focused->window && focused->window->name)
+ ystr(i3string_as_utf8(focused->window->name));
+ else if (focused->type != CT_WORKSPACE && focused->name)
+ ystr(focused->name);
+ else
+ ystr("");
+
+ y(map_close);
not use the GET_TREE ipc request and then filter for the focused node
(which is trivial)? It includes the same properties.
I think the event part of this is rather nice, but the request/reply is
unnecessary. You might want to have a look at
workspace.c:ipc_send_workspace_focus_event to see how other events
include the entire sub-tree. Using this technique would lead to a more
consistent IPC interface than your suggestion.
--
Best regards,
Michael