summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorynovikov@chromium.org <ynovikov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 13:06:42 +0000
committerynovikov@chromium.org <ynovikov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 13:06:42 +0000
commitc41f8269117c1caf53d3c6416364c563e06b2b64 (patch)
treec1438803f7e1215ad61dc8fc3eaee4231540d294 /chromeos
parentfee0d75527b2a9b3e23e017dab06e07d3334045c (diff)
downloadchromium_src-c41f8269117c1caf53d3c6416364c563e06b2b64.zip
chromium_src-c41f8269117c1caf53d3c6416364c563e06b2b64.tar.gz
chromium_src-c41f8269117c1caf53d3c6416364c563e06b2b64.tar.bz2
Configure CTM on touchscreen hotplug.
Subscribe OutputConfigurator to XI_HierarchyChanged events, so it will configure CTM for touchscreens not only when monitor is plugged, but also when touchscreen's USB is plugged. BUG=235861 TEST=Hotplug external touchscreen into link, when external monitor is in external display and mirror modes. Observe correct touches in paint.html Review URL: https://chromiumcodereview.appspot.com/20093003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/display/output_configurator.cc42
-rw-r--r--chromeos/display/output_configurator.h13
2 files changed, 44 insertions, 11 deletions
diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc
index 875513f..92f2953 100644
--- a/chromeos/display/output_configurator.cc
+++ b/chromeos/display/output_configurator.cc
@@ -6,6 +6,7 @@
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/XInput2.h>
#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
@@ -301,22 +302,30 @@ bool OutputConfigurator::Dispatch(const base::NativeEvent& event) {
// Connecting/Disconnecting display may generate multiple
// RRNotify. Defer configuring outputs to avoid
// grabbing X and configuring displays multiple times.
- if (configure_timer_.get()) {
- configure_timer_->Reset();
- } else {
- configure_timer_.reset(new base::OneShotTimer<OutputConfigurator>());
- configure_timer_->Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
- this,
- &OutputConfigurator::ConfigureOutputs);
- }
+ ScheduleConfigureOutputs();
}
}
return true;
}
+base::EventStatus OutputConfigurator::WillProcessEvent(
+ const base::NativeEvent& event) {
+ // XI_HierarchyChanged events are special. There is no window associated with
+ // these events. So process them directly from here.
+ if (configure_display_ && event->type == GenericEvent &&
+ event->xgeneric.evtype == XI_HierarchyChanged) {
+ // Defer configuring outputs to not stall event processing.
+ // This also takes care of same event being received twice.
+ ScheduleConfigureOutputs();
+ }
+
+ return base::EVENT_CONTINUE;
+}
+
+void OutputConfigurator::DidProcessEvent(const base::NativeEvent& event) {
+}
+
void OutputConfigurator::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
@@ -367,6 +376,19 @@ void OutputConfigurator::ConfigureOutputs() {
delegate_->SendProjectingStateToPowerManager(IsProjecting(outputs));
}
+void OutputConfigurator::ScheduleConfigureOutputs() {
+ if (configure_timer_.get()) {
+ configure_timer_->Reset();
+ } else {
+ configure_timer_.reset(new base::OneShotTimer<OutputConfigurator>());
+ configure_timer_->Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
+ this,
+ &OutputConfigurator::ConfigureOutputs);
+ }
+}
+
void OutputConfigurator::NotifyOnDisplayChanged() {
FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged());
}
diff --git a/chromeos/display/output_configurator.h b/chromeos/display/output_configurator.h
index 5285bde..6805efa 100644
--- a/chromeos/display/output_configurator.h
+++ b/chromeos/display/output_configurator.h
@@ -39,7 +39,8 @@ enum OutputState {
// This class interacts directly with the underlying Xrandr API to manipulate
// CTRCs and Outputs.
class CHROMEOS_EXPORT OutputConfigurator
- : public base::MessageLoop::Dispatcher {
+ : public base::MessageLoop::Dispatcher,
+ public base::MessagePumpObserver {
public:
// Information about an output's current state.
struct OutputSnapshot {
@@ -279,6 +280,12 @@ class CHROMEOS_EXPORT OutputConfigurator
// Spurious events will have no effect.
virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
+ // Overridden from base::MessagePumpObserver:
+ virtual base::EventStatus WillProcessEvent(
+ const base::NativeEvent& event) OVERRIDE;
+ virtual void DidProcessEvent(
+ const base::NativeEvent& event) OVERRIDE;
+
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -299,6 +306,10 @@ class CHROMEOS_EXPORT OutputConfigurator
// Configure outputs.
void ConfigureOutputs();
+ // Configure outputs with |kConfigureDelayMs| delay,
+ // so that time-consuming ConfigureOutputs() won't be called multiple times.
+ void ScheduleConfigureOutputs();
+
// Fires OnDisplayModeChanged() event to the observers.
void NotifyOnDisplayChanged();