summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2015-06-23 18:11:05 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-06-24 08:26:38 +0300
commita5fadcb53791f5b41cafe023080286354d5c41dd (patch)
tree63ae2f270fa8abe97bcc736e4b5bf4d8442fed9e
parentd904e9761e417ec945e0d401735f769aaa19a480 (diff)
X11/CnP: remove X11 invocations from elm_entry
Code specific to X11 should not be part of elm_entry and can be easily replaced with elm_cnp APIs. @fix T2183
-rw-r--r--src/lib/elm_entry.c155
-rw-r--r--src/lib/elm_widget_entry.h2
2 files changed, 29 insertions, 128 deletions
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index 1724cb61a..2187a4ac8 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -1411,6 +1411,19 @@ _paste_cb(void *data,
1411} 1411}
1412 1412
1413static void 1413static void
1414_selection_clear(void *data, Elm_Sel_Type selection)
1415{
1416 ELM_ENTRY_DATA_GET(data, sd);
1417
1418 if (!sd->have_selection) return;
1419 if ((selection == ELM_SEL_TYPE_CLIPBOARD) ||
1420 (selection == ELM_SEL_TYPE_PRIMARY))
1421 {
1422 elm_entry_select_none(data);
1423 }
1424}
1425
1426static void
1414_selection_store(Elm_Sel_Type seltype, 1427_selection_store(Elm_Sel_Type seltype,
1415 Evas_Object *obj) 1428 Evas_Object *obj)
1416{ 1429{
@@ -1423,6 +1436,7 @@ _selection_store(Elm_Sel_Type seltype,
1423 1436
1424 elm_cnp_selection_set 1437 elm_cnp_selection_set
1425 (obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel)); 1438 (obj, seltype, ELM_SEL_FORMAT_MARKUP, sel, strlen(sel));
1439 elm_cnp_selection_loss_callback_set(obj, seltype, _selection_clear, obj);
1426 if (seltype == ELM_SEL_TYPE_CLIPBOARD) 1440 if (seltype == ELM_SEL_TYPE_CLIPBOARD)
1427 eina_stringshare_replace(&sd->cut_sel, sel); 1441 eina_stringshare_replace(&sd->cut_sel, sel);
1428} 1442}
@@ -2055,8 +2069,11 @@ _entry_selection_start_signal_cb(void *data,
2055 2069
2056 top = elm_widget_top_get(data); 2070 top = elm_widget_top_get(data);
2057 if (txt && top && (elm_win_window_id_get(top))) 2071 if (txt && top && (elm_win_window_id_get(top)))
2058 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY, 2072 {
2059 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt)); 2073 elm_cnp_selection_set(data, ELM_SEL_TYPE_PRIMARY,
2074 ELM_SEL_FORMAT_MARKUP, txt, strlen(txt));
2075 elm_cnp_selection_loss_callback_set(data, ELM_SEL_TYPE_PRIMARY, _selection_clear, data);
2076 }
2060 elm_object_focus_set(data, EINA_TRUE); 2077 elm_object_focus_set(data, EINA_TRUE);
2061} 2078}
2062 2079
@@ -2106,28 +2123,18 @@ _entry_selection_cleared_signal_cb(void *data,
2106 2123
2107 sd->have_selection = EINA_FALSE; 2124 sd->have_selection = EINA_FALSE;
2108 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL); 2125 evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
2109 if (sd->sel_notify_handler) 2126 if (sd->cut_sel)
2110 { 2127 {
2111 if (sd->cut_sel) 2128 elm_cnp_selection_set
2112 { 2129 (data, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_MARKUP,
2113 Evas_Object *top; 2130 sd->cut_sel, eina_stringshare_strlen(sd->cut_sel));
2114 2131 elm_cnp_selection_loss_callback_set(data, ELM_SEL_TYPE_PRIMARY, _selection_clear, data);
2115 top = elm_widget_top_get(data);
2116 if ((top) && (elm_win_window_id_get(top)))
2117 elm_cnp_selection_set
2118 (data, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_MARKUP,
2119 sd->cut_sel, eina_stringshare_strlen(sd->cut_sel));
2120
2121 ELM_SAFE_FREE(sd->cut_sel, eina_stringshare_del);
2122 }
2123 else
2124 {
2125 Evas_Object *top;
2126 2132
2127 top = elm_widget_top_get(data); 2133 ELM_SAFE_FREE(sd->cut_sel, eina_stringshare_del);
2128 if ((top) && (elm_win_window_id_get(top))) 2134 }
2129 elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY); 2135 else
2130 } 2136 {
2137 elm_object_cnp_selection_clear(data, ELM_SEL_TYPE_PRIMARY);
2131 } 2138 }
2132 _hide_selection_handler(data); 2139 _hide_selection_handler(data);
2133} 2140}
@@ -2515,87 +2522,6 @@ _entry_mouse_triple_signal_cb(void *data,
2515 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL); 2522 evas_object_smart_callback_call(data, SIG_CLICKED_TRIPLE, NULL);
2516} 2523}
2517 2524
2518#ifdef HAVE_ELEMENTARY_X
2519static Eina_Bool
2520_event_selection_notify(void *data,
2521 int type EINA_UNUSED,
2522 void *event)
2523{
2524 Ecore_X_Event_Selection_Notify *ev = event;
2525
2526 ELM_ENTRY_DATA_GET(data, sd);
2527
2528 if ((!sd->selection_asked) && (!sd->drag_selection_asked))
2529 return ECORE_CALLBACK_PASS_ON;
2530
2531 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2532 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2533 {
2534 Ecore_X_Selection_Data_Text *text_data;
2535
2536 text_data = ev->data;
2537 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2538 {
2539 if (text_data->text)
2540 {
2541 char *txt = _elm_util_text_to_mkup(text_data->text);
2542
2543 if (txt)
2544 {
2545 elm_entry_entry_insert(data, txt);
2546 free(txt);
2547 }
2548 }
2549 }
2550 sd->selection_asked = EINA_FALSE;
2551 }
2552 else if (ev->selection == ECORE_X_SELECTION_XDND)
2553 {
2554 Ecore_X_Selection_Data_Text *text_data;
2555
2556 text_data = ev->data;
2557 if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
2558 {
2559 if (text_data->text)
2560 {
2561 char *txt = _elm_util_text_to_mkup(text_data->text);
2562
2563 if (txt)
2564 {
2565 /* Massive FIXME: this should be at the drag point */
2566 elm_entry_entry_insert(data, txt);
2567 free(txt);
2568 }
2569 }
2570 }
2571 sd->drag_selection_asked = EINA_FALSE;
2572
2573 ecore_x_dnd_send_finished();
2574 }
2575
2576 return ECORE_CALLBACK_PASS_ON;
2577}
2578
2579static Eina_Bool
2580_event_selection_clear(void *data EINA_UNUSED,
2581 int type EINA_UNUSED,
2582 void *event EINA_UNUSED)
2583{
2584 Ecore_X_Event_Selection_Clear *ev = event;
2585
2586 ELM_ENTRY_DATA_GET(data, sd);
2587
2588 if (!sd->have_selection) return ECORE_CALLBACK_PASS_ON;
2589 if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
2590 (ev->selection == ECORE_X_SELECTION_PRIMARY))
2591 {
2592 elm_entry_select_none(data);
2593 }
2594
2595 return ECORE_CALLBACK_PASS_ON;
2596}
2597#endif
2598
2599static Evas_Object * 2525static Evas_Object *
2600_item_get(void *data, 2526_item_get(void *data,
2601 Evas_Object *edje EINA_UNUSED, 2527 Evas_Object *edje EINA_UNUSED,
@@ -3404,10 +3330,6 @@ _end_handler_mouse_move_cb(void *data,
3404EOLIAN static void 3330EOLIAN static void
3405_elm_entry_evas_object_smart_add(Eo *obj, Elm_Entry_Data *priv) 3331_elm_entry_evas_object_smart_add(Eo *obj, Elm_Entry_Data *priv)
3406{ 3332{
3407#ifdef HAVE_ELEMENTARY_X
3408 Evas_Object *top;
3409#endif
3410
3411 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 3333 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
3412 3334
3413 eo_do_super(obj, MY_CLASS, evas_obj_smart_add()); 3335 eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
@@ -3540,21 +3462,6 @@ _elm_entry_evas_object_smart_add(Eo *obj, Elm_Entry_Data *priv)
3540 priv->autocapital_type = (Elm_Autocapital_Type)edje_object_part_text_autocapital_type_get 3462 priv->autocapital_type = (Elm_Autocapital_Type)edje_object_part_text_autocapital_type_get
3541 (priv->entry_edje, "elm.text"); 3463 (priv->entry_edje, "elm.text");
3542 3464
3543#ifdef HAVE_ELEMENTARY_X
3544 top = elm_widget_top_get(obj);
3545 if (!eo_isa(top, ELM_WIN_CLASS))
3546 top = ecore_evas_data_get(ecore_evas_ecore_evas_get(evas_object_evas_get(obj)), "elm_win");
3547 if ((top) && (elm_win_xwindow_get(top)))
3548 {
3549 priv->sel_notify_handler =
3550 ecore_event_handler_add
3551 (ECORE_X_EVENT_SELECTION_NOTIFY, _event_selection_notify, obj);
3552 priv->sel_clear_handler =
3553 ecore_event_handler_add
3554 (ECORE_X_EVENT_SELECTION_CLEAR, _event_selection_clear, obj);
3555 }
3556#endif
3557
3558 entries = eina_list_prepend(entries, obj); 3465 entries = eina_list_prepend(entries, obj);
3559 3466
3560 // module - find module for entry 3467 // module - find module for entry
@@ -3638,10 +3545,6 @@ _elm_entry_evas_object_smart_del(Eo *obj, Elm_Entry_Data *sd)
3638 evas_object_del(sd->mgf_clip); 3545 evas_object_del(sd->mgf_clip);
3639 3546
3640 entries = eina_list_remove(entries, obj); 3547 entries = eina_list_remove(entries, obj);
3641#ifdef HAVE_ELEMENTARY_X
3642 ecore_event_handler_del(sd->sel_notify_handler);
3643 ecore_event_handler_del(sd->sel_clear_handler);
3644#endif
3645 eina_stringshare_del(sd->cut_sel); 3548 eina_stringshare_del(sd->cut_sel);
3646 eina_stringshare_del(sd->text); 3549 eina_stringshare_del(sd->text);
3647 ecore_job_del(sd->deferred_recalc_job); 3550 ecore_job_del(sd->deferred_recalc_job);
diff --git a/src/lib/elm_widget_entry.h b/src/lib/elm_widget_entry.h
index 4af06b9b9..e2c21eb20 100644
--- a/src/lib/elm_widget_entry.h
+++ b/src/lib/elm_widget_entry.h
@@ -38,8 +38,6 @@ struct _Elm_Entry_Data
38 Evas_Object *start_handler; 38 Evas_Object *start_handler;
39 Evas_Object *end_handler; 39 Evas_Object *end_handler;
40 Ecore_Job *deferred_recalc_job; 40 Ecore_Job *deferred_recalc_job;
41 Ecore_Event_Handler *sel_notify_handler;
42 Ecore_Event_Handler *sel_clear_handler;
43 Ecore_Timer *longpress_timer; 41 Ecore_Timer *longpress_timer;
44 Ecore_Timer *delay_write; 42 Ecore_Timer *delay_write;
45 /* for deferred appending */ 43 /* for deferred appending */