Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.
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
53 changes: 28 additions & 25 deletions src/modules/Unity/Application/mirsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

// Mir
#include <mir/geometry/rectangle.h>
#include <mir/scene/surface.h>
#include <mir/scene/surface_observer.h>
#include <mir/version.h>
#include <mir_toolkit/cursors.h>
#include <miroil/surface.h>
#include <miroil/surface_observer.h>

// mirserver
#include <logging.h>
Expand Down Expand Up @@ -80,7 +80,7 @@ qint64 msecsSinceReference()

} // namespace {

class MirSurface::SurfaceObserverImpl : public SurfaceObserver, public mir::scene::SurfaceObserver
class MirSurface::SurfaceObserverImpl : public SurfaceObserver, public miroil::SurfaceObserver
{
public:
SurfaceObserverImpl();
Expand Down Expand Up @@ -181,7 +181,7 @@ MirSurface::MirSurface(NewWindow newWindowInfo,
, m_maxHeight{newWindowInfo.windowInfo.max_height().as_int()}
, m_incWidth{newWindowInfo.windowInfo.width_inc().as_int()}
, m_incHeight{newWindowInfo.windowInfo.height_inc().as_int()}
, m_surface(newWindowInfo.surface)
, m_surface(std::make_shared<miroil::Surface>(newWindowInfo.surface))
, m_session(session)
, m_controller(controller)
, m_orientationAngle(Mir::Angle0)
Expand All @@ -205,7 +205,7 @@ MirSurface::MirSurface(NewWindow newWindowInfo,

m_position = convertDisplayToLocalCoords(toQPoint(m_window.top_left()));

SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface->getWrapped());
m_surface->add_observer(m_surfaceObserver);

connect(m_surfaceObserver.get(), &SurfaceObserver::framesPosted, this, &MirSurface::onFramesPostedObserved);
Expand Down Expand Up @@ -1040,7 +1040,7 @@ QRect MirSurface::inputBounds() const

bool MirSurface::confinesMousePointer() const
{
return m_surface->confine_pointer_state() == mir_pointer_confined_to_window;
return m_surface->is_confined_to_window();
}

bool MirSurface::allowClientResize() const
Expand Down Expand Up @@ -1227,23 +1227,23 @@ MirSurface::SurfaceObserverImpl::SurfaceObserverImpl()
, m_framesPosted(false)
{
// mir cursor names, used by the mir protocol

m_cursorNameToShape[mir_default_cursor_name] = Qt::ArrowCursor;
m_cursorNameToShape[mir_arrow_cursor_name] = Qt::ArrowCursor;
m_cursorNameToShape[mir_crosshair_cursor_name] = Qt::CrossCursor;
m_cursorNameToShape[mir_busy_cursor_name] = Qt::WaitCursor;
m_cursorNameToShape[mir_caret_cursor_name] = Qt::IBeamCursor;
m_cursorNameToShape[mir_vertical_resize_cursor_name] = Qt::SizeVerCursor;
m_cursorNameToShape[mir_horizontal_resize_cursor_name] = Qt::SizeHorCursor;
m_cursorNameToShape[mir_diagonal_resize_bottom_to_top_cursor_name] = Qt::SizeBDiagCursor;
m_cursorNameToShape[mir_diagonal_resize_top_to_bottom_cursor_name] = Qt::SizeFDiagCursor;
m_cursorNameToShape[mir_omnidirectional_resize_cursor_name] = Qt::SizeAllCursor;
m_cursorNameToShape[mir_disabled_cursor_name] = Qt::BlankCursor;
m_cursorNameToShape[mir_vsplit_resize_cursor_name] = Qt::SplitVCursor;
m_cursorNameToShape[mir_hsplit_resize_cursor_name] = Qt::SplitHCursor;
m_cursorNameToShape[mir_pointing_hand_cursor_name] = Qt::PointingHandCursor;
m_cursorNameToShape[mir_open_hand_cursor_name] = Qt::OpenHandCursor;
m_cursorNameToShape[mir_closed_hand_cursor_name] = Qt::ClosedHandCursor;
// Cursor names are from CSS3: https://www.w3.org/TR/css-ui-3/#propdef-cursor

m_cursorNameToShape["default"] = Qt::ArrowCursor;
m_cursorNameToShape["crosshair"] = Qt::CrossCursor;
m_cursorNameToShape["wait"] = Qt::WaitCursor;
m_cursorNameToShape["text"] = Qt::IBeamCursor;
m_cursorNameToShape["ns-resize"] = Qt::SizeVerCursor;
m_cursorNameToShape["ew-resize"] = Qt::SizeHorCursor;
m_cursorNameToShape["ne-resize"] = Qt::SizeBDiagCursor;
m_cursorNameToShape["se-resize"] = Qt::SizeFDiagCursor;
m_cursorNameToShape["move"] = Qt::SizeAllCursor;
m_cursorNameToShape["none"] = Qt::BlankCursor;
m_cursorNameToShape["row-resize"] = Qt::SplitVCursor;
m_cursorNameToShape["col-resize"] = Qt::SplitHCursor;
m_cursorNameToShape["pointer"] = Qt::PointingHandCursor;
m_cursorNameToShape["grab"] = Qt::OpenHandCursor;
m_cursorNameToShape["grabbing"] = Qt::ClosedHandCursor;

// xcursor names, used by our cursor themes

Expand Down Expand Up @@ -1445,7 +1445,8 @@ QPoint MirSurface::convertDisplayToLocalCoords(const QPoint &displayPos) const
QPoint localPos = displayPos;

if (m_surface->parent()) {
auto parentPos = m_surface->parent()->top_left();
auto parent = m_surface->parent();
auto parentPos = miroil::Surface(parent).top_left();
localPos.rx() -= parentPos.x.as_int();
localPos.ry() -= parentPos.y.as_int();
}
Expand All @@ -1458,7 +1459,9 @@ QPoint MirSurface::convertLocalToDisplayCoords(const QPoint &localPos) const
QPoint displayPos = localPos;

if (m_surface->parent()) {
auto parentPos = m_surface->parent()->top_left();
miroil::Surface parent(m_surface->parent());

auto parentPos = parent.top_left();
displayPos.rx() += parentPos.x.as_int();
displayPos.ry() += parentPos.y.as_int();
}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/Unity/Application/mirsurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

// mir
#include <mir_toolkit/common.h>

#include <mir_toolkit/mir_input_device_types.h>
#include <miroil/surface.h>

class SurfaceObserver;

Expand Down Expand Up @@ -233,7 +234,7 @@ private Q_SLOTS:
int m_incWidth;
int m_incHeight;

const std::shared_ptr<mir::scene::Surface> m_surface; // keep copy of the Surface for lifecycle
const std::shared_ptr<miroil::Surface> m_surface; // keep copy of the Surface for lifecycle
QPointer<SessionInterface> m_session;
WindowControllerInterface *const m_controller;

Expand Down