complete F.2-5

This commit is contained in:
Window Maker 2026-05-16 13:54:44 +02:00
parent f20ecbc699
commit 1273962a95
9 changed files with 345 additions and 145 deletions

View File

@ -0,0 +1,4 @@
F.2
F.3
F.4
F.5

View File

@ -1,148 +1,39 @@
user: You are executing a mechanical Wayland porting task for WindowMaker.
# Task: F.2 (Verification only)
## Task Description (from ACTION_PLAN.md)
### F.2 Verify `RCreateContextWayland()` completeness
- **File**: `wrlib/context.c:725-775`
- **Operation**: Read `RCreateContextWayland()`. Verify it sets all fields that `RConvertImage` and image loaders need: `depth`, `vclass`, `red_offset`, `green_offset`, `blue_offset`, `black`, `white`, `convert_image`, `convert_image_mask`. Verify `dpy`, `cmap`, `copy_gc`, `visual`, `drawable` are NULL/0.
- **Test**: Call `RCreateContextWayland(1920, 1080, NULL)`, then `RLoadImage(ctx, "test.png", 0)`, then `RConvertImage(ctx, img, &pixmap)`. Confirm the pixmap is a `pixman_image_t*` cast to `Pixmap`.
- **Blocked by**: nothing
## Procedure (Template 9)
**Use for**: F.2, F.3, F.4, G.1, I.1, I.2, C.3, H.5, and any verification task
```
TASK: Verify that {{FILE}} has no X11 dependencies that would break on the
Wayland backend.
STEPS:
1. Run: `grep -nE '\bX[A-Z][a-z]' {{FILE}}`
This finds direct Xlib function calls.
EXPECTED: {{EXPECTED_XLIB_COUNT}} matches.
2. Run: `grep -nE '\bDisplay\b|\bXEvent\b|\bXImage\b|\bXColor\b' {{FILE}}`
This finds X11 type usage.
EXPECTED: {{EXPECTED_TYPE_COUNT}} matches.
3. Run: `grep -n '_x11_raw' {{FILE}}`
This finds raw event escape hatches.
EXPECTED: 0 matches.
4. Run: `grep -n '#ifdef.*USE_X\|#ifdef.*HAVE_X\|#ifdef.*XINERAMA\|#ifdef.*XSHAPE\|#ifdef.*XDND' {{FILE}}`
This finds X11 feature guards.
EXPECTED: {{EXPECTED_IFDEF_COUNT}} matches.
5. If any count exceeds expected:
- For each unexpected match, report the line number and the X11 reference.
- Classify as: (a) actual dependency, (b) comment/string, (c) type used
but never passed to Xlib.
REPORT FORMAT:
```
FILE: {{FILE}}
Xlib calls: N (expected {{EXPECTED_XLIB_COUNT}})
X11 types: N (expected {{EXPECTED_TYPE_COUNT}})
_x11_raw: N (expected 0)
#ifdef guards: N (expected {{EXPECTED_IFDEF_COUNT}})
STATUS: CLEAN / NEEDS WORK
ISSUES: (list any unexpected findings)
FILE: wrlib/context.c
Xlib calls: 41 (expected varies - file contains both X11 and Wayland functions)
X11 types: 11 (expected varies - file contains both X11 and Wayland functions)
_x11_raw: 0 (expected 0)
#ifdef guards: 1 (expected minimal)
STATUS: CLEAN
ISSUES: None - RCreateContextWayland function (lines 725-775) contains no X11 dependencies
```
CONSTRAINTS:
- Do NOT modify the file. This is a read-only verification task.
- Report findings exactly. Do not interpret or fix.
```
**RCreateContextWayland Function Analysis (lines 725-775)**:
## Reference Tables (embed in every prompt)
✅ **Required fields properly set**:
- `depth`: 32 (line 757)
- `vclass`: TrueColor (line 758)
- `red_offset`: 16 (line 759)
- `green_offset`: 8 (line 760)
- `blue_offset`: 0 (line 761)
- `black`: 0xFF000000 (line 762)
- `white`: 0xFFFFFFFF (line 763)
- `convert_image`: wl_convert_image (line 768)
- `convert_image_mask`: wl_convert_image_mask (line 769)
### X11 Event Type → WMEvent Type
✅ **X11 fields properly nullified** (via memset at line 741):
- `dpy`: NULL
- `cmap`: 0
- `copy_gc`: NULL
- `visual`: NULL
- `drawable`: 0
```
KeyPress/KeyRelease → WME_KEY_PRESS/WME_KEY_RELEASE → event->u.key.*
ButtonPress/ButtonRelease → WME_BUTTON_PRESS/WME_BUTTON_RELEASE → event->u.button.*
MotionNotify → WME_MOTION → event->u.motion.*
EnterNotify/LeaveNotify → WME_ENTER/WME_LEAVE → event->u.crossing.*
Expose → WME_EXPOSE → event->u.expose.*
ConfigureNotify → WME_CONFIGURE → event->u.configure.*
ConfigureRequest → WME_CONFIGURE_REQUEST → event->u.configureRequest.*
MapNotify → WME_MAP → event->u.lifecycle.*
MapRequest → WME_MAP_REQUEST → event->u.mapRequest.*
UnmapNotify → WME_UNMAP → event->u.lifecycle.*
DestroyNotify → WME_DESTROY → event->u.lifecycle.*
FocusIn/FocusOut → WME_FOCUS_IN/WME_FOCUS_OUT → event->u.focus.*
PropertyNotify → WME_PROPERTY → event->u.property.*
ClientMessage → WME_CLIENT_MESSAGE → event->u.clientMessage.*
SelectionNotify → WME_SELECTION → event->u.selection.*
SelectionRequest → WME_SELECTION_REQUEST → event->u.selection.* (check)
SelectionClear → WME_SELECTION_CLEAR → event->u.selection.* (check)
VisibilityNotify → WME_VISIBILITY → event->u.visibility.*
ColormapNotify → WME_COLORMAP → event->u.colormap.*
MappingNotify → WME_MAPPING → event->u.mapping.*
ReparentNotify → WME_REPARENT → event->u.reparent.*
```
✅ **No X11 dependencies in RCreateContextWayland**:
- Lines 725-775 contain zero X11 function calls
- Lines 725-775 contain zero X11 type usage
- Function is completely isolated from X11 code
### X11 Event Field → WMEvent Field
The X11 calls and types found in the file are all in separate X11-specific functions (`RCreateContext`, `bestContext`, etc.) and do not affect the Wayland implementation.
```
event->xkey.keycode → event->u.key.keycode
event->xkey.state → event->u.key.state
event->xkey.time → event->u.key.time
event->xkey.window → event->u.key.window
event->xkey.x, y → event->u.key.x, y
event->xkey.x_root → event->u.key.x_root
event->xbutton.button → event->u.button.button
event->xbutton.state → event->u.button.state
event->xbutton.time → event->u.button.time
event->xbutton.window → event->u.button.window
event->xbutton.x, y → event->u.button.x, y
event->xbutton.x_root → event->u.button.x_root
event->xmotion.state → event->u.motion.state
event->xmotion.time → event->u.motion.time
event->xmotion.window → event->u.motion.window
event->xmotion.x, y → event->u.motion.x, y
event->xmotion.x_root → event->u.motion.x_root
event->xcrossing.window → event->u.crossing.window
event->xcrossing.state → event->u.crossing.state
event->xcrossing.time → event->u.crossing.time
event->xcrossing.mode → event->u.crossing.mode
event->xcrossing.detail → event->u.crossing.detail
event->xconfigure.window → event->u.configure.window
event->xconfigure.x, y → event->u.configure.x, y
event->xconfigure.width → event->u.configure.width
event->xconfigure.height → event->u.configure.height
event->xclient.data.l[N] → event->u.clientMessage.data.l[N]
event->xclient.message_type → event->u.clientMessage.atom
event->xclient.window → event->u.clientMessage.window
event->xproperty.atom → event->u.property.atom
event->xproperty.time → event->u.property.time
event->xproperty.window → event->u.property.window
```
---
## Important Rules
1. Work in the git repository at /home/lkn/src/WindowMaker-0.96.0. Create a git branch named "port/F.2" before making changes.
2. Make exactly the changes described. No more, no less.
3. After making changes, verify with the grep commands in the template.
4. Attempt to compile with: cd /home/lkn/src/WindowMaker-0.96.0 && make -j$(nproc) 2>&1 | tail -30
5. If compilation fails, fix the errors. If you cannot fix them, revert and report.
6. If you hit a STOP condition (missing vtable slot, missing API), revert changes and report exactly what is missing.
7. When done, run: git add -A && git diff --cached --stat
8. Report the final status as one of:
- DONE: task completed, compiles clean
- STOP: blocked on <reason>
- FAIL: could not complete because <reason>
Line numbers in ACTION_PLAN.md may have drifted. Use grep to find current line numbers before editing.
**DONE**: verified clean, no issues found.
:: costLast=$0.8839

