summaryrefslogtreecommitdiffhomepage
path: root/.rules/plan/phase-04-input.md
blob: 439d2154533225977b2b7c99814bba9e47299b2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Phase 4 — Input & Focus

---

## Step 4.1 — Click-to-focus and raise

On `ButtonPress` events on managed windows, set focus with
`XSetInputFocus(dpy, win->xwin, RevertToParent, CurrentTime)` and raise
the window with `XRaiseWindow()`.

Register for `ButtonPressMask` on all managed windows using a passive
grab:

```c
XGrabButton(dpy, AnyButton, AnyModifier, win->xwin, True,
    ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
```

On `ButtonPress`, set focus, raise, then `XAllowEvents(dpy, ReplayPointer,
CurrentTime)` to pass the click through to the client.

**Verify:** Click on `xterm` — it receives focus and comes to front.
Type in it. Click `xeyes` — it comes to front. Focus switching works.

---

## Step 4.2 — Window dragging with Mod+Click

Grab `Mod4 + Button1` (Super+Click) on the root window. On press, start
tracking a drag. On motion, `XMoveWindow()` the client and update the
stored position. On release, stop.

```c
XGrabButton(dpy, Button1, Mod4Mask, root, True,
    ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
    GrabModeAsync, GrabModeAsync, None, None);
```

**Verify:** Super+Click and drag moves windows around inside Xephyr.
Release drops them. The composited view updates in real-time.

---

## Step 4.3 — Window resizing with Mod+RightClick

Same pattern as dragging but with `Mod4 + Button3`. On motion, call
`XResizeWindow()`. Re-obtain the pixmap and texture after resize.

**Verify:** Super+RightClick and drag resizes windows. The texture
updates to show the new content.