mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
This commit is contained in:
parent
8b32422b93
commit
da37e97a45
8 changed files with 106 additions and 0 deletions
78
src/show-desktop.c
Normal file
78
src/show-desktop.c
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#include "show-desktop.h"
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include "common/array.h"
|
||||
#include "config/types.h"
|
||||
#include "labwc.h"
|
||||
#include "view.h"
|
||||
|
||||
static bool is_showing_desktop;
|
||||
|
||||
static void
|
||||
minimize_views(struct wl_array *views, bool minimize)
|
||||
{
|
||||
struct view **view;
|
||||
wl_array_for_each_reverse(view, views) {
|
||||
view_minimize(*view, minimize);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
show(void)
|
||||
{
|
||||
static struct wl_array views;
|
||||
wl_array_init(&views);
|
||||
|
||||
/* Build array first as minimize changes server.views */
|
||||
struct view *view;
|
||||
for_each_view(view, &server.views, LAB_VIEW_CRITERIA_CURRENT_WORKSPACE) {
|
||||
if (view->minimized) {
|
||||
continue;
|
||||
}
|
||||
view->was_minimized_by_show_desktop_action = true;
|
||||
array_add(&views, view);
|
||||
}
|
||||
minimize_views(&views, true);
|
||||
is_showing_desktop = true;
|
||||
|
||||
wl_array_release(&views);
|
||||
}
|
||||
|
||||
static void
|
||||
restore(void)
|
||||
{
|
||||
static struct wl_array views;
|
||||
wl_array_init(&views);
|
||||
|
||||
struct view *view;
|
||||
for_each_view(view, &server.views, LAB_VIEW_CRITERIA_CURRENT_WORKSPACE) {
|
||||
if (view->was_minimized_by_show_desktop_action) {
|
||||
array_add(&views, view);
|
||||
}
|
||||
}
|
||||
minimize_views(&views, false);
|
||||
show_desktop_reset();
|
||||
|
||||
wl_array_release(&views);
|
||||
}
|
||||
|
||||
void
|
||||
show_desktop_toggle(void)
|
||||
{
|
||||
if (is_showing_desktop) {
|
||||
restore();
|
||||
} else {
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
show_desktop_reset(void)
|
||||
{
|
||||
is_showing_desktop = false;
|
||||
|
||||
struct view *view;
|
||||
for_each_view(view, &server.views, LAB_VIEW_CRITERIA_NONE) {
|
||||
view->was_minimized_by_show_desktop_action = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue