View: implement borders with scene graph
This commit is contained in:
parent
f4a8d6dcc9
commit
a545a06c5b
@ -455,11 +455,8 @@ fn commitTransaction(self: *Self) void {
|
|||||||
if (view.pending.tags != view.current.tags) view_tags_changed = true;
|
if (view.pending.tags != view.current.tags) view_tags_changed = true;
|
||||||
if (view.pending.urgent != view.current.urgent) urgent_tags_dirty = true;
|
if (view.pending.urgent != view.current.urgent) urgent_tags_dirty = true;
|
||||||
if (view.pending.urgent and view_tags_changed) urgent_tags_dirty = true;
|
if (view.pending.urgent and view_tags_changed) urgent_tags_dirty = true;
|
||||||
view.current = view.pending;
|
|
||||||
|
|
||||||
view.tree.node.setPosition(view.current.box.x, view.current.box.y);
|
view.updateCurrent();
|
||||||
|
|
||||||
view.dropSavedBuffers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view_tags_changed) output.sendViewTags();
|
if (view_tags_changed) output.sendViewTags();
|
||||||
|
@ -78,6 +78,12 @@ impl: Impl,
|
|||||||
output: *Output,
|
output: *Output,
|
||||||
|
|
||||||
tree: *wlr.SceneTree,
|
tree: *wlr.SceneTree,
|
||||||
|
borders: struct {
|
||||||
|
left: *wlr.SceneRect,
|
||||||
|
right: *wlr.SceneRect,
|
||||||
|
top: *wlr.SceneRect,
|
||||||
|
bottom: *wlr.SceneRect,
|
||||||
|
},
|
||||||
|
|
||||||
/// This indicates that the view should be destroyed when the current
|
/// This indicates that the view should be destroyed when the current
|
||||||
/// transaction completes. See View.destroy()
|
/// transaction completes. See View.destroy()
|
||||||
@ -126,6 +132,12 @@ pub fn init(self: *Self, output: *Output, tree: *wlr.SceneTree, impl: Impl) erro
|
|||||||
.impl = impl,
|
.impl = impl,
|
||||||
.output = output,
|
.output = output,
|
||||||
.tree = tree,
|
.tree = tree,
|
||||||
|
.borders = .{
|
||||||
|
.left = try tree.createSceneRect(0, 0, &server.config.border_color_unfocused),
|
||||||
|
.right = try tree.createSceneRect(0, 0, &server.config.border_color_unfocused),
|
||||||
|
.top = try tree.createSceneRect(0, 0, &server.config.border_color_unfocused),
|
||||||
|
.bottom = try tree.createSceneRect(0, 0, &server.config.border_color_unfocused),
|
||||||
|
},
|
||||||
.current = .{ .tags = initial_tags },
|
.current = .{ .tags = initial_tags },
|
||||||
.pending = .{ .tags = initial_tags },
|
.pending = .{ .tags = initial_tags },
|
||||||
};
|
};
|
||||||
@ -185,6 +197,39 @@ pub fn applyPending(self: *Self) void {
|
|||||||
server.root.startTransaction();
|
server.root.startTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn updateCurrent(self: *Self) void {
|
||||||
|
const config = &server.config;
|
||||||
|
|
||||||
|
self.current = self.pending;
|
||||||
|
self.dropSavedBuffers();
|
||||||
|
|
||||||
|
const color = blk: {
|
||||||
|
if (self.current.urgent) break :blk &config.border_color_urgent;
|
||||||
|
if (self.current.focus != 0) break :blk &config.border_color_focused;
|
||||||
|
break :blk &config.border_color_unfocused;
|
||||||
|
};
|
||||||
|
|
||||||
|
const box = &self.current.box;
|
||||||
|
self.tree.node.setPosition(box.x, box.y);
|
||||||
|
|
||||||
|
const border_width: c_int = config.border_width;
|
||||||
|
self.borders.left.node.setPosition(-border_width, -border_width);
|
||||||
|
self.borders.left.setSize(border_width, box.height + 2 * border_width);
|
||||||
|
self.borders.left.setColor(color);
|
||||||
|
|
||||||
|
self.borders.right.node.setPosition(box.width, -border_width);
|
||||||
|
self.borders.right.setSize(border_width, box.height + 2 * border_width);
|
||||||
|
self.borders.right.setColor(color);
|
||||||
|
|
||||||
|
self.borders.top.node.setPosition(0, -border_width);
|
||||||
|
self.borders.top.setSize(box.width, border_width);
|
||||||
|
self.borders.top.setColor(color);
|
||||||
|
|
||||||
|
self.borders.bottom.node.setPosition(0, box.height);
|
||||||
|
self.borders.bottom.setSize(box.width, border_width);
|
||||||
|
self.borders.bottom.setColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn needsConfigure(self: Self) bool {
|
pub fn needsConfigure(self: Self) bool {
|
||||||
return switch (self.impl) {
|
return switch (self.impl) {
|
||||||
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.needsConfigure(),
|
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.needsConfigure(),
|
||||||
@ -459,6 +504,8 @@ pub fn shouldTrackConfigure(self: Self) bool {
|
|||||||
pub fn map(self: *Self) !void {
|
pub fn map(self: *Self) !void {
|
||||||
log.debug("view '{?s}' mapped", .{self.getTitle()});
|
log.debug("view '{?s}' mapped", .{self.getTitle()});
|
||||||
|
|
||||||
|
self.tree.node.setEnabled(true);
|
||||||
|
|
||||||
server.xdg_activation.events.request_activate.add(&self.request_activate);
|
server.xdg_activation.events.request_activate.add(&self.request_activate);
|
||||||
|
|
||||||
// Add the view to the stack of its output
|
// Add the view to the stack of its output
|
||||||
@ -480,6 +527,8 @@ pub fn map(self: *Self) !void {
|
|||||||
pub fn unmap(self: *Self) void {
|
pub fn unmap(self: *Self) void {
|
||||||
log.debug("view '{?s}' unmapped", .{self.getTitle()});
|
log.debug("view '{?s}' unmapped", .{self.getTitle()});
|
||||||
|
|
||||||
|
self.tree.node.setEnabled(false);
|
||||||
|
|
||||||
if (self.saved_buffers.items.len == 0) self.saveBuffers();
|
if (self.saved_buffers.items.len == 0) self.saveBuffers();
|
||||||
|
|
||||||
// Inform all seats that the view has been unmapped so they can handle focus
|
// Inform all seats that the view has been unmapped so they can handle focus
|
||||||
|
@ -63,8 +63,8 @@ pub fn create(output: *Output, xdg_toplevel: *wlr.XdgToplevel) error{OutOfMemory
|
|||||||
errdefer util.gpa.destroy(node);
|
errdefer util.gpa.destroy(node);
|
||||||
const view = &node.view;
|
const view = &node.view;
|
||||||
|
|
||||||
const tree = try output.layers.views.createSceneXdgSurface(xdg_toplevel.base);
|
const tree = try output.layers.views.createSceneTree();
|
||||||
errdefer tree.node.destroy();
|
_ = try tree.createSceneXdgSurface(xdg_toplevel.base);
|
||||||
|
|
||||||
try view.init(output, tree, .{ .xdg_toplevel = .{
|
try view.init(output, tree, .{ .xdg_toplevel = .{
|
||||||
.view = view,
|
.view = view,
|
||||||
@ -269,16 +269,11 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
|||||||
const urgent_tags_dirty = view.pending.urgent != view.current.urgent or
|
const urgent_tags_dirty = view.pending.urgent != view.current.urgent or
|
||||||
(view.pending.urgent and self_tags_changed);
|
(view.pending.urgent and self_tags_changed);
|
||||||
|
|
||||||
view.current = view.pending;
|
view.updateCurrent();
|
||||||
view.tree.node.setPosition(view.current.box.x, view.current.box.y);
|
|
||||||
|
|
||||||
if (self_tags_changed) view.output.sendViewTags();
|
if (self_tags_changed) view.output.sendViewTags();
|
||||||
if (urgent_tags_dirty) view.output.sendUrgentTags();
|
if (urgent_tags_dirty) view.output.sendUrgentTags();
|
||||||
|
|
||||||
// This is necessary if this view was part of a transaction that didn't get completed
|
|
||||||
// before some change occured that caused shouldTrackConfigure() to return false.
|
|
||||||
view.dropSavedBuffers();
|
|
||||||
|
|
||||||
server.input_manager.updateCursorState();
|
server.input_manager.updateCursorState();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,6 +62,7 @@ pub fn borderColorFocused(
|
|||||||
if (args.len > 2) return Error.TooManyArguments;
|
if (args.len > 2) return Error.TooManyArguments;
|
||||||
|
|
||||||
server.config.border_color_focused = try parseRgba(args[1]);
|
server.config.border_color_focused = try parseRgba(args[1]);
|
||||||
|
server.root.startTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borderColorUnfocused(
|
pub fn borderColorUnfocused(
|
||||||
@ -73,6 +74,7 @@ pub fn borderColorUnfocused(
|
|||||||
if (args.len > 2) return Error.TooManyArguments;
|
if (args.len > 2) return Error.TooManyArguments;
|
||||||
|
|
||||||
server.config.border_color_unfocused = try parseRgba(args[1]);
|
server.config.border_color_unfocused = try parseRgba(args[1]);
|
||||||
|
server.root.startTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borderColorUrgent(
|
pub fn borderColorUrgent(
|
||||||
@ -84,6 +86,7 @@ pub fn borderColorUrgent(
|
|||||||
if (args.len > 2) return Error.TooManyArguments;
|
if (args.len > 2) return Error.TooManyArguments;
|
||||||
|
|
||||||
server.config.border_color_urgent = try parseRgba(args[1]);
|
server.config.border_color_urgent = try parseRgba(args[1]);
|
||||||
|
server.root.startTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setCursorWarp(
|
pub fn setCursorWarp(
|
||||||
|
Loading…
Reference in New Issue
Block a user