main shrub/neuswc / libswc / screen.h
 1/* swc: libswc/screen.h
 2 *
 3 * Copyright (c) 2013, 2014 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_SCREEN_H
25#define SWC_SCREEN_H
26
27#include "primary_plane.h"
28#include "swc.h"
29
30#include <wayland-util.h>
31
32struct output;
33struct pixman_region32;
34
35struct screen_modifier {
36	/**
37	 * Takes the screen geometry and sets 'usable' to the usable region of the
38	 * screen. 'usable' is an already initialized pixman region.
39	 */
40	void (*modify)(struct screen_modifier *modifier,
41	               const struct swc_rectangle *geometry,
42	               struct pixman_region32 *usable);
43
44	struct wl_list link;
45};
46
47struct screen {
48	struct swc_screen base;
49	const struct swc_screen_handler *handler;
50	void *handler_data;
51
52	struct wl_signal destroy_signal;
53	uint8_t id;
54#ifdef ENABLE_DRM
55	uint32_t crtc;
56#endif
57
58	struct {
59		struct primary_plane primary;
60		struct plane *cursor;
61	} planes;
62
63	struct wl_global *global;
64	struct wl_list resources;
65
66	struct wl_list outputs;
67	struct wl_list modifiers;
68	struct wl_list link;
69};
70
71bool
72screens_initialize(void);
73void
74screens_finalize(void);
75
76#ifdef ENABLE_DRM
77struct screen *
78screen_new(uint32_t crtc, struct output *output, struct plane *cursor_plane);
79#else
80struct screen *
81screen_new(struct output *output);
82#endif
83void
84screen_destroy(struct screen *screen);
85
86static inline uint32_t
87screen_mask(struct screen *screen)
88{
89	return 1 << screen->id;
90}
91
92void
93screen_update_usable_geometry(struct screen *screen);
94
95#endif