Add device input and form-factor APIs (pointer detail, mouse buttons, wheel, stylus, foldables)#5309
Conversation
|
Developer Guide build artifacts are available for download from this workflow run:
Developer Guide quality checks: |
|
Compared 11 screenshots: 11 matched. |
Cloudflare Preview
|
|
Compared 139 screenshots: 139 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
|
Compared 135 screenshots: 135 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 131 screenshots: 131 matched. |
|
Compared 137 screenshots: 137 matched. |
|
Compared 137 screenshots: 137 matched. |
|
Compared 137 screenshots: 137 matched. Benchmark Results
Detailed Performance Metrics
|
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
|
Compared 134 screenshots: 134 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
|
Compared 138 screenshots: 138 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
|
Compared 136 screenshots: 136 matched. |
f60c478 to
0c52958
Compare
✅ ByteCodeTranslator Quality ReportTest & Coverage
Benchmark Results
Static Analysis
Generated automatically by the PR CI workflow. |
|
Compared 135 screenshots: 135 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 135 screenshots: 135 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 214 screenshots: 214 matched. |
… wheel, stylus, foldables) Adds cross-platform APIs for device-specific input and form factors that were previously missing, all additive and backward compatible with safe defaults: - PointerEvent: rich pointer snapshot (button, pointer type, pressure, tilt, contact size, modifiers, hover) via ActionEvent.getPointerEvent() and polling accessors on CN/Display. - Multi-button mice: button constants/mask plus Component.addContextMenuListener (right click and long press). Wired in JavaSE/Android/iOS. - Mouse wheel: WheelEvent and Component.addMouseWheelListener; horizontal and precise/trackpad deltas. iOS trackpad/Magic Mouse/wheel routed through the same pipeline so WheelEvent is one universal scroll-gesture API. - Stylus/pen: pressure, tilt and eraser via Component.addStylusListener; Android getToolType/getPressure/AXIS_TILT and iOS Apple Pencil force/altitude/azimuth. - Foldables: DevicePosture (posture, hinge orientation, fold bounds) and Display.addPostureListener. Android reads androidx.window through reflection, added only when android.foldableSupport=true. The JavaSE simulator can drive a simulated posture. - Desktop windowing / external displays: isDesktopMode, getDisplayCount, isExternalDisplayConnected. Pointer metadata follows the existing isShiftKeyDown() precedent (current state on the implementation plus a dispatch-time snapshot) rather than threading through the EDT event queue. Device-input listeners are dispatched from the Form so they work uniformly even for components that override the pointer methods. Docs: docs/developer-guide/Device-Input-And-Form-Factors.asciidoc. Tests: PointerEventTest, WheelEventTest, PointerMetadataTest, DevicePostureTest, DeviceInputListenersTest in maven/core-unittests (full suite green, 3676 tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ess, LanguageTool terms) Fix the 10 Vale alerts (contractions, wordiness, quote punctuation) in the new Device-Input-And-Form-Factors chapter and accept-list the technical terms foldable(s), bitmask and DeX for LanguageTool. Vale now reports 0 alerts locally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use eager final initialization for the DevicePosture singleton instead of unsynchronized lazy init. SpotBugs runs only on the JDK 8 build-test job, so this surfaced only there. Verified locally: spotbugs BugInstance size is 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…iedName) Add @OverRide to PointerEvent.toString() and the postureChanged Runnable; import PointerEvent in Display and Form and use the short name; use the already-imported ActionListener short name in CN. The PMD check runs as part of the JDK 8 build-test job. Verified locally: generate-quality-report.py reports no forbidden PMD violations and the device-input unit tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cOS trackpad gestures, watch/tv input - Simulator: add a Simulate -> Foldable menu (enable, posture, fold orientation, hinge angle) so foldable posture is exercised from the UI, not an internal API. Reworked the developer guide to point at the menu and drop implementation details. - Core: add a rotation (twist) gesture callback Component.rotation(float) parallel to pinch, plus Display.fireMagnifyGesture / fireRotationGesture dispatch for native gesture recognizers. - JavaScriptPort: capture mouse button + pointer type metadata; route the wheel through WheelEvent so the browser uses the same universal scroll-gesture API. - Win32 + Linux ports: report pointer type MOUSE on pointer events (the native event protocol does not yet carry mouse buttons; that needs a native protocol extension). - macOS / Mac Catalyst: add UIPinchGestureRecognizer (magnify) and UIRotationGestureRecognizer (rotate) trackpad gestures, scoped to Catalyst so they do not double-apply the existing iOS multi-touch pinch. Verified the pointer-metadata / scroll path is correct for Catalyst. - Apple Watch: route the Digital Crown through the universal wheel pipeline (WheelEvent + scroll) instead of a synthetic press/drag/release. - Apple TV: map the Siri Remote (arrows, select, menu, play/pause) through the key system. Tests: add a gesture-dispatch test; full device-input suite green (25 tests). iOS port + app + arm64 Xcode link verified. The android.foldableSupport AndroidGradleBuilder change is mirrored to the cloud build daemon (codenameone/BuildDaemon#144). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The cn1-local-workspace profile (active when the website CI builds the JavaScript initializr with -Dcn1.localWorkspace=true) was pinned to the released 7.0.255 core despite its comment saying it builds against repo HEAD, so the repo's JavaScript port source was compiled against the released core. That broke the moment the JS port used a new core API (PointerEvent). Align it with the repo snapshot version and with the cn1playground / skindesigner local-workspace profiles, which already use 8.0-SNAPSHOT. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e code The new pointer/gesture native code referenced UIKit types that do not exist on every Apple platform, breaking the tvOS and watchOS targets: - UIPinchGestureRecognizer / UIRotationGestureRecognizer are unavailable on tvOS. The cn1HandlePinch:/cn1HandleRotation: method signatures exposed those types unconditionally (only the bodies sat behind #if TARGET_OS_MACCATALYST), so the tvOS target failed to compile. Wrap the whole handler methods in the Mac Catalyst guard; their only callers are already Catalyst-only. - UITouch is unavailable on watchOS. The cn1CapturePointerMetadata declaration and definition (UITouch* parameter) were at file scope, breaking the watchOS target. Guard both with #if !TARGET_OS_WATCH; every caller is already inside a !TARGET_OS_WATCH region. Verified locally: HelloCodenameOneTV (appletvsimulator), HelloCodenameOneWatch (watchsimulator) and HelloCodenameOne (iphonesimulator) all BUILD SUCCEEDED. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c36bbb8 to
75a323a
Compare
… richer JS button detail Earlier the Windows and Linux ports only forwarded the left mouse button and hard-coded every pointer event to BUTTON_PRIMARY / TYPE_MOUSE, and isTouchDevice() returned a constant false. This wires the device-input APIs through to the real native input on both desktop ports. Protocol: the pointer event's otherwise-unused key field now carries a button bitmask (mirrors PointerEvent.MASK_*) plus high-bit touch/pen flags, decoded by the Java drain into setPointerEventMetadata. No event-struct change. Windows (cn1_windows_window.cpp): - Handle WM_RBUTTONDOWN/UP, WM_MBUTTONDOWN/UP, WM_XBUTTONDOWN/UP (right, middle, back, forward); previously only the left button existed. - WM_MOUSEMOVE drags carry the held-button mask from the MK_* flags. - Mouse capture is held while any button is down, released on the last up. - Touch / pen promoted to mouse messages are tagged via GetMessageExtraInfo so the event reports TYPE_TOUCH / TYPE_STYLUS. - isTouchDevice() via GetSystemMetrics(SM_DIGITIZER), guarded for older SDKs. Linux (cn1_linux_window.c): - Forward GdkEventButton.button (was dropped); drag works for any button via the GdkEvent state mask (was left-button only). - Real GDK_TOUCH_* handler drives the pointer with TYPE_TOUCH; touchscreen-sourced button/motion events are dropped to avoid double dispatch. - isTouchDevice() enumerates the default seat for a GDK_SOURCE_TOUCHSCREEN device. JavaScript (HTML5Implementation.java): - applyMouseMetadata handles DOM buttons 3/4 (back/forward), uses the DOM buttons bitmask for the held-button mask during a drag, and forwards keyboard modifiers. - Replace the deprecated new Character()/new Integer() char/string width cache boxing with autoboxing. Docs updated for desktop/browser button support and touch-laptop TYPE_TOUCH/STYLUS. Verified: maven/windows and maven/linux Java compile against freshly built core. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Routes desktop trackpad / touch gesture recognizers to the same Display.fireMagnifyGesture / fireRotationGesture hooks the macOS trackpad and the mobile two-finger pinch already drive, so a Component pinch(float) / rotation(float) override now fires on Windows and Linux too. Protocol: two new event types (CN1_EVENT_PINCH / CN1_EVENT_ROTATE) carry the incremental scale multiplier / radians as a fixed-point int (1/10000 units) in the key field; the Java drain divides and dispatches. Windows (cn1_windows_window.cpp): handle WM_GESTURE GID_ZOOM and GID_ROTATE via GetGestureInfo, forwarding the incremental scale (from the finger distance) and incremental radians (from GID_ROTATE_ANGLE_FROM_ARGUMENT). Guarded with #ifdef WM_GESTURE so the port still builds against an older SDK target. (A Windows precision touchpad usually reports a pinch as control plus wheel instead, which already flows through the universal WheelEvent API.) Linux (cn1_linux_window.c): handle GDK_TOUCHPAD_PINCH (libinput touchpad gestures) through the generic event signal with GDK_TOUCHPAD_GESTURE_MASK. scale is cumulative from the gesture begin so the incremental multiplier is forwarded; angle_delta is already a per-event delta in degrees, forwarded as incremental radians. This gives full touchpad pinch and rotate on Linux. Docs updated for the desktop trackpad gesture coverage. Verified: maven/windows and maven/linux Java compile against freshly built core. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Adds the cross-platform device-input and form-factor APIs that Codename One was missing: rich pointer detail (mouse buttons, pen pressure/tilt, pointing-device type), a universal mouse-wheel/trackpad event, foldable device posture, and desktop-windowing / multi-display awareness. Everything is additive and backward compatible — every value has a safe default, so existing apps are unaffected and code written against the new APIs runs everywhere.
What's included
PointerEvent— immutable snapshot: button, button mask, pointer type (touch/mouse/stylus/eraser), pressure, tilt, contact size, modifiers, hover. Read it fromActionEvent.getPointerEvent()or pollCN/Display(getPointerButton,getPointerPressure,getPointerType,isStylusPointer, …).Component.addContextMenuListener(fires on right-click and long-press). Wired in JavaSE, Android (getButtonState), iOS.WheelEvent+Component.addMouseWheelListener(consume to suppress scroll), horizontal scroll, and apreciseflag for trackpads. iOS trackpad / Magic Mouse / wheel are captured natively (UIPanGestureRecognizer) and routed through the samepointerWheelMovedpipeline, soWheelEventis one scroll-gesture API across JavaSE/Android/iOS.Component.addStylusListener; AndroidgetToolType/getPressure/AXIS_TILT, iOS Apple Pencilforce/altitudeAngle/azimuthAngle.DevicePosture(posture, hinge orientation, fold/occlusion bounds) +Display.addPostureListener. Android readsandroidx.windowthrough reflection, pulled in only whenandroid.foldableSupport=true(zero weight otherwise). The JavaSE simulator can drive a simulated posture for testing.isDesktopMode(DeX/Stage Manager),getDisplayCount,isExternalDisplayConnected.Design notes
isShiftKeyDown()precedent — current state on the implementation plus a dispatch-time snapshot — rather than threading through the hot EDT event queue.Form(the single chokepoint) so they work even for components likeButtonthat override the pointer methods without callingsuper.Docs
docs/developer-guide/Device-Input-And-Form-Factors.asciidoc(registered in the guide).Tests / validation
maven/core-unittests:PointerEventTest,WheelEventTest,PointerMetadataTest,DevicePostureTest,DeviceInputListenersTest. Full suite green: 3676 tests, 0 failures.DeviceInputDemo+DeviceInputApiTest).🤖 Generated with Claude Code