1 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3    Copyright (C) 2009-2016 Red Hat, Inc.
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef CURSOR_CHANNEL_CLIENT_H_
20 #define CURSOR_CHANNEL_CLIENT_H_
21 
22 #include "cache-item.h"
23 #include "red-common.h"
24 #include "red-channel-client.h"
25 #include "red-stream.h"
26 #include "cursor-channel.h"
27 #include "utils.hpp"
28 
29 #include "push-visibility.h"
30 
31 struct CursorChannelClientPrivate;
32 
33 class CursorChannelClient final: public CommonGraphicsChannelClient
34 {
35 public:
36     CursorChannelClient(RedChannel *channel,
37                         RedClient *client,
38                         RedStream *stream,
39                         RedChannelCapabilities *caps);
40     void reset_cursor_cache();
41     RedCacheItem* cache_find(uint64_t id);
42     int cache_add(uint64_t id, size_t size);
get_channel()43     CursorChannel* get_channel()
44     {
45         return static_cast<CursorChannel*>(CommonGraphicsChannelClient::get_channel());
46     }
47 
48 protected:
49     virtual void on_disconnect() override;
50     void send_item(RedPipeItem *pipe_item) override;
51     /**
52      * Migrate a client channel from a CursorChannel.
53      * This is the equivalent of RedChannel client migrate callback.
54      */
55     virtual void migrate() override;
56 
57 public:
58     red::unique_link<CursorChannelClientPrivate> priv;
59 };
60 
61 CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor,
62                                                RedClient *client,
63                                                RedStream *stream,
64                                                int mig_target,
65                                                RedChannelCapabilities *caps);
66 
67 enum {
68     RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
69     RED_PIPE_ITEM_TYPE_CURSOR_INIT,
70     RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
71 };
72 
73 #include "pop-visibility.h"
74 
75 #endif /* CURSOR_CHANNEL_CLIENT_H_ */
76