2011-11-17 13:33:06 +04:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Collabora, Ltd.
|
|
|
|
*
|
2015-06-11 08:48:59 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2011-11-17 13:33:06 +04:00
|
|
|
*
|
2015-06-11 08:48:59 +03:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2011-11-17 13:33:06 +04:00
|
|
|
*/
|
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
#include "../config.h"
|
2011-11-17 13:33:06 +04:00
|
|
|
|
|
|
|
#include "wscreensaver.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
2011-11-22 18:35:14 +04:00
|
|
|
#include <wayland-client.h>
|
2011-11-17 13:33:06 +04:00
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
#include "desktop-shell-client-protocol.h"
|
2011-11-17 13:33:06 +04:00
|
|
|
#include "window.h"
|
2015-06-16 01:37:08 +03:00
|
|
|
#include "shared/helpers.h"
|
2011-11-17 13:33:06 +04:00
|
|
|
|
|
|
|
extern struct wscreensaver_plugin glmatrix_screensaver;
|
|
|
|
|
|
|
|
static const struct wscreensaver_plugin * const plugins[] = {
|
|
|
|
&glmatrix_screensaver,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *progname = NULL;
|
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
static int demo_mode;
|
|
|
|
|
2011-11-17 13:33:06 +04:00
|
|
|
struct wscreensaver {
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
struct screensaver *interface;
|
|
|
|
|
2011-11-17 13:33:06 +04:00
|
|
|
struct display *display;
|
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
struct ModeInfo *demomode;
|
2011-11-17 13:33:06 +04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
EGLDisplay display;
|
|
|
|
EGLConfig config;
|
|
|
|
} egl;
|
|
|
|
|
|
|
|
const struct wscreensaver_plugin *plugin;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-01-10 22:59:23 +04:00
|
|
|
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
|
|
|
|
{
|
|
|
|
struct ModeInfo *mi = data;
|
|
|
|
|
|
|
|
window_schedule_redraw(mi->window);
|
2012-01-17 18:10:41 +04:00
|
|
|
wl_callback_destroy(callback);
|
2012-01-10 22:59:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_callback_listener listener = {
|
|
|
|
frame_callback
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
redraw_handler(struct widget *widget, void *data)
|
2011-11-17 13:33:06 +04:00
|
|
|
{
|
2012-01-10 22:59:23 +04:00
|
|
|
struct ModeInfo *mi = data;
|
2011-11-17 13:33:06 +04:00
|
|
|
struct wscreensaver *wscr = mi->priv;
|
|
|
|
struct rectangle drawarea;
|
|
|
|
struct rectangle winarea;
|
2012-01-10 22:59:23 +04:00
|
|
|
struct wl_callback *callback;
|
2011-11-17 13:33:06 +04:00
|
|
|
int bottom;
|
|
|
|
|
|
|
|
mi->swap_buffers = 0;
|
|
|
|
|
2012-01-11 04:11:42 +04:00
|
|
|
widget_get_allocation(mi->widget, &drawarea);
|
2011-11-17 13:33:06 +04:00
|
|
|
window_get_allocation(mi->window, &winarea);
|
|
|
|
|
|
|
|
if (display_acquire_window_surface(wscr->display,
|
|
|
|
mi->window,
|
|
|
|
mi->eglctx) < 0) {
|
|
|
|
fprintf(stderr, "%s: unable to acquire window surface",
|
|
|
|
progname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bottom = winarea.height - (drawarea.height + drawarea.y);
|
|
|
|
glViewport(drawarea.x, bottom, drawarea.width, drawarea.height);
|
|
|
|
glScissor(drawarea.x, bottom, drawarea.width, drawarea.height);
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
|
|
|
|
if (mi->width != drawarea.width || mi->height != drawarea.height) {
|
|
|
|
mi->width = drawarea.width;
|
|
|
|
mi->height = drawarea.height;
|
|
|
|
wscr->plugin->reshape(mi, mi->width, mi->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
wscr->plugin->draw(mi);
|
|
|
|
|
|
|
|
if (mi->swap_buffers == 0)
|
|
|
|
fprintf(stderr, "%s: swapBuffers not called\n", progname);
|
|
|
|
|
|
|
|
display_release_window_surface(wscr->display, mi->window);
|
|
|
|
|
|
|
|
callback = wl_surface_frame(window_get_wl_surface(mi->window));
|
|
|
|
wl_callback_add_listener(callback, &listener, mi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_frand(void)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
srandom(tv.tv_sec * 100 + tv.tv_usec / 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT EGLContext *
|
|
|
|
init_GL(struct ModeInfo *mi)
|
|
|
|
{
|
|
|
|
struct wscreensaver *wscr = mi->priv;
|
|
|
|
EGLContext *pctx;
|
|
|
|
|
|
|
|
pctx = malloc(sizeof *pctx);
|
|
|
|
if (!pctx)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (mi->eglctx != EGL_NO_CONTEXT) {
|
|
|
|
fprintf(stderr, "%s: multiple GL contexts are not supported",
|
|
|
|
progname);
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi->eglctx = eglCreateContext(wscr->egl.display, wscr->egl.config,
|
|
|
|
EGL_NO_CONTEXT, NULL);
|
|
|
|
if (mi->eglctx == EGL_NO_CONTEXT) {
|
|
|
|
fprintf(stderr, "%s: init_GL failed to create EGL context\n",
|
|
|
|
progname);
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eglMakeCurrent(wscr->egl.display, NULL, NULL, mi->eglctx)) {
|
|
|
|
fprintf(stderr, "%s: init_GL failed on eglMakeCurrent\n",
|
|
|
|
progname);
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
|
|
|
|
|
|
|
*pctx = mi->eglctx;
|
|
|
|
return pctx;
|
|
|
|
|
|
|
|
errout:
|
|
|
|
free(pctx);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ModeInfo *
|
2012-01-17 18:10:41 +04:00
|
|
|
create_wscreensaver_instance(struct wscreensaver *screensaver,
|
|
|
|
struct wl_output *output, int width, int height)
|
2011-11-17 13:33:06 +04:00
|
|
|
{
|
2012-01-17 18:10:41 +04:00
|
|
|
static int instance;
|
2011-11-17 13:33:06 +04:00
|
|
|
struct ModeInfo *mi;
|
|
|
|
struct rectangle drawarea;
|
|
|
|
|
|
|
|
mi = calloc(1, sizeof *mi);
|
|
|
|
if (!mi)
|
|
|
|
return NULL;
|
|
|
|
|
2012-07-12 06:57:14 +04:00
|
|
|
if (demo_mode)
|
|
|
|
mi->window = window_create(screensaver->display);
|
|
|
|
else
|
|
|
|
mi->window = window_create_custom(screensaver->display);
|
|
|
|
|
2012-01-17 18:10:41 +04:00
|
|
|
if (!mi->window) {
|
2011-11-17 13:33:06 +04:00
|
|
|
fprintf(stderr, "%s: creating a window failed.\n", progname);
|
2012-01-17 18:10:41 +04:00
|
|
|
free(mi);
|
2011-11-17 13:33:06 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-17 18:10:41 +04:00
|
|
|
window_set_title(mi->window, progname);
|
2011-11-17 13:33:06 +04:00
|
|
|
|
2012-07-12 06:57:14 +04:00
|
|
|
if (screensaver->interface && !demo_mode) {
|
2012-01-17 18:10:41 +04:00
|
|
|
mi->widget = window_add_widget(mi->window, mi);
|
2011-11-30 16:45:47 +04:00
|
|
|
screensaver_set_surface(screensaver->interface,
|
2012-06-27 06:15:53 +04:00
|
|
|
window_get_wl_surface(mi->window),
|
2011-11-30 16:45:47 +04:00
|
|
|
output);
|
2012-01-17 18:10:41 +04:00
|
|
|
} else {
|
2013-10-18 05:56:41 +04:00
|
|
|
mi->widget = window_frame_create(mi->window, mi);
|
2011-11-30 16:45:47 +04:00
|
|
|
}
|
2012-01-17 18:10:41 +04:00
|
|
|
widget_set_redraw_handler(mi->widget, redraw_handler);
|
2011-11-30 16:45:47 +04:00
|
|
|
|
2012-01-17 18:10:41 +04:00
|
|
|
mi->priv = screensaver;
|
|
|
|
mi->eglctx = EGL_NO_CONTEXT;
|
|
|
|
mi->instance_number = instance++; /* XXX */
|
|
|
|
|
|
|
|
widget_get_allocation(mi->widget, &drawarea);
|
|
|
|
mi->width = drawarea.width;
|
|
|
|
mi->height = drawarea.height;
|
2011-11-17 13:33:06 +04:00
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
screensaver->plugin->init(mi);
|
2011-11-17 13:33:06 +04:00
|
|
|
|
2012-01-17 18:10:41 +04:00
|
|
|
window_schedule_resize(mi->window, width, height);
|
2011-11-17 13:33:06 +04:00
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
static void
|
|
|
|
handle_output_destroy(struct output *output, void *data)
|
|
|
|
{
|
|
|
|
/* struct ModeInfo *mi = data;
|
|
|
|
* TODO */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_output_configure(struct output *output, void *data)
|
|
|
|
{
|
|
|
|
struct wscreensaver *screensaver = data;
|
|
|
|
struct ModeInfo *mi;
|
|
|
|
struct rectangle area;
|
|
|
|
|
|
|
|
/* skip existing outputs */
|
|
|
|
if (output_get_user_data(output))
|
|
|
|
return;
|
|
|
|
|
|
|
|
output_get_allocation(output, &area);
|
|
|
|
mi = create_wscreensaver_instance(screensaver,
|
|
|
|
output_get_wl_output(output),
|
|
|
|
area.width, area.height);
|
|
|
|
output_set_user_data(output, mi);
|
|
|
|
output_set_destroy_handler(output, handle_output_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-11-17 13:33:06 +04:00
|
|
|
init_wscreensaver(struct wscreensaver *wscr, struct display *display)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
const char prefix[] = "wscreensaver::";
|
|
|
|
char *str;
|
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
display_set_user_data(display, wscr);
|
2011-11-17 13:33:06 +04:00
|
|
|
wscr->display = display;
|
|
|
|
wscr->plugin = plugins[0];
|
|
|
|
|
|
|
|
size = sizeof(prefix) + strlen(wscr->plugin->name);
|
|
|
|
str = malloc(size);
|
2011-11-30 16:45:47 +04:00
|
|
|
if (!str) {
|
|
|
|
fprintf(stderr, "init: out of memory\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2011-11-17 13:33:06 +04:00
|
|
|
snprintf(str, size, "%s%s", prefix, wscr->plugin->name);
|
|
|
|
progname = str;
|
|
|
|
|
|
|
|
wscr->egl.display = display_get_egl_display(wscr->display);
|
2011-11-30 16:45:47 +04:00
|
|
|
if (!wscr->egl.display) {
|
|
|
|
fprintf(stderr, "init: no EGL display\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2011-11-17 13:33:06 +04:00
|
|
|
|
|
|
|
eglBindAPI(EGL_OPENGL_API);
|
2012-03-01 01:14:22 +04:00
|
|
|
wscr->egl.config = display_get_argb_egl_config(wscr->display);
|
2011-11-17 13:33:06 +04:00
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
if (demo_mode) {
|
|
|
|
struct wl_output *o =
|
|
|
|
output_get_wl_output(display_get_output(display));
|
|
|
|
/* only one instance */
|
|
|
|
wscr->demomode =
|
|
|
|
create_wscreensaver_instance(wscr, o, 400, 300);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-17 13:33:06 +04:00
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
display_set_output_configure_handler(display, handle_output_configure);
|
|
|
|
|
|
|
|
return 0;
|
2011-11-17 13:33:06 +04:00
|
|
|
}
|
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
static void
|
2012-10-11 05:34:26 +04:00
|
|
|
global_handler(struct display *display, uint32_t name,
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
const char *interface, uint32_t version, void *data)
|
|
|
|
{
|
|
|
|
struct wscreensaver *screensaver = data;
|
|
|
|
|
|
|
|
if (!strcmp(interface, "screensaver")) {
|
|
|
|
screensaver->interface =
|
2012-10-11 05:34:26 +04:00
|
|
|
display_bind(display, name, &screensaver_interface, 1);
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-12 05:05:57 +04:00
|
|
|
static const struct weston_option wscreensaver_options[] = {
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "demo", 0, &demo_mode },
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
};
|
|
|
|
|
2011-11-17 13:33:06 +04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct display *d;
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
struct wscreensaver screensaver = { 0 };
|
2011-11-17 13:33:06 +04:00
|
|
|
|
|
|
|
init_frand();
|
|
|
|
|
2014-08-08 23:59:54 +04:00
|
|
|
if (parse_options(wscreensaver_options,
|
|
|
|
ARRAY_LENGTH(wscreensaver_options), &argc, argv) > 1) {
|
|
|
|
printf("Usage: %s [OPTIONS]\n --demo for demo mode\n",
|
|
|
|
argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2012-03-12 05:05:57 +04:00
|
|
|
|
2013-02-21 00:27:49 +04:00
|
|
|
d = display_create(&argc, argv);
|
2011-11-17 13:33:06 +04:00
|
|
|
if (d == NULL) {
|
|
|
|
fprintf(stderr, "failed to create display: %m\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
if (!demo_mode) {
|
2011-11-30 16:45:47 +04:00
|
|
|
/* iterates already known globals immediately */
|
2012-10-11 05:34:26 +04:00
|
|
|
display_set_user_data(d, &screensaver);
|
|
|
|
display_set_global_handler(d, global_handler);
|
protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.
When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.
The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-24 13:34:05 +04:00
|
|
|
if (!screensaver.interface) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"Server did not offer screensaver interface,"
|
|
|
|
" exiting.\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-30 16:45:47 +04:00
|
|
|
if (init_wscreensaver(&screensaver, d) < 0) {
|
|
|
|
fprintf(stderr, "wscreensaver init failed.\n");
|
2011-11-17 13:33:06 +04:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
display_run(d);
|
|
|
|
|
|
|
|
free((void *)progname);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|