summaryrefslogtreecommitdiff
path: root/src/wayland/meta-wayland-surface.h
blob: e0886536e41e52655c36523589bad1778654dc3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Copyright (C) 2013 Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#ifndef META_WAYLAND_SURFACE_H
#define META_WAYLAND_SURFACE_H

#include <wayland-server.h>
#include <xkbcommon/xkbcommon.h>
#include <clutter/clutter.h>

#include <glib.h>
#include <cairo.h>

#include <meta/meta-cursor-tracker.h>
#include "meta-wayland-types.h"
#include "meta-surface-actor.h"

struct _MetaWaylandBuffer
{
  struct wl_resource *resource;
  struct wl_signal destroy_signal;
  struct wl_listener destroy_listener;

  CoglTexture *texture;
  uint32_t ref_count;
};

typedef struct
{
  /* wl_surface.attach */
  gboolean newly_attached;
  MetaWaylandBuffer *buffer;
  struct wl_listener buffer_destroy_listener;
  int32_t dx;
  int32_t dy;

  /* wl_surface.damage */
  cairo_region_t *damage;

  cairo_region_t *input_region;
  cairo_region_t *opaque_region;

  /* wl_surface.frame */
  struct wl_list frame_callback_list;

  gboolean frame_extents_changed;
  GtkBorder frame_extents;
} MetaWaylandDoubleBufferedState;

typedef struct
{
  struct wl_resource *resource;
} MetaWaylandSurfaceExtension;

struct _MetaWaylandSurface
{
  struct wl_resource *resource;
  MetaWaylandCompositor *compositor;
  MetaSurfaceActor *surface_actor;
  MetaWindow *window;
  MetaWaylandSurfaceExtension xdg_surface;
  MetaWaylandSurfaceExtension xdg_popup;
  MetaWaylandSurfaceExtension wl_shell_surface;
  MetaWaylandSurfaceExtension gtk_surface;
  MetaWaylandSurfaceExtension subsurface;

  MetaWaylandBuffer *buffer;
  struct wl_listener buffer_destroy_listener;

  GList *subsurfaces;

  struct {
    MetaWaylandSurface *parent;
    struct wl_listener parent_destroy_listener;

    gboolean synchronous;
    MetaWaylandDoubleBufferedState pending_surface_state;

    int32_t pending_x;
    int32_t pending_y;
    gboolean pending_pos;
    GSList *pending_placement_ops;
  } sub;

  uint32_t state_changed_serial;

  /* All the pending state, that wl_surface.commit will apply. */
  MetaWaylandDoubleBufferedState pending;
};

void                meta_wayland_init_shell     (MetaWaylandCompositor *compositor);

MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *compositor,
						 struct wl_client      *client,
						 guint32                id,
						 guint32                version);

void                meta_wayland_surface_make_toplevel (MetaWaylandSurface *surface);
void                meta_wayland_surface_window_unmanaged (MetaWaylandSurface *surface);

void                meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
							   int                 width,
							   int                 height);
void                meta_wayland_surface_send_maximized (MetaWaylandSurface *surface);
void                meta_wayland_surface_send_unmaximized (MetaWaylandSurface *surface);
void                meta_wayland_surface_send_fullscreened (MetaWaylandSurface *surface);
void                meta_wayland_surface_send_unfullscreened (MetaWaylandSurface *surface);

void                meta_wayland_surface_activated (MetaWaylandSurface *surface);
void                meta_wayland_surface_deactivated (MetaWaylandSurface *surface);

void                meta_wayland_surface_ping (MetaWaylandSurface *surface,
                                               guint32             serial);
void                meta_wayland_surface_delete (MetaWaylandSurface *surface);

void                meta_wayland_surface_popup_done (MetaWaylandSurface *surface);


#endif