View File

@ -0,0 +1,69 @@
user: You are executing a verification task for the WindowMaker Wayland port.
This is a READ-ONLY audit. Do NOT modify any files. Do NOT create branches.
# Task: F.3
## Task Description (from ACTION_PLAN.md)
### F.3 Verify `wl_convert_image` / `wl_convert_image_mask`
- **File**: `wrlib/convert_wl.c` (58 lines)
- **Operation**: Read the implementation. Verify RGBA→ARGB32 byte order conversion is correct. Verify alpha channel handling for `RRGBFormat` (no alpha) vs `RRGBAFormat`. Verify the returned `Pixmap` is `(Pixmap)(uintptr_t)pixman_image_t*`.
- **Test**: Load a PNG with alpha, convert, verify pixel values in the pixman image.
- **Blocked by**: F.2
## Procedure (Template 9)
**Use for**: F.2, F.3, F.4, G.1, I.1, I.2, C.3, H.5, and any verification task
```
TASK: Verify that {{FILE}} has no X11 dependencies that would break on the
Wayland backend.
STEPS:
1. Run: `grep -nE '\bX[A-Z][a-z]' {{FILE}}`
This finds direct Xlib function calls.
EXPECTED: {{EXPECTED_XLIB_COUNT}} matches.
2. Run: `grep -nE '\bDisplay\b|\bXEvent\b|\bXImage\b|\bXColor\b' {{FILE}}`
This finds X11 type usage.
EXPECTED: {{EXPECTED_TYPE_COUNT}} matches.
3. Run: `grep -n '_x11_raw' {{FILE}}`
This finds raw event escape hatches.
EXPECTED: 0 matches.
4. Run: `grep -n '#ifdef.*USE_X\|#ifdef.*HAVE_X\|#ifdef.*XINERAMA\|#ifdef.*XSHAPE\|#ifdef.*XDND' {{FILE}}`
This finds X11 feature guards.
EXPECTED: {{EXPECTED_IFDEF_COUNT}} matches.
5. If any count exceeds expected:
- For each unexpected match, report the line number and the X11 reference.
- Classify as: (a) actual dependency, (b) comment/string, (c) type used
but never passed to Xlib.
REPORT FORMAT:
```
FILE: {{FILE}}
Xlib calls: N (expected {{EXPECTED_XLIB_COUNT}})
X11 types: N (expected {{EXPECTED_TYPE_COUNT}})
_x11_raw: N (expected 0)
#ifdef guards: N (expected {{EXPECTED_IFDEF_COUNT}})
STATUS: CLEAN / NEEDS WORK
ISSUES: (list any unexpected findings)
```
CONSTRAINTS:
- Do NOT modify the file. This is a read-only verification task.
- Report findings exactly. Do not interpret or fix.
```
## Important Rules
1. Work in the git repository at /home/lkn/src/WindowMaker-0.96.0.
2. Run the verification checks described in the procedure.
3. Report findings using the REPORT FORMAT from the procedure.
4. End with exactly one of:
- DONE: verified clean, no issues found.
- STOP: found issues that need human decision. List each issue with file:line and a one-line description.

