main neuswc / libswc / surface.h
  1/* swc: surface.h
  2 *
  3 * Copyright (c) 2013 Michael Forney
  4 *
  5 * Permission is hereby granted, free of charge, to any person obtaining a copy
  6 * of this software and associated documentation files (the "Software"), to deal
  7 * in the Software without restriction, including without limitation the rights
  8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9 * copies of the Software, and to permit persons to whom the Software is
 10 * furnished to do so, subject to the following conditions:
 11 *
 12 * The above copyright notice and this permission notice shall be included in
 13 * all copies or substantial portions of the Software.
 14 *
 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 21 * SOFTWARE.
 22 */
 23
 24#ifndef SWC_SURFACE_H
 25#define SWC_SURFACE_H
 26
 27#include "view.h"
 28
 29#include <pixman.h>
 30#include <wayland-server.h>
 31
 32struct subsurface;
 33
 34enum {
 35	SURFACE_COMMIT_ATTACH = (1 << 0),
 36	SURFACE_COMMIT_DAMAGE = (1 << 1),
 37	SURFACE_COMMIT_OPAQUE = (1 << 2),
 38	SURFACE_COMMIT_INPUT = (1 << 3),
 39	SURFACE_COMMIT_FRAME = (1 << 4)
 40};
 41
 42struct surface_state {
 43	struct wld_buffer *buffer;
 44	struct wl_resource *buffer_resource;
 45	struct wl_listener buffer_destroy_listener;
 46
 47	/* The region that needs to be repainted. */
 48	pixman_region32_t damage;
 49
 50	/* The region that is opaque. */
 51	pixman_region32_t opaque;
 52
 53	/* The region that accepts input. */
 54	pixman_region32_t input;
 55
 56	struct wl_list frame_callbacks;
 57
 58	/* subsurface order; double-buffered with surface state. */
 59	struct wl_list subsurfaces_below;
 60	struct wl_list subsurfaces_above;
 61};
 62
 63struct surface {
 64	struct wl_resource *resource;
 65	struct {
 66		struct wl_signal commit;
 67	} signal;
 68
 69	struct surface_state state;
 70
 71	struct {
 72		struct surface_state state;
 73		uint32_t commit;
 74		int32_t x, y;
 75	} pending;
 76
 77	struct view *view;
 78	struct view_handler view_handler;
 79	struct wl_resource *role;
 80	struct wl_listener role_destroy_listener;
 81
 82	struct subsurface *subsurface;
 83	struct wl_list subsurfaces;
 84	bool has_window_geometry;
 85	int32_t window_x, window_y;
 86	int32_t window_width, window_height;
 87	bool window_geometry_applied;
 88};
 89
 90struct surface *
 91surface_new(struct wl_client *client, uint32_t version, uint32_t id);
 92void
 93surface_set_view(struct surface *surface, struct view *view);
 94bool
 95surface_set_role(struct surface *surface, struct wl_resource *role);
 96bool
 97surface_has_buffer(struct surface *surface);
 98void
 99surface_commit_pending(struct surface *surface);
100
101#endif