Skip to content

Commit

Permalink
Press Escape to quit
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoHatt committed Sep 10, 2024
1 parent f1a2a59 commit c32dfe9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ void reset_inputs() {
K->scroll_y_diff = 0;
K->double_click = 0;
}

void post_quit() {
PostQuitMessage(0);
Running = false;
}

static void set_framebuffer_size(Graphics *ctx, iv2 size, bool set_dpi = false);

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
Expand All @@ -27,7 +33,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_QUIT:
case WM_DESTROY:
{
PostQuitMessage(0); Running = false; break;
post_quit(); break;
}
case WM_SIZE:
{
Expand Down
9 changes: 8 additions & 1 deletion src/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3300,6 +3300,10 @@ static void update_gui() {
UI_text(theme->text_header_2, G->ui_font, 12,"F11 key: ");
UI_text(theme->text_reg_main, G->ui_font, 12,"Toggle fullscreen mode.");
}
UI_push_parent_defer(ctx, UI_bar(axis_x)) {
UI_text(theme->text_header_2, G->ui_font, 12,"Esc key: ");
UI_text(theme->text_reg_main, G->ui_font, 12,"Exit fullscreen mode. Otherwise, quit.");
}
UI_push_parent_defer(ctx, UI_bar(axis_x)) {
UI_text(theme->text_header_2, G->ui_font, 12,"R key: ");
UI_text(theme->text_reg_main, G->ui_font, 12,"Reload current folder, and scan for new files in it.");
Expand Down Expand Up @@ -3478,6 +3482,7 @@ static void shuffle_folder() {

static void update_logic() {
bool WantCaptureMouse = G->ui_want_capture_mouse;
bool fullscreen = is_fullscreen(hwnd);

if (G->alert.timer > 0)
G->alert.timer++;
Expand All @@ -3486,8 +3491,10 @@ static void update_logic() {

if (keyup(Key_F11))
toggle_fullscreen(hwnd);
if (keyup(Key_Esc) && is_fullscreen(hwnd))
if (keyup(Key_Esc) && fullscreen)
exit_fullscreen(hwnd);
if (keyup(Key_Esc) && !fullscreen)
post_quit();

if (keyup(Key_F)) {
//send_signal(G->signals.update_filtering);
Expand Down

0 comments on commit c32dfe9

Please sign in to comment.