Skip to content

Commit

Permalink
Remove window position (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Nov 10, 2023
1 parent 88fb8be commit a76636d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
5 changes: 0 additions & 5 deletions data/io.elementary.terminal.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
</enum>

<schema path="/io/elementary/terminal/saved-state/" id="io.elementary.terminal.saved-state">
<key name="window-position" type="(ii)">
<default>(-1, -1)</default>
<summary>Window position</summary>
<description>Most recent window position (x, y)</description>
</key>
<key name="window-size" type="(ii)">
<default>(-1, -1)</default>
<summary>Most recent window size</summary>
Expand Down
40 changes: 5 additions & 35 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace Terminal {
public bool unsafe_ignored;
public bool focus_restored_tabs { get; construct; default = true; }
public bool recreate_tabs { get; construct; default = true; }
public bool restore_pos { get; construct; default = true; }
public Gtk.Menu menu { get; private set; }
public Terminal.Application app { get; construct; }
public SimpleActionGroup actions { get; construct; }
Expand Down Expand Up @@ -106,27 +105,12 @@ namespace Terminal {
{ ACTION_OPEN_IN_BROWSER, action_open_in_browser }
};

public MainWindow (Terminal.Application app, bool recreate_tabs = true) {
public MainWindow (Terminal.Application app, bool recreate_tabs = true, bool ensure_tab = true) {
Object (
app: app,
recreate_tabs: recreate_tabs
);

if (!recreate_tabs) {
new_tab ("");
}
}

public MainWindow.with_coords (Terminal.Application app, int x, int y,
bool recreate_tabs, bool ensure_tab) {
Object (
app: app,
restore_pos: false,
recreate_tabs: recreate_tabs
);

move (x, y);

if (!recreate_tabs && ensure_tab) {
new_tab ("");
}
Expand Down Expand Up @@ -177,7 +161,7 @@ namespace Terminal {
set_visual (Gdk.Screen.get_default ().get_rgba_visual ());

title = TerminalWidget.DEFAULT_LABEL;
restore_saved_state (restore_pos);
restore_saved_state ();

clipboard = Gtk.Clipboard.get (Gdk.Atom.intern ("CLIPBOARD", false));
clipboard.owner_change.connect (update_context_menu);
Expand Down Expand Up @@ -538,7 +522,7 @@ namespace Terminal {
return false;
}

private void restore_saved_state (bool restore_pos = true) {
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 @@ -553,14 +537,6 @@ namespace Terminal {
default_height = geometry.height * 3 / 4;
}

if (restore_pos) {
Terminal.Application.saved_state.get ("window-position", "(ii)", out rect.x, out rect.y);

if (rect.x != -1 || rect.y != -1) {
move (rect.x, rect.y);
}
}

var window_state = Terminal.Application.saved_state.get_enum ("window-state");
if (window_state == MainWindow.MAXIMIZED) {
maximize ();
Expand Down Expand Up @@ -644,12 +620,10 @@ namespace Terminal {
save_opened_terminals (true, true);
}

private void on_tab_moved (Granite.Widgets.Tab tab, int x, int y) {
private void on_tab_moved (Granite.Widgets.Tab tab) {
Idle.add (() => {
var new_window = new MainWindow.with_coords (
var new_window = new MainWindow (
app,
x,
y,
false,
false
);
Expand Down Expand Up @@ -785,10 +759,6 @@ namespace Terminal {
var rect = Gdk.Rectangle ();
get_size (out rect.width, out rect.height);
Terminal.Application.saved_state.set ("window-size", "(ii)", rect.width, rect.height);

int root_x, root_y;
get_position (out root_x, out root_y);
Terminal.Application.saved_state.set ("window-position", "(ii)", root_x, root_y);
}

return false;
Expand Down

0 comments on commit a76636d

Please sign in to comment.