#include #include {-| Module : Bindings.WLC.Core Description : Core WLC Copyright : (c) Ashley Towns 2016 License : BSD3 Maintainer : mail@ashleytowns.id.au Stability : experimental Portability : POSIX Provides bindings to the core WLC API. -} module Bindings.WLC.Core where #strict_import import Bindings.WLC.Defines import Bindings.WLC.Geometry #opaque_t wlc_event_source #opaque_t xkb_state #opaque_t xkb_keymap #opaque_t libinput_device -- |wlc_log(), wlc_vlog(); #integral_t enum wlc_log_type #num WLC_LOG_INFO #num WLC_LOG_WARN #num WLC_LOG_ERROR #num WLC_LOG_WAYLAND -- |wlc_get_backend_type(); #integral_t enum wlc_backend_type #num WLC_BACKEND_NONE #num WLC_BACKEND_DRM #num WLC_BACKEND_X11 -- |mask in wlc_event_loop_add_fd(); #integral_t enum wlc_event_bit #num WLC_EVENT_READABLE #num WLC_EVENT_WRITABLE #num WLC_EVENT_HANGUP #num WLC_EVENT_ERROR -- |wlc_view_get_state(); #integral_t enum wlc_view_state_bit #num WLC_BIT_MAXIMIZED #num WLC_BIT_FULLSCREEN #num WLC_BIT_RESIZING #num WLC_BIT_MOVING #num WLC_BIT_ACTIVATED -- |wlc_view_get_type(); #integral_t enum wlc_view_type_bit -- |Override redirect (x11) #num WLC_BIT_OVERRIDE_REDIRECT -- |Tooltips, DnD's, menus (x11) #num WLC_BIT_UNMANAGED -- |Splash screens (x11) #num WLC_BIT_SPLASH -- |Modal windows (x11) #num WLC_BIT_MODAL -- |xdg-shell, wl-shell popups #num WLC_BIT_POPUP -- |wlc_view_set_geometry(); Edges in interface interface.view.request.resize function. #integral_t enum wlc_resize_edge #num WLC_RESIZE_EDGE_NONE #num WLC_RESIZE_EDGE_TOP #num WLC_RESIZE_EDGE_BOTTOM #num WLC_RESIZE_EDGE_LEFT #num WLC_RESIZE_EDGE_TOP_LEFT #num WLC_RESIZE_EDGE_BOTTOM_LEFT #num WLC_RESIZE_EDGE_RIGHT #num WLC_RESIZE_EDGE_TOP_RIGHT #num WLC_RESIZE_EDGE_BOTTOM_RIGHT -- |Mods in interface.keyboard.key function. #integral_t enum wlc_modifier_bit #num WLC_BIT_MOD_SHIFT #num WLC_BIT_MOD_CAPS #num WLC_BIT_MOD_CTRL #num WLC_BIT_MOD_ALT #num WLC_BIT_MOD_MOD2 #num WLC_BIT_MOD_MOD3 #num WLC_BIT_MOD_LOGO #num WLC_BIT_MOD_MOD5 -- |Leds in interface.keyboard.key function. #integral_t enum wlc_led_bit #num WLC_BIT_LED_NUM #num WLC_BIT_LED_CAPS #num WLC_BIT_LED_SCROLL -- |State in interface.keyboard.key function. #integral_t enum wlc_key_state #num WLC_KEY_STATE_RELEASED #num WLC_KEY_STATE_PRESSED -- |State in interface.pointer.button function. #integral_t enum wlc_button_state #num WLC_BUTTON_STATE_RELEASED #num WLC_BUTTON_STATE_PRESSED -- |Axis in interface.pointer.scroll function. #integral_t enum wlc_scroll_axis_bit #num WLC_SCROLL_AXIS_VERTICAL #num WLC_SCROLL_AXIS_HORIZONTAL -- |Type in interface.touch.touch function #integral_t enum wlc_touch_type #num WLC_TOUCH_DOWN #num WLC_TOUCH_UP #num WLC_TOUCH_MOTION #num WLC_TOUCH_FRAME #num WLC_TOUCH_CANCEL -- |State of keyboard modifiers in various functions. #starttype struct wlc_modifiers #field leds, #field mods, #stoptype -- * Callback API -- ** Types -- *** Output #callback_t output_created_cb , -> IO Bool #callback_t output_destroyed_cb , -> IO () #callback_t output_focus_cb , -> Bool -> IO () #callback_t output_resolution_cb , -> Ptr -> Ptr -> IO () #callback_t output_render_pre_cb , -> IO () #callback_t output_render_post_cb , -> IO () -- *** View #callback_t view_created_cb , -> IO Bool #callback_t view_destroyed_cb , -> IO () #callback_t view_focus_cb , -> Bool -> IO () #callback_t view_move_to_output_cb , -> -> -> IO () #callback_t view_request_geometry_cb , -> Ptr -> IO () #callback_t view_request_state_cb , -> -> Bool -> IO () #callback_t view_request_move_cb , -> Ptr -> IO () #callback_t view_request_resize_cb , -> CUInt -> Ptr -> IO () #callback_t view_render_pre_cb , -> IO () #callback_t view_render_post_cb , -> IO () -- *** Input #callback_t keyboard_key_cb , -> CUInt -> Ptr -> CUInt -> -> IO Bool #callback_t pointer_button_cb , -> CUInt -> Ptr -> CUInt -> -> Ptr -> IO Bool #callback_t pointer_scroll_cb , -> CUInt -> Ptr -> -> Double -> IO Bool #callback_t pointer_motion_cb , -> CUInt -> Ptr -> IO Bool #callback_t touch_cb , -> CUInt -> Ptr -> -> CInt -> Ptr -> IO Bool -- *** Other #callback_t compositor_ready_cb , IO () #callback_t compositor_terminate_cb , IO () -- ** Functions -- *** Output -- |Output was created. Return false if you want to destroy the output. (e.g. failed to allocate data related to view) #ccall wlc_set_output_created_cb , -> IO () -- |Output was destroyed. #ccall wlc_set_output_destroyed_cb , -> IO () -- |Output got or lost focus. #ccall wlc_set_output_focus_cb , -> IO () -- |Output resolution changed. #ccall wlc_set_output_resolution_cb , -> IO () -- |Output pre render hook. #ccall wlc_set_output_render_pre_cb , -> IO () -- |Output post render hook. #ccall wlc_set_output_render_post_cb , -> IO () -- *** View -- |View was created. Return false if you want to destroy the view. (e.g. failed to allocate data related to view) #ccall wlc_set_view_created_cb , -> IO () -- |View was destroyed. #ccall wlc_set_view_destroyed_cb , -> IO () -- |View got or lost focus. #ccall wlc_set_view_focus_cb , -> IO () -- |View was moved to output. #ccall wlc_set_view_move_to_output_cb , -> IO () -- |Request to set given geometry for view. Apply using wlc_view_set_geometry to agree. #ccall wlc_set_view_request_geometry_cb , -> IO () -- |Request to disable or enable the given state for view. Apply using wlc_view_set_state to agree. #ccall wlc_set_view_request_state_cb , -> IO () -- |Request to move itself. Start a interactive move to agree. #ccall wlc_set_view_request_move_cb , -> IO () -- |Request to resize itself with the given edges. Start a interactive resize to agree. #ccall wlc_set_view_request_resize_cb , -> IO () -- |View pre render hook. #ccall wlc_set_view_render_pre_cb , -> IO () -- |View post render hook. #ccall wlc_set_view_render_post_cb , -> IO () -- *** Input -- |Key event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the -- event to clients. #ccall wlc_set_keyboard_key_cb , -> IO () -- |Button event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the -- event to clients. #ccall wlc_set_pointer_button_cb , -> IO () -- |Scroll event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the -- event to clients. #ccall wlc_set_pointer_scroll_cb , -> IO () -- |Motion event was triggered, view handle will be zero if there was no focus. Apply with wlc_pointer_set_position to -- agree. Return true to prevent sending the event to clients. #ccall wlc_set_pointer_motion_cb , -> IO () -- |Touch event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the -- event to clients. #ccall wlc_set_touch_cb , -> IO () -- *** Other -- |Compositor is ready to accept clients. #ccall wlc_set_compositor_ready_cb , -> IO () -- |Compositor is about to terminate #ccall wlc_set_compositor_terminate_cb , -> IO () -- * Core API -- |Creates a log handler callback #callback_t log_handler_cb , -> CString -> IO () -- |Set log handler. Can be set before wlc_init. #ccall wlc_log_set_handler , -> IO () -- |Initialize wlc. Returns false on failure. -- -- Avoid running unverified code before wlc_init as wlc compositor may be run with higher -- privileges on non logind systems where compositor binary needs to be suid. -- -- wlc_init's purpose is to initialize and drop privileges as soon as possible. -- -- Callbacks should be set using wlc_set_*_cb functions before calling wlc_init2, -- failing to do so will cause any callback the init may trigger to not be called. #ccall wlc_init2 , IO Bool -- |Terminate wlc. #ccall wlc_terminate , IO () -- |Query backend wlc is using. #ccall wlc_get_backend_type , IO -- |Exec program. #ccall wlc_exec , CString -> Ptr CString -> IO () -- |Run event loop. #ccall wlc_run , IO () -- |Link custom data to handle. #ccall wlc_handle_set_user_data , -> Ptr () -> IO () -- |Get linked custom data from handle. #ccall wlc_handle_get_user_data , -> IO (Ptr ()) -- * Output API -- |Get outputs. Returned array is a direct reference, careful when moving and destroying handles. #ccall wlc_get_outputs , Ptr CSize -> IO (Ptr ) -- |Get focused output. #ccall wlc_get_focused_output , IO -- |Get output name. #ccall wlc_output_get_name , -> IO CString -- |Get sleep state. #ccall wlc_output_get_sleep , -> IO Bool -- |Wake up / sleep. #ccall wlc_output_set_sleep , -> Bool -> IO () -- |Get resolution. #ccall wlc_output_get_resolution , -> IO (Ptr ) -- |Set resolution. #ccall wlc_output_set_resolution , -> Ptr -> IO () -- |Get current visibility bitmask. #ccall wlc_output_get_mask , -> IO CUInt -- |Set visibility bitmask. #ccall wlc_output_set_mask , -> CUInt -> IO () -- |Get views in stack order. Returned array is a direct reference, careful when moving and destroying handles. #ccall wlc_output_get_views , -> Ptr CSize -> IO (Ptr wlc_handle) -- |Set views in stack order. This will also change mutable views. Returns false on failure. #ccall wlc_output_set_views , -> Ptr -> CSize -> IO Bool -- |Focus output. Pass zero for no focus. #ccall wlc_output_focus , -> IO () -- * View API -- |Focus view. Pass zero for no focus. #ccall wlc_view_focus , -> IO () -- |Close view. #ccall wlc_view_close , -> IO () -- |Get current output. #ccall wlc_view_get_output , -> IO -- |Set output. Alternatively you can wlc_output_set_views. #ccall wlc_view_set_output , -> -> IO () -- |Send behind everything. #ccall wlc_view_send_to_back , -> IO () -- |Send below another view. #ccall wlc_view_send_below , -> -> IO () -- |Send above another view. #ccall wlc_view_bring_above , -> -> IO () -- |Bring to front of everything. #ccall wlc_view_bring_to_front , -> IO () -- |Get current visibility bitmask. #ccall wlc_view_get_mask , -> IO CUInt -- |Set visibility bitmask. #ccall wlc_view_set_mask , -> CUInt -> IO () -- |Get current geometry. (what client sees) #ccall wlc_view_get_geometry , -> IO (Ptr ) -- |Get visible geometry. (what wlc displays) #ccall wlc_view_get_visible_geometry , -> Ptr -> IO () -- |Set geometry. Set edges if the geometry change is caused by interactive resize. #ccall wlc_view_set_geometry , -> CUInt -> Ptr -> IO () -- |Get type bitfield. #ccall wlc_view_get_type , -> IO CUInt -- |Set type bit. Toggle indicates whether it is set or not. #ccall wlc_view_set_type , -> -> Bool -> IO () -- |Get current state bitfield. #ccall wlc_view_get_state , -> IO CUInt -- |Set state bit. Toggle indicates whether it is set or not. #ccall wlc_view_set_state , -> -> Bool -> IO () -- |Get parent view. #ccall wlc_view_get_parent , -> IO -- |Set parent view. #ccall wlc_view_set_parent , -> -> IO () -- |Get title. #ccall wlc_view_get_title , -> IO CString -- |Get class. (shell-surface only) #ccall wlc_view_get_class , -> IO CString -- |Get app id. (xdg-surface only) #ccall wlc_view_get_app_id , -> IO CString -- * Input API -- |Get currently held keys. #ccall wlc_keyboard_get_current_keys , Ptr CSize -> IO (Ptr CUInt) -- |Utility function to convert raw keycode to keysym. Passed modifiers may transform the key. #ccall wlc_keyboard_get_keysym_for_key , CUInt -> Ptr -> IO CUInt -- |Utility function to convert raw keycode to Unicode/UTF-32 codepoint. Passed modifiers may transform the key. #ccall wlc_keyboard_get_utf32_for_key , CUInt -> Ptr -> IO CUInt -- |Get current pointer position. #ccall wlc_pointer_get_position , Ptr -> IO () -- |Set current pointer position. #ccall wlc_pointer_set_position , Ptr -> IO ()