diff options
Diffstat (limited to 'src/compositor.h')
-rw-r--r-- | src/compositor.h | 363 |
1 files changed, 241 insertions, 122 deletions
diff --git a/src/compositor.h b/src/compositor.h index 0dcb604e..22a485fc 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -92,6 +92,8 @@ struct weston_shell_interface { struct shell_surface *(*create_shell_surface)(void *shell, struct weston_surface *surface, const struct weston_shell_client *client); + struct weston_view *(*get_primary_view)(void *shell, + struct shell_surface *shsurf); void (*set_toplevel)(struct shell_surface *shsurf); @@ -112,10 +114,6 @@ struct weston_shell_interface { }; -struct weston_border { - int32_t left, right, top, bottom; -}; - struct weston_animation { void (*frame)(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); @@ -140,18 +138,12 @@ struct weston_spring { uint32_t clip; }; -enum { - ZOOM_FOCUS_POINTER, - ZOOM_FOCUS_TEXT -}; - struct weston_fixed_point { wl_fixed_t x, y; }; struct weston_output_zoom { int active; - uint32_t type; float increment; float level; float max_level; @@ -163,7 +155,7 @@ struct weston_output_zoom { struct weston_fixed_point from; struct weston_fixed_point to; struct weston_fixed_point current; - struct weston_fixed_point text_cursor; + struct wl_listener motion_listener; }; /* bit compatible with drm definitions. */ @@ -194,7 +186,6 @@ struct weston_output { struct wl_list animation_list; int32_t x, y, width, height; int32_t mm_width, mm_height; - struct weston_border border; pixman_region32_t region; pixman_region32_t previous_damage; int repaint_needed; @@ -203,8 +194,11 @@ struct weston_output { int dirty; struct wl_signal frame_signal; struct wl_signal destroy_signal; + struct wl_signal move_signal; + int move_x, move_y; uint32_t frame_time; int disable_planes; + int destroying; char *make, *model, *serial_number; uint32_t subpixel; @@ -242,7 +236,8 @@ struct weston_output { struct weston_pointer_grab; struct weston_pointer_grab_interface { void (*focus)(struct weston_pointer_grab *grab); - void (*motion)(struct weston_pointer_grab *grab, uint32_t time); + void (*motion)(struct weston_pointer_grab *grab, uint32_t time, + wl_fixed_t x, wl_fixed_t y); void (*button)(struct weston_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state); void (*cancel)(struct weston_pointer_grab *grab); @@ -314,11 +309,14 @@ struct weston_pointer { struct wl_list resource_list; struct wl_list focus_resource_list; - struct weston_surface *focus; + struct weston_view *focus; uint32_t focus_serial; + struct wl_listener focus_view_listener; + struct wl_listener focus_resource_listener; struct wl_signal focus_signal; + struct wl_signal motion_signal; - struct weston_surface *sprite; + struct weston_view *sprite; struct wl_listener sprite_destroy_listener; int32_t hotspot_x, hotspot_y; @@ -339,10 +337,14 @@ struct weston_touch { struct wl_list resource_list; struct wl_list focus_resource_list; - struct weston_surface *focus; + struct weston_view *focus; + struct wl_listener focus_view_listener; + struct wl_listener focus_resource_listener; uint32_t focus_serial; struct wl_signal focus_signal; + uint32_t num_tp; + struct weston_touch_grab *grab; struct weston_touch_grab default_grab; int grab_touch_id; @@ -352,12 +354,12 @@ struct weston_touch { }; struct weston_pointer * -weston_pointer_create(void); +weston_pointer_create(struct weston_seat *seat); void weston_pointer_destroy(struct weston_pointer *pointer); void weston_pointer_set_focus(struct weston_pointer *pointer, - struct weston_surface *surface, + struct weston_view *view, wl_fixed_t sx, wl_fixed_t sy); void weston_pointer_start_grab(struct weston_pointer *pointer, @@ -367,6 +369,14 @@ weston_pointer_end_grab(struct weston_pointer *pointer); void weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t *fy); +void +weston_pointer_move(struct weston_pointer *pointer, + wl_fixed_t x, wl_fixed_t y); +void +weston_pointer_set_default_grab(struct weston_pointer *pointer, + const struct weston_pointer_grab_interface *interface); +void +weston_pointer_verify(struct weston_pointer *pointer); struct weston_keyboard * weston_keyboard_create(void); @@ -387,7 +397,7 @@ void weston_touch_destroy(struct weston_touch *touch); void weston_touch_set_focus(struct weston_seat *seat, - struct weston_surface *surface); + struct weston_view *view); void weston_touch_start_grab(struct weston_touch *device, struct weston_touch_grab *grab); @@ -405,10 +415,15 @@ void weston_seat_set_selection(struct weston_seat *seat, struct weston_data_source *source, uint32_t serial); int -weston_seat_start_drag(struct weston_seat *seat, +weston_pointer_start_drag(struct weston_pointer *pointer, struct weston_data_source *source, struct weston_surface *icon, struct wl_client *client); +int +weston_touch_start_drag(struct weston_touch *touch, + struct weston_data_source *source, + struct weston_surface *icon, + struct wl_client *client); struct weston_xkb_info { struct xkb_keymap *keymap; @@ -435,6 +450,7 @@ struct weston_keyboard { struct wl_list resource_list; struct wl_list focus_resource_list; struct weston_surface *focus; + struct wl_listener focus_resource_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -455,6 +471,13 @@ struct weston_keyboard { struct weston_keyboard_grab input_method_grab; struct wl_resource *input_method_resource; + + struct weston_xkb_info *xkb_info; + struct { + struct xkb_state *state; + enum weston_led leds; + } xkb_state; + struct xkb_keymap *pending_keymap; }; struct weston_seat { @@ -484,16 +507,9 @@ struct weston_seat { struct wl_listener selection_data_source_listener; struct wl_signal selection_signal; - uint32_t num_tp; - void (*led_update)(struct weston_seat *ws, enum weston_led leds); - struct weston_xkb_info *xkb_info; - struct { - struct xkb_state *state; - enum weston_led leds; - } xkb_state; - + uint32_t slot_map; struct input_method *input_method; char *seat_name; }; @@ -507,7 +523,7 @@ enum { }; struct weston_layer { - struct wl_list surface_list; + struct wl_list view_list; struct wl_list link; }; @@ -528,11 +544,9 @@ struct weston_renderer { pixman_region32_t *output_damage); void (*flush_damage)(struct weston_surface *surface); void (*attach)(struct weston_surface *es, struct weston_buffer *buffer); - int (*create_surface)(struct weston_surface *surface); void (*surface_set_color)(struct weston_surface *surface, float red, float green, float blue, float alpha); - void (*destroy_surface)(struct weston_surface *surface); void (*destroy)(struct weston_compositor *ec); }; @@ -578,9 +592,10 @@ struct weston_compositor { struct wl_list output_list; struct wl_list seat_list; struct wl_list layer_list; - struct wl_list surface_list; + struct wl_list view_list; struct wl_list plane_list; struct wl_list key_binding_list; + struct wl_list modifier_binding_list; struct wl_list button_binding_list; struct wl_list touch_binding_list; struct wl_list axis_binding_list; @@ -591,12 +606,12 @@ struct weston_compositor { uint32_t idle_inhibit; int idle_time; /* timeout, s */ + const struct weston_pointer_grab_interface *default_pointer_grab; + /* Repaint state. */ struct weston_plane primary_plane; uint32_t capabilities; /* combination of enum weston_capability */ - uint32_t focus; - struct weston_renderer *renderer; pixman_format_code_t read_format; @@ -638,6 +653,23 @@ struct weston_buffer_reference { struct wl_listener destroy_listener; }; +struct weston_buffer_viewport { + /* wl_surface.set_buffer_transform */ + uint32_t transform; + + /* wl_surface.set_scaling_factor */ + int32_t scale; + + /* bool for whether wl_viewport.set has been + * called yet (before this is called there is no + * cropping or scaling on the surface) */ + int viewport_set; /* bool */ + + wl_fixed_t src_x, src_y; + wl_fixed_t src_width, src_height; + int32_t dst_width, dst_height; +}; + struct weston_region { struct wl_resource *resource; pixman_region32_t region; @@ -684,58 +716,57 @@ struct weston_subsurface { struct wl_list frame_callback_list; /* wl_surface.set_buffer_transform */ - uint32_t buffer_transform; - /* wl_surface.set_buffer_scale */ - int32_t buffer_scale; + struct weston_buffer_viewport buffer_viewport; } cached; int synchronized; + + /* Used for constructing the view tree */ + struct wl_list unused_views; }; -/* Using weston_surface transformations +/* Using weston_view transformations * - * To add a transformation to a surface, create a struct weston_transform, and - * add it to the list surface->geometry.transformation_list. Whenever you - * change the list, anything under surface->geometry, or anything in the + * To add a transformation to a view, create a struct weston_transform, and + * add it to the list view->geometry.transformation_list. Whenever you + * change the list, anything under view->geometry, or anything in the * weston_transforms linked into the list, you must call - * weston_surface_geometry_dirty(). + * weston_view_geometry_dirty(). * * The order in the list defines the order of transformations. Let the list * contain the transformation matrices M1, ..., Mn as head to tail. The - * transformation is applied to surface-local coordinate vector p as + * transformation is applied to view-local coordinate vector p as * P = Mn * ... * M2 * M1 * p * to produce the global coordinate vector P. The total transform * Mn * ... * M2 * M1 - * is cached in surface->transform.matrix, and the inverse of it in - * surface->transform.inverse. + * is cached in view->transform.matrix, and the inverse of it in + * view->transform.inverse. * - * The list always contains surface->transform.position transformation, which - * is the translation by surface->geometry.x and y. + * The list always contains view->transform.position transformation, which + * is the translation by view->geometry.x and y. * * If you want to apply a transformation in local coordinates, add your * weston_transform to the head of the list. If you want to apply a * transformation in global coordinates, add it to the tail of the list. * - * If surface->geometry.parent is set, the total transformation of this - * surface will be the parent's total transformation and this transformation + * If view->geometry.parent is set, the total transformation of this + * view will be the parent's total transformation and this transformation * combined: * Mparent * Mn * ... * M2 * M1 */ -struct weston_surface { - struct wl_resource *resource; +struct weston_view { + struct weston_surface *surface; + struct wl_list surface_link; struct wl_signal destroy_signal; - struct weston_compositor *compositor; - pixman_region32_t clip; - pixman_region32_t damage; - pixman_region32_t opaque; /* part of geometry, see below */ - pixman_region32_t input; + struct wl_list link; struct wl_list layer_link; - float alpha; /* part of geometry, see below */ struct weston_plane *plane; - int32_t ref_count; + + pixman_region32_t clip; + float alpha; /* part of geometry, see below */ void *renderer_state; @@ -745,20 +776,19 @@ struct weston_surface { */ struct { float x, y; /* surface translation on display */ - int32_t width, height; /* struct weston_transform */ struct wl_list transformation_list; /* managed by weston_surface_set_transform_parent() */ - struct weston_surface *parent; + struct weston_view *parent; struct wl_listener parent_destroy_listener; struct wl_list child_list; /* geometry.parent_link */ struct wl_list parent_link; } geometry; /* State derived from geometry state, read-only. - * This is updated by weston_surface_update_transform(). + * This is updated by weston_view_update_transform(). */ struct { int dirty; @@ -789,13 +819,51 @@ struct weston_surface { */ uint32_t output_mask; + struct wl_listener output_move_listener; + struct wl_listener output_destroy_listener; +}; + +struct weston_surface { + struct wl_resource *resource; + struct wl_signal destroy_signal; + struct weston_compositor *compositor; + pixman_region32_t damage; + pixman_region32_t opaque; /* part of geometry, see below */ + pixman_region32_t input; + int32_t width, height; + int32_t ref_count; + + /* Not for long-term storage. This exists for book-keeping while + * iterating over surfaces and views + */ + int32_t touched; + + void *renderer_state; + + struct wl_list views; + + /* + * Which output to vsync this surface to. + * Used to determine, whether to send or queue frame events. + * Must be NULL, if 'link' is not in weston_compositor::surface_list. + */ + struct weston_output *output; + + /* + * A more complete representation of all outputs this surface is + * displayed on. + */ + uint32_t output_mask; + struct wl_list frame_callback_list; struct weston_buffer_reference buffer_ref; - uint32_t buffer_transform; - int32_t buffer_scale; + struct weston_buffer_viewport buffer_viewport; int keep_buffer; /* bool for backends to prevent early release */ + /* wl_viewport resource for this surface */ + struct wl_resource *viewport_resource; + /* All the pending state, that wl_surface.commit will apply. */ struct { /* wl_surface.attach */ @@ -818,10 +886,9 @@ struct weston_surface { struct wl_list frame_callback_list; /* wl_surface.set_buffer_transform */ - uint32_t buffer_transform; - /* wl_surface.set_scaling_factor */ - int32_t buffer_scale; + /* wl_viewport.set */ + struct weston_buffer_viewport buffer_viewport; } pending; /* @@ -829,9 +896,15 @@ struct weston_surface { * a new buffer has been set up for this surface. The integer params * are the sx and sy paramerters supplied to surface::attach . */ - void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height); + void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy); void *configure_private; + /* If non-NULL, this function will be called on surface->output:: + * destroy, after the output is removed from the compositor's + * output list and the remaining outputs moved. + */ + void (*output_destroyed)(struct weston_surface *surface); + /* Parent's list of its sub-surfaces, weston_subsurface:parent_link. * Contains also the parent itself as a dummy weston_subsurface, * if the list is not empty. @@ -849,41 +922,36 @@ void weston_version(int *major, int *minor, int *micro); void -weston_surface_update_transform(struct weston_surface *surface); +weston_view_update_transform(struct weston_view *view); void -weston_surface_geometry_dirty(struct weston_surface *surface); +weston_view_geometry_dirty(struct weston_view *view); void -weston_surface_to_global_fixed(struct weston_surface *surface, - wl_fixed_t sx, wl_fixed_t sy, - wl_fixed_t *x, wl_fixed_t *y); +weston_view_to_global_fixed(struct weston_view *view, + wl_fixed_t sx, wl_fixed_t sy, + wl_fixed_t *x, wl_fixed_t *y); void -weston_surface_to_global_float(struct weston_surface *surface, - float sx, float sy, float *x, float *y); +weston_view_to_global_float(struct weston_view *view, + float sx, float sy, float *x, float *y); void -weston_surface_from_global_float(struct weston_surface *surface, - float x, float y, float *sx, float *sy); +weston_view_from_global_float(struct weston_view *view, + float x, float y, float *vx, float *vy); void -weston_surface_from_global(struct weston_surface *surface, - int32_t x, int32_t y, int32_t *sx, int32_t *sy); +weston_view_from_global(struct weston_view *view, + int32_t x, int32_t y, int32_t *vx, int32_t *vy); void -weston_surface_from_global_fixed(struct weston_surface *surface, - wl_fixed_t x, wl_fixed_t y, - wl_fixed_t *sx, wl_fixed_t *sy); -int32_t -weston_surface_buffer_width(struct weston_surface *surface); -int32_t -weston_surface_buffer_height(struct weston_surface *surface); +weston_view_from_global_fixed(struct weston_view *view, + wl_fixed_t x, wl_fixed_t y, + wl_fixed_t *vx, wl_fixed_t *vy); WL_EXPORT void weston_surface_to_buffer_float(struct weston_surface *surface, float x, float y, float *bx, float *by); WL_EXPORT void weston_surface_to_buffer(struct weston_surface *surface, - int sx, int sy, int *bx, int *by); - + int sx, int sy, int *bx, int *by); pixman_box32_t weston_surface_to_buffer_rect(struct weston_surface *surface, pixman_box32_t rect); @@ -967,10 +1035,10 @@ void weston_compositor_offscreen(struct weston_compositor *compositor); void weston_compositor_sleep(struct weston_compositor *compositor); -struct weston_surface * -weston_compositor_pick_surface(struct weston_compositor *compositor, - wl_fixed_t x, wl_fixed_t y, - wl_fixed_t *sx, wl_fixed_t *sy); +struct weston_view * +weston_compositor_pick_view(struct weston_compositor *compositor, + wl_fixed_t x, wl_fixed_t y, + wl_fixed_t *sx, wl_fixed_t *sy); struct weston_binding; @@ -984,6 +1052,15 @@ weston_compositor_add_key_binding(struct weston_compositor *compositor, weston_key_binding_handler_t binding, void *data); +typedef void (*weston_modifier_binding_handler_t)(struct weston_seat *seat, + enum weston_keyboard_modifier modifier, + void *data); +struct weston_binding * +weston_compositor_add_modifier_binding(struct weston_compositor *compositor, + enum weston_keyboard_modifier modifier, + weston_modifier_binding_handler_t binding, + void *data); + typedef void (*weston_button_binding_handler_t)(struct weston_seat *seat, uint32_t time, uint32_t button, void *data); @@ -1028,6 +1105,12 @@ weston_compositor_run_key_binding(struct weston_compositor *compositor, struct weston_seat *seat, uint32_t time, uint32_t key, enum wl_keyboard_key_state state); + +void +weston_compositor_run_modifier_binding(struct weston_compositor *compositor, + struct weston_seat *seat, + enum weston_keyboard_modifier modifier, + enum wl_keyboard_key_state state); void weston_compositor_run_button_binding(struct weston_compositor *compositor, struct weston_seat *seat, uint32_t time, @@ -1047,6 +1130,10 @@ weston_compositor_run_debug_binding(struct weston_compositor *compositor, uint32_t key, enum wl_keyboard_key_state state); +void +weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor, + const struct weston_pointer_grab_interface *interface); + int weston_environment_get_fd(const char *env); @@ -1056,24 +1143,33 @@ weston_compositor_top(struct weston_compositor *compositor); struct weston_surface * weston_surface_create(struct weston_compositor *compositor); +struct weston_view * +weston_view_create(struct weston_surface *surface); + void -weston_surface_configure(struct weston_surface *surface, - float x, float y, int width, int height); +weston_view_destroy(struct weston_view *view); void -weston_surface_restack(struct weston_surface *surface, struct wl_list *below); +weston_view_set_position(struct weston_view *view, + float x, float y); void -weston_surface_set_position(struct weston_surface *surface, - float x, float y); +weston_view_set_transform_parent(struct weston_view *view, + struct weston_view *parent); + +int +weston_view_is_mapped(struct weston_view *view); void -weston_surface_set_transform_parent(struct weston_surface *surface, - struct weston_surface *parent); +weston_view_schedule_repaint(struct weston_view *view); int weston_surface_is_mapped(struct weston_surface *surface); +WL_EXPORT void +weston_surface_set_size(struct weston_surface *surface, + int32_t width, int32_t height); + void weston_surface_schedule_repaint(struct weston_surface *surface); @@ -1081,11 +1177,14 @@ void weston_surface_damage(struct weston_surface *surface); void -weston_surface_damage_below(struct weston_surface *surface); +weston_view_damage_below(struct weston_view *view); void -weston_surface_move_to_plane(struct weston_surface *surface, - struct weston_plane *plane); +weston_view_move_to_plane(struct weston_view *view, + struct weston_plane *plane); +void +weston_view_unmap(struct weston_view *view); + void weston_surface_unmap(struct weston_surface *surface); @@ -1108,12 +1207,11 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display, void weston_compositor_shutdown(struct weston_compositor *ec); void -weston_text_cursor_position_notify(struct weston_surface *surface, - wl_fixed_t x, wl_fixed_t y); -void weston_output_init_zoom(struct weston_output *output); void -weston_output_update_zoom(struct weston_output *output, uint32_t type); +weston_output_update_zoom(struct weston_output *output); +void +weston_output_activate_zoom(struct weston_output *output); void weston_output_update_matrix(struct weston_output *output); void @@ -1124,8 +1222,8 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c, void weston_output_destroy(struct weston_output *output); void -weston_output_transform_coordinate(struct weston_output *x11_output, - int device_x, int device_y, +weston_output_transform_coordinate(struct weston_output *output, + wl_fixed_t device_x, wl_fixed_t device_y, wl_fixed_t *x, wl_fixed_t *y); void @@ -1145,6 +1243,8 @@ void weston_seat_release_touch(struct weston_seat *seat); void weston_seat_repick(struct weston_seat *seat); +void +weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap); void weston_seat_release(struct weston_seat *seat); @@ -1195,9 +1295,6 @@ screenshooter_create(struct weston_compositor *ec); struct clipboard * clipboard_create(struct weston_seat *seat); -void -text_cursor_position_notifier_create(struct weston_compositor *ec); - int text_backend_init(struct weston_compositor *ec); @@ -1220,23 +1317,37 @@ weston_client_launch(struct weston_compositor *compositor, void weston_watch_process(struct weston_process *process); -struct weston_surface_animation; -typedef void (*weston_surface_animation_done_func_t)(struct weston_surface_animation *animation, void *data); +struct weston_view_animation; +typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data); -struct weston_surface_animation * -weston_zoom_run(struct weston_surface *surface, float start, float stop, - weston_surface_animation_done_func_t done, void *data); +void +weston_view_animation_destroy(struct weston_view_animation *animation); + +struct weston_view_animation * +weston_zoom_run(struct weston_view *view, float start, float stop, + weston_view_animation_done_func_t done, void *data); -struct weston_surface_animation * -weston_fade_run(struct weston_surface *surface, +struct weston_view_animation * +weston_fade_run(struct weston_view *view, float start, float end, float k, - weston_surface_animation_done_func_t done, void *data); + weston_view_animation_done_func_t done, void *data); + +struct weston_view_animation * +weston_move_scale_run(struct weston_view *view, int dx, int dy, + float start, float end, int reverse, + weston_view_animation_done_func_t done, void *data); + void -weston_fade_update(struct weston_surface_animation *fade, float target); +weston_fade_update(struct weston_view_animation *fade, float target); -struct weston_surface_animation * -weston_slide_run(struct weston_surface *surface, float start, float stop, - weston_surface_animation_done_func_t done, void *data); +struct weston_view_animation * +weston_stable_fade_run(struct weston_view *front_view, float start, + struct weston_view *back_view, float end, + weston_view_animation_done_func_t done, void *data); + +struct weston_view_animation * +weston_slide_run(struct weston_view *view, float start, float stop, + weston_view_animation_done_func_t done, void *data); void weston_surface_set_color(struct weston_surface *surface, @@ -1270,6 +1381,14 @@ weston_transformed_rect(int width, int height, enum wl_output_transform transform, int32_t scale, pixman_box32_t rect); +void +weston_transformed_region(int width, int height, + enum wl_output_transform transform, + int32_t scale, + pixman_region32_t *src, pixman_region32_t *dest); + +void * +weston_load_module(const char *name, const char *entrypoint); #ifdef __cplusplus } |