✨ Default input focus and _NET_ACTIVE_WINDOW support
This commit is contained in:
parent
6a20573dfa
commit
2b0014be11
@ -18,6 +18,7 @@ add_executable(aswm
|
|||||||
src/aswm/event_handlers/map.c
|
src/aswm/event_handlers/map.c
|
||||||
src/aswm/event_handlers/unmap.c
|
src/aswm/event_handlers/unmap.c
|
||||||
src/aswm/event_handlers/property.c
|
src/aswm/event_handlers/property.c
|
||||||
|
src/aswm/event_handlers/message.c
|
||||||
src/aswm/log/log.c
|
src/aswm/log/log.c
|
||||||
)
|
)
|
||||||
target_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} src)
|
target_include_directories(aswm PUBLIC ${X11_INCLUDE_DIR} src)
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "event_handlers/reparent.h"
|
#include "event_handlers/reparent.h"
|
||||||
#include "event_handlers/destroy.h"
|
#include "event_handlers/destroy.h"
|
||||||
#include "event_handlers/property.h"
|
#include "event_handlers/property.h"
|
||||||
|
#include "event_handlers/message.h"
|
||||||
#include "log/error.h"
|
#include "log/error.h"
|
||||||
|
|
||||||
Aswm _aswm;
|
Aswm _aswm;
|
||||||
@ -84,6 +85,35 @@ void aswm_create_workspace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void aswm_event_loop() {
|
void aswm_event_loop() {
|
||||||
|
printf("MotionNofity %i\n", MotionNotify);
|
||||||
|
printf("ButtonPress %i\n", ButtonPress);
|
||||||
|
printf("ButtonRelease %i\n", ButtonRelease);
|
||||||
|
printf("ColormapNotify %i\n", ColormapNotify);
|
||||||
|
printf("EnterNotify %i\n", EnterNotify);
|
||||||
|
printf("LeaveNotify %i\n", LeaveNotify);
|
||||||
|
printf("Expose %i\n", Expose);
|
||||||
|
printf("GraphicsExpose %i\n", GraphicsExpose);
|
||||||
|
printf("NoExpose %i\n", NoExpose);
|
||||||
|
printf("FocusIn %i\n", FocusIn);
|
||||||
|
printf("FocusOut %i\n", FocusOut);
|
||||||
|
printf("KeymapNotify %i\n", KeymapNotify);
|
||||||
|
printf("KeyPress %i\n", KeyPress);
|
||||||
|
printf("KeyRelease %i\n", KeyRelease);
|
||||||
|
printf("MotionNofity %i\n", MotionNotify);
|
||||||
|
printf("PropertyNotify %i\n", PropertyNotify);
|
||||||
|
printf("ResizeRequest %i\n", ResizeRequest);
|
||||||
|
printf("CirculateNotify %i\n", CirculateNotify);
|
||||||
|
printf("ConfigureNotify %i\n", ConfigureNotify);
|
||||||
|
printf("DestroyNotify %i\n", DestroyNotify);
|
||||||
|
printf("GravityNotify %i\n", GravityNotify);
|
||||||
|
printf("MapNotify %i\n", MapNotify);
|
||||||
|
printf("ReparentNotify %i\n", ReparentNotify);
|
||||||
|
printf("UnmapNotify %i\n", UnmapNotify);
|
||||||
|
printf("CirculateRequest %i\n", CirculateRequest);
|
||||||
|
printf("ConfigureRequest %i\n", ConfigureRequest);
|
||||||
|
printf("MapRequest %i\n", MapRequest);
|
||||||
|
printf("VisibilityNotify %i\n", VisibilityNotify);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
XEvent e;
|
XEvent e;
|
||||||
XNextEvent(_aswm.display, &e);
|
XNextEvent(_aswm.display, &e);
|
||||||
@ -94,6 +124,8 @@ void aswm_event_loop() {
|
|||||||
// ignored, according to the X server specification.
|
// ignored, according to the X server specification.
|
||||||
if(e.xcreatewindow.override_redirect == False)
|
if(e.xcreatewindow.override_redirect == False)
|
||||||
OnCreateNotify(&_aswm, &e.xcreatewindow);
|
OnCreateNotify(&_aswm, &e.xcreatewindow);
|
||||||
|
else
|
||||||
|
printf("Ignored create notify %lu\n", e.xcreatewindow.window);
|
||||||
break;
|
break;
|
||||||
case ConfigureRequest:
|
case ConfigureRequest:
|
||||||
OnConfigureRequest(&e.xconfigurerequest);
|
OnConfigureRequest(&e.xconfigurerequest);
|
||||||
@ -133,17 +165,13 @@ void aswm_event_loop() {
|
|||||||
printf("Release %lu\n", e.xbutton.window);
|
printf("Release %lu\n", e.xbutton.window);
|
||||||
break;
|
break;
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
// TODO: handle this
|
OnClientMessage(&_aswm, &e.xclient);
|
||||||
printf("Unhandled client message from window %lu:\n", e.xclient.window);
|
|
||||||
char* atom_name = XGetAtomName(e.xclient.display, e.xclient.message_type);
|
|
||||||
printf("\t%s\n", atom_name);
|
|
||||||
XFree(atom_name);
|
|
||||||
break;
|
break;
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
OnPropertyNotify(&_aswm, &e.xproperty);
|
OnPropertyNotify(&_aswm, &e.xproperty);
|
||||||
// TODO: handle this
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
printf("Unknown event: %i\n", e.type);
|
||||||
break;
|
break;
|
||||||
/* LOG(WARNING) << "Ignored event"; */
|
/* LOG(WARNING) << "Ignored event"; */
|
||||||
}
|
}
|
||||||
@ -155,6 +183,28 @@ void aswm_close() {
|
|||||||
XCloseDisplay(_aswm.display);
|
XCloseDisplay(_aswm.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window aswm_currently_active() {
|
||||||
|
Window active;
|
||||||
|
int status;
|
||||||
|
XGetInputFocus(_aswm.display, &active, &status);
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
void aswm_activate_window(Window window) {
|
||||||
|
/* XEvent event; */
|
||||||
|
/* event.xclient.display = _aswm.display; */
|
||||||
|
/* event.xclient.window = window; */
|
||||||
|
/* event.xclient.message_type = XInternAtom(_aswm.display, "_NET_ACTIVE_WINDOW", True); */
|
||||||
|
/* event.xclient.format = 32; */
|
||||||
|
/* event.xclient.data.l[0] = 1; // Source indication */
|
||||||
|
/* event.xclient.data.l[1] = 1; // Timestamp // Currently not set */
|
||||||
|
/* event.xclient.data.l[2] = 0; // Requestor's currently active window: TODO */
|
||||||
|
|
||||||
|
printf("Activate window %lu (currently active: %lu)\n", window, aswm_currently_active());
|
||||||
|
/* XSendEvent(_aswm.display, _aswm.root_window, True, 0 [> N. A. <], &event); */
|
||||||
|
XSetInputFocus(_aswm.display, window, RevertToParent, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
aswm_open();
|
aswm_open();
|
||||||
aswm_event_loop();
|
aswm_event_loop();
|
||||||
|
@ -21,6 +21,7 @@ void aswm_open();
|
|||||||
void aswm_create_workspace();
|
void aswm_create_workspace();
|
||||||
void aswm_event_loop();
|
void aswm_event_loop();
|
||||||
void aswm_close();
|
void aswm_close();
|
||||||
|
void aswm_activate_window(Window window);
|
||||||
|
|
||||||
int main(int argc, char** argv);
|
int main(int argc, char** argv);
|
||||||
|
|
||||||
|
@ -190,6 +190,8 @@ void aswm_stack_window(Display* display, Window stack, Window window_to_map, int
|
|||||||
if(stack_attributes.map_state == IsUnmapped) {
|
if(stack_attributes.map_state == IsUnmapped) {
|
||||||
XMapWindow(display, stack);
|
XMapWindow(display, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aswm_activate_window(window_to_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void aswm_unstack_window(Display* display, Window stack) {
|
void aswm_unstack_window(Display* display, Window stack) {
|
||||||
|
Loading…
Reference in New Issue
Block a user