Skip to content

Commit

Permalink
dock: Fix display not updated when docked and un-docked on macOS
Browse files Browse the repository at this point in the history
On macOS, after the scope dock window was docked to or undocked from the
main window, the display was vanished. The handlers of `visibleChanged`
and `screenChanged` are copied from obs-source-dock.
  • Loading branch information
norihiro committed Nov 8, 2024
1 parent b7644cc commit 0383fe5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/scope-widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,31 @@ ScopeWidget::ScopeWidget(QWidget *parent) : QWidget(parent)
data->i_mouse_last = -1;
data->i_src_menu = -1;

connect(windowHandle(), &QWindow::visibleChanged, [this](bool visible) {
if (!visible) {
#if !defined(_WIN32) && !defined(__APPLE__)
DestroyDisplay();
#endif
return;
}

if (!data->disp) {
CreateDisplay();
} else {
QSize size = GetPixelSize(this);
obs_display_resize(data->disp, size.width(), size.height());
}
});

connect(windowHandle(), &QWindow::screenChanged, [this](QScreen *screen) {
CreateDisplay();

if (data->disp) {
QSize size = GetPixelSize(this);
obs_display_resize(data->disp, size.width(), size.height());
}
});

windowHandle()->installEventFilter(new SurfaceEventFilter(this));
}

Expand All @@ -204,6 +229,7 @@ ScopeWidget::~ScopeWidget()
scope_dock_deleted(this);

if (data) {
data->destroying = true;
DestroyDisplay();

pthread_mutex_lock(&data->mutex);
Expand Down Expand Up @@ -262,7 +288,6 @@ void ScopeWidget::DestroyDisplay()

obs_display_destroy(data->disp);
data->disp = NULL;
data->destroying = true;
}

void ScopeWidget::resizeEvent(QResizeEvent *event)
Expand Down

0 comments on commit 0383fe5

Please sign in to comment.