Browse Source

chatgui: запуск на XWayland (xcb) + ручной move/resize с пропорцией

- main.cpp: на Linux принудительно QT_QPA_PLATFORM=xcb (если не задан) — на Wayland
  композитор владеет позицией окна, на XWayland ручной move/resize работает полностью
- videoplayer_window: вернуть ручной move + ручной resize с пропорцией (один путь,
  без платформозависимого нативного startSystemMove/Resize)
v2
evgeny 3 weeks ago
parent
commit
089bbe5189
  1. 6
      tools/chatgui/src/main.cpp
  2. 41
      tools/chatgui/src/videoplayer_window.cpp
  3. 4
      tools/chatgui/src/videoplayer_window.h

6
tools/chatgui/src/main.cpp

@ -57,6 +57,12 @@ static struct ShutdownSentinel {
} g_shutdown_sentinel;
int main(int argc, char *argv[]) {
#ifdef Q_OS_LINUX
/* На Wayland композитор владеет позицией окна (move() игнорируется) —
* для полноценного ручного move/resize с пропорцией запускаемся через XWayland. */
if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORM"))
qputenv("QT_QPA_PLATFORM", "xcb");
#endif
QApplication app(argc, argv);
app.setApplicationName("vibechat");
app.setQuitOnLastWindowClosed(false);

41
tools/chatgui/src/videoplayer_window.cpp

@ -16,7 +16,6 @@
#include <QScreen>
#include <QStyle>
#include <QProxyStyle>
#include <QWindow>
/* ─── VideoRenderWidget ─── */
@ -61,10 +60,6 @@ static QPoint mouseGlobalPos(const QMouseEvent* e) {
#endif
}
static bool isWaylandPlatform() {
return QGuiApplication::platformName() == QLatin1String("wayland");
}
/* Слайдер перемотки: клик по любому месту шкалы = прыжок к позиции (нативно через стиль). */
class SeekSliderStyle : public QProxyStyle {
public:
@ -313,14 +308,11 @@ void VideoPlayerWindow::mousePressEvent(QMouseEvent* e) {
}
ResizeMode m = hitTestResize(e->pos());
if (m != ResizeNone) {
if (isWaylandPlatform()) {
/* Wayland: позицию окна задаёт композитор — только нативный resize тянет край */
if (windowHandle()) windowHandle()->startSystemResize(edgesForMode(m));
} else {
beginResize(m, mouseGlobalPos(e));
}
} else {
if (windowHandle()) windowHandle()->startSystemMove();
m_dragging = true;
m_dragStart = mouseGlobalPos(e);
m_windowStart = frameGeometry().topLeft();
}
}
}
@ -334,12 +326,19 @@ void VideoPlayerWindow::mouseMoveEvent(QMouseEvent* e) {
applyResize(mouseGlobalPos(e));
return;
}
if (m_dragging && (e->buttons() & Qt::LeftButton)) {
move(m_windowStart + (mouseGlobalPos(e) - m_dragStart));
return;
}
if (!(e->buttons() & Qt::LeftButton))
updateResizeCursor(e->pos());
}
void VideoPlayerWindow::mouseReleaseEvent(QMouseEvent* e) {
if (e->button() == Qt::LeftButton) m_resizeMode = ResizeNone;
if (e->button() == Qt::LeftButton) {
m_dragging = false;
m_resizeMode = ResizeNone;
}
}
void VideoPlayerWindow::mouseDoubleClickEvent(QMouseEvent* e) {
@ -359,11 +358,7 @@ bool VideoPlayerWindow::eventFilter(QObject* obj, QEvent* ev) {
QPoint gp = mouseGlobalPos(me);
if (t == QEvent::MouseButtonPress && me->button() == Qt::LeftButton) {
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)) {
@ -423,20 +418,6 @@ 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();

4
tools/chatgui/src/videoplayer_window.h

@ -77,7 +77,6 @@ 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;
@ -89,6 +88,9 @@ private:
bool m_fullscreen = false;
bool m_sliderDragging = false;
bool m_dragging = false;
QPoint m_dragStart;
QPoint m_windowStart;
ResizeMode m_resizeMode = ResizeNone;
QRect m_resizeStartGeom;
QPoint m_resizeStartGlobal;

Loading…
Cancel
Save