34
1 LOOK! IT’S LIBREOFFICE ON KDE PLASMA KATARÍNA BEHRENS LIBREOFFICE CONFERENCE TIRANA

LOOK! IT’S LIBREOFFICE ON KDE PLASMA

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

1

LOOK! IT’S LIBREOFFICE ON KDE PLASMA

KATARÍNA BEHRENSLIBREOFFICE CONFERENCE TIRANA

Page 2: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

2

LOOK WHO'S TALKING

> LibreOffice squirrel @CIB> GSoC mentor> Qt widget charmer> WITch, feminist

Page 3: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

3

„PORTING“ KDE4 VCL PLUGIN TO KF5

1. VCL PLUGIN ARCHITECTURE ON LINUX2. WHY PORT WRITE FROM SCRATCH?3. CHALLENGES4. FILEPICKER5. NEW STUFF

Page 4: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

4

1 | 5

VCL PLUGIN ARCHITECTURE ON LINUX

Page 5: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

5

VCL ? VCL!

> Visual Component Library

> Visual Class Libraries

> Very Complete Library

> Vastly Clueless Library

> Very Confused Library

Page 6: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

6

PLATFORM-DEPENDENT BITS

● Widget look‘n‘feel– Windows and mac OS X– gtk and gtk3– generic X11 („Windows 95“)– kde4, qt5 and kf5

● Menus● File/folder picker dialogs● Printing

Page 7: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

7

SALINSTANCE, SALFRAMES

> SalInstance– every platform/vcl plugin implements one– create and destroy: SalFrames, SalPrinters,

SalVirtualDevices

> SalFrame– system window (main window, dialog etc.)– [undocked] floating window – tooltip– non-native [context] menu– listbox | toolbox dropdown

Page 8: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

8

Sally Instance

CreateFrame(main window)

CreateFilePicker CreateFrame(dialog, dropdown)

Page 9: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

9

SALFRAME, SALGRAPHICS

> SalFrame– every platform/vcl plugin implements one– Acquire/ReleaseGraphics returns SalGraphics

> SalGraphics– enables drawing to SalFrame– APIs such as drawRect, drawLine– drawNativeControl (draws widgets!)

Page 10: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

10

IN A NUTSHELL

SalInstance SalGraphicsSalFramecreates Acquires, releases

SalData

initializes

Page 11: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

11

2 | 5

WHY PORT WRITE FROM SCRATCH?

Page 12: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

12

KDE4 VCL PLUGIN HAS AGED

> KDE4 becoming legacy on most Linux distributions> Thin layer around X11/XLib VCL plugin> Only emulates KDE look'n'feel

– no native widgets, QPainter with QStyle* to render widgets– combined into QPixmap – copied directly into X11 window

(X11SalGraphics::CopyScreenArea)– slow painting, no image caching

Page 13: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

13

„NATIVE“ LOOK‘N‘FEEL WITH X11

X11 Window

OK

QPainter +

QStyleOption

QPixmap

OK

X11SalGraphic::CopyScreenArea

“Paste”

QImage

Page 14: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

14

KDE4 VCL PLUGIN HAS AGED EVEN MORE

> XLib way of processing the events (QApplication::x11ProcessEvent)

> No modal native dialogs– as LibO Widgets are not wrapped in QWidgets

> No Wayland support

Page 15: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

15

DIRECT PORT TO KF5 NOT POSSIBLE

> No way to access internal X11 pixmap anymore

> Similarly, no more X11 event filtering and processing

Page 16: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

16

Page 17: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

17

Page 18: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

18

3 | 5

CHALLENGES

Page 19: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

19

CHALLENGE: X11-LESS WINDOWS

> Replace X11 windows with native QWindows, QWidgets

– 1 SalFrame ⟺ 1 QWidget (QMainWindow respectively)

> Side effect: natively modal dialogs now possible – pop-up dialogs centered over its parent, grey background

overlay– Qt API: setModality, setTransientParent

Page 20: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

20

CHALLENGE: X11-LESS PAINTING

> Variant 1 (plain Qt5): clean-room implementation of QPainter-based SalGraphics

– 2nd rendering path on Linux (aside headless)

> Variant 2 (KF5): integrate with headless SalGraphic– custom QWidget with cairo canvas inside– QPainter (+QStyle[Option]) to paint widget bitmaps and

yield QImage– Raw bitmap extracted from Qimage and „pasted“ to cairo

canvas (BitBLT of a kind)

Page 21: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

21

X11-LESS PAINTING

QWindow with cairo canvas

OK

QPainter +

QStyleOption

Convert to raw bitmap and “paste”(cairo operator)

QImage

OK

Page 22: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

22

CHALLENGE: X11-LESS PROCESSING OF EVENTS

> SalFrames are now QWidgets> Side effect: they receive Qt events > So we can map them to SalEvents (in re-

implemented event handlers)> Additional QAbstractEventDispatcher for non-user

driven events

Page 23: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

23

4 | 5

FILEPICKER

Page 24: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

24

HOW IT WORKS

> „Agnostic“ C++ core code (e.g. print to file) – „Open a file dialog“ (letting user to pick file to print to)

> SalInstance (UI manager)– „Okay, opening a file dialog“– ::CreateFilePicker, ::CreateFolderPicker respectively

> KDE5FilePicker– „I‘m implementing XFilePicker interface and providing the

necessary functions“

Page 25: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

25

HOW IT WORKS II

Sally Instance

Joe KF5 Picker

I implement XFilePicker and

XFolderPicker interfaces

Print to file:Open a file picker

Page 26: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

26

WHY SO COMPLICATED?

> Why do we need all those interfaces?– get/setDisplayDirectory– get/setCurrentFilter– enableControl– get/setLabel etc.

> Because of custom LibO functionality– encrypt with password/GPG key– edit filter settings– enable/disable custom controls as needed

Page 27: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

27

(SMALLER) CHALLENGE: MIGRATE GTK3_KDE5 FPICKER TO PLAIN KF5

> Original work by Milian Wolff (KDAB)> Ships with LibreOffice 6.1> Gtk3 UI + Plasma filepicker as a separate binary> Communicating over stdin/stdout> Most of XFilePicker interface funcs implemented> Kill I/O with fire and open KFileDialog directly

Page 28: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

28

5 | 5

NEW STUFF

Page 29: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

29

NATIVE FOCUS RECTANGLES FOR[RADIO]BUTTONS AND CHECKBOXES

Before: After:

Page 30: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

30

NATIVE MENUS (INCL. GLOBAL MENU SUPPORT)

Page 31: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

31

REAL FOLDER PICKER

Before: After:

Page 32: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

32

THE CODE

> In LibreOffice master> Build with –enable-qt5 and –enable-kde5> Not yet enabled for daily builds – needs baseline

upgrade> (tentatively) shipped with LibreOffice 6.2

– First beta in November 2018– Released in February 2019

Page 33: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

33

ANY QUESTIONS, COMMENTS, PRAISE, CRITICISM, OFFERS (OF BEER)?

Page 34: LOOK! IT’S LIBREOFFICE ON KDE PLASMA

34

THANK YOU!