#include <EGL/egl.h>
#include "compositor.h"
+#include "../shared/config-parser.h"
struct x11_compositor {
struct weston_compositor base;
+ EGLSurface dummy_pbuffer;
+
Display *dpy;
xcb_connection_t *conn;
xcb_screen_t *screen;
{
EGLint major, minor;
EGLint n;
- const char *extensions;
EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
- EGL_DEPTH_SIZE, 1,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE
};
EGL_NONE
};
+ static const EGLint pbuffer_attribs[] = {
+ EGL_WIDTH, 10,
+ EGL_HEIGHT, 10,
+ EGL_NONE
+ };
+
c->base.display = eglGetDisplay(c->dpy);
if (c->base.display == NULL) {
fprintf(stderr, "failed to create display\n");
return -1;
}
- extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
- if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
- fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
- return -1;
- }
-
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
return -1;
return -1;
}
+ c->dummy_pbuffer = eglCreatePbufferSurface(c->base.display,
+ c->base.config,
+ pbuffer_attribs);
+ if (c->base.context == NULL) {
+ fprintf(stderr, "failed to create dummy pbuffer\n");
+ return -1;
+ }
+
if (!eglMakeCurrent(c->base.display, EGL_NO_SURFACE,
EGL_NO_SURFACE, c->base.context)) {
fprintf(stderr, "failed to make context current\n");
}
static void
-x11_output_repaint(struct weston_output *output_base)
+x11_output_repaint(struct weston_output *output_base,
+ pixman_region32_t *damage)
{
struct x11_output *output = (struct x11_output *)output_base;
struct x11_compositor *compositor =
}
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
- weston_surface_draw(surface, &output->base);
+ weston_surface_draw(surface, &output->base, damage);
+
+ weston_output_do_read_pixels(&output->base);
eglSwapBuffers(compositor->base.display, output->egl_surface);
return 1;
}
-static int
-x11_output_prepare_scanout_surface(struct weston_output *output_base,
- struct weston_surface *es)
-{
- return -1;
-}
-
-static int
-x11_output_set_cursor(struct weston_output *output_base,
- struct weston_input_device *input)
-{
- return -1;
-}
-
static void
x11_output_destroy(struct weston_output *output_base)
{
x11_output_set_icon(struct x11_compositor *c,
struct x11_output *output, const char *filename)
{
- uint32_t *icon, *pixels, stride;
+ uint32_t *icon;
int32_t width, height;
+ pixman_image_t *image;
- pixels = weston_load_image(filename, &width, &height, &stride);
- if (!pixels)
+ image = load_image(filename);
+ if (!image)
return;
+ width = pixman_image_get_width(image);
+ height = pixman_image_get_height(image);
icon = malloc(width * height * 4 + 8);
if (!icon) {
- free(pixels);
+ pixman_image_unref(image);
return;
}
icon[0] = width;
icon[1] = height;
- memcpy(icon + 2, pixels, width * height * 4);
+ memcpy(icon + 2, pixman_image_get_data(image), width * height * 4);
xcb_change_property(c->conn, XCB_PROP_MODE_REPLACE, output->window,
c->atom.net_wm_icon, c->atom.cardinal, 32,
width * height + 2, icon);
free(icon);
- free(pixels);
+ pixman_image_unref(image);
}
static int
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
+ output->base.origin = output->base.current;
output->base.repaint = x11_output_repaint;
- output->base.prepare_scanout_surface =
- x11_output_prepare_scanout_surface;
- output->base.set_hardware_cursor = x11_output_set_cursor;
output->base.destroy = x11_output_destroy;
+ output->base.assign_planes = NULL;
+ output->base.set_backlight = NULL;
+ output->base.set_dpms = NULL;
+ output->base.switch_mode = NULL;
wl_list_insert(c->base.output_list.prev, &output->base.link);
button = BTN_RIGHT;
break;
case 4:
+ if (state)
+ notify_axis(c->base.input_device,
+ weston_compositor_get_time(),
+ WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, 1);
+ return;
case 5:
+ if (state)
+ notify_axis(c->base.input_device,
+ weston_compositor_get_time(),
+ WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, -1);
+ return;
case 6:
+ if (state)
+ notify_axis(c->base.input_device,
+ weston_compositor_get_time(),
+ WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, 1);
+ return;
case 7:
- /* X11 sends wheel events as buttons events. But
- * linux input treats as REL_WHEEL, therefore not
- * button type at all. When we update the input
- * protocol and get the 'axis' event, we'll send
- * scroll events as axis events. */
+ if (state)
+ notify_axis(c->base.input_device,
+ weston_compositor_get_time(),
+ WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, -1);
return;
}
xcb_focus_in_event_t *focus_in;
xcb_atom_t atom;
uint32_t *k;
- int i, set;
+ uint32_t i, set;
prev = NULL;
while (x11_compositor_next_event(c, &event, mask)) {
}
output = x11_compositor_find_output(c, focus_in->event);
- notify_keyboard_focus(c->base.input_device,
- weston_compositor_get_time(),
- &output->base, &c->keys);
+ notify_keyboard_focus(c->base.input_device, &c->keys);
free(prev);
prev = NULL;
break;
output = x11_compositor_find_output(c, enter_notify->event);
notify_pointer_focus(c->base.input_device,
- weston_compositor_get_time(),
&output->base,
output->base.x + enter_notify->event_x,
output->base.y + enter_notify->event_y);
if (enter_notify->state >= Button1Mask)
break;
output = x11_compositor_find_output(c, enter_notify->event);
- notify_pointer_focus(c->base.input_device,
- weston_compositor_get_time(),
- NULL,
+ notify_pointer_focus(c->base.input_device, NULL,
output->base.x + enter_notify->event_x,
output->base.y + enter_notify->event_y);
break;
if (focus_in->mode == XCB_NOTIFY_MODE_WHILE_GRABBED ||
focus_in->mode == XCB_NOTIFY_MODE_UNGRAB)
break;
- notify_keyboard_focus(c->base.input_device,
- weston_compositor_get_time(),
- NULL, NULL);
+ notify_keyboard_focus(c->base.input_device, NULL);
break;
default:
xcb_intern_atom_reply_t *reply;
xcb_pixmap_t pixmap;
xcb_gc_t gc;
- int i;
+ unsigned int i;
uint8_t data[] = { 0, 0, 0, 0 };
for (i = 0; i < ARRAY_LENGTH(atoms); i++)
int width, int height, int count, int fullscreen)
{
struct x11_compositor *c;
- struct wl_event_loop *loop;
xcb_screen_iterator_t s;
int i, x;
if (x11_input_create(c) < 0)
return NULL;
- loop = wl_display_get_event_loop(c->base.wl_display);
-
c->xcb_source =
- wl_event_loop_add_fd(loop, xcb_get_file_descriptor(c->conn),
+ wl_event_loop_add_fd(c->base.input_loop,
+ xcb_get_file_descriptor(c->conn),
WL_EVENT_READABLE,
x11_compositor_handle_event, c);
wl_event_source_check(c->xcb_source);
return &c->base;
}
-struct weston_compositor *
-backend_init(struct wl_display *display, char *options);
-
WL_EXPORT struct weston_compositor *
-backend_init(struct wl_display *display, char *options)
+backend_init(struct wl_display *display, int argc, char *argv[])
{
- int width = 1024, height = 640, fullscreen = 0, count = 1, i;
- char *p, *value;
+ int width = 1024, height = 640, fullscreen = 0, count = 1;
- static char * const tokens[] = {
- "width", "height", "fullscreen", "output-count", NULL
+ const struct weston_option x11_options[] = {
+ { WESTON_OPTION_INTEGER, "width", 0, &width },
+ { WESTON_OPTION_INTEGER, "height", 0, &height },
+ { WESTON_OPTION_BOOLEAN, "fullscreen", 0, &fullscreen },
+ { WESTON_OPTION_INTEGER, "output-count", 0, &count },
};
-
- p = options;
- while (i = getsubopt(&p, tokens, &value), i != -1) {
- switch (i) {
- case 0:
- width = strtol(value, NULL, 0);
- break;
- case 1:
- height = strtol(value, NULL, 0);
- break;
- case 2:
- fullscreen = 1;
- break;
- case 3:
- count = strtol(value, NULL, 0);
- break;
- }
- }
+
+ parse_options(x11_options, ARRAY_LENGTH(x11_options), argc, argv);
return x11_compositor_create(display,
width, height, count, fullscreen);