summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland/ecore_wl_dnd.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2013-11-07 14:30:49 +0000
committerChris Michael <cp.michael@samsung.com>2013-11-07 14:31:37 +0000
commitb3e309d04fbd6d3681e06bb3edfc50c8819d004d (patch)
tree69cd5261207acd1895f1ee762893206078e5640c /src/lib/ecore_wayland/ecore_wl_dnd.c
parent9240c2e91c93adacbeb1e6d1ea68d1eec3c5675d (diff)
Fix getting the clipboard selection and add missing LOGFN macros
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wayland/ecore_wl_dnd.c')
-rw-r--r--src/lib/ecore_wayland/ecore_wl_dnd.c57
1 files changed, 53 insertions, 4 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_dnd.c b/src/lib/ecore_wayland/ecore_wl_dnd.c
index f5849dcf9c..b1bf0664f3 100644
--- a/src/lib/ecore_wayland/ecore_wl_dnd.c
+++ b/src/lib/ecore_wayland/ecore_wl_dnd.c
@@ -54,6 +54,8 @@ _ecore_wl_dnd_offer_listener =
54EINA_DEPRECATED EAPI Eina_Bool 54EINA_DEPRECATED EAPI Eina_Bool
55ecore_wl_dnd_set_selection(Ecore_Wl_Dnd *dnd, const char **types_offered) 55ecore_wl_dnd_set_selection(Ecore_Wl_Dnd *dnd, const char **types_offered)
56{ 56{
57 LOGFN(__FILE__, __LINE__, __FUNCTION__);
58
57 return ecore_wl_dnd_selection_set(dnd->input, types_offered); 59 return ecore_wl_dnd_selection_set(dnd->input, types_offered);
58} 60}
59 61
@@ -64,6 +66,8 @@ ecore_wl_dnd_set_selection(Ecore_Wl_Dnd *dnd, const char **types_offered)
64EINA_DEPRECATED EAPI Eina_Bool 66EINA_DEPRECATED EAPI Eina_Bool
65ecore_wl_dnd_get_selection(Ecore_Wl_Dnd *dnd, const char *type) 67ecore_wl_dnd_get_selection(Ecore_Wl_Dnd *dnd, const char *type)
66{ 68{
69 LOGFN(__FILE__, __LINE__, __FUNCTION__);
70
67 return ecore_wl_dnd_selection_get(dnd->input, type); 71 return ecore_wl_dnd_selection_get(dnd->input, type);
68} 72}
69 73
@@ -108,6 +112,8 @@ ecore_wl_dnd_selection_set(Ecore_Wl_Input *input, const char **types_offered)
108 const char **type; 112 const char **type;
109 char **t; 113 char **t;
110 114
115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
116
111 if (!input) return EINA_FALSE; 117 if (!input) return EINA_FALSE;
112 118
113 man = input->display->wl.data_device_manager; 119 man = input->display->wl.data_device_manager;
@@ -125,6 +131,8 @@ ecore_wl_dnd_selection_set(Ecore_Wl_Input *input, const char **types_offered)
125 if (input->data_source) wl_data_source_destroy(input->data_source); 131 if (input->data_source) wl_data_source_destroy(input->data_source);
126 input->data_source = NULL; 132 input->data_source = NULL;
127 133
134 if (!types_offered[0]) return EINA_FALSE;
135
128 /* try to create a new data source */ 136 /* try to create a new data source */
129 if (!(input->data_source = wl_data_device_manager_create_data_source(man))) 137 if (!(input->data_source = wl_data_device_manager_create_data_source(man)))
130 return EINA_FALSE; 138 return EINA_FALSE;
@@ -157,11 +165,15 @@ ecore_wl_dnd_selection_get(Ecore_Wl_Input *input, const char *type)
157{ 165{
158 char **t; 166 char **t;
159 167
168 LOGFN(__FILE__, __LINE__, __FUNCTION__);
169
160 /* check for valid input and selection source */ 170 /* check for valid input and selection source */
161 if ((!input) || (!input->selection_source)) return EINA_FALSE; 171 if ((!input) || (!input->selection_source)) return EINA_FALSE;
162 172
163 wl_array_for_each(t, &input->selection_source->types) 173 for (t = input->selection_source->types.data; *t; t++)
164 if (!strcmp(type, *t)) break; 174 {
175 if (!strcmp(type, *t)) break;
176 }
165 177
166 if (!*t) return EINA_FALSE; 178 if (!*t) return EINA_FALSE;
167 179
@@ -177,6 +189,8 @@ ecore_wl_dnd_selection_get(Ecore_Wl_Input *input, const char *type)
177EAPI Eina_Bool 189EAPI Eina_Bool
178ecore_wl_dnd_selection_owner_has(Ecore_Wl_Input *input) 190ecore_wl_dnd_selection_owner_has(Ecore_Wl_Input *input)
179{ 191{
192 LOGFN(__FILE__, __LINE__, __FUNCTION__);
193
180 if (!input) return EINA_FALSE; 194 if (!input) return EINA_FALSE;
181 return (input->selection_source != NULL); 195 return (input->selection_source != NULL);
182} 196}
@@ -188,6 +202,8 @@ ecore_wl_dnd_selection_owner_has(Ecore_Wl_Input *input)
188EAPI Eina_Bool 202EAPI Eina_Bool
189ecore_wl_dnd_selection_clear(Ecore_Wl_Input *input) 203ecore_wl_dnd_selection_clear(Ecore_Wl_Input *input)
190{ 204{
205 LOGFN(__FILE__, __LINE__, __FUNCTION__);
206
191 /* check for valid input */ 207 /* check for valid input */
192 if (!input) return EINA_FALSE; 208 if (!input) return EINA_FALSE;
193 209
@@ -207,6 +223,8 @@ ecore_wl_dnd_drag_start(Ecore_Wl_Input *input, Ecore_Wl_Window *win, Ecore_Wl_Wi
207{ 223{
208 struct wl_surface *drag_surface; 224 struct wl_surface *drag_surface;
209 225
226 LOGFN(__FILE__, __LINE__, __FUNCTION__);
227
210 /* check for valid input. if not, get the default one */ 228 /* check for valid input. if not, get the default one */
211 if (!input) input = _ecore_wl_disp->input; 229 if (!input) input = _ecore_wl_disp->input;
212 230
@@ -258,6 +276,8 @@ ecore_wl_dnd_drag_end(Ecore_Wl_Input *input)
258{ 276{
259 Ecore_Wl_Event_Dnd_End *ev; 277 Ecore_Wl_Event_Dnd_End *ev;
260 278
279 LOGFN(__FILE__, __LINE__, __FUNCTION__);
280
261 /* check for valid input. if not, get the default one */ 281 /* check for valid input. if not, get the default one */
262 if (!input) input = _ecore_wl_disp->input; 282 if (!input) input = _ecore_wl_disp->input;
263 283
@@ -298,6 +318,8 @@ ecore_wl_dnd_drag_get(Ecore_Wl_Input *input, const char *type)
298{ 318{
299 char **t; 319 char **t;
300 320
321 LOGFN(__FILE__, __LINE__, __FUNCTION__);
322
301 /* check for valid input and drag source */ 323 /* check for valid input and drag source */
302 if ((!input) || (!input->drag_source)) return EINA_FALSE; 324 if ((!input) || (!input->drag_source)) return EINA_FALSE;
303 325
@@ -322,6 +344,8 @@ ecore_wl_dnd_drag_types_set(Ecore_Wl_Input *input, const char **types_offered)
322 const char **type; 344 const char **type;
323 char **t; 345 char **t;
324 346
347 LOGFN(__FILE__, __LINE__, __FUNCTION__);
348
325 /* check for valid input. if not, get the default one */ 349 /* check for valid input. if not, get the default one */
326 if (!input) input = _ecore_wl_disp->input; 350 if (!input) input = _ecore_wl_disp->input;
327 351
@@ -363,6 +387,8 @@ ecore_wl_dnd_drag_types_set(Ecore_Wl_Input *input, const char **types_offered)
363EAPI struct wl_array * 387EAPI struct wl_array *
364ecore_wl_dnd_drag_types_get(Ecore_Wl_Input *input) 388ecore_wl_dnd_drag_types_get(Ecore_Wl_Input *input)
365{ 389{
390 LOGFN(__FILE__, __LINE__, __FUNCTION__);
391
366 /* check for valid input. if not, get the default one */ 392 /* check for valid input. if not, get the default one */
367 if (!input) input = _ecore_wl_disp->input; 393 if (!input) input = _ecore_wl_disp->input;
368 394
@@ -375,6 +401,8 @@ _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device EINA
375{ 401{
376 Ecore_Wl_Dnd_Source *source; 402 Ecore_Wl_Dnd_Source *source;
377 403
404 LOGFN(__FILE__, __LINE__, __FUNCTION__);
405
378 if (!(source = malloc(sizeof(Ecore_Wl_Dnd_Source)))) 406 if (!(source = malloc(sizeof(Ecore_Wl_Dnd_Source))))
379 return; 407 return;
380 408
@@ -396,6 +424,8 @@ _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device EINA_UNUSED,
396 char **types; 424 char **types;
397 int num = 0; 425 int num = 0;
398 426
427 LOGFN(__FILE__, __LINE__, __FUNCTION__);
428
399 if (!(input = data)) return; 429 if (!(input = data)) return;
400 430
401 win = ecore_wl_window_surface_find(surface); 431 win = ecore_wl_window_surface_find(surface);
@@ -440,6 +470,8 @@ _ecore_wl_dnd_leave(void *data, struct wl_data_device *data_device EINA_UNUSED)
440 Ecore_Wl_Event_Dnd_Leave *ev; 470 Ecore_Wl_Event_Dnd_Leave *ev;
441 Ecore_Wl_Input *input; 471 Ecore_Wl_Input *input;
442 472
473 LOGFN(__FILE__, __LINE__, __FUNCTION__);
474
443 if (!(input = data)) return; 475 if (!(input = data)) return;
444 476
445 if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Dnd_Leave)))) return; 477 if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Dnd_Leave)))) return;
@@ -459,6 +491,8 @@ _ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device EINA_UNUSED,
459 Ecore_Wl_Event_Dnd_Position *ev; 491 Ecore_Wl_Event_Dnd_Position *ev;
460 Ecore_Wl_Input *input; 492 Ecore_Wl_Input *input;
461 493
494 LOGFN(__FILE__, __LINE__, __FUNCTION__);
495
462 if (!(input = data)) return; 496 if (!(input = data)) return;
463 497
464 input->sx = wl_fixed_to_int(x); 498 input->sx = wl_fixed_to_int(x);
@@ -484,6 +518,8 @@ _ecore_wl_dnd_drop(void *data, struct wl_data_device *data_device EINA_UNUSED)
484 Ecore_Wl_Event_Dnd_Drop *ev; 518 Ecore_Wl_Event_Dnd_Drop *ev;
485 Ecore_Wl_Input *input; 519 Ecore_Wl_Input *input;
486 520
521 LOGFN(__FILE__, __LINE__, __FUNCTION__);
522
487 if (!(input = data)) return; 523 if (!(input = data)) return;
488 524
489 if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Dnd_Drop)))) return; 525 if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Dnd_Drop)))) return;
@@ -507,9 +543,12 @@ _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device EINA_UNUS
507{ 543{
508 Ecore_Wl_Input *input; 544 Ecore_Wl_Input *input;
509 545
546 LOGFN(__FILE__, __LINE__, __FUNCTION__);
547
510 if (!(input = data)) return; 548 if (!(input = data)) return;
511 549
512 if (input->selection_source) _ecore_wl_dnd_del(input->selection_source); 550 if (input->selection_source) _ecore_wl_dnd_del(input->selection_source);
551 input->selection_source = NULL;
513 552
514 if (offer) 553 if (offer)
515 { 554 {
@@ -519,13 +558,13 @@ _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device EINA_UNUS
519 t = wl_array_add(&input->selection_source->types, sizeof(*t)); 558 t = wl_array_add(&input->selection_source->types, sizeof(*t));
520 *t = NULL; 559 *t = NULL;
521 } 560 }
522 else
523 input->selection_source = NULL;
524} 561}
525 562
526void 563void
527_ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source) 564_ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source)
528{ 565{
566 LOGFN(__FILE__, __LINE__, __FUNCTION__);
567
529 if (!source) return; 568 if (!source) return;
530 source->refcount--; 569 source->refcount--;
531 if (source->refcount == 0) 570 if (source->refcount == 0)
@@ -546,6 +585,8 @@ _ecore_wl_dnd_selection_data_receive(Ecore_Wl_Dnd_Source *source, const char *ty
546 struct _dnd_read_ctx *read_ctx = NULL; 585 struct _dnd_read_ctx *read_ctx = NULL;
547 int p[2]; 586 int p[2];
548 587
588 LOGFN(__FILE__, __LINE__, __FUNCTION__);
589
549 if (pipe2(p, O_CLOEXEC) == -1) 590 if (pipe2(p, O_CLOEXEC) == -1)
550 return; 591 return;
551 592
@@ -601,6 +642,8 @@ _ecore_wl_dnd_selection_data_read(void *data, Ecore_Fd_Handler *fd_handler EINA_
601 Ecore_Wl_Event_Selection_Data_Ready *event; 642 Ecore_Wl_Event_Selection_Data_Ready *event;
602 Eina_Bool ret; 643 Eina_Bool ret;
603 644
645 LOGFN(__FILE__, __LINE__, __FUNCTION__);
646
604 source = data; 647 source = data;
605 648
606 len = read(source->fd, buffer, sizeof buffer); 649 len = read(source->fd, buffer, sizeof buffer);
@@ -658,6 +701,8 @@ _ecore_wl_dnd_selection_cb_idle(void *data)
658 struct _dnd_task *task; 701 struct _dnd_task *task;
659 int count, i; 702 int count, i;
660 703
704 LOGFN(__FILE__, __LINE__, __FUNCTION__);
705
661 ctx = data; 706 ctx = data;
662 count = epoll_wait(ctx->epoll_fd, ctx->ep, 1, 0); 707 count = epoll_wait(ctx->epoll_fd, ctx->ep, 1, 0);
663 for (i = 0; i < count; i++) 708 for (i = 0; i < count; i++)
@@ -719,6 +764,8 @@ _ecore_wl_dnd_source_cb_send_free(void *data EINA_UNUSED, void *event)
719static void 764static void
720_ecore_wl_dnd_source_cb_cancelled(void *data EINA_UNUSED, struct wl_data_source *source) 765_ecore_wl_dnd_source_cb_cancelled(void *data EINA_UNUSED, struct wl_data_source *source)
721{ 766{
767 LOGFN(__FILE__, __LINE__, __FUNCTION__);
768
722 /* FIXME: Raise an Ecore_Wl_Event here */ 769 /* FIXME: Raise an Ecore_Wl_Event here */
723 wl_data_source_destroy(source); 770 wl_data_source_destroy(source);
724} 771}
@@ -729,6 +776,8 @@ _ecore_wl_dnd_offer_cb_offer(void *data, struct wl_data_offer *data_offer EINA_U
729 Ecore_Wl_Dnd_Source *source; 776 Ecore_Wl_Dnd_Source *source;
730 char **t; 777 char **t;
731 778
779 LOGFN(__FILE__, __LINE__, __FUNCTION__);
780
732 if (!(source = data)) return; 781 if (!(source = data)) return;
733 782
734 t = wl_array_add(&source->types, sizeof(*t)); 783 t = wl_array_add(&source->types, sizeof(*t));