mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
[wip] tearing: prefer client hint over fullscreen
This commit is contained in:
parent
db7f300554
commit
928e712c18
4 changed files with 34 additions and 7 deletions
|
|
@ -30,6 +30,12 @@ enum ssd_preference {
|
||||||
LAB_SSD_PREF_SERVER,
|
LAB_SSD_PREF_SERVER,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum three_state {
|
||||||
|
LAB_STATE_UNSPECIFIED = 0,
|
||||||
|
LAB_STATE_ENABLED,
|
||||||
|
LAB_STATE_DISABLED
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directions in which a view can be maximized. "None" is used
|
* Directions in which a view can be maximized. "None" is used
|
||||||
* internally to mean "not maximized" but is not valid in rc.xml.
|
* internally to mean "not maximized" but is not valid in rc.xml.
|
||||||
|
|
@ -163,7 +169,7 @@ struct view {
|
||||||
bool minimized;
|
bool minimized;
|
||||||
enum view_axis maximized;
|
enum view_axis maximized;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool tearing_hint;
|
enum three_state tearing_hint;
|
||||||
bool visible_on_all_workspaces;
|
bool visible_on_all_workspaces;
|
||||||
enum view_edge tiled;
|
enum view_edge tiled;
|
||||||
uint32_t edges_visible; /* enum wlr_edges bitset */
|
uint32_t edges_visible; /* enum wlr_edges bitset */
|
||||||
|
|
|
||||||
13
src/action.c
13
src/action.c
|
|
@ -1007,9 +1007,18 @@ actions_run(struct view *activator, struct server *server,
|
||||||
break;
|
break;
|
||||||
case ACTION_TYPE_TOGGLE_TEARING:
|
case ACTION_TYPE_TOGGLE_TEARING:
|
||||||
if (view) {
|
if (view) {
|
||||||
view->tearing_hint = !view->tearing_hint;
|
switch (view->tearing_hint) {
|
||||||
|
case LAB_STATE_UNSPECIFIED:
|
||||||
|
case LAB_STATE_DISABLED:
|
||||||
|
view->tearing_hint = LAB_STATE_ENABLED;
|
||||||
|
break;
|
||||||
|
case LAB_STATE_ENABLED:
|
||||||
|
view->tearing_hint = LAB_STATE_DISABLED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
wlr_log(WLR_DEBUG, "tearing %sabled",
|
wlr_log(WLR_DEBUG, "tearing %sabled",
|
||||||
view->tearing_hint ? "en" : "dis");
|
view->tearing_hint == LAB_STATE_ENABLED
|
||||||
|
? "en" : "dis");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_TYPE_TOGGLE_SHADE:
|
case ACTION_TYPE_TOGGLE_SHADE:
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,18 @@ get_tearing_preference(struct output *output)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If a hint has been set return the hint */
|
||||||
|
if (server->active_view->tearing_hint != LAB_STATE_UNSPECIFIED) {
|
||||||
|
return server->active_view->tearing_hint == LAB_STATE_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
/* If configured, automatically enable tearing for fullscreen applications */
|
/* If configured, automatically enable tearing for fullscreen applications */
|
||||||
if (rc.allow_tearing == LAB_TEARING_FULLSCREEN
|
if (rc.allow_tearing == LAB_TEARING_FULLSCREEN
|
||||||
&& server->active_view->fullscreen) {
|
&& server->active_view->fullscreen) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the active view requests tearing, or it is toggled on with action, allow it */
|
return false;
|
||||||
return server->active_view->tearing_hint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,16 @@ set_tearing_hint(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct tearing_controller *controller = wl_container_of(listener, controller, set_hint);
|
struct tearing_controller *controller = wl_container_of(listener, controller, set_hint);
|
||||||
struct view *view = view_from_wlr_surface(controller->tearing_control->surface);
|
struct view *view = view_from_wlr_surface(controller->tearing_control->surface);
|
||||||
if (view && controller->tearing_control->hint) {
|
if (view) {
|
||||||
view->tearing_hint = true;
|
/*
|
||||||
|
* tearing_control->hint is actually an enum:
|
||||||
|
* WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC = 0
|
||||||
|
* WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC = 1
|
||||||
|
*
|
||||||
|
* Using it as a bool here allows us to not ship the XML.
|
||||||
|
*/
|
||||||
|
view->tearing_hint = controller->tearing_control->hint
|
||||||
|
? LAB_STATE_ENABLED : LAB_STATE_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue