chatgui: гибридный resize — нативный на Wayland (край тянется), ручной с пропорцией на X11/Windows
This commit is contained in:
1 parent
cf18e184e5
commit
ec8a4b3a4d
2 files changed
+30
-2
No files matched your search
@@ -61,6 +61,10 @@ static QPoint mouseGlobalPos(const QMouseEvent* e) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool isWaylandPlatform() {
|
||||
return QGuiApplication::platformName() == QLatin1String("wayland");
|
||||
}
|
||||
|
||||
/* Слайдер перемотки: клик по любому месту шкалы = прыжок к позиции (нативно через стиль). */
|
||||
class SeekSliderStyle : public QProxyStyle {
|
||||
public:
|
||||
@@ -309,7 +313,12 @@ void VideoPlayerWindow::mousePressEvent(QMouseEvent* e) {
|
||||
}
|
||||
ResizeMode m = hitTestResize(e->pos());
|
||||
if (m != ResizeNone) {
|
||||
beginResize(m, mouseGlobalPos(e));
|
||||
if (isWaylandPlatform()) {
|
||||
/* Wayland: позицию окна задаёт композитор — только нативный resize тянет край */
|
||||
if (windowHandle()) windowHandle()->startSystemResize(edgesForMode(m));
|
||||
} else {
|
||||
beginResize(m, mouseGlobalPos(e));
|
||||
}
|
||||
} else {
|
||||
if (windowHandle()) windowHandle()->startSystemMove();
|
||||
}
|
||||
@@ -350,7 +359,11 @@ bool VideoPlayerWindow::eventFilter(QObject* obj, QEvent* ev) {
|
||||
|
||||
QPoint gp = mouseGlobalPos(me);
|
||||
if (t == QEvent::MouseButtonPress && me->button() == Qt::LeftButton) {
|
||||
beginResize(m, gp);
|
||||
if (isWaylandPlatform()) {
|
||||
if (windowHandle()) windowHandle()->startSystemResize(edgesForMode(m));
|
||||
} else {
|
||||
beginResize(m, gp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (t == QEvent::MouseMove && m_resizeMode != ResizeNone && (me->buttons() & Qt::LeftButton)) {
|
||||
@@ -410,6 +423,20 @@ void VideoPlayerWindow::updateResizeCursor(const QPoint& pos) {
|
||||
}
|
||||
}
|
||||
|
||||
Qt::Edges VideoPlayerWindow::edgesForMode(ResizeMode m) {
|
||||
switch (m) {
|
||||
case ResizeLeft: return Qt::LeftEdge;
|
||||
case ResizeRight: return Qt::RightEdge;
|
||||
case ResizeTop: return Qt::TopEdge;
|
||||
case ResizeBottom: return Qt::BottomEdge;
|
||||
case ResizeTopLeft: return Qt::TopEdge | Qt::LeftEdge;
|
||||
case ResizeTopRight: return Qt::TopEdge | Qt::RightEdge;
|
||||
case ResizeBottomLeft: return Qt::BottomEdge | Qt::LeftEdge;
|
||||
case ResizeBottomRight: return Qt::BottomEdge | Qt::RightEdge;
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
|
||||
void VideoPlayerWindow::beginResize(ResizeMode m, const QPoint& globalPos) {
|
||||
m_resizeMode = m;
|
||||
m_resizeStartGeom = geometry();
|
||||
|
||||
@@ -77,6 +77,7 @@ private:
|
||||
void updateResizeCursor(const QPoint& localPos);
|
||||
void applyResize(const QPoint& globalPos);
|
||||
void beginResize(ResizeMode m, const QPoint& globalPos);
|
||||
static Qt::Edges edgesForMode(ResizeMode m);
|
||||
|
||||
VideoRenderWidget* m_render = nullptr;
|
||||
QWidget* m_controls = nullptr;
|
||||
|
||||
Reference in new issue
Block a user