aboutsummaryrefslogtreecommitdiff
path: root/src/platform/gui
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-12-06 17:09:46 +0800
committerYuqian Yang <crupest@crupest.life>2025-12-06 17:09:46 +0800
commit9a87e5cf786f3e8fddc933136d210edd4ef72c89 (patch)
treee5934f57b074cc5717e636455566ce6134caca64 /src/platform/gui
parent2ba85046b80d2763ed41f4aad44f1ae2f11c3a86 (diff)
downloadcru-9a87e5cf786f3e8fddc933136d210edd4ef72c89.tar.gz
cru-9a87e5cf786f3e8fddc933136d210edd4ef72c89.tar.bz2
cru-9a87e5cf786f3e8fddc933136d210edd4ef72c89.zip
Handle more SDL events.
Diffstat (limited to 'src/platform/gui')
-rw-r--r--src/platform/gui/sdl/UiApplication.cpp4
-rw-r--r--src/platform/gui/sdl/Window.cpp15
2 files changed, 17 insertions, 2 deletions
diff --git a/src/platform/gui/sdl/UiApplication.cpp b/src/platform/gui/sdl/UiApplication.cpp
index 6064159d..edf1e20c 100644
--- a/src/platform/gui/sdl/UiApplication.cpp
+++ b/src/platform/gui/sdl/UiApplication.cpp
@@ -65,6 +65,10 @@ int SdlUiApplication::Run() {
break;
}
+ // char buf[512];
+ // SDL_GetEventDescription(&event, buf, sizeof(buf) / sizeof(*buf));
+ // CruLogDebug(kLogTag, "{}", buf);
+
DispatchEvent(event);
delete_later_pool_.Clean();
diff --git a/src/platform/gui/sdl/Window.cpp b/src/platform/gui/sdl/Window.cpp
index d06f8abc..e5de9310 100644
--- a/src/platform/gui/sdl/Window.cpp
+++ b/src/platform/gui/sdl/Window.cpp
@@ -322,13 +322,15 @@ NativeKeyEventArgs ConvertKeyEvent(const SDL_KeyboardEvent& event) {
std::optional<SDL_WindowID> GetEventWindowId(const SDL_Event& event) {
switch (event.type) {
- case SDL_EVENT_WINDOW_MOVED:
- case SDL_EVENT_WINDOW_RESIZED:
case SDL_EVENT_WINDOW_SHOWN:
case SDL_EVENT_WINDOW_HIDDEN:
+ case SDL_EVENT_WINDOW_EXPOSED:
+ case SDL_EVENT_WINDOW_MOVED:
+ case SDL_EVENT_WINDOW_RESIZED:
case SDL_EVENT_WINDOW_MINIMIZED:
case SDL_EVENT_WINDOW_FOCUS_GAINED:
case SDL_EVENT_WINDOW_FOCUS_LOST:
+ case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_WINDOW_MOUSE_ENTER:
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
case SDL_EVENT_WINDOW_DESTROYED:
@@ -358,9 +360,14 @@ bool SdlWindow::HandleEvent(const SDL_Event* event) {
client_rect_.top = event->window.data2;
return true;
}
+ case SDL_EVENT_WINDOW_EXPOSED: {
+ RequestRepaint();
+ return true;
+ }
case SDL_EVENT_WINDOW_RESIZED: {
client_rect_.width = event->window.data1;
client_rect_.height = event->window.data2;
+ RequestRepaint();
#ifdef __unix
int width, height;
CheckSdlReturn(SDL_GetWindowSizeInPixels(sdl_window_, &width, &height));
@@ -389,6 +396,10 @@ bool SdlWindow::HandleEvent(const SDL_Event* event) {
FocusEvent_.Raise(FocusChangeType::Lose);
return true;
}
+ case SDL_EVENT_WINDOW_CLOSE_REQUESTED: {
+ Close();
+ return true;
+ }
case SDL_EVENT_WINDOW_MOUSE_ENTER: {
MouseEnterLeaveEvent_.Raise(MouseEnterLeaveType::Enter);
return true;