Commit 7c9718cc authored by Cédric Bellegarde's avatar Cédric Bellegarde

Fix logical

parent 368a1c79
...@@ -147,7 +147,7 @@ class Application(Gtk.Application): ...@@ -147,7 +147,7 @@ class Application(Gtk.Application):
windows = self.get_windows() windows = self.get_windows()
if windows and size is None: if windows and size is None:
active_window = self.active_window active_window = self.active_window
size = active_window.get_size() size = active_window.size
maximized = active_window.is_maximized() maximized = active_window.is_maximized()
window = Window(self, size, maximized) window = Window(self, size, maximized)
window.connect('delete-event', self.__on_delete_event) window.connect('delete-event', self.__on_delete_event)
...@@ -487,7 +487,7 @@ class Application(Gtk.Application): ...@@ -487,7 +487,7 @@ class Application(Gtk.Application):
window_state = {} window_state = {}
window_state["id"] = str(window) window_state["id"] = str(window)
window_state["size"] = window.get_size() window_state["size"] = window.size
window_state["maximized"] = window.is_maximized() window_state["maximized"] = window.is_maximized()
session_states = [] session_states = []
if self.settings.get_value("remember-session"): if self.settings.get_value("remember-session"):
......
...@@ -43,8 +43,10 @@ class Window(Gtk.ApplicationWindow): ...@@ -43,8 +43,10 @@ class Window(Gtk.ApplicationWindow):
self.__modifiers = 0 self.__modifiers = 0
self.__window_state = 0 self.__window_state = 0
self.__timeout_configure = None self.__timeout_configure = None
self.__size = size
self.set_default_size(size[0], size[1])
self.__setup_content() self.__setup_content()
self.connect("realize", self.__on_realize, size, maximized) self.connect("realize", self.__on_realize, maximized)
self.connect("key-press-event", self.__on_key_press_event) self.connect("key-press-event", self.__on_key_press_event)
self.connect("key-release-event", self.__on_key_release_event) self.connect("key-release-event", self.__on_key_release_event)
self.connect("window-state-event", self.__on_window_state_event) self.connect("window-state-event", self.__on_window_state_event)
...@@ -241,6 +243,14 @@ class Window(Gtk.ApplicationWindow): ...@@ -241,6 +243,14 @@ class Window(Gtk.ApplicationWindow):
# https://bugs.webkit.org/show_bug.cgi?id=181041 # https://bugs.webkit.org/show_bug.cgi?id=181041
return self.__modifiers return self.__modifiers
@property
def size(self):
"""
Unmaximized window size
return (int, int)
"""
return self.__size
############ ############
# Private # # Private #
############ ############
...@@ -275,15 +285,12 @@ class Window(Gtk.ApplicationWindow): ...@@ -275,15 +285,12 @@ class Window(Gtk.ApplicationWindow):
self.__toolbar.headerbar.set_show_close_button(True) self.__toolbar.headerbar.set_show_close_button(True)
self.add(self.__container) self.add(self.__container)
def __setup_window(self, size, maximized): def __setup_window(self, maximized):
""" """
Set window Set window
@param size as (int, int)
@param maximized as bool @param maximized as bool
""" """
try: try:
if size is not None:
self.resize(size[0], size[1])
if maximized: if maximized:
# Lets resize happen # Lets resize happen
GLib.idle_add(self.maximize) GLib.idle_add(self.maximize)
...@@ -329,6 +336,8 @@ class Window(Gtk.ApplicationWindow): ...@@ -329,6 +336,8 @@ class Window(Gtk.ApplicationWindow):
""" """
self.__timeout_configure = None self.__timeout_configure = None
self.update_zoom_level(False) self.update_zoom_level(False)
if not self.is_maximized():
self.__size = self.get_size()
def __on_window_state_event(self, widget, event): def __on_window_state_event(self, widget, event):
""" """
...@@ -362,14 +371,13 @@ class Window(Gtk.ApplicationWindow): ...@@ -362,14 +371,13 @@ class Window(Gtk.ApplicationWindow):
if not lock: if not lock:
self.__fullscreen_revealer.set_reveal_child(False) self.__fullscreen_revealer.set_reveal_child(False)
def __on_realize(self, widget, size, maximized): def __on_realize(self, widget, maximized):
""" """
Update zoom level Update zoom level
@param widget as Gtk.Widget @param widget as Gtk.Widget
@param size as (int, int)
@param maximized as bool @param maximized as bool
""" """
self.__setup_window(size, maximized) self.__setup_window(maximized)
self.update_zoom_level(False) self.update_zoom_level(False)
def __on_key_press_event(self, window, event): def __on_key_press_event(self, window, event):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment