Cleanup: Various clang-tidy warnings in windowmanager

Pull Request: https://projects.blender.org/blender/blender/pulls/133734
This commit is contained in:
Brecht Van Lommel
2025-01-26 20:07:59 +01:00
parent b78fa81ed4
commit ae28102c3f
32 changed files with 65 additions and 54 deletions

View File

@@ -11,7 +11,6 @@
#include <optional>
#include <string>
#include "BLI_utildefines.h"
#include "DNA_windowmanager_types.h"
#include "WM_types.hh"

View File

@@ -118,7 +118,7 @@ struct wmWindowManager;
#include "DNA_vec_types.h"
#include "DNA_xr_types.h"
#include "BKE_wm_runtime.hh"
#include "BKE_wm_runtime.hh" // IWYU pragma: export
#include "RNA_types.hh"

View File

@@ -13,6 +13,9 @@
#pragma once
#include "WM_gizmo_types.hh"
#include "wm_gizmo_fn.hh"
struct ARegion;
struct bContext;
struct IDProperty;
@@ -40,8 +43,6 @@ struct wmOperatorType;
struct wmWindow;
struct wmWindowManager;
#include "wm_gizmo_fn.hh"
/* -------------------------------------------------------------------- */
/* #wmGizmo. */

View File

@@ -10,11 +10,10 @@
#include "BLI_listbase.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BKE_context.hh"
#include "GPU_batch.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_prototypes.hh"

View File

@@ -29,6 +29,7 @@
#include "RNA_access.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_types.hh"
#include "wm_event_system.hh"

View File

@@ -13,7 +13,6 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
#include <cstddef>
#include <cstring>
#include "DNA_windowmanager_types.h"
@@ -38,6 +37,7 @@
#include "BKE_workspace.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_message.hh"
#include "WM_types.hh"
#include "wm.hh"

View File

@@ -21,8 +21,9 @@
#include "BLT_translation.hh"
#include "BLI_blenlib.h"
#include "BLI_math_color.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BIF_glutil.hh"
@@ -35,19 +36,19 @@
#include "BKE_preview_image.hh"
#include "BKE_screen.hh"
#include "GHOST_C-api.h"
#include "BLO_readfile.hh"
#include "ED_fileselect.hh"
#include "ED_screen.hh"
#include "GPU_shader.hh"
#include "GPU_shader_builtin.hh"
#include "GPU_state.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "GHOST_Types.h"
#include "UI_interface.hh"
#include "UI_interface_icons.hh"
#include "UI_resources.hh"

View File

@@ -15,9 +15,10 @@
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "RNA_access.hh"

View File

@@ -28,8 +28,10 @@
#include "GHOST_C-api.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_timer.h"
#include "BLI_utildefines.h"
@@ -67,6 +69,7 @@
#include "UI_view2d.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_message.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"

View File

@@ -33,12 +33,12 @@
#include "MEM_CacheLimiterC-Api.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_fileops_types.h"
#include "BLI_fileops.h"
#include "BLI_filereader.h"
#include "BLI_linklist.h"
#include "BLI_math_time.h"
#include "BLI_memory_cache.hh"
#include "BLI_string.h"
#include "BLI_system.h"
#include "BLI_threads.h"
#include "BLI_time.h"
@@ -132,6 +132,7 @@
#include "DEG_depsgraph.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_message.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"

View File

@@ -11,7 +11,6 @@
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <cstddef>
#include <cstring>
#include "CLG_log.h"
@@ -21,8 +20,10 @@
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "BLI_map.hh"
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "BLO_readfile.hh"

View File

@@ -16,8 +16,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_bitmap_draw_2d.h"
#include "BLI_blenlib.h"
#include "BLI_lasso_2d.hh"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "WM_api.hh"

View File

@@ -12,8 +12,11 @@
* - Property definitions are in `wm_operator_props.cc`.
*/
#include "MEM_guardedalloc.h"
#include <fmt/format.h>
#include <algorithm>
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
@@ -378,9 +381,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
else {
rect->xmax += floor(fac);
}
if (rect->xmax < 1) {
rect->xmax = 1;
}
rect->xmax = std::max(rect->xmax, 1);
is_circle_size = true;
break;
case GESTURE_MODAL_CIRCLE_ADD:
@@ -389,9 +390,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
break;
case GESTURE_MODAL_CIRCLE_SUB:
rect->xmax -= 2 + rect->xmax / 10;
if (rect->xmax < 1) {
rect->xmax = 1;
}
rect->xmax = std::max(rect->xmax, 1);
is_circle_size = true;
break;
case GESTURE_MODAL_SELECT:

View File

@@ -71,6 +71,7 @@
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_message.hh"
#include "WM_types.hh"
@@ -102,7 +103,6 @@
#include "UI_resources.hh"
#include "UI_string_search.hh"
#include "GPU_compilation_subprocess.hh"
#include "GPU_context.hh"
#include "GPU_init_exit.hh"
#include "GPU_material.hh"

View File

