-
Notifications
You must be signed in to change notification settings - Fork 9
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
Finish tinywl. #5
base: master
Are you sure you want to change the base?
Changes from 104 commits
6d6e75f
87af175
e11ecb5
1d16d8f
f726517
1925924
0d8e5d4
c9a39be
01d3222
0770122
aa7c61b
3ac5ce5
b2bdb00
a5f7978
ddb0f28
b72fc83
ed6953d
eff3a34
f228aa0
97752b3
5e1e2dc
321482c
51e4770
7063ea6
0477c1a
2a17b40
1a4089a
9f49b2e
b8194af
b4503e1
883195b
7a5efa2
5c8627a
046fa8f
f507fba
0c8865c
d63becb
b6e41ad
492a38e
f812bdc
16dde28
9fd4ed0
9d30693
4d7409b
84e4812
6a50824
9bb93e0
dda4e27
cbeb048
7420b87
26e8854
3d338fc
0309baf
05ad4a1
0b2a5f1
23b8b9a
e0d9302
c8b571e
0349b37
757d53d
0611f49
d2d3a16
1ea917b
224e614
8d07b27
88cf008
17ebc7a
69d547c
60301e1
80ccc9b
57e3ffa
01cc9ba
4b0c834
2d7deac
fefa49b
d706005
1dc5bb1
fc34992
743196f
71d4e5a
d09affe
3010ad2
ad2500e
248451c
704faac
b95bc3c
8e3a5f0
a565a8f
0b8b28b
880999f
4b8dbf5
c36922b
38a0a81
7504fe9
03bd566
d8971b8
41ea0e4
c0a8c27
57bcbf9
55bcc65
935fb94
19f7318
a27d884
586c96b
37f84cd
fd22f9c
a8dee0b
a0568b0
a5a92a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,10 @@ struct | |
|
||
let wl_resource_p = ptr Wl_resource.t | ||
|
||
(* wl_output_transform *) | ||
|
||
let wl_output_transform = Wl_output_transform.t | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would drop the alias here (it's not adding anything) and directly use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
|
||
(* wlr_output_mode *) | ||
|
||
let wlr_output_mode_p = ptr Output_mode.t | ||
|
@@ -130,6 +134,17 @@ struct | |
let wlr_output_enable = foreign "wlr_output_enable" | ||
(wlr_output_p @-> bool @-> returning void) | ||
|
||
let wlr_output_effective_resolution = foreign "wlr_output_effective_resolution" | ||
(wlr_output_p @-> ptr int @-> ptr int @-> returning void) | ||
|
||
let wlr_output_transform_invert = foreign "wlr_output_transform_invert" | ||
(wl_output_transform @-> returning wl_output_transform) | ||
|
||
let wlr_output_render_software_cursors = foreign "wlr_output_render_software_cursors" | ||
(* FIXME: The void pointer is a pixman_region32_t for which no bindings exist (yet). | ||
This is only ok because so far, no one uses it. *) | ||
(wlr_output_p @-> ptr void @-> returning void) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would instead add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
|
||
(* wlr_output_layout *) | ||
|
||
let wlr_output_layout_p = ptr Output_layout.t | ||
|
@@ -140,6 +155,9 @@ struct | |
let wlr_output_layout_add_auto = foreign "wlr_output_layout_add_auto" | ||
(wlr_output_layout_p @-> wlr_output_p @-> returning void) | ||
|
||
let wlr_output_layout_output_coords = foreign "wlr_output_layout_output_coords" | ||
(wlr_output_layout_p @-> wlr_output_p @-> ptr double @-> ptr double @-> returning void) | ||
|
||
(* wlr_box *) | ||
|
||
let wlr_box_p = ptr Box.t | ||
|
@@ -169,6 +187,9 @@ struct | |
let wlr_surface_send_frame_done = foreign "wlr_surface_send_frame_done" | ||
(wlr_surface_p @-> time @-> returning void) | ||
|
||
let wlr_surface_get_texture = foreign "wlr_surface_get_texture" | ||
(wlr_surface_p @-> returning wlr_texture_p) | ||
|
||
(* wlr_renderer *) | ||
|
||
let wlr_renderer_p = ptr Renderer.t | ||
|
@@ -185,13 +206,24 @@ struct | |
let wlr_renderer_init_wl_display = foreign "wlr_renderer_init_wl_display" | ||
(wlr_renderer_p @-> wl_display_p @-> returning bool) | ||
|
||
let wlr_render_texture_with_matrix = foreign "wlr_render_texture_with_matrix" | ||
(wlr_renderer_p @-> wlr_texture_p @-> ptr double @-> double @-> returning bool) | ||
|
||
(* wlr_keyboard *) | ||
|
||
let wlr_keyboard_p = ptr Keyboard.t | ||
|
||
let wlr_keyboard_set_keymap = foreign "wlr_keyboard_set_keymap" | ||
(wlr_keyboard_p @-> Xkbcommon.Keymap.t @-> returning bool) | ||
|
||
let wlr_keyboard_modifiers_p = ptr Keyboard_modifiers.t | ||
|
||
let wlr_keyboard_set_repeat_info = foreign "wlr_keyboard_set_repeat_info" | ||
(wlr_keyboard_p @-> int32_t @-> int32_t @-> returning void) | ||
|
||
let wlr_keyboard_get_modifiers = foreign "wlr_keyboard_get_modifiers" | ||
(wlr_keyboard_p @-> returning uint32_t) | ||
|
||
(* wlr_backend *) | ||
|
||
let wlr_backend_p = ptr Backend.t | ||
|
@@ -229,6 +261,33 @@ struct | |
let wlr_xdg_shell_create = foreign "wlr_xdg_shell_create" | ||
(wl_display_p @-> returning wlr_xdg_shell_p) | ||
|
||
(* wlr_xdg_surface *) | ||
|
||
let wlr_xdg_surface_p = ptr Xdg_surface.t | ||
|
||
let wlr_surface_is_xdg_surface = foreign "wlr_surface_is_xdg_surface" | ||
(wlr_surface_p @-> returning bool) | ||
|
||
let wlr_xdg_surface_from_wlr_surface = foreign "wlr_xdg_surface_from_wlr_surface" | ||
(wlr_surface_p @-> returning wlr_xdg_surface_p) | ||
|
||
let wlr_xdg_surface_get_geometry = foreign "wlr_xdg_surface_get_geometry" | ||
(wlr_xdg_surface_p @-> wlr_box_p @-> returning void) | ||
|
||
let wlr_xdg_surface_surface_at = foreign "wlr_xdg_surface_surface_at" | ||
(wlr_xdg_surface_p @-> double @-> double @-> ptr double @-> ptr double @-> returning wlr_surface_p) | ||
|
||
let wlr_xdg_surface_for_each_surface = foreign "wlr_xdg_surface_for_each_surface" | ||
(wlr_xdg_surface_p @-> Surface.wlr_surface_iterator_func_t @-> ptr void @-> returning void) | ||
|
||
(* wlr_xdg_toplevel *) | ||
|
||
let wlr_xdg_toplevel_set_activated = foreign "wlr_xdg_toplevel_set_activated" | ||
(wlr_xdg_surface_p @-> bool @-> returning uint32_t) | ||
|
||
let wlr_xdg_toplevel_set_size = foreign "wlr_xdg_toplevel_set_size" | ||
(wlr_xdg_surface_p @-> int @-> int @-> returning uint32_t) | ||
|
||
(* wlr_input_device *) | ||
|
||
let wlr_input_device_p = ptr Input_device.t | ||
|
@@ -252,6 +311,13 @@ struct | |
foreign "wlr_cursor_set_surface" | ||
(wlr_cursor_p @-> wlr_surface_p @-> int @-> int @-> returning void) | ||
|
||
let wlr_cursor_move = | ||
foreign "wlr_cursor_move" | ||
(wlr_cursor_p @-> wlr_input_device_p @-> double @-> double @-> returning void) | ||
|
||
let wlr_cursor_warp_absolute = foreign "wlr_cursor_warp_absolute" | ||
(wlr_cursor_p @-> wlr_input_device_p @-> double @-> double @-> returning void) | ||
|
||
(* wlr_xcursor_manager *) | ||
|
||
let wlr_xcursor_manager_p = ptr Xcursor_manager.t | ||
|
@@ -262,6 +328,9 @@ struct | |
let wlr_xcursor_manager_load = foreign "wlr_xcursor_manager_load" | ||
(wlr_xcursor_manager_p @-> float @-> returning int) | ||
|
||
let wlr_xcursor_manager_set_cursor_image = foreign "wlr_xcursor_manager_set_cursor_image" | ||
(wlr_xcursor_manager_p @-> string @-> wlr_cursor_p @-> returning void) | ||
|
||
(* wlr_seat *) | ||
|
||
let wlr_seat_p = ptr Seat.t | ||
|
@@ -272,6 +341,47 @@ struct | |
let wlr_seat_set_capabilities = foreign "wlr_seat_set_capabilities" | ||
(wlr_seat_p @-> Wl_seat_capability.t @-> returning void) | ||
|
||
let wlr_seat_set_keyboard = foreign "wlr_seat_set_keyboard" | ||
(wlr_seat_p @-> wlr_input_device_p @-> returning void) | ||
|
||
let wlr_seat_keyboard_notify_modifiers = foreign "wlr_seat_keyboard_notify_modifiers" | ||
(wlr_seat_p @-> wlr_keyboard_modifiers_p @-> returning void) | ||
|
||
let wlr_seat_keyboard_notify_enter = foreign "wlr_seat_keyboard_notify_enter" | ||
(wlr_seat_p | ||
@-> wlr_surface_p | ||
@-> Keycodes.t | ||
@-> size_t | ||
@-> wlr_keyboard_modifiers_p | ||
@-> returning void) | ||
|
||
let wlr_seat_keyboard_notify_key = foreign "wlr_seat_keyboard_notify_key" | ||
(wlr_seat_p @-> uint32_t @-> uint32_t @-> uint32_t @-> returning void) | ||
|
||
let wlr_seat_pointer_notify_enter = foreign "wlr_seat_pointer_notify_enter" | ||
(wlr_seat_p @-> wlr_surface_p @-> double @-> double @-> returning void) | ||
|
||
let wlr_seat_pointer_clear_focus = foreign "wlr_seat_pointer_clear_focus" | ||
(wlr_seat_p @-> returning void) | ||
|
||
let wlr_seat_pointer_notify_motion = foreign "wlr_seat_pointer_notify_motion" | ||
(wlr_seat_p @-> uint32_t @-> double @-> double @-> returning void) | ||
|
||
let wlr_seat_pointer_notify_button = foreign "wlr_seat_pointer_notify_button" | ||
(wlr_seat_p @-> uint32_t @-> uint32_t @-> Button_state.t @-> returning uint32_t) | ||
|
||
let wlr_seat_pointer_notify_axis = foreign "wlr_seat_pointer_notify_axis" | ||
(wlr_seat_p | ||
@-> uint32_t | ||
@-> Axis_orientation.t | ||
@-> double | ||
@-> int32_t | ||
@-> Axis_source.t | ||
@-> returning void) | ||
|
||
let wlr_seat_pointer_notify_frame = foreign "wlr_seat_pointer_notify_frame" | ||
(wlr_seat_p @-> returning void) | ||
|
||
(* wlr_log *) | ||
|
||
(* TODO *) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,33 +7,40 @@ module Types = Wlroots_ffi_f.Ffi.Types | |
type t = Types.Cursor.t ptr | ||
include Ptr | ||
|
||
let x = getfield Types.Cursor.x | ||
let y = getfield Types.Cursor.y | ||
|
||
|
||
let create = Bindings.wlr_cursor_create | ||
let attach_output_layout = Bindings.wlr_cursor_attach_output_layout | ||
let attach_input_device = Bindings.wlr_cursor_attach_input_device | ||
let set_surface = Bindings.wlr_cursor_set_surface | ||
let move = Bindings.wlr_cursor_move | ||
|
||
let signal_motion (cursor: t) : Pointer.Event_motion.t Wl.Signal.t = { | ||
let signal_motion (cursor: t) : Event_pointer_motion.t Wl.Signal.t = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why move these to external modules? The naming convention I was trying to follow (and that also appears with Keyboard.Event_key for example) is that if there's a wlr_foo.h, then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we did this because we were struggling to learn the module system. We can definitely use a different convention. I was kind of hoping to move events to submodules as a convention, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in any case each event type needs to have its own module (so it can include its compare/hash function for example), so it would have to be |
||
c = cursor |-> Types.Cursor.events_motion; | ||
typ = Pointer.Event_motion.t; | ||
typ = Event_pointer_motion.t; | ||
} | ||
|
||
let signal_motion_absolute (cursor: t) : | ||
Pointer.Event_motion_absolute.t Wl.Signal.t = { | ||
Event_pointer_motion_absolute.t Wl.Signal.t = { | ||
c = cursor |-> Types.Cursor.events_motion_absolute; | ||
typ = Pointer.Event_motion_absolute.t; | ||
typ = Event_pointer_motion_absolute.t; | ||
} | ||
|
||
let signal_button (cursor: t) : Pointer.Event_button.t Wl.Signal.t = { | ||
let signal_button (cursor: t) : Event_pointer_button.t Wl.Signal.t = { | ||
c = cursor |-> Types.Cursor.events_button; | ||
typ = Pointer.Event_button.t; | ||
typ = Event_pointer_button.t; | ||
} | ||
|
||
let signal_axis (cursor: t) : Pointer.Event_axis.t Wl.Signal.t = { | ||
let signal_axis (cursor: t) : Event_pointer_axis.t Wl.Signal.t = { | ||
c = cursor |-> Types.Cursor.events_axis; | ||
typ = Pointer.Event_axis.t; | ||
typ = Event_pointer_axis.t; | ||
} | ||
|
||
let signal_frame (cursor: t) : unit Wl.Signal.t = { | ||
c = cursor |-> Types.Cursor.events_frame; | ||
typ = void; | ||
} | ||
|
||
let warp_absolute = Bindings.wlr_cursor_warp_absolute |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
open Ctypes | ||
open Wlroots_common.Utils | ||
|
||
module Bindings = Wlroots_ffi_f.Ffi.Make (Generated_ffi) | ||
module Types = Wlroots_ffi_f.Ffi.Types | ||
|
||
type edges = None | Top | Bottom | Left | Right | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but we wanted to stick to the names from wlroots. I think it is defined as enum wlr_edges {
WLR_EDGE_NONE = 0,
WLR_EDGE_TOP = 1 << 0,
WLR_EDGE_BOTTOM = 1 << 1,
WLR_EDGE_LEFT = 1 << 2,
WLR_EDGE_RIGHT = 1 << 3,
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. I still think that in ocaml it would be more natural to have the type named |
||
type t = edges list | ||
include Poly | ||
|
||
let t : edges list typ = | ||
bitwise_enum32 Types.Edges.([ | ||
None, _WLR_EDGE_NONE; | ||
Top, _WLR_EDGE_TOP; | ||
Bottom, _WLR_EDGE_BOTTOM; | ||
Right, _WLR_EDGE_RIGHT; | ||
Left, _WLR_EDGE_LEFT; | ||
]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
open Ctypes | ||
open Wlroots_common.Utils | ||
|
||
module Bindings = Wlroots_ffi_f.Ffi.Make (Generated_ffi) | ||
module Types = Wlroots_ffi_f.Ffi.Types | ||
|
||
type t = Types.Event_pointer_axis.t ptr | ||
let t = ptr Types.Event_pointer_axis.t | ||
include Ptr | ||
|
||
let time_msec = getfield Types.Event_pointer_axis.time_msec | ||
let orientation = getfield Types.Event_pointer_axis.orientation | ||
let delta = getfield Types.Event_pointer_axis.delta | ||
let delta_discrete = getfield Types.Event_pointer_axis.delta_discrete | ||
let source = getfield Types.Event_pointer_axis.source |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Ctypes | ||
open Wlroots_common.Utils | ||
|
||
module Bindings = Wlroots_ffi_f.Ffi.Make (Generated_ffi) | ||
module Types = Wlroots_ffi_f.Ffi.Types | ||
|
||
type t = Types.Event_pointer_button.t ptr | ||
let t = ptr Types.Event_pointer_button.t | ||
include Ptr | ||
|
||
let time_msec = getfield Types.Event_pointer_button.time_msec | ||
let button = getfield Types.Event_pointer_button.button | ||
let state = getfield Types.Event_pointer_button.state |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
open Ctypes | ||
open Wlroots_common.Utils | ||
|
||
module Bindings = Wlroots_ffi_f.Ffi.Make (Generated_ffi) | ||
module Types = Wlroots_ffi_f.Ffi.Types | ||
|
||
type t = Types.Event_pointer_motion.t ptr | ||
let t = ptr Types.Event_pointer_motion.t | ||
include Ptr | ||
|
||
let device = getfield Types.Event_pointer_motion.device | ||
let time_msec = getfield Types.Event_pointer_motion.time_msec | ||
let delta_x = getfield Types.Event_pointer_motion.delta_x | ||
let delta_y = getfield Types.Event_pointer_motion.delta_y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
open Ctypes | ||
open Wlroots_common.Utils | ||
|
||
module Bindings = Wlroots_ffi_f.Ffi.Make (Generated_ffi) | ||
module Types = Wlroots_ffi_f.Ffi.Types | ||
|
||
type t = Types.Event_pointer_motion_absolute.t ptr | ||
let t = ptr Types.Event_pointer_motion_absolute.t | ||
include Ptr | ||
|
||
let device = getfield Types.Event_pointer_motion_absolute.device | ||
let x = getfield Types.Event_pointer_motion_absolute.x | ||
let y = getfield Types.Event_pointer_motion_absolute.y | ||
let time_msec = getfield Types.Event_pointer_motion_absolute.time_msec |
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.
When should we use
bitwise_enum32
instead ofbitwise_enum
?After a quick google search it looks like it's not terribly well specified which size enums should have; that they fit in a uint32_t is probably a good conservative assumption. However
enum
from ctypes assumes int64 values so this is probably fine as well?In any case I would make a choice and either get rid of
bitwise_enum
or ofbitwise_enum32
.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.
Ah yeah, this was because the
edges
field of thewlr_xdg_toplevel_resize_event
is auint32_t
here https://github.com/swaywm/wlroots/blob/84dea55b20b60c229a5e31ccd37b58c96cba611a/include/wlr/types/wlr_xdg_shell.h#L224:Which is used in
begin_interactive
in tinywl https://github.com/swaywm/wlroots/blob/475d9701e21e5047ee9d7e56909762c1eb961fcd/tinywl/tinywl.c#L723:I wonder if this is an upstream issue.
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.
Another related question: Should
bitwise_enum
be defined in terms ofint64
instead ofuint64_t
? (due to the underspecified nature of enum sizes)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.
Thanks for the details. Then I agree that sticking to the C api and avoiding any integer casts is best. In that case it makes sense to have both
bitwise_enum
andbitwise_enum32
.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.
Would it be possible to use a functor to parameterize the
type of uintsize of the enum members?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 just pushed a WIP commit with a functor for bitwise enums. It does change uint64 to int64 where the unsigned version was used.