Skip to content

Commit

Permalink
gtk: use wide handle for GtkPaned
Browse files Browse the repository at this point in the history
Improves ghostty-org#3020.

Ensures that the drag handle for the pane separator never overlaps pane
content.

See recommendation in upstream Gtk issue:
https://gitlab.gnome.org/GNOME/gtk/-/issues/4484#note_2362002

Also add WIP CSS to style the pane handle with a single centered 1px
line, rather than two 1px borders.
  • Loading branch information
daviewales committed Mar 3, 2025
1 parent ee8ae19 commit 6834ea5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/apprt/gtk/Split.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ pub fn init(
// Keep a long-lived reference, which we unref in destroy.
paned.ref();

// Ensure that the drag handle for split panes never overlaps
// pane content. (#3020)
// See recommendation in upstream Gtk issue:
// https://gitlab.gnome.org/GNOME/gtk/-/issues/4484#note_2362002
paned.setWideHandle(@intFromBool(true));

// Update all of our containers to point to the right place.
// The split has to point to where the sibling pointed to because
// we're inheriting its parent. The sibling points to its location
Expand Down
35 changes: 35 additions & 0 deletions src/apprt/gtk/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,38 @@ window.ssd.no-border-radius {
margin: 0;
padding: 0;
}

/* By default, a GtkPaned wide handle has a 1px border at the left
* and right of the 5px wide pane resize handle. This border is created
* with `box-shadow`. Instead, we want a single 1px line exactly in the
* center of the pane resize handle.
*
* To achieve this, we reset box-shadow to `none`, and create a 1px
* wide linear-gradient of the appropriate color in the center of
* the pane resize handle.
*
* Attribution: https://stackoverflow.com/a/53551089
*
* We need to do this separately for vertical and horizontal panes.
*/
.terminal-window .notebook .vertical paned > separator {
box-shadow: none;
background-image: linear-gradient(
rgba(255, 255, 255, 0.15),
rgba(255, 255, 255, 0.15)
);
background-size: 1px 100%;
background-repeat: no-repeat;
background-position: center center;
}

.terminal-window .notebook .horizontal paned > separator {
box-shadow: none;
background-image: linear-gradient(
rgba(255, 255, 255, 0.15),
rgba(255, 255, 255, 0.15)
);
background-size: 100% 1px;
background-repeat: no-repeat;
background-position: center;
}

0 comments on commit 6834ea5

Please sign in to comment.