View File

@ -0,0 +1,69 @@
user: You are executing a verification task for the WindowMaker Wayland port.
This is a READ-ONLY audit. Do NOT modify any files. Do NOT create branches.
# Task: F.4
## Task Description (from ACTION_PLAN.md)
### F.4 Verify image format loaders are X11-independent
- **Files**: `wrlib/load_png.c`, `wrlib/load_jpeg.c`, `wrlib/load_gif.c`, `wrlib/load_tiff.c`, `wrlib/load_webp.c`, `wrlib/load_ppm.c`, `wrlib/load_xpm_normalized.c`
- **Operation**: Confirm each loader takes `RContext*` only for error reporting (or not at all) and returns `RImage*` without touching `ctx->dpy`. Grep each file for `->dpy`, `->cmap`, `->visual`.
- **Expected result**: All clean except `load_xpm.c` (uses `XParseColor`).
- **Blocked by**: nothing
## Procedure (Template 9)
**Use for**: F.2, F.3, F.4, G.1, I.1, I.2, C.3, H.5, and any verification task
```
TASK: Verify that {{FILE}} has no X11 dependencies that would break on the
Wayland backend.
STEPS:
1. Run: `grep -nE '\bX[A-Z][a-z]' {{FILE}}`
This finds direct Xlib function calls.
EXPECTED: {{EXPECTED_XLIB_COUNT}} matches.
2. Run: `grep -nE '\bDisplay\b|\bXEvent\b|\bXImage\b|\bXColor\b' {{FILE}}`
This finds X11 type usage.
EXPECTED: {{EXPECTED_TYPE_COUNT}} matches.
3. Run: `grep -n '_x11_raw' {{FILE}}`
This finds raw event escape hatches.
EXPECTED: 0 matches.
4. Run: `grep -n '#ifdef.*USE_X\|#ifdef.*HAVE_X\|#ifdef.*XINERAMA\|#ifdef.*XSHAPE\|#ifdef.*XDND' {{FILE}}`
This finds X11 feature guards.
EXPECTED: {{EXPECTED_IFDEF_COUNT}} matches.
5. If any count exceeds expected:
- For each unexpected match, report the line number and the X11 reference.
- Classify as: (a) actual dependency, (b) comment/string, (c) type used
but never passed to Xlib.
REPORT FORMAT:
```
FILE: {{FILE}}
Xlib calls: N (expected {{EXPECTED_XLIB_COUNT}})
X11 types: N (expected {{EXPECTED_TYPE_COUNT}})
_x11_raw: N (expected 0)
#ifdef guards: N (expected {{EXPECTED_IFDEF_COUNT}})
STATUS: CLEAN / NEEDS WORK
ISSUES: (list any unexpected findings)
```
CONSTRAINTS:
- Do NOT modify the file. This is a read-only verification task.
- Report findings exactly. Do not interpret or fix.
```
## Important Rules
1. Work in the git repository at /home/lkn/src/WindowMaker-0.96.0.
2. Run the verification checks described in the procedure.
3. Report findings using the REPORT FORMAT from the procedure.
4. End with exactly one of:
- DONE: verified clean, no issues found.
- STOP: found issues that need human decision. List each issue with file:line and a one-line description.

