🚚 Improved project structure

This commit is contained in:
Paul Breugnot 2024-12-15 15:09:18 +01:00
parent 6b9513987a
commit 3096ba0637
15 changed files with 55 additions and 37 deletions

View File

@ -7,11 +7,11 @@ find_package(X11 REQUIRED)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address")
add_executable(aswm
src/main.c
src/create.c
src/configure.c
src/reparent.c
src/destroy.c
src/map.c)
src/aswm/main.c
src/aswm/event_handlers/create.c
src/aswm/event_handlers/configure.c
src/aswm/event_handlers/reparent.c
src/aswm/event_handlers/destroy.c
src/aswm/event_handlers/map.c)
target_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} include)
target_link_libraries(aswm ${X11_LIBRARIES})

View File

@ -1,32 +1,19 @@
#include "configure.h"
#include "aswm/event_handlers/configure.h"
#include <stdio.h>
#include <X11/Xutil.h>
void OnConfigureRequest(const XConfigureRequestEvent* e) {
XWindowChanges changes;
printf("XConfigureRequestEvent %lu\n", e->window);
printf("\tx = %i\n", e->x);
printf("\ty = %i\n", e->y);
printf("\tw = %i\n", e->width);
printf("\th = %i\n", e->height);
{
XTextProperty text_property;
XGetWMName(e->display, e->window, &text_property);
printf("\tname: %s\n", text_property.value);
}
{
XClassHint class;
XGetClassHint(e->display, e->window, &class);
printf("\tclass: %s, %s\n", class.res_class, class.res_name);
}
int screen_number = XDefaultScreen(e->display);
int full_width = XDisplayWidth(e->display, screen_number);
int full_height = XDisplayWidth(e->display, screen_number);
// Copy fields from e to changes.
XWindowChanges changes;
changes.x = 0;
changes.y = 0;
changes.width = full_width;

View File

@ -1,4 +1,4 @@
#include "create.h"
#include "aswm/event_handlers/create.h"
#include <stdio.h>
void OnCreateNotify(const XCreateWindowEvent* e) {

View File

@ -1,4 +1,4 @@
#include "destroy.h"
#include "aswm/event_handlers/destroy.h"
#include <stdio.h>
void OnDestroyNotify(const XDestroyWindowEvent* e) {

View File

@ -0,0 +1,38 @@
#include "aswm/event_handlers/map.h"
#include <stdio.h>
#include <X11/Xutil.h>
void OnMapRequest(Window root, const XMapRequestEvent* e) {
printf("XMapRequestEvent %lu\n", e->window);
{
XTextProperty text_property;
XGetWMName(e->display, e->window, &text_property);
printf("\tname: %s\n", text_property.value);
}
{
XClassHint class;
XGetClassHint(e->display, e->window, &class);
printf("\tclass: %s, %s\n", class.res_class, class.res_name);
}
int screen_number = XDefaultScreen(e->display);
int full_width = XDisplayWidth(e->display, screen_number);
int full_height = XDisplayWidth(e->display, screen_number);
// Automatically reconfigure position and size of the window
XWindowChanges changes;
changes.x = 0;
changes.y = 0;
changes.width = full_width;
changes.height = full_height;
printf("\tx = %i\n", changes.x);
printf("\ty = %i\n", changes.y);
printf("\tw = %i\n", changes.width);
printf("\th = %i\n", changes.height);
XConfigureWindow(e->display, e->window, CWX | CWY | CWWidth | CWHeight, &changes);
XMapWindow(e->display, e->window);
}

View File

@ -1,4 +1,4 @@
#include "reparent.h"
#include "aswm/event_handlers/reparent.h"
#include <stdio.h>
void OnReparentNotify(const XReparentEvent* e) {

View File

@ -1,4 +1,4 @@
#include "unmap.h"
#include "aswm/event_handlers/unmap.h"
#include <stdio.h>
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {

View File

@ -1,9 +1,9 @@
#include <X11/Xlib.h>
#include "create.h"
#include "configure.h"
#include "map.h"
#include "reparent.h"
#include "destroy.h"
#include "aswm/event_handlers/create.h"
#include "aswm/event_handlers/configure.h"
#include "aswm/event_handlers/map.h"
#include "aswm/event_handlers/reparent.h"
#include "aswm/event_handlers/destroy.h"
Display *display;
Window root;

View File

@ -1,7 +0,0 @@
#include "map.h"
#include <stdio.h>
void OnMapRequest(Window root, const XMapRequestEvent* e) {
printf("XMapRequestEvent %lu\n", e->window);
XMapWindow(e->display, e->window);
}