efl_ui_win: add function client can start moving or resizing the window.

The result of this API can only guarantee that the request has been forwared to the server,
    In fact, there is no guarantee that the request can be processed by the server.

    In order to use this API correctly, avoid the following conditions.
    (The following situations will return a failure)

    1. Calling a function in the absence of a touch(mouse) down event.
    2. Calling the function twice more than once before the touch(mouse) up event.
    3. Calling the function when the elm win already resizing or moving the window.
    4. Calling the function using a combination of unsupported modes.

    Right usage
    1. touch(mouse) down event
    2. efl_ui_win_move_resize_start only once using the supported mode combination.
    3. touch(mouse) up event

    If a touch(mouse) up event occurs after calling the function, it automatically ends the window move and resize operation.

    Since there are some non-exclusive modes, you can use a combination of modes.(ELM_WIN_MOVE_RESIZE_MOVE is exclusive with others)
    However, Some combination of mode is limited for technical reasons.
    At present, only the following nine combinations are allowed.
    For more information, see the Elm.Win.Move_Resize_Mode.

    1. EFL_UI_WIN_MOVE_RESIZE_MOVE
    2. EFL_UI_WIN_MOVE_RESIZE_TOP
    3. EFL_UI_WIN_MOVE_RESIZE_BOTTOM
    4. EFL_UI_WIN_MOVE_RESIZE_LEFT
    5. EFL_UI_WIN_MOVE_RESIZE_RIGHT
    6. EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_LEFT
    7. EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_RIGHT
    8. EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_LEFT
    9. EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_RIGHT
This commit is contained in:
Ji-Youn Park 2016-11-21 20:21:15 +08:30
parent c34e4b6312
commit bfea8c8fca
3 changed files with 296 additions and 1 deletions

View File

