mirror of
https://github.com/labwc/labwc.git
synced 2026-04-17 06:46:28 -04:00
This commit is contained in:
parent
8b32422b93
commit
da37e97a45
8 changed files with 106 additions and 0 deletions
|
|
@ -424,6 +424,13 @@ Actions are used in menus and keyboard/mouse bindings.
|
||||||
Toggle the screen magnifier on or off at the last magnification level
|
Toggle the screen magnifier on or off at the last magnification level
|
||||||
used.
|
used.
|
||||||
|
|
||||||
|
*<action name="ToggleShowDesktop" />*
|
||||||
|
Minimize all windows in the current workspace so that the desktop becomes
|
||||||
|
visible. On calling the action again the hidden windows are unminimized,
|
||||||
|
provided that - since the initial `ShowDesktop` - (a) no windows have been
|
||||||
|
unminimized; (b) workspaces have not been switched; and (c) no new
|
||||||
|
applications have been started.
|
||||||
|
|
||||||
*<action name="ZoomIn">*++
|
*<action name="ZoomIn">*++
|
||||||
*<action name="ZoomOut">*
|
*<action name="ZoomOut">*
|
||||||
Increase or decrease the magnification level for the screen magnifier.
|
Increase or decrease the magnification level for the screen magnifier.
|
||||||
|
|
|
||||||
8
include/show-desktop.h
Normal file
8
include/show-desktop.h
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#ifndef LABWC_SHOW_DESKTOP_H
|
||||||
|
#define LABWC_SHOW_DESKTOP_H
|
||||||
|
|
||||||
|
void show_desktop_toggle(void);
|
||||||
|
void show_desktop_reset(void);
|
||||||
|
|
||||||
|
#endif /* LABWC_SHOW_DESKTOP_H */
|
||||||
|
|
@ -184,6 +184,7 @@ struct view {
|
||||||
enum ssd_preference ssd_preference;
|
enum ssd_preference ssd_preference;
|
||||||
bool shaded;
|
bool shaded;
|
||||||
bool minimized;
|
bool minimized;
|
||||||
|
bool was_minimized_by_show_desktop_action;
|
||||||
enum view_axis maximized;
|
enum view_axis maximized;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool tearing_hint;
|
bool tearing_hint;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "output-virtual.h"
|
#include "output-virtual.h"
|
||||||
#include "regions.h"
|
#include "regions.h"
|
||||||
|
#include "show-desktop.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "translate.h"
|
#include "translate.h"
|
||||||
|
|
@ -133,6 +134,7 @@ struct action_arg_list {
|
||||||
X(TOGGLE_MAGNIFY, "ToggleMagnify") \
|
X(TOGGLE_MAGNIFY, "ToggleMagnify") \
|
||||||
X(ZOOM_IN, "ZoomIn") \
|
X(ZOOM_IN, "ZoomIn") \
|
||||||
X(ZOOM_OUT, "ZoomOut") \
|
X(ZOOM_OUT, "ZoomOut") \
|
||||||
|
X(TOGGLE_SHOW_DESKTOP, "ToggleShowDesktop") \
|
||||||
X(WARP_CURSOR, "WarpCursor") \
|
X(WARP_CURSOR, "WarpCursor") \
|
||||||
X(HIDE_CURSOR, "HideCursor") \
|
X(HIDE_CURSOR, "HideCursor") \
|
||||||
X(DEBUG_TOGGLE_KEY_STATE_INDICATOR, "DebugToggleKeyStateIndicator")
|
X(DEBUG_TOGGLE_KEY_STATE_INDICATOR, "DebugToggleKeyStateIndicator")
|
||||||
|
|
@ -1562,6 +1564,9 @@ run_action(struct view *view, struct action *action,
|
||||||
case ACTION_TYPE_ZOOM_OUT:
|
case ACTION_TYPE_ZOOM_OUT:
|
||||||
magnifier_set_scale(MAGNIFY_DECREASE);
|
magnifier_set_scale(MAGNIFY_DECREASE);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_TYPE_TOGGLE_SHOW_DESKTOP:
|
||||||
|
show_desktop_toggle();
|
||||||
|
break;
|
||||||
case ACTION_TYPE_WARP_CURSOR: {
|
case ACTION_TYPE_WARP_CURSOR: {
|
||||||
const char *to = action_get_str(action, "to", "output");
|
const char *to = action_get_str(action, "to", "output");
|
||||||
const char *x = action_get_str(action, "x", "center");
|
const char *x = action_get_str(action, "x", "center");
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
#include "show-desktop.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
|
@ -113,6 +114,8 @@ desktop_focus_view(struct view *view, bool raise)
|
||||||
*/
|
*/
|
||||||
struct view *dialog = view_get_modal_dialog(view);
|
struct view *dialog = view_get_modal_dialog(view);
|
||||||
set_or_offer_focus(dialog ? dialog : view);
|
set_or_offer_focus(dialog ? dialog : view);
|
||||||
|
|
||||||
|
show_desktop_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: focus layer-shell surfaces also? */
|
/* TODO: focus layer-shell surfaces also? */
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ labwc_sources = files(
|
||||||
'seat.c',
|
'seat.c',
|
||||||
'server.c',
|
'server.c',
|
||||||
'session-lock.c',
|
'session-lock.c',
|
||||||
|
'show-desktop.c',
|
||||||
'snap-constraints.c',
|
'snap-constraints.c',
|
||||||
'snap.c',
|
'snap.c',
|
||||||
'tearing.c',
|
'tearing.c',
|
||||||
|
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "input/keyboard.h"
|
#include "input/keyboard.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
#include "show-desktop.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
|
||||||
|
|
@ -495,6 +496,8 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
||||||
desktop_update_top_layer_visibility();
|
desktop_update_top_layer_visibility();
|
||||||
|
|
||||||
wlr_ext_workspace_handle_v1_set_active(target->ext_workspace, true);
|
wlr_ext_workspace_handle_v1_set_active(target->ext_workspace, true);
|
||||||
|
|
||||||
|
show_desktop_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue