This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
forked from canonical/mir
-
Notifications
You must be signed in to change notification settings - Fork 0
adding a surface observer interface #8
Open
erlend-g
wants to merge
1
commit into
mir-1.9-miroil
Choose a base branch
from
miroil-move-surface-observer-2
base: mir-1.9-miroil
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2021 Canonical, Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License version 3, as published by | ||
* the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef MIROIL_SURFACE_H | ||
#define MIROIL_SURFACE_H | ||
#include <memory> | ||
#include <unordered_map> | ||
#include <mir_toolkit/mir_input_device_types.h> | ||
#include <mir_toolkit/common.h> | ||
#include <mir/graphics/renderable.h> | ||
|
||
namespace mir { | ||
namespace scene { class Surface; } | ||
namespace shell { class InputTargeter; } | ||
namespace geometry { struct Rectangle; } | ||
namespace graphics { class CursorImage; } | ||
namespace compositor { class BufferStream; } | ||
} | ||
|
||
namespace miroil { | ||
|
||
class SurfaceObserver; | ||
class SurfaceObserverImpl; | ||
|
||
using CompositorID = void const*; | ||
|
||
class Surface | ||
{ | ||
public: | ||
Surface(std::shared_ptr<mir::scene::Surface> wrapped); | ||
~Surface() = default; | ||
|
||
auto getWrapped() const -> mir::scene::Surface*; | ||
void add_observer(std::shared_ptr<miroil::SurfaceObserver> const& observer); | ||
void remove_observer(std::shared_ptr<miroil::SurfaceObserver> const& observer); | ||
|
||
int buffers_ready_for_compositor(void const* compositor_id) const; | ||
auto generate_renderables(miroil::CompositorID id) const -> mir::graphics::RenderableList; | ||
|
||
bool is_confined_to_window(); | ||
void set_orientation(MirOrientation orientation); | ||
void set_keymap(MirInputDeviceId id, std::string const& model, std::string const& layout, | ||
std::string const& variant, std::string const& options); | ||
|
||
void set_confine_pointer_state(MirPointerConfinementState state); | ||
auto parent() const -> std::shared_ptr<mir::scene::Surface>; | ||
|
||
/// Top-left corner (of the window frame if present) | ||
mir::geometry::Point top_left() const; | ||
bool visible() const; | ||
|
||
// TODO a legacy of old interactions and needs removing | ||
int configure(MirWindowAttrib attrib, int value); | ||
// TODO a legacy of old interactions and needs removing | ||
int query(MirWindowAttrib attrib) const; | ||
|
||
private: | ||
std::shared_ptr<mir::scene::Surface> wrapped; | ||
std::unordered_map<std::shared_ptr<miroil::SurfaceObserver>, std::shared_ptr<miroil::SurfaceObserverImpl>> observers; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't access to this be protected by (at least) a mutex? It is probably best to copy the |
||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright © 2021 Canonical Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include <mir_toolkit/common.h> | ||
#include <mir/geometry/size.h> | ||
#include <mir/geometry/rectangle.h> | ||
#include <mir/graphics/cursor_image.h> | ||
#include <glm/glm.hpp> | ||
#include <mir_toolkit/mir_input_device_types.h> | ||
#include <vector> | ||
|
||
namespace mir { namespace scene { class SurfaceObserver; } } | ||
namespace mir { namespace scene { class Surface; } } | ||
namespace mir { namespace input { enum class InputReceptionMode; } } | ||
|
||
struct MirEvent; | ||
struct MirInputEvent; | ||
|
||
namespace miroil | ||
{ | ||
|
||
class SurfaceObserver | ||
{ | ||
public: | ||
SurfaceObserver() = default; | ||
SurfaceObserver(SurfaceObserver const&) = delete; | ||
SurfaceObserver& operator=(SurfaceObserver const&) = delete; | ||
virtual ~SurfaceObserver(); | ||
|
||
virtual void attrib_changed(mir::scene::Surface const* surf, MirWindowAttrib attrib, int value) = 0; | ||
virtual void window_resized_to(mir::scene::Surface const* surf, mir::geometry::Size const& window_size) = 0; | ||
virtual void content_resized_to(mir::scene::Surface const* surf, mir::geometry::Size const& content_size) = 0; | ||
virtual void moved_to(mir::scene::Surface const* surf, mir::geometry::Point const& top_left) = 0; | ||
virtual void hidden_set_to(mir::scene::Surface const* surf, bool hide) = 0; | ||
virtual void frame_posted(mir::scene::Surface const* surf, int frames_available, mir::geometry::Size const& size) = 0; | ||
virtual void alpha_set_to(mir::scene::Surface const* surf, float alpha) = 0; | ||
virtual void orientation_set_to(mir::scene::Surface const* surf, MirOrientation orientation) = 0; | ||
virtual void transformation_set_to(mir::scene::Surface const* surf, glm::mat4 const& t) = 0; | ||
virtual void reception_mode_set_to(mir::scene::Surface const* surf, mir::input::InputReceptionMode mode) = 0; | ||
virtual void cursor_image_set_to(mir::scene::Surface const* surf, mir::graphics::CursorImage const& image) = 0; | ||
virtual void client_surface_close_requested(mir::scene::Surface const* surf) = 0; | ||
virtual void keymap_changed(mir::scene::Surface const* surf, MirInputDeviceId id, std::string const& model, | ||
std::string const& layout, std::string const& variant, std::string const& options) = 0; | ||
virtual void renamed(mir::scene::Surface const* surf, char const* name) = 0; | ||
virtual void cursor_image_removed(mir::scene::Surface const* surf) = 0; | ||
virtual void placed_relative(mir::scene::Surface const* surf, mir::geometry::Rectangle const& placement) = 0; | ||
virtual void input_consumed(mir::scene::Surface const* surf, MirEvent const* event) = 0; | ||
virtual void start_drag_and_drop(mir::scene::Surface const* surf, std::vector<uint8_t> const& handle) = 0; | ||
virtual void depth_layer_set_to(mir::scene::Surface const* surf, MirDepthLayer depth_layer) = 0; | ||
virtual void application_id_set_to(mir::scene::Surface const* surf, std::string const& application_id) = 0; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be const?