summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@intel.com>2013-01-09 19:55:08 -0200
committerTiago Vignatti <tiago.vignatti@intel.com>2013-03-25 19:04:57 -0300
commitb76fb1add1081cf8fc848d08e25de1c31ea61df5 (patch)
tree68871a0d38604115610121a684107c239549eaf4
downloadgraynard-b76fb1add1081cf8fc848d08e25de1c31ea61df5.tar.gz
graynard-b76fb1add1081cf8fc848d08e25de1c31ea61df5.zip
Initial commit
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
-rw-r--r--COPYING0
-rw-r--r--Makefile.am1
-rw-r--r--README0
-rwxr-xr-xautogen.sh9
-rw-r--r--configure.ac32
-rw-r--r--protocol/Makefile.am1
-rw-r--r--protocol/README.txt5
-rw-r--r--protocol/desktop-shell.xml119
-rw-r--r--shell/Makefile.am18
-rw-r--r--shell/gtk-shell.c143
10 files changed, 328 insertions, 0 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/COPYING
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..d7c539d
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = shell
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..916169a
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+(
+ cd "$srcdir" &&
+ autoreconf --force -v --install
+) || exit
+test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..daa0fcd
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,32 @@
+AC_PREREQ([2.64])
+AC_INIT([weston],
+ [1.0.0],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=weston],
+ [weston],
+ [http://wayland.freedesktop.org/])
+
+
+AC_CONFIG_HEADERS([config.h])
+
+AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
+
+AM_SILENT_RULES([yes])
+
+# Check for programs
+AC_PROG_CC
+
+# Initialize libtool
+LT_PREREQ([2.2])
+LT_INIT([disable-static])
+
+PKG_PROG_PKG_CONFIG()
+
+PKG_CHECK_MODULES([GTK], [wayland-client >= 1.0.2 gtk+-3.0 >= 3.7])
+
+WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])
+
+AC_CONFIG_FILES([Makefile
+ shell/Makefile
+ protocol/Makefile
+ ])
+AC_OUTPUT
diff --git a/protocol/Makefile.am b/protocol/Makefile.am
new file mode 100644
index 0000000..ff9219a
--- /dev/null
+++ b/protocol/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = desktop-shell.xml
diff --git a/protocol/README.txt b/protocol/README.txt
new file mode 100644
index 0000000..242d1b9
--- /dev/null
+++ b/protocol/README.txt
@@ -0,0 +1,5 @@
+desktop.shell.xml is a straight copy of the one in freedesktop's weston and we
+want to use the same version containing there:
+
+ "protocol: XML files need to be installed and discoverable"
+ https://bugs.freedesktop.org/show_bug.cgi?id=55183
diff --git a/protocol/desktop-shell.xml b/protocol/desktop-shell.xml
new file mode 100644
index 0000000..2b6afbd
--- /dev/null
+++ b/protocol/desktop-shell.xml
@@ -0,0 +1,119 @@
+<protocol name="desktop">
+
+ <interface name="desktop_shell" version="1">
+ <description summary="create desktop widgets and helpers">
+ Traditional user interfaces can rely on this interface to define the
+ foundations of typical desktops. Currently it's possible to set up
+ background, panels and locking surfaces.
+ </description>
+
+ <request name="set_background">
+ <arg name="output" type="object" interface="wl_output"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="set_panel">
+ <arg name="output" type="object" interface="wl_output"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="set_lock_surface">
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="unlock"/>
+
+ <request name="set_grab_surface">
+ <description summary="set grab surface">
+ The surface set by this request will receive a fake
+ pointer.enter event during grabs at position 0, 0 and is
+ expected to set an appropriate cursor image as described by
+ the grab_cursor event sent just before the enter event.
+ </description>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <!-- We'll fold most of wl_shell into this interface and then
+ they'll share the configure event. -->
+ <event name="configure">
+ <arg name="edges" type="uint"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </event>
+
+ <event name="prepare_lock_surface">
+ <description summary="tell the client to create, set the lock surface">
+ Tell the shell we want it to create and set the lock surface, which is
+ a GUI asking the user to unlock the screen. The lock surface is
+ announced with 'set_lock_surface'. Whether or not the shell actually
+ implements locking, it MUST send 'unlock' request to let the normal
+ desktop resume.
+ </description>
+ </event>
+
+ <event name="grab_cursor">
+ <description summary="tell client what cursor to show during a grab">
+ This event will be sent immediately before a fake enter event on the
+ grab surface.
+ </description>
+ <arg name="cursor" type="uint"/>
+ </event>
+
+ <enum name="cursor">
+ <entry name="none" value="0"/>
+
+ <entry name="resize_top" value="1"/>
+ <entry name="resize_bottom" value="2"/>
+
+ <entry name="arrow" value="3"/>
+
+ <entry name="resize_left" value="4"/>
+ <entry name="resize_top_left" value="5"/>
+ <entry name="resize_bottom_left" value="6"/>
+
+ <entry name="move" value="7"/>
+
+ <entry name="resize_right" value="8"/>
+ <entry name="resize_top_right" value="9"/>
+ <entry name="resize_bottom_right" value="10"/>
+
+ <entry name="busy" value="11"/>
+ </enum>
+ </interface>
+
+ <interface name="screensaver" version="1">
+ <description summary="interface for implementing screensavers">
+ Only one client can bind this interface at a time.
+ </description>
+
+ <request name="set_surface">
+ <description summary="set the surface type as a screensaver">
+ A screensaver surface is normally hidden, and only visible after an
+ idle timeout.
+ </description>
+
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="output" type="object" interface="wl_output"/>
+ </request>
+
+ </interface>
+
+ <interface name="input_panel" version="1">
+ <description summary="interface for implementing keyboards">
+ Only one client can bind this interface at a time.
+ </description>
+
+ <request name="set_surface">
+ <description summary="set the surface type as a keyboard">
+ A keybaord surface is only shown, when a text model is active
+ </description>
+
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="output" type="object" interface="wl_output"/>
+ </request>
+
+ </interface>
+
+
+</protocol>
diff --git a/shell/Makefile.am b/shell/Makefile.am
new file mode 100644
index 0000000..8ca72cf
--- /dev/null
+++ b/shell/Makefile.am
@@ -0,0 +1,18 @@
+libexec_PROGRAMS = weston-desktop-shell
+
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(CLIENT_CFLAGS) $(GTK_CFLAGS)
+
+weston_desktop_shell_SOURCES = \
+ gtk-shell.c \
+ desktop-shell-client-protocol.h \
+ desktop-shell-protocol.c
+weston_desktop_shell_LDADD = $(GTK_LIBS)
+
+BUILT_SOURCES = \
+ desktop-shell-client-protocol.h \
+ desktop-shell-protocol.c
+
+CLEANFILES = $(BUILT_SOURCES)
+
+@wayland_scanner_rules@
diff --git a/shell/gtk-shell.c b/shell/gtk-shell.c
new file mode 100644
index 0000000..89fa956
--- /dev/null
+++ b/shell/gtk-shell.c
@@ -0,0 +1,143 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdkwayland.h>
+
+#include "desktop-shell-client-protocol.h"
+
+gchar *filename = "notfound.png";
+
+struct desktop {
+ struct wl_display *display;
+ struct wl_registry *registry;
+ struct desktop_shell *shell;
+ struct wl_output *output;
+ struct wl_surface *surface;
+
+ GdkDisplay *gdk_display;
+ GdkWindow *gdk_window;
+ GtkWidget *widget;
+};
+
+static void
+desktop_shell_configure(void *data,
+ struct desktop_shell *desktop_shell,
+ uint32_t edges,
+ struct wl_surface *surface,
+ int32_t width, int32_t height)
+{
+ struct desktop *desktop = wl_surface_get_user_data(surface);
+
+ gtk_window_resize(GTK_WINDOW(desktop->widget), width, height);
+}
+
+static void
+desktop_shell_prepare_lock_surface(void *data,
+ struct desktop_shell *desktop_shell)
+{
+}
+
+static void
+desktop_shell_grab_cursor(void *data, struct desktop_shell *desktop_shell,
+ uint32_t cursor)
+{
+}
+
+static const struct desktop_shell_listener listener = {
+ desktop_shell_configure,
+ desktop_shell_prepare_lock_surface,
+ desktop_shell_grab_cursor
+};
+
+static void
+background_create(struct desktop *desktop)
+{
+ GtkWidget *image;
+
+ desktop->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ /* XXX: this is actually not working */
+ image = gtk_image_new_from_file(filename);
+
+ gtk_container_add (GTK_CONTAINER (desktop->widget), image);
+
+ gtk_window_set_title(GTK_WINDOW(desktop->widget), "gtk shell");
+ gtk_window_set_decorated(GTK_WINDOW(desktop->widget), FALSE);
+ gtk_widget_realize(desktop->widget);
+ desktop->gdk_window = gtk_widget_get_window(desktop->widget);
+
+ gdk_wayland_window_set_use_custom_surface(desktop->gdk_window);
+
+ desktop->surface =
+ gdk_wayland_window_get_wl_surface(desktop->gdk_window);
+
+ wl_surface_set_user_data(desktop->surface, desktop);
+ desktop_shell_set_background(desktop->shell, desktop->output,
+ desktop->surface);
+
+ gtk_widget_show_all(desktop->widget);
+}
+
+static void
+registry_handle_global(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface, uint32_t version)
+{
+ struct desktop *d = data;
+
+ if (!strcmp(interface, "desktop_shell")) {
+ d->shell = wl_registry_bind(registry, name,
+ &desktop_shell_interface, 1);
+ desktop_shell_add_listener(d->shell, &listener, d);
+ } else if (!strcmp(interface, "wl_output")) {
+
+ /* TODO: create multiple outputs */
+ d->output = wl_registry_bind(registry, name,
+ &wl_output_interface, 1);
+ }
+}
+
+static void
+registry_handle_global_remove(void *data, struct wl_registry *registry,
+ uint32_t name)
+{
+}
+
+static const struct wl_registry_listener registry_listener = {
+ registry_handle_global,
+ registry_handle_global_remove
+};
+
+int
+main(int argc, char *argv[])
+{
+ struct desktop *desktop;
+
+ gtk_init(&argc, &argv);
+
+ desktop = malloc(sizeof *desktop);
+ desktop->output = NULL;
+ desktop->shell = NULL;
+
+ desktop->gdk_display = gdk_display_get_default();
+ desktop->display =
+ gdk_wayland_display_get_wl_display(desktop->gdk_display);
+ if (desktop->display == NULL) {
+ fprintf(stderr, "failed to get display: %m\n");
+ return -1;
+ }
+
+ desktop->registry = wl_display_get_registry(desktop->display);
+ wl_registry_add_listener(desktop->registry,
+ &registry_listener, desktop);
+
+ /* Wait until we have been notified about the compositor and shell
+ * objects */
+ while (!desktop->output || !desktop->shell)
+ wl_display_roundtrip (desktop->display);
+
+ background_create(desktop);
+ gtk_main();
+
+ return EXIT_SUCCESS;
+}