Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Support drag and move projector when clicking inside the window #8138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions UI/window-projector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
&OBSProjector::EscapeTriggered);
popup.exec(QCursor::pos());
} else if (event->button() == Qt::LeftButton) {
onMousePressMouseOffset = event->globalPosition();

// Only MultiView projectors handle left click
if (this->type != ProjectorType::Multiview)
return;
Expand All @@ -306,6 +308,28 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
}
}

void OBSProjector::mouseMoveEvent(QMouseEvent *event)
{
if (!isFullScreen() && (event->buttons() & Qt::LeftButton)) {
QPointF diff =
event->globalPosition() - onMousePressMouseOffset;
window()->move(window()->pos() + diff.toPoint());
onMousePressMouseOffset = event->globalPosition();
}
}

void OBSProjector::enterEvent(QEnterEvent *)
{
if (!isFullScreen()) {
setCursor(Qt::SizeAllCursor);
}
}

void OBSProjector::leaveEvent(QEvent *)
{
setCursor(Qt::ArrowCursor);
}

void OBSProjector::EscapeTriggered()
{
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
Expand Down
5 changes: 5 additions & 0 deletions UI/window-projector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class OBSProjector : public OBSQTDisplay {
static void OBSSourceDestroyed(void *data, calldata_t *params);

void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void enterEvent(QEnterEvent *) override;
void leaveEvent(QEvent *) override;
void closeEvent(QCloseEvent *event) override;

bool isAlwaysOnTop;
Expand All @@ -46,6 +49,8 @@ class OBSProjector : public OBSQTDisplay {

QScreen *screen = nullptr;

QPointF onMousePressMouseOffset;

private slots:
void EscapeTriggered();
void OpenFullScreenProjector();
Expand Down
Loading