Browse Source

Add IPC messages and structs for passing draggable regions.

Cheng Zhao 11 years ago
parent
commit
40273cf37d
4 changed files with 46 additions and 0 deletions
  1. 2 0
      atom.gyp
  2. 10 0
      common/api/api_messages.h
  3. 13 0
      common/draggable_region.cc
  4. 21 0
      common/draggable_region.h

+ 2 - 0
atom.gyp

@@ -139,6 +139,8 @@
       'common/api/atom_extensions.h',
       'common/api/object_life_monitor.cc',
       'common/api/object_life_monitor.h',
+      'common/draggable_region.cc',
+      'common/draggable_region.h',
       'common/node_bindings.cc',
       'common/node_bindings.h',
       'common/node_bindings_mac.cc',

+ 10 - 0
common/api/api_messages.h

@@ -7,6 +7,7 @@
 #include <string>
 
 #include "base/values.h"
+#include "common/draggable_region.h"
 #include "content/public/common/common_param_traits.h"
 #include "ipc/ipc_message_macros.h"
 
@@ -15,6 +16,11 @@
 
 #define IPC_MESSAGE_START ShellMsgStart
 
+IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion)
+  IPC_STRUCT_TRAITS_MEMBER(draggable)
+  IPC_STRUCT_TRAITS_MEMBER(bounds)
+IPC_STRUCT_TRAITS_END()
+
 IPC_MESSAGE_ROUTED2(AtomViewHostMsg_Message,
                     std::string /* channel */,
                     ListValue /* arguments */)
@@ -27,3 +33,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1(AtomViewHostMsg_Message_Sync,
 IPC_MESSAGE_ROUTED2(AtomViewMsg_Message,
                     std::string /* channel */,
                     ListValue /* arguments */)
+
+// Sent by the renderer when the draggable regions are updated.
+IPC_MESSAGE_ROUTED1(AtomViewHostMsg_UpdateDraggableRegions,
+                    std::vector<atom::DraggableRegion> /* regions */)

+ 13 - 0
common/draggable_region.cc

@@ -0,0 +1,13 @@
+// Copyright (c) 2012 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.
+
+#include "common/draggable_region.h"
+
+namespace atom {
+
+DraggableRegion::DraggableRegion()
+    : draggable(false) {
+}
+
+}  // namespace atom

+ 21 - 0
common/draggable_region.h

@@ -0,0 +1,21 @@
+// Copyright (c) 2012 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 ATOM_COMMON_DRAGGABLE_REGION_H_
+#define ATOM_COMMON_DRAGGABLE_REGION_H_
+
+#include "ui/gfx/rect.h"
+
+namespace atom {
+
+struct DraggableRegion {
+  bool draggable;
+  gfx::Rect bounds;
+
+  DraggableRegion();
+};
+
+}  // namespace atom
+
+#endif  // ATOM_COMMON_DRAGGABLE_REGION_H_