This commit is contained in:
2024-07-07 22:30:06 -07:00
7 changed files with 42 additions and 19 deletions

View File

@ -474,6 +474,7 @@ pub fn applyState(output: *Output, state: *wlr.Output.State) error{CommitFailed}
fn handleEnableDisable(output: *Output) void {
output.updateLockRenderStateOnEnableDisable();
output.gamma_dirty = true;
if (output.wlr_output.enabled) {
// Add the output to root.active_outputs and the output layout if it has not
@ -539,18 +540,23 @@ fn renderAndCommit(output: *Output, scene_output: *wlr.SceneOutput) !void {
var state = wlr.Output.State.init();
defer state.finish();
if (server.root.gamma_control_manager.getControl(output.wlr_output)) |control| {
log.info("applying gamma settings from client", .{});
if (!control.apply(&state)) return error.OutOfMemory;
} else {
log.info("clearing gamma settings from client", .{});
const control = server.root.gamma_control_manager.getControl(output.wlr_output);
if (!wlr.GammaControlV1.apply(control, &state)) return error.OutOfMemory;
if (!output.wlr_output.testState(&state)) {
wlr.GammaControlV1.sendFailedAndDestroy(control);
state.clearGammaLut();
// If the backend does not support gamma LUTs it will reject any
// state with the gamma LUT committed bit set even if the state
// has a null LUT. The wayland backend for example has this behavior.
state.committed.gamma_lut = false;
}
if (!scene_output.buildState(&state, null)) return error.CommitFailed;
if (!output.wlr_output.commitState(&state)) return error.CommitFailed;
// TODO(wlroots) remove this rotate() call when updating to wlroots 0.18
scene_output.damage_ring.rotate();
output.gamma_dirty = false;
} else {

View File

@ -897,6 +897,7 @@ fn handlePowerManagerSetMode(
}
output.updateLockRenderStateOnEnableDisable();
output.gamma_dirty = true;
}
fn handleSetGamma(

View File

@ -165,14 +165,21 @@ pub fn focus(seat: *Seat, _target: ?*View) void {
// Views may not receive focus while locked.
if (server.lock_manager.state != .unlocked) return;
// While a layer surface is exclusively focused, views may not receive focus
// A layer surface with exclusive focus will prevent any view from gaining
// focus if it is on the top or overlay layer. Otherwise, only steal focus
// from a focused layer surface if there is an explicit target view.
if (seat.focused == .layer) {
const wlr_layer_surface = seat.focused.layer.wlr_layer_surface;
assert(wlr_layer_surface.surface.mapped);
if (wlr_layer_surface.current.keyboard_interactive == .exclusive and
(wlr_layer_surface.current.layer == .top or wlr_layer_surface.current.layer == .overlay))
{
return;
switch (wlr_layer_surface.current.keyboard_interactive) {
.none => {},
.exclusive => switch (wlr_layer_surface.current.layer) {
.top, .overlay => return,
.bottom, .background => if (target == null) return,
_ => {},
},
.on_demand => if (target == null) return,
_ => {},
}
}

View File

@ -35,6 +35,7 @@ root: *wlr.SceneTree,
tree: *wlr.SceneTree,
destroy: wl.Listener(void) = wl.Listener(void).init(handleDestroy),
commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit),
new_popup: wl.Listener(*wlr.XdgPopup) = wl.Listener(*wlr.XdgPopup).init(handleNewPopup),
reposition: wl.Listener(void) = wl.Listener(void).init(handleReposition),
@ -54,22 +55,30 @@ pub fn create(
};
wlr_xdg_popup.base.events.destroy.add(&xdg_popup.destroy);
wlr_xdg_popup.base.surface.events.commit.add(&xdg_popup.commit);
wlr_xdg_popup.base.events.new_popup.add(&xdg_popup.new_popup);
wlr_xdg_popup.events.reposition.add(&xdg_popup.reposition);
handleReposition(&xdg_popup.reposition);
}
fn handleDestroy(listener: *wl.Listener(void)) void {
const xdg_popup: *XdgPopup = @fieldParentPtr("destroy", listener);
xdg_popup.destroy.link.remove();
xdg_popup.commit.link.remove();
xdg_popup.new_popup.link.remove();
xdg_popup.reposition.link.remove();
util.gpa.destroy(xdg_popup);
}
fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const xdg_popup: *XdgPopup = @fieldParentPtr("commit", listener);
if (xdg_popup.wlr_xdg_popup.base.initial_commit) {
handleReposition(&xdg_popup.reposition);
}
}
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), wlr_xdg_popup: *wlr.XdgPopup) void {
const xdg_popup: *XdgPopup = @fieldParentPtr("new_popup", listener);

View File

@ -106,10 +106,10 @@ pub fn configure(xwayland_view: XwaylandView) bool {
}
xwayland_view.xwayland_surface.configure(
@intCast(inflight.box.x + output_box.x),
@intCast(inflight.box.y + output_box.y),
@intCast(inflight.box.width),
@intCast(inflight.box.height),
math.lossyCast(i16, inflight.box.x + output_box.x),
math.lossyCast(i16, inflight.box.y + output_box.y),
math.lossyCast(u16, inflight.box.width),
math.lossyCast(u16, inflight.box.height),
);
xwayland_view.setActivated(inflight.focus != 0);