🚧 Basic ES-DE window detection and event logging
This commit is contained in:
parent
b8b13ebe07
commit
000b783279
7 changed files with 49 additions and 5 deletions
|
@ -15,6 +15,7 @@ add_executable(aswm
|
||||||
src/aswm/event_handlers/configure.c
|
src/aswm/event_handlers/configure.c
|
||||||
src/aswm/event_handlers/reparent.c
|
src/aswm/event_handlers/reparent.c
|
||||||
src/aswm/event_handlers/destroy.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_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} src)
|
||||||
target_link_libraries(aswm ${X11_LIBRARIES})
|
target_link_libraries(aswm ${X11_LIBRARIES})
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "aswm.h"
|
#include "aswm.h"
|
||||||
#include "event_handlers/create.h"
|
#include "event_handlers/create.h"
|
||||||
#include "event_handlers/configure.h"
|
#include "event_handlers/configure.h"
|
||||||
#include "event_handlers/map.h"
|
#include "event_handlers/map.h"
|
||||||
|
#include "event_handlers/unmap.h"
|
||||||
#include "event_handlers/reparent.h"
|
#include "event_handlers/reparent.h"
|
||||||
#include "event_handlers/destroy.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);
|
_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);
|
XSync(_aswm.display, 0);
|
||||||
|
|
||||||
atexit(aswm_close);
|
atexit(aswm_close);
|
||||||
|
@ -36,12 +42,37 @@ void aswm_event_loop() {
|
||||||
case MapRequest:
|
case MapRequest:
|
||||||
OnMapRequest(&_aswm, &e.xmaprequest);
|
OnMapRequest(&_aswm, &e.xmaprequest);
|
||||||
break;
|
break;
|
||||||
|
case UnmapNotify:
|
||||||
|
OnUnmapNotify(&_aswm, &e.xunmap);
|
||||||
|
break;
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
OnDestroyNotify(&e.xdestroywindow);
|
OnDestroyNotify(&e.xdestroywindow);
|
||||||
break;
|
break;
|
||||||
case ReparentNotify:
|
case ReparentNotify:
|
||||||
OnReparentNotify(&e.xreparent);
|
OnReparentNotify(&e.xreparent);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
/* LOG(WARNING) << "Ignored event"; */
|
/* LOG(WARNING) << "Ignored event"; */
|
||||||
|
|
|
@ -7,6 +7,7 @@ typedef struct {
|
||||||
Display *display;
|
Display *display;
|
||||||
Window root_window;
|
Window root_window;
|
||||||
AswmTile* root_tile;
|
AswmTile* root_tile;
|
||||||
|
Window es_de_window;
|
||||||
} Aswm;
|
} Aswm;
|
||||||
|
|
||||||
void aswm_open();
|
void aswm_open();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
|
void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
|
||||||
|
@ -9,6 +10,8 @@ void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
|
||||||
XTextProperty text_property;
|
XTextProperty text_property;
|
||||||
XGetWMName(e->display, e->window, &text_property);
|
XGetWMName(e->display, e->window, &text_property);
|
||||||
printf("\tname: %s\n", text_property.value);
|
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;
|
XClassHint class;
|
||||||
|
@ -21,5 +24,7 @@ void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
|
||||||
int full_height = XDisplayWidth(e->display, screen_number);
|
int full_height = XDisplayWidth(e->display, screen_number);
|
||||||
|
|
||||||
aswm_map_new_window(e->display, e->window, aswm->root_tile);
|
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);
|
XMapWindow(e->display, e->window);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "unmap.h"
|
#include "unmap.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {
|
void OnUnmapNotify(Aswm* aswm, const XUnmapEvent* e) {
|
||||||
printf("XUnmapWindow %lu", e->window);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
void OnUnmapRequest(Window root, const XMapRequestEvent* e);
|
#include "aswm/aswm.h"
|
||||||
|
|
||||||
|
void OnUnmapNotify(Aswm* aswm, const XUnmapEvent* e);
|
||||||
|
|
|
@ -20,5 +20,6 @@ AswmTile* aswm_alloc_root_tile(Display* display, Window window);
|
||||||
void aswm_free_tile(AswmTile* tile);
|
void aswm_free_tile(AswmTile* tile);
|
||||||
|
|
||||||
AswmTile* aswm_map_new_window(Display* display, Window window, AswmTile* tile);
|
AswmTile* aswm_map_new_window(Display* display, Window window, AswmTile* tile);
|
||||||
|
AswmTile* aswm_unmap_window(Display* display, Window window, AswmTile* tile);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue