@@ -37,6 +37,7 @@ PadViewFrame::PadViewFrame(wxFrame* parent)
37
37
Maximize ();
38
38
39
39
Bind (wxEVT_SIZE, &PadViewFrame::OnSizeEvent, this );
40
+ Bind (wxEVT_DPI_CHANGED, &PadViewFrame::OnDPIChangedEvent, this );
40
41
Bind (wxEVT_MOVE, &PadViewFrame::OnMoveEvent, this );
41
42
Bind (wxEVT_MOTION, &PadViewFrame::OnMouseMove, this );
42
43
@@ -55,6 +56,8 @@ bool PadViewFrame::Initialize()
55
56
const wxSize client_size = GetClientSize ();
56
57
g_window_info.pad_width = client_size.GetWidth ();
57
58
g_window_info.pad_height = client_size.GetHeight ();
59
+ g_window_info.phys_pad_width = ToPhys (client_size.GetWidth ());
60
+ g_window_info.phys_pad_height = ToPhys (client_size.GetHeight ());
58
61
59
62
return true ;
60
63
}
@@ -98,10 +101,22 @@ void PadViewFrame::OnSizeEvent(wxSizeEvent& event)
98
101
const wxSize client_size = GetClientSize ();
99
102
g_window_info.pad_width = client_size.GetWidth ();
100
103
g_window_info.pad_height = client_size.GetHeight ();
104
+ g_window_info.phys_pad_width = ToPhys (client_size.GetWidth ());
105
+ g_window_info.phys_pad_height = ToPhys (client_size.GetHeight ());
101
106
102
107
event.Skip ();
103
108
}
104
109
110
+ void PadViewFrame::OnDPIChangedEvent (wxDPIChangedEvent& event)
111
+ {
112
+ event.Skip ();
113
+ const wxSize client_size = GetClientSize ();
114
+ g_window_info.pad_width = client_size.GetWidth ();
115
+ g_window_info.pad_height = client_size.GetHeight ();
116
+ g_window_info.phys_pad_width = ToPhys (client_size.GetWidth ());
117
+ g_window_info.phys_pad_height = ToPhys (client_size.GetHeight ());
118
+ }
119
+
105
120
void PadViewFrame::OnMoveEvent (wxMoveEvent& event)
106
121
{
107
122
if (!IsMaximized () && !IsFullScreen ())
@@ -130,7 +145,8 @@ void PadViewFrame::OnGesturePan(wxPanGestureEvent& event)
130
145
auto & instance = InputManager::instance ();
131
146
132
147
std::scoped_lock lock (instance.m_pad_touch .m_mutex );
133
- instance.m_pad_touch .position = { event.GetPosition ().x , event.GetPosition ().y };
148
+ auto physPos = ToPhys (event.GetPosition ());
149
+ instance.m_pad_touch .position = { physPos.x , physPos.y };
134
150
instance.m_pad_touch .left_down = event.IsGestureStart () || !event.IsGestureEnd ();
135
151
if (event.IsGestureStart () || !event.IsGestureEnd ())
136
152
instance.m_pad_touch .left_down_toggle = true ;
@@ -149,7 +165,8 @@ void PadViewFrame::OnMouseMove(wxMouseEvent& event)
149
165
auto & instance = InputManager::instance ();
150
166
151
167
std::scoped_lock lock (instance.m_pad_touch .m_mutex );
152
- instance.m_pad_mouse .position = { event.GetPosition ().x , event.GetPosition ().y };
168
+ auto physPos = ToPhys (event.GetPosition ());
169
+ instance.m_pad_mouse .position = { physPos.x , physPos.y };
153
170
154
171
event.Skip ();
155
172
}
@@ -160,7 +177,8 @@ void PadViewFrame::OnMouseLeft(wxMouseEvent& event)
160
177
161
178
std::scoped_lock lock (instance.m_pad_mouse .m_mutex );
162
179
instance.m_pad_mouse .left_down = event.ButtonDown (wxMOUSE_BTN_LEFT);
163
- instance.m_pad_mouse .position = { event.GetPosition ().x , event.GetPosition ().y };
180
+ auto physPos = ToPhys (event.GetPosition ());
181
+ instance.m_pad_mouse .position = { physPos.x , physPos.y };
164
182
if (event.ButtonDown (wxMOUSE_BTN_LEFT))
165
183
instance.m_pad_mouse .left_down_toggle = true ;
166
184
@@ -172,7 +190,8 @@ void PadViewFrame::OnMouseRight(wxMouseEvent& event)
172
190
173
191
std::scoped_lock lock (instance.m_pad_mouse .m_mutex );
174
192
instance.m_pad_mouse .right_down = event.ButtonDown (wxMOUSE_BTN_LEFT);
175
- instance.m_pad_mouse .position = { event.GetPosition ().x , event.GetPosition ().y };
193
+ auto physPos = ToPhys (event.GetPosition ());
194
+ instance.m_pad_mouse .position = { physPos.x , physPos.y };
176
195
if (event.ButtonDown (wxMOUSE_BTN_RIGHT))
177
196
instance.m_pad_mouse .right_down_toggle = true ;
178
197
}
@@ -187,4 +206,4 @@ void PadViewFrame::AsyncSetTitle(std::string_view windowTitle)
187
206
wxCommandEvent set_title_event (wxEVT_SET_WINDOW_TITLE);
188
207
set_title_event.SetString (wxHelper::FromUtf8 (windowTitle));
189
208
QueueEvent (set_title_event.Clone ());
190
- }
209
+ }
0 commit comments