Skip to content

Commit e3652f1

Browse files
committed
[no-exceptions] Revise rtcw_window_rounded_corner_mgr
1 parent 9eef830 commit e3652f1

2 files changed

Lines changed: 29 additions & 30 deletions

File tree

src/rtcw/system/rtcw_window_rounded_corner_mgr.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/*
22
RTCW: Unofficial source port of Return to Castle Wolfenstein and Wolfenstein: Enemy Territory
3-
Copyright (c) 2012-2025 Boris I. Bendovsky (bibendovsky@hotmail.com) and Contributors
3+
Copyright (c) 2025-2026 Boris I. Bendovsky (bibendovsky@hotmail.com) and Contributors
44
SPDX-License-Identifier: GPL-3.0
55
*/
66

77
#include "rtcw_window_rounded_corner_mgr.h"
88
#ifdef _WIN32
9-
#include <stddef.h>
10-
#include <string.h>
9+
#include "rtcw_memory.h"
10+
#include "rtcw_unique_ptr.h"
11+
#include <cstddef>
1112
#include <windows.h>
1213
#include "SDL_syswm.h"
13-
#include "rtcw_unique_ptr.h"
14+
1415
#endif // _WIN32
1516

1617
namespace rtcw {
@@ -29,22 +30,24 @@ class WindowRoundedCornerMgr::Impl
2930
static const DWORD WIN32_DWMWCP_DONOTROUND = 1;
3031
static const DWORD WIN32_DWMWA_WINDOW_CORNER_PREFERENCE = 33;
3132

32-
private:
33-
typedef UniquePtr<WindowRoundedCornerMgr::Impl, UniquePtrDefaultDeleter<WindowRoundedCornerMgr::Impl> > Instance;
33+
struct Deleter
34+
{
35+
void operator()(Impl* impl) const;
36+
};
37+
38+
typedef UniquePtr<WindowRoundedCornerMgr::Impl, Deleter> Instance;
3439

3540
typedef HRESULT (WINAPI * PFNDWMSETWINDOWATTRIBUTEPROC)(
3641
HWND hwnd,
3742
DWORD dwAttribute,
3843
LPCVOID pvAttribute,
3944
DWORD cbAttribute);
4045

41-
private:
4246
static Instance instance_;
4347

4448
HMODULE dwmapi_module_;
4549
PFNDWMSETWINDOWATTRIBUTEPROC dwm_set_window_attribute_;
4650

47-
private:
4851
Impl(const Impl&);
4952
Impl& operator=(const Impl&);
5053

@@ -53,11 +56,18 @@ class WindowRoundedCornerMgr::Impl
5356
void disable(HWND win32_window) const;
5457
};
5558

56-
// --------------------------------------------------------------------------
59+
// -------------------------------------
60+
61+
void WindowRoundedCornerMgr::Impl::Deleter::operator()(Impl* impl) const
62+
{
63+
mem::delete_object(impl);
64+
}
65+
66+
// -------------------------------------
5767

5868
WindowRoundedCornerMgr::Impl::Instance WindowRoundedCornerMgr::Impl::instance_;
5969

60-
// --------------------------------------------------------------------------
70+
// -------------------------------------
6171

6272
WindowRoundedCornerMgr::Impl::Impl()
6373
{
@@ -74,54 +84,45 @@ WindowRoundedCornerMgr::Impl::~Impl()
7484

7585
void WindowRoundedCornerMgr::Impl::disable(SDL_Window* sdl_window)
7686
{
77-
SDL_SysWMinfo sdl_sys_wm_info;
78-
memset(&sdl_sys_wm_info, 0, sizeof(SDL_SysWMinfo));
87+
SDL_SysWMinfo sdl_sys_wm_info = SDL_SysWMinfo();
7988
SDL_VERSION(&sdl_sys_wm_info.version);
80-
8189
if (SDL_GetWindowWMInfo(sdl_window, &sdl_sys_wm_info) != SDL_TRUE ||
8290
sdl_sys_wm_info.info.win.window == NULL)
8391
{
8492
return;
8593
}
86-
8794
if (instance_.get() == NULL)
8895
{
89-
instance_.reset(new Impl());
96+
instance_.reset(mem::new_object<Impl>());
9097
}
91-
9298
instance_->disable(sdl_sys_wm_info.info.win.window);
9399
}
94100

95101
bool WindowRoundedCornerMgr::Impl::initialize()
96102
{
97-
dwmapi_module_ = LoadLibraryW(L"dwmapi.dll");
98-
99-
if (dwmapi_module_ == NULL)
100-
{
101-
return false;
102-
}
103-
104103
union Cast
105104
{
106105
FARPROC from;
107106
PFNDWMSETWINDOWATTRIBUTEPROC to;
108107
};
109108

109+
dwmapi_module_ = LoadLibraryW(L"dwmapi.dll");
110+
if (dwmapi_module_ == NULL)
111+
{
112+
return false;
113+
}
110114
const Cast cast = {GetProcAddress(dwmapi_module_, "DwmSetWindowAttribute")};
111115
dwm_set_window_attribute_ = cast.to;
112-
113116
if (dwm_set_window_attribute_ == NULL)
114117
{
115118
return false;
116119
}
117-
118120
return true;
119121
}
120122

121123
void WindowRoundedCornerMgr::Impl::terminate()
122124
{
123125
dwm_set_window_attribute_ = NULL;
124-
125126
if (dwmapi_module_ != NULL)
126127
{
127128
FreeLibrary(dwmapi_module_);
@@ -135,9 +136,7 @@ void WindowRoundedCornerMgr::Impl::disable(HWND win32_window) const
135136
{
136137
return;
137138
}
138-
139139
const DWORD win32_rounded_corner_type = WIN32_DWMWCP_DONOTROUND;
140-
141140
dwm_set_window_attribute_(
142141
win32_window,
143142
WIN32_DWMWA_WINDOW_CORNER_PREFERENCE,
@@ -147,7 +146,7 @@ void WindowRoundedCornerMgr::Impl::disable(HWND win32_window) const
147146

148147
#endif // _WIN32
149148

150-
// ==========================================================================
149+
// =====================================
151150

152151
#ifdef _WIN32
153152

src/rtcw/system/rtcw_window_rounded_corner_mgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
RTCW: Unofficial source port of Return to Castle Wolfenstein and Wolfenstein: Enemy Territory
3-
Copyright (c) 2012-2025 Boris I. Bendovsky (bibendovsky@hotmail.com) and Contributors
3+
Copyright (c) 2025-2026 Boris I. Bendovsky (bibendovsky@hotmail.com) and Contributors
44
SPDX-License-Identifier: GPL-3.0
55
*/
66

0 commit comments

Comments
 (0)