🚚 Improved project structure
This commit is contained in:
parent
6b9513987a
commit
3096ba0637
15 changed files with 55 additions and 37 deletions
|
@ -7,11 +7,11 @@ find_package(X11 REQUIRED)
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address")
|
||||||
|
|
||||||
add_executable(aswm
|
add_executable(aswm
|
||||||
src/main.c
|
src/aswm/main.c
|
||||||
src/create.c
|
src/aswm/event_handlers/create.c
|
||||||
src/configure.c
|
src/aswm/event_handlers/configure.c
|
||||||
src/reparent.c
|
src/aswm/event_handlers/reparent.c
|
||||||
src/destroy.c
|
src/aswm/event_handlers/destroy.c
|
||||||
src/map.c)
|
src/aswm/event_handlers/map.c)
|
||||||
target_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} include)
|
target_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} include)
|
||||||
target_link_libraries(aswm ${X11_LIBRARIES})
|
target_link_libraries(aswm ${X11_LIBRARIES})
|
||||||
|
|
|
@ -1,32 +1,19 @@
|
||||||
#include "configure.h"
|
#include "aswm/event_handlers/configure.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <X11/Xutil.h>
|
|
||||||
|
|
||||||
void OnConfigureRequest(const XConfigureRequestEvent* e) {
|
void OnConfigureRequest(const XConfigureRequestEvent* e) {
|
||||||
XWindowChanges changes;
|
|
||||||
printf("XConfigureRequestEvent %lu\n", e->window);
|
printf("XConfigureRequestEvent %lu\n", e->window);
|
||||||
printf("\tx = %i\n", e->x);
|
printf("\tx = %i\n", e->x);
|
||||||
printf("\ty = %i\n", e->y);
|
printf("\ty = %i\n", e->y);
|
||||||
printf("\tw = %i\n", e->width);
|
printf("\tw = %i\n", e->width);
|
||||||
printf("\th = %i\n", e->height);
|
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 screen_number = XDefaultScreen(e->display);
|
||||||
int full_width = XDisplayWidth(e->display, screen_number);
|
int full_width = XDisplayWidth(e->display, screen_number);
|
||||||
int full_height = XDisplayWidth(e->display, screen_number);
|
int full_height = XDisplayWidth(e->display, screen_number);
|
||||||
|
|
||||||
// Copy fields from e to changes.
|
// Copy fields from e to changes.
|
||||||
|
XWindowChanges changes;
|
||||||
changes.x = 0;
|
changes.x = 0;
|
||||||
changes.y = 0;
|
changes.y = 0;
|
||||||
changes.width = full_width;
|
changes.width = full_width;
|
|
@ -1,4 +1,4 @@
|
||||||
#include "create.h"
|
#include "aswm/event_handlers/create.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void OnCreateNotify(const XCreateWindowEvent* e) {
|
void OnCreateNotify(const XCreateWindowEvent* e) {
|
|
@ -1,4 +1,4 @@
|
||||||
#include "destroy.h"
|
#include "aswm/event_handlers/destroy.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void OnDestroyNotify(const XDestroyWindowEvent* e) {
|
void OnDestroyNotify(const XDestroyWindowEvent* e) {
|
38
src/aswm/event_handlers/map.c
Normal file
38
src/aswm/event_handlers/map.c
Normal 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);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include "reparent.h"
|
#include "aswm/event_handlers/reparent.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void OnReparentNotify(const XReparentEvent* e) {
|
void OnReparentNotify(const XReparentEvent* e) {
|
|
@ -1,4 +1,4 @@
|
||||||
#include "unmap.h"
|
#include "aswm/event_handlers/unmap.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {
|
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {
|
|
@ -1,9 +1,9 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include "create.h"
|
#include "aswm/event_handlers/create.h"
|
||||||
#include "configure.h"
|
#include "aswm/event_handlers/configure.h"
|
||||||
#include "map.h"
|
#include "aswm/event_handlers/map.h"
|
||||||
#include "reparent.h"
|
#include "aswm/event_handlers/reparent.h"
|
||||||
#include "destroy.h"
|
#include "aswm/event_handlers/destroy.h"
|
||||||
|
|
||||||
Display *display;
|
Display *display;
|
||||||
Window root;
|
Window root;
|
|
@ -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);
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue