aboutsummaryrefslogtreecommitdiffstats
path: root/src/transient
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/transient/transient.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/transient/transient.c b/src/transient/transient.c
deleted file mode 100644
index fed0f77..0000000
--- a/src/transient/transient.c
+++ /dev/null
@@ -1,90 +0,0 @@
1#include <X11/Xlib.h>
2#include <X11/Xutil.h>
3#include <stdlib.h>
4#include <unistd.h>
5
6#define FLOATING_WINDOW_WIDTH 400
7#define FLOATING_WINDOW_HEIGHT 400
8#define FLOATING_WINDOW_X_POS 100
9#define FLOATING_WINDOW_Y_POS 100
10
11#define TRANSIENT_WINDOW_WIDTH 100
12#define TRANSIENT_WINDOW_HEIGHT 100
13#define TRANSIENT_WINDOW_X_POS 50
14#define TRANSIENT_WINDOW_Y_POS 50
15
16#define SLEEP_TIME 5
17
18#define WINDOW_BORDER_WIDTH 0
19#define WINDOW_BORDER_COLOR 0
20#define WINDOW_BACKGROUND_COLOR 0
21
22/**
23 * @brief Function that creates and manages floating and transient window.
24 *
25 * This program opens an X display, creates a floating window with specific
26 * size and position, and then creates a transient (child) window after a
27 * specified delay. The transient window is always associated with the
28 * floating window, meaning it will behave as a child of the floating window.
29 * The program uses Xlib to interact with the X server, handle events, and
30 * manage window properties such as size, title, and position.
31 *
32 * The key steps are:
33 * 1. Create the floating window and set its size constraints.
34 * 2. After a delay (5 seconds), create the transient window and associate
35 * it with the floating window.
36 * 3. Display both windows on the screen.
37 * 4. Wait for and process X events in an infinite loop. This allows the
38 * windows to remain open and interact with the X server.
39 *
40 * @return int Exit status (always 0).
41 */
42int main(void)
43{
44 Display *display;
45 Window rootWindow, floatingWindow, transientWindow = None;
46 XSizeHints sizeHints;
47 XEvent event;
48
49 display = XOpenDisplay(NULL);
50 if (!display)
51 exit(1);
52
53 rootWindow = DefaultRootWindow(display);
54
55 floatingWindow = XCreateSimpleWindow(
56 display, rootWindow, FLOATING_WINDOW_X_POS, FLOATING_WINDOW_Y_POS,
57 FLOATING_WINDOW_WIDTH, FLOATING_WINDOW_HEIGHT, WINDOW_BORDER_WIDTH,
58 WINDOW_BORDER_COLOR, WINDOW_BACKGROUND_COLOR);
59
60 sizeHints.min_width = sizeHints.max_width = sizeHints.min_height =
61 sizeHints.max_height = FLOATING_WINDOW_WIDTH;
62 sizeHints.flags = PMinSize | PMaxSize;
63 XSetWMNormalHints(display, floatingWindow, &sizeHints);
64 XStoreName(display, floatingWindow, "floating");
65 XMapWindow(display, floatingWindow);
66 XSelectInput(display, floatingWindow, ExposureMask);
67
68 while (1) {
69 XNextEvent(display, &event);
70
71 if (transientWindow == None) {
72 sleep(SLEEP_TIME);
73
74 transientWindow = XCreateSimpleWindow(
75 display, rootWindow, TRANSIENT_WINDOW_X_POS,
76 TRANSIENT_WINDOW_Y_POS, TRANSIENT_WINDOW_WIDTH,
77 TRANSIENT_WINDOW_HEIGHT, WINDOW_BORDER_WIDTH,
78 WINDOW_BORDER_COLOR, WINDOW_BACKGROUND_COLOR);
79
80 XSetTransientForHint(display, transientWindow,
81 floatingWindow);
82 XStoreName(display, transientWindow, "transient");
83 XMapWindow(display, transientWindow);
84 XSelectInput(display, transientWindow, ExposureMask);
85 }
86 }
87
88 XCloseDisplay(display);
89 exit(0);
90}