|
|
|
@ -9,26 +9,27 @@
|
|
|
|
|
|
|
|
|
|
#define WLR_FOREIGN_TOPLEVEL_MANAGEMENT_VERSION 3
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
|
|
|
|
* 1. foreign-toplevel
|
|
|
|
|
* Prints a list of opened toplevels
|
|
|
|
|
* 2. foreign-toplevel -f <id>
|
|
|
|
|
* Focus the toplevel with the given id
|
|
|
|
|
* 3. foreign-toplevel -a <id>
|
|
|
|
|
* Maximize the toplevel with the given id
|
|
|
|
|
* 4. foreign-toplevel -u <id>
|
|
|
|
|
* Unmaximize the toplevel with the given id
|
|
|
|
|
* 5. foreign-toplevel -i <id>
|
|
|
|
|
* Minimize the toplevel with the given id
|
|
|
|
|
* 6. foreign-toplevel -r <id>
|
|
|
|
|
* Restore(unminimize) the toplevel with the given id
|
|
|
|
|
* 7. foreign-toplevel -c <id>
|
|
|
|
|
* Close the toplevel with the given id
|
|
|
|
|
* 8. foreign-toplevel -m
|
|
|
|
|
* Continuously print changes to the list of opened toplevels.
|
|
|
|
|
* Can be used together with some of the previous options.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void print_help(void) {
|
|
|
|
|
static const char usage[] =
|
|
|
|
|
"Usage: foreign-toplevel [OPTIONS] ...\n"
|
|
|
|
|
"Manage and view information about toplevel windows.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" -f <id> focus\n"
|
|
|
|
|
" -s <id> fullscreen\n"
|
|
|
|
|
" -o <output_id> select output for fullscreen toplevel to appear on. Use this\n"
|
|
|
|
|
" option with -s. View available outputs with wayland-info.\n"
|
|
|
|
|
" -S <id> unfullscreen\n"
|
|
|
|
|
" -a <id> maximize\n"
|
|
|
|
|
" -u <id> unmaximize\n"
|
|
|
|
|
" -i <id> minimize\n"
|
|
|
|
|
" -r <id> restore(unminimize)\n"
|
|
|
|
|
" -c <id> close\n"
|
|
|
|
|
" -m continuously print changes to the list of opened toplevels\n"
|
|
|
|
|
" Can be used together with some of the previous options.\n"
|
|
|
|
|
" -h print help message and quit\n";
|
|
|
|
|
fprintf(stderr, "%s", usage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum toplevel_state_field {
|
|
|
|
|
TOPLEVEL_STATE_MAXIMIZED = (1 << 0),
|
|
|
|
@ -39,6 +40,8 @@ enum toplevel_state_field {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const uint32_t no_parent = (uint32_t)-1;
|
|
|
|
|
static struct wl_output *pref_output = NULL;
|
|
|
|
|
static uint32_t pref_output_id = UINT32_MAX;
|
|
|
|
|
|
|
|
|
|
struct toplevel_state {
|
|
|
|
|
char *title;
|
|
|
|
@ -94,7 +97,7 @@ static void print_toplevel(struct toplevel_v1 *toplevel, bool print_endl) {
|
|
|
|
|
} else {
|
|
|
|
|
printf(" no parent");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (print_endl) {
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
@ -271,9 +274,11 @@ struct wl_seat *seat = NULL;
|
|
|
|
|
static void handle_global(void *data, struct wl_registry *registry,
|
|
|
|
|
uint32_t name, const char *interface, uint32_t version) {
|
|
|
|
|
if (strcmp(interface, wl_output_interface.name) == 0) {
|
|
|
|
|
struct wl_output *output = wl_registry_bind(registry, name,
|
|
|
|
|
&wl_output_interface, version);
|
|
|
|
|
wl_output_set_user_data(output, (void*)(size_t)name); // assign some ID to the output
|
|
|
|
|
if (name == pref_output_id) {
|
|
|
|
|
pref_output = wl_registry_bind(registry, name,
|
|
|
|
|
&wl_output_interface, version);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else if (strcmp(interface,
|
|
|
|
|
zwlr_foreign_toplevel_manager_v1_interface.name) == 0) {
|
|
|
|
|
toplevel_manager = wl_registry_bind(registry, name,
|
|
|
|
@ -324,8 +329,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
int one_shot = 1;
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
// TODO maybe print usage with -h?
|
|
|
|
|
while ((c = getopt(argc, argv, "f:a:u:i:r:c:s:S:m")) != -1) {
|
|
|
|
|
while ((c = getopt(argc, argv, "f:a:u:i:r:c:s:S:mo:h")) != -1) {
|
|
|
|
|
switch (c) {
|
|
|
|
|
case 'f':
|
|
|
|
|
focus_id = atoi(optarg);
|
|
|
|
@ -354,6 +358,17 @@ int main(int argc, char **argv) {
|
|
|
|
|
case 'm':
|
|
|
|
|
one_shot = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 'o':
|
|
|
|
|
pref_output_id = atoi(optarg);
|
|
|
|
|
break;
|
|
|
|
|
case '?':
|
|
|
|
|
print_help();
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
break;
|
|
|
|
|
case 'h':
|
|
|
|
|
print_help();
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -391,7 +406,11 @@ int main(int argc, char **argv) {
|
|
|
|
|
zwlr_foreign_toplevel_handle_v1_unset_minimized(toplevel->zwlr_toplevel);
|
|
|
|
|
}
|
|
|
|
|
if ((toplevel = toplevel_by_id_or_bail(fullscreen_id))) {
|
|
|
|
|
zwlr_foreign_toplevel_handle_v1_set_fullscreen(toplevel->zwlr_toplevel, NULL);
|
|
|
|
|
if (pref_output_id != UINT32_MAX && pref_output == NULL) {
|
|
|
|
|
fprintf(stderr, "Could not find output %i\n", pref_output_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zwlr_foreign_toplevel_handle_v1_set_fullscreen(toplevel->zwlr_toplevel, pref_output);
|
|
|
|
|
}
|
|
|
|
|
if ((toplevel = toplevel_by_id_or_bail(unfullscreen_id))) {
|
|
|
|
|
zwlr_foreign_toplevel_handle_v1_unset_fullscreen(toplevel->zwlr_toplevel);
|
|
|
|
|