Skip to content

Commit

Permalink
Fix view focusing
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Oct 13, 2023
1 parent 68180a5 commit 28e352a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/input/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void cursor_button_notify(wl_listener* listener, void* data) {
if (cursor.mode != MAGPIE_CURSOR_PASSTHROUGH) {
cursor.reset_mode();
}
} else if (typeid(magpie_surface) == typeid(View*)) {
} else if (magpie_surface != nullptr && magpie_surface->is_view()) {
/* Focus that client if the button was _pressed_ */
server.focus_view(*static_cast<View*>(magpie_surface), surface);
}
Expand Down
4 changes: 4 additions & 0 deletions src/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ Layer::~Layer() noexcept {
inline Server& Layer::get_server() const {
return server;
}

bool Layer::is_view() const {
return false;
}
3 changes: 2 additions & 1 deletion src/layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Layer : public Surface {
Layer(Output& output, wlr_layer_surface_v1& surface) noexcept;
~Layer() noexcept;

inline Server& get_server() const;
inline Server& get_server() const override;
bool is_view() const override;
};

class LayerSubsurface {
Expand Down
4 changes: 4 additions & 0 deletions src/popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ Popup::~Popup() noexcept {
inline Server& Popup::get_server() const {
return server;
}

bool Popup::is_view() const {
return false;
}
1 change: 1 addition & 0 deletions src/popup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Popup : public Surface {
~Popup() noexcept;

Server& get_server() const override;
bool is_view() const override;
};

#endif
1 change: 1 addition & 0 deletions src/surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct Surface {
virtual ~Surface() noexcept {};

virtual Server& get_server() const = 0;
virtual bool is_view() const = 0;
};

#endif
4 changes: 4 additions & 0 deletions src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const std::optional<const Output*> View::find_output_for_maximize() {
return best_output;
}

bool View::is_view() const {
return true;
}

void View::begin_interactive(const CursorMode mode, const uint32_t edges) {
Server& server = get_server();

Expand Down
1 change: 1 addition & 0 deletions src/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct View : public Surface {
virtual void map() = 0;
virtual void unmap() = 0;

bool is_view() const;
void begin_interactive(const CursorMode mode, const uint32_t edges);
void set_size(const int new_width, const int new_height);
void set_activated(const bool activated);
Expand Down

0 comments on commit 28e352a

Please sign in to comment.