summaryrefslogtreecommitdiff
path: root/chromium/services/ui/ws/operation.h
blob: 9b6abe6425090e188cc34ad729785750954b75ef (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
// 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 SERVICES_UI_WS_OPERATION_H_
#define SERVICES_UI_WS_OPERATION_H_

#include <set>

#include "base/macros.h"
#include "services/ui/common/types.h"

namespace ui {
namespace ws {

class WindowServer;
class WindowTree;

enum class OperationType {
  NONE,
  ADD_TRANSIENT_WINDOW,
  ADD_WINDOW,
  DELETE_WINDOW,
  EMBED,
  RELEASE_CAPTURE,
  REMOVE_TRANSIENT_WINDOW_FROM_PARENT,
  REMOVE_WINDOW_FROM_PARENT,
  REORDER_WINDOW,
  SET_CAPTURE,
  SET_CLIENT_AREA,
  SET_FOCUS,
  SET_WINDOW_BOUNDS,
  SET_WINDOW_OPACITY,
  SET_WINDOW_PREDEFINED_CURSOR,
  SET_WINDOW_PROPERTY,
  SET_WINDOW_VISIBILITY,
};

// This class tracks the currently pending client-initiated operation.
// This is typically used to suppress superfluous notifications generated
// by suboperations in the window server.
class Operation {
 public:
  Operation(WindowTree* tree,
            WindowServer* window_server,
            OperationType operation_type);
  ~Operation();

  ClientSpecificId source_tree_id() const { return source_tree_id_; }

  const OperationType& type() const { return operation_type_; }

  // Marks the tree with the specified id as having been sent a message
  // during the course of |this| operation.
  void MarkTreeAsMessaged(ClientSpecificId tree_id) {
    message_ids_.insert(tree_id);
  }

  // Returns true if MarkTreeAsMessaged(tree_id) was invoked.
  bool DidMessageTree(ClientSpecificId tree_id) const {
    return message_ids_.count(tree_id) > 0;
  }

 private:
  WindowServer* const window_server_;
  const ClientSpecificId source_tree_id_;
  const OperationType operation_type_;

  // See description of MarkTreeAsMessaged/DidMessageTree.
  std::set<ClientSpecificId> message_ids_;

  DISALLOW_COPY_AND_ASSIGN(Operation);
};

}  // namespace ws
}  // namespace ui

#endif  // SERVICES_UI_WS_OPERATION_H_