mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1822 from ghostty-org/gtk-wrap
gtk: goto_split:previous/next wrap
This commit is contained in:
@ -274,37 +274,50 @@ pub fn directionMap(self: *const Split, from: Side) DirectionMap {
|
|||||||
var result = DirectionMap.initFull(null);
|
var result = DirectionMap.initFull(null);
|
||||||
|
|
||||||
if (self.directionPrevious(from)) |prev| {
|
if (self.directionPrevious(from)) |prev| {
|
||||||
result.put(.previous, prev);
|
result.put(.previous, prev.surface);
|
||||||
|
if (!prev.wrapped) {
|
||||||
// This behavior matches the behavior of macOS at the time of writing
|
// This behavior matches the behavior of macOS at the time of writing
|
||||||
// this. There is an open issue (#524) to make this depend on the
|
// this. There is an open issue (#524) to make this depend on the
|
||||||
// actual physical location of the current split.
|
// actual physical location of the current split.
|
||||||
result.put(.top, prev);
|
result.put(.top, prev.surface);
|
||||||
result.put(.left, prev);
|
result.put(.left, prev.surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.directionNext(from)) |next| {
|
if (self.directionNext(from)) |next| {
|
||||||
result.put(.next, next);
|
result.put(.next, next.surface);
|
||||||
result.put(.bottom, next);
|
if (!next.wrapped) {
|
||||||
result.put(.right, next);
|
result.put(.bottom, next.surface);
|
||||||
|
result.put(.right, next.surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn directionPrevious(self: *const Split, from: Side) ?*Surface {
|
fn directionPrevious(self: *const Split, from: Side) ?struct {
|
||||||
|
surface: *Surface,
|
||||||
|
wrapped: bool,
|
||||||
|
} {
|
||||||
switch (from) {
|
switch (from) {
|
||||||
// From the bottom right, our previous is the deepest surface
|
// From the bottom right, our previous is the deepest surface
|
||||||
// in the top-left of our own split.
|
// in the top-left of our own split.
|
||||||
.bottom_right => return self.top_left.deepestSurface(.bottom_right),
|
.bottom_right => return .{
|
||||||
|
.surface = self.top_left.deepestSurface(.bottom_right) orelse return null,
|
||||||
|
.wrapped = false,
|
||||||
|
},
|
||||||
|
|
||||||
// From the top left its more complicated. It is the de
|
// From the top left its more complicated. It is the de
|
||||||
.top_left => {
|
.top_left => {
|
||||||
// If we have no parent split then there can be no previous.
|
// If we have no parent split then there can be no unwrapped prev.
|
||||||
const parent = self.container.split() orelse return null;
|
// We can still have a wrapped previous.
|
||||||
const side = self.container.splitSide() orelse return null;
|
const parent = self.container.split() orelse return .{
|
||||||
|
.surface = self.bottom_right.deepestSurface(.bottom_right) orelse return null,
|
||||||
|
.wrapped = true,
|
||||||
|
};
|
||||||
|
|
||||||
// The previous value is the previous of the side that we are.
|
// The previous value is the previous of the side that we are.
|
||||||
|
const side = self.container.splitSide() orelse return null;
|
||||||
return switch (side) {
|
return switch (side) {
|
||||||
.top_left => parent.directionPrevious(.top_left),
|
.top_left => parent.directionPrevious(.top_left),
|
||||||
.bottom_right => parent.directionPrevious(.bottom_right),
|
.bottom_right => parent.directionPrevious(.bottom_right),
|
||||||
@ -313,20 +326,29 @@ fn directionPrevious(self: *const Split, from: Side) ?*Surface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn directionNext(self: *const Split, from: Side) ?*Surface {
|
fn directionNext(self: *const Split, from: Side) ?struct {
|
||||||
|
surface: *Surface,
|
||||||
|
wrapped: bool,
|
||||||
|
} {
|
||||||
switch (from) {
|
switch (from) {
|
||||||
// From the top left, our next is the earliest surface in the
|
// From the top left, our next is the earliest surface in the
|
||||||
// top-left direction of the bottom-right side of our split. Fun!
|
// top-left direction of the bottom-right side of our split. Fun!
|
||||||
.top_left => return self.bottom_right.deepestSurface(.top_left),
|
.top_left => return .{
|
||||||
|
.surface = self.bottom_right.deepestSurface(.top_left) orelse return null,
|
||||||
|
.wrapped = false,
|
||||||
|
},
|
||||||
|
|
||||||
// From the bottom right is more compliated. It is the deepest
|
// From the bottom right is more compliated. It is the deepest
|
||||||
// (last) surface in the
|
// (last) surface in the
|
||||||
.bottom_right => {
|
.bottom_right => {
|
||||||
// If we have no parent split then there can be no next.
|
// If we have no parent split then there can be no next.
|
||||||
const parent = self.container.split() orelse return null;
|
const parent = self.container.split() orelse return .{
|
||||||
const side = self.container.splitSide() orelse return null;
|
.surface = self.top_left.deepestSurface(.top_left) orelse return null,
|
||||||
|
.wrapped = true,
|
||||||
|
};
|
||||||
|
|
||||||
// The previous value is the previous of the side that we are.
|
// The previous value is the previous of the side that we are.
|
||||||
|
const side = self.container.splitSide() orelse return null;
|
||||||
return switch (side) {
|
return switch (side) {
|
||||||
.top_left => parent.directionNext(.top_left),
|
.top_left => parent.directionNext(.top_left),
|
||||||
.bottom_right => parent.directionNext(.bottom_right),
|
.bottom_right => parent.directionNext(.bottom_right),
|
||||||
|
Reference in New Issue
Block a user