shell: implement wl_shell_interface
[platform/core/uifw/libds-tizen.git] / src / libds / shell.h
1 #ifndef DS_SHELL_H
2 #define DS_SHELL_H
3
4 #include <wayland-server.h>
5
6 #include "libds/output.h"
7
8 #include "surface.h"
9
10 enum ds_shell_surface_role
11 {
12     DS_SHELL_SURFACE_ROLE_NONE,
13     DS_SHELL_SURFACE_ROLE_TOPLEVEL,
14     DS_SHELL_SURFACE_ROLE_POPUP,
15 };
16
17 struct ds_shell
18 {
19     struct wl_global *global;
20
21     struct wl_list clients;
22
23     struct wl_listener display_destroy;
24
25     struct {
26         struct wl_signal destroy;
27         struct wl_signal new_surface;
28     } events;
29
30     uint32_t ping_timeout;
31 };
32
33 struct ds_shell_client
34 {
35     struct ds_shell *shell;
36
37     struct wl_resource *resource;
38     struct wl_client *wl_client;
39     struct wl_event_source *ping_timer;
40
41     struct wl_list shell_surfaces;
42
43     struct wl_list link; // ds_shell::clients
44
45     uint32_t ping_serial;
46 };
47
48 struct ds_shell_toplevel_state
49 {
50     bool maximized, fullscreen, resizing, activated;
51     uint32_t tiled;
52     uint32_t width, height;
53     uint32_t max_width, max_height;
54     uint32_t min_width, min_height;
55 };
56
57 struct ds_shell_toplevel_requested
58 {
59     bool maximized, minimized, fullscreen;
60     struct ds_output *fullscreen_output;
61     struct wl_listener fullscreen_output_destroy;
62 };
63
64 struct ds_shell_toplevel
65 {
66     struct ds_shell_surface *base;
67     bool added;
68
69     struct ds_shell_surface *parent;
70     struct wl_listener parent_unmap;
71
72     struct ds_shell_toplevel_state current, pending;
73     struct ds_shell_toplevel_requested requested;
74
75     char *title;
76     char *app_id;
77
78     struct {
79         struct wl_signal request_maximize;
80         struct wl_signal request_fullscreen;
81         struct wl_signal request_minimize;
82         struct wl_signal request_move;
83         struct wl_signal request_resize;
84         struct wl_signal request_show_window_menu;
85         struct wl_signal set_parent;
86         struct wl_signal set_title;
87         struct wl_signal set_app_id;
88     } events;
89 };
90
91 struct ds_xdg_popup
92 {
93
94 };
95
96 struct ds_shell_surface_state
97 {
98     uint32_t configure_serial;
99     struct {
100         int x, y;
101         int width, height;
102     } geometry;
103 };
104
105 struct ds_shell_surface
106 {
107     struct ds_shell_client *client;
108     struct ds_surface *surface;
109
110     enum ds_shell_surface_role role;
111
112     union {
113         struct ds_shell_toplevel *toplevel;
114         struct ds_xdg_popup *popup;
115     };
116
117     struct wl_resource *resource;
118
119     struct wl_event_source *configure_idle;
120     uint32_t scheduled_serial;
121     struct wl_list configure_list;
122
123     struct ds_shell_surface_state current, pending;
124
125     struct wl_list link; // ds_shell_client::surfaces
126
127     struct {
128         struct wl_listener surface_destroy;
129         struct wl_listener surface_commit;
130     } listener;
131
132     struct {
133         struct wl_signal destroy;
134         struct wl_signal ping_timeout;
135         struct wl_signal new_popup;
136         struct wl_signal map;
137         struct wl_signal unmap;
138         struct wl_signal configure;
139     } events;
140
141     bool added, configured, mapped;
142 };
143
144 struct ds_shell_surface_configure
145 {
146     struct ds_shell_surface *shell_surface;
147     struct wl_list link;
148     uint32_t serial;
149 };
150
151 struct ds_shell_surface *
152 create_shell_surface(struct ds_shell_client *client, struct ds_surface *surface,
153         uint32_t id);
154
155 void destroy_shell_surface(struct ds_shell_surface *surface);
156
157 #endif