@ -11,6 +11,9 @@ typedef struct _Testitem
static int rotate_with_resize = 0;
static Eina_Bool fullscreen = EINA_FALSE;
static Eina_Bool floating = EINA_FALSE;
static Evas_Object *win;
static void
my_bt_38_alpha_on(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
@ -133,6 +136,14 @@ my_ck_38_borderless(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
elm_win_borderless_set(win, borderless);
}
static void
my_ck_38_floating(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *win = data;
floating = elm_check_state_get(obj);
elm_win_floating_mode_set(win, floating);
}
static void
my_win_move(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -241,10 +252,62 @@ _win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
printf("win: hide\n");
}
static void
_bt_pressed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
int param = (int)(uintptr_t)(data);
Eina_Bool res = EINA_FALSE;
printf("pressed event on Button:%d\n", param);
switch (param)
{
case 1:
printf("Top Left\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_LEFT);
break;
case 2:
printf("Top\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_TOP);
break;
case 3:
printf("Top Right\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_RIGHT);
break;
case 4:
printf("Left\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_LEFT);
break;
case 5:
printf("Move win\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_MOVE);
break;
case 6:
printf("Right\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_RIGHT);
break;
case 7:
printf("Bottom Left\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_LEFT);
break;
case 8:
printf("Bottom\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_BOTTOM);
break;
case 9:
printf("Bottom Right\n");
res = elm_win_move_resize_start(win, EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_RIGHT);
break;
default:
printf("No action\n");
}
printf("result = %d\n", res);
}
void
test_win_state(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *bg, *sl, *bx, *bx2, *bt, *ck;
Evas_Object *bg, *sl, *bx, *bx2, *bt, *ck, *tb;
win = elm_win_add(NULL, "window-states", ELM_WIN_BASIC);
elm_win_title_set(win, "Window States");
@ -427,6 +490,15 @@ test_win_state(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
evas_object_show(ck);
elm_box_pack_end(bx, ck);
ck = elm_check_add(win);
elm_object_text_set(ck, "floating");
elm_check_state_set(ck, floating);
evas_object_smart_callback_add(ck, "changed", my_ck_38_floating, win);
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ck, 0.02, 0.99);
evas_object_show(ck);
elm_box_pack_end(bx, ck);
bx2 = elm_box_add(win);
elm_box_horizontal_set(bx2, EINA_TRUE);
elm_box_homogeneous_set(bx2, EINA_TRUE);
@ -476,6 +548,86 @@ test_win_state(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
elm_box_pack_end(bx, bx2);
evas_object_show(bx2);
tb = elm_table_add(win);
evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(tb);
bt = elm_button_add(win);
elm_object_text_set(bt, "Top Left");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)1);
elm_table_pack(tb, bt, 0, 0, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Top");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)2);
elm_table_pack(tb, bt, 1, 0, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Top Right");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)3);
elm_table_pack(tb, bt, 2, 0, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Left");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)4);
elm_table_pack(tb, bt, 0, 1, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Move");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)5);
elm_table_pack(tb, bt, 1, 1, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Right");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)6);
elm_table_pack(tb, bt, 2, 1, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Bot Left");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)7);
elm_table_pack(tb, bt, 0, 2, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Bottom");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)8);
elm_table_pack(tb, bt, 1, 2, 1, 1);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Bot Right");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "pressed", _bt_pressed, (void *)9);
elm_table_pack(tb, bt, 2, 2, 1, 1);
evas_object_show(bt);
elm_box_pack_end(bx, tb);
evas_object_resize(win, 280, 400);
evas_object_show(win);
}

View File

@ -2123,6 +2123,15 @@ _win_event_del_cb(void *data, const Efl_Event *ev)
}
}
static void
_elm_win_cb_mouse_up(void *data, const Efl_Event *ev EINA_UNUSED)
{
DBG("Evas mouse up event");
/*Currently wayland server didn't send mouse up event after resize the window*/
Efl_Ui_Win_Data *sd = data;
if(sd->resizing) sd->resizing = EINA_FALSE;
}
static void
_deferred_ecore_evas_free(void *data)
{
@ -2664,6 +2673,8 @@ _efl_ui_win_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Win_Data *sd)
efl_event_callback_del(obj, EFL_EVENT_CALLBACK_DEL, _win_event_del_cb, sd);
efl_event_callback_array_del(obj, _elm_win_evas_feed_fake_callbacks(), sd->evas);
efl_event_callback_del(sd->evas, EFL_EVENT_POINTER_UP, _elm_win_cb_mouse_up, sd);
evas_object_del(sd->box);
evas_object_del(sd->edje);
@ -4922,6 +4933,8 @@ _elm_win_finalize_internal(Eo *obj, Efl_Ui_Win_Data *sd, const char *name, Elm_W
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _win_event_add_cb, sd);
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_DEL, _win_event_del_cb, sd);
efl_event_callback_add(sd->evas, EFL_EVENT_POINTER_UP, _elm_win_cb_mouse_up, sd);
evas_object_show(sd->edje);
if (type == ELM_WIN_FAKE)
@ -6340,6 +6353,65 @@ _efl_ui_win_teamwork_uri_open(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const ch
#endif
}
EOLIAN static Eina_Bool
_efl_ui_win_move_resize_start(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Move_Resize_Mode mode)
{
Eina_Bool res = EINA_FALSE;
#ifdef HAVE_ELEMENTARY_WL2
if (!sd->wl.win) return res;
int i = 0;
//1. move_resize can be start after mouse down event
i = evas_event_down_count_get(sd->evas);
if (i <= 0) return res;
//2. check move_resize start already .
if (sd->resizing) return res;
i = sd->rot / 90;
if (mode == EFL_UI_WIN_MOVE_RESIZE_MOVE)
{
int ox, oy;
sd->resizing = EINA_TRUE;
edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.opaque",
&ox, &oy, NULL, NULL);
ecore_evas_wayland_move(sd->ee, ox, oy);
res = EINA_TRUE;
}
else
{
if(mode == EFL_UI_WIN_MOVE_RESIZE_TOP)
sd->resize_location = _border_side[(0 + i) % 4].location;
else if (mode == EFL_UI_WIN_MOVE_RESIZE_BOTTOM)
sd->resize_location = _border_side[(2 + i) % 4].location;
else if (mode == EFL_UI_WIN_MOVE_RESIZE_LEFT)
sd->resize_location = _border_side[(1 + i) % 4].location;
else if (mode == EFL_UI_WIN_MOVE_RESIZE_RIGHT)
sd->resize_location = _border_side[(3 + i) % 4].location;
else if (mode == (EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_LEFT))
sd->resize_location = _border_corner[(0 + i) % 4].location;
else if (mode == (EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_RIGHT))
sd->resize_location = _border_corner[(3 + i) % 4].location;
else if (mode == (EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_LEFT))
sd->resize_location = _border_corner[(1 + i) % 4].location;
else if (mode == (EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_RIGHT))
sd->resize_location = _border_corner[(2 + i) % 4].location;
else
sd->resize_location = 0;
if (sd->resize_location > 0)
{
sd->resizing = EINA_TRUE;
ecore_evas_wayland_resize(sd->ee, sd->resize_location);
res = EINA_TRUE;
}
}
#endif
return res;
}
/* legacy APIs */
EAPI void

View File

@ -140,6 +140,34 @@ enum Efl.Ui.Win.Urgent_Mode
urgent [[The window is a urgent window.]]
}
enum Efl.Ui.Win.Move_Resize_Mode
{
[[Define the move or resize mode of window.
The user can request the server to start moving or resizing the window by combining this modes.
However, only limited combinations are allowd.
Currently, only the following 9 combinations are allowed (ELM_WIN_MOVE_RESIZE_MOVE should be used alone),
and possibly more combinations may be added in the future.
1. EFL_UI_WIN_MOVE_RESIZE_MOVE
2. EFL_UI_WIN_MOVE_RESIZE_TOP
3. EFL_UI_WIN_MOVE_RESIZE_BOTTOM
4. EFL_UI_WIN_MOVE_RESIZE_LEFT
5. EFL_UI_WIN_MOVE_RESIZE_RIGHT
6. EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_LEFT
7. EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_RIGHT
8. EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_LEFT
9. EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_RIGHT
]]
legacy: efl_ui_win_move_resize;
move = 0, [[start moving window]]
top = (1 << 1), [[start resizing window to the top]]
bottom = (1 << 2), [[start resizing window to the bottom]]
left = (1 << 3), [[start resizing window to the left]]
right = (1 << 4) [[start resizing window to the right]]
}
class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
Elm.Interface.Atspi_Widget_Action, Efl.Pack,
Efl.Input.State, Efl.Input.Interface, Efl.Screen,
@ -808,6 +836,49 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
@in uri: string; [[This is the uri to open]]
}
}
move_resize_start {
[[Start moving or resizing the window.
The user can request the server to start moving or resizing the window by combining Elm.Win.Move_Resize_Mode.
The result of this API can only guarantee that the request has been forwared to the server,
In fact, there is no guarantee that the request can be processed by the server.
In order to use this API correctly, avoid the following conditions.
(The following situations will return a failure)
1. Calling a function in the absence of a touch(mouse) down event.
2. Calling the function twice more than once before the touch(mouse) up event.
3. Calling the function when the elm win already resizing or moving the window.
4. Calling the function using a combination of unsupported modes.
Right usage
1. touch(mouse) down event
2. efl_ui_win_move_resize_start only once using the supported mode combination.
3. touch(mouse) up event
If a touch(mouse) up event occurs after calling the function, it automatically ends the window move and resize operation.
Since there are some non-exclusive modes, you can use a combination of modes.(ELM_WIN_MOVE_RESIZE_MOVE is exclusive with others)
However, Some combination of mode is limited for technical reasons.
At present, only the following nine combinations are allowed.
For more information, see the Elm.Win.Move_Resize_Mode.
1. EFL_UI_WIN_MOVE_RESIZE_MOVE
2. EFL_UI_WIN_MOVE_RESIZE_TOP
3. EFL_UI_WIN_MOVE_RESIZE_BOTTOM
4. EFL_UI_WIN_MOVE_RESIZE_LEFT
5. EFL_UI_WIN_MOVE_RESIZE_RIGHT
6. EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_LEFT
7. EFL_UI_WIN_MOVE_RESIZE_TOP | EFL_UI_WIN_MOVE_RESIZE_RIGHT
8. EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_LEFT
9. EFL_UI_WIN_MOVE_RESIZE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_RIGHT
]]
return: bool; [[$true = success to send request to server, $false = error]]
params {
@in mode: Efl.Ui.Win.Move_Resize_Mode; [[According to the move resize mode, it can request move resize to the server differently.]]
}
}
}
implements {
class.constructor;