Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inoperative header decorations when fullscreened #753

Merged
merged 11 commits into from
Jan 19, 2024
38 changes: 24 additions & 14 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Terminal {
public class MainWindow : Hdy.Window {
private Pango.FontDescription term_font;
private Hdy.HeaderBar header;
private Granite.Widgets.DynamicNotebook notebook;
private Gtk.Clipboard clipboard;
private Gtk.Clipboard primary_selection;
Expand All @@ -30,7 +31,22 @@ namespace Terminal {
private Granite.AccelLabel open_in_browser_menuitem_label;

private HashTable<string, TerminalWidget> restorable_terminals;
private bool is_fullscreen = false;
private bool is_fullscreen {
get {
return header.decoration_layout_set;
}

set {
if (value) {
fullscreen ();
header.decoration_layout_set = true;
//TODO Show Toast like Chrome? or additional unfullscreen button?
} else {
unfullscreen ();
header.decoration_layout_set = false;
}
}
}
jeremypw marked this conversation as resolved.
Show resolved Hide resolved
private bool on_drag = false;

private Gtk.EventControllerKey key_controller;
Expand Down Expand Up @@ -112,7 +128,6 @@ namespace Terminal {
actions = new SimpleActionGroup ();
actions.add_action_entries (ACTION_ENTRIES, this);
insert_action_group ("win", actions);

icon_name = "utilities-terminal";

set_application (app);
Expand All @@ -127,7 +142,6 @@ namespace Terminal {
set_visual (Gdk.Screen.get_default ().get_rgba_visual ());

title = TerminalWidget.DEFAULT_LABEL;
restore_saved_state ();

clipboard = Gtk.Clipboard.get (Gdk.Atom.intern ("CLIPBOARD", false));
primary_selection = Gtk.Clipboard.get (Gdk.Atom.intern ("PRIMARY", false));
Expand Down Expand Up @@ -181,7 +195,6 @@ namespace Terminal {
menu.insert_action_group ("win", actions);

setup_ui ();
show_all ();

key_controller = new Gtk.EventControllerKey (this) {
propagation_phase = TARGET
Expand All @@ -205,6 +218,9 @@ namespace Terminal {

restorable_terminals = new HashTable<string, TerminalWidget> (str_hash, str_equal);

restore_saved_state ();
show_all ();

if (recreate_tabs) {
open_tabs ();
}
Expand Down Expand Up @@ -275,7 +291,7 @@ namespace Terminal {
// We set visible child here to avoid transition being visible on startup.
title_stack.visible_child = title_label;

var header = new Hdy.HeaderBar () {
header = new Hdy.HeaderBar () {
show_close_button = true,
has_subtitle = false
};
Expand All @@ -285,6 +301,8 @@ namespace Terminal {

unowned Gtk.StyleContext header_context = header.get_style_context ();
header_context.add_class ("default-decoration");
header.decoration_layout = "";
jeremypw marked this conversation as resolved.
Show resolved Hide resolved
is_fullscreen = false; // State will be restored later

notebook = new Granite.Widgets.DynamicNotebook.with_accellabels (
new Granite.AccelLabel.from_action_name (_("New Tab"), ACTION_PREFIX + ACTION_NEW_TAB)
Expand Down Expand Up @@ -393,7 +411,6 @@ namespace Terminal {
}

private void restore_saved_state () {

var rect = Gdk.Rectangle ();
Terminal.Application.saved_state.get ("window-size", "(ii)", out rect.width, out rect.height);

Expand All @@ -411,7 +428,6 @@ namespace Terminal {
if (window_state == MainWindow.MAXIMIZED) {
maximize ();
} else if (window_state == MainWindow.FULLSCREEN) {
fullscreen ();
is_fullscreen = true;
}
}
Expand Down Expand Up @@ -1019,13 +1035,7 @@ namespace Terminal {
}

private void action_fullscreen () {
if (is_fullscreen) {
unfullscreen ();
is_fullscreen = false;
} else {
fullscreen ();
is_fullscreen = true;
}
is_fullscreen = !is_fullscreen;
}

private TerminalWidget get_term_widget (Granite.Widgets.Tab tab) {
Expand Down