Cleanup code

This commit is contained in:
Oskari Alaranta 2026-02-11 17:35:22 +02:00
parent b48f099aa2
commit 93a101b235
3 changed files with 119 additions and 124 deletions

View File

@ -128,8 +128,6 @@ namespace LibInput
strncpy(null_path, path.data(), path.size()); strncpy(null_path, path.data(), path.size());
null_path[path.size()] = '\0'; null_path[path.size()] = '\0';
printf("opening '%s'\n", null_path);
struct stat st; struct stat st;
if (stat(null_path, &st) == -1) if (stat(null_path, &st) == -1)
return BAN::Error::from_errno(errno); return BAN::Error::from_errno(errno);

View File

@ -1375,14 +1375,16 @@ void WindowServer::remove_client_fd(int fd)
for (size_t i = 0; i < m_client_windows.size(); i++) for (size_t i = 0; i < m_client_windows.size(); i++)
{ {
auto window = m_client_windows[i]; auto window = m_client_windows[i];
if (window->client_fd() == fd) if (window->client_fd() != fd)
{ continue;
auto window_area = window->full_area(); auto window_area = window->full_area();
m_client_windows.remove(i); m_client_windows.remove(i);
invalidate(window_area); invalidate(window_area);
if (window == m_focused_window) if (window != m_focused_window)
{ break;
m_focused_window = nullptr; m_focused_window = nullptr;
for (size_t j = m_client_windows.size(); j > 0; j--) for (size_t j = m_client_windows.size(); j > 0; j--)
{ {
@ -1392,11 +1394,9 @@ void WindowServer::remove_client_fd(int fd)
set_focused_window(client_window); set_focused_window(client_window);
break; break;
} }
}
break; break;
} }
}
} }
WindowServer::ClientData& WindowServer::get_client_data(int fd) WindowServer::ClientData& WindowServer::get_client_data(int fd)

View File

