summaryrefslogtreecommitdiffstats
path: root/remoting/client/empty_cursor_filter.h
blob: 03eb347376e8973864618e3c160e7f94db1f1b2b (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
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_CLIENT_EMPTY_CURSOR_FILTER_H_
#define REMOTING_CLIENT_EMPTY_CURSOR_FILTER_H_

#include "base/macros.h"
#include "remoting/protocol/cursor_shape_stub.h"

namespace remoting {

// Returns an empty cursor.
protocol::CursorShapeInfo EmptyCursorShape();

// Returns true of the supplied cursor is empty, i.e. width and/or height <= 0.
bool IsCursorShapeEmpty(const protocol::CursorShapeInfo& cursor_shape);

// Helper that checks whether a cursor has any visible pixels, and resizes
// it down to (0x0) if not.
// TODO(wez): Turn this into a general-purpose cropping filter that both
// client and host can use.
class EmptyCursorFilter : public protocol::CursorShapeStub {
 public:
  explicit EmptyCursorFilter(protocol::CursorShapeStub* cursor_stub);
  ~EmptyCursorFilter() override;

  // protocol::CursorShapeStub interface.
  void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;

  // Replaces the stub to which cursor shapes will be passed-on.
  void set_cursor_stub(protocol::CursorShapeStub* cursor_stub) {
    cursor_stub_ = cursor_stub;
  }

 private:
  protocol::CursorShapeStub* cursor_stub_;

  DISALLOW_COPY_AND_ASSIGN(EmptyCursorFilter);
};

}  // namespace remoting

#endif  // REMOTING_CLIENT_EMPTY_CURSOR_FILTER_H_