diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2020-01-09 13:22:24 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2020-01-09 13:22:24 +0300 |
commit | e159344ce50d5d59f8e594b3cd489873f0be7e59 (patch) | |
tree | 3096a3968cde0f7aa875acb06fe1a2abc9f0aac3 /sandboxes | |
parent | 7d55df052fe99908664744bb9b1340b4c7b9d718 (diff) |
further fixes for X window crashes.
Diffstat (limited to 'sandboxes')
-rw-r--r-- | sandboxes/opencsg/main.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/sandboxes/opencsg/main.cpp b/sandboxes/opencsg/main.cpp index 82efb8ada..ab379c196 100644 --- a/sandboxes/opencsg/main.cpp +++ b/sandboxes/opencsg/main.cpp @@ -91,30 +91,7 @@ class Canvas: public wxGLCanvas public: template<class...Args> - Canvas(Args &&...args): wxGLCanvas(std::forward<Args>(args)...) - { - Bind(wxEVT_PAINT, [this](wxPaintEvent &) { - // This is required even though dc is not used otherwise. - wxPaintDC dc(this); - - // Set the OpenGL viewport according to the client size of this - // canvas. This is done here rather than in a wxSizeEvent handler - // because our OpenGL rendering context (and thus viewport - // setting) is used with multiple canvases: If we updated the - // viewport in the wxSizeEvent handler, changing the size of one - // canvas causes a viewport setting that is wrong when next - // another canvas is repainted. - const wxSize ClientSize = GetClientSize(); - - m_display->set_screen_size(ClientSize.x, ClientSize.y); - }); - - Bind(wxEVT_SIZE, [this](wxSizeEvent &) { - const wxSize ClientSize = GetClientSize(); - m_display->set_screen_size(ClientSize.x, ClientSize.y); - m_display->repaint(); - }); - } + Canvas(Args &&...args): wxGLCanvas(std::forward<Args>(args)...) {} shptr<Slic3r::GL::Display> get_display() const { return m_display; } @@ -466,6 +443,20 @@ void MyFrame::activate_canvas_display() m_canvas->get_display()->set_active(ClientSize.x, ClientSize.y); enable_multisampling(m_ms_toggle->GetValue()); + m_canvas->Bind(wxEVT_PAINT, [this](wxPaintEvent &) { + // This is required even though dc is not used otherwise. + wxPaintDC dc(this); + const wxSize csize = GetClientSize(); + m_canvas->get_display()->set_screen_size(csize.x, csize.y); + m_canvas->get_display()->repaint(); + }); + + m_canvas->Bind(wxEVT_SIZE, [this](wxSizeEvent &) { + const wxSize csize = GetClientSize(); + m_canvas->get_display()->set_screen_size(csize.x, csize.y); + m_canvas->get_display()->repaint(); + }); + // Do the repaint continuously m_canvas->Bind(wxEVT_IDLE, [this](wxIdleEvent &evt) { m_canvas->get_display()->repaint(); |