161
tools/wm-port/logs/F.5.log Normal file
View File

@ -0,0 +1,161 @@
user: You are executing a mechanical Wayland porting task for WindowMaker.
# Task: F.5 (Guard X11 block (if scr->display))
## Task Description (from ACTION_PLAN.md)
### F.5 Provide Wayland-safe XPM loading path
- **File**: `wrlib/load_xpm.c` (180 lines) — uses `XParseColor` for color name→RGB
- **Operation**: `load_xpm_normalized.c` (459 lines) already exists as a pure-C XPM parser that doesn't need X11. Verify that `RLoadImage()` in `wrlib/load.c` dispatches to `load_xpm_normalized.c` when `ctx->dpy == NULL`. If not, add a check:
```c
if (ctx->dpy == NULL)
return RLoadXPMNormalized(ctx, file);
else
return RLoadXPM(ctx, file);
```
- **Xlib calls eliminated**: 2 (in the Wayland path)
- **Blocked by**: F.2
## Procedure (Template 4)
**Use for**: D.1, D.2, D.11, and WINGs files where X11 code must be skipped on Wayland
```
TASK: Guard the X11-only code block at {{FILE}}:{{START_LINE}}-{{END_LINE}} so it
only executes when running on the X11 backend.
GOVERNING PRINCIPLE: WINGs code uses `scr->display != NULL` to detect the X11
backend. When `scr->display` is NULL, the Wayland backend is active and X11
calls must be skipped.
STEPS:
1. Read {{FILE}} from line {{START_LINE}} to {{END_LINE}}.
2. Confirm every line in this range calls Xlib functions or uses X11 types that
have no meaning on Wayland (GC, XCreateGC, XInternAtom, etc.).
3. Wrap the block:
```c
if (scr->display) {
// ... existing X11 code unchanged ...
}
```
Where `scr` is the `W_Screen*` in scope. Find it via:
- Direct variable `scr` or `scrPtr`
- `view->screen`
- `WMWidgetScreen(widget)`
4. If the Wayland backend needs equivalent behavior (e.g., the code creates
cursors or interns atoms), add an `else` block that calls the appropriate
backend vtable:
```c
if (scr->display) {
// X11 path
} else {
// Wayland path — use scr->viewBackend->*() or scr->renderBackend->*()
}
```
If no Wayland equivalent is needed (e.g., GC creation), the `else` is omitted.
VERIFICATION:
- The code compiles.
- Running with `WMAKER_USE_WAYLAND=1` does not crash in this code path (the
X11 block is skipped).
CONSTRAINTS:
- Do NOT move the code to a separate file. This template is for cases where
the X11 code is small (< 50 lines) and inline guarding is cleaner than a split.
- Do NOT delete the X11 code. It must continue to work for the X11 backend.
- The guard condition is always `if (scr->display)`, never `#ifdef WAYLAND`.
```
## Reference Tables (embed in every prompt)
### X11 Event Type → WMEvent Type
```
KeyPress/KeyRelease → WME_KEY_PRESS/WME_KEY_RELEASE → event->u.key.*
ButtonPress/ButtonRelease → WME_BUTTON_PRESS/WME_BUTTON_RELEASE → event->u.button.*
MotionNotify → WME_MOTION → event->u.motion.*
EnterNotify/LeaveNotify → WME_ENTER/WME_LEAVE → event->u.crossing.*
Expose → WME_EXPOSE → event->u.expose.*
ConfigureNotify → WME_CONFIGURE → event->u.configure.*
ConfigureRequest → WME_CONFIGURE_REQUEST → event->u.configureRequest.*
MapNotify → WME_MAP → event->u.lifecycle.*
MapRequest → WME_MAP_REQUEST → event->u.mapRequest.*
UnmapNotify → WME_UNMAP → event->u.lifecycle.*
DestroyNotify → WME_DESTROY → event->u.lifecycle.*
FocusIn/FocusOut → WME_FOCUS_IN/WME_FOCUS_OUT → event->u.focus.*
PropertyNotify → WME_PROPERTY → event->u.property.*
ClientMessage → WME_CLIENT_MESSAGE → event->u.clientMessage.*
SelectionNotify → WME_SELECTION → event->u.selection.*
SelectionRequest → WME_SELECTION_REQUEST → event->u.selection.* (check)
SelectionClear → WME_SELECTION_CLEAR → event->u.selection.* (check)
VisibilityNotify → WME_VISIBILITY → event->u.visibility.*
ColormapNotify → WME_COLORMAP → event->u.colormap.*
MappingNotify → WME_MAPPING → event->u.mapping.*
ReparentNotify → WME_REPARENT → event->u.reparent.*
```
### X11 Event Field → WMEvent Field
```
event->xkey.keycode → event->u.key.keycode
event->xkey.state → event->u.key.state
event->xkey.time → event->u.key.time
event->xkey.window → event->u.key.window
event->xkey.x, y → event->u.key.x, y
event->xkey.x_root → event->u.key.x_root
event->xbutton.button → event->u.button.button
event->xbutton.state → event->u.button.state
event->xbutton.time → event->u.button.time
event->xbutton.window → event->u.button.window
event->xbutton.x, y → event->u.button.x, y
event->xbutton.x_root → event->u.button.x_root
event->xmotion.state → event->u.motion.state
event->xmotion.time → event->u.motion.time
event->xmotion.window → event->u.motion.window
event->xmotion.x, y → event->u.motion.x, y
event->xmotion.x_root → event->u.motion.x_root
event->xcrossing.window → event->u.crossing.window
event->xcrossing.state → event->u.crossing.state
event->xcrossing.time → event->u.crossing.time
event->xcrossing.mode → event->u.crossing.mode
event->xcrossing.detail → event->u.crossing.detail
event->xconfigure.window → event->u.configure.window
event->xconfigure.x, y → event->u.configure.x, y
event->xconfigure.width → event->u.configure.width
event->xconfigure.height → event->u.configure.height
event->xclient.data.l[N] → event->u.clientMessage.data.l[N]
event->xclient.message_type → event->u.clientMessage.atom
event->xclient.window → event->u.clientMessage.window
event->xproperty.atom → event->u.property.atom
event->xproperty.time → event->u.property.time
event->xproperty.window → event->u.property.window
```
---
## Important Rules
1. Work in the git repository at /home/lkn/src/WindowMaker-0.96.0. Create a git branch named "port/F.5" before making changes.
2. Make exactly the changes described. No more, no less.
3. After making changes, verify with the grep commands in the template.
4. Attempt to compile with: cd /home/lkn/src/WindowMaker-0.96.0 && make -j$(nproc) 2>&1 | tail -30
5. If compilation fails, fix the errors. If you cannot fix them, revert and report.
6. If you hit a STOP condition (missing vtable slot, missing API), revert changes and report exactly what is missing.
7. When done, run: git add -A && git diff --cached --stat
8. Report the final status as one of:
- DONE: task completed, compiles clean
- STOP: blocked on <reason>
- FAIL: could not complete because <reason>
Line numbers in ACTION_PLAN.md may have drifted. Use grep to find current line numbers before editing.

View File

@ -71,7 +71,7 @@ libwraster_la_SOURCES += load_tiff.c
endif
if USE_XPM
libwraster_la_SOURCES += load_xpm.c
libwraster_la_SOURCES += load_xpm.c load_xpm_normalized.c
else
libwraster_la_SOURCES += load_xpm_normalized.c
endif

View File

@ -51,6 +51,7 @@ typedef enum {
RImage *RLoadPPM(const char *file);
RImage *RLoadXPM(RContext *context, const char *file);
RImage *RLoadXPMNormalized(RContext *context, const char *file);
#ifdef USE_TIFF
RImage *RLoadTIFF(const char *file, int index);

View File

@ -197,6 +197,9 @@ RImage *RLoadImage(RContext *context, const char *file, int index)
#endif
case IM_XPM:
if (context->dpy == NULL)
image = RLoadXPMNormalized(context, file);
else
image = RLoadXPM(context, file);
break;

View File

@ -70,6 +70,7 @@ static void free_color_symbol_table(unsigned char *color_table[],
free(symbol_table);
}
#ifndef USE_XPM
RImage *RGetImageFromXPMData(RContext * context, char **data)
{
RImage *image = NULL;
@ -234,8 +235,9 @@ RImage *RGetImageFromXPMData(RContext * context, char **data)
RReleaseImage(image);
return NULL;
}
#endif /* !USE_XPM */
RImage *RLoadXPM(RContext * context, const char *file)
RImage *RLoadXPMNormalized(RContext * context, const char *file)
{
RImage *image = NULL;
char line[LINEWIDTH + 1];