Closed Bug 503042 Opened 15 years ago Closed 15 years ago

Implement a way to detect a touch enabled device

Categories

(Core :: Widget: Win32, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2b1

People

(Reporter: Felipe, Assigned: Felipe)

References

(Depends on 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(3 files, 4 obsolete files)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5
Build Identifier: 

To be able to tailor the behavior and appearance of Firefox for a touch based interactions (e.g. increase target area or the size of elements), we need to implement a way to detect if we're running on a touch enabled device so we can apply certain modifications only under this condition.

The initial approach will be to create to create a new boolean flag for the :-moz-system-metric pseudo CSS selector, for example :-moz-system-metric(windows-touch).

Patch coming.

Reproducible: Always
Blocks: 488715
This patch seems to work. Gonna test more soon. It still needs more considerations on some parts, and some polish here and there that I'll be doing soon but I think that it should already be valuable to post it here in the current state. 

(To create it I followed the same structure from the patch on bug 426660)
Attached file Simple test case (obsolete) —
A simple test case to check if the detection is working via the :-moz-system-metric(windows-touch) CSS selector
I suggest we use touch or perhaps touch-device instead of windows-touch so other platforms can implement similar functionality.
+/*
+ * Gesture System Metrics
+ */
+#define SM_DIGITIZER         94

I'd move these up to the top of the header. Also are these defined in the win7 sdk? If so, you'll also want to ifndef the block so that when these defines are exposed through the sdk, this won't break the build.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: unspecified → Trunk
New version addressing comments above. I've changed the token from windows-touch to touch-enabled. Also made the #defines conditional to an #ifdef

No review request yet because we're figuring out if there's a better way to detect a touch device (because this one detects the presence of the input service, not taking into account if there's actually such device attached)
Assignee: nobody → felipc
Attachment #387420 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attached file Test case for selector
Updating test case to reflect new token name
Attachment #387421 - Attachment is obsolete: true
Blocks: 503889
Is there any way to get this working on non-windows based touchscreen devices? Fennec would like some of these features too.
I suspect it is but I also suspect it would need to be a separate implementation since this is for Win7 touch. The way this is implemented should definitely take into account other detection routines such as the ones needed for Fennec
Adding new detection routines here should be straightforward. Note that this detection is currently only for setting the CSS selector though. We may also want to change from a boolean value to a integer value on return so we can detect different cases if that's needed (different devices or different forms of input for example)
Small update on the patch, removing a leftover printf and updating an #ifdef with Robert's suggestion.

Now we've confirmed that the API we are using to detect the touch device is indeed the correct, and the problem we saw before was due to a non plug-and-play driver, so this patch should be correct by now.
Attachment #387997 - Attachment is obsolete: true
Oops sorry for the email, forgot to add that this patch doesn't consider a pen-only device as touch enabled. It only considers if there is actual finger touch support*. We can easily change that if wanted. This was mainly because the pen just simulates a mouse, while hand touch brings other interaction considerations.

* Checking if NID_INTERNAL_TOUCH or NID_EXTERNAL_TOUCH is reported. To add pen we would just check NID_INTERNAL_PEN or NID_EXTERNAL_PEN as well
>Oops sorry for the email, forgot to add that this patch doesn't consider a
>pen-only device as touch enabled. It only considers if there is actual finger
>touch support

yeah, I think this makes sense, especially if we start to make targets finger sized based on the physical size of the screen (assuming we can get this information from the system).
Comment on attachment 389056 [details] [diff] [review]
:-moz-system-metric(touch-enabled) rev3

Vlad, you were the reviewer for a similar patch which I took as a base for this one, so I'm requesting review here as well.
Attachment #389056 - Flags: review?(vladimir)
Attachment #389056 - Flags: superreview?(dbaron)
Comment on attachment 389056 [details] [diff] [review]
:-moz-system-metric(touch-enabled) rev3

David, this adds supports for :-moz-system-metric(touch-enabled), which we would like to use to style things differently on devices with touch support (currently for win7 only)
Comment on attachment 389056 [details] [diff] [review]
:-moz-system-metric(touch-enabled) rev3

>+/*
>+ * Gesture System Metrics
>+ */
>+#ifndef SM_DIGITIZER
>+#define SM_DIGITIZER         94
>+#define TABLET_CONFIG_NONE   0x00000000
>+#define NID_INTEGRATED_TOUCH 0x00000001
>+#define NID_EXTERNAL_TOUCH   0x00000002
>+#define NID_INTEGRATED_PEN   0x00000004
>+#define NID_EXTERNAL_PEN     0x00000008
>+#define NID_MULTI_INPUT      0x00000040
>+#define NID_READY            0x00000080
>+#endif

It might be good to have a comment saying where these constants come from.

Also, given this has #define SM_DIGITIZER, does the part in nsLookAndFeel.cpp need the #ifdef?  It seems that by that point it will always be defined.


sr=dbaron.  Sorry for the delay.
Attachment #389056 - Flags: superreview?(dbaron) → superreview+
sorry for previous attachment, I hit Enter before filing the details

> Also, given this has #define SM_DIGITIZER, does the part in nsLookAndFeel.cpp
> need the #ifdef?  It seems that by that point it will always be defined.

That was there because after bug 506197 gets done SM_DIGITIZER won't be manually defined at the .h anymore. Talking with Rob Strong I'm changing this for #ifndef WINCE which will work better

Only diff between these patches is at widget/src/windows/nsLookAndFeel.cpp:
-#if defined(SM_DIGITIZER)
+#ifndef WINCE
Attachment #393635 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Keywords: dev-doc-needed
Target Milestone: --- → mozilla1.9.2b1
We should not be evangelizing -moz-system-metric for use on Web sites. A media query value is the way to go for Web content.
Blocks: 522149
Is there a media query value for this?
with my CSS WG co-chair hat on, I just do not understand why this became a
functional pseudo-class and not an extension to CSS Media Queries.
And I really regret it did not become a Media Query **before** the article
on hacks.mozilla.org.
IMHO, this should have never landed as a pseudo-class...
How hard would it be to add a media query for it? I don't know the process behind making that happen, but the sooner it happens, the better for everyone.
This was originally implemented to make adjustments on the Firefox chrome only  (the changes made on bug 503889).

The fact that it happily works on webpages too is how it got documented, but it's still a -moz extension. I've filed bug 522149 to make this a media query.
-moz-system-metric(touch-enabled) reports wrong. I use a Dell XT2 Tablet and
have the touch input disabled (Control Panel, Pen and Touch, Touch, "Use your
finger as an input device" unchecked), so only the pen can be used.
Second the property should be monitor-dependent. Only the laptops integrated
monitor is touch/pen capable, not an external monitor.

This property should be divided into touch-enabled, pen-enabled, etc...?
(In reply to comment #25)
-> Bug 541242
Depends on: 541242
Depends on: 541386
Blocks: 548100
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: