Cleanup: pass const arguments in GHOST/Wayland implementation

This commit is contained in:
Campbell Barton
2025-07-31 03:45:42 +00:00
parent 024291987c
commit 7c5ba9cb2c
2 changed files with 83 additions and 75 deletions

View File

@@ -1843,8 +1843,8 @@ static bool gwl_registry_entry_remove_by_name(GWL_Display *display,
}
static bool gwl_registry_entry_remove_by_interface_slot(GWL_Display *display,
int interface_slot,
bool on_exit)
const int interface_slot,
const bool on_exit)
{
GWL_RegistryEntry *reg = display->registry_entry;
GWL_RegistryEntry **reg_link_p = &display->registry_entry;
@@ -3836,7 +3836,7 @@ static void cursor_surface_handle_leave(void *data, wl_surface *wl_surface, wl_o
static void cursor_surface_handle_preferred_buffer_scale(void * /*data*/,
wl_surface * /*wl_surface*/,
int32_t factor)
const int32_t factor)
{
/* Only available in interface version 6. */
CLOG_DEBUG(LOG, "handle_preferred_buffer_scale (factor=%d)", factor);
@@ -4190,7 +4190,7 @@ static void pointer_handle_frame(void *data, wl_pointer * /*wl_pointer*/)
}
static void pointer_handle_axis_source(void *data,
wl_pointer * /*wl_pointer*/,
uint32_t axis_source)
const uint32_t axis_source)
{
CLOG_DEBUG(LOG, "axis_source (axis_source=%u)", axis_source);
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
@@ -4198,8 +4198,8 @@ static void pointer_handle_axis_source(void *data,
}
static void pointer_handle_axis_stop(void *data,
wl_pointer * /*wl_pointer*/,
uint32_t time,
uint32_t axis)
const uint32_t time,
const uint32_t axis)
{
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
seat->pointer_scroll.event_ms = seat->system->ms_from_input_time(time);
@@ -4219,8 +4219,8 @@ static void pointer_handle_axis_stop(void *data,
}
static void pointer_handle_axis_discrete(void *data,
wl_pointer * /*wl_pointer*/,
uint32_t axis,
int32_t discrete)
const uint32_t axis,
const int32_t discrete)
{
/* NOTE: a discrete axis are typically mouse wheel events.
* The non-discrete version of this function is used for touch-pad. */
@@ -4236,8 +4236,8 @@ static void pointer_handle_axis_discrete(void *data,
}
static void pointer_handle_axis_value120(void *data,
wl_pointer * /*wl_pointer*/,
uint32_t axis,
int32_t value120)
const uint32_t axis,
const int32_t value120)
{
/* Only available in interface version 8. */
CLOG_DEBUG(LOG, "axis_value120 (axis=%u, value120=%d)", axis, value120);
@@ -4253,8 +4253,8 @@ static void pointer_handle_axis_value120(void *data,
#ifdef WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM /* Requires WAYLAND 1.22 or newer. */
static void pointer_handle_axis_relative_direction(void *data,
wl_pointer * /*wl_pointer*/,
uint32_t axis,
uint32_t direction)
const uint32_t axis,
const uint32_t direction)
{
/* Only available in interface version 9. */
CLOG_DEBUG(LOG, "axis_relative_direction (axis=%u, direction=%u)", axis, direction);
@@ -4299,19 +4299,19 @@ static CLG_LogRef LOG_WL_POINTER_GESTURE_HOLD = {"ghost.wl.handle.pointer_gestur
static void gesture_hold_handle_begin(
void * /*data*/,
zwp_pointer_gesture_hold_v1 * /*zwp_pointer_gesture_hold_v1*/,
uint32_t /*serial*/,
uint32_t /*time*/,
const uint32_t /*serial*/,
const uint32_t /*time*/,
wl_surface * /*surface*/,
uint32_t fingers)
const uint32_t fingers)
{
CLOG_DEBUG(LOG, "begin (fingers=%u)", fingers);
}
static void gesture_hold_handle_end(void * /*data*/,
zwp_pointer_gesture_hold_v1 * /*zwp_pointer_gesture_hold_v1*/,
uint32_t /*serial*/,
uint32_t /*time*/,
int32_t cancelled)
const uint32_t /*serial*/,
const uint32_t /*time*/,
const int32_t cancelled)
{
CLOG_DEBUG(LOG, "end (cancelled=%i)", cancelled);
}
@@ -4336,10 +4336,10 @@ static CLG_LogRef LOG_WL_POINTER_GESTURE_PINCH = {"ghost.wl.handle.pointer_gestu
static void gesture_pinch_handle_begin(void *data,
zwp_pointer_gesture_pinch_v1 * /*pinch*/,
uint32_t /*serial*/,
uint32_t time,
const uint32_t /*serial*/,
const uint32_t time,
wl_surface * /*surface*/,
uint32_t fingers)
const uint32_t fingers)
{
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
(void)seat->system->ms_from_input_time(time); /* Only update internal time. */
@@ -4393,11 +4393,11 @@ static void gesture_pinch_handle_begin(void *data,
static void gesture_pinch_handle_update(void *data,
zwp_pointer_gesture_pinch_v1 * /*pinch*/,
uint32_t time,
wl_fixed_t dx,
wl_fixed_t dy,
wl_fixed_t scale,
wl_fixed_t rotation)
const uint32_t time,
const wl_fixed_t dx,
const wl_fixed_t dy,
const wl_fixed_t scale,
const wl_fixed_t rotation)
{
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
const uint64_t event_ms = seat->system->ms_from_input_time(time);
@@ -4453,9 +4453,9 @@ static void gesture_pinch_handle_update(void *data,
static void gesture_pinch_handle_end(void *data,
zwp_pointer_gesture_pinch_v1 * /*pinch*/,
uint32_t /*serial*/,
uint32_t time,
int32_t cancelled)
const uint32_t /*serial*/,
const uint32_t time,
const int32_t cancelled)
{
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
(void)seat->system->ms_from_input_time(time); /* Only update internal time. */
@@ -4546,12 +4546,12 @@ static CLG_LogRef LOG_WL_TOUCH = {"ghost.wl.handle.touch"};
static void touch_seat_handle_down(void *data,
wl_touch * /*touch*/,
uint32_t serial,
uint32_t time,
const uint32_t serial,
const uint32_t time,
wl_surface *surface,
int32_t id,
wl_fixed_t x,
wl_fixed_t y)
const int32_t id,
const wl_fixed_t x,
const wl_fixed_t y)
{
/* Touching down is equivalent to moving a pointer and holding its left mouse button. */
@@ -4595,8 +4595,11 @@ static void touch_seat_handle_down(void *data,
win->cursor_shape_refresh();
}
static void touch_seat_handle_up(
void *data, wl_touch * /*touch*/, uint32_t /*event_serial*/, uint32_t time, int32_t id)
static void touch_seat_handle_up(void *data,
wl_touch * /*touch*/,
const uint32_t /*serial*/,
const uint32_t time,
const int32_t id)
{
CLOG_DEBUG(LOG, "up");
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
@@ -4612,8 +4615,12 @@ static void touch_seat_handle_up(
seat->touch_state.up_event_time_ms = event_ms;
}
static void touch_seat_handle_motion(
void *data, wl_touch * /*touch*/, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y)
static void touch_seat_handle_motion(void *data,
wl_touch * /*touch*/,
const uint32_t time,
const int32_t id,
const wl_fixed_t x,
const wl_fixed_t y)
{
CLOG_DEBUG(LOG, "motion");
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
@@ -4713,17 +4720,17 @@ static void touch_seat_handle_cancel(void * /*data*/, wl_touch * /*wl_touch*/)
static void touch_seat_handle_shape(void * /*data*/,
wl_touch * /*touch*/,
int32_t /*id*/,
wl_fixed_t /*major*/,
wl_fixed_t /*minor*/)
const int32_t /*id*/,
const wl_fixed_t /*major*/,
const wl_fixed_t /*minor*/)
{
CLOG_DEBUG(LOG, "shape");
}
static void touch_seat_handle_orientation(void * /*data*/,
wl_touch * /*touch*/,
int32_t /*id*/,
wl_fixed_t /*orientation*/)
const int32_t /*id*/,
const wl_fixed_t /*orientation*/)
{
CLOG_DEBUG(LOG, "orientation");
}
@@ -5842,7 +5849,7 @@ static CLG_LogRef LOG_WL_PRIMARY_SELECTION_SOURCE = {"ghost.wl.handle.primary_se
static void primary_selection_source_send(void *data,
zwp_primary_selection_source_v1 * /*source*/,
const char * /*mime_type*/,
int32_t fd)
const int32_t fd)
{
CLOG_DEBUG(LOG, "send");
@@ -5957,8 +5964,8 @@ static void text_input_handle_leave(void *data,
static void text_input_handle_preedit_string(void *data,
zwp_text_input_v3 * /*zwp_text_input_v3*/,
const char *text,
int32_t cursor_begin,
int32_t cursor_end)
const int32_t cursor_begin,
const int32_t cursor_end)
{
CLOG_DEBUG(LOG,
"preedit_string (text=\"%s\", cursor_begin=%d, cursor_end=%d)",
@@ -6000,8 +6007,8 @@ static void text_input_handle_commit_string(void *data,
static void text_input_handle_delete_surrounding_text(void * /*data*/,
zwp_text_input_v3 * /*zwp_text_input_v3*/,
uint32_t before_length,
uint32_t after_length)
const uint32_t before_length,
const uint32_t after_length)
{
CLOG_DEBUG(LOG,
"delete_surrounding_text (before_length=%u, after_length=%u)",
@@ -6014,7 +6021,7 @@ static void text_input_handle_delete_surrounding_text(void * /*data*/,
static void text_input_handle_done(void *data,
zwp_text_input_v3 * /*zwp_text_input_v3*/,
uint32_t /*serial*/)
const uint32_t /*serial*/)
{
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
GHOST_SystemWayland *system = seat->system;
@@ -7548,7 +7555,7 @@ static void gwl_display_event_thread_destroy(GWL_Display *display)
* WAYLAND specific implementation of the #GHOST_System interface.
* \{ */
GHOST_SystemWayland::GHOST_SystemWayland(bool background)
GHOST_SystemWayland::GHOST_SystemWayland(const bool background)
: GHOST_System(),
#ifdef USE_EVENT_BACKGROUND_THREAD
server_mutex(new std::mutex),
@@ -8010,7 +8017,7 @@ static char *system_clipboard_get_primary_selection(GWL_Display *display,
}
static char *system_clipboard_get(GWL_Display *display,
bool nil_terminate,
const bool nil_terminate,
const char *mime_receive_override,
size_t *r_data_len)
{
@@ -8070,7 +8077,7 @@ static char *system_clipboard_get(GWL_Display *display,
return data;
}
char *GHOST_SystemWayland::getClipboard(bool selection) const
char *GHOST_SystemWayland::getClipboard(const bool selection) const
{
#ifdef USE_EVENT_BACKGROUND_THREAD
std::lock_guard lock_server_guard{*server_mutex};
@@ -8156,7 +8163,7 @@ static void system_clipboard_put(GWL_Display *display, const char *buffer)
}
}
void GHOST_SystemWayland::putClipboard(const char *buffer, bool selection) const
void GHOST_SystemWayland::putClipboard(const char *buffer, const bool selection) const
{
#ifdef USE_EVENT_BACKGROUND_THREAD
std::lock_guard lock_server_guard{*server_mutex};
@@ -9315,11 +9322,11 @@ GHOST_TimerManager *GHOST_SystemWayland::ghost_timer_manager()
#ifdef WITH_INPUT_IME
void GHOST_SystemWayland::ime_begin(const GHOST_WindowWayland *win,
int32_t x,
int32_t y,
int32_t w,
int32_t h,
bool completed) const
const int32_t x,
const int32_t y,
const int32_t w,
const int32_t h,
const bool completed) const
{
GWL_Seat *seat = gwl_display_seat_active_get(display_);
if (UNLIKELY(!seat)) {

View File

@@ -228,7 +228,7 @@ static void gwl_round_int2_by(int value_p[2], const int round_value)
/**
* Return true if the value is already rounded by `round_value`.
*/
static bool gwl_round_int_test(int value, const int round_value)
static bool gwl_round_int_test(const int value, const int round_value)
{
return value == ((value / round_value) * round_value);
}
@@ -266,11 +266,11 @@ wl_fixed_t gwl_window_scale_wl_fixed_from(const GWL_WindowScaleParams &scale_par
return value / scale_params.scale;
}
int gwl_window_scale_int_to(const GWL_WindowScaleParams &scale_params, int value)
int gwl_window_scale_int_to(const GWL_WindowScaleParams &scale_params, const int value)
{
return wl_fixed_to_int(gwl_window_scale_wl_fixed_to(scale_params, wl_fixed_from_int(value)));
}
int gwl_window_scale_int_from(const GWL_WindowScaleParams &scale_params, int value)
int gwl_window_scale_int_from(const GWL_WindowScaleParams &scale_params, const int value)
{
return wl_fixed_to_int(gwl_window_scale_wl_fixed_from(scale_params, wl_fixed_from_int(value)));
}
@@ -641,7 +641,7 @@ static bool gwl_window_state_set(GWL_Window *win, const GHOST_TWindowState state
* Scale a value from a viewport value to Wayland windowing.
* Scale down or not at all.
*/
static int gwl_window_fractional_to_viewport(const GWL_WindowFrame &frame, int value)
static int gwl_window_fractional_to_viewport(const GWL_WindowFrame &frame, const int value)
{
GHOST_ASSERT(frame.fractional_scale != 0, "Not fractional or called before initialized!");
return (value * frame.fractional_scale) / FRACTIONAL_DENOMINATOR;
@@ -651,7 +651,7 @@ static int gwl_window_fractional_to_viewport(const GWL_WindowFrame &frame, int v
* Scale a value from a Wayland windowing value to the viewport.
* Scales up or not at all.
*/
static int gwl_window_fractional_from_viewport(const GWL_WindowFrame &frame, int value)
static int gwl_window_fractional_from_viewport(const GWL_WindowFrame &frame, const int value)
{
GHOST_ASSERT(frame.fractional_scale != 0, "Not fractional or called before initialized!");
return (value * FRACTIONAL_DENOMINATOR) / frame.fractional_scale;
@@ -661,13 +661,13 @@ static int gwl_window_fractional_from_viewport(const GWL_WindowFrame &frame, int
* (rounding is part of the WAYLAND spec). All other conversions such as cursor coordinates
* can used simple integer division as rounding is not defined in this case. */
static int gwl_window_fractional_to_viewport_round(const GWL_WindowFrame &frame, int value)
static int gwl_window_fractional_to_viewport_round(const GWL_WindowFrame &frame, const int value)
{
GHOST_ASSERT(frame.fractional_scale != 0, "Not fractional or called before initialized!");
return lroundf(double(value * frame.fractional_scale) / double(FRACTIONAL_DENOMINATOR));
}
static int gwl_window_fractional_from_viewport_round(const GWL_WindowFrame &frame, int value)
static int gwl_window_fractional_from_viewport_round(const GWL_WindowFrame &frame, const int value)
{
GHOST_ASSERT(frame.fractional_scale != 0, "Not fractional or called before initialized!");
return lroundf(double(value * FRACTIONAL_DENOMINATOR) / double(frame.fractional_scale));
@@ -1289,8 +1289,8 @@ static void xdg_toplevel_handle_close(void *data, xdg_toplevel * /*xdg_toplevel*
static void xdg_toplevel_handle_configure_bounds(void *data,
xdg_toplevel * /*xdg_toplevel*/,
int32_t width,
int32_t height)
const int32_t width,
const int32_t height)
{
/* Only available in interface version 4. */
CLOG_DEBUG(LOG, "configure_bounds (size=[%d, %d])", width, height);
@@ -1688,7 +1688,7 @@ static void surface_handle_leave(void *data, wl_surface * /*wl_surface*/, wl_out
defined(WL_SURFACE_PREFERRED_BUFFER_TRANSFORM_SINCE_VERSION)
static void surface_handle_preferred_buffer_scale(void * /*data*/,
wl_surface * /*wl_surface*/,
int32_t factor)
const int32_t factor)
{
/* Only available in interface version 6. */
CLOG_DEBUG(LOG, "handle_preferred_buffer_scale (factor=%d)", factor);
@@ -1696,7 +1696,7 @@ static void surface_handle_preferred_buffer_scale(void * /*data*/,
static void surface_handle_preferred_buffer_transform(void * /*data*/,
wl_surface * /*wl_surface*/,
uint32_t transform)
const uint32_t transform)
{
/* Only available in interface version 6. */
CLOG_DEBUG(LOG, "handle_preferred_buffer_transform (transform=%u)", transform);
@@ -2359,8 +2359,8 @@ GHOST_TSuccess GHOST_WindowWayland::setClientSize(const uint32_t width, const ui
return GHOST_kSuccess;
}
void GHOST_WindowWayland::screenToClient(int32_t inX,
int32_t inY,
void GHOST_WindowWayland::screenToClient(const int32_t inX,
const int32_t inY,
int32_t &outX,
int32_t &outY) const
{
@@ -2368,8 +2368,8 @@ void GHOST_WindowWayland::screenToClient(int32_t inX,
outY = inY;
}
void GHOST_WindowWayland::clientToScreen(int32_t inX,
int32_t inY,
void GHOST_WindowWayland::clientToScreen(const int32_t inX,
const int32_t inY,
int32_t &outX,
int32_t &outY) const
{
@@ -2389,7 +2389,7 @@ uint16_t GHOST_WindowWayland::getDPIHint()
return window_->frame.buffer_scale * base_dpi;
}
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorVisibility(bool visible)
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorVisibility(const bool visible)
{
#ifdef USE_EVENT_BACKGROUND_THREAD
std::lock_guard lock_server_guard{*system_->server_mutex};
@@ -2507,7 +2507,8 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
#ifdef WITH_INPUT_IME
void GHOST_WindowWayland::beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed)
void GHOST_WindowWayland::beginIME(
const int32_t x, const int32_t y, const int32_t w, const int32_t h, const bool completed)
{
system_->ime_begin(this, x, y, w, h, completed);
}