File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed
Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,17 @@ struct container_t {
153153 std::list< std::shared_ptr<container_t > > nodes;
154154};
155155
156+
157+ /* *
158+ * A workspace event
159+ */
160+ struct workspace_event_t {
161+ WorkspaceEventType type;
162+ std::shared_ptr<workspace_t > current; // /< Current focused workspace
163+ std::shared_ptr<workspace_t > old; // /< Old (previous) workspace @note With some WindowEventType could be null
164+ };
165+
166+
156167/* *
157168 * @deprecated
158169 */
@@ -231,7 +242,7 @@ class connection {
231242 */
232243 void handle_event ();
233244
234- sigc::signal<void , WorkspaceEventType > signal_workspace_event; // /< Workspace event signal
245+ sigc::signal<void , const workspace_event_t & > signal_workspace_event; // /< Workspace event signal
235246 sigc::signal<void > signal_output_event; // /< Output event signal
236247 sigc::signal<void > signal_mode_event; // /< Output mode event signal
237248 sigc::signal<void , WindowEventType> signal_window_event; // /< Window event signal
Original file line number Diff line number Diff line change @@ -176,25 +176,35 @@ connection::connection(const std::string& socket_path) : m_main_socket(i3_conne
176176 signal_event.connect ([this ](EventType event_type, const std::shared_ptr<const buf_t >& buf) {
177177 switch (event_type) {
178178 case ET_WORKSPACE: {
179- WorkspaceEventType type ;
179+ workspace_event_t ev ;
180180 Json::Value root;
181181 IPC_JSON_READ (root);
182182 std::string change = root[" change" ].asString ();
183183 if (change == " focus" ) {
184- type = WorkspaceEventType::FOCUS;
184+ ev. type = WorkspaceEventType::FOCUS;
185185 } else if (change == " init" ) {
186- type = WorkspaceEventType::INIT;
186+ ev. type = WorkspaceEventType::INIT;
187187 } else if (change == " empty" ) {
188- type = WorkspaceEventType::EMPTY;
188+ ev. type = WorkspaceEventType::EMPTY;
189189 } else if (change == " urgent" ) {
190- type = WorkspaceEventType::URGENT;
190+ ev. type = WorkspaceEventType::URGENT;
191191 } else {
192192 I3IPC_WARN (" Unknown workspace event type " << change)
193193 break ;
194194 }
195195 I3IPC_DEBUG (" WORKSPACE " << change)
196196
197- signal_workspace_event.emit (type);
197+ Json::Value current = root[" current" ];
198+ Json::Value old = root[" current" ];
199+
200+ if (!current.isNull ()) {
201+ ev.current = parse_workspace_from_json (current);
202+ }
203+ if (!old.isNull ()) {
204+ ev.old = parse_workspace_from_json (old);
205+ }
206+
207+ signal_workspace_event.emit (ev);
198208 break ;
199209 }
200210 case ET_OUTPUT:
You can’t perform that action at this time.
0 commit comments