@ -8,12 +8,6 @@
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibInput/KeyboardLayout.h> #include <LibInput/KeyboardLayout.h>
#include <SDL2/SDL_keycode.h>
#include <SDL2/SDL_mouse.h>
#include <SDL2/SDL_video.h>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <signal.h> #include <signal.h>
@ -33,8 +27,6 @@ extern SDL_Surface* g_surface;
extern SDL_Texture* g_texture; extern SDL_Texture* g_texture;
extern SDL_Window* g_window; extern SDL_Window* g_window;
struct Keymap struct Keymap
{ {
consteval Keymap() consteval Keymap()
@ -60,6 +52,7 @@ struct Keymap
map[SDL_SCANCODE_MINUS] = keycode_normal(0, 11); map[SDL_SCANCODE_MINUS] = keycode_normal(0, 11);
map[SDL_SCANCODE_EQUALS] = keycode_normal(0, 12); map[SDL_SCANCODE_EQUALS] = keycode_normal(0, 12);
map[SDL_SCANCODE_BACKSPACE] = keycode_normal(0, 13); map[SDL_SCANCODE_BACKSPACE] = keycode_normal(0, 13);
map[SDL_SCANCODE_TAB] = keycode_normal(1, 0); map[SDL_SCANCODE_TAB] = keycode_normal(1, 0);
map[SDL_SCANCODE_Q] = keycode_normal(1, 1); map[SDL_SCANCODE_Q] = keycode_normal(1, 1);
map[SDL_SCANCODE_W] = keycode_normal(1, 2); map[SDL_SCANCODE_W] = keycode_normal(1, 2);
@ -73,6 +66,7 @@ struct Keymap
map[SDL_SCANCODE_P] = keycode_normal(1, 10); map[SDL_SCANCODE_P] = keycode_normal(1, 10);
map[SDL_SCANCODE_LEFTBRACKET] = keycode_normal(1, 11); map[SDL_SCANCODE_LEFTBRACKET] = keycode_normal(1, 11);
map[SDL_SCANCODE_RIGHTBRACKET] = keycode_normal(1, 12); map[SDL_SCANCODE_RIGHTBRACKET] = keycode_normal(1, 12);
map[SDL_SCANCODE_CAPSLOCK] = keycode_normal(2, 0); map[SDL_SCANCODE_CAPSLOCK] = keycode_normal(2, 0);
map[SDL_SCANCODE_A] = keycode_normal(2, 1); map[SDL_SCANCODE_A] = keycode_normal(2, 1);
map[SDL_SCANCODE_S] = keycode_normal(2, 2); map[SDL_SCANCODE_S] = keycode_normal(2, 2);
@ -87,6 +81,7 @@ struct Keymap
map[SDL_SCANCODE_APOSTROPHE] = keycode_normal(2, 11); map[SDL_SCANCODE_APOSTROPHE] = keycode_normal(2, 11);
map[SDL_SCANCODE_BACKSLASH] = keycode_normal(2, 12); map[SDL_SCANCODE_BACKSLASH] = keycode_normal(2, 12);
map[SDL_SCANCODE_RETURN] = keycode_normal(2, 13); map[SDL_SCANCODE_RETURN] = keycode_normal(2, 13);
map[SDL_SCANCODE_LSHIFT] = keycode_normal(3, 0); map[SDL_SCANCODE_LSHIFT] = keycode_normal(3, 0);
map[SDL_SCANCODE_NONUSBACKSLASH] = keycode_normal(3, 1); map[SDL_SCANCODE_NONUSBACKSLASH] = keycode_normal(3, 1);
map[SDL_SCANCODE_Z] = keycode_normal(3, 2); map[SDL_SCANCODE_Z] = keycode_normal(3, 2);
@ -100,12 +95,13 @@ struct Keymap
map[SDL_SCANCODE_PERIOD] = keycode_normal(3, 10); map[SDL_SCANCODE_PERIOD] = keycode_normal(3, 10);
map[SDL_SCANCODE_SLASH] = keycode_normal(3, 11); map[SDL_SCANCODE_SLASH] = keycode_normal(3, 11);
map[SDL_SCANCODE_RSHIFT] = keycode_normal(3, 12); map[SDL_SCANCODE_RSHIFT] = keycode_normal(3, 12);
map[SDL_SCANCODE_LCTRL] = keycode_normal(4, 0); map[SDL_SCANCODE_LCTRL] = keycode_normal(4, 0);
map[SDL_SCANCODE_LGUI] = keycode_normal(4, 1); map[SDL_SCANCODE_LGUI] = keycode_normal(4, 1);
map[SDL_SCANCODE_LALT] = keycode_normal(4, 2); map[SDL_SCANCODE_LALT] = keycode_normal(4, 2);
map[SDL_SCANCODE_SPACE] = keycode_normal(4, 3); map[SDL_SCANCODE_SPACE] = keycode_normal(4, 3);
map[SDL_SCANCODE_RALT] = keycode_normal(4, 5); map[SDL_SCANCODE_RALT] = keycode_normal(4, 4);
map[SDL_SCANCODE_RCTRL] = keycode_normal(4, 6); map[SDL_SCANCODE_RCTRL] = keycode_normal(4, 5);
map[SDL_SCANCODE_UP] = keycode_normal(5, 0); map[SDL_SCANCODE_UP] = keycode_normal(5, 0);
map[SDL_SCANCODE_LEFT] = keycode_normal(5, 1); map[SDL_SCANCODE_LEFT] = keycode_normal(5, 1);
@ -326,6 +322,7 @@ int main()
SIGTSTP, SIGTSTP,
SIGTTIN, SIGTTIN,
SIGTTOU, SIGTTOU,
SIGWINCH,
}; };
constexpr int ignored_signals[] { constexpr int ignored_signals[] {
SIGPIPE, SIGPIPE,