main neuswc / libswc / window.h
  1/* swc: libswc/window.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_WINDOW_H
 25#define SWC_WINDOW_H
 26
 27#include "pointer.h"
 28#include "swc.h"
 29
 30#include <stdint.h>
 31#include <wayland-server.h>
 32
 33struct window_pointer_interaction {
 34	bool active;
 35	uint32_t serial;
 36	struct pointer_handler handler, *original_handler;
 37};
 38
 39enum window_mode {
 40	WINDOW_MODE_STACKED,
 41	WINDOW_MODE_TILED,
 42	WINDOW_MODE_FULLSCREEN,
 43};
 44
 45struct window {
 46	struct swc_window base;
 47	const struct window_impl *impl;
 48	const struct swc_window_handler *handler;
 49	void *handler_data;
 50
 51	struct compositor_view *view;
 52	struct view_handler view_handler;
 53	bool managed;
 54	unsigned mode;
 55
 56	struct {
 57		struct swc_rectangle geom;
 58		unsigned mode;
 59	} prev;
 60
 61	struct {
 62		struct window_pointer_interaction interaction;
 63		struct {
 64			int32_t x, y;
 65		} offset;
 66
 67		bool pending;
 68		int32_t x, y;
 69		uint32_t last_time;
 70	} move;
 71
 72	struct {
 73		struct window_pointer_interaction interaction;
 74		struct {
 75			int32_t x, y;
 76		} offset;
 77		uint32_t edges;
 78		uint32_t last_time;
 79	} resize;
 80
 81	struct {
 82		bool pending, acknowledged;
 83		uint32_t width, height;
 84	} configure;
 85};
 86
 87struct window_impl {
 88	void (*move)(struct window *window, int32_t x, int32_t y);
 89	void (*configure)(struct window *window, uint32_t width, uint32_t height);
 90	void (*focus)(struct window *window);
 91	void (*unfocus)(struct window *window);
 92	void (*close)(struct window *window);
 93	void (*set_mode)(struct window *window, enum window_mode mode);
 94};
 95
 96extern struct wl_listener window_enter_listener;
 97
 98bool
 99window_initialize(struct window *window, const struct window_impl *impl,
100                  struct surface *surface);
101void
102window_finalize(struct window *window);
103void
104window_manage(struct window *window);
105void
106window_unmanage(struct window *window);
107void
108window_set_title(struct window *window, const char *title, size_t length);
109void
110window_set_app_id(struct window *window, const char *app_id);
111void
112window_set_parent(struct window *window, struct window *parent);
113void
114window_begin_move(struct window *window, struct button *button);
115void
116window_begin_resize(struct window *window, uint32_t edges,
117                    struct button *button);
118
119#endif