@@ -14,7 +14,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_string.h"
#include "BLI_threads.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
@@ -268,7 +268,7 @@ static void wm_jobs_update_progress_bars(wmWindowManager *wm)
/* If there are running jobs, set the global progress indicator. */
if (jobs_progress > 0) {
float progress = total_progress / float(jobs_progress);
float progress = total_progress / jobs_progress;
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WM_progress_set(win, progress);

View File

@@ -20,7 +20,8 @@
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BLF_api.hh"
@@ -40,6 +41,7 @@
#include "RNA_enum_types.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_types.hh"
#include "wm_event_system.hh"
#include "wm_event_types.hh"

View File

@@ -21,6 +21,7 @@
#include "RNA_access.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_types.hh"
/* Menu wrapper for #WM_keymap_add_item. */

View File

@@ -10,8 +10,6 @@
#include <cstdio>
#include "BLI_sys_types.h"
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"

View File

@@ -15,7 +15,6 @@
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BLI_bounds.hh"
#include "BLI_math_base.h"
#include "BLI_rect.h"

View File

@@ -17,7 +17,7 @@
#include "BLT_translation.hh"
#include "BLI_blenlib.h"
#include "BLI_string.h"
#include "BLI_vector_set.hh"
#include "BKE_context.hh"
@@ -33,6 +33,7 @@
#endif
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_types.hh"
#include "wm.hh"

View File

@@ -128,7 +128,7 @@ static bool interactive_value_update(ValueInteraction *inter,
value_scale;
if (event->modifier & KM_CTRL) {
const double snap = 0.1;
value_delta = float(roundf(double(value_delta) / snap)) * snap;
value_delta = roundf(double(value_delta) / snap) * snap;
}
if (event->modifier & KM_SHIFT) {
value_delta *= 0.1f;

View File

@@ -39,10 +39,12 @@
#include "BLT_translation.hh"
#include "BLI_blenlib.h"
#include "BLI_dial_2d.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector_types.hh"
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
@@ -95,6 +97,7 @@
#include "UI_resources.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_types.hh"
#include "wm.hh"
@@ -146,7 +149,7 @@ size_t WM_operator_py_idname(char *dst, const char *src)
size_t WM_operator_bl_idname(char *dst, const char *src)
{
const size_t from_len = size_t(strlen(src));
const size_t from_len = strlen(src);
const char *sep = strchr(src, OP_PY_SEP_CHAR);
if (sep && (from_len <= OP_MAX_PY_IDNAME)) {
@@ -2474,7 +2477,7 @@ bool WM_paint_cursor_end(wmPaintCursor *handle)
{
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
LISTBASE_FOREACH (wmPaintCursor *, pc, &wm->paintcursors) {
if (pc == (wmPaintCursor *)handle) {
if (pc == handle) {
BLI_remlink(&wm->paintcursors, pc);
MEM_freeN(pc);
return true;

View File

@@ -21,6 +21,7 @@
#include "BKE_appdir.hh"
#include "BKE_global.hh"
#include "GPU_context.hh"
#include "GPU_platform.hh"
#define WM_PLATFORM_SUPPORT_TEXT_SIZE 1024

View File

@@ -7,6 +7,4 @@
*/
#pragma once
#include "BLI_sys_types.h"
bool WM_platform_support_perform_checks();

View File

@@ -12,6 +12,7 @@
* this could be made into its own module, alongside creator.
*/
#include <algorithm>
#include <cerrno>
#include <cstdlib>
#include <cstring>
@@ -1976,9 +1977,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_
ps.picture = ps.picture->prev;
}
}
if (g_playanim.total_time > 0.0) {
g_playanim.total_time = 0.0;
}
g_playanim.total_time = std::min(g_playanim.total_time, 0.0);
#ifdef WITH_AUDASPACE
if (g_audaspace.playback_handle) {

View File

@@ -20,7 +20,7 @@
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_path_utils.hh"
#include "BLI_utildefines.h"
#include "BKE_appdir.hh"

View File

@@ -9,13 +9,13 @@
*/
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "GPU_viewport.hh"
#include "WM_api.hh"

View File

@@ -11,8 +11,6 @@
# include "BLI_threads.h"
#endif
#include "GHOST_C-api.h"
#include "GPU_context.hh"
#include "GPU_framebuffer.hh"

View File

@@ -8,6 +8,7 @@
* Window management, wrap GHOST.
*/
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
@@ -28,7 +29,11 @@
#include "GHOST_C-api.h"
#include "BLI_blenlib.h"
#include "BLI_math_vector.h"
#include "BLI_path_utils.hh"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_system.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
@@ -49,6 +54,7 @@
#include "RNA_enum_types.hh"
#include "WM_api.hh"
#include "WM_keymap.hh"
#include "WM_types.hh"
#include "wm.hh"
#include "wm_draw.hh"
@@ -577,7 +583,7 @@ void WM_window_set_dpi(const wmWindow *win)
U.dpi = auto_dpi * U.ui_scale * (72.0 / 96.0f);
/* Automatically set larger pixel size for high DPI. */
int pixelsize = max_ii(1, int(U.dpi / 64));
int pixelsize = max_ii(1, (U.dpi / 64));
/* User adjustment for pixel size. */
pixelsize = max_ii(1, pixelsize + U.ui_line_width);
@@ -1760,9 +1766,7 @@ static bool wm_window_timers_process(const bContext *C, int *sleep_us_p)
if (wt->time_next >= time) {
if ((has_event == false) && (sleep_us != 0)) {
/* The timer is not ready to run but may run shortly. */
if (wt->time_next < ntime_min) {
ntime_min = wt->time_next;
}
ntime_min = std::min(wt->time_next, ntime_min);
}
continue;
}

View File

@@ -7,11 +7,9 @@
*/
#pragma once
#include "BLI_sys_types.h"
#include "GHOST_Types.h"
#include "GPU_context.hh"
#include "GPU_platform_backend_enum.h"
struct bContext;

View File

@@ -13,6 +13,7 @@
#include <cstring>
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
@@ -20,10 +21,11 @@
#include "ED_view3d_offscreen.hh"
#include "GHOST_C-api.h"
#include "GPU_batch_presets.hh"
#include "GPU_immediate.hh"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "GPU_viewport.hh"
#include "WM_api.hh"

View File

@@ -35,6 +35,7 @@
#include "GHOST_Types.h"
#include "GPU_immediate.hh"
#include "GPU_state.hh"
#include "MEM_guardedalloc.h"