forked from enlightenment/efl
Ecore_Wayland: Rework ecore_wayland to match current wayland git wrt
pointer grabs, shm_pool interface. Rename fields of the wl_event_mouse_in/out structures to match other ecore event structs. Add API functions for getting a list of outputs, for getting a windows shell_surface, and for setting a windows parent. SVN revision: 69997
This commit is contained in:
parent
a74871955c
commit
5d4554996f
|
@ -65,6 +65,7 @@ struct _Ecore_Wl_Display
|
|||
struct wl_display *display;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_shell *desktop_shell;
|
||||
struct wl_shm *shm;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
} wl;
|
||||
|
@ -161,9 +162,9 @@ struct _Ecore_Wl_Event_Mouse_In
|
|||
{
|
||||
int x, y;
|
||||
} root;
|
||||
unsigned int win;
|
||||
unsigned int event_win;
|
||||
unsigned int root_win;
|
||||
unsigned int window;
|
||||
unsigned int event_window;
|
||||
unsigned int root_window;
|
||||
unsigned int timestamp;
|
||||
};
|
||||
|
||||
|
@ -175,9 +176,9 @@ struct _Ecore_Wl_Event_Mouse_Out
|
|||
{
|
||||
int x, y;
|
||||
} root;
|
||||
unsigned int win;
|
||||
unsigned int event_win;
|
||||
unsigned int root_win;
|
||||
unsigned int window;
|
||||
unsigned int event_window;
|
||||
unsigned int root_window;
|
||||
unsigned int timestamp;
|
||||
};
|
||||
|
||||
|
@ -281,6 +282,8 @@ EAPI void ecore_wl_display_iterate(void);
|
|||
EAPI void ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button);
|
||||
EAPI void ecore_wl_input_ungrab(Ecore_Wl_Input *input, unsigned int timestamp);
|
||||
|
||||
EAPI struct wl_list ecore_wl_outputs_get(void);
|
||||
|
||||
EAPI Ecore_Wl_Window *ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buffer_type);
|
||||
EAPI void ecore_wl_window_free(Ecore_Wl_Window *win);
|
||||
EAPI void ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y);
|
||||
|
@ -295,8 +298,10 @@ EAPI void ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscr
|
|||
EAPI void ecore_wl_window_transparent_set(Ecore_Wl_Window *win, Eina_Bool transparent);
|
||||
EAPI void ecore_wl_window_update_size(Ecore_Wl_Window *win, int w, int h);
|
||||
EAPI struct wl_surface *ecore_wl_window_surface_get(Ecore_Wl_Window *win);
|
||||
EAPI struct wl_shell_surface *ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win);
|
||||
EAPI Ecore_Wl_Window *ecore_wl_window_find(unsigned int id);
|
||||
EAPI void ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type);
|
||||
EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_buffer *buffer, int hot_x, int hot_y, unsigned int timestamp);
|
||||
EAPI void ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -411,6 +411,8 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char
|
|||
|
||||
ewd = data;
|
||||
|
||||
/* TODO: Add listener for wl_display so we can catch fatal errors !! */
|
||||
|
||||
if (!strcmp(interface, "wl_compositor"))
|
||||
ewd->wl.compositor = wl_display_bind(disp, id, &wl_compositor_interface);
|
||||
else if (!strcmp(interface, "wl_output"))
|
||||
|
@ -419,6 +421,8 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char
|
|||
_ecore_wl_input_add(ewd, id);
|
||||
else if (!strcmp(interface, "wl_shell"))
|
||||
ewd->wl.shell = wl_display_bind(disp, id, &wl_shell_interface);
|
||||
/* else if (!strcmp(interface, "desktop_shell")) */
|
||||
/* ewd->wl.desktop_shell = wl_display_bind(disp, id, &wl_shell_interface); */
|
||||
else if (!strcmp(interface, "wl_shm"))
|
||||
ewd->wl.shm = wl_display_bind(disp, id, &wl_shm_interface);
|
||||
else if (!strcmp(interface, "wl_data_device_manager"))
|
||||
|
|
|
@ -44,6 +44,7 @@ static void _ecore_wl_input_cb_data_drop(void *data, struct wl_data_device *data
|
|||
static void _ecore_wl_input_cb_data_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer);
|
||||
|
||||
static void _ecore_wl_input_keyboard_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp);
|
||||
static void _ecore_wl_input_pointer_focus_set(Ecore_Wl_Input *input, Ecore_Wl_Window *focus, unsigned int timestamp, int x, int y);
|
||||
static void _ecore_wl_input_pointer_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp);
|
||||
static void _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, unsigned int timestamp);
|
||||
static void _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, unsigned int timestamp);
|
||||
|
@ -100,10 +101,11 @@ ecore_wl_input_ungrab(Ecore_Wl_Input *input, unsigned int timestamp)
|
|||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
input->grab = NULL;
|
||||
input->grab_button = 0;
|
||||
|
||||
if (input->pointer_focus)
|
||||
{
|
||||
printf("Ungrab: %d\n", timestamp);
|
||||
}
|
||||
_ecore_wl_input_pointer_focus_set(input, input->pointer_focus,
|
||||
timestamp, input->sx, input->sy);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -179,6 +181,10 @@ _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNU
|
|||
input->sx = sx;
|
||||
input->sy = sy;
|
||||
|
||||
if (!(input->grab && input->grab_button))
|
||||
_ecore_wl_input_pointer_focus_set(input, input->pointer_focus,
|
||||
timestamp, sx, sy);
|
||||
|
||||
/* TODO: FIXME: NB: Weston window code has set pointer image here also */
|
||||
_ecore_wl_input_mouse_move_send(input, timestamp);
|
||||
}
|
||||
|
@ -197,17 +203,11 @@ _ecore_wl_input_cb_button(void *data, struct wl_input_device *input_device __UNU
|
|||
if ((input->pointer_focus) && (!input->grab) && (state))
|
||||
ecore_wl_input_grab(input, input->pointer_focus, button);
|
||||
|
||||
// _ecore_wl_input_mouse_move_send(input, timestamp);
|
||||
|
||||
if ((button >= BTN_SIDE) && (button <= BTN_BACK))
|
||||
{
|
||||
/* TODO: raise mouse wheel */
|
||||
printf("Raise Mouse Wheel Event\n");
|
||||
}
|
||||
else
|
||||
if (input->grab)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
|
||||
input->button = button;
|
||||
_ecore_wl_input_mouse_down_send(input, timestamp);
|
||||
}
|
||||
|
@ -215,11 +215,11 @@ _ecore_wl_input_cb_button(void *data, struct wl_input_device *input_device __UNU
|
|||
{
|
||||
_ecore_wl_input_mouse_up_send(input, timestamp);
|
||||
input->button = 0;
|
||||
|
||||
if ((input->grab) && (input->grab_button == button))
|
||||
ecore_wl_input_ungrab(input, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
if ((input->grab) && (input->grab_button == button) && (!state))
|
||||
ecore_wl_input_ungrab(input, timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -272,36 +272,15 @@ _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_devic
|
|||
|
||||
if (!(input = data)) return;
|
||||
|
||||
/* _pointer_x = sx; */
|
||||
/* _pointer_y = sy; */
|
||||
if ((win = wl_surface_get_user_data(surface)))
|
||||
win->pointer_device = input;
|
||||
else
|
||||
return;
|
||||
|
||||
/* input->sx = sx; */
|
||||
/* input->sy = sy; */
|
||||
input->sx = sx;
|
||||
input->sy = sy;
|
||||
|
||||
// _ecore_wl_input_mouse_move_send(input, timestamp);
|
||||
|
||||
win = input->pointer_focus;
|
||||
if ((win) && (win->surface != surface))
|
||||
{
|
||||
if (!input->button)
|
||||
_ecore_wl_input_pointer_focus_remove(input, timestamp);
|
||||
}
|
||||
|
||||
if (surface)
|
||||
{
|
||||
if ((win = wl_surface_get_user_data(surface)))
|
||||
{
|
||||
input->pointer_focus = win;
|
||||
win->pointer_device = input;
|
||||
}
|
||||
/* if (input->button) */
|
||||
/* { */
|
||||
/* _ecore_wl_input_mouse_up_send(input, timestamp); */
|
||||
/* input->button = 0; */
|
||||
/* } */
|
||||
/* else */
|
||||
_ecore_wl_input_mouse_in_send(input, timestamp);
|
||||
}
|
||||
_ecore_wl_input_pointer_focus_set(input, win, timestamp, sx, sy);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -326,22 +305,17 @@ _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_devi
|
|||
|
||||
if (!(input = data)) return;
|
||||
|
||||
input->keyboard_focus = wl_surface_get_user_data(surface);
|
||||
|
||||
end = keys->data + keys->size;
|
||||
input->modifiers = 0;
|
||||
for (k = keys->data; k < end; k++)
|
||||
input->modifiers |= _ecore_wl_disp->xkb->map->modmap[*k];
|
||||
|
||||
if (surface)
|
||||
{
|
||||
if ((win = wl_surface_get_user_data(surface)))
|
||||
{
|
||||
input->keyboard_focus = win;
|
||||
win->keyboard_device = input;
|
||||
}
|
||||
else
|
||||
input->keyboard_focus = NULL;
|
||||
_ecore_wl_input_focus_in_send(input, timestamp);
|
||||
}
|
||||
win = input->keyboard_focus;
|
||||
win->keyboard_device = input;
|
||||
|
||||
_ecore_wl_input_focus_in_send(input, timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -474,12 +448,43 @@ _ecore_wl_input_keyboard_focus_remove(Ecore_Wl_Input *input, unsigned int timest
|
|||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(win = input->keyboard_focus)) return;
|
||||
|
||||
win->keyboard_device = NULL;
|
||||
|
||||
_ecore_wl_input_focus_out_send(input, timestamp);
|
||||
if ((win = input->keyboard_focus))
|
||||
win->keyboard_device = NULL;
|
||||
|
||||
input->keyboard_focus = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_wl_input_pointer_focus_set(Ecore_Wl_Input *input, Ecore_Wl_Window *focus, unsigned int timestamp, int x, int y)
|
||||
{
|
||||
if ((focus) && (focus == input->pointer_focus)) return;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
input->sx = x;
|
||||
input->sy = y;
|
||||
|
||||
if (input->pointer_focus)
|
||||
{
|
||||
Ecore_Wl_Window *nwin;
|
||||
|
||||
nwin = input->pointer_focus;
|
||||
_ecore_wl_input_mouse_out_send(input, timestamp);
|
||||
input->pointer_focus = NULL;
|
||||
nwin->pointer_device = NULL;
|
||||
}
|
||||
|
||||
if (focus)
|
||||
{
|
||||
input->pointer_focus = focus;
|
||||
_ecore_wl_input_mouse_in_send(input, timestamp);
|
||||
focus->pointer_device = input;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_wl_input_pointer_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp)
|
||||
{
|
||||
|
@ -487,13 +492,12 @@ _ecore_wl_input_pointer_focus_remove(Ecore_Wl_Input *input, unsigned int timesta
|
|||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!input->button)
|
||||
_ecore_wl_input_mouse_out_send(input, timestamp);
|
||||
win = input->pointer_focus;
|
||||
|
||||
if ((win = input->pointer_focus))
|
||||
win->pointer_device = NULL;
|
||||
_ecore_wl_input_pointer_focus_set(input, NULL, timestamp, 0, 0);
|
||||
|
||||
input->pointer_focus = NULL;
|
||||
if (win) win->pointer_device = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -551,10 +555,15 @@ _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, unsigned int timestamp)
|
|||
ev->modifiers = input->modifiers;
|
||||
ev->timestamp = timestamp;
|
||||
|
||||
if (input->pointer_focus)
|
||||
if (input->grab)
|
||||
{
|
||||
ev->win = input->pointer_focus->id;
|
||||
ev->event_win = input->pointer_focus->id;
|
||||
ev->window = input->grab->id;
|
||||
ev->event_window = input->grab->id;
|
||||
}
|
||||
else if (input->pointer_focus)
|
||||
{
|
||||
ev->window = input->pointer_focus->id;
|
||||
ev->event_window = input->pointer_focus->id;
|
||||
}
|
||||
|
||||
ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL);
|
||||
|
@ -576,10 +585,15 @@ _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, unsigned int timestamp)
|
|||
ev->modifiers = input->modifiers;
|
||||
ev->timestamp = timestamp;
|
||||
|
||||
if (input->pointer_focus)
|
||||
if (input->grab)
|
||||
{
|
||||
ev->win = input->pointer_focus->id;
|
||||
ev->event_win = input->pointer_focus->id;
|
||||
ev->window = input->grab->id;
|
||||
ev->event_window = input->grab->id;
|
||||
}
|
||||
else if (input->pointer_focus)
|
||||
{
|
||||
ev->window = input->pointer_focus->id;
|
||||
ev->event_window = input->pointer_focus->id;
|
||||
}
|
||||
|
||||
ecore_event_add(ECORE_WL_EVENT_MOUSE_OUT, ev, NULL, NULL);
|
||||
|
@ -651,7 +665,12 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, unsigned int timestamp)
|
|||
ev->multi.x = input->sx;
|
||||
ev->multi.y = input->sy;
|
||||
|
||||
if (input->pointer_focus)
|
||||
if (input->grab)
|
||||
{
|
||||
ev->window = input->grab->id;
|
||||
ev->event_window = input->grab->id;
|
||||
}
|
||||
else if (input->pointer_focus)
|
||||
{
|
||||
ev->window = input->pointer_focus->id;
|
||||
ev->event_window = input->pointer_focus->id;
|
||||
|
@ -698,7 +717,12 @@ _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, unsigned int timestamp)
|
|||
ev->multi.x = input->sx;
|
||||
ev->multi.y = input->sy;
|
||||
|
||||
if (input->pointer_focus)
|
||||
if (input->grab)
|
||||
{
|
||||
ev->window = input->grab->id;
|
||||
ev->event_window = input->grab->id;
|
||||
}
|
||||
else if (input->pointer_focus)
|
||||
{
|
||||
ev->window = input->pointer_focus->id;
|
||||
ev->event_window = input->pointer_focus->id;
|
||||
|
@ -733,7 +757,12 @@ _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int v
|
|||
/* TODO: handle horizontal scroll */
|
||||
}
|
||||
|
||||
if (input->pointer_focus)
|
||||
if (input->grab)
|
||||
{
|
||||
ev->window = input->grab->id;
|
||||
ev->event_window = input->grab->id;
|
||||
}
|
||||
else if (input->pointer_focus)
|
||||
{
|
||||
ev->window = input->pointer_focus->id;
|
||||
ev->event_window = input->pointer_focus->id;
|
||||
|
|
|
@ -18,6 +18,13 @@ static const struct wl_output_listener _ecore_wl_output_listener =
|
|||
_ecore_wl_output_cb_mode
|
||||
};
|
||||
|
||||
/* @since 1.2 */
|
||||
EAPI struct wl_list
|
||||
ecore_wl_outputs_get(void)
|
||||
{
|
||||
return _ecore_wl_disp->outputs;
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id)
|
||||
{
|
||||
|
|
|
@ -156,9 +156,15 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
|
|||
if (!(input = win->keyboard_device))
|
||||
{
|
||||
if (win->parent)
|
||||
input = win->parent->keyboard_device;
|
||||
{
|
||||
if (!(input = win->parent->keyboard_device))
|
||||
input = win->parent->pointer_device;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!input) || (!input->input_device)) return;
|
||||
|
||||
ecore_wl_input_ungrab(input, input->timestamp);
|
||||
wl_shell_surface_move(win->shell_surface, input->input_device,
|
||||
input->timestamp);
|
||||
}
|
||||
|
@ -205,7 +211,18 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
|
|||
{
|
||||
Ecore_Wl_Input *input;
|
||||
|
||||
input = win->keyboard_device;
|
||||
if (!(input = win->keyboard_device))
|
||||
{
|
||||
if (win->parent)
|
||||
{
|
||||
if (!(input = win->parent->keyboard_device))
|
||||
input = win->parent->pointer_device;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!input) || (!input->input_device)) return;
|
||||
|
||||
ecore_wl_input_ungrab(input, input->timestamp);
|
||||
wl_shell_surface_resize(win->shell_surface, input->input_device,
|
||||
input->timestamp, location);
|
||||
}
|
||||
|
@ -298,7 +315,6 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
|
|||
if (win->surface) return;
|
||||
|
||||
win->surface = wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
|
||||
|
||||
wl_surface_set_user_data(win->surface, win);
|
||||
|
||||
win->shell_surface =
|
||||
|
@ -323,15 +339,18 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
|
|||
break;
|
||||
case ECORE_WL_WINDOW_TYPE_MENU:
|
||||
wl_shell_surface_set_popup(win->shell_surface,
|
||||
win->parent->pointer_device->input_device,
|
||||
win->parent->pointer_device->timestamp,
|
||||
_ecore_wl_disp->input->input_device,
|
||||
_ecore_wl_disp->input->timestamp,
|
||||
/* win->parent->pointer_device->input_device, */
|
||||
/* win->parent->pointer_device->timestamp, */
|
||||
win->parent->shell_surface,
|
||||
win->allocation.x, win->allocation.y, 0);
|
||||
break;
|
||||
case ECORE_WL_WINDOW_TYPE_TOPLEVEL:
|
||||
default:
|
||||
wl_shell_surface_set_toplevel(win->shell_surface);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (win->type != ECORE_WL_WINDOW_TYPE_FULLSCREEN)
|
||||
|
@ -341,6 +360,7 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
|
|||
wl_region_add(win->region.input, win->allocation.x, win->allocation.y,
|
||||
win->allocation.w, win->allocation.h);
|
||||
}
|
||||
|
||||
if (!win->transparent)
|
||||
{
|
||||
win->region.opaque =
|
||||
|
@ -478,6 +498,16 @@ ecore_wl_window_surface_get(Ecore_Wl_Window *win)
|
|||
return win->surface;
|
||||
}
|
||||
|
||||
/* @since 1.2 */
|
||||
EAPI struct wl_shell_surface *
|
||||
ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!win) return NULL;
|
||||
return win->shell_surface;
|
||||
}
|
||||
|
||||
EAPI Ecore_Wl_Window *
|
||||
ecore_wl_window_find(unsigned int id)
|
||||
{
|
||||
|
@ -512,6 +542,15 @@ ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_buffer *buffer, int
|
|||
buffer, hot_x, hot_y);
|
||||
}
|
||||
|
||||
/* @since 1.2 */
|
||||
EAPI void
|
||||
ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
win->parent = parent;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, unsigned int timestamp, unsigned int edges, int w, int h)
|
||||
|
|
Loading…
Reference in New Issue