Window callbacks
Window callbacks does not run concurrently with calling thread until noted otherwise. See explanation of callback annotations here. Example use of open and destroy callbacks along with windowing system initialization:
main { ; Initialize window system if GUI subsystem is enabled ; gui_enabled { window_init window_open (\ title_name: "My window", \ title_charset: NULL, \ parent_handle: NOPARENT, \ widget_stack_id: NOWIDGET, \ widget_set: 0, \ window_refresh_divider: PASSIVE_REFRESH, \ position_x: POS_CENTERED, \ position_y: POS_CENTERED, \ size_width: 800, \ size_height: 600, \ cb_main_loop: NULL, \ cb_expose: NULL, \ cb_key_press: NULL, \ cb_key_release: NULL, \ cb_button_press: NULL, \ cb_button_release: NULL, \ cb_client_message: NULL, \ cb_save_yourself: NULL, \ cb_configure_notify: NULL, \ cb_destroy_notify: "cb_destroy", \ cb_motion_notify: NULL, \ cb_map_notify: NULL, \ cb_unmap_notify: NULL, \ cb_open_notify: "cb_open") } } _WINCB_OPEN_ callback cb_open (_hnd) { _hnd.map() } _WINCB_DESTROY_ callback cb_destroy (_hnd) { _hnd.destroy() exit }
Main loop callback
Main loop callback runs when window main loop starts over. This callback blocks calling thread until it is complete.
_WINCB_MAINLOOP_ callback cb_main_loop (_window_handle) { ; ; _window_handle is the window that runs this callback. ; ; Parameter types: ; ; window_handle .. handle ; }
Expose callback
Expose callback runs when window receives expose event.
_WINCB_EXPOSE_ callback cb_expose (_window_handle, \ _x, _y, _width, _height, _data) { ; ; _window_handle is the window that runs this callback. ; ; _x, _y, _width and _height is expose area position and size, ; as in XExpose event. ; ; _data is pointer to internal pixel buffer to expose. Each pixel in ; buffer is one uint32_t value splitted in four bytes for each color ; component and pixel alpha value. See struct pixel_rgba_8 in ; engine/pixel.h for details. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _width ......... usize ; _height ........ usize ; _data .......... pointer ; }
Key press callback
Key press callback runs when key is pressed.
_WINCB_KEY_ callback cb_key_press (_window_handle, \ _x, _y, _x_root, _y_root, _state, _keycode, _key) { ; ; _window_handle is the window that runs this callback. ; ; _x and _y is pointer coordinates relative to window in question. ; _x_root and _y_root is pointer coordinates relative to root window. ; _state is key or button state mask as in XKey event. ; _keycode is the keycode as in XKey event. ; _key is the key pressed in human readable form. ; ; _state parameter is initialized as bitmask, telling if there is ; some special key pressed when this event occurred. Bits include: ; ; dec bin ; 1 0000000000000001 (ShiftMask) is set when shift key is pressed, ; 2 0000000000000010 (LockMask) is set when caps lock is on, ; 4 0000000000000100 (ControlMask) is set when control key is pressed, ; 8 0000000000001000 (Mod1Mask) is set when alt key is pressed, ; 16 0000000000010000 (Mod2Mask) is set when num lock is on, ; 32 0000000000100000 (Mod3Mask) is set when scroll lock is on, ; 64 0000000001000000 (Mod4Mask) is set when win key is pressed, and ; 128 0000000010000000 (Mod5Mask) is set when alt-gr key is pressed. ; ; There may be more bits available and may vary depending on keyboard and ; keyboard settings. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _x_root ........ int ; _y_root ........ int ; _state ......... uint ; _keycode ....... uint ; _key ........... string ; }
Key release callback
Key release callback runs when key is released.
_WINCB_KEY_ callback cb_key_release (_window_handle, \ _x, _y, _x_root, _y_root, _state, _keycode, _key) { ; ; _window_handle is the window that runs this callback. ; ; _x and _y is pointer coordinates relative to window in question. ; _x_root and _y_root is pointer coordinates relative to root window. ; _state is key or button state mask as in XKey event. See details ; in Key press section. ; _keycode is the keycode as in XKey event. ; _key is the key released in human readable form. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _x_root ........ int ; _y_root ........ int ; _state ......... uint ; _keycode ....... uint ; _key ........... string ; }
Button press callback
Button press callback runs when mouse or other pointing device button is pressed.
_WINCB_BUTTON_ callback cb_button_press (_window_handle, \ _x, _y, _x_root, _y_root, _state, _button) { ; ; _window_handle is the window that runs this callback. ; ; _x and _y is pointer coordinates relative to window in question. ; _x_root and _y_root is pointer coordinates relative to root window. ; _state is key or button state mask as in XButton event. See details ; in Key press section. ; _button is the button detail as in XButton event. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _x_root ........ int ; _y_root ........ int ; _state ......... uint ; _button ........ uint ; }
Button release callback
Button release callback runs when mouse or other pointing device button is released.
_WINCB_BUTTON_ callback cb_button_release (_window_handle, \ _x, _y, _x_root, _y_root, _state, _button) { ; ; _window_handle is the window that runs this callback. ; ; _x and _y is pointer coordinates relative to window in question. ; _x_root and _y_root is pointer coordinates relative to root window. ; _state is key or button state mask as in XButton event. See details ; in Key press section. ; _button is the button detail as in XButton event. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _x_root ........ int ; _y_root ........ int ; _state ......... uint ; _button ........ uint ; }
Client message callback
Client message callback runs when window receives client message event.
_WINCB_CLIENTMESSAGE_ callback cb_client_message (_window_handle, \ _data_format, _data_1, _data_2, _data_3, _data_4, _data5) { ; ; _window_handle is the window that runs this callback. ; ; _data_format and _data_1-5 is message details as described in ; XClient event. ; ; Parameter types: ; ; window_handle .. handle ; _data_format ... int ; _data_1 ........ long ; _data_2 ........ long ; _data_3 ........ long ; _data_4 ........ long ; _data_5 ........ long ; }
Save yourself callback
Save yourself callback runs when window receives save yourself message from session manager.
_WINCB_SAVEYOURSELF_ callback cb_save_yourself (_window_handle) { ; ; _window_handle is the window that runs this callback. ; ; Parameter types: ; ; window_handle .. handle ; }
Configure notify callback
Configure notify callback runs when window receives configure notify event.
_WINCB_CONFIGURE_ callback cb_configure_notify (_window_handle, \ _x, _y, _width, _height, _border_width) { ; ; _window_handle is the window that runs this callback. ; ; _x and _y is window position relative to root window. ; _width and _height is the size of the window in question. ; _border_width is window border width as in XConfigure event. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _width ......... usize ; _height ........ usize ; _border_width .. int ; }
Destroy notify callback
Destroy notify callback runs when window receives destroy event, that happens when window close button is pressed.
_WINCB_DESTROY_ callback cb_destroy_notify (_window_handle) { ; ; _window_handle is the window that runs this callback. ; ; Parameter types: ; ; window_handle .. handle ; }
Motion notify callback
Motion notify callback runs when pointer moves on window.
_WINCB_MOTION_ callback cb_motion_notify (_window_handle, \ _x, _y, _x_root, _y_root, _button_press, _detail) { ; ; _window_handle is the window that runs this callback. ; ; _x and _y is pointer coordinates relative to window in question. ; _x_root and _y_root is pointer coordinates relative to root window. ; _button_press is key or button state mask as in XMotion event. ; _detail is the detail as in XMotion event. ; ; Parameter types: ; ; window_handle .. handle ; _x ............. int ; _y ............. int ; _x_root ........ int ; _y_root ........ int ; _button_press .. uint ; _detail ........ char ; }
Map notify callback
Map notify callback runs when window is mapped on screen.
_WINCB_MAP_ callback cb_map_notify (_window_handle) { ; ; _window_handle is the window that runs this callback. ; ; Parameter types: ; ; window_handle .. handle ; }
Unmap notify callback
Unmap notify callback runs when window is unmapped from screen.
_WINCB_UNMAP_ callback cb_unmap_notify (_window_handle) { ; ; _window_handle is the window that runs this callback. ; ; Parameter types: ; ; window_handle .. handle ; }
Open notify callback
Open notify callback runs when window is opened, also known as created. Window is not visible until it is mapped. This callback blocks calling thread until it is complete.
_WINCB_OPEN_ callback cb_open_notify (_window_handle) { ; ; _window_handle is the window that runs this callback. ; ; Parameter types: ; ; window_handle .. handle ; }
Copyright © 2024, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.