update dwl protocol
This commit is contained in:
		
							parent
							
								
									1573c6348a
								
							
						
					
					
						commit
						0b5710da3e
					
				| @ -37,10 +37,35 @@ | |||||||
|             </description> |             </description> | ||||||
|         </request> |         </request> | ||||||
| 
 | 
 | ||||||
|  |         <request name="get_monitor"> | ||||||
|  |             <description summary="gets a dwl monitor from an output"> | ||||||
|  |             </description> | ||||||
|  |             <arg name="id" type="new_id" interface="znet_tapesoftware_dwl_wm_monitor_v1" /> | ||||||
|  |             <arg name="output" type="object" interface="wl_output" /> | ||||||
|  |         </request> | ||||||
|  | 
 | ||||||
|         <event name="tag"> |         <event name="tag"> | ||||||
|             <description summary="announces the presence of a tag"> |             <description summary="announces the presence of a tag"> | ||||||
|             </description> |             </description> | ||||||
|             <arg name="name" type="string"/> |             <arg name="name" type="string"/> | ||||||
|         </event> |         </event> | ||||||
|     </interface> |     </interface> | ||||||
|  | 
 | ||||||
|  |     <interface name="znet_tapesoftware_dwl_wm_monitor_v1" version="1"> | ||||||
|  |         <description summary="control one monitor"> | ||||||
|  |         </description> | ||||||
|  | 
 | ||||||
|  |         <request name="release" type="destructor"> | ||||||
|  |             <description summary="release dwl_monitor"> | ||||||
|  |             </description> | ||||||
|  |         </request> | ||||||
|  | 
 | ||||||
|  |         <event name="tag"> | ||||||
|  |             <description summary="sent every time a tag state gets updated"> | ||||||
|  |             </description> | ||||||
|  |             <arg name="tag" type="int"/> | ||||||
|  |             <arg name="active" type="int"/> | ||||||
|  |             <arg name="num_clients" type="int"/> | ||||||
|  |         </event> | ||||||
|  |     </interface> | ||||||
| </protocol> | </protocol> | ||||||
|  | |||||||
							
								
								
									
										40
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/main.cpp
									
									
									
									
									
								
							| @ -1,6 +1,7 @@ | |||||||
| // somebar - dwl bar
 | // somebar - dwl bar
 | ||||||
| // See LICENSE file for copyright and license details.
 | // See LICENSE file for copyright and license details.
 | ||||||
| 
 | 
 | ||||||
|  | #include <cstdio> | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| #include <math.h> | #include <math.h> | ||||||
| #include <signal.h> | #include <signal.h> | ||||||
| @ -21,6 +22,13 @@ | |||||||
| #include "common.hpp" | #include "common.hpp" | ||||||
| #include "bar.hpp" | #include "bar.hpp" | ||||||
| 
 | 
 | ||||||
