-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making the window transparent (X Window System, X11) #1
Comments
I can't quite figure out where I am going wrong in all of the pointer arithmetic. Without the sanity checks, I constantly run into I pulled the offending code out of From the output, you can see the the first $ zig run x11-flexible-array-member-parsing.zig
release_number: 12101008
resource_id_base: 396361728
resource_id_mask: 2097151
motion_buffer_size: 256
vendor_len: 20
max_request_len: 65535
root_screen_count: 1
format_count: 7
image_byte_order: x11-flexible-array-member-parsing.ConnectSetup.Fixed.ImageByteOrder.lsb_first
bitmap_format_bit_order: 0
bitmap_format_scanline_unit: 32
bitmap_format_scanline_pad: 32
min_keycode: 8
max_keycode: 255
unused: 0
debug: asdf allowed_depth_count 7
debug: asdf SCREENDEPTH | depth: 24
debug: asdf SCREENDEPTH | unused0: 0
debug: asdf SCREENDEPTH | visual_type_count: 480
debug: asdf SCREENDEPTH | unused1: 0
debug: asdf SCREENDEPTH | _visual_types_array_start: { x11-flexible-array-member-parsing.VisualType{ .id = 33, .class = x11-flexible-array-member-parsing.VisualType.Class.true_color, .bits_per_rgb_value = 8, .colormap_entries = 256, .red_mask = 16711680, .green_mask = 65280, .blue_mask = 255, .unused = 0 } }
debug: visual count 480, pointer_offset += 11528
debug: asdf SCREENDEPTH | depth: 0
debug: asdf SCREENDEPTH | unused0: 0
debug: asdf SCREENDEPTH | visual_type_count: 255
debug: asdf SCREENDEPTH | unused1: 65280
debug: asdf SCREENDEPTH | _visual_types_array_start: { x11-flexible-array-member-parsing.VisualType{ .id = 255, .class = x11-flexible-array-member-parsing.VisualType.Class.static_gray, .bits_per_rgb_value = 0, .colormap_entries = 0, .red_mask = 1910, .green_mask = 16779269, .blue_mask = 16711680, .unused = 65280 } }
debug: visual count 255, pointer_offset += 6128
debug: asdf SCREENDEPTH | depth: 58
debug: asdf SCREENDEPTH | unused0: 47
debug: asdf SCREENDEPTH | visual_type_count: 26978
debug: asdf SCREENDEPTH | unused1: 1966029422
debug: asdf SCREENDEPTH | _visual_types_array_start: { x11-flexible-array-member-parsing.VisualType{ .id = 1815048819, .class = x11-flexible-array-member-parsing.VisualType.Class.thread 169494 panic: invalid enum value
/home/eric/.zvm/0.11.0/lib/std/fmt.zig:527:37: 0x298d2a in formatType__anon_10664 (x11-flexible-array-member-parsing)
try writer.writeAll(@tagName(value));
^
/home/eric/.zvm/0.11.0/lib/std/fmt.zig:596:31: 0x289ad9 in formatType__anon_10483 (x11-flexible-array-member-parsing)
try formatType(@field(value, f.name), ANY, options, writer, max_depth - 1);
^
/home/eric/.zvm/0.11.0/lib/std/fmt.zig:688:31: 0x27d807 in formatType__anon_10071 (x11-flexible-array-member-parsing)
try formatType(elem, actual_fmt, options, writer, max_depth - 1);
^
/home/eric/.zvm/0.11.0/lib/std/fmt.zig:184:23: 0x27d5ed in format__anon_10051 (x11-flexible-array-member-parsing)
try formatType(
^
/home/eric/.zvm/0.11.0/lib/std/io/writer.zig:28:34: 0x271560 in print__anon_9605 (x11-flexible-array-member-parsing)
return std.fmt.format(self, format, args);
^
/home/eric/.zvm/0.11.0/lib/std/log.zig:154:27: 0x25fe1d in defaultLog__anon_8294 (x11-flexible-array-member-parsing)
nosuspend stderr.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return;
^
/home/eric/.zvm/0.11.0/lib/std/log.zig:125:22: 0x230008 in log__anon_4826 (x11-flexible-array-member-parsing)
std.options.logFn(message_level, scope, format, args);
^
/home/eric/.zvm/0.11.0/lib/std/log.zig:197:16: 0x229dd8 in debug__anon_4076 (x11-flexible-array-member-parsing)
log(.debug, scope, format, args);
^
/home/eric/Documents/code/zig/random/x11-flexible-array-member-parsing/x11-flexible-array-member-parsing.zig:59:30: 0x2299de in getAllowedDepths (x11-flexible-array-member-parsing)
std.log.debug("asdf SCREENDEPTH | {s}: {any}", .{ field.name, @field(depth_ptr, field.name) });
^
/home/eric/Documents/code/zig/random/x11-flexible-array-member-parsing/x11-flexible-array-member-parsing.zig:299:55: 0x22a09a in getScreens (x11-flexible-array-member-parsing)
const depths = try screen.getAllowedDepths(allocator);
^
/home/eric/Documents/code/zig/random/x11-flexible-array-member-parsing/x11-flexible-array-member-parsing.zig:349:47: 0x22ae34 in main (x11-flexible-array-member-parsing)
var screens = try connect_setup.getScreens(allocator);
^
/home/eric/.zvm/0.11.0/lib/std/start.zig:574:37: 0x22705e in posixCallMainAndExit (x11-flexible-array-member-parsing)
const result = root.main() catch |err| {
^
/home/eric/.zvm/0.11.0/lib/std/start.zig:243:5: 0x226b41 in _start (x11-flexible-array-member-parsing)
asm volatile (switch (native_arch) {
^
???:?:?: 0x0 in ??? (???)
Aborted (core dumped) Another aspect I can't quite figure out is why the pointers don't line up. If I log something like the following, I'd expect the following but the math isn't adding up (perhaps this is an alignment thing?).
// asdf iterating through depth 0 - 140736350248287 vs 140736350248360 vs &self=140736350248392 &self.root=140736350248464 + 0 + 39 or 40 = 140736350248575 vs 140736350248648
std.log.debug("asdf iterating through depth {} - {} vs {} vs &self={} &self.root={} + {} + {} or {} = {} vs {}", .{
i,
@intFromPtr(&self.allowed_depth_count),
@intFromPtr(&self._allowed_depths_array_start),
@intFromPtr(&self),
@intFromPtr(&self.root),
@offsetOf(@TypeOf(self), "root"),
@offsetOf(@TypeOf(self), "allowed_depth_count"),
@offsetOf(@TypeOf(self), "_allowed_depths_array_start"),
@intFromPtr(&self) + @offsetOf(@TypeOf(self), "allowed_depth_count"),
@intFromPtr(&self) + @offsetOf(@TypeOf(self), "_allowed_depths_array_start"),
}); |
I figured it out! The problem boils down to Related post: https://zig.news/gowind/beware-the-copy-32l4 From the Zig docs:
|
Submitted a PR to parse the rest of the connection setup buffer to get the screens, depths, and visual types -> marler8997/zigx#8 |
Another PR to create and specify custom color maps marler8997/zigx#9 I was able to get transparency/alpha (32-bit color depth) working with both of these changes! #2 |
These are just notes I can share around on this problem. I haven't gotten this working yet.
Background
To make sure this isn't an X/Y problem, I'm trying to make the window background transparent but it's always just opaque even when giving it 32-bit colors(ARGB,
0xaabbccdd
). With a successful basic the window setup, we can set.parent_window_id = screen.root
,.depth = 0
(which means inherit from parent), and.visual_id = screen.root_visual
to get a opaque window showing on the screen. The reason it's 24-bit color-depth is because the root window is 24-bit depth and we inherit from the parent window. You can verify the color depth of the root window by running thexdpyinfo
command on your system (see the command output in the dev notes).When trying to provide
.depth = 32
but still using the same.visual_id
, we get amatch
error from the connection setup which is as expected according to the docs.So we need to find the correct matching
.visual_id
that has 32-bit color depth and allows us to do transparency.Problem
I'm trying to modify
zigx
to parse the following buffer of data that you get back when the connection is accepted during setup because it looks like it has the necessary info.There is already code that successfully parses up to and including the first screen but without the sub-lists of
ScreenDepths
orVisualType
. EachScreen
has manyScreenDepths
and eachScreenDepth
has manyVisualType
.Buffer structure (X11 protocol docs source):
How the problem is solved in other X11 client libraries
libx11
->src/OpenDis.c#L59-570
x11-client
->src/main/java/com/github/moaxcp/x11client/X11Connection.java#L34-L67
andsrc/main/xcbXmls/xproto.xml#L94-L267
Xlib/protocol/display.py#L1024-L1059
libxcb
breadx
x11rb
Keywords:
The text was updated successfully, but these errors were encountered: