diff --git a/resources/gresource-session.xml b/resources/gresource-session.xml index 4c70a9b..dde94c5 100644 --- a/resources/gresource-session.xml +++ b/resources/gresource-session.xml @@ -2,6 +2,7 @@ resources/session-shell.css + resources/virtual-keyboard.css resources/default.keymap \ No newline at end of file diff --git a/src/foreign.c b/src/foreign.c index 02597a0..c7e0f7a 100644 --- a/src/foreign.c +++ b/src/foreign.c @@ -2,6 +2,7 @@ #include #include "wlr-foreign-toplevel-management-unstable-v1.h" #include "foreign.h" +#include "wayland.h" /** * @DiyaForeignWindow Object definition @@ -209,6 +210,8 @@ static void toplevel_handle_state(void *data, wstate |= DIYA_WIN_STATE_FOCUS; break; } + g_debug("toplevel_handle_state: (%.04x) active: %d, full screen %d, maximize %d, minimize %d", wstate, wstate & DIYA_WIN_STATE_FOCUS, + wstate & DIYA_WIN_STATE_FULLSCREEN, wstate & DIYA_WIN_STATE_MAXIMIZE, wstate & DIYA_WIN_STATE_MINIMIZE); g_object_set(win, "state", wstate, NULL); } static void toplevel_handle_done(void *data, @@ -309,4 +312,58 @@ void diya_session_shell_foreign_toplevel_register(struct wl_registry *registry, DiyaSessionShell* session_shell = DIYA_SESSION_SHELL(shell); g_toplevel_manager = wl_registry_bind(registry, name, &zwlr_foreign_toplevel_manager_v1_interface, 3); zwlr_foreign_toplevel_manager_v1_add_listener(g_toplevel_manager, &g_toplevel_manager_impl, (void *)session_shell); +} + + +DiyaShell* diya_foreign_window_get_shell(DiyaForeignWindow* self) +{ + assert(self); + gpointer ptr; + + g_object_get(self, "shell", &ptr, NULL); + DiyaShell* shell = DIYA_SHELL(ptr); + assert(shell); + return shell; +} +void diya_foreign_window_set_state(DiyaForeignWindow* self, enum diya_win_state state, bool value) +{ + if(state & DIYA_WIN_STATE_MINIMIZE) + { + if(value) + { + zwlr_foreign_toplevel_handle_v1_set_minimized(self->handle); + } + else + { + zwlr_foreign_toplevel_handle_v1_unset_minimized(self->handle); + } + } + + if(state & DIYA_WIN_STATE_MAXIMIZE) + { + if(value) + { + zwlr_foreign_toplevel_handle_v1_set_maximized(self->handle); + } + else + { + zwlr_foreign_toplevel_handle_v1_unset_maximized(self->handle); + } + } + + if(state & DIYA_WIN_STATE_FULLSCREEN) + { + DiyaShell* shell = diya_foreign_window_get_shell(self); + DiyaWayland* wl = diya_shell_get_wayland(shell); + assert(wl); + struct wl_output* output = diya_wayland_get_output(wl, 0); + if(value) + { + zwlr_foreign_toplevel_handle_v1_set_fullscreen(self->handle, output); + } + else + { + zwlr_foreign_toplevel_handle_v1_unset_fullscreen(self->handle); + } + } } \ No newline at end of file diff --git a/src/foreign.h b/src/foreign.h index 2a65a20..21332ac 100644 --- a/src/foreign.h +++ b/src/foreign.h @@ -13,4 +13,7 @@ enum diya_win_state void diya_session_shell_foreign_toplevel_register(struct wl_registry *registry, uint32_t name, DiyaShell * shell); +DiyaShell* diya_foreign_window_get_shell(DiyaForeignWindow* window); + +void diya_foreign_window_set_state(DiyaForeignWindow* window, enum diya_win_state state, bool value); #endif \ No newline at end of file diff --git a/src/launcher.c b/src/launcher.c index 9bddabb..1410abc 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -35,6 +35,26 @@ static void session_lock(GtkWidget *widget,gpointer data) diya_session_shell_lock(data); } +static void show_windows(GtkWidget *widget,gpointer data) +{ + (void) widget; + g_warning("Show all windows"); + DiyaSessionShell * shell = DIYA_SESSION_SHELL(data); + assert(shell); + GHashTable* windows = NULL; + g_object_get(shell, "windows", &windows, NULL); + assert(windows); + GHashTableIter iter; + gpointer handle; + DiyaForeignWindow* window; + g_hash_table_iter_init (&iter, windows); + while (g_hash_table_iter_next(&iter, (gpointer) &handle, (gpointer) &window)) + { + g_warning("unset minimized %s", diya_object_to_string(window)); + diya_foreign_window_set_state(window, DIYA_WIN_STATE_MINIMIZE, false); + } +} + void diya_session_shell_launcher_init(DiyaSessionShell * shell) { assert(shell); @@ -74,6 +94,10 @@ void diya_session_shell_launcher_init(DiyaSessionShell * shell) GtkWidget * button = gtk_button_new_with_label ("lock"); g_signal_connect (button, "clicked", G_CALLBACK (session_lock), shell); gtk_box_append (GTK_BOX (box), button); + + button = gtk_button_new_with_label ("show all windows"); + g_signal_connect (button, "clicked", G_CALLBACK (show_windows), shell); + gtk_box_append (GTK_BOX (box), button); //g_signal_connect (gtk_window, "orientation-changed", G_CALLBACK (on_orientation_changed), /*data*/NULL); gtk_window_present (GTK_WINDOW (gtk_window));