river-status support

This commit is contained in:
bluepython508
2025-03-17 15:10:28 +00:00
parent a5e4b682fe
commit b31915e6a6
10 changed files with 433 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
#include "wayland-client-core.h"
#include <ctype.h>
#include <signal.h>
#include <stdbool.h>
@@ -21,6 +22,7 @@
#include "river-layout-v3.h"
#include "ext-idle-notify-v1.h"
#include "river-control-unstable-v1.h"
#include "river-status-unstable-v1.h"
#include "load-script.h"
#include "call-exit-handler.h"
@@ -66,6 +68,12 @@ static void registry_handle_global (void *data, struct wl_registry *registry,
registry, name, &ext_idle_notifier_v1_interface, 1
);
}
else if ( strcmp(interface, zriver_status_manager_v1_interface.name) == 0 )
{
context.status_manager = wl_registry_bind(
registry, name, &zriver_status_manager_v1_interface, 4
);
}
else if ( strcmp(interface, wl_output_interface.name) == 0 )
{
struct wl_output *wl_output = wl_registry_bind(
@@ -135,7 +143,8 @@ static const struct wl_callback_listener sync_callback_listener = {
static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint32_t other_data)
{
static int i = 0;
if ( i == 1 )
i++;
if ( i > 2 )
{
assert(context.mode == ONESHOT);
context.loop = false;
@@ -145,6 +154,22 @@ static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint3
wl_callback_destroy(wl_callback);
context.sync_callback = NULL;
if (i == 1) {
struct Output *output;
wl_list_for_each(output, &context.outputs, link) {
output_status_init(output);
}
struct Seat *seat;
wl_list_for_each(seat, &context.seats, link) {
seat_status_init(seat);
}
context.sync_callback = wl_display_sync(context.wl_display);
wl_callback_add_listener(context.sync_callback, &sync_callback_listener, NULL);
return;
}
/* Load the script after connecting to the server and binding interfaces
* to allow calling Wayland requests from it.
*/
@@ -171,8 +196,6 @@ static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint3
/* Oneshot mode. Sync again so we are sure that all commands
* have been send, then exit.
*/
assert(i == 0);
i++;
context.sync_callback = wl_display_sync(context.wl_display);
wl_callback_add_listener(context.sync_callback, &sync_callback_listener, NULL);
fputs("INFO: No handlers installed: Riverguile will exit.\n", stderr);
@@ -381,6 +404,8 @@ int main (int argc, char *argv[])
river_layout_manager_v3_destroy(context.layout_manager);
if ( context.river_control != NULL )
zriver_control_v1_destroy(context.river_control);
if ( context.status_manager != NULL )
zriver_status_manager_v1_destroy(context.status_manager);
if ( context.sync_callback != NULL )
wl_callback_destroy(context.sync_callback);
if ( context.wl_registry != NULL )