swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 5fb73048a0c176fd022e68485c57343153370e23
parent 09023ff8933523d926512b84b01ed1761a92ea6a
Author: Michael Forney <mforney@mforney.org>
Date:   Tue, 22 Jul 2014 17:25:17 -0700

screen: Add wayland global

Diffstat:
Mlibswc/local.mk | 2+-
Mlibswc/screen.c | 49++++++++++++++++++++++++++++++++++++++++++-------
Mlibswc/screen.h | 3+++
Mprotocol/swc.xml | 8++++++++
4 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/libswc/local.mk b/libswc/local.mk @@ -84,8 +84,8 @@ SWC_SHARED_OBJECTS = $(SWC_SOURCES:%.c=%.lo) # Explicitly state dependencies on generated files objects = $(foreach obj,$(1),$(dir)/$(obj).o $(dir)/$(obj).lo) +$(call objects,compositor panel_manager panel screen): protocol/swc-server-protocol.h $(call objects,drm drm_buffer): protocol/wayland-drm-server-protocol.h -$(call objects,panel_manager panel): protocol/swc-server-protocol.h $(call objects,pointer): cursor/cursor_data.h $(dir)/libswc.a: $(SWC_STATIC_OBJECTS) diff --git a/libswc/screen.c b/libswc/screen.c @@ -28,6 +28,7 @@ #include "mode.h" #include "output.h" #include "util.h" +#include "protocol/swc-server-protocol.h" #include <stdlib.h> #include <sys/param.h> @@ -55,6 +56,28 @@ void screens_finalize() screen_destroy(screen); } +static void bind_screen(struct wl_client * client, void * data, + uint32_t version, uint32_t id) +{ + struct screen * screen = data; + struct wl_resource * resource; + + if (version >= 1) + version = 1; + + resource = wl_resource_create(client, &swc_screen_interface, version, id); + + if (!resource) + { + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, NULL, + screen, &swc_remove_resource); + wl_list_insert(&screen->resources, wl_resource_get_link(resource)); +} + struct screen * screen_new(uint32_t crtc, struct swc_output * output) { struct screen * screen; @@ -67,26 +90,36 @@ struct screen * screen_new(uint32_t crtc, struct swc_output * output) if (!(screen = malloc(sizeof *screen))) goto error0; - wl_signal_init(&screen->base.event_signal); - wl_list_init(&screen->outputs); - wl_list_insert(&screen->outputs, &output->link); - wl_list_init(&screen->modifiers); + screen->global = wl_global_create(swc.display, &swc_screen_interface, 1, + screen, &bind_screen); + + if (!screen->global) + { + ERROR("Failed to create screen global\n"); + goto error1; + } if (!framebuffer_plane_initialize(&screen->planes.framebuffer, crtc, output->preferred_mode, &output->connector, 1)) { ERROR("Failed to initialize framebuffer plane\n"); - goto error1; + goto error2; } if (!cursor_plane_initialize(&screen->planes.cursor, crtc, &screen->base.geometry)) { ERROR("Failed to initialize cursor plane\n"); - goto error2; + goto error3; } + wl_signal_init(&screen->base.event_signal); + wl_list_init(&screen->resources); + wl_list_init(&screen->outputs); + wl_list_insert(&screen->outputs, &output->link); + wl_list_init(&screen->modifiers); + view_move(&screen->planes.framebuffer.view, x, 0); screen->base.geometry = screen->planes.framebuffer.view.geometry; screen->base.usable_geometry = screen->base.geometry; @@ -95,8 +128,10 @@ struct screen * screen_new(uint32_t crtc, struct swc_output * output) return screen; - error2: + error3: framebuffer_plane_finalize(&screen->planes.framebuffer); + error2: + wl_global_destroy(screen->global); error1: free(screen); error0: diff --git a/libswc/screen.h b/libswc/screen.h @@ -58,6 +58,9 @@ struct screen struct cursor_plane cursor; } planes; + struct wl_global * global; + struct wl_list resources; + struct wl_list outputs; struct wl_list modifiers; struct wl_list link; diff --git a/protocol/swc.xml b/protocol/swc.xml @@ -22,6 +22,14 @@ SOFTWARE. </copyright> + <interface name="swc_screen" version="1"> + <description summary="an area in which windows may be placed"> + A screen represents an area in which windows may be placed. It + corresponds to one or monitors displaying the same content (in + mirror mode). + </description> + </interface> + <interface name="swc_panel_manager" version="1"> <request name="create_panel"> <arg name="id" type="new_id" interface="swc_panel" />