From 4078e1d17c0fb1439ee5a0ba1e539f06a8f47aab Mon Sep 17 00:00:00 2001 From: Kamikadze <40305144+Kam1k4dze@users.noreply.github.com> Date: Sat, 31 May 2025 18:02:02 +0500 Subject: [PATCH] refactor: replace all `typedef` with `using` (#10594) --- src/SharedDefs.hpp | 8 ++++---- src/desktop/DesktopTypes.hpp | 16 ++++++++-------- src/helpers/Format.hpp | 6 +++--- src/layout/IHyprLayout.cpp | 2 +- src/managers/HookSystemManager.hpp | 4 ++-- src/managers/XWaylandManager.hpp | 2 +- src/plugins/PluginAPI.hpp | 10 +++++----- src/protocols/types/ColorManagement.hpp | 2 +- src/xwayland/XSurface.hpp | 12 ++++++------ 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/SharedDefs.hpp b/src/SharedDefs.hpp index a46a2429b..b80949974 100644 --- a/src/SharedDefs.hpp +++ b/src/SharedDefs.hpp @@ -58,8 +58,8 @@ struct SDispatchResult { std::string error; }; -typedef int64_t WINDOWID; -typedef int64_t MONITORID; -typedef int64_t WORKSPACEID; +using WINDOWID = int64_t; +using MONITORID = int64_t; +using WORKSPACEID = int64_t; -typedef std::function HOOK_CALLBACK_FN; +using HOOK_CALLBACK_FN = std::function; diff --git a/src/desktop/DesktopTypes.hpp b/src/desktop/DesktopTypes.hpp index 080f13d37..f724c7b96 100644 --- a/src/desktop/DesktopTypes.hpp +++ b/src/desktop/DesktopTypes.hpp @@ -6,21 +6,21 @@ class CLayerSurface; class CMonitor; /* Shared pointer to a workspace */ -typedef SP PHLWORKSPACE; +using PHLWORKSPACE = SP; /* Weak pointer to a workspace */ -typedef WP PHLWORKSPACEREF; +using PHLWORKSPACEREF = WP; /* Shared pointer to a window */ -typedef SP PHLWINDOW; +using PHLWINDOW = SP; /* Weak pointer to a window */ -typedef WP PHLWINDOWREF; +using PHLWINDOWREF = WP; /* Shared pointer to a layer surface */ -typedef SP PHLLS; +using PHLLS = SP; /* Weak pointer to a layer surface */ -typedef WP PHLLSREF; +using PHLLSREF = WP; /* Shared pointer to a monitor */ -typedef SP PHLMONITOR; +using PHLMONITOR = SP; /* Weak pointer to a monitor */ -typedef WP PHLMONITORREF; +using PHLMONITORREF = WP; diff --git a/src/helpers/Format.hpp b/src/helpers/Format.hpp index b1353dc7e..fe68f763b 100644 --- a/src/helpers/Format.hpp +++ b/src/helpers/Format.hpp @@ -5,8 +5,8 @@ #include "math/Math.hpp" #include -typedef uint32_t DRMFormat; -typedef uint32_t SHMFormat; +using DRMFormat = uint32_t; +using SHMFormat = uint32_t; struct SPixelFormat { DRMFormat drmFormat = 0; /* DRM_FORMAT_INVALID */ @@ -20,7 +20,7 @@ struct SPixelFormat { Vector2D blockSize; }; -typedef Aquamarine::SDRMFormat SDRMFormat; +using SDRMFormat = Aquamarine::SDRMFormat; namespace NFormatUtils { SHMFormat drmToShm(DRMFormat drm); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 1fe3a936f..fbde7344e 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -411,7 +411,7 @@ static void snapResize(double& start, double& end, const double P) { start = P; } -typedef std::function SnapFn; +using SnapFn = std::function; static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRAGGINGWINDOW, const eMouseBindMode MODE, const int CORNER, const Vector2D& BEGINSIZE) { static auto SNAPWINDOWGAP = CConfigValue("general:snap:window_gap"); diff --git a/src/managers/HookSystemManager.hpp b/src/managers/HookSystemManager.hpp index 69d54a607..647e96703 100644 --- a/src/managers/HookSystemManager.hpp +++ b/src/managers/HookSystemManager.hpp @@ -11,9 +11,9 @@ #define HANDLE void* -// global typedef for hooked functions. Passes itself as a ptr when called, and `data` additionally. +// global type alias for hooked functions. Passes itself as a ptr when called, and `data` additionally. -typedef std::function HOOK_CALLBACK_FN; +using HOOK_CALLBACK_FN = std::function; struct SCallbackFNPtr { WP fn; diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp index e4f1e17ae..59eee4c58 100644 --- a/src/managers/XWaylandManager.hpp +++ b/src/managers/XWaylandManager.hpp @@ -4,7 +4,7 @@ #include class CWindow; // because clangd -typedef SP PHLWINDOW; +using PHLWINDOW = SP; class CWLSurfaceResource; class CHyprXWaylandManager { diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp index 0f3332947..00a1e8b26 100644 --- a/src/plugins/PluginAPI.hpp +++ b/src/plugins/PluginAPI.hpp @@ -31,12 +31,12 @@ Feel like the API is missing something you'd like to use in your plugin? Open an #include #include -typedef struct { +using PLUGIN_DESCRIPTION_INFO = struct { std::string name; std::string description; std::string author; std::string version; -} PLUGIN_DESCRIPTION_INFO; +}; struct SFunctionMatch { void* address = nullptr; @@ -83,7 +83,7 @@ class CWindow; This function should not be modified, see the example plugin. */ -typedef REQUIRED std::string (*PPLUGIN_API_VERSION_FUNC)(); +using PPLUGIN_API_VERSION_FUNC = REQUIRED std::string (*)(); #define PLUGIN_API_VERSION pluginAPIVersion #define PLUGIN_API_VERSION_FUNC_STR "pluginAPIVersion" @@ -93,7 +93,7 @@ typedef REQUIRED std::string (*PPLUGIN_API_VERSION_FUNC)(); Keep in mind this is executed synchronously, and as such any blocking calls to hyprland might hang. (e.g. system("hyprctl ...")) */ -typedef REQUIRED PLUGIN_DESCRIPTION_INFO (*PPLUGIN_INIT_FUNC)(HANDLE); +using PPLUGIN_INIT_FUNC = REQUIRED PLUGIN_DESCRIPTION_INFO (*)(HANDLE); #define PLUGIN_INIT pluginInit #define PLUGIN_INIT_FUNC_STR "pluginInit" @@ -103,7 +103,7 @@ typedef REQUIRED PLUGIN_DESCRIPTION_INFO (*PPLUGIN_INIT_FUNC)(HANDLE); Hooks are unloaded after exit. */ -typedef OPTIONAL void (*PPLUGIN_EXIT_FUNC)(); +using PPLUGIN_EXIT_FUNC = OPTIONAL void (*)(); #define PLUGIN_EXIT pluginExit #define PLUGIN_EXIT_FUNC_STR "pluginExit" diff --git a/src/protocols/types/ColorManagement.hpp b/src/protocols/types/ColorManagement.hpp index 48d8dd31b..2dd1c075d 100644 --- a/src/protocols/types/ColorManagement.hpp +++ b/src/protocols/types/ColorManagement.hpp @@ -54,7 +54,7 @@ namespace NColorManagement { return (eTransferFunction)tf; } - typedef Hyprgraphics::SPCPRimaries SPCPRimaries; + using SPCPRimaries = Hyprgraphics::SPCPRimaries; namespace NColorPrimaries { static const auto DEFAULT_PRIMARIES = SPCPRimaries{}; diff --git a/src/xwayland/XSurface.hpp b/src/xwayland/XSurface.hpp index dc43acbbe..ec71aad30 100644 --- a/src/xwayland/XSurface.hpp +++ b/src/xwayland/XSurface.hpp @@ -9,9 +9,9 @@ class CWLSurfaceResource; class CXWaylandSurfaceResource; #ifdef NO_XWAYLAND -typedef uint32_t xcb_pixmap_t; -typedef uint32_t xcb_window_t; -typedef struct { +using xcb_pixmap_t = uint32_t; +using xcb_window_t = uint32_t; +using xcb_icccm_wm_hints_t = struct { int32_t flags; uint32_t input; int32_t initial_state; @@ -20,8 +20,8 @@ typedef struct { int32_t icon_x, icon_y; xcb_pixmap_t icon_mask; xcb_window_t window_group; -} xcb_icccm_wm_hints_t; -typedef struct { +}; +using xcb_size_hints_t = struct { uint32_t flags; int32_t x, y; int32_t width, height; @@ -32,7 +32,7 @@ typedef struct { int32_t max_aspect_num, max_aspect_den; int32_t base_width, base_height; uint32_t win_gravity; -} xcb_size_hints_t; +}; #else #include #endif