void QWaylandWindow::doResize() { if (mConfigure.isEmpty()) { return; } int widthWithoutMargins = qMax(mConfigure.width-(frameMargins().left() +frameMargins().right()),1); int heightWithoutMargins = qMax(mConfigure.height-(frameMargins().top()+frameMargins().bottom()),1); widthWithoutMargins = qMax(widthWithoutMargins, window()->minimumSize().width()); heightWithoutMargins = qMax(heightWithoutMargins, window()->minimumSize().height()); QRect geometry = QRect(0,0, widthWithoutMargins, heightWithoutMargins); int x = 0; int y = 0; QSize size = this->geometry().size(); if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_LEFT) { x = size.width() - geometry.width(); } if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_TOP) { y = size.height() - geometry.height(); } mOffset += QPoint(x, y); setGeometry(geometry); mConfigure.clear(); }
void QWaylandWindow::configure(uint32_t edges, int32_t width, int32_t height) { Q_UNUSED(edges); int widthWithoutMargins = qMax(width-(frameMargins().left() +frameMargins().right()),1); int heightWithoutMargins = qMax(height-(frameMargins().top()+frameMargins().bottom()),1); widthWithoutMargins = qMax(widthWithoutMargins, window()->minimumSize().width()); heightWithoutMargins = qMax(heightWithoutMargins, window()->minimumSize().height()); QRect geometry = QRect(0,0, widthWithoutMargins, heightWithoutMargins); setGeometry(geometry); QWindowSystemInterface::handleGeometryChange(window(), geometry); }
void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, ulong timestamp, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) { if (mWindowDecoration->handleMouse(inputDevice,local,global,b,mods)) return; QMargins marg = frameMargins(); QRect windowRect(0 + marg.left(), 0 + marg.top(), geometry().size().width() - marg.right(), geometry().size().height() - marg.bottom()); if (windowRect.contains(local.toPoint()) || mMousePressedInContentArea != Qt::NoButton) { QPointF localTranslated = local; QPointF globalTranslated = global; localTranslated.setX(localTranslated.x() - marg.left()); localTranslated.setY(localTranslated.y() - marg.top()); globalTranslated.setX(globalTranslated.x() - marg.left()); globalTranslated.setY(globalTranslated.y() - marg.top()); if (!mMouseEventsInContentArea) { restoreMouseCursor(inputDevice); QWindowSystemInterface::handleEnterEvent(window()); } QWindowSystemInterface::handleMouseEvent(window(), timestamp, localTranslated, globalTranslated, b, mods); mMouseEventsInContentArea = true; mMousePressedInContentArea = b; } else { if (mMouseEventsInContentArea) { QWindowSystemInterface::handleLeaveEvent(window()); mMouseEventsInContentArea = false; } mWindowDecoration->handleMouse(inputDevice,local,global,b,mods); } }
void QWidgetWindow::updateMargins() { const QMargins margins = frameMargins(); QTLWExtra *te = m_widget->d_func()->topData(); te->posIncludesFrame= false; te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); m_widget->data->fstrut_dirty = false; }
void QWidgetWindow::updateGeometry() { if (m_widget->testAttribute(Qt::WA_OutsideWSRange)) return; const QMargins margins = frameMargins(); m_widget->data->crect = geometry(); QTLWExtra *te = m_widget->d_func()->topData(); te->posIncludesFrame= false; te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); m_widget->data->fstrut_dirty = false; }
void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e) { if (mMousePressedInContentArea == Qt::NoButton && mWindowDecoration->handleMouse(inputDevice, e.local, e.global, e.buttons, e.modifiers)) { if (mMouseEventsInContentArea) QWindowSystemInterface::handleLeaveEvent(window()); return; } QMargins marg = frameMargins(); QRect windowRect(0 + marg.left(), 0 + marg.top(), geometry().size().width() - marg.right(), geometry().size().height() - marg.bottom()); if (windowRect.contains(e.local.toPoint()) || mMousePressedInContentArea != Qt::NoButton) { QPointF localTranslated = e.local; QPointF globalTranslated = e.global; localTranslated.setX(localTranslated.x() - marg.left()); localTranslated.setY(localTranslated.y() - marg.top()); globalTranslated.setX(globalTranslated.x() - marg.left()); globalTranslated.setY(globalTranslated.y() - marg.top()); if (!mMouseEventsInContentArea) { restoreMouseCursor(inputDevice); QWindowSystemInterface::handleEnterEvent(window()); } switch (e.type) { case QWaylandPointerEvent::Enter: QWindowSystemInterface::handleEnterEvent(window(), localTranslated, globalTranslated); break; case QWaylandPointerEvent::Motion: QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers); break; case QWaylandPointerEvent::Wheel: QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta); break; } mMouseEventsInContentArea = true; mMousePressedInContentArea = e.buttons; } else { if (mMouseEventsInContentArea) { QWindowSystemInterface::handleLeaveEvent(window()); mMouseEventsInContentArea = false; } } }
void QWindowsWindow::setGeometry_sys(const QRect &rect) const { const QMargins margins = frameMargins(); const QRect frameGeometry = rect + margins; if (QWindowsContext::verboseWindows) qDebug() << '>' << __FUNCTION__ << this << window() << " \n from " << geometry_sys() << " frame: " << margins << " to " <<rect << " new frame: " << frameGeometry; const bool rc = MoveWindow(m_data.hwnd, frameGeometry.x(), frameGeometry.y(), frameGeometry.width(), frameGeometry.height(), true); if (QWindowsContext::verboseWindows) qDebug() << '<' << __FUNCTION__ << this << window() << " \n resulting " << rc << geometry_sys(); }
EGLSurface QWaylandEglWindow::eglSurface() const { if (!m_waylandEglWindow) { const_cast<QWaylandEglWindow *>(this)->createDecoration(); QMargins margins = frameMargins(); QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); m_waylandEglWindow = wl_egl_window_create(mSurface, sizeWithMargins.width(), sizeWithMargins.height()); } if (!m_eglSurface) { m_eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), window()->format(), true); const_cast<QWaylandEglWindow *>(this)->m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(),m_eglConfig); EGLNativeWindowType window = (EGLNativeWindowType) m_waylandEglWindow; m_eglSurface = eglCreateWindowSurface(m_eglIntegration->eglDisplay(), m_eglConfig, window, 0); } return m_eglSurface; }
void QWaylandEglWindow::redraw() { createDecoration(); QMargins margins = frameMargins(); QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); if (m_waylandEglWindow) { int current_width, current_height; wl_egl_window_get_attached_size(m_waylandEglWindow,¤t_width,¤t_height); if (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) { waitForFrameSync(); wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y()); mOffset = QPoint(); m_resize = true; } } else { m_waylandEglWindow = wl_egl_window_create(mSurface, sizeWithMargins.width(), sizeWithMargins.height()); } }
QRect QWaylandEglWindow::contentsRect() const { QRect r = geometry(); QMargins m = frameMargins(); return QRect(m.left(), m.bottom(), r.width(), r.height()); }
QRect QWindowsWindow::geometry_sys() const { // Warning: Returns bogus values when minimized. QRect result = frameGeometry(m_data.hwnd, window()->isTopLevel()) - frameMargins(); return result; }