Skip to content

Commit

Permalink
Apply clang-tidy suggestions to all source files
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Nov 10, 2023
1 parent 51ca5f4 commit 945b425
Show file tree
Hide file tree
Showing 23 changed files with 390 additions and 376 deletions.
34 changes: 17 additions & 17 deletions src/foreign_toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

static void foreign_toplevel_handle_request_maximize_notify(wl_listener* listener, void* data) {
const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_activate);
auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_maximized_event*>(data);
const auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_maximized_event*>(data);

auto placement = event.maximized ? VIEW_PLACEMENT_MAXIMIZED : VIEW_PLACEMENT_STACKING;
const auto placement = event.maximized ? VIEW_PLACEMENT_MAXIMIZED : VIEW_PLACEMENT_STACKING;
handle.view.set_placement(placement);
}

static void foreign_toplevel_handle_request_fullscreen_notify(wl_listener* listener, void* data) {
const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_activate);
auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_maximized_event*>(data);
const auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_maximized_event*>(data);

auto placement = event.maximized ? VIEW_PLACEMENT_FULLSCREEN : VIEW_PLACEMENT_STACKING;
const auto placement = event.maximized ? VIEW_PLACEMENT_FULLSCREEN : VIEW_PLACEMENT_STACKING;
handle.view.set_placement(placement);
}

static void foreign_toplevel_handle_request_minimize_notify(wl_listener* listener, void* data) {
const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_activate);
auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_minimized_event*>(data);
const auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_minimized_event*>(data);

handle.view.set_minimized(event.minimized);
}
Expand All @@ -42,7 +42,7 @@ static void foreign_toplevel_handle_request_close_notify(wl_listener* listener,

static void foreign_toplevel_handle_set_rectangle_notify(wl_listener* listener, void* data) {
const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, set_rectangle);
auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_set_rectangle_event*>(data);
const auto& event = *static_cast<wlr_foreign_toplevel_handle_v1_set_rectangle_event*>(data);

handle.view.set_position(event.x, event.y);
handle.view.set_size(event.width, event.height);
Expand Down Expand Up @@ -76,47 +76,47 @@ ForeignToplevelHandle::~ForeignToplevelHandle() noexcept {
wl_list_remove(&listeners.set_rectangle.link);
}

void ForeignToplevelHandle::set_title(const char* title) {
void ForeignToplevelHandle::set_title(const char* title) const {
if (title != nullptr) {
wlr_foreign_toplevel_handle_v1_set_title(&handle, title);
}
}

void ForeignToplevelHandle::set_app_id(const char* app_id) {
void ForeignToplevelHandle::set_app_id(const char* app_id) const {
if (app_id != nullptr) {
wlr_foreign_toplevel_handle_v1_set_app_id(&handle, app_id);
}
}

void ForeignToplevelHandle::set_parent(std::optional<std::reference_wrapper<const ForeignToplevelHandle>> parent) {
wlr_foreign_toplevel_handle_v1_set_parent(&handle, (parent.has_value()) ? nullptr : &parent->get().handle);
void ForeignToplevelHandle::set_parent(const std::optional<std::reference_wrapper<const ForeignToplevelHandle>> parent) const {
wlr_foreign_toplevel_handle_v1_set_parent(&handle, parent.has_value() ? nullptr : &parent->get().handle);
}

void ForeignToplevelHandle::set_placement(const ViewPlacement placement) {
void ForeignToplevelHandle::set_placement(const ViewPlacement placement) const {
set_maximized(placement == VIEW_PLACEMENT_MAXIMIZED);
set_fullscreen(placement == VIEW_PLACEMENT_FULLSCREEN);
}

void ForeignToplevelHandle::set_maximized(const bool maximized) {
void ForeignToplevelHandle::set_maximized(const bool maximized) const {
wlr_foreign_toplevel_handle_v1_set_maximized(&handle, maximized);
}

void ForeignToplevelHandle::set_minimized(const bool minimized) {
void ForeignToplevelHandle::set_minimized(const bool minimized) const {
wlr_foreign_toplevel_handle_v1_set_minimized(&handle, minimized);
}

void ForeignToplevelHandle::set_activated(const bool activated) {
void ForeignToplevelHandle::set_activated(const bool activated) const {
wlr_foreign_toplevel_handle_v1_set_activated(&handle, activated);
}

void ForeignToplevelHandle::set_fullscreen(const bool fullscreen) {
void ForeignToplevelHandle::set_fullscreen(const bool fullscreen) const {
wlr_foreign_toplevel_handle_v1_set_fullscreen(&handle, fullscreen);
}

void ForeignToplevelHandle::output_enter(const Output& output) {
void ForeignToplevelHandle::output_enter(const Output& output) const {
wlr_foreign_toplevel_handle_v1_output_enter(&handle, &output.wlr);
}

void ForeignToplevelHandle::output_leave(const Output& output) {
void ForeignToplevelHandle::output_leave(const Output& output) const {
wlr_foreign_toplevel_handle_v1_output_leave(&handle, &output.wlr);
}
36 changes: 18 additions & 18 deletions src/foreign_toplevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class ForeignToplevelHandle {
public:
struct Listeners {
std::reference_wrapper<ForeignToplevelHandle> parent;
wl_listener request_maximize;
wl_listener request_minimize;
wl_listener request_activate;
wl_listener request_fullscreen;
wl_listener request_close;
wl_listener set_rectangle;
Listeners(ForeignToplevelHandle& parent) noexcept : parent(parent) {}
wl_listener request_maximize = {};
wl_listener request_minimize = {};
wl_listener request_activate = {};
wl_listener request_fullscreen = {};
wl_listener request_close = {};
wl_listener set_rectangle = {};
explicit Listeners(ForeignToplevelHandle& parent) noexcept : parent(parent) {}
};

private:
Expand All @@ -30,19 +30,19 @@ class ForeignToplevelHandle {
View& view;
wlr_foreign_toplevel_handle_v1& handle;

ForeignToplevelHandle(View& view) noexcept;
explicit ForeignToplevelHandle(View& view) noexcept;
~ForeignToplevelHandle() noexcept;

void set_title(const char* title);
void set_app_id(const char* app_id);
void set_parent(std::optional<std::reference_wrapper<const ForeignToplevelHandle>> parent);
void set_placement(const ViewPlacement placement);
void set_maximized(const bool maximized);
void set_fullscreen(const bool fullscreen);
void set_minimized(const bool minimized);
void set_activated(const bool activated);
void output_enter(const Output& output);
void output_leave(const Output& output);
void set_title(const char* title) const;
void set_app_id(const char* app_id) const;
void set_parent(std::optional<std::reference_wrapper<const ForeignToplevelHandle>> parent) const;
void set_placement(ViewPlacement placement) const;
void set_maximized(bool maximized) const;
void set_fullscreen(bool fullscreen) const;
void set_minimized(bool minimized) const;
void set_activated(bool activated) const;
void output_enter(const Output& output) const;
void output_leave(const Output& output) const;
};

#endif
8 changes: 4 additions & 4 deletions src/input/constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class PointerConstraint {
public:
struct Listeners {
std::reference_wrapper<PointerConstraint> parent;
wl_listener set_region;
wl_listener surface_commit;
wl_listener destroy;
Listeners(PointerConstraint& parent) noexcept : parent(parent) {}
wl_listener set_region = {};
wl_listener surface_commit = {};
wl_listener destroy = {};
explicit Listeners(PointerConstraint& parent) noexcept : parent(parent) {}
};

private:
Expand Down
Loading

0 comments on commit 945b425

Please sign in to comment.