summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-08 10:46:09 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-08 11:01:15 +0100
commit7dd92a2d98b983557fc4ce21f8d5740e81fa2a74 (patch)
tree6c7576939b37138f5c6e6f9852712034dfa7ba9b /src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
parentc731cf56d5d242441d029907ea749ada6eb32ed6 (diff)
port cnp on Windows
Test Plan: Ctrl-c and Ctrl-Vworking Reviewers: raster, zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11439
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/win32/ecore_evas_win32.c305
1 files changed, 214 insertions, 91 deletions
diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
index 6198ed4bac..d0686c535c 100644
--- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
+++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
@@ -62,11 +62,15 @@ static const int interface_win32_version = 1;
62 62
63typedef struct _Ecore_Evas_Engine_Data_Win32 Ecore_Evas_Engine_Data_Win32; 63typedef struct _Ecore_Evas_Engine_Data_Win32 Ecore_Evas_Engine_Data_Win32;
64 64
65struct _Ecore_Evas_Engine_Data_Win32 { 65struct _Ecore_Evas_Engine_Data_Win32
66{
66 Ecore_Win32_Window *parent; 67 Ecore_Win32_Window *parent;
67 struct { 68 Ecore_Evas_Selection_Callbacks clipboard;
68 unsigned char region : 1; 69 Eina_Future *delivery;
69 unsigned char fullscreen : 1; 70 struct
71 {
72 unsigned char region : 1;
73 unsigned char fullscreen : 1;
70 } state; 74 } state;
71}; 75};
72 76
@@ -1197,96 +1201,215 @@ _ecore_evas_win32_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi)
1197 *ydpi = y_dpi; 1201 *ydpi = y_dpi;
1198} 1202}
1199 1203
1204static Eina_Value
1205_delivery(void *data, const Eina_Value value EINA_UNUSED, const Eina_Future *dead_future EINA_UNUSED)
1206{
1207 Ecore_Evas *ee = data;
1208 Ecore_Evas_Engine_Data_Win32 *edata = ee->engine.data;
1209 Eina_Rw_Slice slice;
1210 const char *mime_type = NULL;
1211
1212 EINA_SAFETY_ON_NULL_GOTO(edata->delivery, end);
1213
1214 for (unsigned int i = 0; i < eina_array_count(edata->clipboard.available_types); ++i)
1215 {
1216 mime_type = eina_array_data_get(edata->clipboard.available_types, i);
1217 if (eina_str_has_prefix(mime_type, "text/"))
1218 break;
1219 }
1220 if (mime_type)
1221 {
1222 edata->clipboard.delivery(ee, 0, ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER, mime_type, &slice);
1223 EINA_SAFETY_ON_FALSE_GOTO(ecore_win32_clipboard_set((Ecore_Win32_Window *)ee->prop.window, slice.mem, slice.len, mime_type), end);
1224 }
1225 else
1226 {
1227 ERR("No compatible mime type found");
1228 }
1229
1230end:
1231 return EINA_VALUE_EMPTY;
1232}
1233
1234static Eina_Bool
1235_ecore_evas_win32_selection_claim(Ecore_Evas *ee, unsigned int seat, Ecore_Evas_Selection_Buffer selection, Eina_Array *available_types, Ecore_Evas_Internal_Delivery delivery, Ecore_Evas_Internal_Cancel cancel)
1236{
1237 if (selection != ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER)
1238 return EINA_FALSE;
1239
1240 if (!delivery && !cancel)
1241 {
1242 ecore_win32_clipboard_clear((Ecore_Win32_Window *)ee->prop.window);
1243 return EINA_TRUE;
1244 }
1245 else
1246 {
1247 Ecore_Evas_Engine_Data_Win32 *edata = ee->engine.data;
1248
1249 if (edata->clipboard.cancel)
1250 {
1251 edata->clipboard.cancel(ee, seat, selection);
1252 eina_array_free(edata->clipboard.available_types);
1253 }
1254
1255 edata->delivery = efl_loop_job(efl_main_loop_get());
1256 eina_future_then(edata->delivery, _delivery, ee);
1257 edata->clipboard.delivery = delivery;
1258 edata->clipboard.cancel = cancel;
1259 edata->clipboard.available_types = available_types;
1260 return EINA_TRUE;
1261 }
1262}
1263
1264Eina_Future*
1265_ecore_evas_win32_selection_request(Ecore_Evas *ee EINA_UNUSED, unsigned int seat EINA_UNUSED, Ecore_Evas_Selection_Buffer selection, Eina_Array *acceptable_type)
1266{
1267 Eina_Future *future;
1268 Eina_Promise *promise;
1269 const char *mime_type = NULL;
1270
1271 if (selection != ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER)
1272 return eina_future_rejected(efl_loop_future_scheduler_get(efl_main_loop_get()), ecore_evas_no_selection);
1273
1274 promise = efl_loop_promise_new(efl_main_loop_get());
1275 future = eina_future_new(promise);
1276
1277 for (unsigned int i = 0; i < eina_array_count(acceptable_type); ++i)
1278 {
1279 mime_type = eina_array_data_get(acceptable_type, i);
1280 if (eina_str_has_prefix(mime_type, "text/"))
1281 break;
1282 }
1283 if (!mime_type)
1284 {
1285 eina_promise_reject(promise, ecore_evas_no_matching_type);
1286 }
1287 else
1288 {
1289 size_t size;
1290 void *data;
1291 Eina_Content *content;
1292 Eina_Rw_Slice slice;
1293
1294 data = ecore_win32_clipboard_get((Ecore_Win32_Window *)ee->prop.window, &size, mime_type);
1295 if (eina_str_has_prefix(mime_type, "text/"))
1296 {
1297 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
1298 slice.len = size + 1;
1299 slice.mem = eina_memdup(data, size, EINA_TRUE);
1300 }
1301 else
1302 {
1303 slice.len = size;
1304 slice.mem = data;
1305 }
1306 content = eina_content_new(eina_rw_slice_slice_get(slice), mime_type);
1307 if (!content) // construction can fail because of some validation reasons
1308 eina_promise_reject(promise, ecore_evas_no_matching_type);
1309 else
1310 eina_promise_resolve(promise, eina_value_content_init(content));
1311 }
1312 return future;
1313}
1314
1315static Eina_Bool
1316_ecore_evas_win32_selection_has_owner(Ecore_Evas *ee EINA_UNUSED, unsigned int seat EINA_UNUSED, Ecore_Evas_Selection_Buffer selection)
1317{
1318 return (selection == ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER);
1319}
1320
1200static Ecore_Evas_Engine_Func _ecore_win32_engine_func = 1321static Ecore_Evas_Engine_Func _ecore_win32_engine_func =
1201{ 1322{
1202 _ecore_evas_win32_free, 1323 _ecore_evas_win32_free,
1203 NULL, 1324 NULL,
1204 NULL, 1325 NULL,
1205 NULL, 1326 NULL,
1206 NULL, 1327 NULL,
1207 _ecore_evas_win32_callback_delete_request_set, 1328 _ecore_evas_win32_callback_delete_request_set,
1208 NULL, 1329 NULL,
1209 NULL, 1330 NULL,
1210 NULL, 1331 NULL,
1211 NULL, 1332 NULL,
1212 NULL, 1333 NULL,
1213 NULL, 1334 NULL,
1214 NULL, 1335 NULL,
1215 NULL, 1336 NULL,
1216 NULL, 1337 NULL,
1217 _ecore_evas_win32_move, 1338 _ecore_evas_win32_move,
1218 NULL, 1339 NULL,
1219 _ecore_evas_win32_resize, 1340 _ecore_evas_win32_resize,
1220 _ecore_evas_win32_move_resize, 1341 _ecore_evas_win32_move_resize,
1221 _ecore_evas_win32_rotation_set, 1342 _ecore_evas_win32_rotation_set,
1222 _ecore_evas_win32_shaped_set, 1343 _ecore_evas_win32_shaped_set,
1223 _ecore_evas_win32_show, 1344 _ecore_evas_win32_show,
1224 _ecore_evas_win32_hide, 1345 _ecore_evas_win32_hide,
1225 _ecore_evas_win32_raise, 1346 _ecore_evas_win32_raise,
1226 _ecore_evas_win32_lower, 1347 _ecore_evas_win32_lower,
1227 _ecore_evas_win32_activate, 1348 _ecore_evas_win32_activate,
1228 _ecore_evas_win32_title_set, 1349 _ecore_evas_win32_title_set,
1229 NULL, /* _ecore_evas_x_name_class_set */ 1350 NULL, /* _ecore_evas_x_name_class_set */
1230 _ecore_evas_win32_size_min_set, 1351 _ecore_evas_win32_size_min_set,
1231 _ecore_evas_win32_size_max_set, 1352 _ecore_evas_win32_size_max_set,
1232 _ecore_evas_win32_size_base_set, 1353 _ecore_evas_win32_size_base_set,
1233 _ecore_evas_win32_size_step_set, 1354 _ecore_evas_win32_size_step_set,
1234 _ecore_evas_win32_object_cursor_set, 1355 _ecore_evas_win32_object_cursor_set,
1235 _ecore_evas_win32_object_cursor_unset, 1356 _ecore_evas_win32_object_cursor_unset,
1236 NULL, /* _ecore_evas_x_layer_set */ 1357 NULL, /* _ecore_evas_x_layer_set */
1237 _ecore_evas_win32_focus_set, 1358 _ecore_evas_win32_focus_set,
1238 _ecore_evas_win32_iconified_set, 1359 _ecore_evas_win32_iconified_set,
1239 _ecore_evas_win32_borderless_set, 1360 _ecore_evas_win32_borderless_set,
1240 _ecore_evas_win32_override_set, 1361 _ecore_evas_win32_override_set,
1241 NULL, 1362 NULL,
1242 _ecore_evas_win32_fullscreen_set, 1363 _ecore_evas_win32_fullscreen_set,
1243 NULL, /* _ecore_evas_x_avoid_damage_set */ 1364 NULL, /* _ecore_evas_x_avoid_damage_set */
1244 NULL, /* _ecore_evas_x_withdrawn_set */ 1365 NULL, /* _ecore_evas_x_withdrawn_set */
1245 NULL, /* _ecore_evas_x_sticky_set */ 1366 NULL, /* _ecore_evas_x_sticky_set */
1246 NULL, /* _ecore_evas_x_ignore_events_set */ 1367 NULL, /* _ecore_evas_x_ignore_events_set */
1247 _ecore_evas_win32_alpha_set, 1368 _ecore_evas_win32_alpha_set,
1248 NULL, //transparent 1369 NULL, //transparent
1249 NULL, // profiles_set 1370 NULL, // profiles_set
1250 NULL, // profile_set 1371 NULL, // profile_set
1251 1372
1252 NULL, 1373 NULL,
1253 NULL, 1374 NULL,
1254 NULL, 1375 NULL,
1255 NULL, 1376 NULL,
1256 NULL, 1377 NULL,
1257 NULL, 1378 NULL,
1258 1379
1259 NULL, // render 1380 NULL, // render
1260 _ecore_evas_win32_screen_geometry_get, 1381 _ecore_evas_win32_screen_geometry_get,
1261 _ecore_evas_win32_screen_dpi_get, 1382 _ecore_evas_win32_screen_dpi_get,
1262 NULL, 1383 NULL,
1263 NULL, // msg_send 1384 NULL, // msg_send
1264 1385
1265 NULL, // pointer_xy_get 1386 NULL, // pointer_xy_get
1266 NULL, // pointer_warp 1387 NULL, // pointer_warp
1267 1388
1268 NULL, // wm_rot_preferred_rotation_set 1389 NULL, // wm_rot_preferred_rotation_set
1269 NULL, // wm_rot_available_rotations_set 1390 NULL, // wm_rot_available_rotations_set
1270 NULL, // wm_rot_manual_rotation_done_set 1391 NULL, // wm_rot_manual_rotation_done_set
1271 NULL, // wm_rot_manual_rotation_done 1392 NULL, // wm_rot_manual_rotation_done
1272 1393
1273 NULL, // aux_hints_set 1394 NULL, // aux_hints_set
1274 1395
1275 NULL, // fn_animator_register 1396 NULL, // fn_animator_register
1276 NULL, // fn_animator_unregister 1397 NULL, // fn_animator_unregister
1277 1398
1278 NULL, // fn_evas_changed 1399 NULL, // fn_evas_changed
1279 NULL, //fn_focus_device_set 1400 NULL, //fn_focus_device_set
1280 NULL, //fn_callback_focus_device_in_set 1401 NULL, //fn_callback_focus_device_in_set
1281 NULL, //fn_callback_focus_device_out_set 1402 NULL, //fn_callback_focus_device_out_set
1282 NULL, //fn_callback_device_mouse_in_set 1403 NULL, //fn_callback_device_mouse_in_set
1283 NULL, //fn_callback_device_mouse_out_set 1404 NULL, //fn_callback_device_mouse_out_set
1284 NULL, //fn_pointer_device_xy_get 1405 NULL, //fn_pointer_device_xy_get
1285 NULL, //fn_prepare 1406 NULL, //fn_prepare
1286 NULL, //fn_last_tick_get 1407 NULL, //fn_last_tick_get
1287 NULL, //fn_selection_claim 1408 _ecore_evas_win32_selection_claim, //fn_selection_claim
1288 NULL, //fn_selection_has_owner 1409 _ecore_evas_win32_selection_has_owner, //fn_selection_has_owner
1289 NULL, //fn_selection_request 1410 _ecore_evas_win32_selection_request, //fn_selection_request
1411 NULL, //fn_dnd_start
1412 NULL, //fn_dnd_stop
1290}; 1413};
1291 1414
1292#endif /* BUILD_ECORE_EVAS_WIN32 */ 1415#endif /* BUILD_ECORE_EVAS_WIN32 */