Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: ui/base/x/scroll_factory.h

Issue 8907005: Add support for new scroll valuators coming from CMT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup and comments Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/x/scroll_factory.h
diff --git a/ui/base/x/scroll_factory.h b/ui/base/x/scroll_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..d37ee07d6c0877b221aa377ff98e5ba67fb753b7
--- /dev/null
+++ b/ui/base/x/scroll_factory.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 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 UI_BASE_X_SCROLL_FACTORY_H_
+#define UI_BASE_X_SCROLL_FACTORY_H_
+#pragma once
+
+#include <bitset>
+#include <map>
+
+#include "base/memory/singleton.h"
+#include "ui/base/ui_export.h"
+
+typedef struct _XDisplay Display;
+typedef union _XEvent XEvent;
+
+namespace ui {
+
+// A class to support the detection of scroll events, using X11 valuators.
+class UI_EXPORT ScrollFactory {
+ public:
+ // Returns the ScrollFactory singleton.
+ static ScrollFactory* GetInstance();
+
+ // Updates the list of devices.
+ void UpdateDeviceList(Display* display);
+
+ // Returns true if this is a scroll event (a motion event with the necessary
+ // valuators. Also returns the offsets. |x_offset| and |y_offset| can be
+ // NULL.
+ bool GetScrollOffsets(const XEvent& xev, float* x_offset, float* y_offset);
+
+ private:
+ ScrollFactory();
+ ~ScrollFactory();
+ // Requirement for Signleton
Ben Goodger (Google) 2011/12/14 19:01:39 nit: I believe your type definitions have to go be
DaveMoore 2011/12/14 21:26:04 Done.
+ friend struct DefaultSingletonTraits<ScrollFactory>;
+ struct Valuators {
+ int x_scroll;
+ int y_scroll;
+ };
+
+ // A quick lookup table for determining if events from the pointer device
+ // should be processed.
+ static const int kMaxDeviceNum = 128;
+ std::bitset<kMaxDeviceNum> scroll_devices_;
+ std::map<int, Valuators> device_to_valuators_;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_X_SCROLL_FACTORY_H_
« ui/base/events.h ('K') | « ui/base/x/events_x.cc ('k') | ui/base/x/scroll_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698