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>
This commit is contained in:
Pekka Paalanen
2011-11-24 11:34:05 +02:00
parent 12c05b74ad
commit 6e16811e5e
4 changed files with 112 additions and 5 deletions
+6 -1
View File
@@ -70,7 +70,12 @@ smoke_LDADD = $(toolkit_libs)
resizor_SOURCES = resizor.c
resizor_LDADD = $(toolkit_libs)
wscreensaver_SOURCES = wscreensaver.c wscreensaver-glue.c glmatrix.c
wscreensaver_SOURCES = \
wscreensaver.c \
desktop-shell-client-protocol.h \
desktop-shell-protocol.c \
wscreensaver-glue.c \
glmatrix.c
wscreensaver_LDADD = $(toolkit_libs) -lGLU
eventdemo_SOURCES = eventdemo.c
+39 -4
View File
@@ -20,7 +20,7 @@
* OF THIS SOFTWARE.
*/
#include "config.h"
#include "../config.h"
#include "wscreensaver.h"
@@ -34,6 +34,7 @@
#include <wayland-client.h>
#include "desktop-shell-client-protocol.h"
#include "window.h"
extern struct wscreensaver_plugin glmatrix_screensaver;
@@ -45,7 +46,11 @@ static const struct wscreensaver_plugin * const plugins[] = {
const char *progname = NULL;
static int demo_mode;
struct wscreensaver {
struct screensaver *interface;
struct display *display;
/* per output, if fullscreen mode */
@@ -246,21 +251,51 @@ init_wscreensaver(struct wscreensaver *wscr, struct display *display)
return NULL;
}
static void
global_handler(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
struct wscreensaver *screensaver = data;
if (!strcmp(interface, "screensaver")) {
screensaver->interface =
wl_display_bind(display, id, &screensaver_interface);
}
}
static const GOptionEntry option_entries[] = {
{ "demo", 0, 0, G_OPTION_ARG_NONE, &demo_mode,
"Run as a regular application, not a screensaver.", NULL },
{ NULL }
};
int main(int argc, char *argv[])
{
struct display *d;
struct wscreensaver wscr = { 0 };
struct wscreensaver screensaver = { 0 };
const char *msg;
init_frand();
d = display_create(&argc, &argv, NULL);
d = display_create(&argc, &argv, option_entries);
if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n");
return EXIT_FAILURE;
}
msg = init_wscreensaver(&wscr, d);
if (!demo_mode) {
wl_display_add_global_listener(display_get_display(d),
global_handler, &screensaver);
wl_display_roundtrip(display_get_display(d));
if (!screensaver.interface) {
fprintf(stderr,
"Server did not offer screensaver interface,"
" exiting.\n");
return EXIT_FAILURE;
}
}
msg = init_wscreensaver(&screensaver, d);
if (msg) {
fprintf(stderr, "wscreensaver init failed: %s\n", msg);
return EXIT_FAILURE;