Skip to content

Commit

Permalink
Fix inspector windows appearing disabled on GTK
Browse files Browse the repository at this point in the history
For some reason the wxFRAME_TOOL_WINDOW style causes inspector windows to
appear without taking focus, which gives the impression that they are disabled
until specifically clicked on.

The wxFRAME_TOOL_WINDOW style is now only used on Windows, where it is
apparently needed to resolve minimisation issues.
  • Loading branch information
Matthew Mott committed Jun 30, 2021
1 parent dbcaf84 commit b0a6c53
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
20 changes: 13 additions & 7 deletions libs/wxutil/window/TransientWindow.cpp
Expand Up @@ -7,11 +7,17 @@
namespace wxutil
{

TransientWindow::TransientWindow(const std::string& title, wxWindow* parent, bool hideOnDelete) :
wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
wxSYSTEM_MENU | wxRESIZE_BORDER | wxCLOSE_BOX | wxCAPTION | wxFRAME_TOOL_WINDOW |
wxCLIP_CHILDREN | wxFRAME_FLOAT_ON_PARENT | wxFRAME_NO_TASKBAR),
_hideOnDelete(hideOnDelete)
TransientWindow::TransientWindow(const std::string& title, wxWindow* parent,
bool hideOnDelete)
: wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
wxSYSTEM_MENU | wxRESIZE_BORDER | wxCLOSE_BOX | wxCAPTION
#if defined(_WIN32)
// Avoids minimisation problems on Windows, but results in child
// window appearing unfocused on GTK, which is annoying.
| wxFRAME_TOOL_WINDOW
#endif
| wxCLIP_CHILDREN | wxFRAME_FLOAT_ON_PARENT | wxFRAME_NO_TASKBAR),
_hideOnDelete(hideOnDelete)
{
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(TransientWindow::_onDelete), NULL, this);
Connect(wxEVT_SHOW, wxShowEventHandler(TransientWindow::_onShowHide), NULL, this);
Expand Down Expand Up @@ -73,7 +79,7 @@ bool TransientWindow::_onDeleteEvent()
}

_preDestroy();

Destroy();

_postDestroy();
Expand Down Expand Up @@ -116,7 +122,7 @@ void TransientWindow::ToggleVisibility()
}
}

void TransientWindow::InitialiseWindowPosition(int defaultWidth, int defaultHeight,
void TransientWindow::InitialiseWindowPosition(int defaultWidth, int defaultHeight,
const std::string& windowStateKey)
{
SetSize(defaultWidth, defaultHeight);
Expand Down
17 changes: 13 additions & 4 deletions libs/wxutil/window/TransientWindow.h
Expand Up @@ -6,17 +6,26 @@
namespace wxutil
{

class TransientWindow :
public wxFrame
/**
* \brief Base class for a non-modal child window (e.g. light inspector)
*
* TransientWindows are used for inspector windows which appear above the main
* window but are not modal, thereby allowing selection changes which should
* dynamically update the inspector window contents.
*
* The window may be hidden rather than deleted, allowing it to be re-shown with
* the same contents as before, and it can remember its position across
* sessions.
*/
class TransientWindow: public wxFrame
{
private:
// Whether this window should be hidden rather than destroyed
bool _hideOnDelete;

// The window position tracker
WindowPosition _windowPosition;

// Registry key to load/save window position
// Registry key to load/save window position
std::string _windowStateKey;

protected:
Expand Down

0 comments on commit b0a6c53

Please sign in to comment.