Skip to content

Commit

Permalink
Resolve some warnings from clang-tidy and Resharper
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Dec 14, 2024
1 parent 221970d commit aefcb62
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/input/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void Cursor::process_resize(const uint32_t time) const {
* you'd wait for the client to prepare a buffer at the new size, then
* commit any movement that was prepared.
*/
std::shared_ptr<View> view = seat.server.grabbed_view.lock();
const std::shared_ptr<View> view = seat.server.grabbed_view.lock();

if (view == nullptr) {
wlr_log(WLR_ERROR, "Attempted to process_resize without a grabbed view");
Expand Down Expand Up @@ -186,7 +186,7 @@ static void cursor_button_notify(wl_listener* listener, void* data) {
double sy;

wlr_surface* surface = nullptr;
auto magpie_surface = server.surface_at(cursor.wlr.x, cursor.wlr.y, &surface, &sx, &sy).lock();
const auto magpie_surface = server.surface_at(cursor.wlr.x, cursor.wlr.y, &surface, &sx, &sy).lock();

if (event->state == WL_POINTER_BUTTON_STATE_RELEASED) {
/* If you released any buttons, we exit interactive move/resize mode. */
Expand Down Expand Up @@ -474,7 +474,7 @@ void Cursor::reset_mode() {
}

void Cursor::warp_to_constraint(const PointerConstraint& constraint) const {
auto focused_view = seat.server.focused_view.lock();
const auto focused_view = seat.server.focused_view.lock();

if (focused_view == nullptr) {
// only warp to constraints tied to views...
Expand Down
2 changes: 1 addition & 1 deletion src/input/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void keyboard_handle_destroy(wl_listener* listener, [[maybe_unused]] void
}

static bool handle_compositor_keybinding(const Keyboard& keyboard, const uint32_t modifiers, const xkb_keysym_t sym) {
Server& server = keyboard.seat.server;
const Server& server = keyboard.seat.server;

if (modifiers == WLR_MODIFIER_ALT) {
switch (sym) {
Expand Down
2 changes: 1 addition & 1 deletion src/input/seat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Seat::apply_constraint(const wlr_pointer* pointer, double* dx, double* dy)
return;
}

auto focused_view = server.focused_view.lock();
const auto focused_view = server.focused_view.lock();

if (focused_view == nullptr) {
wlr_log(WLR_DEBUG, "Attempted to apply a pointer constraint without a focused view");
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/budgie_keyboard_shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void budgie_keyboard_shortcuts_subscriber_unregister_shortcut(
free(target);
}

static const struct budgie_keyboard_shortcuts_subscriber_interface budgie_keyboard_shortcuts_subscriber_impl = {
static constexpr struct budgie_keyboard_shortcuts_subscriber_interface budgie_keyboard_shortcuts_subscriber_impl = {
.destroy = budgie_keyboard_shortcuts_subscriber_destroy,
.register_shortcut = budgie_keyboard_shortcuts_subscriber_register_shortcut,
.unregister_shortcut = budgie_keyboard_shortcuts_subscriber_unregister_shortcut,
Expand Down Expand Up @@ -111,7 +111,7 @@ static void budgie_keyboard_shortcuts_manager_subscribe(wl_client* client, wl_re
wl_signal_emit_mutable(&manager->events.subscribe, subscriber);
}

static const struct budgie_keyboard_shortcuts_manager_interface budgie_keyboard_shortcuts_manager_impl = {
static constexpr struct budgie_keyboard_shortcuts_manager_interface budgie_keyboard_shortcuts_manager_impl = {
.destroy = budgie_keyboard_shortcuts_manager_destroy,
.subscribe = budgie_keyboard_shortcuts_manager_subscribe,
};
Expand Down
2 changes: 1 addition & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Server::try_focus_next_exclusive_layer() {
focus_layer(topmost_exclusive_layer);
}

void Server::focus_layer(std::shared_ptr<Layer> layer) {
void Server::focus_layer(const std::shared_ptr<Layer>& layer) {
if (layer == nullptr) {
focused_layer.reset();
if (focused_view.lock() != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion src/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Server final : public std::enable_shared_from_this<Server> {

std::weak_ptr<Surface> surface_at(double lx, double ly, wlr_surface** wlr, double* sx, double* sy) const;
void focus_view(std::shared_ptr<View>&& view);
void focus_layer(std::shared_ptr<Layer> layer);
void focus_layer(const std::shared_ptr<Layer>& layer);
void try_focus_next_exclusive_layer();
bool is_restricted(const wl_global* global) const;
};
Expand Down
4 changes: 2 additions & 2 deletions src/surface/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void wlr_layer_surface_v1_map_notify(wl_listener* listener, [[maybe_unuse
static void wlr_layer_surface_v1_unmap_notify(wl_listener* listener, [[maybe_unused]] void* data) {
wlr_log(WLR_DEBUG, "wlr_layer_surface_v1.events.unmap(listener=%p, data=%p)", (void*) listener, data);

Layer& layer = magpie_container_of(listener, layer, unmap);
const Layer& layer = magpie_container_of(listener, layer, unmap);

wlr_scene_node_set_enabled(layer.scene_node, false);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ static void wlr_layer_surface_v1_new_popup_notify(wl_listener* listener, void* d
return;
}

Layer& layer = magpie_container_of(listener, layer, new_popup);
const Layer& layer = magpie_container_of(listener, layer, new_popup);
auto* surface = static_cast<Surface*>(layer.wlr.surface->data);
surface->popups.emplace(std::make_shared<Popup>(*surface, *static_cast<wlr_xdg_popup*>(data)));
}
Expand Down
1 change: 0 additions & 1 deletion src/surface/subsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <utility>

#include "wlr-wrap-start.hpp"
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/util/log.h>
Expand Down
4 changes: 2 additions & 2 deletions src/surface/xdg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ XdgView::XdgView(Server& server, wlr_xdg_toplevel& xdg_toplevel) noexcept
toplevel_handle->set_app_id(xdg_toplevel.app_id);

if (xdg_toplevel.parent != nullptr) {
auto* m_view = dynamic_cast<View*>(static_cast<Surface*>(xdg_toplevel.parent->base->data));
const auto* m_view = dynamic_cast<View*>(static_cast<Surface*>(xdg_toplevel.parent->base->data));
if (m_view != nullptr) {
toplevel_handle->set_parent(m_view->toplevel_handle);
}
Expand Down Expand Up @@ -282,7 +282,7 @@ void XdgView::map() {
wlr_xdg_surface_get_geometry(wlr.base, &current);

if (!server.outputs.empty()) {
auto* const output = static_cast<Output*>(wlr_output_layout_get_center_output(server.output_layout)->data);
const auto* const output = static_cast<Output*>(wlr_output_layout_get_center_output(server.output_layout)->data);
const auto usable_area = output->usable_area;
const auto center_x = usable_area.x + (usable_area.width / 2);
const auto center_y = usable_area.y + (usable_area.height / 2);
Expand Down

0 comments on commit aefcb62

Please sign in to comment.