neuswc

patched neuswc library (tracked)
git clone https://git.daat.foo/neuswc.git
Log | Files | Refs | README | LICENSE

window.h (3477B)


      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 
     33 struct window_pointer_interaction {
     34 	bool active;
     35 	uint32_t serial;
     36 	struct pointer_handler handler, *original_handler;
     37 };
     38 
     39 enum window_mode {
     40 	WINDOW_MODE_STACKED,
     41 	WINDOW_MODE_TILED,
     42 	WINDOW_MODE_FULLSCREEN,
     43 };
     44 
     45 struct 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 
     87 struct 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 
     96 extern struct wl_listener window_enter_listener;
     97 
     98 /* The pointer is over the window as much as over its surface: its handler is
     99  * told, as when the surface is entered. */
    100 void
    101 window_pointer_entered(struct window *window);
    102 
    103 bool
    104 window_initialize(struct window *window, const struct window_impl *impl,
    105                   struct surface *surface);
    106 void
    107 window_finalize(struct window *window);
    108 void
    109 window_manage(struct window *window);
    110 void
    111 window_unmanage(struct window *window);
    112 void
    113 window_set_title(struct window *window, const char *title, size_t length);
    114 void
    115 window_set_app_id(struct window *window, const char *app_id);
    116 void
    117 window_set_parent(struct window *window, struct window *parent);
    118 void
    119 window_set_modal(struct window *window, bool modal);
    120 void
    121 window_begin_move(struct window *window, struct button *button);
    122 void
    123 window_begin_resize(struct window *window, uint32_t edges,
    124                     struct button *button);
    125 
    126 #endif