Skip to content

Commit 93a9562

Browse files
committed
sem-ver: feature: issue-2337: add a thin bottom drag handle so user can
use mouse to resize the terminal up and down. The final height percentage will be saved to final setting.
1 parent 0911ddf commit 93a9562

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

‎guake/guake_app.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,21 @@ def load_schema():
190190
self.mainframe = self.get_widget("mainframe")
191191
self.mainframe.remove(self.get_widget("notebook-teminals"))
192192

193+
# Window is undecorated (no WM title bar/borders), so provide a thin
194+
# drag handle at the bottom edge to let users resize it manually.
195+
self.bottom_drag_handle = Gtk.EventBox()
196+
self.bottom_drag_handle.set_size_request(-1, 8)
197+
self.bottom_drag_handle.connect(
198+
"realize",
199+
lambda widget: widget.get_window().set_cursor(
200+
Gdk.Cursor.new_from_name(Gdk.Display.get_default(), "ns-resize")
201+
),
202+
)
203+
self.bottom_drag_handle.connect("button-press-event", self.on_resize_handle_by_dragging)
204+
self.bottom_drag_handle.connect("button-release-event", self.on_resize_handle_release)
205+
self.mainframe.pack_end(self.bottom_drag_handle, False, False, 0)
206+
self.bottom_drag_handle.show()
207+
193208
# Pending restore for terminal split after show-up
194209
# [(RootTerminalBox, TerminaBox, panes), ...]
195210
self.pending_restore_page_split = []
@@ -544,6 +559,33 @@ def losefocus_callback(sleep_time):
544559
def on_window_takefocus(self, window, event):
545560
self.takefocus_time = get_server_time(self.window)
546561

562+
def on_resize_handle_by_dragging(self, widget, event):
563+
"""Start an interactive window resize as long as the user holds the button."""
564+
if event.button == 1:
565+
self.window.begin_resize_drag(
566+
Gdk.WindowEdge.SOUTH, event.button, int(event.x_root), int(event.y_root), event.time
567+
)
568+
return True
569+
570+
def on_resize_handle_release(self, widget, event):
571+
"""Once the drag completes, persist height percentage to setting."""
572+
if event.button != 1:
573+
return True
574+
575+
workarea = RectCalculator.get_final_window_monitor(
576+
self.settings, self.window
577+
).get_workarea()
578+
if workarea.height <= 0:
579+
log.warning("Skipping resize-override update: invalid workarea %r", workarea)
580+
return True
581+
582+
height = self.window.get_size()[1]
583+
current_height_percentage = min(round(height / workarea.height * 100), 100)
584+
self.settings.general.set_int("window-height", current_height_percentage)
585+
586+
log.debug("Resize settled at %spx / %s%%", height, current_height_percentage)
587+
return True
588+
547589
def show_menu(self, status_icon, button, activate_time):
548590
"""Show the tray icon menu."""
549591
menu = self.get_widget("tray-menu")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
release_summary: >
2+
You can now resize the drop-down terminal by dragging its bottom edge,
3+
similar to Windows Terminal - handy for temporarily expanding the
4+
terminal to read long command output without leaving the drop-down view.
5+
6+
7+
features:
8+
- |
9+
- Allow resizing the drop-down terminal by dragging its bottom edge (#2337).
10+
This is a discoverable, user-friendly alternative to the existing
11+
Ctrl+Up/Ctrl+Down shortcuts, which many users may never discover on their own.
12+
13+
known_issues:
14+
15+
upgrade:
16+
17+
deprecations:
18+
19+
security:
20+
21+
fixes:
22+
23+
translations:
24+
25+
notes_for_package_maintainers:
26+
27+
other:

0 commit comments

Comments
 (0)