|  | struct Monitor { | ||||||
|  |     uint32_t name; | ||||||
|  |     wl_output *wlOutput; | ||||||
|  |     znet_tapesoftware_dwl_wm_monitor_v1 *dwlMonitor; | ||||||
|  |     std::optional<Bar> bar; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| static void waylandFlush(); | static void waylandFlush(); | ||||||
| static void waylandWriteReady(); | static void waylandWriteReady(); | ||||||
| static void requireGlobal(const void *p, const char *name); | static void requireGlobal(const void *p, const char *name); | ||||||
| @ -34,6 +42,7 @@ wl_shm *shm; | |||||||
| zwlr_layer_shell_v1 *wlrLayerShell; | zwlr_layer_shell_v1 *wlrLayerShell; | ||||||
| znet_tapesoftware_dwl_wm_v1 *dwlWm; | znet_tapesoftware_dwl_wm_v1 *dwlWm; | ||||||
| std::vector<QString> tagNames; | std::vector<QString> tagNames; | ||||||
|  | static std::vector<Monitor> monitors; | ||||||
| static std::optional<Bar> bar; | static std::optional<Bar> bar; | ||||||
| static std::string statusFifoName; | static std::string statusFifoName; | ||||||
| static int statusFifoFd {-1}; | static int statusFifoFd {-1}; | ||||||
| @ -115,6 +124,25 @@ static const struct znet_tapesoftware_dwl_wm_v1_listener dwlWmListener = { | |||||||
|     }, |     }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | static const struct znet_tapesoftware_dwl_wm_monitor_v1_listener dwlWmMonitorListener { | ||||||
|  |     .tag = [](void*, znet_tapesoftware_dwl_wm_monitor_v1*, int tag, int active, int numClients) { | ||||||
|  |         printf("tag %s: active=%d, num_clients=%d\n", qPrintable(tagNames[tag]), active, numClients); | ||||||
|  |     } | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | static void setupOutput(Monitor &monitor) { | ||||||
|  |     monitor.dwlMonitor = znet_tapesoftware_dwl_wm_v1_get_monitor(dwlWm, monitor.wlOutput); | ||||||
|  |     znet_tapesoftware_dwl_wm_monitor_v1_add_listener(monitor.dwlMonitor, &dwlWmMonitorListener, &monitor); | ||||||
|  |     monitor.bar.emplace(monitor.wlOutput); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void onOutput(int name, wl_output *output) { | ||||||
|  |     auto& monitor = monitors.emplace_back(name, output); | ||||||
|  |     if (dwlWm) { | ||||||
|  |         setupOutput(monitor); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // called after we have received the initial batch of globals
 | // called after we have received the initial batch of globals
 | ||||||
| static void onReady() | static void onReady() | ||||||
| { | { | ||||||
| @ -122,8 +150,14 @@ static void onReady() | |||||||
|     requireGlobal(shm, "wl_shm"); |     requireGlobal(shm, "wl_shm"); | ||||||
|     requireGlobal(seat, "wl_seat"); |     requireGlobal(seat, "wl_seat"); | ||||||
|     requireGlobal(wlrLayerShell, "zwlr_layer_shell_v1"); |     requireGlobal(wlrLayerShell, "zwlr_layer_shell_v1"); | ||||||
|  |     requireGlobal(dwlWm, "znet_tapesoftware_dwl_wm_v1"); | ||||||
|     setupStatusFifo(); |     setupStatusFifo(); | ||||||
|     bar.emplace(nullptr); |     wl_display_roundtrip(display); // roundtrip so we receive all dwl tags etc.
 | ||||||
|  |     for (auto& monitor : monitors) { | ||||||
|  |         auto monitor = znet_tapesoftware_dwl_wm_v1_get_monitor(dwlWm, output); | ||||||
|  |         printf("created monitor %p for output %p\n", monitor, output); | ||||||
|  |         bar.emplace(output); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void setupStatusFifo() | static void setupStatusFifo() | ||||||
| @ -195,9 +229,11 @@ static void registryHandleGlobal(void*, wl_registry *registry, uint32_t name, co | |||||||
|     if (seat == nullptr && reg.handle(seat, wl_seat_interface, 7)) { |     if (seat == nullptr && reg.handle(seat, wl_seat_interface, 7)) { | ||||||
|         wl_seat_add_listener(seat, &seatListener, nullptr); |         wl_seat_add_listener(seat, &seatListener, nullptr); | ||||||
|     } |     } | ||||||
|  |     if (wl_output *output; reg.handle(output, wl_output_interface, 1)) { | ||||||
|  |         outputs.push_back(output); | ||||||
|  |     } | ||||||
|     if (reg.handle(dwlWm, znet_tapesoftware_dwl_wm_v1_interface, 1)) { |     if (reg.handle(dwlWm, znet_tapesoftware_dwl_wm_v1_interface, 1)) { | ||||||
|         znet_tapesoftware_dwl_wm_v1_add_listener(dwlWm, &dwlWmListener, nullptr); |         znet_tapesoftware_dwl_wm_v1_add_listener(dwlWm, &dwlWmListener, nullptr); | ||||||
|         wl_display_roundtrip(display); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| static const struct wl_registry_listener registry_listener = { registryHandleGlobal, nullptr }; | static const struct wl_registry_listener registry_listener = { registryHandleGlobal, nullptr }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user