Skip to content

Commit

Permalink
Attempt to fix #4526: Panel sizes not persisted between startups (Linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jun 28, 2017
1 parent 8a69a67 commit fab4a32
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 17 deletions.
5 changes: 5 additions & 0 deletions include/imainframelayout.h
Expand Up @@ -38,6 +38,11 @@ class IMainFrameLayout
* its state.
*/
virtual void toggleFullscreenCameraView() = 0;

/**
* Loads and applies the stored state from the registry.
*/
virtual void restoreStateFromRegistry() = 0;
};
typedef std::shared_ptr<IMainFrameLayout> IMainFrameLayoutPtr;

Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/mainframe/EmbeddedLayout.cpp
Expand Up @@ -176,6 +176,11 @@ void EmbeddedLayout::restoreStateFromPath(const std::string& path)
}
}

void EmbeddedLayout::restoreStateFromRegistry()
{
restoreStateFromPath(RKEY_EMBEDDED_ROOT);
}

void EmbeddedLayout::saveStateToPath(const std::string& path)
{
GlobalRegistry().createKeyWithName(path, "pane", "horizontal");
Expand Down
9 changes: 5 additions & 4 deletions radiant/ui/mainframe/EmbeddedLayout.h
Expand Up @@ -28,10 +28,11 @@ class EmbeddedLayout :

public:
// IMainFrameLayout implementation
virtual std::string getName();
virtual void activate();
virtual void deactivate();
virtual void toggleFullscreenCameraView();
std::string getName() override;
void activate() override;
void deactivate() override;
void toggleFullscreenCameraView() override;
void restoreStateFromRegistry() override;

// The creation function, needed by the mainframe layout manager
static EmbeddedLayoutPtr CreateInstance();
Expand Down
7 changes: 6 additions & 1 deletion radiant/ui/mainframe/FloatingLayout.cpp
Expand Up @@ -131,10 +131,15 @@ void FloatingLayout::toggleFullscreenCameraView()
_floatingCamWnd->ShowFullScreen(!_floatingCamWnd->IsFullScreen());
}

void FloatingLayout::restoreStateFromRegistry()
{
// nothing yet
}

// The creation function, needed by the mainframe layout manager
FloatingLayoutPtr FloatingLayout::CreateInstance()
{
return FloatingLayoutPtr(new FloatingLayout);
return std::make_shared<FloatingLayout>();
}

} // namespace ui
9 changes: 5 additions & 4 deletions radiant/ui/mainframe/FloatingLayout.h
Expand Up @@ -22,10 +22,11 @@ class FloatingLayout :

public:
// IMainFrameLayout implementation
virtual std::string getName();
virtual void activate();
virtual void deactivate();
virtual void toggleFullscreenCameraView();
std::string getName() override;
void activate() override;
void deactivate() override;
void toggleFullscreenCameraView() override;
void restoreStateFromRegistry() override;

// The creation function, needed by the mainframe layout manager
static FloatingLayoutPtr CreateInstance();
Expand Down
16 changes: 16 additions & 0 deletions radiant/ui/mainframe/MainFrame.cpp
Expand Up @@ -228,6 +228,22 @@ void MainFrame::construct()
}
}

#ifdef __linux__
// #4526: In Linux, do another restore after the top level window has been shown
// After startup, GTK emits onSizeAllocate events which trigger a Layout() sequence
// messing up the pane positions, so do the restore() one more time after the main
// window came up.
_topLevelWindow->Bind(wxEVT_SHOW, [&](wxShowEvent& ev)
{
if (_currentLayout && ev.IsShown())
{
_currentLayout->restoreStateFromRegistry();
}

ev.Skip();
});
#endif

// register the commands
GlobalMainFrameLayoutManager().registerCommands();

Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/mainframe/RegularLayout.cpp
Expand Up @@ -175,6 +175,11 @@ void RegularLayout::restoreStateFromPath(const std::string& path)
}
}

void RegularLayout::restoreStateFromRegistry()
{
restoreStateFromPath(RKEY_REGULAR_ROOT);
}

void RegularLayout::saveStateToPath(const std::string& path)
{
GlobalRegistry().createKeyWithName(path, "pane", "horizontal");
Expand Down
9 changes: 5 additions & 4 deletions radiant/ui/mainframe/RegularLayout.h
Expand Up @@ -38,10 +38,11 @@ class RegularLayout :

public:
// IMainFrameLayout implementation
virtual std::string getName();
virtual void activate();
virtual void deactivate();
virtual void toggleFullscreenCameraView();
std::string getName() override;
void activate() override;
void deactivate() override;
void toggleFullscreenCameraView() override;
void restoreStateFromRegistry() override;

// The creation function, needed by the mainframe layout manager
static RegularLayoutPtr CreateRegularLeftInstance();
Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/mainframe/SplitPaneLayout.cpp
Expand Up @@ -360,6 +360,11 @@ void SplitPaneLayout::toggleFullscreenCameraView()
}
}

void SplitPaneLayout::restoreStateFromRegistry()
{
restoreStateFromPath(RKEY_SPLITPANE_ROOT);
}

SplitPaneLayout::Position SplitPaneLayout::getCameraPositionFromRegistry()
{
int value = registry::getValue<int>(RKEY_SPLITPANE_CAMPOS);
Expand Down
9 changes: 5 additions & 4 deletions radiant/ui/mainframe/SplitPaneLayout.h
Expand Up @@ -83,10 +83,11 @@ class SplitPaneLayout :

public:
// IMainFrameLayout implementation
virtual std::string getName();
virtual void activate();
virtual void deactivate();
virtual void toggleFullscreenCameraView();
std::string getName() override;
void activate() override;
void deactivate() override;
void toggleFullscreenCameraView() override;
void restoreStateFromRegistry() override;

// The creation function, needed by the mainframe layout manager
static SplitPaneLayoutPtr CreateInstance();
Expand Down

0 comments on commit fab4a32

Please sign in to comment.