From 61cd3686da8af50f237acffeb325e4ecbce77564 Mon Sep 17 00:00:00 2001 From: Sergey Naumov Date: Sun, 24 Apr 2016 10:47:31 +0300 Subject: [PATCH] Shipping all payload in window event --- include/i3ipc++/ipc.hpp | 11 ++++++++++- src/ipc.cpp | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/i3ipc++/ipc.hpp b/include/i3ipc++/ipc.hpp index 584252d..a36b297 100644 --- a/include/i3ipc++/ipc.hpp +++ b/include/i3ipc++/ipc.hpp @@ -164,6 +164,15 @@ struct workspace_event_t { }; +/** + * A window event + */ +struct window_event_t { + WindowEventType type; + std::shared_ptr container; ///< A container event associated with @note With some WindowEventType could be null +}; + + /** * @deprecated */ @@ -245,7 +254,7 @@ public: sigc::signal signal_workspace_event; ///< Workspace event signal sigc::signal signal_output_event; ///< Output event signal sigc::signal signal_mode_event; ///< Output mode event signal - sigc::signal signal_window_event; ///< Window event signal + sigc::signal signal_window_event; ///< Window event signal sigc::signal signal_barconfig_update_event; ///< Barconfig update event signal sigc::signal&> signal_event; ///< i3 event signal @note Default handler routes event to signal according to type private: diff --git a/src/ipc.cpp b/src/ipc.cpp index b08d1dd..76714a9 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -216,30 +216,35 @@ connection::connection(const std::string& socket_path) : m_main_socket(i3_conne signal_mode_event.emit(); break; case ET_WINDOW: { - WindowEventType type; + window_event_t ev; Json::Value root; IPC_JSON_READ(root); std::string change = root["change"].asString(); if (change == "new") { - type = WindowEventType::NEW; + ev.type = WindowEventType::NEW; } else if (change == "close") { - type = WindowEventType::CLOSE; + ev.type = WindowEventType::CLOSE; } else if (change == "focus") { - type = WindowEventType::FOCUS; + ev.type = WindowEventType::FOCUS; } else if (change == "title") { - type = WindowEventType::TITLE; + ev.type = WindowEventType::TITLE; } else if (change == "fullscreen_mode") { - type = WindowEventType::FULLSCREEN_MODE; + ev.type = WindowEventType::FULLSCREEN_MODE; } else if (change == "move") { - type = WindowEventType::MOVE; + ev.type = WindowEventType::MOVE; } else if (change == "floating") { - type = WindowEventType::FLOATING; + ev.type = WindowEventType::FLOATING; } else if (change == "urgent") { - type = WindowEventType::URGENT; + ev.type = WindowEventType::URGENT; } I3IPC_DEBUG("WINDOW " << change) - signal_window_event.emit(type); + Json::Value container = root["container"]; + if (!container.isNull()) { + ev.container = parse_container_from_json(container); + } + + signal_window_event.emit(ev); break; } case ET_BARCONFIG_UPDATE: