# include <Eina.h>
# include <wayland-client.h>
# include <wayland-egl.h> // NB: already includes wayland-client.h
+# include <GLES2/gl2.h>
+# include <GLES2/gl2ext.h>
# include <EGL/egl.h>
# include <EGL/eglext.h>
struct
{
EGLDisplay display;
- EGLConfig rgb_config;
EGLConfig argb_config;
- EGLContext rgb_context;
EGLContext argb_context;
} egl;
struct xkb_desc *xkb;
Ecore_Wl_Output *output;
+ Ecore_Wl_Input *input;
PFNEGLCREATEIMAGEKHRPROC create_image;
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
Ecore_Wl_Display *display;
struct wl_output *output;
Eina_Rectangle allocation;
+ int mw, mh;
struct wl_list link;
void (*destroy) (Ecore_Wl_Output *output, void *data);
struct wl_list link;
- /* TODO: grab */
+ Ecore_Wl_Window *grab;
unsigned int grab_button;
Ecore_Wl_Dnd_Source *drag_source;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
+ struct
+ {
+ struct wl_region *input, *opaque;
+ } region;
+
int id;
int x, y;
int edges;
EAPI struct wl_display *ecore_wl_display_get(void);
EAPI void ecore_wl_screen_size_get(int *w, int *h);
EAPI void ecore_wl_pointer_xy_get(int *x, int *y);
+EAPI int ecore_wl_dpi_get(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 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_raise(Ecore_Wl_Window *win);
EAPI void ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized);
EAPI void ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen);
+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 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);
#endif
_ecore_wl_cb_handle_global, _ecore_wl_disp);
/* FIXME: Process connection events ?? */
- wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE);
+ /* wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); */
/* if (!_ecore_wl_egl_init(_ecore_wl_disp)) */
/* { */
EAPI void
ecore_wl_flush(void)
{
- LOGFN(__FILE__, __LINE__, __FUNCTION__);
+// LOGFN(__FILE__, __LINE__, __FUNCTION__);
while (_ecore_wl_disp->mask & WL_DISPLAY_WRITABLE)
wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_WRITABLE);
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
- wl_display_roundtrip(_ecore_wl_disp->wl.display);
+ wl_display_sync(_ecore_wl_disp->wl.display);
+
+ //wl_display_roundtrip(_ecore_wl_disp->wl.display);
+
// old sync code
// wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE);
}
_ecore_wl_input_pointer_xy_get(x, y);
}
+EAPI int
+ecore_wl_dpi_get(void)
+{
+ int w, mw;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ mw = _ecore_wl_disp->output->mw;
+ if (mw <= 0) return 75;
+
+ w = _ecore_wl_disp->output->allocation.w;
+ return (((w * 254) / mw) + 5) / 10;
+}
+
/* local functions */
static Eina_Bool
_ecore_wl_shutdown(Eina_Bool close)
{
Ecore_Wl_Display *ewd;
- LOGFN(__FILE__, __LINE__, __FUNCTION__);
+// LOGFN(__FILE__, __LINE__, __FUNCTION__);
ewd = data;
ewd->mask = mask;
{
Ecore_Wl_Display *ewd;
- LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
- if ((!strcmp(interface, "wl_display")) ||
- (!strcmp(interface, "wl_drm")) ||
- (!strcmp(interface, "desktop_shell")))
- return;
+// LOGFN(__FILE__, __LINE__, __FUNCTION__);
ewd = data;
static void _ecore_wl_input_keyboard_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp);
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_cb_mouse_move_free(void *data __UNUSED__, void *event);
static void _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, unsigned int timestamp);
static void _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, unsigned int timestamp);
static void _ecore_wl_input_focus_in_send(Ecore_Wl_Input *input, unsigned int timestamp);
/* local variables */
static int _pointer_x, _pointer_y;
+EAPI void
+ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ input->grab = win;
+ input->grab_button = button;
+}
+
+EAPI void
+ecore_wl_input_ungrab(Ecore_Wl_Input *input, unsigned int timestamp)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ input->grab = NULL;
+ if (input->pointer_focus)
+ {
+ printf("Ungrab: %d\n", timestamp);
+ }
+}
+
void
_ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
{
input->input_device);
wl_data_device_add_listener(input->data_device,
&_ecore_wl_data_listener, input);
+ ewd->input = input;
}
void
input->timestamp = timestamp;
- _ecore_wl_input_mouse_move_send(input, timestamp);
+ 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))
{
{
_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 = data)) return;
- input->sx = sx;
- input->sy = sy;
+ /* _pointer_x = sx; */
+ /* _pointer_y = sy; */
- _ecore_wl_input_mouse_move_send(input, timestamp);
+ /* input->sx = sx; */
+ /* input->sy = sy; */
+
+// _ecore_wl_input_mouse_move_send(input, timestamp);
win = input->pointer_focus;
if ((win) && (win->surface != surface))
input->pointer_focus = win;
win->pointer_device = input;
}
- if (input->button)
- {
- _ecore_wl_input_mouse_up_send(input, timestamp);
- input->button = 0;
- }
- else
+ /* if (input->button) */
+ /* { */
+ /* _ecore_wl_input_mouse_up_send(input, timestamp); */
+ /* input->button = 0; */
+ /* } */
+ /* else */
_ecore_wl_input_mouse_in_send(input, timestamp);
}
}
if ((win = input->pointer_focus))
win->pointer_device = NULL;
+
input->pointer_focus = NULL;
}
_ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, unsigned int timestamp)
{
Ecore_Event_Mouse_Move *ev;
- Ecore_Event *event;
+// Ecore_Event *event;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ev->timestamp = timestamp;
ev->x = input->sx;
ev->y = input->sy;
+ ev->root.x = input->sx;
+ ev->root.y = input->sy;
ev->modifiers = input->modifiers;
ev->multi.device = 0;
ev->multi.radius = 1;
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;
}
- event = ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev,
- _ecore_wl_input_cb_mouse_move_free, NULL);
-}
-
-static void
-_ecore_wl_input_cb_mouse_move_free(void *data __UNUSED__, void *event)
-{
- Ecore_Event_Mouse_Move *ev;
-
- if ((ev = event)) free(ev);
+ ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
}
static void
_ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, unsigned int timestamp)
{
Ecore_Wl_Event_Mouse_In *ev;
- Ecore_Event *event;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ev->x = input->sx;
ev->y = input->sy;
+ ev->root.x = input->sx;
+ ev->root.y = input->sy;
ev->modifiers = input->modifiers;
ev->timestamp = timestamp;
ev->event_win = input->pointer_focus->id;
}
- event = ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL);
+ ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL);
}
static void
ev->x = input->sx;
ev->y = input->sy;
+ ev->root.x = input->sx;
+ ev->root.y = input->sy;
ev->modifiers = input->modifiers;
ev->timestamp = timestamp;
ev->timestamp = timestamp;
ev->x = input->sx;
ev->y = input->sy;
+ ev->root.x = input->sx;
+ ev->root.y = input->sy;
ev->modifiers = input->modifiers;
/* FIXME: Need to get these from wayland somehow */
ev->timestamp = timestamp;
ev->x = input->sx;
ev->y = input->sy;
+ ev->root.x = input->sx;
+ ev->root.y = input->sy;
ev->modifiers = input->modifiers;
/* FIXME: Need to get these from wayland somehow */
#include "Ecore_Wayland.h"
/* local function prototypes */
-static void _ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output __UNUSED__, int x, int y, int w __UNUSED__, int h __UNUSED__, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__);
+static void _ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output __UNUSED__, int x, int y, int w, int h, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__);
static void _ecore_wl_output_cb_mode(void *data, struct wl_output *wl_output __UNUSED__, unsigned int flags, int w, int h, int refresh __UNUSED__);
/* wayland listeners */
/* local functions */
static void
-_ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output __UNUSED__, int x, int y, int w __UNUSED__, int h __UNUSED__, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__)
+_ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output __UNUSED__, int x, int y, int w, int h, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__)
{
Ecore_Wl_Output *output;
output = data;
output->allocation.x = x;
output->allocation.y = y;
+ output->mw = w;
+ output->mh = h;
}
static void
win->allocation.w = w;
win->allocation.h = h;
win->saved_allocation = win->allocation;
- win->transparent = EINA_TRUE;
+ win->transparent = EINA_FALSE;
win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
win->buffer_type = buffer_type;
win->id = _win_id++;
input->keyboard_focus = NULL;
}
+ if (win->region.input) wl_region_destroy(win->region.input);
+ if (win->region.opaque) wl_region_destroy(win->region.opaque);
+
if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
win->shell_surface = NULL;
{
Ecore_Wl_Input *input;
- input = win->keyboard_device;
+ if (!(input = win->keyboard_device))
+ {
+ if (win->parent)
+ input = win->parent->keyboard_device;
+ }
+
wl_shell_surface_move(win->shell_surface, input->input_device,
input->timestamp);
}
if (!win) return;
win->allocation.w = w;
win->allocation.h = h;
+ if (win->type != ECORE_WL_WINDOW_TYPE_FULLSCREEN)
+ {
+ win->region.input =
+ wl_compositor_create_region(_ecore_wl_disp->wl.compositor);
+ wl_region_add(win->region.input, win->allocation.x, win->allocation.y,
+ win->allocation.w, win->allocation.h);
+ }
+ if (!win->transparent)
+ {
+ win->region.opaque =
+ wl_compositor_create_region(_ecore_wl_disp->wl.compositor);
+ wl_region_add(win->region.opaque, win->allocation.x, win->allocation.y,
+ win->allocation.w, win->allocation.h);
+ }
+
if (win->shell_surface)
{
Ecore_Wl_Input *input;
if (!win) return;
if ((win->surface) && (buffer))
wl_surface_attach(win->surface, buffer, x, y);
+ if (win->surface)
+ {
+ if (win->region.input)
+ {
+ wl_surface_set_input_region(win->surface, win->region.input);
+ wl_region_destroy(win->region.input);
+ win->region.input = NULL;
+ }
+ if (win->region.opaque)
+ {
+ wl_surface_set_opaque_region(win->surface, win->region.opaque);
+ wl_region_destroy(win->region.opaque);
+ win->region.opaque = NULL;
+ }
+ wl_surface_damage(win->surface, 0, 0,
+ win->allocation.w, win->allocation.h);
+ }
}
/**
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 =
break;
case ECORE_WL_WINDOW_TYPE_MENU:
wl_shell_surface_set_popup(win->shell_surface,
- win->pointer_device->input_device,
- win->pointer_device->timestamp,
+ win->parent->pointer_device->input_device,
+ win->parent->pointer_device->timestamp,
win->parent->shell_surface,
win->allocation.x, win->allocation.y, 0);
break;
wl_shell_surface_set_toplevel(win->shell_surface);
break;
}
+
+ if (win->type != ECORE_WL_WINDOW_TYPE_FULLSCREEN)
+ {
+ win->region.input =
+ wl_compositor_create_region(_ecore_wl_disp->wl.compositor);
+ wl_region_add(win->region.input, win->allocation.x, win->allocation.y,
+ win->allocation.w, win->allocation.h);
+ }
+ if (!win->transparent)
+ {
+ win->region.opaque =
+ wl_compositor_create_region(_ecore_wl_disp->wl.compositor);
+ wl_region_add(win->region.opaque, win->allocation.x, win->allocation.y,
+ win->allocation.w, win->allocation.h);
+ }
}
/**
}
EAPI void
+ecore_wl_window_transparent_set(Ecore_Wl_Window *win, Eina_Bool transparent)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ if (!win) return;
+ win->transparent = transparent;
+}
+
+EAPI void
ecore_wl_window_update_size(Ecore_Wl_Window *win, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return NULL;
}
+EAPI void
+ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ if (!win) return;
+ win->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)
+{
+ Ecore_Wl_Input *input;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ if (!win) return;
+
+ input = _ecore_wl_disp->input;
+ wl_input_device_attach(input->input_device, timestamp,
+ buffer, hot_x, hot_y);
+}
+
/* 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)
win->edges = edges;
win->allocation.w = w;
win->allocation.h = h;
+ if (win->region.input) wl_region_destroy(win->region.input);
+ win->region.input = NULL;
+ if (win->region.opaque) wl_region_destroy(win->region.opaque);
+ win->region.opaque = NULL;
_ecore_wl_window_configure_send(win, w, h, timestamp);
}
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!(win = data)) return;
- /* TODO: handle popup destroy */
+ ecore_wl_input_ungrab(win->pointer_device, 0);
}
static void