reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 0da8da6b9f2ff867964ba3d01ef408b8034e30b3
parent 9776e1226ffe0892b5ef86e6bcf0332c2c04d85f
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Wed, 21 Sep 2016 20:40:05 -0700

tabbar: avoid flickering on wine when switching tab

Diffstat:
Msrc/about.cpp | 8++------
Msrc/control.hpp | 31++++++++++++++++++++-----------
Msrc/dialog.hpp | 3+--
Msrc/tabbar.cpp | 2++
4 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -91,10 +91,8 @@ void About::onCommand(const int id, int) void About::setDelegate(const DelegatePtr &delegate, const bool focus) { -#ifdef _WIN32 - // preventing fast blinking on windows - SendMessage(handle(), WM_SETREDRAW, false, 0); -#endif + // prevent fast flickering on Windows + InhibitControl block(handle()); m_tabs->clear(); m_menu->reset(); @@ -131,8 +129,6 @@ void About::setDelegate(const DelegatePtr &delegate, const bool focus) m_list->autoSizeHeader(); #ifdef _WIN32 - SendMessage(handle(), WM_SETREDRAW, true, 0); - // Without this the first tab would not be redrawn completely on Windows. // Though I have no idea why... InvalidateRect(handle(), nullptr, true); diff --git a/src/control.hpp b/src/control.hpp @@ -28,19 +28,19 @@ class Dialog; class Control { public: - Control(HWND handle) : m_handle(handle) {} - virtual ~Control() {} - - HWND handle() const { return m_handle; } - - void inhibitRedraw(const bool inhibit) + static void inhibitRedraw(HWND handle, const bool inhibit) { #ifdef WM_SETREDRAW // WM_SETREDRAW is not supported by SWELL - SendMessage(m_handle, WM_SETREDRAW, !inhibit, 0); + SendMessage(handle, WM_SETREDRAW, !inhibit, 0); #endif } + Control(HWND handle) : m_handle(handle) {} + virtual ~Control() {} + + HWND handle() const { return m_handle; } + protected: friend Dialog; virtual void onNotify(LPNMHDR, LPARAM) {} @@ -53,18 +53,27 @@ private: class InhibitControl { public: InhibitControl(Control *ctrl) - : m_control(ctrl) + : m_handle(ctrl->handle()) { - m_control->inhibitRedraw(true); + block(); + } + + InhibitControl(HWND handle) + : m_handle(handle) + { + block(); } ~InhibitControl() { - m_control->inhibitRedraw(false); + unblock(); } + void block() { Control::inhibitRedraw(m_handle, true); } + void unblock() { Control::inhibitRedraw(m_handle, false); } + private: - Control *m_control; + HWND m_handle; }; #endif diff --git a/src/dialog.hpp b/src/dialog.hpp @@ -171,8 +171,7 @@ private: class LockDialog { public: - LockDialog(Dialog *dlg) - : m_dialog(dlg) + LockDialog(Dialog *dlg) : m_dialog(dlg) { if(m_dialog) m_dialog->disable(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp @@ -104,6 +104,8 @@ void TabBar::onNotify(LPNMHDR info, LPARAM) void TabBar::switchPage() { + InhibitControl block(m_parent->handle()); + if(m_lastPage > -1) { for(HWND control : m_pages[m_lastPage]) ShowWindow(control, SW_HIDE);