SnapToRegion: Add dynamic overlay

Either uses a half transparent single rect if running
hardware accelerated or uses a solid struct multirect
outline if not.
This commit is contained in:
Consolatis 2022-09-13 08:15:33 +02:00
parent 4edd67de17
commit eb5c8cfdad
10 changed files with 88 additions and 45 deletions

View file

@ -47,6 +47,7 @@
#include "cursor.h"
#include "config/keybind.h"
#include "config/rcxml.h"
#include "regions.h"
#if HAVE_NLS
#include <libintl.h>
#include <locale.h>
@ -156,7 +157,9 @@ struct seat {
struct wlr_scene_tree *icons;
} drag;
struct wlr_scene_rect *region_overlay;
/* Private use by regions.c */
struct region *region_active;
struct region_overlay region_overlay;
struct wl_client *active_client_while_inhibited;
struct wl_list inputs;
@ -312,6 +315,7 @@ struct output {
struct wlr_box usable_area;
struct wl_list regions; /* struct region.link */
struct wlr_box regions_usable_area;
struct lab_data_buffer *osd_buffer;

View file

@ -2,14 +2,13 @@
#ifndef __LABWC_REGIONS_H
#define __LABWC_REGIONS_H
//FIXME: ignore that there could be more than a single seat
struct seat;
struct view;
struct server;
struct output;
struct wl_list;
struct wlr_box;
struct multi_rect;
/* Double use: rcxml.c for config and output.c for usage */
struct region {
@ -23,17 +22,24 @@ struct region {
} center;
};
struct region_overlay {
struct wlr_scene_tree *tree;
union {
struct wlr_scene_rect *overlay;
struct multi_rect *pixman_overlay;
};
};
/* Can be used as a cheap check to detect if there are any regions configured */
bool regions_available(void);
void regions_init(struct server *server, struct seat *seat);
void regions_update(struct output *output);
void regions_evacuate_output(struct output *output);
void regions_destroy(struct wl_list *regions);
void regions_destroy(struct seat *seat, struct wl_list *regions);
struct region *regions_from_cursor(struct server *server);
struct region *regions_from_name(const char *region_name, struct output *output);
void regions_show_overlay(struct view *view, struct seat *seat, struct region *region);
void regions_hide_overlay(struct server *server, struct seat *seat);
void regions_hide_overlay(struct seat *seat);
#endif /* __LABWC_REGIONS_H */