Drawpile icon indicating copy to clipboard operation
Drawpile copied to clipboard

(MacOS Catalina) Improved Sidecar optimizations

Open Charmandrigo opened this issue 6 years ago • 6 comments

Apple introduced a feature on MacOS Catalina called Sidecar, allows using an iPad pro as a drawing tablet. a few optimizations that could be added to Drawpile is adding specific drawpile shortcuts to the touchbar feature, as well as support of iPad gestures and Tablet Events. https://www.apple.com/macos/catalina/docs/Sidecar_Tech_Brief_Oct_2019.pdf

Charmandrigo avatar Oct 30 '19 18:10 Charmandrigo

Interesting. To implement this, I will need help from someone with an iPad pro (and mac development experience,) since I don't have one myself.

callaa avatar Oct 31 '19 17:10 callaa

Hey! I have an iPad the supports sidecar and some mac development experience.

Please let me know how I can help!

I think this documentation from apple might be helpful in implementing this: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTabletEvents/HandlingTabletEvents.html#//apple_ref/doc/uid/10000060i-CH10-SW1

krystalCoconut avatar Nov 16 '19 07:11 krystalCoconut

Would you be able to help me understand where the tablet event code is in your project, I've had a bit of a look around and found it hard to find. I only found this: https://github.com/drawpile/Drawpile/blob/b49ed959718830357f66e6548f023d192d007c0b/src/mobile/quick/canvasinputarea.cpp . I think this is for only mobile though?

Then I can try implementing the tablet events with preprocessor directives to check if its running on macOS.

krystalCoconut avatar Nov 16 '19 07:11 krystalCoconut

Hello, and thank you!

The canvas input handling is done here: https://github.com/drawpile/Drawpile/blob/master/src/desktop/scene/canvasview.cpp

However, this all relies on Qt's tablet events, which abstract the underlying native events. If you need access to the native events, you may need to create a native event filter. Here's how it's done on X11: https://github.com/drawpile/Drawpile/blob/master/src/desktop/bundled/kis_tablet/kis_xi2_event_filter.cpp

And it's activated in the main function: https://github.com/drawpile/Drawpile/blob/master/src/desktop/main.cpp#L290

callaa avatar Nov 16 '19 09:11 callaa

I don't really get what a native event filter is, could you please explain the concept to me?

krystalCoconut avatar Nov 20 '19 09:11 krystalCoconut

A native event filter is a class that intercepts native events. It lets you handle platform specific events before they're converted to Qt's internal events and handed to the rest of the application. In the example I linked, it's used to grab native XInput tablet events and handle them in custom code, since Qt's built-in tablet support is not very good.

I'm not actually sure what it takes to support Sidecar, so I don't know if you even need a native event handler.

callaa avatar Nov 20 '19 18:11 callaa