├── .gitignore ├── COPYING ├── Makefile.am ├── README ├── autogen.sh ├── clients ├── calibrator.c ├── clickdot.c ├── cliptest.c ├── desktop-shell.c ├── dnd.c ├── editor.c ├── eventdemo.c ├── flower.c ├── fullscreen.c ├── gears.c ├── glmatrix.c ├── image.c ├── keyboard.c ├── matrix3.xpm ├── multi-resource.c ├── nested-client.c ├── nested.c ├── resizor.c ├── scaler.c ├── screenshot.c ├── simple-egl.c ├── simple-shm.c ├── simple-touch.c ├── smoke.c ├── stacking.c ├── subsurfaces.c ├── terminal.c ├── transformed.c ├── weston-info.c ├── weston-simple-im.c ├── window.c ├── window.h ├── wscreensaver-glue.c ├── wscreensaver-glue.h ├── wscreensaver.c └── wscreensaver.h ├── configure.ac ├── data ├── COPYING ├── border.png ├── icon_window.png ├── pattern.png ├── sign_close.png ├── sign_maximize.png ├── sign_minimize.png ├── terminal.png ├── wayland.png └── wayland.svg ├── desktop-shell ├── exposay.c ├── input-panel.c ├── shell.c └── shell.h ├── man ├── .gitignore ├── weston-drm.man ├── weston.ini.man └── weston.man ├── notes.txt ├── protocol ├── desktop-shell.xml ├── input-method.xml ├── scaler.xml ├── screenshooter.xml ├── text-cursor-position.xml ├── text.xml ├── wayland-test.xml ├── workspaces.xml ├── xdg-shell.xml └── xserver.xml ├── shared ├── cairo-util.c ├── cairo-util.h ├── config-parser.c ├── config-parser.h ├── frame.c ├── image-loader.c ├── image-loader.h ├── matrix.c ├── matrix.h ├── option-parser.c ├── os-compatibility.c ├── os-compatibility.h └── zalloc.h ├── src ├── animation.c ├── bindings.c ├── clipboard.c ├── cms-colord.c ├── cms-helper.c ├── cms-helper.h ├── cms-static.c ├── compositor-drm.c ├── compositor-fbdev.c ├── compositor-headless.c ├── compositor-rdp.c ├── compositor-rpi.c ├── compositor-wayland.c ├── compositor-x11.c ├── compositor.c ├── compositor.h ├── data-device.c ├── dbus.c ├── dbus.h ├── evdev-touchpad.c ├── evdev.c ├── evdev.h ├── filter.c ├── filter.h ├── gl-renderer.c ├── gl-renderer.h ├── input.c ├── launcher-util.c ├── launcher-util.h ├── libbacklight.c ├── libbacklight.h ├── log.c ├── logind-util.c ├── logind-util.h ├── noop-renderer.c ├── pixman-renderer.c ├── pixman-renderer.h ├── rpi-bcm-stubs.h ├── rpi-renderer.c ├── rpi-renderer.h ├── screenshooter.c ├── spring-tool.c ├── text-backend.c ├── udev-seat.c ├── udev-seat.h ├── vaapi-recorder.c ├── vaapi-recorder.h ├── version.h.in ├── vertex-clipping.c ├── vertex-clipping.h ├── weston-egl-ext.h ├── weston-launch.c ├── weston-launch.h ├── weston.pc.in └── zoom.c ├── tests ├── .gitignore ├── bad-buffer-test.c ├── buffer-count-test.c ├── button-test.c ├── config-parser-test.c ├── event-test.c ├── keyboard-test.c ├── matrix-test.c ├── setbacklight.c ├── subsurface-test.c ├── surface-global-test.c ├── surface-test.c ├── text-test.c ├── vertex-clip-test.c ├── weston-test-client-helper.c ├── weston-test-client-helper.h ├── weston-test-runner.c ├── weston-test-runner.h ├── weston-test.c ├── weston-tests-env └── xwayland-test.c ├── wcap ├── .gitignore ├── README ├── main.c ├── wcap-decode.c └── wcap-decode.h ├── weston.ini.in └── xwayland ├── dnd.c ├── hash.c ├── hash.h ├── launcher.c ├── selection.c ├── window-manager.c └── xwayland.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.deps 2 | *.jpg 3 | *.la 4 | *.lo 5 | *.o 6 | *.pc 7 | *.so 8 | *.swp 9 | *~ 10 | ctags 11 | cscope.out 12 | .libs 13 | .dirstamp 14 | /aclocal.m4 15 | /autom4te.cache 16 | /build-aux/ 17 | /config.h 18 | /config.h.in 19 | /config.log 20 | /config.mk 21 | /config.status 22 | /configure 23 | /libtool 24 | /stamp-h1 25 | /test-driver 26 | /weston.ini 27 | Makefile 28 | Makefile.in 29 | TAGS 30 | protocol/.*.valid 31 | protocol/*.[ch] 32 | 33 | weston-calibrator 34 | weston-clickdot 35 | weston-cliptest 36 | weston-dnd 37 | weston-editor 38 | weston-eventdemo 39 | weston-flower 40 | weston-fullscreen 41 | weston-gears 42 | weston-image 43 | weston-nested 44 | weston-nested-client 45 | weston-resizor 46 | weston-scaler 47 | weston-simple-egl 48 | weston-simple-shm 49 | weston-simple-touch 50 | weston-smoke 51 | weston-stacking 52 | weston-subsurfaces 53 | weston-transformed 54 | weston-view 55 | 56 | weston-keyboard 57 | libtoytoolkit.a 58 | weston-desktop-shell 59 | weston-info 60 | weston-screensaver 61 | weston-screenshooter 62 | weston-tablet-shell 63 | weston-terminal 64 | weston-multi-resource 65 | weston-simple-im 66 | git-version.h 67 | version.h 68 | weston 69 | weston-launch 70 | spring-tool 71 | 72 | *.weston 73 | *.test 74 | wcap-decode 75 | matrix-test 76 | setbacklight 77 | weston.1 78 | weston-drm.7 79 | weston.ini.5 80 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright © 2008-2012 Kristian Høgsberg 2 | Copyright © 2010-2012 Intel Corporation 3 | Copyright © 2010-2011 Benjamin Franzke 4 | Copyright © 2011-2012 Collabora, Ltd. 5 | 6 | Permission to use, copy, modify, distribute, and sell this software and its 7 | documentation for any purpose is hereby granted without fee, provided that 8 | the above copyright notice appear in all copies and that both that copyright 9 | notice and this permission notice appear in supporting documentation, and 10 | that the name of the copyright holders not be used in advertising or 11 | publicity pertaining to distribution of the software without specific, 12 | written prior permission. The copyright holders make no representations 13 | about the suitability of this software for any purpose. It is provided "as 14 | is" without express or implied warranty. 15 | 16 | THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18 | EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 19 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 20 | DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 21 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 22 | OF THIS SOFTWARE. 23 | 24 | 25 | For libbacklight.c: 26 | 27 | Copyright © 2012 Intel Corporation 28 | Copyright © 2010 Red Hat 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a 31 | copy of this software and associated documentation files (the "Software"), 32 | to deal in the Software without restriction, including without limitation 33 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 34 | and/or sell copies of the Software, and to permit persons to whom the 35 | Software is furnished to do so, subject to the following conditions: 36 | 37 | The above copyright notice and this permission notice (including the next 38 | paragraph) shall be included in all copies or substantial portions of the 39 | Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 42 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 43 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 44 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 45 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 46 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 47 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 48 | DEALINGS IN THE SOFTWARE. 49 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Weston 2 | 3 | Weston is the reference implementation of a Wayland compositor, and a 4 | useful compositor in its own right. Weston has various backends that 5 | lets it run on Linux kernel modesetting and evdev input as well as 6 | under X11. Weston ships with a few example clients, from simple 7 | clients that demonstrate certain aspects of the protocol to more 8 | complete clients and a simplistic toolkit. There is also a quite 9 | capable terminal emulator (weston-terminal) and an toy/example desktop 10 | shell. Finally, weston also provides integration with the Xorg server 11 | and can pull X clients into the Wayland desktop and act as a X window 12 | manager. 13 | 14 | Refer to http://wayland.freedesktop.org/building.html for building 15 | weston and its dependencies. 16 | 17 | The test suite can be invoked via `make check`; see 18 | http://wayland.freedesktop.org/testing.html for additional details. 19 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | test -n "$srcdir" || srcdir=`dirname "$0"` 4 | test -n "$srcdir" || srcdir=. 5 | ( 6 | cd "$srcdir" && 7 | autoreconf --force -v --install 8 | ) || exit 9 | test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" 10 | -------------------------------------------------------------------------------- /clients/flower.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2008 Kristian Høgsberg 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include "window.h" 35 | 36 | struct flower { 37 | struct display *display; 38 | struct window *window; 39 | struct widget *widget; 40 | int width, height; 41 | }; 42 | 43 | static void 44 | set_random_color(cairo_t *cr) 45 | { 46 | cairo_set_source_rgba(cr, 47 | 0.5 + (random() % 50) / 49.0, 48 | 0.5 + (random() % 50) / 49.0, 49 | 0.5 + (random() % 50) / 49.0, 50 | 0.5 + (random() % 100) / 99.0); 51 | } 52 | 53 | 54 | static void 55 | draw_stuff(cairo_surface_t *surface, int width, int height) 56 | { 57 | const int petal_count = 3 + random() % 5; 58 | const double r1 = 60 + random() % 35; 59 | const double r2 = 20 + random() % 40; 60 | const double u = (10 + random() % 90) / 100.0; 61 | const double v = (random() % 90) / 100.0; 62 | 63 | cairo_t *cr; 64 | int i; 65 | double t, dt = 2 * M_PI / (petal_count * 2); 66 | double x1, y1, x2, y2, x3, y3; 67 | 68 | cr = cairo_create(surface); 69 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); 70 | cairo_set_source_rgba(cr, 0, 0, 0, 0); 71 | cairo_paint(cr); 72 | 73 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); 74 | cairo_translate(cr, width / 2, height / 2); 75 | cairo_move_to(cr, cos(0) * r1, sin(0) * r1); 76 | for (t = 0, i = 0; i < petal_count; i++, t += dt * 2) { 77 | x1 = cos(t) * r1; 78 | y1 = sin(t) * r1; 79 | x2 = cos(t + dt) * r2; 80 | y2 = sin(t + dt) * r2; 81 | x3 = cos(t + 2 * dt) * r1; 82 | y3 = sin(t + 2 * dt) * r1; 83 | 84 | cairo_curve_to(cr, 85 | x1 - y1 * u, y1 + x1 * u, 86 | x2 + y2 * v, y2 - x2 * v, 87 | x2, y2); 88 | 89 | cairo_curve_to(cr, 90 | x2 - y2 * v, y2 + x2 * v, 91 | x3 + y3 * u, y3 - x3 * u, 92 | x3, y3); 93 | } 94 | 95 | cairo_close_path(cr); 96 | set_random_color(cr); 97 | cairo_fill_preserve(cr); 98 | set_random_color(cr); 99 | cairo_stroke(cr); 100 | 101 | cairo_destroy(cr); 102 | } 103 | 104 | static void 105 | resize_handler(struct widget *widget, 106 | int32_t width, int32_t height, void *data) 107 | { 108 | struct flower *flower = data; 109 | 110 | /* Dont resize me */ 111 | widget_set_size(flower->widget, flower->width, flower->height); 112 | } 113 | 114 | static void 115 | redraw_handler(struct widget *widget, void *data) 116 | { 117 | struct flower *flower = data; 118 | cairo_surface_t *surface; 119 | 120 | surface = window_get_surface(flower->window); 121 | if (surface == NULL || 122 | cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) { 123 | fprintf(stderr, "failed to create cairo egl surface\n"); 124 | return; 125 | } 126 | 127 | draw_stuff(surface, flower->width, flower->height); 128 | cairo_surface_destroy(surface); 129 | } 130 | 131 | static void 132 | button_handler(struct widget *widget, 133 | struct input *input, uint32_t time, 134 | uint32_t button, enum wl_pointer_button_state state, void *data) 135 | { 136 | struct flower *flower = data; 137 | 138 | switch (button) { 139 | case BTN_LEFT: 140 | if (state == WL_POINTER_BUTTON_STATE_PRESSED) 141 | window_move(flower->window, input, 142 | display_get_serial(flower->display)); 143 | break; 144 | case BTN_MIDDLE: 145 | if (state == WL_POINTER_BUTTON_STATE_PRESSED) 146 | widget_schedule_redraw(widget); 147 | break; 148 | case BTN_RIGHT: 149 | if (state == WL_POINTER_BUTTON_STATE_PRESSED) 150 | window_show_frame_menu(flower->window, input, time); 151 | break; 152 | } 153 | } 154 | 155 | static void 156 | touch_down_handler(struct widget *widget, struct input *input, 157 | uint32_t serial, uint32_t time, int32_t id, 158 | float x, float y, void *data) 159 | { 160 | struct flower *flower = data; 161 | window_move(flower->window, input, display_get_serial(flower->display)); 162 | } 163 | 164 | int main(int argc, char *argv[]) 165 | { 166 | struct flower flower; 167 | struct display *d; 168 | struct timeval tv; 169 | 170 | d = display_create(&argc, argv); 171 | if (d == NULL) { 172 | fprintf(stderr, "failed to create display: %m\n"); 173 | return -1; 174 | } 175 | 176 | gettimeofday(&tv, NULL); 177 | srandom(tv.tv_usec); 178 | 179 | flower.width = 200; 180 | flower.height = 200; 181 | flower.display = d; 182 | flower.window = window_create(d); 183 | flower.widget = window_add_widget(flower.window, &flower); 184 | window_set_title(flower.window, "Flower"); 185 | 186 | widget_set_resize_handler(flower.widget, resize_handler); 187 | widget_set_redraw_handler(flower.widget, redraw_handler); 188 | widget_set_button_handler(flower.widget, button_handler); 189 | widget_set_default_cursor(flower.widget, CURSOR_HAND1); 190 | widget_set_touch_down_handler(flower.widget, touch_down_handler); 191 | 192 | window_schedule_resize(flower.window, flower.width, flower.height); 193 | 194 | display_run(d); 195 | 196 | return 0; 197 | } 198 | -------------------------------------------------------------------------------- /clients/wscreensaver-glue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011 Collabora, Ltd. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "wscreensaver-glue.h" 24 | 25 | double frand(double f) 26 | { 27 | double r = random(); 28 | return r * f / (double)RAND_MAX; 29 | } 30 | 31 | void clear_gl_error(void) 32 | { 33 | while (glGetError() != GL_NO_ERROR) 34 | ; 35 | } 36 | 37 | void check_gl_error(const char *msg) 38 | { 39 | const char *emsg; 40 | int err = glGetError(); 41 | 42 | switch (err) 43 | { 44 | case GL_NO_ERROR: 45 | return; 46 | 47 | #define ERR(tok) case tok: emsg = #tok; break; 48 | ERR(GL_INVALID_ENUM) 49 | ERR(GL_INVALID_VALUE) 50 | ERR(GL_INVALID_OPERATION) 51 | ERR(GL_STACK_OVERFLOW) 52 | ERR(GL_STACK_UNDERFLOW) 53 | ERR(GL_OUT_OF_MEMORY) 54 | #undef ERR 55 | 56 | default: 57 | fprintf(stderr, "%s: %s: unknown GL error 0x%04x\n", 58 | progname, msg, err); 59 | exit(1); 60 | } 61 | 62 | fprintf(stderr, "%s: %s: GL error %s\n", progname, msg, emsg); 63 | exit(1); 64 | } 65 | 66 | static void 67 | read_xpm_color(uint32_t *ctable, const char *line) 68 | { 69 | unsigned char key; 70 | char cstr[10]; 71 | char *end; 72 | uint32_t value; 73 | 74 | if (sscanf(line, "%1c c %9s", &key, cstr) < 2) { 75 | fprintf(stderr, "%s: error in XPM color definition '%s'\n", 76 | progname, line); 77 | return; 78 | } 79 | 80 | value = strtol(&cstr[1], &end, 16); 81 | 82 | if (strcmp(cstr, "None") == 0) 83 | ctable[key] = 0x00000000; 84 | else if (cstr[0] != '#' || !(cstr[1] != '\0' && *end == '\0')) { 85 | fprintf(stderr, "%s: error interpreting XPM color '%s'\n", 86 | progname, cstr); 87 | return; 88 | } else { 89 | ctable[key] = value | 0xff000000; 90 | } 91 | } 92 | 93 | static void 94 | read_xpm_row(char *data, const char *line, uint32_t *ctable, int width) 95 | { 96 | uint32_t *pixel = (uint32_t *)data; 97 | uint8_t *p = (uint8_t *)line; 98 | int i; 99 | 100 | for (i = 0; i < width; ++i) 101 | pixel[i] = ctable[p[i]]; 102 | } 103 | 104 | XImage *xpm_to_ximage(char **xpm_data) 105 | { 106 | XImage *xi; 107 | int colors; 108 | int cpp; 109 | int i; 110 | uint32_t ctable[256] = { 0 }; 111 | 112 | xi = malloc(sizeof *xi); 113 | if (!xi) 114 | return NULL; 115 | xi->data = NULL; 116 | 117 | if (sscanf(xpm_data[0], "%d %d %d %d", &xi->width, 118 | &xi->height, &colors, &cpp) < 4) 119 | goto errout; 120 | 121 | if (xi->width < 1 || xi->height < 1 || cpp != 1) 122 | goto errout; 123 | 124 | xi->bytes_per_line = xi->width * sizeof(uint32_t); 125 | xi->data = malloc(xi->height * xi->bytes_per_line); 126 | if (!xi->data) 127 | goto errout; 128 | 129 | for (i = 0; i < colors; ++i) 130 | read_xpm_color(ctable, xpm_data[i + 1]); 131 | 132 | for (i = 0; i < xi->height; ++i) 133 | read_xpm_row(xi->data + i * xi->bytes_per_line, 134 | xpm_data[i + colors + 1], ctable, xi->width); 135 | 136 | return xi; 137 | 138 | errout: 139 | fprintf(stderr, "%s: error processing XPM data.\n", progname); 140 | XDestroyImage(xi); 141 | return NULL; 142 | } 143 | 144 | void XDestroyImage(XImage *xi) 145 | { 146 | free(xi->data); 147 | free(xi); 148 | } 149 | -------------------------------------------------------------------------------- /clients/wscreensaver-glue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011 Collabora, Ltd. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef WSCREENSAVER_GLUE_H 24 | #define WSCREENSAVER_GLUE_H 25 | 26 | /* 27 | * This file is glue, that tries to avoid changing glmatrix.c from the 28 | * original too much, hopefully easing the porting of other (GL) 29 | * xscreensaver "hacks". 30 | */ 31 | 32 | #include "wscreensaver.h" 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | #include "window.h" 47 | 48 | #define ENTRYPOINT static 49 | 50 | typedef bool Bool; 51 | #define True true 52 | #define False false 53 | 54 | typedef struct ModeInfo ModeInfo; 55 | 56 | #define MI_DISPLAY(mi) NULL 57 | #define MI_WINDOW(mi) (mi) 58 | #define MI_SCREEN(mi) ((mi)->instance_number) 59 | #define MI_WIDTH(mi) ((mi)->width) 60 | #define MI_HEIGHT(mi) ((mi)->height) 61 | #define MI_IS_WIREFRAME(mi) 0 62 | #define MI_NUM_SCREENS(mi) 16 63 | 64 | typedef EGLContext GLXContext; 65 | 66 | double frand(double f); 67 | void clear_gl_error(void); 68 | void check_gl_error(const char *msg); 69 | 70 | static inline void 71 | glXMakeCurrent(void *dummy, ModeInfo *mi, EGLContext ctx) 72 | { 73 | assert(mi->eglctx == ctx); 74 | } 75 | 76 | static inline void 77 | glXSwapBuffers(void *dummy, ModeInfo *mi) 78 | { 79 | mi->swap_buffers = 1; 80 | } 81 | 82 | static inline void 83 | do_fps(ModeInfo *mi) 84 | { 85 | } 86 | 87 | /* just enough XImage to satisfy glmatrix.c */ 88 | 89 | typedef struct _XImage { 90 | int width; 91 | int height; 92 | char *data; 93 | int bytes_per_line; 94 | } XImage; 95 | 96 | XImage *xpm_to_ximage(char **xpm_data); 97 | void XDestroyImage(XImage *xi); 98 | 99 | static inline unsigned long 100 | XGetPixel(XImage *xi, int x, int y) 101 | { 102 | return *(uint32_t *)(xi->data + xi->bytes_per_line * y + 4 * x); 103 | } 104 | 105 | static inline void 106 | XPutPixel(XImage *xi, int x, int y, unsigned long pixel) 107 | { 108 | *(uint32_t *)(xi->data + xi->bytes_per_line * y + 4 * x) = pixel; 109 | } 110 | 111 | /* 112 | * override glViewport from the plugin, so we can set it up properly 113 | * rendering to a regular decorated Wayland window. 114 | */ 115 | #ifdef glViewport 116 | #undef glViewport 117 | #endif 118 | #define glViewport(x,y,w,h) do {} while (0) 119 | 120 | #endif /* WSCREENSAVER_GLUE_H */ 121 | -------------------------------------------------------------------------------- /clients/wscreensaver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011 Collabora, Ltd. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef WSCREENSAVER_H 24 | #define WSCREENSAVER_H 25 | 26 | #define MESA_EGL_NO_X11_HEADERS 27 | #include 28 | 29 | extern const char *progname; 30 | 31 | struct wscreensaver; 32 | 33 | struct ModeInfo { 34 | struct wscreensaver *priv; 35 | EGLContext eglctx; 36 | int swap_buffers; 37 | 38 | struct window *window; 39 | struct widget *widget; 40 | 41 | int instance_number; 42 | int width; 43 | int height; 44 | 45 | unsigned long polygon_count; 46 | int fps_p; 47 | }; 48 | 49 | struct wscreensaver_plugin { 50 | const char *name; 51 | void (*init)(struct ModeInfo *mi); 52 | void (*draw)(struct ModeInfo *mi); 53 | void (*reshape)(struct ModeInfo *mi, int w, int h); 54 | /* void (*refresh)(struct ModeInfo *mi); 55 | void (*finish)(struct ModeInfo *mi);*/ 56 | }; 57 | 58 | EGLContext * 59 | init_GL(struct ModeInfo *mi); 60 | 61 | #endif /* WSCREENSAVER_H */ 62 | -------------------------------------------------------------------------------- /data/COPYING: -------------------------------------------------------------------------------- 1 | For the DMZ cursors: 2 | 3 | (c) 2007-2010 Novell, Inc. 4 | 5 | This work is licenced under the Creative Commons Attribution-Share Alike 3.0 6 | United States License. To view a copy of this licence, visit 7 | http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative 8 | Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. 9 | 10 | The terminal icon is taken from the gnome-icon-theme collection which 11 | is also distributed under the Creative Commons BY-SA 3.0 license. -------------------------------------------------------------------------------- /data/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/border.png -------------------------------------------------------------------------------- /data/icon_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/icon_window.png -------------------------------------------------------------------------------- /data/pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/pattern.png -------------------------------------------------------------------------------- /data/sign_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/sign_close.png -------------------------------------------------------------------------------- /data/sign_maximize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/sign_maximize.png -------------------------------------------------------------------------------- /data/sign_minimize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/sign_minimize.png -------------------------------------------------------------------------------- /data/terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/terminal.png -------------------------------------------------------------------------------- /data/wayland.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/weston/8e2184b12e0abab0e8abeb3caa475408006360a7/data/wayland.png -------------------------------------------------------------------------------- /desktop-shell/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2010-2012 Intel Corporation 3 | * Copyright © 2011-2012 Collabora, Ltd. 4 | * Copyright © 2013 Raspberry Pi Foundation 5 | * 6 | * Permission to use, copy, modify, distribute, and sell this software and 7 | * its documentation for any purpose is hereby granted without fee, provided 8 | * that the above copyright notice appear in all copies and that both that 9 | * copyright notice and this permission notice appear in supporting 10 | * documentation, and that the name of the copyright holders not be used in 11 | * advertising or publicity pertaining to distribution of the software 12 | * without specific, written prior permission. The copyright holders make 13 | * no representations about the suitability of this software for any 14 | * purpose. It is provided "as is" without express or implied warranty. 15 | * 16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 21 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 22 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | #include "compositor.h" 28 | 29 | enum animation_type { 30 | ANIMATION_NONE, 31 | 32 | ANIMATION_ZOOM, 33 | ANIMATION_FADE, 34 | ANIMATION_DIM_LAYER, 35 | }; 36 | 37 | enum fade_type { 38 | FADE_IN, 39 | FADE_OUT 40 | }; 41 | 42 | enum exposay_target_state { 43 | EXPOSAY_TARGET_OVERVIEW, /* show all windows */ 44 | EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */ 45 | EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */ 46 | }; 47 | 48 | enum exposay_layout_state { 49 | EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */ 50 | EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */ 51 | EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */ 52 | EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */ 53 | }; 54 | 55 | struct focus_surface { 56 | struct weston_surface *surface; 57 | struct weston_view *view; 58 | struct weston_transform workspace_transform; 59 | }; 60 | 61 | struct workspace { 62 | struct weston_layer layer; 63 | 64 | struct wl_list focus_list; 65 | struct wl_listener seat_destroyed_listener; 66 | 67 | struct focus_surface *fsurf_front; 68 | struct focus_surface *fsurf_back; 69 | struct weston_view_animation *focus_animation; 70 | }; 71 | 72 | struct desktop_shell { 73 | struct weston_compositor *compositor; 74 | 75 | struct wl_listener idle_listener; 76 | struct wl_listener wake_listener; 77 | struct wl_listener destroy_listener; 78 | struct wl_listener show_input_panel_listener; 79 | struct wl_listener hide_input_panel_listener; 80 | struct wl_listener update_input_panel_listener; 81 | 82 | struct weston_layer fullscreen_layer; 83 | struct weston_layer panel_layer; 84 | struct weston_layer background_layer; 85 | struct weston_layer lock_layer; 86 | struct weston_layer input_panel_layer; 87 | 88 | struct wl_listener pointer_focus_listener; 89 | struct weston_surface *grab_surface; 90 | 91 | struct { 92 | struct weston_process process; 93 | struct wl_client *client; 94 | struct wl_resource *desktop_shell; 95 | struct wl_listener client_destroy_listener; 96 | 97 | unsigned deathcount; 98 | uint32_t deathstamp; 99 | } child; 100 | 101 | bool locked; 102 | bool showing_input_panels; 103 | bool prepare_event_sent; 104 | 105 | struct { 106 | struct weston_surface *surface; 107 | pixman_box32_t cursor_rectangle; 108 | } text_input; 109 | 110 | struct weston_surface *lock_surface; 111 | struct wl_listener lock_surface_listener; 112 | 113 | struct { 114 | struct wl_array array; 115 | unsigned int current; 116 | unsigned int num; 117 | 118 | struct wl_list client_list; 119 | 120 | struct weston_animation animation; 121 | struct wl_list anim_sticky_list; 122 | int anim_dir; 123 | uint32_t anim_timestamp; 124 | double anim_current; 125 | struct workspace *anim_from; 126 | struct workspace *anim_to; 127 | } workspaces; 128 | 129 | struct { 130 | char *path; 131 | int duration; 132 | struct wl_resource *binding; 133 | struct weston_process process; 134 | struct wl_event_source *timer; 135 | } screensaver; 136 | 137 | struct { 138 | struct wl_resource *binding; 139 | struct wl_list surfaces; 140 | } input_panel; 141 | 142 | struct { 143 | struct weston_view *view; 144 | struct weston_view_animation *animation; 145 | enum fade_type type; 146 | struct wl_event_source *startup_timer; 147 | } fade; 148 | 149 | struct exposay { 150 | /* XXX: Make these exposay_surfaces. */ 151 | struct weston_view *focus_prev; 152 | struct weston_view *focus_current; 153 | struct weston_view *clicked; 154 | struct workspace *workspace; 155 | struct weston_seat *seat; 156 | struct wl_list surface_list; 157 | 158 | struct weston_keyboard_grab grab_kbd; 159 | struct weston_pointer_grab grab_ptr; 160 | 161 | enum exposay_target_state state_target; 162 | enum exposay_layout_state state_cur; 163 | int in_flight; /* number of animations still running */ 164 | 165 | int num_surfaces; 166 | int grid_size; 167 | int surface_size; 168 | 169 | int hpadding_outer; 170 | int vpadding_outer; 171 | int padding_inner; 172 | 173 | int row_current; 174 | int column_current; 175 | 176 | bool mod_pressed; 177 | bool mod_invalid; 178 | } exposay; 179 | 180 | uint32_t binding_modifier; 181 | uint32_t exposay_modifier; 182 | enum animation_type win_animation_type; 183 | enum animation_type startup_animation_type; 184 | enum animation_type focus_animation_type; 185 | 186 | struct wl_listener output_create_listener; 187 | struct wl_listener output_move_listener; 188 | struct wl_list output_list; 189 | 190 | uint32_t panel_position; 191 | 192 | char *client; 193 | }; 194 | 195 | void 196 | set_alpha_if_fullscreen(struct shell_surface *shsurf); 197 | 198 | struct weston_output * 199 | get_default_output(struct weston_compositor *compositor); 200 | 201 | struct weston_view * 202 | get_default_view(struct weston_surface *surface); 203 | 204 | struct shell_surface * 205 | get_shell_surface(struct weston_surface *surface); 206 | 207 | struct workspace * 208 | get_current_workspace(struct desktop_shell *shell); 209 | 210 | void 211 | lower_fullscreen_layer(struct desktop_shell *shell); 212 | 213 | void 214 | activate(struct desktop_shell *shell, struct weston_surface *es, 215 | struct weston_seat *seat); 216 | 217 | void 218 | exposay_binding(struct weston_seat *seat, 219 | enum weston_keyboard_modifier modifier, 220 | void *data); 221 | int 222 | input_panel_setup(struct desktop_shell *shell); 223 | void 224 | input_panel_destroy(struct desktop_shell *shell); 225 | -------------------------------------------------------------------------------- /man/.gitignore: -------------------------------------------------------------------------------- 1 | weston.1 2 | weston-drm.7 3 | weston.ini.5 4 | 5 | -------------------------------------------------------------------------------- /man/weston-drm.man: -------------------------------------------------------------------------------- 1 | .TH WESTON-DRM 7 "2012-11-27" "Weston __version__" 2 | .SH NAME 3 | weston-drm \- the DRM backend for Weston 4 | .SH SYNOPSIS 5 | .B weston-launch 6 | .LP 7 | .B weston --backend=drm-backend.so 8 | . 9 | .\" *************************************************************** 10 | .SH DESCRIPTION 11 | The DRM backend is the native Weston backend for systems that support 12 | the Linux kernel DRM, kernel mode setting (KMS), and evdev input devices. 13 | It is the recommended backend for desktop PCs, and aims to provide 14 | the full Wayland experience with the "every frame is perfect" concept. 15 | It also relies on the Mesa GBM interface. 16 | 17 | With the DRM backend, 18 | .B weston 19 | runs without any underlying windowing system. The backend uses the 20 | Linux KMS API to detect connected monitors. Monitor hot-plugging is 21 | supported. Input devices are found automatically by 22 | .BR udev (7). 23 | Compositing happens mainly in GL\ ES\ 2, initialized through EGL. It 24 | is also possible to take advantage of hardware cursors and overlays, 25 | when they exist and are functional. Full-screen surfaces will be 26 | scanned out directly without compositing, when possible. 27 | Hardware accelerated clients are supported via EGL. 28 | 29 | The backend chooses the DRM graphics device first based on seat id. 30 | If seat identifiers are not set, it looks for the graphics device 31 | that was used in boot. If that is not found, it finally chooses 32 | the first DRM device returned by 33 | .BR udev (7). 34 | Combining multiple graphics devices are not supported yet. 35 | 36 | The DRM backend relies on 37 | .B weston-launch 38 | for managing input device access and DRM master status, so that 39 | .B weston 40 | can be run without root privileges. On switching away from the 41 | virtual terminal (VT) hosting Weston, all input devices are closed and 42 | the DRM master capability is dropped, so that other servers, 43 | including 44 | .BR Xorg (1), 45 | can run on other VTs. On switching back to Weston's VT, input devices 46 | and DRM master are re-acquired through the parent process 47 | .BR weston-launch . 48 | . 49 | .\" *************************************************************** 50 | .SH CONFIGURATION 51 | . 52 | The DRM backend uses the following entries from 53 | .BR weston.ini . 54 | .SS Section output 55 | .TP 56 | \fBname\fR=\fIconnector\fR 57 | The KMS connector name identifying the output, for instance 58 | .IR LVDS1 . 59 | .TP 60 | \fBmode\fR=\fImode\fR 61 | Specify the video mode for the output. The argument 62 | .I mode 63 | can be one of the words 64 | .BR off " to turn the output off, " 65 | .BR preferred " to use the monitor's preferred video mode, or " 66 | .BR current " to use the current video mode and avoid a mode switch." 67 | It can also be a resolution as 68 | \fIwidth\fBx\fIheight\fR, or a detailed mode line as below. 69 | .TP 70 | \fBmode\fR=\fIdotclock hdisp hsyncstart hsyncend htotal \ 71 | vdisp vsyncstart vsyncend vtotal hflag vflag\fR 72 | Use the given detailed mode line as the video mode for this output. 73 | The definition is the same as in 74 | .BR xorg.conf "(5), and " cvt (1) 75 | can generate detailed mode lines. 76 | .TP 77 | \fBtransform\fR=\fItransform\fR 78 | Transform for the output, which can be rotated in 90-degree steps 79 | and possibly flipped. Possible values are 80 | .BR normal ", " 90 ", " 180 ", " 270 ", " 81 | .BR flipped ", " flipped-90 ", " flipped-180 ", and " flipped-270 . 82 | . 83 | .\" *************************************************************** 84 | .SH OPTIONS 85 | . 86 | When the DRM backend is loaded, 87 | .B weston 88 | will understand the following additional command line options. 89 | .TP 90 | \fB\-\-connector\fR=\fIconnectorid\fR 91 | Use the connector with id number 92 | .I connectorid 93 | as the only initial output. 94 | .TP 95 | .B \-\-current\-mode 96 | By default, use the current video mode of all outputs, instead of 97 | switching to the monitor preferred mode. 98 | .TP 99 | \fB\-\-seat\fR=\fIseatid\fR 100 | Use graphics and input devices designated for seat 101 | .I seatid 102 | instead of the default seat 103 | .BR seat0 . 104 | .TP 105 | \fB\-\-tty\fR=\fIx\fR 106 | Launch Weston on tty 107 | .I x 108 | instead of using the current tty. 109 | . 110 | .\" *************************************************************** 111 | .SH ENVIRONMENT 112 | . 113 | .TP 114 | .B WESTON_TTY_FD 115 | The file descriptor (integer) of the opened tty where 116 | .B weston 117 | will run. Set by 118 | .BR weston-launch . 119 | .TP 120 | .B WESTON_LAUNCHER_SOCK 121 | The file descriptor (integer) where 122 | .B weston-launch 123 | is listening. Automatically set by 124 | .BR weston-launch . 125 | . 126 | .\" *************************************************************** 127 | .SH "SEE ALSO" 128 | .BR weston (1) 129 | .\".BR weston-launch (1), 130 | .\".BR weston.ini (5) 131 | -------------------------------------------------------------------------------- /notes.txt: -------------------------------------------------------------------------------- 1 | This file is a collection of informal notes, with references to where 2 | they were originally written. Each note should have a source and date 3 | mentioned. Let's keep these in date order, newest first. 4 | 5 | 6 | 7 | ----------------------------------------------------------------------- 8 | 2012-10-23; Pekka Paalanen 9 | http://lists.freedesktop.org/archives/wayland-devel/2012-October/005969.html 10 | 11 | For anyone wanting to port or write their own window manager to Wayland: 12 | 13 | Most likely you have a desktop window manager. A quick way to get 14 | started, is to fork Weston's desktop-shell plugin and start hacking it. 15 | Qt could be another good choice, but I am not familiar with it. 16 | 17 | You also need to understand some concepts. I'm repeating things I wrote 18 | to the wayland-devel list earlier, a little rephrased. 19 | 20 | We need to distinguish three different things here (towards Wayland 21 | clients): 22 | 23 | - compositors (servers) 24 | All Wayland compositors are indistinguishable by definition, 25 | since they are Wayland compositors. They only differ in the 26 | global interfaces they advertise, and for general purpose 27 | compositors, we should aim to support the same minimum set of 28 | globals everywhere. For instance, all desktop compositors 29 | should implement wl_shell. In X, this component corresponds to 30 | the X server with a built-in compositing manager. 31 | 32 | - shells 33 | This is a new concept compared to an X stack. A shell defines 34 | how a user and applications interact. The most familiar is a 35 | desktop (environment). If KDE, Gnome, and XFCE are desktop 36 | environments, they all fall under the *same* shell: the desktop 37 | shell. You can have applications in windows, several visible at 38 | the same time, you have keyboards and mice, etc. 39 | 40 | An example of something that is not a desktop shell 41 | could be a TV user interface. TV is profoundly different: 42 | usually no mouse, no keyboard, but you have a remote control 43 | with some buttons. Freely floating windows probably do not make 44 | sense. You may have picture-in-picture, but usually not several 45 | applications showing at once. Most importantly, trying to run 46 | desktop applications here does not work due to the 47 | incompatible application and user interface paradigms. 48 | 49 | On protocol level, a shell is the public shell interface(s), 50 | currently for desktop it is the wl_shell. 51 | 52 | - "window managers" 53 | The X Window Managers correspond to different wl_shell 54 | implementations, not different shells, since they pratically 55 | all deal with a desktop environment. You also want all desktop 56 | applications to work with all window managers, so you need to 57 | implement wl_shell anyway. 58 | 59 | I understand there could be special purpose X Window Managers, that 60 | would better correspond to their own shells. These window managers 61 | might not implement e.g. EWMH by the spec. 62 | 63 | When you implement your own window manager, you want to keep the public 64 | desktop shell interface (wl_shell). You can offer new public 65 | interfaces, too, but keep in mind, that someone needs to make 66 | applications use them. 67 | 68 | In Weston, a shell implementation has two parts: a weston plugin, and a 69 | special client. For desktop shell (wl_shell) these are src/shell.c and 70 | clients/desktop-shell.c. The is also a private protocol extension that 71 | these two can explicitly communicate with. 72 | 73 | The plugin does window management, and the client does most of user 74 | interaction: draw backgrounds, panels, buttons, lock screen dialog, 75 | basically everything that is on screen. 76 | 77 | ----------------------------------------------------------------------- 78 | -------------------------------------------------------------------------------- /protocol/desktop-shell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Traditional user interfaces can rely on this interface to define the 6 | foundations of typical desktops. Currently it's possible to set up 7 | background, panels and locking surfaces. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | The surface set by this request will receive a fake 29 | pointer.enter event during grabs at position 0, 0 and is 30 | expected to set an appropriate cursor image as described by 31 | the grab_cursor event sent just before the enter event. 32 | 33 | 34 | 35 | 36 | 37 | 38 | Tell the server, that enough desktop elements have been drawn 39 | to make the desktop look ready for use. During start-up, the 40 | server can wait for this request with a black screen before 41 | starting to fade in the desktop, for instance. If the client 42 | parts of a desktop take a long time to initialize, we avoid 43 | showing temporary garbage. 44 | 45 | 46 | 47 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | Tell the shell we want it to create and set the lock surface, which is 59 | a GUI asking the user to unlock the screen. The lock surface is 60 | announced with 'set_lock_surface'. Whether or not the shell actually 61 | implements locking, it MUST send 'unlock' request to let the normal 62 | desktop resume. 63 | 64 | 65 | 66 | 67 | 68 | This event will be sent immediately before a fake enter event on the 69 | grab surface. 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Tell the shell which side of the screen the panel is 108 | located. This is so that new windows do not overlap the panel 109 | and maximized windows maximize properly. 110 | 111 | 112 | 113 | 114 | 115 | 116 | Only one client can bind this interface at a time. 117 | 118 | 119 | 120 | 121 | A screensaver surface is normally hidden, and only visible after an 122 | idle timeout. 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /protocol/screenshooter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /protocol/text-cursor-position.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /protocol/wayland-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Copyright © 2012 Intel Corporation 6 | 7 | Permission to use, copy, modify, distribute, and sell this 8 | software and its documentation for any purpose is hereby granted 9 | without fee, provided that the above copyright notice appear in 10 | all copies and that both that copyright notice and this permission 11 | notice appear in supporting documentation, and that the name of 12 | the copyright holders not be used in advertising or publicity 13 | pertaining to distribution of the software without specific, 14 | written prior permission. The copyright holders make no 15 | representations about the suitability of this software for any 16 | purpose. It is provided "as is" without express or implied 17 | warranty. 18 | 19 | THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 20 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 | FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 23 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 24 | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 25 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 26 | THIS SOFTWARE. 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /protocol/workspaces.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An interface for managing surfaces in workspaces. 6 | 7 | 8 | 9 | 10 | Move the given surface to the specified workspace. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | The current workspace state, such as current workspace and workspace 19 | count, has changed. 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /protocol/xserver.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /shared/cairo-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2008 Kristian Høgsberg 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _CAIRO_UTIL_H 24 | #define _CAIRO_UTIL_H 25 | 26 | #include 27 | #include 28 | 29 | void 30 | surface_flush_device(cairo_surface_t *surface); 31 | 32 | void 33 | tile_mask(cairo_t *cr, cairo_surface_t *surface, 34 | int x, int y, int width, int height, int margin, int top_margin); 35 | 36 | void 37 | tile_source(cairo_t *cr, cairo_surface_t *surface, 38 | int x, int y, int width, int height, int margin, int top_margin); 39 | 40 | void 41 | rounded_rect(cairo_t *cr, int x0, int y0, int x1, int y1, int radius); 42 | 43 | cairo_surface_t * 44 | load_cairo_surface(const char *filename); 45 | 46 | struct theme { 47 | cairo_surface_t *active_frame; 48 | cairo_surface_t *inactive_frame; 49 | cairo_surface_t *shadow; 50 | int frame_radius; 51 | int margin; 52 | int width; 53 | int titlebar_height; 54 | }; 55 | 56 | struct theme * 57 | theme_create(void); 58 | void 59 | theme_destroy(struct theme *t); 60 | 61 | enum { 62 | THEME_FRAME_ACTIVE = 1, 63 | THEME_FRAME_MAXIMIZED = 2, 64 | THEME_FRAME_NO_TITLE = 4 65 | }; 66 | 67 | void 68 | theme_set_background_source(struct theme *t, cairo_t *cr, uint32_t flags); 69 | void 70 | theme_render_frame(struct theme *t, 71 | cairo_t *cr, int width, int height, 72 | const char *title, uint32_t flags); 73 | 74 | enum theme_location { 75 | THEME_LOCATION_INTERIOR = 0, 76 | THEME_LOCATION_RESIZING_TOP = 1, 77 | THEME_LOCATION_RESIZING_BOTTOM = 2, 78 | THEME_LOCATION_RESIZING_LEFT = 4, 79 | THEME_LOCATION_RESIZING_TOP_LEFT = 5, 80 | THEME_LOCATION_RESIZING_BOTTOM_LEFT = 6, 81 | THEME_LOCATION_RESIZING_RIGHT = 8, 82 | THEME_LOCATION_RESIZING_TOP_RIGHT = 9, 83 | THEME_LOCATION_RESIZING_BOTTOM_RIGHT = 10, 84 | THEME_LOCATION_RESIZING_MASK = 15, 85 | THEME_LOCATION_EXTERIOR = 16, 86 | THEME_LOCATION_TITLEBAR = 17, 87 | THEME_LOCATION_CLIENT_AREA = 18, 88 | }; 89 | 90 | enum theme_location 91 | theme_get_location(struct theme *t, int x, int y, int width, int height, int flags); 92 | 93 | struct frame; 94 | 95 | enum frame_status { 96 | FRAME_STATUS_NONE = 0, 97 | FRAME_STATUS_REPAINT = 0x1, 98 | FRAME_STATUS_MINIMIZE = 0x2, 99 | FRAME_STATUS_MAXIMIZE = 0x4, 100 | FRAME_STATUS_CLOSE = 0x8, 101 | FRAME_STATUS_MENU = 0x10, 102 | FRAME_STATUS_RESIZE = 0x20, 103 | FRAME_STATUS_MOVE = 0x40, 104 | FRAME_STATUS_ALL = 0x7f 105 | }; 106 | 107 | enum frame_flag { 108 | FRAME_FLAG_ACTIVE = 0x1, 109 | FRAME_FLAG_MAXIMIZED = 0x2 110 | }; 111 | 112 | enum { 113 | FRAME_BUTTON_NONE = 0, 114 | FRAME_BUTTON_CLOSE = 0x1, 115 | FRAME_BUTTON_MAXIMIZE = 0x2, 116 | FRAME_BUTTON_MINIMIZE = 0x4, 117 | FRAME_BUTTON_ALL = 0x7 118 | }; 119 | 120 | enum frame_button_state { 121 | FRAME_BUTTON_RELEASED = 0, 122 | FRAME_BUTTON_PRESSED = 1 123 | }; 124 | 125 | struct frame * 126 | frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons, 127 | const char *title); 128 | 129 | void 130 | frame_destroy(struct frame *frame); 131 | 132 | /* May set FRAME_STATUS_REPAINT */ 133 | int 134 | frame_set_title(struct frame *frame, const char *title); 135 | 136 | /* May set FRAME_STATUS_REPAINT */ 137 | void 138 | frame_set_flag(struct frame *frame, enum frame_flag flag); 139 | 140 | /* May set FRAME_STATUS_REPAINT */ 141 | void 142 | frame_unset_flag(struct frame *frame, enum frame_flag flag); 143 | 144 | /* May set FRAME_STATUS_REPAINT */ 145 | void 146 | frame_resize(struct frame *frame, int32_t width, int32_t height); 147 | 148 | /* May set FRAME_STATUS_REPAINT */ 149 | void 150 | frame_resize_inside(struct frame *frame, int32_t width, int32_t height); 151 | 152 | int32_t 153 | frame_width(struct frame *frame); 154 | 155 | int32_t 156 | frame_height(struct frame *frame); 157 | 158 | void 159 | frame_interior(struct frame *frame, int32_t *x, int32_t *y, 160 | int32_t *width, int32_t *height); 161 | void 162 | frame_input_rect(struct frame *frame, int32_t *x, int32_t *y, 163 | int32_t *width, int32_t *height); 164 | void 165 | frame_opaque_rect(struct frame *frame, int32_t *x, int32_t *y, 166 | int32_t *width, int32_t *height); 167 | 168 | int 169 | frame_get_shadow_margin(struct frame *frame); 170 | 171 | uint32_t 172 | frame_status(struct frame *frame); 173 | 174 | void 175 | frame_status_clear(struct frame *frame, enum frame_status status); 176 | 177 | /* May set FRAME_STATUS_REPAINT */ 178 | enum theme_location 179 | frame_pointer_enter(struct frame *frame, void *pointer, int x, int y); 180 | 181 | /* May set FRAME_STATUS_REPAINT */ 182 | enum theme_location 183 | frame_pointer_motion(struct frame *frame, void *pointer, int x, int y); 184 | 185 | /* May set FRAME_STATUS_REPAINT */ 186 | void 187 | frame_pointer_leave(struct frame *frame, void *pointer); 188 | 189 | /* Call to indicate that a button has been pressed/released. The return 190 | * value for a button release will be the same as for the corresponding 191 | * press. This allows you to more easily track grabs. If you want the 192 | * actual location, simply keep the location from the last 193 | * frame_pointer_motion call. 194 | * 195 | * May set: 196 | * FRAME_STATUS_MINIMIZE 197 | * FRAME_STATUS_MAXIMIZE 198 | * FRAME_STATUS_CLOSE 199 | * FRAME_STATUS_MENU 200 | * FRAME_STATUS_RESIZE 201 | * FRAME_STATUS_MOVE 202 | */ 203 | enum theme_location 204 | frame_pointer_button(struct frame *frame, void *pointer, 205 | uint32_t button, enum frame_button_state state); 206 | 207 | void 208 | frame_touch_down(struct frame *frame, void *data, int32_t id, int x, int y); 209 | 210 | void 211 | frame_touch_up(struct frame *frame, void *data, int32_t id); 212 | 213 | void 214 | frame_repaint(struct frame *frame, cairo_t *cr); 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /shared/config-parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2008 Kristian Høgsberg 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef CONFIGPARSER_H 24 | #define CONFIGPARSER_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | enum config_key_type { 31 | CONFIG_KEY_INTEGER, /* typeof data = int */ 32 | CONFIG_KEY_UNSIGNED_INTEGER, /* typeof data = unsigned int */ 33 | CONFIG_KEY_STRING, /* typeof data = char* */ 34 | CONFIG_KEY_BOOLEAN /* typeof data = int */ 35 | }; 36 | 37 | struct config_key { 38 | const char *name; 39 | enum config_key_type type; 40 | void *data; 41 | }; 42 | 43 | struct config_section { 44 | const char *name; 45 | const struct config_key *keys; 46 | int num_keys; 47 | void (*done)(void *data); 48 | }; 49 | 50 | enum weston_option_type { 51 | WESTON_OPTION_INTEGER, 52 | WESTON_OPTION_UNSIGNED_INTEGER, 53 | WESTON_OPTION_STRING, 54 | WESTON_OPTION_BOOLEAN 55 | }; 56 | 57 | struct weston_option { 58 | enum weston_option_type type; 59 | const char *name; 60 | int short_name; 61 | void *data; 62 | }; 63 | 64 | int 65 | parse_options(const struct weston_option *options, 66 | int count, int *argc, char *argv[]); 67 | 68 | struct weston_config_section; 69 | struct weston_config; 70 | 71 | struct weston_config_section * 72 | weston_config_get_section(struct weston_config *config, const char *section, 73 | const char *key, const char *value); 74 | int 75 | weston_config_section_get_int(struct weston_config_section *section, 76 | const char *key, 77 | int32_t *value, int32_t default_value); 78 | int 79 | weston_config_section_get_uint(struct weston_config_section *section, 80 | const char *key, 81 | uint32_t *value, uint32_t default_value); 82 | int 83 | weston_config_section_get_double(struct weston_config_section *section, 84 | const char *key, 85 | double *value, double default_value); 86 | int 87 | weston_config_section_get_string(struct weston_config_section *section, 88 | const char *key, 89 | char **value, 90 | const char *default_value); 91 | int 92 | weston_config_section_get_bool(struct weston_config_section *section, 93 | const char *key, 94 | int *value, int default_value); 95 | struct weston_config * 96 | weston_config_parse(const char *name); 97 | 98 | const char * 99 | weston_config_get_full_path(struct weston_config *config); 100 | 101 | void 102 | weston_config_destroy(struct weston_config *config); 103 | 104 | int weston_config_next_section(struct weston_config *config, 105 | struct weston_config_section **section, 106 | const char **name); 107 | 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* CONFIGPARSER_H */ 114 | 115 | -------------------------------------------------------------------------------- /shared/image-loader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _IMAGE_LOADER_H 24 | #define _IMAGE_LOADER_H 25 | 26 | #include 27 | 28 | pixman_image_t * 29 | load_image(const char *filename); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /shared/matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2008-2011 Kristian Høgsberg 3 | * Copyright © 2012 Collabora, Ltd. 4 | * 5 | * Permission to use, copy, modify, distribute, and sell this software and 6 | * its documentation for any purpose is hereby granted without fee, provided 7 | * that the above copyright notice appear in all copies and that both that 8 | * copyright notice and this permission notice appear in supporting 9 | * documentation, and that the name of the copyright holders not be used in 10 | * advertising or publicity pertaining to distribution of the software 11 | * without specific, written prior permission. The copyright holders make 12 | * no representations about the suitability of this software for any 13 | * purpose. It is provided "as is" without express or implied warranty. 14 | * 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | */ 23 | 24 | #ifndef WESTON_MATRIX_H 25 | #define WESTON_MATRIX_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | enum weston_matrix_transform_type { 32 | WESTON_MATRIX_TRANSFORM_TRANSLATE = (1 << 0), 33 | WESTON_MATRIX_TRANSFORM_SCALE = (1 << 1), 34 | WESTON_MATRIX_TRANSFORM_ROTATE = (1 << 2), 35 | WESTON_MATRIX_TRANSFORM_OTHER = (1 << 3), 36 | }; 37 | 38 | struct weston_matrix { 39 | float d[16]; 40 | unsigned int type; 41 | }; 42 | 43 | struct weston_vector { 44 | float f[4]; 45 | }; 46 | 47 | void 48 | weston_matrix_init(struct weston_matrix *matrix); 49 | void 50 | weston_matrix_multiply(struct weston_matrix *m, const struct weston_matrix *n); 51 | void 52 | weston_matrix_scale(struct weston_matrix *matrix, float x, float y, float z); 53 | void 54 | weston_matrix_translate(struct weston_matrix *matrix, 55 | float x, float y, float z); 56 | void 57 | weston_matrix_rotate_xy(struct weston_matrix *matrix, float cos, float sin); 58 | void 59 | weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v); 60 | 61 | int 62 | weston_matrix_invert(struct weston_matrix *inverse, 63 | const struct weston_matrix *matrix); 64 | 65 | #ifdef UNIT_TEST 66 | # define MATRIX_TEST_EXPORT WL_EXPORT 67 | 68 | int 69 | matrix_invert(double *A, unsigned *p, const struct weston_matrix *matrix); 70 | 71 | void 72 | inverse_transform(const double *LU, const unsigned *p, float *v); 73 | 74 | #else 75 | # define MATRIX_TEST_EXPORT static 76 | #endif 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* WESTON_MATRIX_H */ 83 | -------------------------------------------------------------------------------- /shared/option-parser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Kristian Høgsberg 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "config-parser.h" 32 | 33 | static void 34 | handle_option(const struct weston_option *option, char *value) 35 | { 36 | switch (option->type) { 37 | case WESTON_OPTION_INTEGER: 38 | * (int32_t *) option->data = strtol(value, NULL, 0); 39 | return; 40 | case WESTON_OPTION_UNSIGNED_INTEGER: 41 | * (uint32_t *) option->data = strtoul(value, NULL, 0); 42 | return; 43 | case WESTON_OPTION_STRING: 44 | * (char **) option->data = strdup(value); 45 | return; 46 | case WESTON_OPTION_BOOLEAN: 47 | * (int32_t *) option->data = 1; 48 | return; 49 | default: 50 | assert(0); 51 | } 52 | } 53 | 54 | int 55 | parse_options(const struct weston_option *options, 56 | int count, int *argc, char *argv[]) 57 | { 58 | int i, j, k, len = 0; 59 | 60 | for (i = 1, j = 1; i < *argc; i++) { 61 | for (k = 0; k < count; k++) { 62 | if (options[k].name) 63 | len = strlen(options[k].name); 64 | if (options[k].name && 65 | argv[i][0] == '-' && 66 | argv[i][1] == '-' && 67 | strncmp(options[k].name, &argv[i][2], len) == 0 && 68 | (argv[i][len + 2] == '=' || argv[i][len + 2] == '\0')) { 69 | handle_option(&options[k], &argv[i][len + 3]); 70 | break; 71 | } else if (options[k].short_name && 72 | argv[i][0] == '-' && 73 | options[k].short_name == argv[i][1]) { 74 | handle_option(&options[k], &argv[i][2]); 75 | break; 76 | } 77 | } 78 | if (k == count) 79 | argv[j++] = argv[i]; 80 | } 81 | argv[j] = NULL; 82 | *argc = j; 83 | 84 | return j; 85 | } 86 | -------------------------------------------------------------------------------- /shared/os-compatibility.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Collabora, Ltd. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "os-compatibility.h" 35 | 36 | static int 37 | set_cloexec_or_close(int fd) 38 | { 39 | long flags; 40 | 41 | if (fd == -1) 42 | return -1; 43 | 44 | flags = fcntl(fd, F_GETFD); 45 | if (flags == -1) 46 | goto err; 47 | 48 | if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) 49 | goto err; 50 | 51 | return fd; 52 | 53 | err: 54 | close(fd); 55 | return -1; 56 | } 57 | 58 | int 59 | os_socketpair_cloexec(int domain, int type, int protocol, int *sv) 60 | { 61 | int ret; 62 | 63 | #ifdef SOCK_CLOEXEC 64 | ret = socketpair(domain, type | SOCK_CLOEXEC, protocol, sv); 65 | if (ret == 0 || errno != EINVAL) 66 | return ret; 67 | #endif 68 | 69 | ret = socketpair(domain, type, protocol, sv); 70 | if (ret < 0) 71 | return ret; 72 | 73 | sv[0] = set_cloexec_or_close(sv[0]); 74 | sv[1] = set_cloexec_or_close(sv[1]); 75 | 76 | if (sv[0] != -1 && sv[1] != -1) 77 | return 0; 78 | 79 | close(sv[0]); 80 | close(sv[1]); 81 | return -1; 82 | } 83 | 84 | int 85 | os_epoll_create_cloexec(void) 86 | { 87 | int fd; 88 | 89 | #ifdef EPOLL_CLOEXEC 90 | fd = epoll_create1(EPOLL_CLOEXEC); 91 | if (fd >= 0) 92 | return fd; 93 | if (errno != EINVAL) 94 | return -1; 95 | #endif 96 | 97 | fd = epoll_create(1); 98 | return set_cloexec_or_close(fd); 99 | } 100 | 101 | static int 102 | create_tmpfile_cloexec(char *tmpname) 103 | { 104 | int fd; 105 | 106 | #ifdef HAVE_MKOSTEMP 107 | fd = mkostemp(tmpname, O_CLOEXEC); 108 | if (fd >= 0) 109 | unlink(tmpname); 110 | #else 111 | fd = mkstemp(tmpname); 112 | if (fd >= 0) { 113 | fd = set_cloexec_or_close(fd); 114 | unlink(tmpname); 115 | } 116 | #endif 117 | 118 | return fd; 119 | } 120 | 121 | /* 122 | * Create a new, unique, anonymous file of the given size, and 123 | * return the file descriptor for it. The file descriptor is set 124 | * CLOEXEC. The file is immediately suitable for mmap()'ing 125 | * the given size at offset zero. 126 | * 127 | * The file should not have a permanent backing store like a disk, 128 | * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. 129 | * 130 | * The file name is deleted from the file system. 131 | * 132 | * The file is suitable for buffer sharing between processes by 133 | * transmitting the file descriptor over Unix sockets using the 134 | * SCM_RIGHTS methods. 135 | * 136 | * If the C library implements posix_fallocate(), it is used to 137 | * guarantee that disk space is available for the file at the 138 | * given size. If disk space is insufficent, errno is set to ENOSPC. 139 | * If posix_fallocate() is not supported, program may receive 140 | * SIGBUS on accessing mmap()'ed file contents instead. 141 | */ 142 | int 143 | os_create_anonymous_file(off_t size) 144 | { 145 | static const char template[] = "/weston-shared-XXXXXX"; 146 | const char *path; 147 | char *name; 148 | int fd; 149 | int ret; 150 | 151 | path = getenv("XDG_RUNTIME_DIR"); 152 | if (!path) { 153 | errno = ENOENT; 154 | return -1; 155 | } 156 | 157 | name = malloc(strlen(path) + sizeof(template)); 158 | if (!name) 159 | return -1; 160 | 161 | strcpy(name, path); 162 | strcat(name, template); 163 | 164 | fd = create_tmpfile_cloexec(name); 165 | 166 | free(name); 167 | 168 | if (fd < 0) 169 | return -1; 170 | 171 | #ifdef HAVE_POSIX_FALLOCATE 172 | ret = posix_fallocate(fd, 0, size); 173 | if (ret != 0) { 174 | close(fd); 175 | errno = ret; 176 | return -1; 177 | } 178 | #else 179 | ret = ftruncate(fd, size); 180 | if (ret < 0) { 181 | close(fd); 182 | return -1; 183 | } 184 | #endif 185 | 186 | return fd; 187 | } 188 | 189 | #ifndef HAVE_STRCHRNUL 190 | char * 191 | strchrnul(const char *s, int c) 192 | { 193 | while (*s && *s != c) 194 | s++; 195 | return (char *)s; 196 | } 197 | #endif 198 | -------------------------------------------------------------------------------- /shared/os-compatibility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Collabora, Ltd. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef OS_COMPATIBILITY_H 24 | #define OS_COMPATIBILITY_H 25 | 26 | #include 27 | 28 | #include "config.h" 29 | 30 | #ifdef HAVE_EXECINFO_H 31 | #include 32 | #else 33 | static inline int 34 | backtrace(void **buffer, int size) 35 | { 36 | return 0; 37 | } 38 | #endif 39 | 40 | int 41 | os_socketpair_cloexec(int domain, int type, int protocol, int *sv); 42 | 43 | int 44 | os_epoll_create_cloexec(void); 45 | 46 | int 47 | os_create_anonymous_file(off_t size); 48 | 49 | #ifndef HAVE_STRCHRNUL 50 | char * 51 | strchrnul(const char *s, int c); 52 | #endif 53 | 54 | #endif /* OS_COMPATIBILITY_H */ 55 | -------------------------------------------------------------------------------- /shared/zalloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Red Hat, Inc. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef WESTON_ZALLOC_H 24 | #define WESTON_ZALLOC_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #include 31 | 32 | static inline void * 33 | zalloc(size_t size) 34 | { 35 | return calloc(1, size); 36 | } 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* WESTON_ZALLOC_H */ 43 | -------------------------------------------------------------------------------- /src/cms-helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Richard Hughes 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #ifdef HAVE_LCMS 30 | #include 31 | #endif 32 | 33 | #include "compositor.h" 34 | #include "cms-helper.h" 35 | 36 | #ifdef HAVE_LCMS 37 | static void 38 | weston_cms_gamma_clear(struct weston_output *o) 39 | { 40 | int i; 41 | uint16_t *red; 42 | 43 | if (!o->set_gamma) 44 | return; 45 | 46 | red = calloc(o->gamma_size, sizeof(uint16_t)); 47 | for (i = 0; i < o->gamma_size; i++) 48 | red[i] = (uint32_t) 0xffff * (uint32_t) i / (uint32_t) (o->gamma_size - 1); 49 | o->set_gamma(o, o->gamma_size, red, red, red); 50 | free(red); 51 | } 52 | #endif 53 | 54 | void 55 | weston_cms_set_color_profile(struct weston_output *o, 56 | struct weston_color_profile *p) 57 | { 58 | #ifdef HAVE_LCMS 59 | cmsFloat32Number in; 60 | const cmsToneCurve **vcgt; 61 | int i; 62 | int size; 63 | uint16_t *red = NULL; 64 | uint16_t *green = NULL; 65 | uint16_t *blue = NULL; 66 | 67 | if (!o->set_gamma) 68 | return; 69 | if (!p) { 70 | weston_cms_gamma_clear(o); 71 | return; 72 | } 73 | 74 | weston_log("Using ICC profile %s\n", p->filename); 75 | vcgt = cmsReadTag (p->lcms_handle, cmsSigVcgtTag); 76 | if (vcgt == NULL || vcgt[0] == NULL) { 77 | weston_cms_gamma_clear(o); 78 | return; 79 | } 80 | 81 | size = o->gamma_size; 82 | red = calloc(size, sizeof(uint16_t)); 83 | green = calloc(size, sizeof(uint16_t)); 84 | blue = calloc(size, sizeof(uint16_t)); 85 | for (i = 0; i < size; i++) { 86 | in = (cmsFloat32Number) i / (cmsFloat32Number) (size - 1); 87 | red[i] = cmsEvalToneCurveFloat(vcgt[0], in) * (double) 0xffff; 88 | green[i] = cmsEvalToneCurveFloat(vcgt[1], in) * (double) 0xffff; 89 | blue[i] = cmsEvalToneCurveFloat(vcgt[2], in) * (double) 0xffff; 90 | } 91 | o->set_gamma(o, size, red, green, blue); 92 | free(red); 93 | free(green); 94 | free(blue); 95 | #endif 96 | } 97 | 98 | void 99 | weston_cms_destroy_profile(struct weston_color_profile *p) 100 | { 101 | if (!p) 102 | return; 103 | #ifdef HAVE_LCMS 104 | cmsCloseProfile(p->lcms_handle); 105 | #endif 106 | free(p->filename); 107 | free(p); 108 | } 109 | 110 | struct weston_color_profile * 111 | weston_cms_create_profile(const char *filename, 112 | void *lcms_profile) 113 | { 114 | struct weston_color_profile *p; 115 | p = calloc(1, sizeof(struct weston_color_profile)); 116 | p->filename = strdup(filename); 117 | p->lcms_handle = lcms_profile; 118 | return p; 119 | } 120 | 121 | struct weston_color_profile * 122 | weston_cms_load_profile(const char *filename) 123 | { 124 | struct weston_color_profile *p = NULL; 125 | #ifdef HAVE_LCMS 126 | cmsHPROFILE lcms_profile; 127 | lcms_profile = cmsOpenProfileFromFile(filename, "r"); 128 | if (lcms_profile) 129 | p = weston_cms_create_profile(filename, lcms_profile); 130 | #endif 131 | return p; 132 | } 133 | -------------------------------------------------------------------------------- /src/cms-helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Richard Hughes 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _WESTON_CMS_H_ 24 | #define _WESTON_CMS_H_ 25 | 26 | #include "config.h" 27 | 28 | #include "compositor.h" 29 | 30 | /* General overview on how to be a CMS plugin: 31 | * 32 | * First, some nomenclature: 33 | * 34 | * CMF: Color management framework, i.e. "Use foo.icc for device $bar" 35 | * CMM: Color management module that converts pixel colors, which is 36 | * usually lcms2 on any modern OS. 37 | * CMS: Color management system that encompasses both a CMF and CMM. 38 | * ICC: International Color Consortium, the people that define the 39 | * binary encoding of a .icc file. 40 | * VCGT: Video Card Gamma Tag. An Apple extension to the ICC specification 41 | * that allows the calibration state to be stored in the ICC profile 42 | * Output: Physical port with a display attached, e.g. LVDS1 43 | * 44 | * As a CMF is probably something you don't want or need on an embeded install 45 | * these functions will not be called if the icc_profile key is set for a 46 | * specific [output] section in weston.ini 47 | * 48 | * Most desktop environments want the CMF to decide what profile to use in 49 | * different situations, so that displays can be profiled and also so that 50 | * the ICC profiles can be changed at runtime depending on the task or ambient 51 | * environment. 52 | * 53 | * The CMF can be selected using the 'modules' key in the [core] section. 54 | */ 55 | 56 | struct weston_color_profile { 57 | char *filename; 58 | void *lcms_handle; 59 | }; 60 | 61 | void 62 | weston_cms_set_color_profile(struct weston_output *o, 63 | struct weston_color_profile *p); 64 | struct weston_color_profile * 65 | weston_cms_create_profile(const char *filename, 66 | void *lcms_profile); 67 | struct weston_color_profile * 68 | weston_cms_load_profile(const char *filename); 69 | void 70 | weston_cms_destroy_profile(struct weston_color_profile *p); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/cms-static.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Richard Hughes 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | 28 | #include "compositor.h" 29 | #include "cms-helper.h" 30 | 31 | struct cms_static { 32 | struct weston_compositor *ec; 33 | struct wl_listener destroy_listener; 34 | struct wl_listener output_created_listener; 35 | }; 36 | 37 | static void 38 | cms_output_created(struct cms_static *cms, struct weston_output *o) 39 | { 40 | struct weston_color_profile *p; 41 | struct weston_config_section *s; 42 | char *profile; 43 | 44 | weston_log("cms-static: output %i [%s] created\n", o->id, o->name); 45 | 46 | if (o->name == NULL) 47 | return; 48 | s = weston_config_get_section(cms->ec->config, 49 | "output", "name", o->name); 50 | if (s == NULL) 51 | return; 52 | if (weston_config_section_get_string(s, "icc_profile", &profile, NULL) < 0) 53 | return; 54 | p = weston_cms_load_profile(profile); 55 | if (p == NULL) { 56 | weston_log("cms-static: failed to load %s\n", profile); 57 | } else { 58 | weston_log("cms-static: loading %s for %s\n", 59 | profile, o->name); 60 | weston_cms_set_color_profile(o, p); 61 | } 62 | } 63 | 64 | static void 65 | cms_notifier_output_created(struct wl_listener *listener, void *data) 66 | { 67 | struct weston_output *o = (struct weston_output *) data; 68 | struct cms_static *cms = 69 | container_of(listener, struct cms_static, output_created_listener); 70 | cms_output_created(cms, o); 71 | } 72 | 73 | static void 74 | cms_module_destroy(struct cms_static *cms) 75 | { 76 | free(cms); 77 | } 78 | 79 | static void 80 | cms_notifier_destroy(struct wl_listener *listener, void *data) 81 | { 82 | struct cms_static *cms = container_of(listener, struct cms_static, destroy_listener); 83 | cms_module_destroy(cms); 84 | } 85 | 86 | 87 | WL_EXPORT int 88 | module_init(struct weston_compositor *ec, 89 | int *argc, char *argv[]) 90 | { 91 | struct cms_static *cms; 92 | struct weston_output *output; 93 | 94 | weston_log("cms-static: initialized\n"); 95 | 96 | /* create local state object */ 97 | cms = zalloc(sizeof *cms); 98 | if (cms == NULL) 99 | return -1; 100 | 101 | cms->ec = ec; 102 | cms->destroy_listener.notify = cms_notifier_destroy; 103 | wl_signal_add(&ec->destroy_signal, &cms->destroy_listener); 104 | 105 | cms->output_created_listener.notify = cms_notifier_output_created; 106 | wl_signal_add(&ec->output_created_signal, &cms->output_created_listener); 107 | 108 | /* discover outputs */ 109 | wl_list_for_each(output, &ec->output_list, link) 110 | cms_output_created(cms, output); 111 | 112 | return 0; 113 | } 114 | -------------------------------------------------------------------------------- /src/compositor-headless.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2010-2011 Benjamin Franzke 3 | * Copyright © 2012 Intel Corporation 4 | * 5 | * Permission to use, copy, modify, distribute, and sell this software and 6 | * its documentation for any purpose is hereby granted without fee, provided 7 | * that the above copyright notice appear in all copies and that both that 8 | * copyright notice and this permission notice appear in supporting 9 | * documentation, and that the name of the copyright holders not be used in 10 | * advertising or publicity pertaining to distribution of the software 11 | * without specific, written prior permission. The copyright holders make 12 | * no representations about the suitability of this software for any 13 | * purpose. It is provided "as is" without express or implied warranty. 14 | * 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "compositor.h" 31 | 32 | struct headless_compositor { 33 | struct weston_compositor base; 34 | struct weston_seat fake_seat; 35 | }; 36 | 37 | struct headless_output { 38 | struct weston_output base; 39 | struct weston_mode mode; 40 | struct wl_event_source *finish_frame_timer; 41 | }; 42 | 43 | 44 | static void 45 | headless_output_start_repaint_loop(struct weston_output *output) 46 | { 47 | uint32_t msec; 48 | struct timeval tv; 49 | 50 | gettimeofday(&tv, NULL); 51 | msec = tv.tv_sec * 1000 + tv.tv_usec / 1000; 52 | weston_output_finish_frame(output, msec); 53 | } 54 | 55 | static int 56 | finish_frame_handler(void *data) 57 | { 58 | headless_output_start_repaint_loop(data); 59 | 60 | return 1; 61 | } 62 | 63 | static int 64 | headless_output_repaint(struct weston_output *output_base, 65 | pixman_region32_t *damage) 66 | { 67 | struct headless_output *output = (struct headless_output *) output_base; 68 | struct weston_compositor *ec = output->base.compositor; 69 | 70 | ec->renderer->repaint_output(&output->base, damage); 71 | 72 | pixman_region32_subtract(&ec->primary_plane.damage, 73 | &ec->primary_plane.damage, damage); 74 | 75 | wl_event_source_timer_update(output->finish_frame_timer, 16); 76 | 77 | return 0; 78 | } 79 | 80 | static void 81 | headless_output_destroy(struct weston_output *output_base) 82 | { 83 | struct headless_output *output = (struct headless_output *) output_base; 84 | 85 | wl_event_source_remove(output->finish_frame_timer); 86 | free(output); 87 | 88 | return; 89 | } 90 | 91 | static int 92 | headless_compositor_create_output(struct headless_compositor *c, 93 | int width, int height) 94 | { 95 | struct headless_output *output; 96 | struct wl_event_loop *loop; 97 | 98 | output = zalloc(sizeof *output); 99 | if (output == NULL) 100 | return -1; 101 | 102 | output->mode.flags = 103 | WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; 104 | output->mode.width = width; 105 | output->mode.height = height; 106 | output->mode.refresh = 60; 107 | wl_list_init(&output->base.mode_list); 108 | wl_list_insert(&output->base.mode_list, &output->mode.link); 109 | 110 | output->base.current_mode = &output->mode; 111 | weston_output_init(&output->base, &c->base, 0, 0, width, height, 112 | WL_OUTPUT_TRANSFORM_NORMAL, 1); 113 | 114 | output->base.make = "weston"; 115 | output->base.model = "headless"; 116 | 117 | loop = wl_display_get_event_loop(c->base.wl_display); 118 | output->finish_frame_timer = 119 | wl_event_loop_add_timer(loop, finish_frame_handler, output); 120 | 121 | output->base.start_repaint_loop = headless_output_start_repaint_loop; 122 | output->base.repaint = headless_output_repaint; 123 | output->base.destroy = headless_output_destroy; 124 | output->base.assign_planes = NULL; 125 | output->base.set_backlight = NULL; 126 | output->base.set_dpms = NULL; 127 | output->base.switch_mode = NULL; 128 | 129 | wl_list_insert(c->base.output_list.prev, &output->base.link); 130 | 131 | return 0; 132 | } 133 | 134 | static void 135 | headless_restore(struct weston_compositor *ec) 136 | { 137 | } 138 | 139 | static void 140 | headless_destroy(struct weston_compositor *ec) 141 | { 142 | struct headless_compositor *c = (struct headless_compositor *) ec; 143 | 144 | weston_seat_release(&c->fake_seat); 145 | weston_compositor_shutdown(ec); 146 | 147 | free(ec); 148 | } 149 | 150 | static struct weston_compositor * 151 | headless_compositor_create(struct wl_display *display, 152 | int width, int height, const char *display_name, 153 | int *argc, char *argv[], 154 | struct weston_config *config) 155 | { 156 | struct headless_compositor *c; 157 | 158 | c = zalloc(sizeof *c); 159 | if (c == NULL) 160 | return NULL; 161 | 162 | if (weston_compositor_init(&c->base, display, argc, argv, config) < 0) 163 | goto err_free; 164 | 165 | weston_seat_init(&c->fake_seat, &c->base, "default"); 166 | 167 | c->base.destroy = headless_destroy; 168 | c->base.restore = headless_restore; 169 | 170 | if (headless_compositor_create_output(c, width, height) < 0) 171 | goto err_compositor; 172 | 173 | if (noop_renderer_init(&c->base) < 0) 174 | goto err_compositor; 175 | 176 | return &c->base; 177 | 178 | err_compositor: 179 | weston_compositor_shutdown(&c->base); 180 | err_free: 181 | free(c); 182 | return NULL; 183 | } 184 | 185 | WL_EXPORT struct weston_compositor * 186 | backend_init(struct wl_display *display, int *argc, char *argv[], 187 | struct weston_config *config) 188 | { 189 | int width = 1024, height = 640; 190 | char *display_name = NULL; 191 | 192 | const struct weston_option headless_options[] = { 193 | { WESTON_OPTION_INTEGER, "width", 0, &width }, 194 | { WESTON_OPTION_INTEGER, "height", 0, &height }, 195 | }; 196 | 197 | parse_options(headless_options, 198 | ARRAY_LENGTH(headless_options), argc, argv); 199 | 200 | return headless_compositor_create(display, width, height, display_name, 201 | argc, argv, config); 202 | } 203 | -------------------------------------------------------------------------------- /src/dbus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 David Herrmann 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _WESTON_DBUS_H_ 24 | #define _WESTON_DBUS_H_ 25 | 26 | #include "config.h" 27 | 28 | #include 29 | #include 30 | 31 | #include "compositor.h" 32 | 33 | #ifdef HAVE_DBUS 34 | 35 | #include 36 | 37 | /* 38 | * weston_dbus_open() - Open new dbus connection 39 | * 40 | * Opens a new dbus connection to the bus given as @bus. It automatically 41 | * integrates the new connection into the main-loop @loop. The connection 42 | * itself is returned in @out. 43 | * This also returns a context source used for dbus dispatching. It is 44 | * returned on success in @ctx_out and must be passed to weston_dbus_close() 45 | * unchanged. You must not access it from outside of a dbus helper! 46 | * 47 | * Returns 0 on success, negative error code on failure. 48 | */ 49 | int weston_dbus_open(struct wl_event_loop *loop, DBusBusType bus, 50 | DBusConnection **out, struct wl_event_source **ctx_out); 51 | 52 | /* 53 | * weston_dbus_close() - Close dbus connection 54 | * 55 | * Closes a dbus connection that was previously opened via weston_dbus_open(). 56 | * It unbinds the connection from the main-loop it was previously bound to, 57 | * closes the dbus connection and frees all resources. If you want to access 58 | * @c after this call returns, you must hold a dbus-reference to it. But 59 | * notice that the connection is closed after this returns so it cannot be 60 | * used to spawn new dbus requests. 61 | * You must pass the context source returns by weston_dbus_open() as @ctx. 62 | */ 63 | void weston_dbus_close(DBusConnection *c, struct wl_event_source *ctx); 64 | 65 | /* 66 | * weston_dbus_add_match() - Add dbus match 67 | * 68 | * Configure a dbus-match on the given dbus-connection. This match is saved 69 | * on the dbus-server as long as the connection is open. See dbus-manual 70 | * for information. Compared to the dbus_bus_add_match() this allows a 71 | * var-arg formatted match-string. 72 | */ 73 | int weston_dbus_add_match(DBusConnection *c, const char *format, ...); 74 | 75 | /* 76 | * weston_dbus_add_match_signal() - Add dbus signal match 77 | * 78 | * Same as weston_dbus_add_match() but does the dbus-match formatting for 79 | * signals internally. 80 | */ 81 | int weston_dbus_add_match_signal(DBusConnection *c, const char *sender, 82 | const char *iface, const char *member, 83 | const char *path); 84 | 85 | /* 86 | * weston_dbus_remove_match() - Remove dbus match 87 | * 88 | * Remove a previously configured dbus-match from the dbus server. There is 89 | * no need to remove dbus-matches if you close the connection, anyway. 90 | * Compared to dbus_bus_remove_match() this allows a var-arg formatted 91 | * match string. 92 | */ 93 | void weston_dbus_remove_match(DBusConnection *c, const char *format, ...); 94 | 95 | /* 96 | * weston_dbus_remove_match_signal() - Remove dbus signal match 97 | * 98 | * Same as weston_dbus_remove_match() but does the dbus-match formatting for 99 | * signals internally. 100 | */ 101 | void weston_dbus_remove_match_signal(DBusConnection *c, const char *sender, 102 | const char *iface, const char *member, 103 | const char *path); 104 | 105 | #endif /* HAVE_DBUS */ 106 | 107 | #endif // _WESTON_DBUS_H_ 108 | -------------------------------------------------------------------------------- /src/evdev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011, 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef EVDEV_H 24 | #define EVDEV_H 25 | 26 | #include "config.h" 27 | 28 | #include 29 | #include 30 | 31 | #define MAX_SLOTS 16 32 | 33 | enum evdev_event_type { 34 | EVDEV_NONE, 35 | EVDEV_ABSOLUTE_TOUCH_DOWN, 36 | EVDEV_ABSOLUTE_MOTION, 37 | EVDEV_ABSOLUTE_TOUCH_UP, 38 | EVDEV_ABSOLUTE_MT_DOWN, 39 | EVDEV_ABSOLUTE_MT_MOTION, 40 | EVDEV_ABSOLUTE_MT_UP, 41 | EVDEV_RELATIVE_MOTION, 42 | }; 43 | 44 | enum evdev_device_seat_capability { 45 | EVDEV_SEAT_POINTER = (1 << 0), 46 | EVDEV_SEAT_KEYBOARD = (1 << 1), 47 | EVDEV_SEAT_TOUCH = (1 << 2) 48 | }; 49 | 50 | struct evdev_device { 51 | struct weston_seat *seat; 52 | struct wl_list link; 53 | struct wl_event_source *source; 54 | struct weston_output *output; 55 | struct evdev_dispatch *dispatch; 56 | struct wl_listener output_destroy_listener; 57 | char *devnode; 58 | char *devname; 59 | char *output_name; 60 | int fd; 61 | struct { 62 | int min_x, max_x, min_y, max_y; 63 | uint32_t seat_slot; 64 | int32_t x, y; 65 | 66 | int apply_calibration; 67 | float calibration[6]; 68 | } abs; 69 | 70 | struct { 71 | int slot; 72 | struct { 73 | int32_t x, y; 74 | uint32_t seat_slot; 75 | } slots[MAX_SLOTS]; 76 | } mt; 77 | struct mtdev *mtdev; 78 | 79 | struct { 80 | wl_fixed_t dx, dy; 81 | } rel; 82 | 83 | enum evdev_event_type pending_event; 84 | enum evdev_device_seat_capability seat_caps; 85 | 86 | int is_mt; 87 | }; 88 | 89 | /* copied from udev/extras/input_id/input_id.c */ 90 | /* we must use this kernel-compatible implementation */ 91 | #define BITS_PER_LONG (sizeof(unsigned long) * 8) 92 | #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) 93 | #define OFF(x) ((x)%BITS_PER_LONG) 94 | #define BIT(x) (1UL<> OFF(bit)) & 1) 97 | /* end copied */ 98 | 99 | #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1) 100 | 101 | struct evdev_dispatch; 102 | 103 | struct evdev_dispatch_interface { 104 | /* Process an evdev input event. */ 105 | void (*process)(struct evdev_dispatch *dispatch, 106 | struct evdev_device *device, 107 | struct input_event *event, 108 | uint32_t time); 109 | 110 | /* Destroy an event dispatch handler and free all its resources. */ 111 | void (*destroy)(struct evdev_dispatch *dispatch); 112 | }; 113 | 114 | struct evdev_dispatch { 115 | struct evdev_dispatch_interface *interface; 116 | }; 117 | 118 | struct evdev_dispatch * 119 | evdev_touchpad_create(struct evdev_device *device); 120 | 121 | void 122 | evdev_led_update(struct evdev_device *device, enum weston_led leds); 123 | 124 | struct evdev_device * 125 | evdev_device_create(struct weston_seat *seat, const char *path, int device_fd); 126 | 127 | void 128 | evdev_device_set_output(struct evdev_device *device, 129 | struct weston_output *output); 130 | void 131 | evdev_device_destroy(struct evdev_device *device); 132 | 133 | void 134 | evdev_notify_keyboard_focus(struct weston_seat *seat, 135 | struct wl_list *evdev_devices); 136 | 137 | #endif /* EVDEV_H */ 138 | -------------------------------------------------------------------------------- /src/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Jonas Ådahl 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _FILTER_H_ 24 | #define _FILTER_H_ 25 | 26 | #include "config.h" 27 | 28 | #include 29 | 30 | #include "compositor.h" 31 | 32 | struct weston_motion_params { 33 | double dx, dy; 34 | }; 35 | 36 | struct weston_motion_filter; 37 | 38 | WL_EXPORT void 39 | weston_filter_dispatch(struct weston_motion_filter *filter, 40 | struct weston_motion_params *motion, 41 | void *data, uint32_t time); 42 | 43 | 44 | struct weston_motion_filter_interface { 45 | void (*filter)(struct weston_motion_filter *filter, 46 | struct weston_motion_params *motion, 47 | void *data, uint32_t time); 48 | void (*destroy)(struct weston_motion_filter *filter); 49 | }; 50 | 51 | struct weston_motion_filter { 52 | struct weston_motion_filter_interface *interface; 53 | }; 54 | 55 | WL_EXPORT struct weston_motion_filter * 56 | create_linear_acceleration_filter(double speed); 57 | 58 | typedef double (*accel_profile_func_t)(struct weston_motion_filter *filter, 59 | void *data, 60 | double velocity, 61 | uint32_t time); 62 | 63 | WL_EXPORT struct weston_motion_filter * 64 | create_pointer_accelator_filter(accel_profile_func_t filter); 65 | 66 | #endif // _FILTER_H_ 67 | -------------------------------------------------------------------------------- /src/gl-renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 John Kåre Alsaker 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include "compositor.h" 26 | 27 | #ifdef ENABLE_EGL 28 | 29 | #include 30 | 31 | #else 32 | 33 | typedef int EGLint; 34 | typedef void *EGLDisplay; 35 | typedef void *EGLSurface; 36 | typedef intptr_t EGLNativeDisplayType; 37 | typedef intptr_t EGLNativeWindowType; 38 | #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) 39 | 40 | #endif 41 | 42 | enum gl_renderer_border_side { 43 | GL_RENDERER_BORDER_TOP = 0, 44 | GL_RENDERER_BORDER_LEFT = 1, 45 | GL_RENDERER_BORDER_RIGHT = 2, 46 | GL_RENDERER_BORDER_BOTTOM = 3, 47 | }; 48 | 49 | struct gl_renderer_interface { 50 | const EGLint *opaque_attribs; 51 | const EGLint *alpha_attribs; 52 | 53 | int (*create)(struct weston_compositor *ec, 54 | EGLNativeDisplayType display, 55 | const EGLint *attribs, 56 | const EGLint *visual_id); 57 | 58 | EGLDisplay (*display)(struct weston_compositor *ec); 59 | 60 | int (*output_create)(struct weston_output *output, 61 | EGLNativeWindowType window); 62 | 63 | void (*output_destroy)(struct weston_output *output); 64 | 65 | EGLSurface (*output_surface)(struct weston_output *output); 66 | 67 | /* Sets the output border. 68 | * 69 | * The side specifies the side for which we are setting the border. 70 | * The width and height are the width and height of the border. 71 | * The tex_width patemeter specifies the width of the actual 72 | * texture; this may be larger than width if the data is not 73 | * tightly packed. 74 | * 75 | * The top and bottom textures will extend over the sides to the 76 | * full width of the bordered window while. The right and left 77 | * edges, however, will extend only to the top and bottom of the 78 | * compositor surface. This is demonstrated by the picture below: 79 | * 80 | * +-----------------------+ 81 | * | TOP | 82 | * +-+-------------------+-+ 83 | * | | | | 84 | * |L| |R| 85 | * |E| |I| 86 | * |F| |G| 87 | * |T| |H| 88 | * | | |T| 89 | * | | | | 90 | * +-+-------------------+-+ 91 | * | BOTTOM | 92 | * +-----------------------+ 93 | */ 94 | void (*output_set_border)(struct weston_output *output, 95 | enum gl_renderer_border_side side, 96 | int32_t width, int32_t height, 97 | int32_t tex_width, unsigned char *data); 98 | 99 | void (*print_egl_error_state)(void); 100 | }; 101 | 102 | struct gl_renderer_interface gl_renderer_interface; 103 | -------------------------------------------------------------------------------- /src/launcher-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Benjamin Franzke 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _WESTON_LAUNCHER_UTIL_H_ 24 | #define _WESTON_LAUNCHER_UTIL_H_ 25 | 26 | #include "config.h" 27 | 28 | #include "compositor.h" 29 | 30 | struct weston_launcher; 31 | 32 | struct weston_launcher * 33 | weston_launcher_connect(struct weston_compositor *compositor, int tty, 34 | const char *seat_id); 35 | 36 | void 37 | weston_launcher_destroy(struct weston_launcher *launcher); 38 | 39 | int 40 | weston_launcher_open(struct weston_launcher *launcher, 41 | const char *path, int flags); 42 | 43 | void 44 | weston_launcher_close(struct weston_launcher *launcher, int fd); 45 | 46 | int 47 | weston_launcher_activate_vt(struct weston_launcher *launcher, int vt); 48 | 49 | void 50 | weston_launcher_restore(struct weston_launcher *launcher); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/libbacklight.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBBACKLIGHT_H 2 | #define LIBBACKLIGHT_H 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | enum backlight_type { 11 | BACKLIGHT_RAW, 12 | BACKLIGHT_PLATFORM, 13 | BACKLIGHT_FIRMWARE 14 | }; 15 | 16 | struct backlight { 17 | char *path; 18 | int max_brightness; 19 | int brightness; 20 | enum backlight_type type; 21 | }; 22 | 23 | /* 24 | * Find and set up a backlight for a valid udev connector device, i.e. one 25 | * matching drm subsytem and with status of connected. 26 | */ 27 | struct backlight *backlight_init(struct udev_device *drm_device, 28 | uint32_t connector_type); 29 | 30 | /* Free backlight resources */ 31 | void backlight_destroy(struct backlight *backlight); 32 | 33 | /* Provide the maximum backlight value */ 34 | long backlight_get_max_brightness(struct backlight *backlight); 35 | 36 | /* Provide the cached backlight value */ 37 | long backlight_get_brightness(struct backlight *backlight); 38 | 39 | /* Provide the hardware backlight value */ 40 | long backlight_get_actual_brightness(struct backlight *backlight); 41 | 42 | /* Set the backlight to a value between 0 and max */ 43 | long backlight_set_brightness(struct backlight *backlight, long brightness); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* LIBBACKLIGHT_H */ 50 | -------------------------------------------------------------------------------- /src/log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Martin Minarik 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | #include "compositor.h" 35 | 36 | static FILE *weston_logfile = NULL; 37 | 38 | static int cached_tm_mday = -1; 39 | 40 | static int weston_log_timestamp(void) 41 | { 42 | struct timeval tv; 43 | struct tm *brokendown_time; 44 | char string[128]; 45 | 46 | gettimeofday(&tv, NULL); 47 | 48 | brokendown_time = localtime(&tv.tv_sec); 49 | if (brokendown_time == NULL) 50 | return fprintf(weston_logfile, "[(NULL)localtime] "); 51 | 52 | if (brokendown_time->tm_mday != cached_tm_mday) { 53 | strftime(string, sizeof string, "%Y-%m-%d %Z", brokendown_time); 54 | fprintf(weston_logfile, "Date: %s\n", string); 55 | 56 | cached_tm_mday = brokendown_time->tm_mday; 57 | } 58 | 59 | strftime(string, sizeof string, "%H:%M:%S", brokendown_time); 60 | 61 | return fprintf(weston_logfile, "[%s.%03li] ", string, tv.tv_usec/1000); 62 | } 63 | 64 | static void 65 | custom_handler(const char *fmt, va_list arg) 66 | { 67 | weston_log_timestamp(); 68 | fprintf(weston_logfile, "libwayland: "); 69 | vfprintf(weston_logfile, fmt, arg); 70 | } 71 | 72 | void 73 | weston_log_file_open(const char *filename) 74 | { 75 | wl_log_set_handler_server(custom_handler); 76 | 77 | if (filename != NULL) 78 | weston_logfile = fopen(filename, "a"); 79 | 80 | if (weston_logfile == NULL) 81 | weston_logfile = stderr; 82 | else 83 | setvbuf(weston_logfile, NULL, _IOLBF, 256); 84 | } 85 | 86 | void 87 | weston_log_file_close() 88 | { 89 | if ((weston_logfile != stderr) && (weston_logfile != NULL)) 90 | fclose(weston_logfile); 91 | weston_logfile = stderr; 92 | } 93 | 94 | WL_EXPORT int 95 | weston_vlog(const char *fmt, va_list ap) 96 | { 97 | int l; 98 | 99 | l = weston_log_timestamp(); 100 | l += vfprintf(weston_logfile, fmt, ap); 101 | 102 | return l; 103 | } 104 | 105 | WL_EXPORT int 106 | weston_log(const char *fmt, ...) 107 | { 108 | int l; 109 | va_list argp; 110 | 111 | va_start(argp, fmt); 112 | l = weston_vlog(fmt, argp); 113 | va_end(argp); 114 | 115 | return l; 116 | } 117 | 118 | WL_EXPORT int 119 | weston_vlog_continue(const char *fmt, va_list argp) 120 | { 121 | return vfprintf(weston_logfile, fmt, argp); 122 | } 123 | 124 | WL_EXPORT int 125 | weston_log_continue(const char *fmt, ...) 126 | { 127 | int l; 128 | va_list argp; 129 | 130 | va_start(argp, fmt); 131 | l = weston_vlog_continue(fmt, argp); 132 | va_end(argp); 133 | 134 | return l; 135 | } 136 | -------------------------------------------------------------------------------- /src/logind-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 David Herrmann 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "compositor.h" 31 | 32 | struct weston_logind; 33 | 34 | #if defined(HAVE_SYSTEMD_LOGIN) && defined(HAVE_DBUS) 35 | 36 | #include 37 | 38 | int 39 | weston_logind_open(struct weston_logind *wl, const char *path, 40 | int flags); 41 | 42 | void 43 | weston_logind_close(struct weston_logind *wl, int fd); 44 | 45 | void 46 | weston_logind_restore(struct weston_logind *wl); 47 | 48 | int 49 | weston_logind_activate_vt(struct weston_logind *wl, int vt); 50 | 51 | int 52 | weston_logind_connect(struct weston_logind **out, 53 | struct weston_compositor *compositor, 54 | const char *seat_id, int tty); 55 | 56 | void 57 | weston_logind_destroy(struct weston_logind *wl); 58 | 59 | static inline int 60 | weston_sd_session_get_vt(const char *sid, unsigned int *out) 61 | { 62 | #ifdef HAVE_SYSTEMD_LOGIN_209 63 | return sd_session_get_vt(sid, out); 64 | #else 65 | int r; 66 | char *tty; 67 | 68 | r = sd_session_get_tty(sid, &tty); 69 | if (r < 0) 70 | return r; 71 | 72 | r = sscanf(tty, "tty%u", out); 73 | free(tty); 74 | 75 | if (r != 1) 76 | return -EINVAL; 77 | 78 | return 0; 79 | #endif 80 | } 81 | 82 | #else /* defined(HAVE_SYSTEMD_LOGIN) && defined(HAVE_DBUS) */ 83 | 84 | static inline int 85 | weston_logind_open(struct weston_logind *wl, const char *path, 86 | int flags) 87 | { 88 | return -ENOSYS; 89 | } 90 | 91 | static inline void 92 | weston_logind_close(struct weston_logind *wl, int fd) 93 | { 94 | } 95 | 96 | static inline void 97 | weston_logind_restore(struct weston_logind *wl) 98 | { 99 | } 100 | 101 | static inline int 102 | weston_logind_activate_vt(struct weston_logind *wl, int vt) 103 | { 104 | return -ENOSYS; 105 | } 106 | 107 | static inline int 108 | weston_logind_connect(struct weston_logind **out, 109 | struct weston_compositor *compositor, 110 | const char *seat_id, int tty) 111 | { 112 | return -ENOSYS; 113 | } 114 | 115 | static inline void 116 | weston_logind_destroy(struct weston_logind *wl) 117 | { 118 | } 119 | 120 | #endif /* defined(HAVE_SYSTEMD_LOGIN) && defined(HAVE_DBUS) */ 121 | -------------------------------------------------------------------------------- /src/noop-renderer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | 27 | #include "compositor.h" 28 | 29 | static int 30 | noop_renderer_read_pixels(struct weston_output *output, 31 | pixman_format_code_t format, void *pixels, 32 | uint32_t x, uint32_t y, 33 | uint32_t width, uint32_t height) 34 | { 35 | return 0; 36 | } 37 | 38 | static void 39 | noop_renderer_repaint_output(struct weston_output *output, 40 | pixman_region32_t *output_damage) 41 | { 42 | } 43 | 44 | static void 45 | noop_renderer_flush_damage(struct weston_surface *surface) 46 | { 47 | } 48 | 49 | static void 50 | noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer) 51 | { 52 | } 53 | 54 | static void 55 | noop_renderer_surface_set_color(struct weston_surface *surface, 56 | float red, float green, float blue, float alpha) 57 | { 58 | } 59 | 60 | static void 61 | noop_renderer_destroy(struct weston_compositor *ec) 62 | { 63 | free(ec->renderer); 64 | ec->renderer = NULL; 65 | } 66 | 67 | WL_EXPORT int 68 | noop_renderer_init(struct weston_compositor *ec) 69 | { 70 | struct weston_renderer *renderer; 71 | 72 | renderer = malloc(sizeof *renderer); 73 | if (renderer == NULL) 74 | return -1; 75 | 76 | renderer->read_pixels = noop_renderer_read_pixels; 77 | renderer->repaint_output = noop_renderer_repaint_output; 78 | renderer->flush_damage = noop_renderer_flush_damage; 79 | renderer->attach = noop_renderer_attach; 80 | renderer->surface_set_color = noop_renderer_surface_set_color; 81 | renderer->destroy = noop_renderer_destroy; 82 | ec->renderer = renderer; 83 | 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /src/pixman-renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Vasily Khoruzhick 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include "compositor.h" 26 | 27 | int 28 | pixman_renderer_init(struct weston_compositor *ec); 29 | 30 | int 31 | pixman_renderer_output_create(struct weston_output *output); 32 | 33 | void 34 | pixman_renderer_output_set_buffer(struct weston_output *output, pixman_image_t *buffer); 35 | 36 | void 37 | pixman_renderer_output_destroy(struct weston_output *output); 38 | -------------------------------------------------------------------------------- /src/rpi-renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Raspberry Pi Foundation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef RPI_RENDERER_H 24 | #define RPI_RENDERER_H 25 | 26 | struct rpi_renderer_parameters { 27 | int single_buffer; 28 | int opaque_regions; 29 | }; 30 | 31 | int 32 | rpi_renderer_create(struct weston_compositor *compositor, 33 | const struct rpi_renderer_parameters *params); 34 | 35 | int 36 | rpi_renderer_output_create(struct weston_output *base, 37 | DISPMANX_DISPLAY_HANDLE_T display); 38 | 39 | void 40 | rpi_renderer_output_destroy(struct weston_output *base); 41 | 42 | void 43 | rpi_renderer_set_update_handle(struct weston_output *base, 44 | DISPMANX_UPDATE_HANDLE_T handle); 45 | 46 | void 47 | rpi_renderer_finish_frame(struct weston_output *base); 48 | 49 | #endif /* RPI_RENDERER_H */ 50 | -------------------------------------------------------------------------------- /src/spring-tool.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include "compositor.h" 26 | 27 | WL_EXPORT void 28 | weston_view_geometry_dirty(struct weston_view *view) 29 | { 30 | } 31 | 32 | WL_EXPORT int 33 | weston_log(const char *fmt, ...) 34 | { 35 | return 0; 36 | } 37 | 38 | WL_EXPORT void 39 | weston_view_schedule_repaint(struct weston_view *view) 40 | { 41 | } 42 | 43 | WL_EXPORT void 44 | weston_compositor_schedule_repaint(struct weston_compositor *compositor) 45 | { 46 | } 47 | 48 | int 49 | main(int argc, char *argv[]) 50 | { 51 | const double k = 300.0; 52 | const double current = 0.5; 53 | const double target = 1.0; 54 | const double friction = 1400; 55 | 56 | struct weston_spring spring; 57 | uint32_t time = 0; 58 | 59 | weston_spring_init(&spring, k, current, target); 60 | spring.friction = friction; 61 | spring.previous = 0.48; 62 | spring.timestamp = 0; 63 | 64 | while (!weston_spring_done(&spring)) { 65 | printf("\t%d\t%f\n", time, spring.current); 66 | weston_spring_update(&spring, time); 67 | time += 16; 68 | } 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /src/udev-seat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _UDEV_SEAT_H_ 24 | #define _UDEV_SEAT_H_ 25 | 26 | #include "config.h" 27 | 28 | #include 29 | 30 | #include "compositor.h" 31 | 32 | struct udev_seat { 33 | struct weston_seat base; 34 | struct wl_list devices_list; 35 | struct wl_listener output_create_listener; 36 | }; 37 | 38 | struct udev_input { 39 | struct udev_monitor *udev_monitor; 40 | struct wl_event_source *udev_monitor_source; 41 | char *seat_id; 42 | struct weston_compositor *compositor; 43 | int enabled; 44 | }; 45 | 46 | int udev_input_enable(struct udev_input *input, struct udev *udev); 47 | void udev_input_disable(struct udev_input *input); 48 | int udev_input_init(struct udev_input *input, 49 | struct weston_compositor *c, 50 | struct udev *udev, 51 | const char *seat_id); 52 | void udev_input_destroy(struct udev_input *input); 53 | 54 | struct udev_seat *udev_seat_get_named(struct weston_compositor *c, 55 | const char *seat_name); 56 | #endif 57 | -------------------------------------------------------------------------------- /src/vaapi-recorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _VAAPI_RECORDER_H_ 24 | #define _VAAPI_RECORDER_H_ 25 | 26 | struct vaapi_recorder; 27 | 28 | struct vaapi_recorder * 29 | vaapi_recorder_create(int drm_fd, int width, int height, const char *filename); 30 | void 31 | vaapi_recorder_destroy(struct vaapi_recorder *r); 32 | void 33 | vaapi_recorder_frame(struct vaapi_recorder *r, int fd, int stride); 34 | 35 | #endif /* _VAAPI_RECORDER_H_ */ 36 | -------------------------------------------------------------------------------- /src/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef WESTON_VERSION_H 24 | #define WESTON_VERSION_H 25 | 26 | #define WESTON_VERSION_MAJOR @WESTON_VERSION_MAJOR@ 27 | #define WESTON_VERSION_MINOR @WESTON_VERSION_MINOR@ 28 | #define WESTON_VERSION_MICRO @WESTON_VERSION_MICRO@ 29 | #define WESTON_VERSION "@WESTON_VERSION@" 30 | 31 | /* This macro may not do what you expect. Weston doesn't guarantee 32 | * any stable API between 1.X and 1.Y, and thus this macro will return 33 | * FALSE on any WESTON_VERSION_AT_LEAST(1,X,0) if the actualy version 34 | * is 1.Y.0 and X !=Y). In particular, it fail if X < Y, that is, 35 | * 1.3.0 is considered to not be "at least" 1.4.0. 36 | * 37 | * If you want to test for the version number being 1.3.0 or above or 38 | * maybe in a range (eg 1.2.0 to 1.4.0), just use the WESTON_VERSION_* 39 | * defines above directly. 40 | */ 41 | 42 | #define WESTON_VERSION_AT_LEAST(major, minor, micro) \ 43 | (WESTON_VERSION_MAJOR == (major) && \ 44 | WESTON_VERSION_MINOR == (minor) && \ 45 | WESTON_VERSION_MICRO >= (micro)) 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/vertex-clipping.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | #ifndef _WESTON_VERTEX_CLIPPING_H 23 | #define _WESTON_VERTEX_CLIPPING_H 24 | 25 | struct polygon8 { 26 | float x[8]; 27 | float y[8]; 28 | int n; 29 | }; 30 | 31 | struct clip_context { 32 | struct { 33 | float x; 34 | float y; 35 | } prev; 36 | 37 | struct { 38 | float x1, y1; 39 | float x2, y2; 40 | } clip; 41 | 42 | struct { 43 | float *x; 44 | float *y; 45 | } vertices; 46 | }; 47 | 48 | float 49 | float_difference(float a, float b); 50 | 51 | int 52 | clip_simple(struct clip_context *ctx, 53 | struct polygon8 *surf, 54 | float *ex, 55 | float *ey); 56 | 57 | int 58 | clip_transformed(struct clip_context *ctx, 59 | struct polygon8 *surf, 60 | float *ex, 61 | float *ey);\ 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/weston-egl-ext.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * 3 | * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. 4 | * All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sub license, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice (including the 15 | * next paragraph) shall be included in all copies or substantial portions 16 | * of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | * DEALINGS IN THE SOFTWARE. 25 | * 26 | **************************************************************************/ 27 | 28 | /* Extensions used by Weston, copied from Mesa's eglmesaext.h, */ 29 | 30 | #ifndef WESTON_EGL_EXT_H 31 | #define WESTON_EGL_EXT_H 32 | 33 | #ifndef EGL_WL_bind_wayland_display 34 | #define EGL_WL_bind_wayland_display 1 35 | 36 | #define EGL_WAYLAND_BUFFER_WL 0x31D5 /* eglCreateImageKHR target */ 37 | #define EGL_WAYLAND_PLANE_WL 0x31D6 /* eglCreateImageKHR target */ 38 | 39 | #define EGL_TEXTURE_Y_U_V_WL 0x31D7 40 | #define EGL_TEXTURE_Y_UV_WL 0x31D8 41 | #define EGL_TEXTURE_Y_XUXV_WL 0x31D9 42 | #define EGL_TEXTURE_EXTERNAL_WL 0x31DA 43 | 44 | struct wl_display; 45 | struct wl_resource; 46 | #ifdef EGL_EGLEXT_PROTOTYPES 47 | EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display); 48 | EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display); 49 | EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); 50 | #endif 51 | typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); 52 | typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); 53 | typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); 54 | 55 | #endif 56 | 57 | #ifndef EGL_TEXTURE_EXTERNAL_WL 58 | #define EGL_TEXTURE_EXTERNAL_WL 0x31DA 59 | #endif 60 | 61 | #ifndef EGL_BUFFER_AGE_EXT 62 | #define EGL_BUFFER_AGE_EXT 0x313D 63 | #endif 64 | 65 | #ifndef EGL_WAYLAND_Y_INVERTED_WL 66 | #define EGL_WAYLAND_Y_INVERTED_WL 0x31DB /* eglQueryWaylandBufferWL attribute */ 67 | #endif 68 | 69 | /* Mesas gl2ext.h and probably Khronos upstream defined 70 | * GL_EXT_unpack_subimage with non _EXT suffixed GL_UNPACK_* tokens. 71 | * In case we're using that mess, manually define the _EXT versions 72 | * of the tokens here.*/ 73 | #if defined(GL_EXT_unpack_subimage) && !defined(GL_UNPACK_ROW_LENGTH_EXT) 74 | #define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 75 | #define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 76 | #define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 77 | #endif 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/weston-launch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Benjamin Franzke 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _WESTON_LAUNCH_H_ 24 | #define _WESTON_LAUNCH_H_ 25 | 26 | enum weston_launcher_opcode { 27 | WESTON_LAUNCHER_OPEN, 28 | }; 29 | 30 | enum weston_launcher_event { 31 | WESTON_LAUNCHER_SUCCESS, 32 | WESTON_LAUNCHER_ACTIVATE, 33 | WESTON_LAUNCHER_DEACTIVATE 34 | }; 35 | 36 | struct weston_launcher_message { 37 | int opcode; 38 | }; 39 | 40 | struct weston_launcher_open { 41 | struct weston_launcher_message header; 42 | int flags; 43 | char path[0]; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/weston.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | libexecdir=@libexecdir@ 6 | pkglibexecdir=${libexecdir}/@PACKAGE@ 7 | 8 | Name: Weston Plugin API 9 | Description: Header files for Weston plugin development 10 | Version: @WESTON_VERSION@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.test 3 | *.trs 4 | *.weston 5 | logs 6 | matrix-test 7 | setbacklight 8 | test-client 9 | test-text-client 10 | -------------------------------------------------------------------------------- /tests/bad-buffer-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * Copyright © 2013 Collabora, Ltd. 4 | * 5 | * Permission to use, copy, modify, distribute, and sell this software and 6 | * its documentation for any purpose is hereby granted without fee, provided 7 | * that the above copyright notice appear in all copies and that both that 8 | * copyright notice and this permission notice appear in supporting 9 | * documentation, and that the name of the copyright holders not be used in 10 | * advertising or publicity pertaining to distribution of the software 11 | * without specific, written prior permission. The copyright holders make 12 | * no representations about the suitability of this software for any 13 | * purpose. It is provided "as is" without express or implied warranty. 14 | * 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #include "../shared/os-compatibility.h" 28 | #include "weston-test-client-helper.h" 29 | 30 | /* tests, that attempt to crash the compositor on purpose */ 31 | 32 | static struct wl_buffer * 33 | create_bad_shm_buffer(struct client *client, int width, int height) 34 | { 35 | struct wl_shm *shm = client->wl_shm; 36 | int stride = width * 4; 37 | int size = stride * height; 38 | struct wl_shm_pool *pool; 39 | struct wl_buffer *buffer; 40 | int fd; 41 | 42 | fd = os_create_anonymous_file(size); 43 | assert(fd >= 0); 44 | 45 | pool = wl_shm_create_pool(shm, fd, size); 46 | buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, 47 | WL_SHM_FORMAT_ARGB8888); 48 | wl_shm_pool_destroy(pool); 49 | 50 | /* Truncate the file to a small size, so that the compositor 51 | * will access it out-of-bounds, and hit SIGBUS. 52 | */ 53 | assert(ftruncate(fd, 12) == 0); 54 | close(fd); 55 | 56 | return buffer; 57 | } 58 | 59 | FAIL_TEST(test_truncated_shm_file) 60 | { 61 | struct client *client; 62 | struct wl_buffer *bad_buffer; 63 | struct wl_surface *surface; 64 | int frame; 65 | 66 | client = client_create(46, 76, 111, 134); 67 | assert(client); 68 | surface = client->surface->wl_surface; 69 | 70 | bad_buffer = create_bad_shm_buffer(client, 200, 200); 71 | 72 | wl_surface_attach(surface, bad_buffer, 0, 0); 73 | wl_surface_damage(surface, 0, 0, 200, 200); 74 | frame_callback_set(surface, &frame); 75 | wl_surface_commit(surface); 76 | frame_callback_wait(client, &frame); 77 | } 78 | -------------------------------------------------------------------------------- /tests/buffer-count-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "weston-test-client-helper.h" 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | struct test_data { 35 | struct client *client; 36 | 37 | EGLDisplay egl_dpy; 38 | EGLContext egl_ctx; 39 | EGLConfig egl_conf; 40 | EGLSurface egl_surface; 41 | }; 42 | 43 | static void 44 | init_egl(struct test_data *test_data) 45 | { 46 | struct wl_egl_window *native_window; 47 | struct surface *surface = test_data->client->surface; 48 | const char *str, *mesa; 49 | 50 | static const EGLint context_attribs[] = { 51 | EGL_CONTEXT_CLIENT_VERSION, 2, 52 | EGL_NONE 53 | }; 54 | 55 | EGLint config_attribs[] = { 56 | EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 57 | EGL_RED_SIZE, 1, 58 | EGL_GREEN_SIZE, 1, 59 | EGL_BLUE_SIZE, 1, 60 | EGL_ALPHA_SIZE, 0, 61 | EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 62 | EGL_NONE 63 | }; 64 | 65 | EGLint major, minor, n; 66 | EGLBoolean ret; 67 | 68 | test_data->egl_dpy = eglGetDisplay((EGLNativeDisplayType) 69 | test_data->client->wl_display); 70 | assert(test_data->egl_dpy); 71 | 72 | ret = eglInitialize(test_data->egl_dpy, &major, &minor); 73 | assert(ret == EGL_TRUE); 74 | ret = eglBindAPI(EGL_OPENGL_ES_API); 75 | assert(ret == EGL_TRUE); 76 | 77 | ret = eglChooseConfig(test_data->egl_dpy, config_attribs, 78 | &test_data->egl_conf, 1, &n); 79 | assert(ret && n == 1); 80 | 81 | test_data->egl_ctx = eglCreateContext(test_data->egl_dpy, 82 | test_data->egl_conf, 83 | EGL_NO_CONTEXT, context_attribs); 84 | assert(test_data->egl_ctx); 85 | 86 | native_window = 87 | wl_egl_window_create(surface->wl_surface, 88 | surface->width, 89 | surface->height); 90 | test_data->egl_surface = 91 | eglCreateWindowSurface(test_data->egl_dpy, 92 | test_data->egl_conf, 93 | (EGLNativeWindowType) native_window, 94 | NULL); 95 | 96 | ret = eglMakeCurrent(test_data->egl_dpy, test_data->egl_surface, 97 | test_data->egl_surface, test_data->egl_ctx); 98 | assert(ret == EGL_TRUE); 99 | 100 | /* This test is specific to mesa 10.1 and later, which is the 101 | * first release that doesn't accidentally triple-buffer. */ 102 | str = (const char *) glGetString(GL_VERSION); 103 | mesa = strstr(str, "Mesa "); 104 | if (mesa == NULL) 105 | skip("unknown EGL implementation (%s)\n", str); 106 | if (sscanf(mesa + 5, "%d.%d", &major, &minor) != 2) 107 | skip("unrecognized mesa version (%s)\n", str); 108 | if (major < 10 || (major == 10 && minor < 1)) 109 | skip("mesa version too old (%s)\n", str); 110 | 111 | } 112 | 113 | TEST(test_buffer_count) 114 | { 115 | struct test_data test_data; 116 | uint32_t buffer_count; 117 | int i; 118 | 119 | test_data.client = client_create(10, 10, 10, 10); 120 | init_egl(&test_data); 121 | 122 | /* This is meant to represent a typical game loop which is 123 | * expecting eglSwapBuffers to block and throttle the 124 | * rendering to a sensible frame rate. Therefore it doesn't 125 | * expect to have to install a frame callback itself. I'd 126 | * imagine this is what a typical SDL game would end up 127 | * doing */ 128 | 129 | for (i = 0; i < 10; i++) { 130 | glClear(GL_COLOR_BUFFER_BIT); 131 | eglSwapBuffers(test_data.egl_dpy, test_data.egl_surface); 132 | } 133 | 134 | buffer_count = get_n_egl_buffers(test_data.client); 135 | 136 | printf("buffers used = %i\n", buffer_count); 137 | 138 | /* The implementation should only end up creating two buffers 139 | * and cycling between them */ 140 | assert(buffer_count == 2); 141 | } 142 | -------------------------------------------------------------------------------- /tests/button-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include "weston-test-client-helper.h" 25 | 26 | TEST(simple_button_test) 27 | { 28 | struct client *client; 29 | struct pointer *pointer; 30 | 31 | client = client_create(100, 100, 100, 100); 32 | assert(client); 33 | 34 | pointer = client->input->pointer; 35 | 36 | assert(pointer->button == 0); 37 | assert(pointer->state == 0); 38 | 39 | wl_test_move_pointer(client->test->wl_test, 150, 150); 40 | client_roundtrip(client); 41 | assert(pointer->x == 50); 42 | assert(pointer->y == 50); 43 | 44 | wl_test_send_button(client->test->wl_test, BTN_LEFT, 45 | WL_POINTER_BUTTON_STATE_PRESSED); 46 | client_roundtrip(client); 47 | assert(pointer->button == BTN_LEFT); 48 | assert(pointer->state == WL_POINTER_BUTTON_STATE_PRESSED); 49 | 50 | wl_test_send_button(client->test->wl_test, BTN_LEFT, 51 | WL_POINTER_BUTTON_STATE_RELEASED); 52 | client_roundtrip(client); 53 | assert(pointer->button == BTN_LEFT); 54 | assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED); 55 | } 56 | -------------------------------------------------------------------------------- /tests/config-parser-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "config-parser.h" 31 | 32 | static struct weston_config * 33 | run_test(const char *text) 34 | { 35 | struct weston_config *config; 36 | char file[] = "/tmp/weston-config-parser-test-XXXXXX"; 37 | int fd, len; 38 | 39 | fd = mkstemp(file); 40 | len = write(fd, text, strlen(text)); 41 | assert(len == (int) strlen(text)); 42 | 43 | config = weston_config_parse(file); 44 | close(fd); 45 | unlink(file); 46 | 47 | return config; 48 | } 49 | 50 | static const char t0[] = 51 | "# nothing in this file...\n"; 52 | 53 | static const char t1[] = 54 | "# comment line here...\n" 55 | "\n" 56 | "[foo]\n" 57 | "a=b\n" 58 | "name= Roy Batty \n" 59 | "\n" 60 | "\n" 61 | "[bar]\n" 62 | "# more comments\n" 63 | "number=5252\n" 64 | "flag=false\n" 65 | "\n" 66 | "[stuff]\n" 67 | "flag= true \n" 68 | "\n" 69 | "[bucket]\n" 70 | "color=blue \n" 71 | "contents=live crabs\n" 72 | "pinchy=true\n" 73 | "\n" 74 | "[bucket]\n" 75 | "material=plastic \n" 76 | "color=red\n" 77 | "contents=sand\n"; 78 | 79 | static const char *section_names[] = { 80 | "foo", "bar", "stuff", "bucket", "bucket" 81 | }; 82 | 83 | static const char t2[] = 84 | "# invalid section...\n" 85 | "[this bracket isn't closed\n"; 86 | 87 | static const char t3[] = 88 | "# line without = ...\n" 89 | "[bambam]\n" 90 | "this line isn't any kind of valid\n"; 91 | 92 | static const char t4[] = 93 | "# starting with = ...\n" 94 | "[bambam]\n" 95 | "=not valid at all\n"; 96 | 97 | int main(int argc, char *argv[]) 98 | { 99 | struct weston_config *config; 100 | struct weston_config_section *section; 101 | const char *name; 102 | char *s; 103 | int r, b, i; 104 | int32_t n; 105 | uint32_t u; 106 | 107 | config = run_test(t0); 108 | assert(config); 109 | weston_config_destroy(config); 110 | 111 | config = run_test(t1); 112 | assert(config); 113 | section = weston_config_get_section(config, "mollusc", NULL, NULL); 114 | assert(section == NULL); 115 | 116 | section = weston_config_get_section(config, "foo", NULL, NULL); 117 | r = weston_config_section_get_string(section, "a", &s, NULL); 118 | assert(r == 0 && strcmp(s, "b") == 0); 119 | free(s); 120 | 121 | section = weston_config_get_section(config, "foo", NULL, NULL); 122 | r = weston_config_section_get_string(section, "b", &s, NULL); 123 | assert(r == -1 && errno == ENOENT && s == NULL); 124 | 125 | section = weston_config_get_section(config, "foo", NULL, NULL); 126 | r = weston_config_section_get_string(section, "name", &s, NULL); 127 | assert(r == 0 && strcmp(s, "Roy Batty") == 0); 128 | free(s); 129 | 130 | section = weston_config_get_section(config, "bar", NULL, NULL); 131 | r = weston_config_section_get_string(section, "a", &s, "boo"); 132 | assert(r == -1 && errno == ENOENT && strcmp(s, "boo") == 0); 133 | free(s); 134 | 135 | section = weston_config_get_section(config, "bar", NULL, NULL); 136 | r = weston_config_section_get_int(section, "number", &n, 600); 137 | assert(r == 0 && n == 5252); 138 | 139 | section = weston_config_get_section(config, "bar", NULL, NULL); 140 | r = weston_config_section_get_int(section, "+++", &n, 700); 141 | assert(r == -1 && errno == ENOENT && n == 700); 142 | 143 | section = weston_config_get_section(config, "bar", NULL, NULL); 144 | r = weston_config_section_get_uint(section, "number", &u, 600); 145 | assert(r == 0 && u == 5252); 146 | 147 | section = weston_config_get_section(config, "bar", NULL, NULL); 148 | r = weston_config_section_get_uint(section, "+++", &u, 600); 149 | assert(r == -1 && errno == ENOENT && u == 600); 150 | 151 | section = weston_config_get_section(config, "bar", NULL, NULL); 152 | r = weston_config_section_get_bool(section, "flag", &b, 600); 153 | assert(r == 0 && b == 0); 154 | 155 | section = weston_config_get_section(config, "stuff", NULL, NULL); 156 | r = weston_config_section_get_bool(section, "flag", &b, -1); 157 | assert(r == 0 && b == 1); 158 | 159 | section = weston_config_get_section(config, "stuff", NULL, NULL); 160 | r = weston_config_section_get_bool(section, "bonk", &b, -1); 161 | assert(r == -1 && errno == ENOENT && b == -1); 162 | 163 | section = weston_config_get_section(config, "bucket", "color", "blue"); 164 | r = weston_config_section_get_string(section, "contents", &s, NULL); 165 | assert(r == 0 && strcmp(s, "live crabs") == 0); 166 | free(s); 167 | 168 | section = weston_config_get_section(config, "bucket", "color", "red"); 169 | r = weston_config_section_get_string(section, "contents", &s, NULL); 170 | assert(r == 0 && strcmp(s, "sand") == 0); 171 | free(s); 172 | 173 | section = weston_config_get_section(config, "bucket", "color", "pink"); 174 | assert(section == NULL); 175 | r = weston_config_section_get_string(section, "contents", &s, "eels"); 176 | assert(r == -1 && errno == ENOENT && strcmp(s, "eels") == 0); 177 | free(s); 178 | 179 | section = NULL; 180 | i = 0; 181 | while (weston_config_next_section(config, §ion, &name)) 182 | assert(strcmp(section_names[i++], name) == 0); 183 | assert(i == 5); 184 | 185 | weston_config_destroy(config); 186 | 187 | config = run_test(t2); 188 | assert(config == NULL); 189 | 190 | config = run_test(t3); 191 | assert(config == NULL); 192 | 193 | config = run_test(t4); 194 | assert(config == NULL); 195 | 196 | weston_config_destroy(NULL); 197 | assert(weston_config_next_section(NULL, NULL, NULL) == 0); 198 | 199 | section = weston_config_get_section(NULL, "bucket", NULL, NULL); 200 | assert(section == NULL); 201 | 202 | return 0; 203 | } 204 | -------------------------------------------------------------------------------- /tests/keyboard-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "weston-test-client-helper.h" 24 | 25 | TEST(simple_keyboard_test) 26 | { 27 | struct client *client; 28 | struct surface *expect_focus = NULL; 29 | struct keyboard *keyboard; 30 | uint32_t expect_key = 0; 31 | uint32_t expect_state = 0; 32 | 33 | client = client_create(10, 10, 1, 1); 34 | assert(client); 35 | 36 | keyboard = client->input->keyboard; 37 | 38 | while(1) { 39 | assert(keyboard->key == expect_key); 40 | assert(keyboard->state == expect_state); 41 | assert(keyboard->focus == expect_focus); 42 | 43 | if (keyboard->state == WL_KEYBOARD_KEY_STATE_PRESSED) { 44 | expect_state = WL_KEYBOARD_KEY_STATE_RELEASED; 45 | wl_test_send_key(client->test->wl_test, expect_key, 46 | expect_state); 47 | } else if (keyboard->focus) { 48 | expect_focus = NULL; 49 | wl_test_activate_surface(client->test->wl_test, 50 | NULL); 51 | } else if (expect_key < 10) { 52 | expect_key++; 53 | expect_focus = client->surface; 54 | expect_state = WL_KEYBOARD_KEY_STATE_PRESSED; 55 | wl_test_activate_surface(client->test->wl_test, 56 | expect_focus->wl_surface); 57 | wl_test_send_key(client->test->wl_test, expect_key, 58 | expect_state); 59 | } else { 60 | break; 61 | } 62 | 63 | client_roundtrip(client); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tests/setbacklight.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | * 22 | * Author: Tiago Vignatti 23 | */ 24 | /* 25 | * \file setbacklight.c 26 | * Test program to get a backlight connector and set its brightness value. 27 | * Queries for the connectors id can be performed using drm/tests/modeprint 28 | * program. 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "libbacklight.h" 39 | 40 | static uint32_t 41 | get_drm_connector_type(struct udev_device *drm_device, uint32_t connector_id) 42 | { 43 | const char *filename; 44 | int fd, i, connector_type; 45 | drmModeResPtr res; 46 | drmModeConnectorPtr connector; 47 | 48 | filename = udev_device_get_devnode(drm_device); 49 | fd = open(filename, O_RDWR | O_CLOEXEC); 50 | if (fd < 0) { 51 | printf("couldn't open drm_device\n"); 52 | return -1; 53 | } 54 | 55 | res = drmModeGetResources(fd); 56 | if (res == 0) { 57 | printf("Failed to get resources from card\n"); 58 | close(fd); 59 | return -1; 60 | } 61 | 62 | for (i = 0; i < res->count_connectors; i++) { 63 | connector = drmModeGetConnector(fd, res->connectors[i]); 64 | if (!connector) 65 | continue; 66 | 67 | if ((connector->connection == DRM_MODE_DISCONNECTED) || 68 | (connector->connector_id != connector_id)) { 69 | drmModeFreeConnector(connector); 70 | continue; 71 | } 72 | 73 | connector_type = connector->connector_type; 74 | drmModeFreeConnector(connector); 75 | drmModeFreeResources(res); 76 | 77 | close(fd); 78 | return connector_type; 79 | } 80 | 81 | close(fd); 82 | drmModeFreeResources(res); 83 | return -1; 84 | } 85 | 86 | /* returns a value between 0-255 range, where higher is brighter */ 87 | static uint32_t 88 | get_normalized_backlight(struct backlight *backlight) 89 | { 90 | long brightness, max_brightness; 91 | long norm; 92 | 93 | brightness = backlight_get_brightness(backlight); 94 | max_brightness = backlight_get_max_brightness(backlight); 95 | 96 | /* convert it to a scale of 0 to 255 */ 97 | norm = (brightness * 255)/(max_brightness); 98 | 99 | return (int) norm; 100 | } 101 | 102 | static void 103 | set_backlight(struct udev_device *drm_device, int connector_id, int blight) 104 | { 105 | int connector_type; 106 | long max_brightness, brightness, actual_brightness; 107 | struct backlight *backlight; 108 | long new_blight; 109 | 110 | connector_type = get_drm_connector_type(drm_device, connector_id); 111 | if (connector_type < 0) 112 | return; 113 | 114 | backlight = backlight_init(drm_device, connector_type); 115 | if (!backlight) { 116 | printf("backlight adjust failed\n"); 117 | return; 118 | } 119 | 120 | max_brightness = backlight_get_max_brightness(backlight); 121 | printf("Max backlight: %ld\n", max_brightness); 122 | 123 | brightness = backlight_get_brightness(backlight); 124 | printf("Cached backlight: %ld\n", brightness); 125 | 126 | actual_brightness = backlight_get_actual_brightness(backlight); 127 | printf("Hardware backlight: %ld\n", actual_brightness); 128 | 129 | printf("normalized current brightness: %d\n", 130 | get_normalized_backlight(backlight)); 131 | 132 | /* denormalized value */ 133 | new_blight = (blight * max_brightness) / 255; 134 | 135 | backlight_set_brightness(backlight, new_blight); 136 | printf("Setting brightness to: %ld (norm: %d)\n", new_blight, blight); 137 | 138 | backlight_destroy(backlight); 139 | } 140 | 141 | int 142 | main(int argc, char **argv) 143 | { 144 | int blight, connector_id; 145 | const char *path; 146 | struct udev *udev; 147 | struct udev_enumerate *e; 148 | struct udev_list_entry *entry; 149 | struct udev_device *drm_device; 150 | 151 | if (argc < 3) { 152 | printf("Please add connector_id and brightness values from 0-255\n"); 153 | return 1; 154 | } 155 | 156 | connector_id = atoi(argv[1]); 157 | blight = atoi(argv[2]); 158 | 159 | udev = udev_new(); 160 | if (udev == NULL) { 161 | printf("failed to initialize udev context\n"); 162 | return 1; 163 | } 164 | 165 | e = udev_enumerate_new(udev); 166 | udev_enumerate_add_match_subsystem(e, "drm"); 167 | udev_enumerate_add_match_sysname(e, "card[0-9]*"); 168 | 169 | udev_enumerate_scan_devices(e); 170 | drm_device = NULL; 171 | udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { 172 | path = udev_list_entry_get_name(entry); 173 | drm_device = udev_device_new_from_syspath(udev, path); 174 | break; 175 | } 176 | 177 | if (drm_device == NULL) { 178 | printf("no drm device found\n"); 179 | return 1; 180 | } 181 | 182 | set_backlight(drm_device, connector_id, blight); 183 | 184 | udev_device_unref(drm_device); 185 | return 0; 186 | } 187 | -------------------------------------------------------------------------------- /tests/surface-global-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "../src/compositor.h" 26 | 27 | static void 28 | surface_to_from_global(void *data) 29 | { 30 | struct weston_compositor *compositor = data; 31 | struct weston_surface *surface; 32 | struct weston_view *view; 33 | float x, y; 34 | wl_fixed_t fx, fy; 35 | int32_t ix, iy; 36 | 37 | surface = weston_surface_create(compositor); 38 | assert(surface); 39 | view = weston_view_create(surface); 40 | assert(view); 41 | surface->width = 50; 42 | surface->height = 50; 43 | weston_view_set_position(view, 5, 10); 44 | weston_view_update_transform(view); 45 | 46 | weston_view_to_global_float(view, 33, 22, &x, &y); 47 | assert(x == 38 && y == 32); 48 | 49 | weston_view_to_global_float(view, -8, -2, &x, &y); 50 | assert(x == -3 && y == 8); 51 | 52 | weston_view_to_global_fixed(view, wl_fixed_from_int(12), 53 | wl_fixed_from_int(5), &fx, &fy); 54 | assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15)); 55 | 56 | weston_view_from_global_float(view, 38, 32, &x, &y); 57 | assert(x == 33 && y == 22); 58 | 59 | weston_view_from_global_float(view, 42, 5, &x, &y); 60 | assert(x == 37 && y == -5); 61 | 62 | weston_view_from_global_fixed(view, wl_fixed_from_int(21), 63 | wl_fixed_from_int(100), &fx, &fy); 64 | assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90)); 65 | 66 | weston_view_from_global(view, 0, 0, &ix, &iy); 67 | assert(ix == -5 && iy == -10); 68 | 69 | weston_view_from_global(view, 5, 10, &ix, &iy); 70 | assert(ix == 0 && iy == 0); 71 | 72 | wl_display_terminate(compositor->wl_display); 73 | } 74 | 75 | WL_EXPORT int 76 | module_init(struct weston_compositor *compositor, int *argc, char *argv[]) 77 | { 78 | struct wl_event_loop *loop; 79 | 80 | loop = wl_display_get_event_loop(compositor->wl_display); 81 | 82 | wl_event_loop_add_idle(loop, surface_to_from_global, compositor); 83 | 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /tests/surface-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "../src/compositor.h" 28 | 29 | static void 30 | surface_transform(void *data) 31 | { 32 | struct weston_compositor *compositor = data; 33 | struct weston_surface *surface; 34 | struct weston_view *view; 35 | float x, y; 36 | 37 | surface = weston_surface_create(compositor); 38 | assert(surface); 39 | view = weston_view_create(surface); 40 | assert(view); 41 | surface->width = 200; 42 | surface->height = 200; 43 | weston_view_set_position(view, 100, 100); 44 | weston_view_update_transform(view); 45 | weston_view_to_global_float(view, 20, 20, &x, &y); 46 | 47 | fprintf(stderr, "20,20 maps to %f, %f\n", x, y); 48 | assert(x == 120 && y == 120); 49 | 50 | weston_view_set_position(view, 150, 300); 51 | weston_view_update_transform(view); 52 | weston_view_to_global_float(view, 50, 40, &x, &y); 53 | assert(x == 200 && y == 340); 54 | 55 | wl_display_terminate(compositor->wl_display); 56 | } 57 | 58 | WL_EXPORT int 59 | module_init(struct weston_compositor *compositor, int *argc, char *argv[]) 60 | { 61 | struct wl_event_loop *loop; 62 | 63 | loop = wl_display_get_event_loop(compositor->wl_display); 64 | 65 | wl_event_loop_add_idle(loop, surface_transform, compositor); 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /tests/text-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include "weston-test-client-helper.h" 27 | #include "text-client-protocol.h" 28 | 29 | struct text_input_state { 30 | int activated; 31 | int deactivated; 32 | }; 33 | 34 | static void 35 | text_input_commit_string(void *data, 36 | struct wl_text_input *text_input, 37 | uint32_t serial, 38 | const char *text) 39 | { 40 | } 41 | 42 | static void 43 | text_input_preedit_string(void *data, 44 | struct wl_text_input *text_input, 45 | uint32_t serial, 46 | const char *text, 47 | const char *commit) 48 | { 49 | } 50 | 51 | static void 52 | text_input_delete_surrounding_text(void *data, 53 | struct wl_text_input *text_input, 54 | int32_t index, 55 | uint32_t length) 56 | { 57 | } 58 | 59 | static void 60 | text_input_cursor_position(void *data, 61 | struct wl_text_input *text_input, 62 | int32_t index, 63 | int32_t anchor) 64 | { 65 | } 66 | 67 | static void 68 | text_input_preedit_styling(void *data, 69 | struct wl_text_input *text_input, 70 | uint32_t index, 71 | uint32_t length, 72 | uint32_t style) 73 | { 74 | } 75 | 76 | static void 77 | text_input_preedit_cursor(void *data, 78 | struct wl_text_input *text_input, 79 | int32_t index) 80 | { 81 | } 82 | 83 | static void 84 | text_input_modifiers_map(void *data, 85 | struct wl_text_input *text_input, 86 | struct wl_array *map) 87 | { 88 | } 89 | 90 | static void 91 | text_input_keysym(void *data, 92 | struct wl_text_input *text_input, 93 | uint32_t serial, 94 | uint32_t time, 95 | uint32_t sym, 96 | uint32_t state, 97 | uint32_t modifiers) 98 | { 99 | } 100 | 101 | static void 102 | text_input_enter(void *data, 103 | struct wl_text_input *text_input, 104 | struct wl_surface *surface) 105 | 106 | { 107 | struct text_input_state *state = data; 108 | 109 | fprintf(stderr, "%s\n", __FUNCTION__); 110 | 111 | state->activated += 1; 112 | } 113 | 114 | static void 115 | text_input_leave(void *data, 116 | struct wl_text_input *text_input) 117 | { 118 | struct text_input_state *state = data; 119 | 120 | state->deactivated += 1; 121 | } 122 | 123 | static void 124 | text_input_input_panel_state(void *data, 125 | struct wl_text_input *text_input, 126 | uint32_t state) 127 | { 128 | } 129 | 130 | static void 131 | text_input_language(void *data, 132 | struct wl_text_input *text_input, 133 | uint32_t serial, 134 | const char *language) 135 | { 136 | } 137 | 138 | static void 139 | text_input_text_direction(void *data, 140 | struct wl_text_input *text_input, 141 | uint32_t serial, 142 | uint32_t direction) 143 | { 144 | } 145 | 146 | static const struct wl_text_input_listener text_input_listener = { 147 | text_input_enter, 148 | text_input_leave, 149 | text_input_modifiers_map, 150 | text_input_input_panel_state, 151 | text_input_preedit_string, 152 | text_input_preedit_styling, 153 | text_input_preedit_cursor, 154 | text_input_commit_string, 155 | text_input_cursor_position, 156 | text_input_delete_surrounding_text, 157 | text_input_keysym, 158 | text_input_language, 159 | text_input_text_direction 160 | }; 161 | 162 | TEST(text_test) 163 | { 164 | struct client *client; 165 | struct global *global; 166 | struct wl_text_input_manager *factory; 167 | struct wl_text_input *text_input; 168 | struct text_input_state state; 169 | 170 | client = client_create(100, 100, 100, 100); 171 | assert(client); 172 | 173 | factory = NULL; 174 | wl_list_for_each(global, &client->global_list, link) { 175 | if (strcmp(global->interface, "wl_text_input_manager") == 0) 176 | factory = wl_registry_bind(client->wl_registry, 177 | global->name, 178 | &wl_text_input_manager_interface, 1); 179 | } 180 | 181 | assert(factory); 182 | 183 | memset(&state, 0, sizeof state); 184 | text_input = wl_text_input_manager_create_text_input(factory); 185 | wl_text_input_add_listener(text_input, &text_input_listener, &state); 186 | 187 | /* Make sure our test surface has keyboard focus. */ 188 | wl_test_activate_surface(client->test->wl_test, 189 | client->surface->wl_surface); 190 | client_roundtrip(client); 191 | assert(client->input->keyboard->focus == client->surface); 192 | 193 | /* Activate test model and make sure we get enter event. */ 194 | wl_text_input_activate(text_input, client->input->wl_seat, 195 | client->surface->wl_surface); 196 | client_roundtrip(client); 197 | assert(state.activated == 1 && state.deactivated == 0); 198 | 199 | /* Deactivate test model and make sure we get leave event. */ 200 | wl_text_input_deactivate(text_input, client->input->wl_seat); 201 | client_roundtrip(client); 202 | assert(state.activated == 1 && state.deactivated == 1); 203 | 204 | /* Activate test model again. */ 205 | wl_text_input_activate(text_input, client->input->wl_seat, 206 | client->surface->wl_surface); 207 | client_roundtrip(client); 208 | assert(state.activated == 2 && state.deactivated == 1); 209 | 210 | /* Take keyboard focus away and verify we get leave event. */ 211 | wl_test_activate_surface(client->test->wl_test, NULL); 212 | client_roundtrip(client); 213 | assert(state.activated == 2 && state.deactivated == 2); 214 | } 215 | -------------------------------------------------------------------------------- /tests/weston-test-client-helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _WESTON_TEST_CLIENT_HELPER_H_ 24 | #define _WESTON_TEST_CLIENT_HELPER_H_ 25 | 26 | #include 27 | #include "weston-test-runner.h" 28 | #include "wayland-test-client-protocol.h" 29 | 30 | struct client { 31 | struct wl_display *wl_display; 32 | struct wl_registry *wl_registry; 33 | struct wl_compositor *wl_compositor; 34 | struct wl_shm *wl_shm; 35 | struct test *test; 36 | struct input *input; 37 | struct output *output; 38 | struct surface *surface; 39 | int has_argb; 40 | struct wl_list global_list; 41 | }; 42 | 43 | struct global { 44 | uint32_t name; 45 | char *interface; 46 | uint32_t version; 47 | struct wl_list link; 48 | }; 49 | 50 | struct test { 51 | struct wl_test *wl_test; 52 | int pointer_x; 53 | int pointer_y; 54 | uint32_t n_egl_buffers; 55 | }; 56 | 57 | struct input { 58 | struct wl_seat *wl_seat; 59 | struct pointer *pointer; 60 | struct keyboard *keyboard; 61 | }; 62 | 63 | struct pointer { 64 | struct wl_pointer *wl_pointer; 65 | struct surface *focus; 66 | int x; 67 | int y; 68 | uint32_t button; 69 | uint32_t state; 70 | }; 71 | 72 | struct keyboard { 73 | struct wl_keyboard *wl_keyboard; 74 | struct surface *focus; 75 | uint32_t key; 76 | uint32_t state; 77 | uint32_t mods_depressed; 78 | uint32_t mods_latched; 79 | uint32_t mods_locked; 80 | uint32_t group; 81 | }; 82 | 83 | struct output { 84 | struct wl_output *wl_output; 85 | int x; 86 | int y; 87 | int width; 88 | int height; 89 | }; 90 | 91 | struct surface { 92 | struct wl_surface *wl_surface; 93 | struct wl_buffer *wl_buffer; 94 | struct output *output; 95 | int x; 96 | int y; 97 | int width; 98 | int height; 99 | void *data; 100 | }; 101 | 102 | struct client * 103 | client_create(int x, int y, int width, int height); 104 | 105 | struct wl_buffer * 106 | create_shm_buffer(struct client *client, int width, int height, void **pixels); 107 | 108 | int 109 | surface_contains(struct surface *surface, int x, int y); 110 | 111 | void 112 | move_client(struct client *client, int x, int y); 113 | 114 | #define client_roundtrip(c) do { \ 115 | assert(wl_display_roundtrip((c)->wl_display) >= 0); \ 116 | } while (0) 117 | 118 | struct wl_callback * 119 | frame_callback_set(struct wl_surface *surface, int *done); 120 | 121 | void 122 | frame_callback_wait(struct client *client, int *done); 123 | 124 | int 125 | get_n_egl_buffers(struct client *client); 126 | 127 | void 128 | skip(const char *fmt, ...); 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /tests/weston-test-runner.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that copyright 7 | * notice and this permission notice appear in supporting documentation, and 8 | * that the name of the copyright holders not be used in advertising or 9 | * publicity pertaining to distribution of the software without specific, 10 | * written prior permission. The copyright holders make no representations 11 | * about the suitability of this software for any purpose. It is provided "as 12 | * is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 | * OF THIS SOFTWARE. 21 | */ 22 | 23 | #include "config.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "weston-test-runner.h" 34 | 35 | extern const struct weston_test __start_test_section, __stop_test_section; 36 | 37 | static const struct weston_test * 38 | find_test(const char *name) 39 | { 40 | const struct weston_test *t; 41 | 42 | for (t = &__start_test_section; t < &__stop_test_section; t++) 43 | if (strcmp(t->name, name) == 0) 44 | return t; 45 | 46 | return NULL; 47 | } 48 | 49 | static void 50 | run_test(const struct weston_test *t, void *data) 51 | { 52 | t->run(data); 53 | exit(EXIT_SUCCESS); 54 | } 55 | 56 | static void 57 | list_tests(void) 58 | { 59 | const struct weston_test *t; 60 | 61 | fprintf(stderr, "Available test names:\n"); 62 | for (t = &__start_test_section; t < &__stop_test_section; t++) 63 | fprintf(stderr, " %s\n", t->name); 64 | } 65 | 66 | static int 67 | exec_and_report_test(const struct weston_test *t, void *test_data, int iteration) 68 | { 69 | int success = 0; 70 | int hardfail = 0; 71 | siginfo_t info; 72 | 73 | pid_t pid = fork(); 74 | assert(pid >= 0); 75 | 76 | if (pid == 0) 77 | run_test(t, test_data); /* never returns */ 78 | 79 | if (waitid(P_ALL, 0, &info, WEXITED)) { 80 | fprintf(stderr, "waitid failed: %m\n"); 81 | abort(); 82 | } 83 | 84 | if (test_data) 85 | fprintf(stderr, "test \"%s/%i\":\t", t->name, iteration); 86 | else 87 | fprintf(stderr, "test \"%s\":\t", t->name); 88 | 89 | switch (info.si_code) { 90 | case CLD_EXITED: 91 | fprintf(stderr, "exit status %d", info.si_status); 92 | if (info.si_status == EXIT_SUCCESS) 93 | success = 1; 94 | break; 95 | case CLD_KILLED: 96 | case CLD_DUMPED: 97 | fprintf(stderr, "signal %d", info.si_status); 98 | if (info.si_status != SIGABRT) 99 | hardfail = 1; 100 | break; 101 | } 102 | 103 | if (t->must_fail) 104 | success = !success; 105 | 106 | if (success && !hardfail) { 107 | fprintf(stderr, ", pass.\n"); 108 | return 1; 109 | } else { 110 | fprintf(stderr, ", fail.\n"); 111 | return 0; 112 | } 113 | } 114 | 115 | /* Returns number of tests and number of pass / fail in param args */ 116 | static int 117 | iterate_test(const struct weston_test *t, int *passed) 118 | { 119 | int i; 120 | void *current_test_data = (void *) t->table_data; 121 | for (i = 0; i < t->n_elements; ++i, current_test_data += t->element_size) 122 | { 123 | if (exec_and_report_test(t, current_test_data, i)) 124 | ++(*passed); 125 | } 126 | 127 | return t->n_elements; 128 | } 129 | 130 | int main(int argc, char *argv[]) 131 | { 132 | const struct weston_test *t; 133 | int total = 0; 134 | int pass = 0; 135 | 136 | if (argc == 2) { 137 | const char *testname = argv[1]; 138 | if (strcmp(testname, "--help") == 0 || 139 | strcmp(testname, "-h") == 0) { 140 | fprintf(stderr, "Usage: %s [test-name]\n", program_invocation_short_name); 141 | list_tests(); 142 | exit(EXIT_SUCCESS); 143 | } 144 | 145 | t = find_test(argv[1]); 146 | if (t == NULL) { 147 | fprintf(stderr, "unknown test: \"%s\"\n", argv[1]); 148 | list_tests(); 149 | exit(EXIT_FAILURE); 150 | } 151 | 152 | int number_passed_in_test = 0; 153 | total += iterate_test(t, &number_passed_in_test); 154 | pass += number_passed_in_test; 155 | } else { 156 | for (t = &__start_test_section; t < &__stop_test_section; t++) { 157 | int number_passed_in_test = 0; 158 | total += iterate_test(t, &number_passed_in_test); 159 | pass += number_passed_in_test; 160 | } 161 | } 162 | 163 | fprintf(stderr, "%d tests, %d pass, %d fail\n", 164 | total, pass, total - pass); 165 | 166 | return pass == total ? EXIT_SUCCESS : EXIT_FAILURE; 167 | } 168 | -------------------------------------------------------------------------------- /tests/weston-test-runner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * Copyright © 2013 Sam Spilsbury 4 | * 5 | * Permission to use, copy, modify, distribute, and sell this software and 6 | * its documentation for any purpose is hereby granted without fee, provided 7 | * that the above copyright notice appear in all copies and that both that 8 | * copyright notice and this permission notice appear in supporting 9 | * documentation, and that the name of the copyright holders not be used in 10 | * advertising or publicity pertaining to distribution of the software 11 | * without specific, written prior permission. The copyright holders make 12 | * no representations about the suitability of this software for any 13 | * purpose. It is provided "as is" without express or implied warranty. 14 | * 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | */ 23 | 24 | #ifndef _WESTON_TEST_RUNNER_H_ 25 | #define _WESTON_TEST_RUNNER_H_ 26 | 27 | #include 28 | 29 | #ifdef NDEBUG 30 | #error "Tests must not be built with NDEBUG defined, they rely on assert()." 31 | #endif 32 | 33 | struct weston_test { 34 | const char *name; 35 | void (*run)(void *); 36 | const void *table_data; 37 | size_t element_size; 38 | int n_elements; 39 | int must_fail; 40 | } __attribute__ ((aligned (32))); 41 | 42 | #define TEST_BEGIN(name, arg) \ 43 | static void name(arg) 44 | 45 | #define TEST_COMMON(func, name, ret, data, size, n_elem) \ 46 | static void func(void *); \ 47 | \ 48 | const struct weston_test test##name \ 49 | __attribute__ ((section ("test_section"))) = \ 50 | { \ 51 | #name, func, data, size, n_elem, ret \ 52 | }; 53 | 54 | #define NO_ARG_TEST(name, ret) \ 55 | TEST_COMMON(wrap##name, name, ret, NULL, 0, 1) \ 56 | static void name(void); \ 57 | static void wrap##name(void *data) \ 58 | { \ 59 | (void) data; \ 60 | name(); \ 61 | } \ 62 | \ 63 | TEST_BEGIN(name, void) 64 | 65 | #define ARG_TEST(name, ret, test_data) \ 66 | TEST_COMMON(name, name, ret, test_data, \ 67 | sizeof(test_data[0]), \ 68 | sizeof(test_data) / sizeof (test_data[0])) \ 69 | TEST_BEGIN(name, void *data) \ 70 | 71 | #define TEST(name) NO_ARG_TEST(name, 0) 72 | #define FAIL_TEST(name) NO_ARG_TEST(name, 1) 73 | #define TEST_P(name, data) ARG_TEST(name, 0, data) 74 | #define FAIL_TEST_P(name, data) ARG_TEST(name, 1, data) 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /tests/weston-tests-env: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TESTNAME=$1 4 | 5 | if test -z "$TESTNAME"; then 6 | echo "usage: $(basename $0) " 7 | exit 1; 8 | fi 9 | 10 | WESTON=$abs_builddir/weston 11 | LOGDIR=$abs_builddir/logs 12 | 13 | mkdir -p "$LOGDIR" 14 | 15 | SERVERLOG="$LOGDIR/$1-serverlog.txt" 16 | OUTLOG="$LOGDIR/$1-log.txt" 17 | 18 | rm -f "$SERVERLOG" 19 | 20 | if test x$WAYLAND_DISPLAY != x; then 21 | BACKEND=$abs_builddir/.libs/wayland-backend.so 22 | elif test x$DISPLAY != x; then 23 | BACKEND=$abs_builddir/.libs/x11-backend.so 24 | else 25 | BACKEND=$abs_builddir/.libs/wayland-backend.so 26 | fi 27 | 28 | case $TESTNAME in 29 | *.la|*.so) 30 | $WESTON --backend=$BACKEND \ 31 | --socket=test-$(basename $TESTNAME) \ 32 | --modules=$abs_builddir/.libs/${TESTNAME/.la/.so},xwayland.so \ 33 | --log="$SERVERLOG" \ 34 | &> "$OUTLOG" 35 | ;; 36 | *) 37 | WESTON_TEST_CLIENT_PATH=$abs_builddir/$TESTNAME $WESTON \ 38 | --socket=test-$(basename $TESTNAME) \ 39 | --backend=$BACKEND \ 40 | --log="$SERVERLOG" \ 41 | --modules=$abs_builddir/.libs/weston-test.so,xwayland.so \ 42 | &> "$OUTLOG" 43 | esac 44 | -------------------------------------------------------------------------------- /tests/xwayland-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2013 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | * 22 | * Author: Tiago Vignatti 23 | * 24 | * xwayland-test: the idea is to guarantee that XWayland infrastructure in 25 | * general works with Weston. 26 | */ 27 | 28 | #include "weston-test-runner.h" 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | 41 | static int 42 | dri2_open(xcb_connection_t *c, xcb_screen_t *screen) 43 | { 44 | xcb_dri2_connect_cookie_t cookie; 45 | xcb_dri2_connect_reply_t *reply; 46 | xcb_dri2_authenticate_cookie_t cookie_auth; 47 | xcb_dri2_authenticate_reply_t *reply_auth; 48 | char *driver, *device; 49 | int fd; 50 | drm_magic_t magic; 51 | 52 | cookie = xcb_dri2_connect(c, screen->root, XCB_DRI2_DRIVER_TYPE_DRI); 53 | reply = xcb_dri2_connect_reply(c, cookie, 0); 54 | assert(reply); 55 | 56 | driver = strndup(xcb_dri2_connect_driver_name (reply), 57 | xcb_dri2_connect_driver_name_length (reply)); 58 | device = strndup(xcb_dri2_connect_device_name (reply), 59 | xcb_dri2_connect_device_name_length (reply)); 60 | 61 | fd = open(device, O_RDWR); 62 | printf ("Trying connect to %s driver on %s\n", driver, device); 63 | free(driver); 64 | free(device); 65 | 66 | if (fd < 0) 67 | return -1; 68 | 69 | drmGetMagic(fd, &magic); 70 | 71 | cookie_auth = xcb_dri2_authenticate(c, screen->root, magic); 72 | reply_auth = xcb_dri2_authenticate_reply(c, cookie_auth, 0); 73 | assert(reply_auth); 74 | 75 | return fd; 76 | } 77 | 78 | static int 79 | create_window(void) 80 | { 81 | xcb_connection_t *c; 82 | xcb_screen_t *screen; 83 | xcb_window_t win; 84 | int fd; 85 | 86 | c = xcb_connect (NULL, NULL); 87 | if (c == NULL) { 88 | printf("failed to get X11 connection\n"); 89 | return -1; 90 | } 91 | 92 | screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data; 93 | 94 | win = xcb_generate_id(c); 95 | xcb_create_window(c, XCB_COPY_FROM_PARENT, win, screen->root, 96 | 0, 0, 150, 150, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, 97 | screen->root_visual, 0, NULL); 98 | 99 | xcb_change_property (c, XCB_PROP_MODE_REPLACE, win, 100 | XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 101 | 5, "title"); 102 | xcb_map_window(c, win); 103 | xcb_flush(c); 104 | 105 | fd = dri2_open(c, screen); 106 | if (fd < 0) 107 | return -1; 108 | 109 | xcb_destroy_window(c, win); 110 | xcb_disconnect(c); 111 | return 0; 112 | } 113 | 114 | /* 115 | * Ideally, the X Window Manager (XWM) and Weston Wayland compositor shouldn't 116 | * be in the same process because they are using two different protocol 117 | * streams in which one does not interface with the other. Probably the 118 | * biggest problem with such architecture are the potentials dead locks that 119 | * it may occur. So hypothetically, an X client might issue an X11 blocking 120 | * request via X (DRI2Authenticate) which in turn sends a Wayland blocking 121 | * request for Weston process it. X is blocked. At the same time, XWM might be 122 | * trying to process an XChangeProperty, so it requests a blocking X11 call to 123 | * the X server (xcb_get_property_reply -> xcb_wait_for_reply) which therefore 124 | * will blocks there. It's a deadlock situation and this test is trying to 125 | * catch that. 126 | */ 127 | static void 128 | check_dri2_authenticate(void) 129 | { 130 | int i, num_tests; 131 | 132 | /* TODO: explain why num_tests times */ 133 | num_tests = 10; 134 | for (i = 0; i < num_tests; i++) 135 | assert(create_window() == 0); 136 | } 137 | 138 | TEST(xwayland_client_test) 139 | { 140 | check_dri2_authenticate(); 141 | exit(EXIT_SUCCESS); 142 | } 143 | -------------------------------------------------------------------------------- /wcap/.gitignore: -------------------------------------------------------------------------------- 1 | wcap-decode 2 | wcap-snapshot 3 | 4 | -------------------------------------------------------------------------------- /wcap/README: -------------------------------------------------------------------------------- 1 | WCAP Tools 2 | 3 | WCAP is the video capture format used by Weston (Weston CAPture). 4 | It's a simple, lossless format, that encodes the difference between 5 | frames as run-length encoded rectangles. It's a variable framerate 6 | format, that only records new frames along with a timestamp when 7 | something actually changes. 8 | 9 | Recording in Weston is started by pressing MOD+R and stopped by 10 | pressing MOD+R again. Currently this leaves a capture.wcap file in 11 | the cwd of the weston process. The file format is documented below 12 | and Weston comes with the wcap-decode tool to convert the wcap file 13 | into something more usable: 14 | 15 | - Extract single or all frames as individual png files. This will 16 | produce a lossless screenshot, which is useful if you're trying to 17 | screenshot a brief glitch or something like that that's hard to 18 | capture with the screenshot tool. 19 | 20 | wcap-decode takes a number of options and a wcap file as its 21 | arguments. Without anything else, it will show the screen size and 22 | number of frames in the file. Pass --frame= to extract a 23 | single frame or pass --all to extract all frames as png files: 24 | 25 | [krh@minato weston]$ wcap-snapshot capture.wcap 26 | wcap file: size 1024x640, 176 frames 27 | [krh@minato weston]$ wcap-snapshot capture.wcap 20 28 | wrote wcap-frame-20.png 29 | wcap file: size 1024x640, 176 frames 30 | 31 | - Decode and the wcap file and dump it as a YUV4MPEG2 stream on 32 | stdout. This format is compatible with most video encoders and can 33 | be piped directly into a command line encoder such as vpxenc (part 34 | of libvpx, encodes to a webm file) or theora_encode (part of 35 | libtheora, encodes to a ogg theora file). 36 | 37 | Using vpxenc to encode a webm file would look something like this: 38 | 39 | [krh@minato weston]$ wcap-decode --yuv4mpeg2 ../capture.wcap | 40 | vpxenc --target-bitrate=1024 --best -t 4 -o foo.webm - 41 | 42 | where we select target bitrate, pass -t 4 to let vpxenc use 43 | multiple threads. To encode to Ogg Theora a command line like this 44 | works: 45 | 46 | [krh@minato weston]$ wcap-decode ../capture.wcap --yuv4mpeg2 | 47 | theora_encode - -o cap.ogv 48 | 49 | 50 | WCAP File format 51 | 52 | The file format has a small header and then just consists of the 53 | indivial frames. The header is 54 | 55 | uint32_t magic 56 | uint32_t format 57 | uint32_t width 58 | uint32_t height 59 | 60 | all CPU endian 32 bit words. The magic number is 61 | 62 | #define WCAP_HEADER_MAGIC 0x57434150 63 | 64 | and makes it easy to recognize a wcap file and verify that it's the 65 | right endian. There are four supported pixel formats: 66 | 67 | #define WCAP_FORMAT_XRGB8888 0x34325258 68 | #define WCAP_FORMAT_XBGR8888 0x34324258 69 | #define WCAP_FORMAT_RGBX8888 0x34325852 70 | #define WCAP_FORMAT_BGRX8888 0x34325842 71 | 72 | Each frame has a header: 73 | 74 | uint32_t msecs 75 | uint32_t nrects 76 | 77 | which specifies a timestamp in ms and the number of rectangles that 78 | changed since previous frame. The timestamps are typically just a raw 79 | system timestamp and the first frame doesn't start from 0ms. 80 | 81 | A frame consists of a list of rectangles, each of which represents the 82 | component-wise difference between the previous frame and the current 83 | using a run-length encoding. The initial frame is decoded against a 84 | previous frame of all 0x00000000 pixels. Each rectangle starts out 85 | with 86 | 87 | int32_t x1 88 | int32_t y1 89 | int32_t x2 90 | int32_t y2 91 | 92 | followed by (x2 - x1) * (y2 - y1) pixels, run-length encoded. The 93 | run-length encoding uses the 'X' channel in the pixel format to encode 94 | the length of the run. That is for WCAP_FORMAT_XRGB8888, for example, 95 | the length of the run is in the upper 8 bits. For X values 0-0xdf, 96 | the length is X + 1, for X above or equal to 0xe0, the run length is 1 97 | << (X - 0xe0 + 7). That is, a pixel value of 0xe3000100, means that 98 | the next 1024 pixels differ by RGB(0x00, 0x01, 0x00) from the previous 99 | pixels. 100 | -------------------------------------------------------------------------------- /wcap/wcap-decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | #include "wcap-decode.h" 39 | 40 | static void 41 | wcap_decoder_decode_rectangle(struct wcap_decoder *decoder, 42 | struct wcap_rectangle *rect) 43 | { 44 | uint32_t v, *p = decoder->p, *d; 45 | int width = rect->x2 - rect->x1, height = rect->y2 - rect->y1; 46 | int x, i, j, k, l, count = width * height; 47 | unsigned char r, g, b, dr, dg, db; 48 | 49 | d = decoder->frame + (rect->y2 - 1) * decoder->width; 50 | x = rect->x1; 51 | i = 0; 52 | while (i < count) { 53 | v = *p++; 54 | l = v >> 24; 55 | if (l < 0xe0) { 56 | j = l + 1; 57 | } else { 58 | j = 1 << (l - 0xe0 + 7); 59 | } 60 | 61 | dr = (v >> 16); 62 | dg = (v >> 8); 63 | db = (v >> 0); 64 | for (k = 0; k < j; k++) { 65 | r = (d[x] >> 16) + dr; 66 | g = (d[x] >> 8) + dg; 67 | b = (d[x] >> 0) + db; 68 | d[x] = 0xff000000 | (r << 16) | (g << 8) | b; 69 | x++; 70 | if (x == rect->x2) { 71 | x = rect->x1; 72 | d -= decoder->width; 73 | } 74 | } 75 | i += j; 76 | } 77 | 78 | if (i != count) 79 | printf("rle encoding longer than expected (%d expected %d)\n", 80 | i, count); 81 | 82 | decoder->p = p; 83 | } 84 | 85 | int 86 | wcap_decoder_get_frame(struct wcap_decoder *decoder) 87 | { 88 | struct wcap_rectangle *rects; 89 | struct wcap_frame_header *header; 90 | uint32_t i; 91 | 92 | if (decoder->p == decoder->end) 93 | return 0; 94 | 95 | header = decoder->p; 96 | decoder->msecs = header->msecs; 97 | decoder->count++; 98 | 99 | rects = (void *) (header + 1); 100 | decoder->p = (uint32_t *) (rects + header->nrects); 101 | for (i = 0; i < header->nrects; i++) 102 | wcap_decoder_decode_rectangle(decoder, &rects[i]); 103 | 104 | return 1; 105 | } 106 | 107 | struct wcap_decoder * 108 | wcap_decoder_create(const char *filename) 109 | { 110 | struct wcap_decoder *decoder; 111 | struct wcap_header *header; 112 | int frame_size; 113 | struct stat buf; 114 | 115 | decoder = malloc(sizeof *decoder); 116 | if (decoder == NULL) 117 | return NULL; 118 | 119 | decoder->fd = open(filename, O_RDONLY); 120 | if (decoder->fd == -1) { 121 | free(decoder); 122 | return NULL; 123 | } 124 | 125 | fstat(decoder->fd, &buf); 126 | decoder->size = buf.st_size; 127 | decoder->map = mmap(NULL, decoder->size, 128 | PROT_READ, MAP_PRIVATE, decoder->fd, 0); 129 | 130 | header = decoder->map; 131 | decoder->format = header->format; 132 | decoder->count = 0; 133 | decoder->width = header->width; 134 | decoder->height = header->height; 135 | decoder->p = header + 1; 136 | decoder->end = decoder->map + decoder->size; 137 | 138 | frame_size = header->width * header->height * 4; 139 | decoder->frame = malloc(frame_size); 140 | memset(decoder->frame, 0, frame_size); 141 | 142 | return decoder; 143 | } 144 | 145 | void 146 | wcap_decoder_destroy(struct wcap_decoder *decoder) 147 | { 148 | munmap(decoder->map, decoder->size); 149 | close(decoder->fd); 150 | free(decoder->frame); 151 | free(decoder); 152 | } 153 | -------------------------------------------------------------------------------- /wcap/wcap-decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #ifndef _WCAP_DECODE_ 24 | #define _WCAP_DECODE_ 25 | 26 | #define WCAP_HEADER_MAGIC 0x57434150 27 | 28 | #define WCAP_FORMAT_XRGB8888 0x34325258 29 | #define WCAP_FORMAT_XBGR8888 0x34324258 30 | #define WCAP_FORMAT_RGBX8888 0x34325852 31 | #define WCAP_FORMAT_BGRX8888 0x34325842 32 | 33 | struct wcap_header { 34 | uint32_t magic; 35 | uint32_t format; 36 | uint32_t width, height; 37 | }; 38 | 39 | struct wcap_frame_header { 40 | uint32_t msecs; 41 | uint32_t nrects; 42 | }; 43 | 44 | struct wcap_rectangle { 45 | int32_t x1, y1, x2, y2; 46 | }; 47 | 48 | struct wcap_decoder { 49 | int fd; 50 | size_t size; 51 | void *map, *p, *end; 52 | uint32_t *frame; 53 | uint32_t format; 54 | uint32_t msecs; 55 | uint32_t count; 56 | int width, height; 57 | }; 58 | 59 | int wcap_decoder_get_frame(struct wcap_decoder *decoder); 60 | struct wcap_decoder *wcap_decoder_create(const char *filename); 61 | void wcap_decoder_destroy(struct wcap_decoder *decoder); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /weston.ini.in: -------------------------------------------------------------------------------- 1 | [core] 2 | #modules=xwayland.so,cms-colord.so 3 | #shell=desktop-shell.so 4 | #gbm-format=xrgb2101010 5 | 6 | [shell] 7 | background-image=/usr/share/backgrounds/gnome/Aqua.jpg 8 | background-color=0xff002244 9 | background-type=tile 10 | panel-color=0x90ff0000 11 | locking=true 12 | animation=zoom 13 | startup-animation=fade 14 | #binding-modifier=ctrl 15 | #num-workspaces=6 16 | #cursor-theme=whiteglass 17 | #cursor-size=24 18 | 19 | #lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png 20 | #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg 21 | #homescreen=/usr/share/backgrounds/gnome/Blinds.jpg 22 | #animation=fade 23 | 24 | [launcher] 25 | icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png 26 | path=/usr/bin/gnome-terminal 27 | 28 | [launcher] 29 | icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png 30 | path=@bindir@/weston-terminal 31 | 32 | [launcher] 33 | icon=/usr/share/icons/hicolor/24x24/apps/google-chrome.png 34 | path=/usr/bin/google-chrome 35 | 36 | [launcher] 37 | icon=/usr/share/icons/gnome/24x24/apps/arts.png 38 | path=@abs_top_builddir@/clients/weston-flower 39 | 40 | [screensaver] 41 | # Uncomment path to disable screensaver 42 | path=@libexecdir@/weston-screensaver 43 | duration=600 44 | 45 | [input-method] 46 | path=@libexecdir@/weston-keyboard 47 | 48 | #[output] 49 | #name=LVDS1 50 | #mode=1680x1050 51 | #transform=90 52 | #icc_profile=/usr/share/color/icc/colord/Bluish.icc 53 | 54 | #[output] 55 | #name=VGA1 56 | #mode=173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync 57 | #transform=flipped 58 | 59 | #[output] 60 | #name=X1 61 | #mode=1024x768 62 | #transform=flipped-270 63 | 64 | #[touchpad] 65 | #constant_accel_factor = 50 66 | #min_accel_factor = 0.16 67 | #max_accel_factor = 1.0 68 | -------------------------------------------------------------------------------- /xwayland/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2009 Intel Corporation 3 | * Copyright © 1988-2004 Keith Packard and Bart Massey. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice (including the next 13 | * paragraph) shall be included in all copies or substantial portions of the 14 | * Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * Except as contained in this notice, the names of the authors 25 | * or their institutions shall not be used in advertising or 26 | * otherwise to promote the sale, use or other dealings in this 27 | * Software without prior written authorization from the 28 | * authors. 29 | * 30 | * Authors: 31 | * Eric Anholt 32 | * Keith Packard 33 | */ 34 | 35 | #ifndef HASH_H 36 | #define HASH_H 37 | 38 | struct hash_table; 39 | struct hash_table *hash_table_create(void); 40 | typedef void (*hash_table_iterator_func_t)(void *element, void *data); 41 | 42 | void hash_table_destroy(struct hash_table *ht); 43 | void *hash_table_lookup(struct hash_table *ht, uint32_t hash); 44 | int hash_table_insert(struct hash_table *ht, uint32_t hash, void *data); 45 | void hash_table_remove(struct hash_table *ht, uint32_t hash); 46 | void hash_table_for_each(struct hash_table *ht, 47 | hash_table_iterator_func_t func, void *data); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /xwayland/xwayland.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012 Intel Corporation 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and 5 | * its documentation for any purpose is hereby granted without fee, provided 6 | * that the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation, and that the name of the copyright holders not be used in 9 | * advertising or publicity pertaining to distribution of the software 10 | * without specific, written prior permission. The copyright holders make 11 | * no representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "compositor.h" 30 | 31 | #define SEND_EVENT_MASK (0x80) 32 | #define EVENT_TYPE(event) ((event)->response_type & ~SEND_EVENT_MASK) 33 | 34 | struct weston_xserver { 35 | struct wl_display *wl_display; 36 | struct wl_event_loop *loop; 37 | struct wl_event_source *sigchld_source; 38 | int abstract_fd; 39 | struct wl_event_source *abstract_source; 40 | int unix_fd; 41 | struct wl_event_source *unix_source; 42 | int display; 43 | struct weston_process process; 44 | struct wl_resource *resource; 45 | struct wl_client *client; 46 | struct weston_compositor *compositor; 47 | struct weston_wm *wm; 48 | struct wl_listener destroy_listener; 49 | }; 50 | 51 | struct weston_wm { 52 | xcb_connection_t *conn; 53 | const xcb_query_extension_reply_t *xfixes; 54 | struct wl_event_source *source; 55 | xcb_screen_t *screen; 56 | struct hash_table *window_hash; 57 | struct weston_xserver *server; 58 | xcb_window_t wm_window; 59 | struct weston_wm_window *focus_window; 60 | struct theme *theme; 61 | xcb_cursor_t *cursors; 62 | int last_cursor; 63 | xcb_render_pictforminfo_t format_rgb, format_rgba; 64 | xcb_visualid_t visual_id; 65 | xcb_colormap_t colormap; 66 | struct wl_listener activate_listener; 67 | struct wl_listener transform_listener; 68 | struct wl_listener kill_listener; 69 | 70 | xcb_window_t selection_window; 71 | xcb_window_t selection_owner; 72 | int incr; 73 | int data_source_fd; 74 | struct wl_event_source *property_source; 75 | xcb_get_property_reply_t *property_reply; 76 | int property_start; 77 | struct wl_array source_data; 78 | xcb_selection_request_event_t selection_request; 79 | xcb_atom_t selection_target; 80 | xcb_timestamp_t selection_timestamp; 81 | int selection_property_set; 82 | int flush_property_on_delete; 83 | struct wl_listener selection_listener; 84 | 85 | xcb_window_t dnd_window; 86 | xcb_window_t dnd_owner; 87 | 88 | struct { 89 | xcb_atom_t wm_protocols; 90 | xcb_atom_t wm_normal_hints; 91 | xcb_atom_t wm_take_focus; 92 | xcb_atom_t wm_delete_window; 93 | xcb_atom_t wm_state; 94 | xcb_atom_t wm_s0; 95 | xcb_atom_t wm_client_machine; 96 | xcb_atom_t net_wm_cm_s0; 97 | xcb_atom_t net_wm_name; 98 | xcb_atom_t net_wm_pid; 99 | xcb_atom_t net_wm_icon; 100 | xcb_atom_t net_wm_state; 101 | xcb_atom_t net_wm_state_fullscreen; 102 | xcb_atom_t net_wm_user_time; 103 | xcb_atom_t net_wm_icon_name; 104 | xcb_atom_t net_wm_window_type; 105 | xcb_atom_t net_wm_window_type_desktop; 106 | xcb_atom_t net_wm_window_type_dock; 107 | xcb_atom_t net_wm_window_type_toolbar; 108 | xcb_atom_t net_wm_window_type_menu; 109 | xcb_atom_t net_wm_window_type_utility; 110 | xcb_atom_t net_wm_window_type_splash; 111 | xcb_atom_t net_wm_window_type_dialog; 112 | xcb_atom_t net_wm_window_type_dropdown; 113 | xcb_atom_t net_wm_window_type_popup; 114 | xcb_atom_t net_wm_window_type_tooltip; 115 | xcb_atom_t net_wm_window_type_notification; 116 | xcb_atom_t net_wm_window_type_combo; 117 | xcb_atom_t net_wm_window_type_dnd; 118 | xcb_atom_t net_wm_window_type_normal; 119 | xcb_atom_t net_wm_moveresize; 120 | xcb_atom_t net_supporting_wm_check; 121 | xcb_atom_t net_supported; 122 | xcb_atom_t motif_wm_hints; 123 | xcb_atom_t clipboard; 124 | xcb_atom_t clipboard_manager; 125 | xcb_atom_t targets; 126 | xcb_atom_t utf8_string; 127 | xcb_atom_t wl_selection; 128 | xcb_atom_t incr; 129 | xcb_atom_t timestamp; 130 | xcb_atom_t multiple; 131 | xcb_atom_t compound_text; 132 | xcb_atom_t text; 133 | xcb_atom_t string; 134 | xcb_atom_t text_plain_utf8; 135 | xcb_atom_t text_plain; 136 | xcb_atom_t xdnd_selection; 137 | xcb_atom_t xdnd_aware; 138 | xcb_atom_t xdnd_enter; 139 | xcb_atom_t xdnd_leave; 140 | xcb_atom_t xdnd_drop; 141 | xcb_atom_t xdnd_status; 142 | xcb_atom_t xdnd_finished; 143 | xcb_atom_t xdnd_type_list; 144 | xcb_atom_t xdnd_action_copy; 145 | } atom; 146 | }; 147 | 148 | void 149 | dump_property(struct weston_wm *wm, xcb_atom_t property, 150 | xcb_get_property_reply_t *reply); 151 | 152 | const char * 153 | get_atom_name(xcb_connection_t *c, xcb_atom_t atom); 154 | 155 | void 156 | weston_wm_selection_init(struct weston_wm *wm); 157 | int 158 | weston_wm_handle_selection_event(struct weston_wm *wm, 159 | xcb_generic_event_t *event); 160 | 161 | extern const struct xserver_interface xserver_implementation; 162 | 163 | struct weston_wm * 164 | weston_wm_create(struct weston_xserver *wxs); 165 | void 166 | weston_wm_destroy(struct weston_wm *wm); 167 | 168 | struct weston_seat * 169 | weston_wm_pick_seat(struct weston_wm *wm); 170 | 171 | int 172 | weston_wm_handle_dnd_event(struct weston_wm *wm, 173 | xcb_generic_event_t *event); 174 | void 175 | weston_wm_dnd_init(struct weston_wm *wm); 176 | --------------------------------------------------------------------------------