🚧 Basic ES-DE window detection and event logging

This commit is contained in:
Paul Breugnot 2024-12-28 11:11:16 +01:00
parent b8b13ebe07
commit 000b783279
7 changed files with 49 additions and 5 deletions

View File

@ -15,6 +15,7 @@ add_executable(aswm
src/aswm/event_handlers/configure.c
src/aswm/event_handlers/reparent.c
src/aswm/event_handlers/destroy.c
src/aswm/event_handlers/map.c)
src/aswm/event_handlers/map.c
src/aswm/event_handlers/unmap.c)
target_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} src)
target_link_libraries(aswm ${X11_LIBRARIES})

View File

@ -1,8 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include "aswm.h"
#include "event_handlers/create.h"
#include "event_handlers/configure.h"
#include "event_handlers/map.h"
#include "event_handlers/unmap.h"
#include "event_handlers/reparent.h"
#include "event_handlers/destroy.h"
@ -15,7 +17,11 @@ void aswm_open() {
_aswm.root_tile = aswm_alloc_root_tile(_aswm.display, _aswm.root_window);
XSelectInput(_aswm.display, _aswm.root_window, SubstructureRedirectMask | SubstructureNotifyMask);
printf("PointerRoot %lu\n", PointerRoot);
printf("None %lu\n", None);
printf("Root window %lu\n", _aswm.root_window);
XSelectInput(_aswm.display, _aswm.root_window, SubstructureRedirectMask | SubstructureNotifyMask | FocusChangeMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask);
XSync(_aswm.display, 0);
atexit(aswm_close);
@ -36,12 +42,37 @@ void aswm_event_loop() {
case MapRequest:
OnMapRequest(&_aswm, &e.xmaprequest);
break;
case UnmapNotify:
OnUnmapNotify(&_aswm, &e.xunmap);
break;
case DestroyNotify:
OnDestroyNotify(&e.xdestroywindow);
break;
case ReparentNotify:
OnReparentNotify(&e.xreparent);
break;
case FocusIn:
printf("FocusIn %lu\n", (&e.xfocus)->window);
break;
case FocusOut:
printf("FocusOut %lu\n", e.xfocus.window);
break;
case EnterNotify:
int revert_to;
Window window;
XGetInputFocus(e.xcrossing.display, &window, &revert_to);
printf("Enter %lu\n", e.xcrossing.window);
printf("Input focus %lu\n", window);
break;
case LeaveNotify:
printf("Leave %lu\n", e.xcrossing.window);
break;
case ButtonPress:
printf("Press %lu\n", e.xbutton.window);
break;
case ButtonRelease:
printf("Release %lu\n", e.xbutton.window);
break;
default:
break;
/* LOG(WARNING) << "Ignored event"; */

View File

@ -7,6 +7,7 @@ typedef struct {
Display *display;
Window root_window;
AswmTile* root_tile;
Window es_de_window;
} Aswm;
void aswm_open();

View File

@ -1,5 +1,6 @@
#include "map.h"
#include <stdio.h>
#include <string.h>
#include <X11/Xutil.h>
void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
@ -9,6 +10,8 @@ void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
XTextProperty text_property;
XGetWMName(e->display, e->window, &text_property);
printf("\tname: %s\n", text_property.value);
if(text_property.value != nullptr && strcmp(text_property.value, "ES-DE") == 0)
aswm->es_de_window = e->window;
}
{
XClassHint class;
@ -21,5 +24,7 @@ void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
int full_height = XDisplayWidth(e->display, screen_number);
aswm_map_new_window(e->display, e->window, aswm->root_tile);
/* XSelectInput(e->display, e->window, FocusChangeMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask); */
XMapWindow(e->display, e->window);
}

View File

@ -1,6 +1,9 @@
#include "unmap.h"
#include <stdio.h>
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {
printf("XUnmapWindow %lu", e->window);
void OnUnmapNotify(Aswm* aswm, const XUnmapEvent* e) {
printf("XUnmapWindow %lu\n", e->window);
printf("ES-DE window %lu\n", aswm->es_de_window);
if(aswm->es_de_window != None)
XSetInputFocus(e->display, aswm->es_de_window, RevertToPointerRoot, CurrentTime);
}

View File

@ -1,3 +1,5 @@
#include <X11/Xlib.h>
void OnUnmapRequest(Window root, const XMapRequestEvent* e);
#include "aswm/aswm.h"
void OnUnmapNotify(Aswm* aswm, const XUnmapEvent* e);

View File

@ -20,5 +20,6 @@ AswmTile* aswm_alloc_root_tile(Display* display, Window window);
void aswm_free_tile(AswmTile* tile);
AswmTile* aswm_map_new_window(Display* display, Window window, AswmTile* tile);
AswmTile* aswm_unmap_window(Display* display, Window window, AswmTile* tile);
#endif