Skip to content

modesetting: Move cursor_up into the cursor struct.#1855

Open
notbabaisyou wants to merge 1 commit intoX11Libre:masterfrom
notbabaisyou:cursor-nit
Open

modesetting: Move cursor_up into the cursor struct.#1855
notbabaisyou wants to merge 1 commit intoX11Libre:masterfrom
notbabaisyou:cursor-nit

Conversation

@notbabaisyou
Copy link
Contributor

Currently the drmmode_cursor_rec has a 6-byte hole in the middle of it like this:

   num_dimensions (2 bytes)
   ------ unused 6 bytes on 64-bit platforms
   drmmode_cursor_dim_rec* (pointer)
   struct dumb_bo *bo (pointer)

Mitigate this by moving the cursor_up boolean into the struct itself.

While we're at it use drmmode_cursor more in drmmode_load_cursor_argb_check.

Currently the drmmode_cursor_rec has a 6-byte hole in the middle of it like this:

```
   num_dimensions (2 bytes)
   ------ unused 6 bytes on 64-bit platforms
   drmmode_cursor_dim_rec* (pointer)
   struct dumb_bo *bo (pointer)
```

Mitigate this by moving the cursor_up boolean into the struct itself.

While we're at it use drmmode_cursor more in drmmode_load_cursor_argb_check.

Signed-off-by: notbabaisyou <though-went-some-simple@proton.me>

typedef struct {
uint16_t num_dimensions;
Bool up;
Copy link

@Petricak-1982 Petricak-1982 Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not much familiar with C, but watching xlibre for some time to notice that @metux replaced some Bool occurrences with standard bool. Maybe it's good idea to follow this guideline for new code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bool is just an integer, but using aligned sizes tends to be faster than doing byte or bit operations, especially on older platforms, plus we have some guarantees about atomicity.

Using a true boolean would still leave a large gap within the struct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got your point, thanks for explanation. So far I was coding mostly in Python, seeing C++ only few months on university almost two decades ago. Trying to watch your work and learn a bit, but so far I don't dare to write any code like you do. Thanks for your patience with my silly question and all the best for whole Xlibre team.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For new code I'd really prefer stdbool. In the future I'd like to get rid of Xorg's Bool type (different from BOOL protocol type) as much as possible.

@github-actions
Copy link

Merge Conflict found

3 similar comments
@github-actions
Copy link

Merge Conflict found

@github-actions
Copy link

Merge Conflict found

@github-actions
Copy link

Merge Conflict found

@metux
Copy link
Contributor

metux commented Feb 2, 2026

@notbabaisyou needs rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants