7f62d19e6a870c83d1d1b165427013b32658bfe2 — Leon Henrik Plickat a month ago c610e9c
Add config option to enable/disable use of foreign toplevel management
M doc/lavalauncher.1.scd => doc/lavalauncher.1.scd +12 -4
@@ 56,6 56,13 @@ Comments start with an octothorpe ('#'). Any string can be quoted.
Global settings can be configured int the "global-settings" context. The
assignments which can be made in this context are as follows.

	Use foreign toplevel mangement protocol extension to enable toplevel and
	app-id related functionality. Can be "true" or "false". The default is
	"false". Behold: Not every compositor supports this extension. Enabling this
	option causes LavaLauncher to use CPU cycles on toplevel operations like
	spawning, focusing and closing windows and to consume slightly more memory.

	Automatically reload when a change in the configuration file is detected.
	Can be "true" or "false". The default is "false". Behold: If the

@@ 185,8 192,8 @@ this context are as follows.

	The app-id of toplevels LavaLauncher should consider to belong to this
	button. Behold: This requires the compositor to implement foreign toplevel
	button. Behold: This requires the global option "use-foreign-toplevel" to be

	The background colour of the individual button. This overrides the

@@ 244,8 251,9 @@ the commands. These variables are as follows.

	The amount of current toplevels which share the app-id of the button. If the
	compositor does not support foreign toplevel management, it is set to -1. If
	no app-id has been configured for the button, it is set to -2.
	compositor does not support foreign toplevel management or the global option
	"use-foreign-toplevel" has not been enabled, it is set to -1. If no app-id
	has been configured for the button, it is set to -2.

LavaLauncher excepts colours in the formats "#RRGGBBAA" or "#RRGGBB". Therefore,

M src/config/global.c => src/config/global.c +16 -1
@@ 47,12 47,27 @@ static bool global_set_watch (struct Lava_data *data, const char *arg)

static bool global_set_toplevel (struct Lava_data *data, const char *arg)
	if (is_boolean_true(arg))
		data->use_toplevel = true;
	else if (is_boolean_false(arg))
		data->use_toplevel = false;
		log_message(NULL, 0, "ERROR: 'use-foreign-toplevel' expects a boolean value.\n");
		return false;
	return true;

	const char *variable;
	bool (*set)(struct Lava_data*, const char*);
} global_configs[] = {
	{ .variable = "watch-config-file", .set = global_set_watch }
	{ .variable = "watch-config-file",    .set = global_set_watch    },
	{ .variable = "use-foreign-toplevel", .set = global_set_toplevel }

bool global_set_variable (struct Lava_data *data, const char *variable,

M src/lavalauncher.c => src/lavalauncher.c +1 -0
@@ 309,6 309,7 @@ static void init_data (struct Lava_data *data)
	data->layer_shell        = NULL;
	data->xdg_output_manager = NULL;
	data->toplevel_manager   = NULL;
	data->use_toplevel       = false;


M src/lavalauncher.h => src/lavalauncher.h +1 -0
@@ 37,6 37,7 @@ struct Lava_data
	struct zwlr_layer_shell_v1    *layer_shell;
	struct zxdg_output_manager_v1 *xdg_output_manager;

	bool use_toplevel;
	struct zwlr_foreign_toplevel_manager_v1 *toplevel_manager;
	struct wl_list toplevels;

M src/registry.c => src/registry.c +2 -0
@@ 73,6 73,8 @@ static void registry_handle_global (void *raw_data, struct wl_registry *registry
	else if (! strcmp(interface, zwlr_foreign_toplevel_manager_v1_interface.name))
		if (! data->use_toplevel)
		log_message(data, 2, "[registry] Get zwlr_foreign_toplevel_manager_v1.\n");
		if (! create_toplevel_manager(data, registry, name))
			goto error;

M src/toplevel.c => src/toplevel.c +0 -3
@@ 47,10 47,7 @@ int32_t count_toplevels_with_appid (struct Lava_data *data, const char *app_id)
	struct Lava_toplevel *toplevel;
	wl_list_for_each(toplevel, &data->toplevels, link)
		if (! strcmp(app_id, toplevel->current_app_id))
			log_message(NULL, 0, "found one.\n");

	return ret;