@@ -82,53 +82,117 @@ static const unsigned long retroarch_icon_data[] = {
82
82
0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000 ,0x00000000
83
83
};
84
84
85
- void xdg_toplevel_handle_configure_common (gfx_ctx_wayland_data_t * wl ,
86
- void * toplevel ,
85
+ typedef struct shm_buffer
86
+ {
87
+ struct wl_buffer * wl_buffer ;
88
+ void * data ;
89
+ size_t data_size ;
90
+ } shm_buffer_t ;
91
+
92
+ #ifdef HAVE_LIBDECOR_H
93
+ static void libdecor_handle_error (struct libdecor * context ,
94
+ enum libdecor_error error , const char * message )
95
+ {
96
+ RARCH_ERR ("[Wayland]: libdecor Caught error (%d): %s\n" , error , message );
97
+ }
98
+
99
+ const struct libdecor_interface libdecor_interface = {
100
+ .error = libdecor_handle_error ,
101
+ };
102
+ #endif
103
+
104
+ typedef struct wayland_configuration
105
+ {
106
+ unsigned width ;
107
+ unsigned height ;
108
+ bool fullscreen ;
109
+ bool maximized ;
110
+ bool floating ;
111
+ bool resizing ;
112
+ bool activated ;
113
+ } wayland_configuration_t ;
114
+
115
+ void xdg_toplevel_handle_configure (void * data ,
116
+ struct xdg_toplevel * xdg_toplevel ,
87
117
int32_t width , int32_t height , struct wl_array * states )
88
118
{
119
+ gfx_ctx_wayland_data_t * wl = (gfx_ctx_wayland_data_t * )data ;
89
120
const uint32_t * state ;
90
- bool floating = true;
91
121
92
- wl -> fullscreen = false;
93
- wl -> maximized = false;
122
+ wl -> pending_configuration = (wayland_configuration_t * )calloc (1 , sizeof (wayland_configuration_t ));
123
+ wayland_configuration_t * conf = wl -> pending_configuration ;
124
+
125
+ conf -> floating = true;
94
126
95
127
WL_ARRAY_FOR_EACH (state , states , const uint32_t * )
96
128
{
97
129
switch (* state )
98
130
{
99
131
case XDG_TOPLEVEL_STATE_FULLSCREEN :
100
- wl -> fullscreen = true;
101
- floating = false;
132
+ conf -> fullscreen = true;
133
+ conf -> floating = false;
102
134
break ;
103
135
case XDG_TOPLEVEL_STATE_MAXIMIZED :
104
- wl -> maximized = true;
136
+ conf -> maximized = true;
105
137
/* fall-through */
106
138
case XDG_TOPLEVEL_STATE_TILED_LEFT :
107
139
case XDG_TOPLEVEL_STATE_TILED_RIGHT :
108
140
case XDG_TOPLEVEL_STATE_TILED_TOP :
109
141
case XDG_TOPLEVEL_STATE_TILED_BOTTOM :
110
- floating = false;
142
+ conf -> floating = false;
111
143
break ;
112
144
case XDG_TOPLEVEL_STATE_RESIZING :
113
- wl -> resize = true;
145
+ conf -> resizing = true;
114
146
break ;
115
147
case XDG_TOPLEVEL_STATE_ACTIVATED :
116
- wl -> activated = true;
148
+ conf -> activated = true;
117
149
break ;
118
150
}
119
151
}
120
152
121
- if (width == 0 || height == 0 )
153
+ conf -> width = width ;
154
+ conf -> height = height ;
155
+ }
156
+
157
+ void xdg_toplevel_handle_close (void * data ,
158
+ struct xdg_toplevel * xdg_toplevel );
159
+
160
+ static struct xdg_toplevel_listener xdg_toplevel_listener = {
161
+ .configure = xdg_toplevel_handle_configure ,
162
+ .close = xdg_toplevel_handle_close ,
163
+ };
164
+
165
+ static void xdg_surface_handle_configure (void * data ,
166
+ struct xdg_surface * xdg_surface , uint32_t serial )
167
+ {
168
+ gfx_ctx_wayland_data_t * wl = (gfx_ctx_wayland_data_t * )data ;
169
+ wayland_configuration_t * conf ;
170
+
171
+ conf = wl -> pending_configuration ;
172
+ wl -> pending_configuration = NULL ;
173
+
174
+ if (conf == NULL )
175
+ conf = (wayland_configuration_t * )calloc (1 , sizeof (wayland_configuration_t ));
176
+ // TODO: Set defaults for wayland_configuration_t!
177
+
178
+ bool floating = conf -> floating ;
179
+
180
+ wl -> fullscreen = conf -> fullscreen ;
181
+ wl -> maximized = conf -> maximized ;
182
+ wl -> resize = conf -> resizing ;
183
+ wl -> activated = conf -> activated ;
184
+
185
+ if (conf -> width == 0 || conf -> height == 0 )
122
186
{
123
- width = wl -> floating_width ;
124
- height = wl -> floating_height ;
187
+ conf -> width = wl -> floating_width ;
188
+ conf -> height = wl -> floating_height ;
125
189
}
126
190
127
- if ( (width > 0 )
128
- && (height > 0 ))
191
+ if ( (conf -> width > 0 )
192
+ && (conf -> height > 0 ))
129
193
{
130
- wl -> width = width ;
131
- wl -> height = height ;
194
+ wl -> width = conf -> width ;
195
+ wl -> height = conf -> height ;
132
196
wl -> buffer_width = wl -> fractional_scale ?
133
197
FRACTIONAL_SCALE_MULT (wl -> width , wl -> fractional_scale_num ) : wl -> width * wl -> buffer_scale ;
134
198
wl -> buffer_height = wl -> fractional_scale ?
@@ -144,22 +208,39 @@ void xdg_toplevel_handle_configure_common(gfx_ctx_wayland_data_t *wl,
144
208
145
209
if (floating )
146
210
{
147
- wl -> floating_width = width ;
148
- wl -> floating_height = height ;
211
+ wl -> floating_width = conf -> width ;
212
+ wl -> floating_height = conf -> height ;
149
213
}
214
+
215
+ if (wl -> driver_configure_handler != NULL )
216
+ wl -> driver_configure_handler (wl );
217
+ xdg_surface_ack_configure (xdg_surface , serial );
218
+
219
+ wl_surface_commit (wl -> surface );
220
+
221
+ if (conf != NULL )
222
+ free (conf );
223
+
224
+ wl -> configured = false;
150
225
}
151
226
227
+ static struct xdg_surface_listener xdg_surface_listener = {
228
+ .configure = xdg_surface_handle_configure
229
+ };
230
+
152
231
void xdg_toplevel_handle_close (void * data ,
153
232
struct xdg_toplevel * xdg_toplevel )
154
233
{
155
234
frontend_driver_set_signal_handler_state (1 );
156
235
}
157
236
158
237
#ifdef HAVE_LIBDECOR_H
159
- void libdecor_frame_handle_configure_common (struct libdecor_frame * frame ,
238
+ void libdecor_frame_handle_configure (struct libdecor_frame * frame ,
160
239
struct libdecor_configuration * configuration ,
161
- gfx_ctx_wayland_data_t * wl )
240
+ void * data )
162
241
{
242
+ gfx_ctx_wayland_data_t * wl = (gfx_ctx_wayland_data_t * )data ;
243
+
163
244
int width = 0 , height = 0 ;
164
245
struct libdecor_state * state = NULL ;
165
246
enum libdecor_window_state window_state ;
@@ -223,6 +304,11 @@ void libdecor_frame_handle_configure_common(struct libdecor_frame *frame,
223
304
wl -> floating_width = width ;
224
305
wl -> floating_height = height ;
225
306
}
307
+
308
+ if (wl -> driver_configure_handler != NULL )
309
+ wl -> driver_configure_handler (wl );
310
+
311
+ wl -> configured = false;
226
312
}
227
313
228
314
void libdecor_frame_handle_close (struct libdecor_frame * frame ,
@@ -232,6 +318,12 @@ void libdecor_frame_handle_close(struct libdecor_frame *frame,
232
318
}
233
319
void libdecor_frame_handle_commit (struct libdecor_frame * frame ,
234
320
void * data ) { }
321
+
322
+ static struct libdecor_frame_interface libdecor_frame_interface = {
323
+ .configure = libdecor_frame_handle_configure ,
324
+ .close = libdecor_frame_handle_close ,
325
+ .commit = libdecor_frame_handle_commit ,
326
+ };
235
327
#endif
236
328
237
329
void gfx_ctx_wl_get_video_size_common (void * data ,
@@ -662,7 +754,7 @@ static bool wl_draw_splash_screen(gfx_ctx_wayland_data_t *wl)
662
754
}
663
755
664
756
bool gfx_ctx_wl_init_common (
665
- const toplevel_listener_t * toplevel_listener , gfx_ctx_wayland_data_t * * wwl )
757
+ const driver_configure_handler_t driver_configure_handler , gfx_ctx_wayland_data_t * * wwl )
666
758
{
667
759
int i ;
668
760
gfx_ctx_wayland_data_t * wl ;
@@ -802,7 +894,7 @@ bool gfx_ctx_wl_init_common(
802
894
{
803
895
wl -> libdecor_context = wl -> libdecor_new (wl -> input .dpy , & libdecor_interface );
804
896
805
- wl -> libdecor_frame = wl -> libdecor_decorate (wl -> libdecor_context , wl -> surface , & toplevel_listener -> libdecor_frame_interface , wl );
897
+ wl -> libdecor_frame = wl -> libdecor_decorate (wl -> libdecor_context , wl -> surface , & libdecor_frame_interface , wl );
806
898
if (!wl -> libdecor_frame )
807
899
{
808
900
RARCH_ERR ("[Wayland]: Failed to create libdecor frame\n" );
@@ -832,8 +924,10 @@ bool gfx_ctx_wl_init_common(
832
924
wl -> xdg_surface = xdg_wm_base_get_xdg_surface (wl -> xdg_shell , wl -> surface );
833
925
xdg_surface_add_listener (wl -> xdg_surface , & xdg_surface_listener , wl );
834
926
927
+ wl -> driver_configure_handler = driver_configure_handler ;
928
+
835
929
wl -> xdg_toplevel = xdg_surface_get_toplevel (wl -> xdg_surface );
836
- xdg_toplevel_add_listener (wl -> xdg_toplevel , & toplevel_listener -> xdg_toplevel_listener , wl );
930
+ xdg_toplevel_add_listener (wl -> xdg_toplevel , & xdg_toplevel_listener , wl );
837
931
838
932
xdg_toplevel_set_app_id (wl -> xdg_toplevel , WAYLAND_APP_ID );
839
933
xdg_toplevel_set_title (wl -> xdg_toplevel , WINDOW_TITLE );
@@ -880,9 +974,6 @@ bool gfx_ctx_wl_init_common(
880
974
}
881
975
}
882
976
883
- // Ignore configure events until splash screen has been replaced
884
- wl -> ignore_configuration = true;
885
-
886
977
wl -> input .fd = wl_display_get_fd (wl -> input .dpy );
887
978
888
979
wl -> input .keyboard_focus = true;
@@ -946,6 +1037,8 @@ bool gfx_ctx_wl_set_video_mode_common_size(gfx_ctx_wayland_data_t *wl,
946
1037
}
947
1038
#endif
948
1039
1040
+ wl_surface_commit (wl -> surface );
1041
+
949
1042
return true;
950
1043
}
951
1044
@@ -1089,28 +1182,7 @@ static void shm_buffer_handle_release(void *data,
1089
1182
free (buffer );
1090
1183
}
1091
1184
1092
- #if 0
1093
- static void xdg_surface_handle_configure (void * data ,
1094
- struct xdg_surface * surface , uint32_t serial )
1095
- {
1096
- xdg_surface_ack_configure (surface , serial );
1097
- }
1098
- #endif
1099
-
1100
- #ifdef HAVE_LIBDECOR_H
1101
- static void libdecor_handle_error (struct libdecor * context ,
1102
- enum libdecor_error error , const char * message )
1103
- {
1104
- RARCH_ERR ("[Wayland]: libdecor Caught error (%d): %s\n" , error , message );
1105
- }
1106
- #endif
1107
-
1108
1185
const struct wl_buffer_listener shm_buffer_listener = {
1109
1186
shm_buffer_handle_release ,
1110
1187
};
1111
1188
1112
- #ifdef HAVE_LIBDECOR_H
1113
- const struct libdecor_interface libdecor_interface = {
1114
- .error = libdecor_handle_error ,
1115
- };
1116
- #endif
0 commit comments