🎨 No reparent + logs
This commit is contained in:
parent
cb31369947
commit
6b9513987a
@ -4,6 +4,8 @@ project(aswm)
|
|||||||
|
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address")
|
||||||
|
|
||||||
add_executable(aswm
|
add_executable(aswm
|
||||||
src/main.c
|
src/main.c
|
||||||
src/create.c
|
src/create.c
|
||||||
|
@ -1,21 +1,39 @@
|
|||||||
#ifndef ASWM_CONFIGURE
|
|
||||||
#define ASWM_CONFIGURE
|
|
||||||
|
|
||||||
#include "configure.h"
|
#include "configure.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
void OnConfigureRequest(const XConfigureRequestEvent* e) {
|
void OnConfigureRequest(const XConfigureRequestEvent* e) {
|
||||||
XWindowChanges changes;
|
XWindowChanges changes;
|
||||||
printf("XConfigureRequestEvent %lu\n", e->window);
|
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.
|
// Copy fields from e to changes.
|
||||||
changes.x = e->x;
|
changes.x = 0;
|
||||||
changes.y = e->y;
|
changes.y = 0;
|
||||||
changes.width = e->width;
|
changes.width = full_width;
|
||||||
changes.height = e->height;
|
changes.height = full_height;
|
||||||
changes.border_width = e->border_width;
|
changes.border_width = e->border_width;
|
||||||
changes.sibling = e->above;
|
changes.sibling = e->above;
|
||||||
changes.stack_mode = e->detail;
|
changes.stack_mode = e->detail;
|
||||||
// Grant request by calling XConfigureWindow().
|
// Grant request by calling XConfigureWindow().
|
||||||
XConfigureWindow(e->display, e->window, e->value_mask, &changes);
|
XConfigureWindow(e->display, e->window, e->value_mask, &changes);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#ifndef ASWM_CREATE
|
|
||||||
#define ASWM_CREATE
|
|
||||||
|
|
||||||
#include "create.h"
|
#include "create.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void OnCreateNotify(const XCreateWindowEvent* e) {
|
void OnCreateNotify(const XCreateWindowEvent* e) {
|
||||||
printf("XCreateWindowEvent %lu\n", e->window);
|
printf("XCreateWindowEvent %lu\n", e->window);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
68
src/map.c
68
src/map.c
@ -1,75 +1,7 @@
|
|||||||
#ifndef ASWM_MAP
|
|
||||||
#define ASWM_MAP
|
|
||||||
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void map_fullscreen_window(Window root, Display* display, Window w);
|
|
||||||
|
|
||||||
void OnMapRequest(Window root, const XMapRequestEvent* e) {
|
void OnMapRequest(Window root, const XMapRequestEvent* e) {
|
||||||
printf("XMapRequestEvent %lu\n", e->window);
|
printf("XMapRequestEvent %lu\n", e->window);
|
||||||
map_fullscreen_window(root, e->display, e->window);
|
|
||||||
XMapWindow(e->display, e->window);
|
XMapWindow(e->display, e->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_fullscreen_window(Window root, Display* display, Window w) {
|
|
||||||
// Visual properties of the frame to create.
|
|
||||||
const unsigned int BORDER_WIDTH = 0;
|
|
||||||
const unsigned long BORDER_COLOR = 0xff0000;
|
|
||||||
const unsigned long BG_COLOR = 0x0000ff;
|
|
||||||
|
|
||||||
// 1. Retrieve attributes of window to frame.
|
|
||||||
XWindowAttributes x_window_attrs;
|
|
||||||
XGetWindowAttributes(display, w, &x_window_attrs);
|
|
||||||
|
|
||||||
// 2. TODO - see Framing Existing Top-Level Windows section below.
|
|
||||||
|
|
||||||
printf("\tXCreateSimpleWindow:\n");
|
|
||||||
printf("\t\tx: %i\n", x_window_attrs.x);
|
|
||||||
printf("\t\ty: %i\n", x_window_attrs.y);
|
|
||||||
printf("\t\tw: %i\n", x_window_attrs.width);
|
|
||||||
printf("\t\th: %i\n", x_window_attrs.height);
|
|
||||||
|
|
||||||
// 3. Create frame.
|
|
||||||
const Window frame = XCreateSimpleWindow(
|
|
||||||
display,
|
|
||||||
root,
|
|
||||||
x_window_attrs.x,
|
|
||||||
x_window_attrs.y,
|
|
||||||
x_window_attrs.width,
|
|
||||||
x_window_attrs.height,
|
|
||||||
BORDER_WIDTH,
|
|
||||||
BORDER_COLOR,
|
|
||||||
BG_COLOR);
|
|
||||||
// 3. Select events on frame.
|
|
||||||
XSelectInput(
|
|
||||||
display,
|
|
||||||
frame,
|
|
||||||
SubstructureRedirectMask | SubstructureNotifyMask);
|
|
||||||
// 4. Add client to save set, so that it will be restored and kept alive if we
|
|
||||||
// crash.
|
|
||||||
XAddToSaveSet(display, w);
|
|
||||||
// 5. Reparent client window.
|
|
||||||
XReparentWindow(
|
|
||||||
display,
|
|
||||||
w,
|
|
||||||
frame,
|
|
||||||
0, 0); // Offset of client window within frame.
|
|
||||||
// 6. Map frame.
|
|
||||||
XMapWindow(display, frame);
|
|
||||||
// 7. Save frame handle.
|
|
||||||
/* clients_[w] = frame; */
|
|
||||||
// 8. Grab events for window management actions on client window.
|
|
||||||
// a. Move windows with alt + left button.
|
|
||||||
/* XGrabButton(...); */
|
|
||||||
// b. Resize windows with alt + right button.
|
|
||||||
/* XGrabButton(...); */
|
|
||||||
// c. Kill windows with alt + f4.
|
|
||||||
/* XGrabKey(...); */
|
|
||||||
// d. Switch windows with alt + tab.
|
|
||||||
/* XGrabKey(...); */
|
|
||||||
|
|
||||||
printf("\tFramed window %lu [%lu]\n", w, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
23
src/unmap.c
23
src/unmap.c
@ -4,26 +4,3 @@
|
|||||||
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {
|
void OnUnmapRequest(Window root, const XMapRequestEvent* e) {
|
||||||
printf("XUnmapWindow %lu", e->window);
|
printf("XUnmapWindow %lu", e->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* void unframe(Window root, Display* display, Window w) {
|
|
||||||
* // We reverse the steps taken in Frame().
|
|
||||||
* const Window frame = clients_[w];
|
|
||||||
* // 1. Unmap frame.
|
|
||||||
* XUnmapWindow(display, frame);
|
|
||||||
* // 2. Reparent client window back to root window.
|
|
||||||
* XReparentWindow(
|
|
||||||
* display,
|
|
||||||
* w,
|
|
||||||
* root,
|
|
||||||
* 0, 0); // Offset of client window within root.
|
|
||||||
* // 3. Remove client window from save set, as it is now unrelated to us.
|
|
||||||
* XRemoveFromSaveSet(display, w);
|
|
||||||
* // 4. Destroy frame.
|
|
||||||
* XDestroyWindow(display, frame);
|
|
||||||
* // 5. Drop reference to frame handle.
|
|
||||||
* clients_.erase(w);
|
|
||||||
*
|
|
||||||
* LOG(INFO) << "Unframed window " << w << " [" << frame << "]";
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user