-
Notifications
You must be signed in to change notification settings - Fork 5
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
Expand X Render extension to be able to composite windows onto one another #11
base: master
Are you sure you want to change the base?
Expand X Render extension to be able to composite windows onto one another #11
Conversation
@@ -184,15 +222,17 @@ pub fn main() !u8 { | |||
} | |||
|
|||
const double_buf = try x.DoubleBuffer.init( | |||
std.mem.alignForward(usize, 1000, std.mem.page_size), | |||
std.mem.alignForward(usize, 8000, std.mem.page_size), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumped to 8000
because the query_pict_formats
response is big (4888
bytes on my system)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a few comments but overall the changes look reasonable and really cool functionality you've added!
|
||
const font_dims: FontDims = blk: { | ||
_ = try x.readOneMsg(conn.reader(), @alignCast(buf.nextReadBuffer())); | ||
const message_length = try x.readOneMsg(conn.reader(), @alignCast(buf.nextReadBuffer())); | ||
try checkMessageLengthFitsInBuffer(message_length, buffer_limit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by this. Doesn't nextReadBuffer
already limit the buffer to the maximum length? If not maybe that's a footgun that should be fixed? If we have to add an extra check after reading into a buffer in order to use it correctly, seems like there's a bigger underlying issue that needs addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what the doc comment suggests:
Lines 2541 to 2545 in 74ffbcb
/// The caller must check whether the length returned is larger than the provided `buf`. | |
/// If it is, then only the first 32-bytes have been read. The caller can allocate a new | |
/// buffer large enough to accomodate and finish reading the message by copying the first | |
/// 32 bytes to the new buffer then calling `readOneMsgFinish`. | |
pub fn readOneMsg(reader: anytype, buf: []align(4) u8) !u32 { |
Expand X Render extension to be able to composite windows (or any "picture") onto one another.
Adds to the X Render extension
xrender.zig
:query_pict_formats
: Find matching picture formats in order to create a picturecreate_picture
: Create a picture from any drawable (like a window or pixmap) for use with the X Render extensioncomposite
: Composite those created pictures together with a variety of operationsTesting strategy
Notice a small 100x100 snapshot of the root window is copied to our window
Why use
composite
overcopy_area
?When dealing with a normal default situation where our window just inherits 24-bit color depth from the root window, you could also just use the
copy_area
command for this kind of functionality. Butcopy_area
does not work when there is a depth mismatch, like when you change your window to 32-bit depth for transparency and try to copy from the 24-bit root window. For an example of this, see MadLittleMods/fps-aim-analyzer#5Dev notes