Skip to content

Deprecation Request: Cursor(Device, ImageData, ImageData, int, int) #462

@ShahzaibIbrahim

Description

@ShahzaibIbrahim

Background

The constructor Cursor(Device, ImageData source, ImageData mask, int hotspotX, int hotspotY) allows creating a cursor by providing a source image and a 1-bit mask to define transparency. This approach requires developers to manually define mask pixels and works reliably only in fixed DPI environments.

With the introduction of multi-monitor DPI support, this constructor produces inconsistent results.

  • Masks do not scale properly when using DPIUtil.autoScaleImageData, leading to visual artifacts.
  • Developers need to handle scaling and mask adjustments manually, which is error-prone.

Recommendation

Deprecate the Cursor(Device, ImageData, ImageData, int, int) constructor.

Instead, recommend using:

Cursor(Device device, ImageDataProvider imageDataProvider, int hotspotX, int hotspotY)

The ImageDataProvider variant:

  • Provides better results with multi-monitor DPI scaling.
  • Allows supplying high-DPI images directly.
  • Avoids manual mask management.

Migration Guidance

  • For new code, use Cursor(Device, ImageDataProvider, int, int).
  • Existing usages of source+mask should be refactored to provide ARGB images via ImageDataProvider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HiDPIA HiDPI-Related Issue or FeatureSWTIssue for SWT

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions