Skip to content

Commit

Permalink
Store screen info (xcb_screen_t) in XCBWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
serenity4 committed Oct 20, 2024
1 parent 32cb0b5 commit 0557eaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/testing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function event_xcb(wm::XWindowManager, e::Event)
T === xcb_configure_notify_event_t && return T(response_type_xcb(e), 0, 0, e.win.id, e.win.id, 0, x, y, wx, wy, 0, 0, 0)
T === xcb_focus_in_event_t && return T(response_type_xcb(e), detail_xcb(wm, e), 0, e.win.id, 0, (0, 0, 0))
e.type == WINDOW_CLOSED && return T(response_type_xcb(e), 32, 0, e.win.id, 0x00000183, xcb_client_message_data_t(serialize_delete_request_data(e.win.delete_request)))
T(response_type_xcb(e), detail_xcb(wm, e), 0, 0, e.win.parent_id, e.win.id, 0, 0, 0, x, y, state_xcb(e), true, false)
T(response_type_xcb(e), detail_xcb(wm, e), 0, 0, e.win.screen.root, e.win.id, 0, 0, 0, x, y, state_xcb(e), true, false)
end

send_event(wm::XWindowManager, e::Event) = send_event(e.win, event_xcb(wm, e))
Expand Down
18 changes: 6 additions & 12 deletions src/window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,32 @@ Window type used with the XCB API.
mutable struct XCBWindow <: AbstractWindow
conn::Connection
id::xcb_window_t
parent_id::xcb_window_t
visual_id::xcb_visualid_t
screen::xcb_screen_t
delete_request::xcb_atom_t
gc::Union{Nothing,GraphicsContext}
end

"""
Create a new window whose parent is given by `parent_id` and visual by `visual_id`.
Create a new window on the provided `screen`.
"""
function XCBWindow(conn, parent_id, visual_id; depth=XCB_COPY_FROM_PARENT, x=0, y=0, width=512, height=512, border_width=1, class=XCB_WINDOW_CLASS_INPUT_OUTPUT, window_title="", icon_title=nothing, map=true, attributes=[], values=[])
function XCBWindow(conn, screen::xcb_screen_t; depth=XCB_COPY_FROM_PARENT, x=0, y=0, width=512, height=512, border_width=1, class=XCB_WINDOW_CLASS_INPUT_OUTPUT, window_title="", icon_title=nothing, map=true, attributes=[], values=[])
win_id = xcb_generate_id(conn)
xcb_create_window(
conn,
depth,
win_id,
parent_id,
screen.root,
x,
y,
width,
height,
border_width,
class,
visual_id,
screen.root_visual,
0,
C_NULL,
)
win = XCBWindow(conn, win_id, parent_id, visual_id, delete_request(conn, win_id), nothing)
win = XCBWindow(conn, win_id, screen, delete_request(conn, win_id), nothing)

set_event_mask(win, keys(event_type_bits))
set_attributes(win, attributes, values)
Expand All @@ -44,11 +43,6 @@ function XCBWindow(conn, parent_id, visual_id; depth=XCB_COPY_FROM_PARENT, x=0,
Base.finalizer(x -> @check(:error, xcb_destroy_window(x.conn, x.id)), win)
end

"""
Create a new window on the provided `screen`.
"""
XCBWindow(conn::Connection, screen; kwargs...) = XCBWindow(conn, screen.root, screen.root_visual; kwargs...)

"""
Create a new window on the current screen.
"""
Expand Down

0 comments on commit 0557eaf

Please sign in to comment.