summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/android.pro9
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp2
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp34
-rw-r--r--src/plugins/platforms/android/androidjniinput.h4
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp2
-rw-r--r--src/plugins/platforms/android/qandroideventdispatcher.h2
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp212
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.h14
-rw-r--r--src/plugins/platforms/android/qandroidplatformfontdatabase.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp20
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglcontext.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglcontext.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglwindow.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.cpp3
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp2
-rw-r--r--src/plugins/platforms/bsdfb/bsdfb.json3
-rw-r--r--src/plugins/platforms/bsdfb/bsdfb.pro19
-rw-r--r--src/plugins/platforms/bsdfb/main.cpp60
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbintegration.cpp142
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbintegration.h81
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbscreen.cpp276
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbscreen.h74
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro7
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm25
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h24
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm75
-rw-r--r--src/plugins/platforms/cocoa/qcocoaclipboard.h7
-rw-r--r--src/plugins/platforms/cocoa/qcocoaclipboard.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm53
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h36
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm588
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm17
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.mm8
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm34
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.h8
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.mm209
-rw-r--r--src/plugins/platforms/cocoa/qcocoamimetypes.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintdevice.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintersupport.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaresources.qrc5
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm98
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm64
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h51
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm271
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.h4
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm16
-rw-r--r--src/plugins/platforms/cocoa/qmacdefines_mac.h57
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h8
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm264
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm4
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h2
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm14
-rw-r--r--src/plugins/platforms/cocoa/qpaintengine_mac.mm87
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm4
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac_p.h3
-rw-r--r--src/plugins/platforms/cocoa/qt_mac_p.h58
-rw-r--r--src/plugins/platforms/cocoa/qt_menu.nib/classes.nib59
-rw-r--r--src/plugins/platforms/cocoa/qt_menu.nib/info.nib18
-rw-r--r--src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nibbin5560 -> 0 bytes
-rw-r--r--src/plugins/platforms/direct2d/direct2d.pro9
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp10
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h7
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp6
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp6
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp2
-rw-r--r--src/plugins/platforms/directfb/directfb.pro11
-rw-r--r--src/plugins/platforms/directfb/qdirectfb_egl.cpp6
-rw-r--r--src/plugins/platforms/directfb/qdirectfbbackingstore.cpp16
-rw-r--r--src/plugins/platforms/directfb/qdirectfbbackingstore.h2
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.cpp6
-rw-r--r--src/plugins/platforms/eglfs/api/api.pri21
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscontext.cpp (renamed from src/plugins/platforms/eglfs/qeglfscontext.cpp)14
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscontext_p.h (renamed from src/plugins/platforms/eglfs/qeglfscontext.h)15
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor.cpp (renamed from src/plugins/platforms/eglfs/qeglfscursor.cpp)176
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor_p.h (renamed from src/plugins/platforms/eglfs/qeglfscursor.h)30
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp (renamed from src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp)114
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h (renamed from src/plugins/platforms/eglfs/qeglfsdeviceintegration.h)20
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsglobal_p.h (renamed from src/plugins/platforms/eglfs/qeglfsglobal.h)20
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfshooks.cpp (renamed from src/plugins/platforms/eglfs/qeglfshooks.cpp)16
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfshooks_p.h (renamed from src/plugins/platforms/eglfs/qeglfshooks.h)19
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration.cpp (renamed from src/plugins/platforms/eglfs/qeglfsintegration.cpp)76
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration_p.h (renamed from src/plugins/platforms/eglfs/qeglfsintegration.h)15
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp (renamed from src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp)6
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow_p.h (renamed from src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h)13
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp (renamed from src/plugins/platforms/eglfs/qeglfsscreen.cpp)33
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen_p.h (renamed from src/plugins/platforms/eglfs/qeglfsscreen.h)16
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp (renamed from src/plugins/platforms/eglfs/qeglfswindow.cpp)19
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h (renamed from src/plugins/platforms/eglfs/qeglfswindow.h)19
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro12
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h5
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro12
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp33
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp21
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h5
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp28
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h10
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro12
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp120
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h13
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp30
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h11
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp19
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h10
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro5
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp8
-rw-r--r--src/plugins/platforms/eglfs/eglfs-plugin.pro4
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pro2
-rw-r--r--src/plugins/platforms/eglfs/eglfs_device_lib.pro54
-rw-r--r--src/plugins/platforms/eglfs/eglfsdeviceintegration.pro50
-rw-r--r--src/plugins/platforms/eglfs/qeglfsmain.cpp2
-rw-r--r--src/plugins/platforms/haiku/haiku.pro4
-rw-r--r--src/plugins/platforms/haiku/qhaikuclipboard.cpp2
-rw-r--r--src/plugins/platforms/haiku/qhaikuintegration.cpp2
-rw-r--r--src/plugins/platforms/integrity/integrity.pro7
-rw-r--r--src/plugins/platforms/integrity/qintegrityfbintegration.cpp12
-rw-r--r--src/plugins/platforms/integrity/qintegrityfbscreen.cpp4
-rw-r--r--src/plugins/platforms/integrity/qintegrityfbscreen.h2
-rw-r--r--src/plugins/platforms/ios/kernel.pro34
-rw-r--r--src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h4
-rw-r--r--src/plugins/platforms/ios/optional/optional.pro2
-rw-r--r--src/plugins/platforms/ios/plugin.mm4
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.h2
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.mm29
-rw-r--r--src/plugins/platforms/ios/qiosclipboard.h7
-rw-r--r--src/plugins/platforms/ios/qiosclipboard.mm6
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm3
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm2
-rw-r--r--src/plugins/platforms/ios/qiosfiledialog.h4
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h11
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm26
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h4
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm22
-rw-r--r--src/plugins/platforms/ios/qiosintegration.h11
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm18
-rw-r--r--src/plugins/platforms/ios/qiosmenu.h2
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm6
-rw-r--r--src/plugins/platforms/ios/qiosmessagedialog.h4
-rw-r--r--src/plugins/platforms/ios/qiosplatformaccessibility.h4
-rw-r--r--src/plugins/platforms/ios/qiosplatformaccessibility.mm6
-rw-r--r--src/plugins/platforms/ios/qiosscreen.h2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm57
-rw-r--r--src/plugins/platforms/ios/qiostextinputoverlay.mm22
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.h10
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm17
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm14
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.h9
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm74
-rw-r--r--src/plugins/platforms/ios/qioswindow.h4
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm4
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.h3
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.mm6
-rw-r--r--src/plugins/platforms/ios/quiview.h8
-rw-r--r--src/plugins/platforms/ios/quiview.mm111
-rw-r--r--src/plugins/platforms/linuxfb/linuxfb.pro12
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp36
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp12
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.h2
-rw-r--r--src/plugins/platforms/minimal/minimal.pro9
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp14
-rw-r--r--src/plugins/platforms/minimalegl/minimalegl.pro6
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglintegration.cpp6
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.cpp4
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.h2
-rw-r--r--src/plugins/platforms/mirclient/mirclient.pro10
-rw-r--r--src/plugins/platforms/mirclient/qmirclientbackingstore.cpp8
-rw-r--r--src/plugins/platforms/mirclient/qmirclientcursor.cpp2
-rw-r--r--src/plugins/platforms/mirclient/qmirclientglcontext.cpp2
-rw-r--r--src/plugins/platforms/mirclient/qmirclientinput.cpp1
-rw-r--r--src/plugins/platforms/mirclient/qmirclientintegration.cpp4
-rw-r--r--src/plugins/platforms/mirclient/qmirclientplatformservices.h4
-rw-r--r--src/plugins/platforms/mirclient/qmirclientscreen.cpp2
-rw-r--r--src/plugins/platforms/mirclient/qmirclienttheme.h2
-rw-r--r--src/plugins/platforms/offscreen/offscreen.pro9
-rw-r--r--src/plugins/platforms/offscreen/qoffscreencommon.cpp22
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.cpp6
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp2
-rw-r--r--src/plugins/platforms/openwfd/openwf.pro9
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdintegration.cpp5
-rw-r--r--src/plugins/platforms/platforms.pro29
-rw-r--r--src/plugins/platforms/qnx/qnx.pro17
-rw-r--r--src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp12
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp3
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorpps.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterwindow.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp21
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp2
-rw-r--r--src/plugins/platforms/vnc/main.cpp (renamed from src/plugins/platforms/windows/qwindowsnativeimage.h)47
-rw-r--r--src/plugins/platforms/vnc/qvnc.cpp685
-rw-r--r--src/plugins/platforms/vnc/qvnc_p.h417
-rw-r--r--src/plugins/platforms/vnc/qvncclient.cpp662
-rw-r--r--src/plugins/platforms/vnc/qvncclient.h149
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp148
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.h (renamed from src/plugins/platforms/winrt/qwinrtfontdatabase.h)64
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.cpp187
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.h93
-rw-r--r--src/plugins/platforms/vnc/vnc.json3
-rw-r--r--src/plugins/platforms/vnc/vnc.pro31
-rw-r--r--src/plugins/platforms/windows/accessible/accessible.pri14
-rw-r--r--src/plugins/platforms/windows/accessible/comutils.cpp24
-rw-r--r--src/plugins/platforms/windows/accessible/iaccessible2.cpp2
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp60
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp3
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h2
-rw-r--r--src/plugins/platforms/windows/qplatformfunctions_wince.h371
-rw-r--r--src/plugins/platforms/windows/qtwindows_additional.h179
-rw-r--r--src/plugins/platforms/windows/qtwindowsglobal.h23
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp41
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp214
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h47
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp70
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp340
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp1907
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.h133
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp755
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.h68
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp1381
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.h186
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp891
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h138
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp55
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h8
-rw-r--r--src/plugins/platforms/windows/qwindowsinternalmimedata.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsinternalmimedata.h2
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp36
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp128
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.h6
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeimage.cpp152
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsole.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp36
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h4
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp170
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h11
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp192
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h22
-rw-r--r--src/plugins/platforms/windows/windows.pri63
-rw-r--r--src/plugins/platforms/windows/windows.pro9
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp4
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.cpp491
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.cpp56
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.h4
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp6
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp85
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.h5
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp11
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.h2
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp2
-rw-r--r--src/plugins/platforms/winrt/winrt.pro9
-rw-r--r--src/plugins/platforms/xcb/README10
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro5
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri33
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h4
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp14
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp4
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro5
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro8
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp19
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp28
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h13
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp18
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp32
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp13
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp15
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbsessionmanager.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbsessionmanager.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp33
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h1
-rw-r--r--src/plugins/platforms/xcb/xcb-plugin.pro4
-rw-r--r--src/plugins/platforms/xcb/xcb-static/xcb-static.pro11
-rw-r--r--src/plugins/platforms/xcb/xcb.pro3
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro72
354 files changed, 6125 insertions, 10803 deletions
diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro
index 045e55ec65..bd3fe5a6cc 100644
--- a/src/plugins/platforms/android/android.pro
+++ b/src/plugins/platforms/android/android.pro
@@ -6,9 +6,10 @@ DEFINES += QT_STATICPLUGIN
LIBS += -ljnigraphics -landroid
-QT += core-private gui-private platformsupport-private
-
-CONFIG += qpa/genericunixfontdatabase
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private accessibility_support-private \
+ fontdatabase_support-private egl_support-private
OTHER_FILES += $$PWD/android.json
@@ -72,7 +73,7 @@ HEADERS += $$PWD/qandroidplatformintegration.h \
$$PWD/qandroidplatformforeignwindow.h \
$$PWD/qandroideventdispatcher.h
-android-style-assets: SOURCES += $$PWD/extract.cpp
+qtConfig(android-style-assets): SOURCES += $$PWD/extract.cpp
else: SOURCES += $$PWD/extract-dummy.cpp
PLUGIN_TYPE = platforms
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index e8536235d7..a987092862 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -41,7 +41,7 @@
#include "androidjnimain.h"
#include "qandroidplatformintegration.h"
#include "qpa/qplatformaccessibility.h"
-#include <QtPlatformSupport/private/qaccessiblebridgeutils_p.h>
+#include <QtAccessibilitySupport/private/qaccessiblebridgeutils_p.h>
#include "qguiapplication.h"
#include "qwindow.h"
#include "qrect.h"
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 5be128a0c5..5f05ab395e 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
+** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -120,6 +121,12 @@ namespace QtAndroidInput
return m_softwareKeyboardRect;
}
+ void updateHandles(int mode, QPoint cursor, QPoint anchor)
+ {
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "updateHandles", "(IIIII)V",
+ mode, cursor.x(), cursor.y(), anchor.x(),
+ anchor.y());
+ }
static void mouseDown(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
{
@@ -168,6 +175,10 @@ namespace QtAndroidInput
static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
{
+ QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext();
+ if (inputContext && qGuiApp)
+ QMetaObject::invokeMethod(inputContext, "longPress", Q_ARG(int, x), Q_ARG(int, y));
+
//### TODO: add proper API for Qt 5.2
static bool rightMouseFromLongPress = qEnvironmentVariableIntValue("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS");
if (!rightMouseFromLongPress)
@@ -225,6 +236,12 @@ namespace QtAndroidInput
double(dw*size),
double(dh*size));
m_touchPoints.push_back(touchPoint);
+
+ if (state == Qt::TouchPointPressed) {
+ QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext();
+ if (inputContext && qGuiApp)
+ QMetaObject::invokeMethod(inputContext, "touchDown", Q_ARG(int, x), Q_ARG(int, y));
+ }
}
static void touchEnd(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint /*action*/)
@@ -786,6 +803,18 @@ namespace QtAndroidInput
#endif
}
+ static void handleLocationChanged(JNIEnv */*env*/, jobject /*thiz*/, int id, int x, int y)
+ {
+#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL
+ qDebug() << "@@@ handleLocationChanged" << id << x << y;
+#endif
+ QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext();
+ if (inputContext && qGuiApp)
+ QMetaObject::invokeMethod(inputContext, "handleLocationChanged",
+ Q_ARG(int, id), Q_ARG(int, x), Q_ARG(int, y));
+
+ }
+
static JNINativeMethod methods[] = {
{"touchBegin","(I)V",(void*)touchBegin},
{"touchAdd","(IIIZIIFF)V",(void*)touchAdd},
@@ -799,7 +828,8 @@ namespace QtAndroidInput
{"keyDown", "(IIIZ)V", (void *)keyDown},
{"keyUp", "(IIIZ)V", (void *)keyUp},
{"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged},
- {"keyboardGeometryChanged", "(IIII)V", (void *)keyboardGeometryChanged}
+ {"keyboardGeometryChanged", "(IIII)V", (void *)keyboardGeometryChanged},
+ {"handleLocationChanged", "(III)V", (void *)handleLocationChanged}
};
bool registerNatives(JNIEnv *env)
diff --git a/src/plugins/platforms/android/androidjniinput.h b/src/plugins/platforms/android/androidjniinput.h
index 682abde098..af18a96dc1 100644
--- a/src/plugins/platforms/android/androidjniinput.h
+++ b/src/plugins/platforms/android/androidjniinput.h
@@ -39,6 +39,7 @@
#ifndef ANDROIDJNIINPUT_H
#define ANDROIDJNIINPUT_H
+
#include <jni.h>
#include <QtCore/qglobal.h>
#include <QtCore/QRect>
@@ -56,6 +57,9 @@ namespace QtAndroidInput
void updateSelection(int selStart, int selEnd, int candidatesStart, int candidatesEnd);
// Software keyboard support
+ // cursor/selection handles
+ void updateHandles(int handleCount, QPoint cursor = QPoint(), QPoint anchor = QPoint());
+
bool registerNatives(JNIEnv *env);
}
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 2614bb52a8..df8883ab34 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -514,7 +514,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para
if (m_applicationParams.length()) {
// Obtain a handle to the main library (the library that contains the main() function).
// This library should already be loaded, and calling dlopen() will just return a reference to it.
- m_mainLibraryHnd = dlopen(m_applicationParams.first().data(), 0);
+ m_mainLibraryHnd = dlopen(m_applicationParams.constFirst().data(), 0);
if (Q_UNLIKELY(!m_mainLibraryHnd)) {
qCritical() << "dlopen failed:" << dlerror();
return false;
diff --git a/src/plugins/platforms/android/qandroideventdispatcher.h b/src/plugins/platforms/android/qandroideventdispatcher.h
index 227027f3c3..86a7e460b3 100644
--- a/src/plugins/platforms/android/qandroideventdispatcher.h
+++ b/src/plugins/platforms/android/qandroideventdispatcher.h
@@ -42,7 +42,7 @@
#include <QtCore/QMutex>
#include <QtCore/QSemaphore>
-#include <QtPlatformSupport/private/qunixeventdispatcher_qpa_p.h>
+#include <QtEventDispatcherSupport/private/qunixeventdispatcher_qpa_p.h>
class QAndroidEventDispatcher : public QUnixEventDispatcherQPA
{
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index dc420775cf..2656d45d5f 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -2,6 +2,7 @@
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -342,9 +343,28 @@ static JNINativeMethod methods[] = {
{"updateCursorPosition", "()Z", (void *)updateCursorPosition}
};
+static QRect inputItemRectangle()
+{
+ QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle();
+ QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect();
+ QWindow *window = qGuiApp->focusWindow();
+ if (window)
+ rect = QRect(window->mapToGlobal(rect.topLeft()), rect.size());
+ double pixelDensity = window
+ ? QHighDpiScaling::factor(window)
+ : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
+ if (pixelDensity != 1.0) {
+ rect.setX(rect.x() * pixelDensity);
+ rect.setY(rect.y() * pixelDensity);
+ rect.setWidth(rect.width() * pixelDensity);
+ rect.setHeight(rect.height() * pixelDensity);
+ }
+ return rect;
+}
QAndroidInputContext::QAndroidInputContext()
- : QPlatformInputContext(), m_composingTextStart(-1), m_blockUpdateSelection(false), m_batchEditNestingLevel(0), m_focusObject(0)
+ : QPlatformInputContext(), m_composingTextStart(-1), m_blockUpdateSelection(false),
+ m_cursorHandleShown(CursorHandleNotShown), m_batchEditNestingLevel(0), m_focusObject(0)
{
jclass clazz = QJNIEnvironmentPrivate::findClass(QtNativeInputConnectionClassName);
if (Q_UNLIKELY(!clazz)) {
@@ -415,6 +435,9 @@ QAndroidInputContext::QAndroidInputContext()
qRegisterMetaType<QInputMethodEvent *>("QInputMethodEvent*");
qRegisterMetaType<QInputMethodQueryEvent *>("QInputMethodQueryEvent*");
m_androidInputContext = this;
+
+ QObject::connect(QGuiApplication::inputMethod(), &QInputMethod::cursorRectangleChanged,
+ this, &QAndroidInputContext::updateSelectionHandles);
}
QAndroidInputContext::~QAndroidInputContext()
@@ -452,6 +475,7 @@ void QAndroidInputContext::reset()
{
clear();
m_batchEditNestingLevel = 0;
+ m_cursorHandleShown = QAndroidInputContext::CursorHandleNotShown;
if (qGuiApp->focusObject()) {
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe(Qt::ImEnabled);
if (!query.isNull() && query->value(Qt::ImEnabled).toBool()) {
@@ -500,6 +524,119 @@ void QAndroidInputContext::updateCursorPosition()
}
}
+void QAndroidInputContext::updateSelectionHandles()
+{
+ auto im = qGuiApp->inputMethod();
+ if (!m_focusObject || (m_cursorHandleShown == CursorHandleNotShown)) {
+ // Hide the handles
+ QtAndroidInput::updateHandles(0);
+ return;
+ }
+ QWindow *window = qGuiApp->focusWindow();
+ double pixelDensity = window
+ ? QHighDpiScaling::factor(window)
+ : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
+
+ QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImEnabled);
+ QCoreApplication::sendEvent(m_focusObject, &query);
+ int cpos = query.value(Qt::ImCursorPosition).toInt();
+ int anchor = query.value(Qt::ImAnchorPosition).toInt();
+
+ if (cpos == anchor || im->anchorRectangle().isNull()) {
+ if (!query.value(Qt::ImEnabled).toBool()) {
+ QtAndroidInput::updateHandles(0);
+ return;
+ }
+
+ auto curRect = im->cursorRectangle();
+ QPoint cursorPoint(curRect.center().x(), curRect.bottom());
+ QPoint editMenuPoint(curRect.center().x(), curRect.top());
+ QtAndroidInput::updateHandles(m_cursorHandleShown, cursorPoint * pixelDensity,
+ editMenuPoint * pixelDensity);
+ return;
+ }
+
+ auto leftRect = im->cursorRectangle();
+ auto rightRect = im->anchorRectangle();
+ if (cpos > anchor)
+ std::swap(leftRect, rightRect);
+
+ QPoint leftPoint(leftRect.bottomLeft().toPoint() * pixelDensity);
+ QPoint righPoint(rightRect.bottomRight().toPoint() * pixelDensity);
+ QtAndroidInput::updateHandles(CursorHandleShowSelection, leftPoint, righPoint);
+
+ if (m_cursorHandleShown == CursorHandleShowPopup) {
+ // make sure the popup does not reappear when the selection menu closes
+ m_cursorHandleShown = QAndroidInputContext::CursorHandleNotShown;
+ }
+}
+
+/*
+ Called from Java when a cursor/selection handle was dragged to a new position
+
+ handleId of 1 means the cursor handle, 2 means the left handle, 3 means the right handle
+ */
+void QAndroidInputContext::handleLocationChanged(int handleId, int x, int y)
+{
+ auto im = qGuiApp->inputMethod();
+ auto leftRect = im->cursorRectangle();
+ // The handle is down of the cursor, but we want the position in the middle.
+ QWindow *window = qGuiApp->focusWindow();
+ double pixelDensity = window
+ ? QHighDpiScaling::factor(window)
+ : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
+ QPoint point(x / pixelDensity, y / pixelDensity);
+ y -= leftRect.width() / 2;
+ if (handleId == 1) {
+ setSelectionOnFocusObject(point, point);
+ return;
+ }
+
+ QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition);
+ QCoreApplication::sendEvent(m_focusObject, &query);
+ int cpos = query.value(Qt::ImCursorPosition).toInt();
+ int anchor = query.value(Qt::ImAnchorPosition).toInt();
+
+ auto rightRect = im->anchorRectangle();
+ if (cpos > anchor)
+ std::swap(leftRect, rightRect);
+
+ if (handleId == 2) {
+ QPoint rightPoint(rightRect.center().toPoint());
+ setSelectionOnFocusObject(point, rightPoint);
+ } else if (handleId == 3) {
+ QPoint leftPoint(leftRect.center().toPoint());
+ setSelectionOnFocusObject(leftPoint, point);
+ }
+}
+
+void QAndroidInputContext::touchDown(int x, int y)
+{
+ if (m_focusObject && inputItemRectangle().contains(x, y) && !m_cursorHandleShown) {
+ // If the user touch the input rectangle, we can show the cursor handle
+ m_cursorHandleShown = QAndroidInputContext::CursorHandleShowNormal;
+ updateSelectionHandles();
+ }
+}
+
+void QAndroidInputContext::longPress(int x, int y)
+{
+ if (m_focusObject && inputItemRectangle().contains(x, y)) {
+ // Show the paste menu if there is something to paste.
+ m_cursorHandleShown = QAndroidInputContext::CursorHandleShowPopup;
+ updateSelectionHandles();
+ }
+}
+
+void QAndroidInputContext::keyDown()
+{
+ if (m_cursorHandleShown) {
+ // When the user enter text on the keyboard, we hide the cursor handle
+ m_cursorHandleShown = QAndroidInputContext::CursorHandleNotShown;
+ updateSelectionHandles();
+ }
+}
+
void QAndroidInputContext::update(Qt::InputMethodQueries queries)
{
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe(queries);
@@ -543,22 +680,11 @@ void QAndroidInputContext::showInputPanel()
m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition()));
else
m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
- QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle();
- QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect();
- QWindow *window = qGuiApp->focusWindow();
- if (window)
- rect = QRect(window->mapToGlobal(rect.topLeft()), rect.size());
-
- double pixelDensity = window ? QHighDpiScaling::factor(window)
- : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen());
- QtAndroidInput::showSoftwareKeyboard(rect.left() * pixelDensity,
- rect.top() * pixelDensity,
- rect.width() * pixelDensity,
- rect.height() * pixelDensity,
+ QRect rect = inputItemRectangle();
+ QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(),
query->value(Qt::ImHints).toUInt(),
- query->value(Qt::ImEnterKeyType).toUInt()
- );
+ query->value(Qt::ImEnterKeyType).toUInt());
}
void QAndroidInputContext::showInputPanelLater(Qt::ApplicationState state)
@@ -601,6 +727,7 @@ void QAndroidInputContext::setFocusObject(QObject *object)
reset();
}
QPlatformInputContext::setFocusObject(object);
+ updateSelectionHandles();
}
jboolean QAndroidInputContext::beginBatchEdit()
@@ -645,7 +772,7 @@ jboolean QAndroidInputContext::commitText(const QString &text, jint newCursorPos
: localPos - text.length() + newCursorPosition;
//move the cursor
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection,
- newLocalPos, 0, QVariant()));
+ newLocalPos, 0));
}
}
m_blockUpdateSelection = updateSelectionWasBlocked;
@@ -691,7 +818,7 @@ jboolean QAndroidInputContext::finishComposingText()
// Moving Qt's cursor to where the preedit cursor used to be
QList<QInputMethodEvent::Attribute> attributes;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0, QVariant()));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0));
QInputMethodEvent event(QString(), attributes);
event.setCommitString(m_composingText);
@@ -739,7 +866,7 @@ const QAndroidInputContext::ExtractedText &QAndroidInputContext::getExtractedTex
if (composeLength > 0) {
//Qt doesn't give us the preedit text, so we have to insert it at the correct position
int localComposePos = m_composingTextStart - blockPos;
- blockText = blockText.left(localComposePos) + m_composingText + blockText.mid(localComposePos);
+ blockText = blockText.leftRef(localComposePos) + m_composingText + blockText.midRef(localComposePos);
}
int cpos = localPos + composeLength; //actual cursor pos relative to the current block
@@ -803,9 +930,8 @@ QString QAndroidInputContext::getTextAfterCursor(jint length, jint /*flags*/)
QString QAndroidInputContext::getTextBeforeCursor(jint length, jint /*flags*/)
{
QVariant textBefore = queryFocusObjectThreadSafe(Qt::ImTextBeforeCursor, QVariant(length));
- if (textBefore.isValid()) {
- return textBefore.toString().right(length) + m_composingText;
- }
+ if (textBefore.isValid())
+ return textBefore.toString().rightRef(length) + m_composingText;
//compatibility code for old controls that do not implement the new API
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe();
@@ -819,9 +945,9 @@ QString QAndroidInputContext::getTextBeforeCursor(jint length, jint /*flags*/)
//### the preedit text does not need to be immediately before the cursor
if (cursorPos <= length)
- return text.left(cursorPos) + m_composingText;
+ return text.leftRef(cursorPos) + m_composingText;
else
- return text.mid(cursorPos - length, length) + m_composingText;
+ return text.midRef(cursorPos - length, length) + m_composingText;
}
/*
@@ -848,8 +974,7 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
QList<QInputMethodEvent::Attribute> attributes;
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
newCursorPosition,
- 1,
- QVariant()));
+ 1));
// Show compose text underlined
QTextCharFormat underlined;
underlined.setFontUnderline(true);
@@ -859,6 +984,8 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
QInputMethodEvent event(m_composingText, attributes);
sendInputMethodEventThreadSafe(&event);
+ QMetaObject::invokeMethod(this, "keyDown");
+
updateCursorPosition();
return JNI_TRUE;
@@ -921,7 +1048,7 @@ jboolean QAndroidInputContext::setComposingRegion(jint start, jint end)
QVariant(underlined)));
// Keep the cursor position unchanged (don't move to end of preedit)
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, currentCursor - start, 1, QVariant()));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, currentCursor - start, 1));
QInputMethodEvent event(m_composingText, attributes);
event.setCommitString(QString(), relativeStart, length);
@@ -955,7 +1082,7 @@ jboolean QAndroidInputContext::setSelection(jint start, jint end)
// preedit cursor
int localOldPos = query->value(Qt::ImCursorPosition).toInt();
int pos = localCursorPos - localOldPos;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, pos, 1, QVariant()));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, pos, 1));
//but we have to tell Qt about the compose text all over again
@@ -970,8 +1097,7 @@ jboolean QAndroidInputContext::setSelection(jint start, jint end)
// actually changing the selection
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection,
localCursorPos,
- end - start,
- QVariant()));
+ end - start));
}
QInputMethodEvent event(m_composingText, attributes);
sendInputMethodEventThreadSafe(&event);
@@ -981,20 +1107,21 @@ jboolean QAndroidInputContext::setSelection(jint start, jint end)
jboolean QAndroidInputContext::selectAll()
{
-#warning TODO
- return JNI_FALSE;
+ sendShortcut(QKeySequence::SelectAll);
+ return JNI_TRUE;
}
jboolean QAndroidInputContext::cut()
{
-#warning TODO
- return JNI_FALSE;
+ m_cursorHandleShown = CursorHandleNotShown;
+ sendShortcut(QKeySequence::Cut);
+ return JNI_TRUE;
}
jboolean QAndroidInputContext::copy()
{
-#warning TODO
- return JNI_FALSE;
+ sendShortcut(QKeySequence::Copy);
+ return JNI_TRUE;
}
jboolean QAndroidInputContext::copyURL()
@@ -1005,10 +1132,21 @@ jboolean QAndroidInputContext::copyURL()
jboolean QAndroidInputContext::paste()
{
-#warning TODO
- return JNI_FALSE;
+ m_cursorHandleShown = CursorHandleNotShown;
+ sendShortcut(QKeySequence::Paste);
+ return JNI_TRUE;
}
+void QAndroidInputContext::sendShortcut(const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i) {
+ const int keys = sequence[i];
+ Qt::Key key = Qt::Key(keys & ~Qt::KeyboardModifierMask);
+ Qt::KeyboardModifiers mod = Qt::KeyboardModifiers(keys & Qt::KeyboardModifierMask);
+ QGuiApplication::postEvent(m_focusObject, new QKeyEvent(QEvent::KeyPress, key, mod));
+ QGuiApplication::postEvent(m_focusObject, new QKeyEvent(QEvent::KeyRelease, key, mod));
+ }
+}
Q_INVOKABLE QVariant QAndroidInputContext::queryFocusObjectUnsafe(Qt::InputMethodQuery query, QVariant argument)
{
diff --git a/src/plugins/platforms/android/qandroidinputcontext.h b/src/plugins/platforms/android/qandroidinputcontext.h
index 5ab85dcab0..8a33ff71cc 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.h
+++ b/src/plugins/platforms/android/qandroidinputcontext.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -94,6 +95,7 @@ public:
bool isComposing() const;
void clear();
void setFocusObject(QObject *object);
+ void sendShortcut(const QKeySequence &);
//---------------//
jboolean beginBatchEdit();
@@ -117,6 +119,11 @@ public:
public slots:
void updateCursorPosition();
+ void updateSelectionHandles();
+ void handleLocationChanged(int handleId, int x, int y);
+ void touchDown(int x, int y);
+ void longPress(int x, int y);
+ void keyDown();
private slots:
void showInputPanelLater(Qt::ApplicationState);
@@ -138,6 +145,13 @@ private:
int m_composingCursor;
QMetaObject::Connection m_updateCursorPosConnection;
bool m_blockUpdateSelection;
+ enum CursorHandleShowMode {
+ CursorHandleNotShown,
+ CursorHandleShowNormal = 1,
+ CursorHandleShowSelection = 2,
+ CursorHandleShowPopup = 3
+ };
+ CursorHandleShowMode m_cursorHandleShown;
int m_batchEditNestingLevel;
QObject *m_focusObject;
};
diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.h b/src/plugins/platforms/android/qandroidplatformfontdatabase.h
index a00a3730fb..b20fd75cb2 100644
--- a/src/plugins/platforms/android/qandroidplatformfontdatabase.h
+++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.h
@@ -40,7 +40,7 @@
#ifndef QANDROIDPLATFORMFONTDATABASE_H
#define QANDROIDPLATFORMFONTDATABASE_H
-#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qbasicfontdatabase_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index 80d7e31aa3..6669ee3176 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -46,7 +46,7 @@
#include <QThread>
#include <QOffscreenSurface>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformoffscreensurface.h>
@@ -80,6 +80,8 @@ Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::Pri
Qt::ApplicationState QAndroidPlatformIntegration::m_defaultApplicationState = Qt::ApplicationActive;
+bool QAndroidPlatformIntegration::m_showPasswordEnabled = false;
+
void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
{
if (resource=="JavaVM")
@@ -191,6 +193,19 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &para
}
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
}
+
+ auto contentResolver = javaActivity.callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
+ Q_ASSERT(contentResolver.isValid());
+ QJNIObjectPrivate txtShowPassValue = QJNIObjectPrivate::callStaticObjectMethod("android/provider/Settings$System",
+ "getString",
+ "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;",
+ contentResolver.object(),
+ QJNIObjectPrivate::getStaticObjectField("android/provider/Settings$System", "TEXT_SHOW_PASSWORD", "Ljava/lang/String;").object());
+ if (txtShowPassValue.isValid()) {
+ bool ok = false;
+ const int txtShowPass = txtShowPassValue.toString().toInt(&ok);
+ m_showPasswordEnabled = ok ? (txtShowPass == 1) : false;
+ }
}
QGuiApplicationPrivate::instance()->setApplicationState(m_defaultApplicationState);
@@ -313,6 +328,9 @@ QPlatformServices *QAndroidPlatformIntegration::services() const
QVariant QAndroidPlatformIntegration::styleHint(StyleHint hint) const
{
switch (hint) {
+ case PasswordMaskDelay:
+ // this number is from a hard-coded value in Android code (cf. PasswordTransformationMethod)
+ return m_showPasswordEnabled ? 1500 : 0;
case ShowIsMaximized:
return true;
default:
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h
index 1f06c23d0b..bda0bee9ad 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.h
+++ b/src/plugins/platforms/android/qandroidplatformintegration.h
@@ -143,6 +143,8 @@ private:
static Qt::ApplicationState m_defaultApplicationState;
+ static bool m_showPasswordEnabled;
+
QPlatformFontDatabase *m_androidFDB;
QAndroidPlatformNativeInterface *m_androidPlatformNativeInterface;
QAndroidPlatformServices *m_androidPlatformServices;
diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
index 80693acf88..2644fa27f6 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
@@ -42,7 +42,7 @@
#include "qandroidplatformopenglwindow.h"
#include "qandroidplatformintegration.h"
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <QSurface>
#include <QtGui/private/qopenglcontext_p.h>
diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.h b/src/plugins/platforms/android/qandroidplatformopenglcontext.h
index c88dbf327b..d3f6cf13a4 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglcontext.h
+++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.h
@@ -41,7 +41,7 @@
#ifndef QANDROIDPLATFORMOPENGLCONTEXT_H
#define QANDROIDPLATFORMOPENGLCONTEXT_H
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#include <QtEglSupport/private/qeglplatformcontext_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
index 7801629633..3e1cfe305d 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
@@ -50,7 +50,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index a73550606b..155d6bfb8d 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -379,9 +379,8 @@ void QAndroidPlatformScreen::doRedraw()
}
}
- foreach (const QRect &rect, visibleRegion.rects()) {
+ for (const QRect &rect : visibleRegion)
compositePainter.fillRect(rect, QColor(Qt::transparent));
- }
ret = ANativeWindow_unlockAndPost(m_nativeSurface);
if (ret >= 0)
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index 6cabdd8b3c..b891407c44 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -486,7 +486,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
if (ret > 0)
return ret;
- // fall through
+ Q_FALLTHROUGH();
}
default:
return QPlatformTheme::themeHint(hint);
diff --git a/src/plugins/platforms/bsdfb/bsdfb.json b/src/plugins/platforms/bsdfb/bsdfb.json
new file mode 100644
index 0000000000..97b3e7707e
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/bsdfb.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "bsdfb" ]
+}
diff --git a/src/plugins/platforms/bsdfb/bsdfb.pro b/src/plugins/platforms/bsdfb/bsdfb.pro
new file mode 100644
index 0000000000..770145a8ff
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/bsdfb.pro
@@ -0,0 +1,19 @@
+TARGET = qbsdfb
+
+QT += \
+ core-private gui-private \
+ service_support-private eventdispatcher_support-private \
+ fontdatabase_support-private fb_support-private
+
+qtHaveModule(input_support-private): \
+ QT += input_support-private
+
+SOURCES = main.cpp qbsdfbintegration.cpp qbsdfbscreen.cpp
+HEADERS = qbsdfbintegration.h qbsdfbscreen.h
+
+OTHER_FILES += bsdfb.json
+
+PLUGIN_TYPE = platforms
+PLUGIN_CLASS_NAME = QBsdFbIntegrationPlugin
+!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
+load(qt_plugin)
diff --git a/src/plugins/platforms/bsdfb/main.cpp b/src/plugins/platforms/bsdfb/main.cpp
new file mode 100644
index 0000000000..f4ab3dee39
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qpa/qplatformintegrationplugin.h>
+#include "qbsdfbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBsdFbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "bsdfb.json")
+public:
+ QPlatformIntegration *create(const QString&, const QStringList&) override;
+};
+
+QPlatformIntegration* QBsdFbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (!system.compare(QLatin1String("bsdfb"), Qt::CaseInsensitive))
+ return new QBsdFbIntegration(paramList);
+
+ return nullptr;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
+
diff --git a/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp b/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp
new file mode 100644
index 0000000000..1fa13183f8
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbsdfbintegration.h"
+#include "qbsdfbscreen.h"
+
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
+
+#include <QtFbSupport/private/qfbvthandler_p.h>
+#include <QtFbSupport/private/qfbbackingstore_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatforminputcontext.h>
+#include <qpa/qplatforminputcontextfactory_p.h>
+
+#if QT_CONFIG(tslib)
+#include <QtInputSupport/private/qtslib_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QBsdFbIntegration::QBsdFbIntegration(const QStringList &paramList)
+{
+ m_fontDb.reset(new QGenericUnixFontDatabase);
+ m_services.reset(new QGenericUnixServices);
+ m_primaryScreen.reset(new QBsdFbScreen(paramList));
+}
+
+QBsdFbIntegration::~QBsdFbIntegration()
+{
+ destroyScreen(m_primaryScreen.take());
+}
+
+void QBsdFbIntegration::initialize()
+{
+ if (m_primaryScreen->initialize())
+ screenAdded(m_primaryScreen.data());
+ else
+ qWarning("bsdfb: Failed to initialize screen");
+
+ m_inputContext.reset(QPlatformInputContextFactory::create());
+ m_nativeInterface.reset(new QPlatformNativeInterface);
+ m_vtHandler.reset(new QFbVtHandler);
+
+ if (!qEnvironmentVariableIntValue("QT_QPA_FB_DISABLE_INPUT"))
+ createInputHandlers();
+}
+
+bool QBsdFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps:
+ return true;
+ case WindowManagement:
+ return false;
+ default:
+ return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPlatformBackingStore *QBsdFbIntegration::createPlatformBackingStore(QWindow *window) const
+{
+ return new QFbBackingStore(window);
+}
+
+QPlatformWindow *QBsdFbIntegration::createPlatformWindow(QWindow *window) const
+{
+ return new QFbWindow(window);
+}
+
+QAbstractEventDispatcher *QBsdFbIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
+QList<QPlatformScreen *> QBsdFbIntegration::screens() const
+{
+ QList<QPlatformScreen *> list;
+ list.append(m_primaryScreen.data());
+ return list;
+}
+
+QPlatformFontDatabase *QBsdFbIntegration::fontDatabase() const
+{
+ return m_fontDb.data();
+}
+
+QPlatformServices *QBsdFbIntegration::services() const
+{
+ return m_services.data();
+}
+
+void QBsdFbIntegration::createInputHandlers()
+{
+#if QT_CONFIG(tslib)
+ const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
+ if (useTslib)
+ new QTsLibMouseHandler(QLatin1String("TsLib"), QString());
+#endif
+}
+
+QPlatformNativeInterface *QBsdFbIntegration::nativeInterface() const
+{
+ return m_nativeInterface.data();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/bsdfb/qbsdfbintegration.h b/src/plugins/platforms/bsdfb/qbsdfbintegration.h
new file mode 100644
index 0000000000..2be5ea260d
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbintegration.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDFBINTEGRATION_H
+#define QBSDFBINTEGRATION_H
+
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractEventDispatcher;
+class QBsdFbScreen;
+class QFbVtHandler;
+
+class QBsdFbIntegration : public QPlatformIntegration, public QPlatformNativeInterface
+{
+public:
+ explicit QBsdFbIntegration(const QStringList &paramList);
+ ~QBsdFbIntegration() override;
+
+ void initialize() override;
+ bool hasCapability(QPlatformIntegration::Capability cap) const override;
+
+ QPlatformWindow *createPlatformWindow(QWindow *window) const override;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
+
+ QAbstractEventDispatcher *createEventDispatcher() const override;
+
+ QPlatformFontDatabase *fontDatabase() const override;
+ QPlatformServices *services() const override;
+ QPlatformInputContext *inputContext() const override { return m_inputContext.data(); }
+
+ QPlatformNativeInterface *nativeInterface() const override;
+
+ QList<QPlatformScreen *> screens() const;
+
+private:
+ void createInputHandlers();
+
+ QScopedPointer<QBsdFbScreen> m_primaryScreen;
+ QScopedPointer<QPlatformInputContext> m_inputContext;
+ QScopedPointer<QPlatformFontDatabase> m_fontDb;
+ QScopedPointer<QPlatformServices> m_services;
+ QScopedPointer<QFbVtHandler> m_vtHandler;
+ QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBSDFBINTEGRATION_H
diff --git a/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp b/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
new file mode 100644
index 0000000000..0ef57d37e5
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
@@ -0,0 +1,276 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbsdfbscreen.h"
+#include <QtFbSupport/private/qfbcursor_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
+#include <QtCore/QRegularExpression>
+#include <QtGui/QPainter>
+
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+#include <qimage.h>
+#include <qdebug.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <limits.h>
+#include <signal.h>
+
+#include <sys/consio.h>
+#include <sys/fbio.h>
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ DefaultDPI = 100
+};
+
+static int openFramebufferDevice(const QString &dev)
+{
+ const QByteArray devPath = QFile::encodeName(dev);
+
+ int fd = QT_OPEN(devPath.constData(), O_RDWR);
+
+ if (fd == -1)
+ fd = QT_OPEN(devPath.constData(), O_RDONLY);
+
+ return fd;
+}
+
+static QRect determineGeometry(const struct fbtype &fb, const QRect &userGeometry)
+{
+ int xoff = 0;
+ int yoff = 0;
+ int w = 0;
+ int h = 0;
+
+ if (userGeometry.isValid()) {
+ w = qMin(userGeometry.width(), fb.fb_width);
+ h = qMin(userGeometry.height(), fb.fb_height);
+
+ int xxoff = userGeometry.x(), yyoff = userGeometry.y();
+ if (xxoff != 0 || yyoff != 0) {
+ if (xxoff < 0 || xxoff + w > fb.fb_width)
+ xxoff = fb.fb_width - w;
+ if (yyoff < 0 || yyoff + h > fb.fb_height)
+ yyoff = fb.fb_height - h;
+ xoff += xxoff;
+ yoff += yyoff;
+ } else {
+ xoff += (fb.fb_width - w)/2;
+ yoff += (fb.fb_height - h)/2;
+ }
+ } else {
+ w = fb.fb_width;
+ h = fb.fb_height;
+ }
+
+ if (w == 0 || h == 0) {
+ qWarning("Unable to find screen geometry, using 320x240");
+ w = 320;
+ h = 240;
+ }
+
+ return QRect(xoff, yoff, w, h);
+}
+
+static QSizeF determinePhysicalSize(const QSize &mmSize, const QSize &res)
+{
+ int mmWidth = mmSize.width();
+ int mmHeight = mmSize.height();
+
+ if (mmWidth <= 0 && mmHeight <= 0) {
+ const int dpi = DefaultDPI;
+ mmWidth = qRound(res.width() * 25.4 / dpi);
+ mmHeight = qRound(res.height() * 25.4 / dpi);
+ } else if (mmWidth > 0 && mmHeight <= 0) {
+ mmHeight = res.height() * mmWidth/res.width();
+ } else if (mmHeight > 0 && mmWidth <= 0) {
+ mmWidth = res.width() * mmHeight/res.height();
+ }
+
+ return QSize(mmWidth, mmHeight);
+}
+
+QBsdFbScreen::QBsdFbScreen(const QStringList &args)
+ : m_arguments(args)
+{
+}
+
+QBsdFbScreen::~QBsdFbScreen()
+{
+ if (m_framebufferFd != -1) {
+ munmap(m_mmap.data - m_mmap.offset, m_mmap.size);
+ qt_safe_close(m_framebufferFd);
+ }
+}
+
+bool QBsdFbScreen::initialize()
+{
+ QRegularExpression fbRx(QLatin1String("fb=(.*)"));
+ QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)"));
+ QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)"));
+ QRegularExpression offsetRx(QLatin1String("offset=(\\d+)x(\\d+)"));
+
+ QString fbDevice;
+ QSize userMmSize;
+ QRect userGeometry;
+
+ // Parse arguments
+ for (const QString &arg : qAsConst(m_arguments)) {
+ QRegularExpressionMatch match;
+ if (arg.contains(mmSizeRx, &match))
+ userMmSize = QSize(match.captured(1).toInt(), match.captured(2).toInt());
+ else if (arg.contains(sizeRx, &match))
+ userGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
+ else if (arg.contains(offsetRx, &match))
+ userGeometry.setTopLeft(QPoint(match.captured(1).toInt(), match.captured(2).toInt()));
+ else if (arg.contains(fbRx, &match))
+ fbDevice = match.captured(1);
+ }
+
+ if (!fbDevice.isEmpty()) {
+ // Open the device
+ m_framebufferFd = openFramebufferDevice(fbDevice);
+ } else {
+ m_framebufferFd = STDIN_FILENO;
+ }
+
+ if (m_framebufferFd == -1) {
+ qErrnoWarning(errno, "Failed to open framebuffer %s", qPrintable(fbDevice));
+ return false;
+ }
+
+ struct fbtype fb;
+ if (ioctl(m_framebufferFd, FBIOGTYPE, &fb) != 0) {
+ qErrnoWarning(errno, "Error reading framebuffer information");
+ return false;
+ }
+
+ int line_length = 0;
+ if (ioctl(m_framebufferFd, FBIO_GETLINEWIDTH, &line_length) != 0) {
+ qErrnoWarning(errno, "Error reading line length information");
+ return false;
+ }
+
+ mDepth = fb.fb_depth;
+
+ m_bytesPerLine = line_length;
+ const QRect geometry = determineGeometry(fb, userGeometry);
+ mGeometry = QRect(QPoint(0, 0), geometry.size());
+ switch (mDepth) {
+ case 32:
+ mFormat = QImage::Format_RGB32;
+ break;
+ case 24:
+ mFormat = QImage::Format_RGB888;
+ break;
+ case 16:
+ // falling back
+ default:
+ mFormat = QImage::Format_RGB16;
+ break;
+ }
+ mPhysicalSize = determinePhysicalSize(userMmSize, geometry.size());
+
+ // mmap the framebuffer
+ const size_t pagemask = getpagesize() - 1;
+ m_mmap.size = (m_bytesPerLine * fb.fb_height + pagemask) & ~pagemask;
+ uchar *data = static_cast<uchar*>(mmap(nullptr, m_mmap.size, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebufferFd, 0));
+ if (data == MAP_FAILED) {
+ qErrnoWarning(errno, "Failed to mmap framebuffer");
+ return false;
+ }
+
+ m_mmap.offset = geometry.y() * m_bytesPerLine + geometry.x() * mDepth / 8;
+ m_mmap.data = data + m_mmap.offset;
+
+ QFbScreen::initializeCompositor();
+ m_onscreenImage = QImage(m_mmap.data, geometry.width(), geometry.height(), m_bytesPerLine, mFormat);
+
+ mCursor = new QFbCursor(this);
+
+ return true;
+}
+
+QRegion QBsdFbScreen::doRedraw()
+{
+ const QRegion touched = QFbScreen::doRedraw();
+
+ if (touched.isEmpty())
+ return touched;
+
+ if (!m_blitter)
+ m_blitter.reset(new QPainter(&m_onscreenImage));
+
+ const auto rects = touched.rects();
+ for (const QRect &rect : rects)
+ m_blitter->drawImage(rect, *mScreenImage, rect);
+ return touched;
+}
+
+// grabWindow() grabs "from the screen" not from the backingstores.
+QPixmap QBsdFbScreen::grabWindow(WId wid, int x, int y, int width, int height) const
+{
+ if (!wid) {
+ if (width < 0)
+ width = m_onscreenImage.width() - x;
+ if (height < 0)
+ height = m_onscreenImage.height() - y;
+ return QPixmap::fromImage(m_onscreenImage).copy(x, y, width, height);
+ }
+
+ const QFbWindow *window = windowForId(wid);
+ if (window) {
+ const QRect geom = window->geometry();
+ if (width < 0)
+ width = geom.width() - x;
+ if (height < 0)
+ height = geom.height() - y;
+ QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
+ rect &= window->geometry();
+ return QPixmap::fromImage(m_onscreenImage).copy(rect);
+ }
+
+ return QPixmap();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/bsdfb/qbsdfbscreen.h b/src/plugins/platforms/bsdfb/qbsdfbscreen.h
new file mode 100644
index 0000000000..3e244e3460
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbscreen.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDFBSCREEN_H
+#define QBSDFBSCREEN_H
+
+#include <QtFbSupport/private/qfbscreen_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+
+class QBsdFbScreen : public QFbScreen
+{
+ Q_OBJECT
+public:
+ explicit QBsdFbScreen(const QStringList &args);
+ ~QBsdFbScreen() override;
+
+ bool initialize();
+
+ QPixmap grabWindow(WId wid, int x, int y, int width, int height) const override;
+
+ QRegion doRedraw() override;
+
+private:
+ QStringList m_arguments;
+ int m_framebufferFd = -1;
+ QImage m_onscreenImage;
+
+ int m_bytesPerLine = -1;
+
+ struct {
+ uchar *data;
+ int offset, size;
+ } m_mmap;
+
+ QScopedPointer<QPainter> m_blitter;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBSDFBSCREEN_H
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index 02d8b16110..0664841c2d 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -71,7 +71,7 @@ HEADERS += qcocoaintegration.h \
messages.h \
qcocoamimetypes.h
-contains(QT_CONFIG, opengl.*) {
+qtConfig(opengl.*) {
OBJECTIVE_SOURCES += qcocoaglcontext.mm
HEADERS += qcocoaglcontext.h
@@ -81,7 +81,10 @@ RESOURCES += qcocoaresources.qrc
LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ accessibility_support-private clipboard_support-private theme_support-private \
+ fontdatabase_support-private graphics_support-private cgl_support-private
qtHaveModule(widgets) {
OBJECTIVE_SOURCES += \
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 1faa806480..b15c486e9d 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -359,7 +359,7 @@ id getValueAttribute(QAccessibleInterface *interface)
{
const QAccessible::Role qtrole = interface->role();
if (qtrole == QAccessible::StaticText) {
- return QCFString::toNSString(interface->text(QAccessible::Name));
+ return interface->text(QAccessible::Name).toNSString();
}
if (qtrole == QAccessible::EditableText) {
if (QAccessibleTextInterface *textInterface = interface->textInterface()) {
@@ -380,12 +380,12 @@ id getValueAttribute(QAccessibleInterface *interface)
// textInterface->textAfterOffset(0, QAccessible2::SentenceBoundary, &begin, &end);
text = textInterface->text(begin, end);
}
- return QCFString::toNSString(text);
+ return text.toNSString();
}
}
if (QAccessibleValueInterface *valueInterface = interface->valueInterface()) {
- return QCFString::toNSString(valueInterface->currentValue().toString());
+ return valueInterface->currentValue().toString().toNSString();
}
if (interface->state().checkable) {
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 7128fb72c3..97bd402b73 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -41,7 +41,7 @@
#include "qcocoahelpers.h"
#include "qcocoawindow.h"
#include "private/qaccessiblecache_p.h"
-#include <QtPlatformSupport/private/qaccessiblebridgeutils_p.h>
+#include <QtAccessibilitySupport/private/qaccessiblebridgeutils_p.h>
#include <QtGui/qaccessible.h>
#import <AppKit/NSAccessibility.h>
@@ -237,7 +237,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if (QWindow *window = iface->window()) {
QCocoaWindow *win = static_cast<QCocoaWindow*>(window->handle());
- return win->qtView();
+ return qnsview_cast(win->view());
}
QAccessibleInterface *parent = iface->parent();
@@ -300,9 +300,9 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
} else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) {
if (iface->role() == QAccessible::StaticText)
return nil;
- return QCFString::toNSString(iface->text(QAccessible::Name));
+ return iface->text(QAccessible::Name).toNSString();
} else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) {
- return QCFString::toNSString(iface->text(QAccessible::Description));
+ return iface->text(QAccessible::Description).toNSString();
} else if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) {
return [NSNumber numberWithBool:!iface->state().disabled];
} else if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
@@ -439,7 +439,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if ([attribute isEqualToString: NSAccessibilityAttributedStringForRangeParameterizedAttribute]) {
NSRange range = [parameter rangeValue];
QString text = iface->textInterface()->text(range.location, range.location + range.length);
- return [[NSAttributedString alloc] initWithString: text.toNSString()];
+ return [[NSAttributedString alloc] initWithString:text.toNSString()];
} else if ([attribute isEqualToString: NSAccessibilityRangeForPositionParameterizedAttribute]) {
NSPoint nsPoint = [parameter pointValue];
QPoint point(static_cast<int>(nsPoint.x), static_cast<int>(qt_mac_flipYCoordinate(nsPoint.y)));
@@ -532,7 +532,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
} else {
description = qAccessibleLocalizedActionDescription(qtAction);
}
- return QCFString::toNSString(description);
+ return description.toNSString();
}
- (void)accessibilityPerformAction:(NSString *)action {
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.h b/src/plugins/platforms/cocoa/qcocoaapplication.h
index e92bef4011..7bd3c8c76c 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.h
@@ -95,7 +95,6 @@
@interface NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu;
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader);
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)event;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index c496134606..c5ae4bc2bf 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -71,11 +71,11 @@
**
****************************************************************************/
-#include <qcocoaapplication.h>
+#include "qcocoaapplication.h"
-#include <qcocoaintrospection.h>
-#include <qcocoaapplicationdelegate.h>
-#include <qcocoahelpers.h>
+#include "qcocoaintrospection.h"
+#include "qcocoaapplicationdelegate.h"
+#include "qcocoahelpers.h"
#include <qguiapplication.h>
#include <qdebug.h>
@@ -88,11 +88,6 @@ QT_USE_NAMESPACE
[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu];
}
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)
-{
- return [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader];
-}
-
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel
{
Q_UNUSED(fontPanel);
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
index 68a028ed8a..59c71017e3 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
@@ -95,14 +95,11 @@
@interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) : NSObject <NSApplicationDelegate> {
bool startedQuit;
NSMenu *dockMenu;
- QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
NSObject <NSApplicationDelegate> *reflectionDelegate;
bool inLaunch;
}
+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
- (void)setDockMenu:(NSMenu *)newMenu;
-- (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void) removeAppleEventHandlers;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index d18df35b80..da755aa189 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -122,7 +122,6 @@ QT_END_NAMESPACE
{
sharedCocoaApplicationDelegate = nil;
[dockMenu release];
- [qtMenuLoader release];
if (reflectionDelegate) {
[[NSApplication sharedApplication] setDelegate:reflectionDelegate];
[reflectionDelegate release];
@@ -169,24 +168,12 @@ QT_END_NAMESPACE
return [[dockMenu retain] autorelease];
}
-- (void)setMenuLoader:(QCocoaMenuLoader *)menuLoader
-{
- [menuLoader retain];
- [qtMenuLoader release];
- qtMenuLoader = menuLoader;
-}
-
-- (QCocoaMenuLoader *)menuLoader
-{
- return [[qtMenuLoader retain] autorelease];
-}
-
- (BOOL) canQuit
{
[[NSApp mainMenu] cancelTracking];
bool handle_quit = true;
- NSMenuItem *quitMenuItem = [[[QCocoaApplicationDelegate sharedDelegate] menuLoader] quitMenuItem];
+ NSMenuItem *quitMenuItem = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) sharedMenuLoader] quitMenuItem];
if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty()
&& [quitMenuItem isEnabled]) {
int visible = 0;
@@ -309,7 +296,7 @@ QT_END_NAMESPACE
Q_UNUSED(sender);
for (NSString *fileName in filenames) {
- QString qtFileName = QCFString::toQString(fileName);
+ QString qtFileName = QString::fromNSString(fileName);
if (inLaunch) {
// We need to be careful because Cocoa will be nice enough to take
// command line arguments and send them to us as events. Given the history
@@ -437,7 +424,7 @@ QT_END_NAMESPACE
{
Q_UNUSED(replyEvent);
NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
- QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString)));
+ QWindowSystemInterface::handleFileOpenEvent(QUrl(QString::fromNSString(urlString)));
}
- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
@@ -447,10 +434,4 @@ QT_END_NAMESPACE
[NSApp terminate:self];
}
-- (void)qtDispatcherToQAction:(id)sender
-{
- Q_UNUSED(sender);
- [qtMenuLoader qtDispatcherToQPAMenuItem:sender];
-}
-
@end
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index fa05626d18..5ed455fd71 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -40,36 +40,20 @@
#ifndef QBACKINGSTORE_COCOA_H
#define QBACKINGSTORE_COCOA_H
-#include <AppKit/AppKit.h>
-
-#include "qcocoawindow.h"
-#include "qnsview.h"
-
-#include <qpa/qplatformbackingstore.h>
+#include <QtGraphicsSupport/private/qrasterbackingstore_p.h>
QT_BEGIN_NAMESPACE
-class QCocoaBackingStore : public QPlatformBackingStore
+class QCocoaBackingStore : public QRasterBackingStore
{
public:
QCocoaBackingStore(QWindow *window);
~QCocoaBackingStore();
- QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
- void flush(QWindow *widget, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
-#ifndef QT_NO_OPENGL
- QImage toImage() const Q_DECL_OVERRIDE;
-#else
- QImage toImage() const; // No QPlatformBackingStore::toImage() for NO_OPENGL builds.
-#endif
- void resize (const QSize &size, const QRegion &) Q_DECL_OVERRIDE;
- bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE;
- void beginPaint(const QRegion &region) Q_DECL_OVERRIDE;
- qreal getBackingStoreDevicePixelRatio();
+ void flush(QWindow *, const QRegion &, const QPoint &) Q_DECL_OVERRIDE;
private:
- QImage m_qImage;
- QSize m_requestedSize;
+ QImage::Format format() const Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index b060d6a082..a74995319b 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -38,87 +38,38 @@
****************************************************************************/
#include "qcocoabackingstore.h"
-#include <QtGui/QPainter>
+
+#include "qcocoawindow.h"
#include "qcocoahelpers.h"
QT_BEGIN_NAMESPACE
QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
- : QPlatformBackingStore(window)
+ : QRasterBackingStore(window)
{
}
QCocoaBackingStore::~QCocoaBackingStore()
{
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()))
- [cocoaWindow->m_qtView clearBackingStore:this];
-}
-
-QPaintDevice *QCocoaBackingStore::paintDevice()
-{
- QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle());
- int windowDevicePixelRatio = int(cocoaWindow->devicePixelRatio());
-
- // Receate the backing store buffer if the effective buffer size has changed,
- // either due to a window resize or devicePixelRatio change.
- QSize effectiveBufferSize = m_requestedSize * windowDevicePixelRatio;
- if (m_qImage.size() != effectiveBufferSize) {
- QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient)
- ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
- m_qImage = QImage(effectiveBufferSize, format);
- m_qImage.setDevicePixelRatio(windowDevicePixelRatio);
- if (format == QImage::Format_ARGB32_Premultiplied)
- m_qImage.fill(Qt::transparent);
- }
- return &m_qImage;
+ [qnsview_cast(cocoaWindow->view()) clearBackingStore:this];
}
-void QCocoaBackingStore::flush(QWindow *win, const QRegion &region, const QPoint &offset)
+QImage::Format QCocoaBackingStore::format() const
{
- if (!m_qImage.isNull()) {
- if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(win->handle()))
- [cocoaWindow->m_qtView flushBackingStore:this region:region offset:offset];
- }
-}
+ if (static_cast<QCocoaWindow *>(window()->handle())->m_drawContentBorderGradient)
+ return QImage::Format_ARGB32_Premultiplied;
-QImage QCocoaBackingStore::toImage() const
-{
- return m_qImage;
+ return QRasterBackingStore::format();
}
-void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
+void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
- m_requestedSize = size;
-}
+ if (m_image.isNull())
+ return;
-bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy)
-{
- extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
- const qreal devicePixelRatio = m_qImage.devicePixelRatio();
- QPoint qpoint(dx * devicePixelRatio, dy * devicePixelRatio);
- const QVector<QRect> qrects = area.rects();
- for (int i = 0; i < qrects.count(); ++i) {
- const QRect &qrect = QRect(qrects.at(i).topLeft() * devicePixelRatio, qrects.at(i).size() * devicePixelRatio);
- qt_scrollRectInImage(m_qImage, qrect, qpoint);
- }
- return true;
-}
-
-void QCocoaBackingStore::beginPaint(const QRegion &region)
-{
- if (m_qImage.hasAlphaChannel()) {
- QPainter p(&m_qImage);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = region.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(), end = rects.end(); it != end; ++it)
- p.fillRect(*it, blank);
- }
-}
-
-qreal QCocoaBackingStore::getBackingStoreDevicePixelRatio()
-{
- return m_qImage.devicePixelRatio();
+ if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle()))
+ [qnsview_cast(cocoaWindow->view()) flushBackingStore:this region:region offset:offset];
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.h b/src/plugins/platforms/cocoa/qcocoaclipboard.h
index 52fec61f39..cab2cfaa91 100644
--- a/src/plugins/platforms/cocoa/qcocoaclipboard.h
+++ b/src/plugins/platforms/cocoa/qcocoaclipboard.h
@@ -41,6 +41,9 @@
#define QCOCOACLIPBOARD_H
#include <qpa/qplatformclipboard.h>
+
+#ifndef QT_NO_CLIPBOARD
+
#include "qmacclipboard.h"
#include <QtCore/QScopedPointer>
@@ -71,4 +74,6 @@ private:
QT_END_NAMESPACE
-#endif
+#endif // QT_NO_CLIPBOARD
+
+#endif // QCOCOACLIPBOARD_H
diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm
index 7209c93a94..b4745900dc 100644
--- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm
+++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm
@@ -39,6 +39,8 @@
#include "qcocoaclipboard.h"
+#ifndef QT_NO_CLIPBOARD
+
QT_BEGIN_NAMESPACE
QCocoaClipboard::QCocoaClipboard()
@@ -105,3 +107,5 @@ void QCocoaClipboard::handleApplicationStateChanged(Qt::ApplicationState state)
#include "moc_qcocoaclipboard.cpp"
QT_END_NAMESPACE
+
+#endif // QT_NO_CLIPBOARD
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index f89c06fc58..7f81e313cb 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -133,7 +133,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)setDialogHelper:(QCocoaColorDialogHelper *)helper
{
mHelper = helper;
- [mColorPanel setShowsAlpha:mHelper->options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
+
if (mHelper->options()->testOption(QColorDialogOptions::NoButtons)) {
[self restoreOriginalContentView];
} else if (!mStolenContentView) {
@@ -486,6 +486,14 @@ bool QCocoaColorDialogHelper::show(Qt::WindowFlags, Qt::WindowModality windowMod
{
if (windowModality == Qt::WindowModal)
windowModality = Qt::ApplicationModal;
+
+ // Workaround for Apple rdar://25792119: If you invoke
+ // -setShowsAlpha: multiple times before showing the color
+ // picker, its height grows irrevocably. Instead, only
+ // invoke it once, when we show the dialog.
+ [[NSColorPanel sharedColorPanel] setShowsAlpha:
+ options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
+
sharedColorPanel()->init(this);
return sharedColorPanel()->show(windowModality, parent);
}
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 4870c521c7..3df2a7c962 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -40,6 +40,7 @@
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
+#include <QtGui/private/qcoregraphics_p.h>
#include <QtGui/QBitmap>
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
index bb8d12e3ce..7d11023b78 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
@@ -43,6 +43,7 @@
#ifndef QT_NO_WIDGETS
#include <QtWidgets/qwidget.h>
#endif
+#include <QtGui/private/qcoregraphics_p.h>
QT_BEGIN_NAMESPACE
@@ -131,7 +132,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
QPixmap pm = dragPixmap(m_drag, hotSpot);
QSize pmDeviceIndependentSize = pm.size() / pm.devicePixelRatio();
NSImage *nsimage = qt_mac_create_nsimage(pm);
- [nsimage setSize : qt_mac_toNSSize(pmDeviceIndependentSize)];
+ [nsimage setSize:pmDeviceIndependentSize.toCGSize()];
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index d9c835d797..72c7856c2d 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -85,7 +85,6 @@
#include "private/qguiapplication_p.h"
#include <qdebug.h>
-#undef slots
#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index c7191e4841..234da57f59 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -62,6 +62,8 @@
#include <qvarlengtharray.h>
#include <stdlib.h>
#include <qabstracteventdispatcher.h>
+#include <qsysinfo.h>
+#include <qglobal.h>
#include <QDir>
#include <qpa/qplatformnativeinterface.h>
@@ -144,14 +146,14 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
QFileInfo sel(selectFile);
if (sel.isDir() && !sel.isBundle()){
- mCurrentDir = [QCFString::toNSString(sel.absoluteFilePath()) retain];
+ mCurrentDir = [sel.absoluteFilePath().toNSString() retain];
mCurrentSelection = new QString;
} else {
- mCurrentDir = [QCFString::toNSString(sel.absolutePath()) retain];
+ mCurrentDir = [sel.absolutePath().toNSString() retain];
mCurrentSelection = new QString(sel.absoluteFilePath());
}
- [mSavePanel setTitle:QCFString::toNSString(options->windowTitle())];
+ [mSavePanel setTitle:options->windowTitle().toNSString()];
[self createPopUpButton:selectedVisualNameFilter hideDetails:options->testOption(QFileDialogOptions::HideNameFilterDetails)];
[self createTextField];
[self createAccessory];
@@ -161,6 +163,11 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
// here to make sure it gets the correct value.
[mSavePanel setDelegate:self];
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_11)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_11)
+ mOpenPanel.accessoryViewDisclosed = YES;
+#endif
+
if (mOptions->isLabelExplicitlySet(QFileDialogOptions::Accept))
[mSavePanel setPrompt:[self strip:options->labelText(QFileDialogOptions::Accept)]];
if (mOptions->isLabelExplicitlySet(QFileDialogOptions::FileName))
@@ -197,12 +204,12 @@ static QString strippedText(QString s)
- (NSString *)strip:(const QString &)label
{
- return QCFString::toNSString(strippedText(label));
+ return strippedText(label).toNSString();
}
- (void)closePanel
{
- *mCurrentSelection = QCFString::toQString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
+ *mCurrentSelection = QString::fromNSString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
if ([mSavePanel respondsToSelector:@selector(close)])
[mSavePanel close];
if ([mSavePanel isSheet])
@@ -213,14 +220,14 @@ static QString strippedText(QString s)
{
if (mOpenPanel){
QFileInfo info(*mCurrentSelection);
- NSString *filepath = QCFString::toNSString(info.filePath());
+ NSString *filepath = info.filePath().toNSString();
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
[self updateProperties];
QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
[mOpenPanel setAllowedFileTypes:nil];
- [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""];
+ [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
[mOpenPanel beginWithCompletionHandler:^(NSInteger result){
mReturnCode = result;
@@ -233,12 +240,12 @@ static QString strippedText(QString s)
- (BOOL)runApplicationModalPanel
{
QFileInfo info(*mCurrentSelection);
- NSString *filepath = QCFString::toNSString(info.filePath());
+ NSString *filepath = info.filePath().toNSString();
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];
- [mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""];
+ [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
// Call processEvents in case the event dispatcher has been interrupted, and needs to do
// cleanup of modal sessions. Do this before showing the native dialog, otherwise it will
@@ -264,7 +271,7 @@ static QString strippedText(QString s)
- (void)showWindowModalSheet:(QWindow *)parent
{
QFileInfo info(*mCurrentSelection);
- NSString *filepath = QCFString::toNSString(info.filePath());
+ NSString *filepath = info.filePath().toNSString();
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
@@ -272,7 +279,7 @@ static QString strippedText(QString s)
QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];
- [mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""];
+ [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
NSWindow *nsparent = static_cast<NSWindow *>(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent));
[mSavePanel beginSheetModalForWindow:nsparent completionHandler:^(NSInteger result){
@@ -319,7 +326,7 @@ static QString strippedText(QString s)
}
}
- QString qtFileName = QFileInfo(QCFString::toQString(filename)).fileName();
+ QString qtFileName = QFileInfo(QString::fromNSString(filename)).fileName();
// No filter means accept everything
bool nameMatches = mSelectedNameFilter->isEmpty();
// Check if the current file name filter accepts the file:
@@ -371,7 +378,7 @@ static QString strippedText(QString s)
if (filters.size() > 0){
for (int i=0; i<filters.size(); ++i) {
QString filter = hideDetails ? [self removeExtensions:filters.at(i)] : filters.at(i);
- [mPopUpButton addItemWithTitle:QCFString::toNSString(filter)];
+ [mPopUpButton addItemWithTitle:filter.toNSString()];
}
[mPopUpButton selectItemAtIndex:0];
[mSavePanel setAccessoryView:mAccessoryView];
@@ -405,13 +412,13 @@ static QString strippedText(QString s)
QList<QUrl> result;
NSArray* array = [mOpenPanel URLs];
for (NSUInteger i=0; i<[array count]; ++i) {
- QString path = QCFString::toQString([[array objectAtIndex:i] path]).normalized(QString::NormalizationForm_C);
+ QString path = QString::fromNSString([[array objectAtIndex:i] path]).normalized(QString::NormalizationForm_C);
result << QUrl::fromLocalFile(path);
}
return result;
} else {
QList<QUrl> result;
- QString filename = QCFString::toQString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
+ QString filename = QString::fromNSString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
result << QUrl::fromLocalFile(filename.remove(QLatin1String("___qt_very_unlikely_prefix_")));
return result;
}
@@ -434,8 +441,8 @@ static QString strippedText(QString s)
[mSavePanel setCanCreateDirectories:!(mOptions->testOption(QFileDialogOptions::ReadOnly))];
[mOpenPanel setAllowsMultipleSelection:(fileMode == QFileDialogOptions::ExistingFiles)];
[mOpenPanel setResolvesAliases:!(mOptions->testOption(QFileDialogOptions::DontResolveSymlinks))];
- [mOpenPanel setTitle:QCFString::toNSString(mOptions->windowTitle())];
- [mSavePanel setTitle:QCFString::toNSString(mOptions->windowTitle())];
+ [mOpenPanel setTitle:mOptions->windowTitle().toNSString()];
+ [mSavePanel setTitle:mOptions->windowTitle().toNSString()];
[mPopUpButton setHidden:chooseDirsOnly]; // TODO hide the whole sunken pane instead?
QStringList ext = [self acceptableExtensionsForSave];
@@ -454,7 +461,7 @@ static QString strippedText(QString s)
{
Q_UNUSED(sender);
if (mHelper && [mSavePanel isVisible]) {
- QString selection = QCFString::toQString([[mSavePanel URL] path]);
+ QString selection = QString::fromNSString([[mSavePanel URL] path]);
if (selection != mCurrentSelection) {
*mCurrentSelection = selection;
mHelper->QNSOpenSavePanelDelegate_selectionChanged(selection);
@@ -472,7 +479,7 @@ static QString strippedText(QString s)
[mCurrentDir release];
mCurrentDir = [path retain];
- mHelper->QNSOpenSavePanelDelegate_directoryEntered(QCFString::toQString(mCurrentDir));
+ mHelper->QNSOpenSavePanelDelegate_directoryEntered(QString::fromNSString(mCurrentDir));
}
/*
@@ -535,7 +542,7 @@ static QString strippedText(QString s)
(filterToUse == -1 && currentFilter.startsWith(selectedFilter)))
filterToUse = i;
QString filter = hideDetails ? [self removeExtensions:currentFilter] : currentFilter;
- [mPopUpButton addItemWithTitle:QCFString::toNSString(filter)];
+ [mPopUpButton addItemWithTitle:filter.toNSString()];
}
if (filterToUse != -1)
[mPopUpButton selectItemAtIndex:filterToUse];
@@ -607,7 +614,7 @@ void QCocoaFileDialogHelper::QNSOpenSavePanelDelegate_filterSelected(int menuInd
void QCocoaFileDialogHelper::setDirectory(const QUrl &directory)
{
if (mDelegate)
- [mDelegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory.toLocalFile())]];
+ [mDelegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:directory.toLocalFile().toNSString()]];
else
mDir = directory;
}
@@ -615,7 +622,7 @@ void QCocoaFileDialogHelper::setDirectory(const QUrl &directory)
QUrl QCocoaFileDialogHelper::directory() const
{
if (mDelegate) {
- QString path = QCFString::toQString([[mDelegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C);
+ QString path = QString::fromNSString([[mDelegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C);
return QUrl::fromLocalFile(path);
}
return mDir;
@@ -644,7 +651,7 @@ void QCocoaFileDialogHelper::setFilter()
if (!mDelegate)
return;
const SharedPointerFileDialogOptions &opts = options();
- [mDelegate->mSavePanel setTitle:QCFString::toNSString(opts->windowTitle())];
+ [mDelegate->mSavePanel setTitle:opts->windowTitle().toNSString()];
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
[mDelegate->mSavePanel setPrompt:[mDelegate strip:opts->labelText(QFileDialogOptions::Accept)]];
if (opts->isLabelExplicitlySet(QFileDialogOptions::FileName))
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 32c4077961..791839d6ea 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -163,7 +163,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
{
mHelper = helper;
- [mFontPanel setTitle:QCFString::toNSString(helper->options()->windowTitle())];
+ [mFontPanel setTitle:helper->options()->windowTitle().toNSString()];
if (mHelper->options()->testOption(QFontDialogOptions::NoButtons)) {
[self restoreOriginalContentView];
@@ -447,7 +447,7 @@ public:
}
QFontInfo fontInfo(font);
- nsFont = [mgr fontWithFamily:QCFString::toNSString(fontInfo.family())
+ nsFont = [mgr fontWithFamily:fontInfo.family().toNSString()
traits:mask
weight:weight
size:fontInfo.pointSize()];
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index 5bee708b76..1a66cec0e3 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -45,7 +45,6 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QWindow>
-#undef slots
#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index ccb11f80f1..a7cc19b3bf 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -42,7 +42,7 @@
#include "qcocoahelpers.h"
#include <qdebug.h>
#include <QtCore/private/qcore_mac_p.h>
-#include <QtPlatformSupport/private/cglconvenience_p.h>
+#include <QtCglSupport/private/cglconvenience_p.h>
#include <QtPlatformHeaders/qcocoanativecontext.h>
#include <dlfcn.h>
@@ -255,7 +255,7 @@ void QCocoaGLContext::setActiveWindow(QWindow *window)
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
cocoaWindow->setCurrentContext(this);
- [(QNSView *) cocoaWindow->contentView() setQCocoaGLContext:this];
+ [(QNSView *) cocoaWindow->view() setQCocoaGLContext:this];
}
void QCocoaGLContext::updateSurfaceFormat()
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index ec2f7f8cf1..1b038a6b5e 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -55,6 +55,8 @@
#include <QtGui/qpalette.h>
#include <QtGui/qscreen.h>
+Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSView));
+
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaCocoaWindow)
@@ -69,39 +71,15 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list);
inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qstrlist)
{ return reinterpret_cast<NSMutableArray *>(qt_mac_QStringListToNSMutableArrayVoid(qstrlist)); }
-NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge);
-NSImage *qt_mac_create_nsimage(const QPixmap &pm);
-NSImage *qt_mac_create_nsimage(const QIcon &icon);
-CGImageRef qt_mac_toCGImage(const QImage &qImage);
-CGImageRef qt_mac_toCGImageMask(const QImage &qImage);
-QImage qt_mac_toQImage(CGImageRef image);
-QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size);
-
-NSSize qt_mac_toNSSize(const QSize &qtSize);
-NSRect qt_mac_toNSRect(const QRect &rect);
-QRect qt_mac_toQRect(const NSRect &rect);
-
-QColor qt_mac_toQColor(const NSColor *color);
-QColor qt_mac_toQColor(CGColorRef color);
-
-QBrush qt_mac_toQBrush(CGColorRef color);
-QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup = QPalette::Normal);
-
-// Creates a mutable shape, it's the caller's responsibility to release.
-HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region);
-
-OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage);
-
NSDragOperation qt_mac_mapDropAction(Qt::DropAction action);
NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions);
Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions);
Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions);
+QT_MANGLE_NAMESPACE(QNSView) *qnsview_cast(NSView *view);
+
// Misc
void qt_mac_transformProccessToForegroundApplication();
-CGColorSpaceRef qt_mac_genericColorSpace();
-CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget);
-CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice);
QString qt_mac_applicationName();
int qt_mac_flipYCoordinate(int y);
@@ -114,10 +92,6 @@ NSRect qt_mac_flipRect(const QRect &rect);
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
-bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret);
-bool qt_mac_execute_apple_script(const char *script, AEDesc *ret);
-bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
-
// strip out '&' characters, and convert "&&" to a single '&', in menu
// text - since menu text is sometimes decorated with these for Windows
// accelerators.
@@ -151,8 +125,6 @@ public:
}
};
-CGContextRef qt_mac_cg_context(QPaintDevice *pdev);
-
template<typename T>
T qt_mac_resolveOption(const T &fallback, const QByteArray &environment)
{
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 606b2e7032..c57567bdd6 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -40,13 +40,14 @@
#include <qpa/qplatformtheme.h>
#include "qcocoahelpers.h"
-
+#include "qnsview.h"
#include <QtCore>
#include <QtGui>
#include <qpa/qplatformscreen.h>
#include <private/qguiapplication_p.h>
#include <private/qwindow_p.h>
+#include <QtGui/private/qcoregraphics_p.h>
#ifndef QT_NO_WIDGETS
#include <QtWidgets/QWidget>
@@ -56,25 +57,6 @@
#include <Carbon/Carbon.h>
-@interface NSGraphicsContext (QtAdditions)
-
-+ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState;
-
-@end
-
-@implementation NSGraphicsContext (QtAdditions)
-
-+ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState
-{
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10)
- return [self graphicsContextWithCGContext:graphicsPort flipped:initialFlippedState];
-#endif
- return [self graphicsContextWithGraphicsPort:graphicsPort flipped:initialFlippedState];
-}
-
-@end
-
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaCocoaWindow, "qt.qpa.cocoa.window");
@@ -88,7 +70,7 @@ QStringList qt_mac_NSArrayToQStringList(void *nsarray)
QStringList result;
NSArray *array = static_cast<NSArray *>(nsarray);
for (NSUInteger i=0; i<[array count]; ++i)
- result << QCFString::toQString([array objectAtIndex:i]);
+ result << QString::fromNSString([array objectAtIndex:i]);
return result;
}
@@ -101,291 +83,6 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
return result;
}
-static void qt_mac_deleteImage(void *image, const void *, size_t)
-{
- delete static_cast<QImage *>(image);
-}
-
-// Creates a CGDataProvider with the data from the given image.
-// The data provider retains a copy of the image.
-CGDataProviderRef qt_mac_CGDataProvider(const QImage &image)
-{
- return CGDataProviderCreateWithData(new QImage(image), image.bits(),
- image.byteCount(), qt_mac_deleteImage);
-}
-
-CGImageRef qt_mac_toCGImage(const QImage &inImage)
-{
- if (inImage.isNull())
- return 0;
-
- QImage image = inImage;
-
- uint cgflags = kCGImageAlphaNone;
- switch (image.format()) {
- case QImage::Format_ARGB32:
- cgflags = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
- break;
- case QImage::Format_RGB32:
- cgflags = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
- break;
- case QImage::Format_RGB888:
- cgflags = kCGImageAlphaNone | kCGBitmapByteOrder32Big;
- break;
- case QImage::Format_RGBA8888_Premultiplied:
- cgflags = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big;
- break;
- case QImage::Format_RGBA8888:
- cgflags = kCGImageAlphaLast | kCGBitmapByteOrder32Big;
- break;
- case QImage::Format_RGBX8888:
- cgflags = kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big;
- break;
- default:
- // Everything not recognized explicitly is converted to ARGB32_Premultiplied.
- image = inImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- // no break;
- case QImage::Format_ARGB32_Premultiplied:
- cgflags = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
- break;
- }
-
- QCFType<CGDataProviderRef> dataProvider = qt_mac_CGDataProvider(image);
- return CGImageCreate(image.width(), image.height(), 8, 32,
- image.bytesPerLine(),
- qt_mac_genericColorSpace(),
- cgflags, dataProvider, 0, false, kCGRenderingIntentDefault);
-}
-
-CGImageRef qt_mac_toCGImageMask(const QImage &image)
-{
- QCFType<CGDataProviderRef> dataProvider = qt_mac_CGDataProvider(image);
- return CGImageMaskCreate(image.width(), image.height(), 8, image.depth(),
- image.bytesPerLine(), dataProvider, NULL, false);
-}
-
-NSImage *qt_mac_cgimage_to_nsimage(CGImageRef image)
-{
- NSImage *newImage = [[NSImage alloc] initWithCGImage:image size:NSZeroSize];
- return newImage;
-}
-
-NSImage *qt_mac_create_nsimage(const QPixmap &pm)
-{
- if (pm.isNull())
- return 0;
- QImage image = pm.toImage();
- CGImageRef cgImage = qt_mac_toCGImage(image);
- NSImage *nsImage = qt_mac_cgimage_to_nsimage(cgImage);
- CGImageRelease(cgImage);
- return nsImage;
-}
-
-NSImage *qt_mac_create_nsimage(const QIcon &icon)
-{
- if (icon.isNull())
- return nil;
-
- NSImage *nsImage = [[NSImage alloc] init];
- foreach (QSize size, icon.availableSizes()) {
- QPixmap pm = icon.pixmap(size);
- QImage image = pm.toImage();
- CGImageRef cgImage = qt_mac_toCGImage(image);
- NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
- [nsImage addRepresentation:imageRep];
- [imageRep release];
- CGImageRelease(cgImage);
- }
- return nsImage;
-}
-
-HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region)
-{
- HIMutableShapeRef shape = HIShapeCreateMutable();
- QVector<QRect> rects = region.rects();
- if (!rects.isEmpty()) {
- int n = rects.count();
- const QRect *qt_r = rects.constData();
- while (n--) {
- CGRect cgRect = CGRectMake(qt_r->x(), qt_r->y(), qt_r->width(), qt_r->height());
- HIShapeUnionWithRect(shape, &cgRect);
- ++qt_r;
- }
- }
- return shape;
-}
-
-NSSize qt_mac_toNSSize(const QSize &qtSize)
-{
- return NSMakeSize(qtSize.width(), qtSize.height());
-}
-
-NSRect qt_mac_toNSRect(const QRect &rect)
-{
- return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-QRect qt_mac_toQRect(const NSRect &rect)
-{
- return QRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
-QColor qt_mac_toQColor(const NSColor *color)
-{
- QColor qtColor;
- NSString *colorSpace = [color colorSpaceName];
- if (colorSpace == NSDeviceCMYKColorSpace) {
- CGFloat cyan, magenta, yellow, black, alpha;
- [color getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha];
- qtColor.setCmykF(cyan, magenta, yellow, black, alpha);
- } else {
- NSColor *tmpColor;
- tmpColor = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
- CGFloat red, green, blue, alpha;
- [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
- qtColor.setRgbF(red, green, blue, alpha);
- }
- return qtColor;
-}
-
-QColor qt_mac_toQColor(CGColorRef color)
-{
- QColor qtColor;
- CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color));
- const CGFloat *components = CGColorGetComponents(color);
- if (model == kCGColorSpaceModelRGB) {
- qtColor.setRgbF(components[0], components[1], components[2], components[3]);
- } else if (model == kCGColorSpaceModelCMYK) {
- qtColor.setCmykF(components[0], components[1], components[2], components[3]);
- } else if (model == kCGColorSpaceModelMonochrome) {
- qtColor.setRgbF(components[0], components[0], components[0], components[1]);
- } else {
- // Colorspace we can't deal with.
- qWarning("Qt: qt_mac_toQColor: cannot convert from colorspace model: %d", model);
- Q_ASSERT(false);
- }
- return qtColor;
-}
-
-QBrush qt_mac_toQBrush(CGColorRef color)
-{
- QBrush qtBrush;
- CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color));
- if (model == kCGColorSpaceModelPattern) {
- // Colorspace we can't deal with; the color is drawn directly using a callback.
- qWarning("Qt: qt_mac_toQBrush: cannot convert from colorspace model: %d", model);
- Q_ASSERT(false);
- } else {
- qtBrush.setStyle(Qt::SolidPattern);
- qtBrush.setColor(qt_mac_toQColor(color));
- }
- return qtBrush;
-}
-
-static bool qt_mac_isSystemColorOrInstance(const NSColor *color, NSString *colorNameComponent, NSString *className)
-{
- // We specifically do not want isKindOfClass: here
- if ([color.className isEqualToString:className]) // NSPatternColorSpace
- return true;
- if ([color.catalogNameComponent isEqualToString:@"System"] &&
- [color.colorNameComponent isEqualToString:colorNameComponent] &&
- [color.colorSpaceName isEqualToString:NSNamedColorSpace])
- return true;
- return false;
-}
-
-QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup)
-{
- QBrush qtBrush;
-
- // QTBUG-49773: This calls NSDrawMenuItemBackground to render a 1 by n gradient; could use HITheme
- if ([color.className isEqualToString:@"NSMenuItemHighlightColor"]) {
- qWarning("Qt: qt_mac_toQBrush: cannot convert from NSMenuItemHighlightColor");
- return qtBrush;
- }
-
- // Not a catalog color or a manifestation of System.windowBackgroundColor;
- // only retrieved from NSWindow.backgroundColor directly
- if ([color.className isEqualToString:@"NSMetalPatternColor"]) {
- // NSTexturedBackgroundWindowMask, could theoretically handle this without private API by
- // creating a window with the appropriate properties and then calling NSWindow.backgroundColor.patternImage,
- // which returns a texture sized 1 by (window height, including frame), backed by a CGPattern
- // which follows the window key state... probably need to allow QBrush to store a function pointer
- // like CGPattern does
- qWarning("Qt: qt_mac_toQBrush: cannot convert from NSMetalPatternColor");
- return qtBrush;
- }
-
- // No public API to get these colors/stops;
- // both accurately obtained through runtime object inspection on OS X 10.11
- // (the NSColor object has NSGradient i-vars for both color groups)
- if (qt_mac_isSystemColorOrInstance(color, @"_sourceListBackgroundColor", @"NSSourceListBackgroundColor")) {
- QLinearGradient gradient;
- if (colorGroup == QPalette::Active) {
- gradient.setColorAt(0, QColor(233, 237, 242));
- gradient.setColorAt(0.5, QColor(225, 229, 235));
- gradient.setColorAt(1, QColor(209, 216, 224));
- } else {
- gradient.setColorAt(0, QColor(248, 248, 248));
- gradient.setColorAt(0.5, QColor(240, 240, 240));
- gradient.setColorAt(1, QColor(235, 235, 235));
- }
- return QBrush(gradient);
- }
-
- // A couple colors are special... they are actually instances of NSGradientPatternColor, which
- // override set/setFill/setStroke to instead initialize an internal color
- // ([NSColor colorWithCalibratedWhite:0.909804 alpha:1.000000]) while still returning the
- // ruled lines pattern image (from OS X 10.4) to the user from -[NSColor patternImage]
- // (and providing no public API to get the underlying color without this insanity)
- if (qt_mac_isSystemColorOrInstance(color, @"controlColor", @"NSGradientPatternColor") ||
- qt_mac_isSystemColorOrInstance(color, @"windowBackgroundColor", @"NSGradientPatternColor")) {
- static QColor newColor;
- if (!newColor.isValid()) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- newColor = qt_mac_toQColor(color.CGColor);
- } else
-#endif
- {
- NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
- pixelsWide:1
- pixelsHigh:1
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:4
- bitsPerPixel:32];
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep]];
- NSEraseRect(NSMakeRect(0, 0, 1, 1));
- [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)];
- [NSGraphicsContext restoreGraphicsState];
- NSUInteger pixel[4];
- [offscreenRep getPixel:pixel atX:0 y:0];
- [offscreenRep release];
- newColor = QColor(pixel[0], pixel[1], pixel[2], pixel[3]);
- }
- }
-
- qtBrush.setStyle(Qt::SolidPattern);
- qtBrush.setColor(newColor);
- return qtBrush;
- }
-
- if (NSColor *patternColor = [color colorUsingColorSpaceName:NSPatternColorSpace]) {
- NSImage *patternImage = patternColor.patternImage;
- const QSizeF sz(patternImage.size.width, patternImage.size.height);
- qtBrush.setTexture(qt_mac_toQPixmap(patternImage, sz)); // QTBUG-49774
- } else {
- qtBrush.setStyle(Qt::SolidPattern);
- qtBrush.setColor(qt_mac_toQColor(color));
- }
- return qtBrush;
-}
-
struct dndenum_mapper
{
NSDragOperation mac_code;
@@ -446,7 +143,30 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions)
return actions;
}
+/*!
+ Returns the view cast to a QNSview if possible.
+
+ If the view is not a QNSView, nil is returned, which is safe to
+ send messages to, effectivly making [qnsview_cast(view) message]
+ a no-op.
+ For extra verbosity and clearer code, please consider checking
+ that window()->type() != Qt::ForeignWindow before using this cast.
+
+ Do not use this method soley to check for foreign windows, as
+ that will make the code harder to read for people not working
+ primarily on macOS, who do not know the difference between the
+ NSView and QNSView cases.
+*/
+QNSView *qnsview_cast(NSView *view)
+{
+ if (![view isKindOfClass:[QNSView class]]) {
+ qCWarning(lcQpaCocoaWindow) << "NSView is not QNSView, consider checking for Qt::ForeignWindow";
+ return nil;
+ }
+
+ return static_cast<QNSView *>(view);
+}
//
// Misc
@@ -464,7 +184,7 @@ void qt_mac_transformProccessToForegroundApplication()
// Officially it's supposed to be a string, a boolean makes sense, so we'll check.
// A number less so, but OK.
if (valueType == CFStringGetTypeID())
- forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt());
+ forceTransform = !(QString::fromCFString(static_cast<CFStringRef>(value)).toInt());
else if (valueType == CFBooleanGetTypeID())
forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value));
else if (valueType == CFNumberGetTypeID()) {
@@ -482,7 +202,7 @@ void qt_mac_transformProccessToForegroundApplication()
if (valueType == CFBooleanGetTypeID())
forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value));
else if (valueType == CFStringGetTypeID())
- forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt());
+ forceTransform = !(QString::fromCFString(static_cast<CFStringRef>(value)).toInt());
else if (valueType == CFNumberGetTypeID()) {
int valueAsInt;
CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt);
@@ -495,104 +215,13 @@ void qt_mac_transformProccessToForegroundApplication()
[[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular];
}
}
-static CGColorSpaceRef m_genericColorSpace = 0;
-static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
-static bool m_postRoutineRegistered = false;
-
-CGColorSpaceRef qt_mac_genericColorSpace()
-{
-#if 0
- if (!m_genericColorSpace) {
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
- m_genericColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
- } else
- {
- m_genericColorSpace = CGColorSpaceCreateDeviceRGB();
- }
- if (!m_postRoutineRegistered) {
- m_postRoutineRegistered = true;
- qAddPostRoutine(QCoreGraphicsPaintEngine::cleanUpMacColorSpaces);
- }
- }
- return m_genericColorSpace;
-#else
- // Just return the main display colorspace for the moment.
- return qt_mac_displayColorSpace(0);
-#endif
-}
-
-/*
- Ideally, we should pass the widget in here, and use CGGetDisplaysWithRect() etc.
- to support multiple displays correctly.
-*/
-CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget)
-{
- CGColorSpaceRef colorSpace;
-
- CGDirectDisplayID displayID;
- if (widget == 0) {
- displayID = CGMainDisplayID();
- } else {
- displayID = CGMainDisplayID();
- /*
- ### get correct display
- const QRect &qrect = widget->window()->geometry();
- CGRect rect = CGRectMake(qrect.x(), qrect.y(), qrect.width(), qrect.height());
- CGDisplayCount throwAway;
- CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway);
- if (dErr != kCGErrorSuccess)
- return macDisplayColorSpace(0); // fall back on main display
- */
- }
- if ((colorSpace = m_displayColorSpaceHash.value(displayID)))
- return colorSpace;
-
- colorSpace = CGDisplayCopyColorSpace(displayID);
- if (colorSpace == 0)
- colorSpace = CGColorSpaceCreateDeviceRGB();
-
- m_displayColorSpaceHash.insert(displayID, colorSpace);
- if (!m_postRoutineRegistered) {
- m_postRoutineRegistered = true;
- void qt_mac_cleanUpMacColorSpaces();
- qAddPostRoutine(qt_mac_cleanUpMacColorSpaces);
- }
- return colorSpace;
-}
-
-void qt_mac_cleanUpMacColorSpaces()
-{
- if (m_genericColorSpace) {
- CFRelease(m_genericColorSpace);
- m_genericColorSpace = 0;
- }
- QHash<CGDirectDisplayID, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin();
- while (it != m_displayColorSpaceHash.constEnd()) {
- if (it.value())
- CFRelease(it.value());
- ++it;
- }
- m_displayColorSpaceHash.clear();
-}
-
-CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice)
-{
-#ifdef QT_NO_WIDGETS
- Q_UNUSED(paintDevice)
- return qt_mac_displayColorSpace(0);
-#else
- bool isWidget = (paintDevice->devType() == QInternal::Widget);
- return qt_mac_displayColorSpace(isWidget ? static_cast<const QWidget *>(paintDevice): 0);
-#endif
-
-}
QString qt_mac_applicationName()
{
QString appName;
CFTypeRef string = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("CFBundleName"));
if (string)
- appName = QCFString::toQString(static_cast<CFStringRef>(string));
+ appName = QString::fromCFString(static_cast<CFStringRef>(string));
if (appName.isEmpty()) {
QString arg0 = QGuiApplicationPrivate::instance()->appName();
@@ -650,28 +279,6 @@ NSRect qt_mac_flipRect(const QRect &rect)
return NSMakeRect(rect.x(), flippedY, rect.width(), rect.height());
}
-OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
-{
- // Verbatim copy if HIViewDrawCGImage (as shown on Carbon-Dev)
- OSStatus err = noErr;
-
- require_action(inContext != NULL, InvalidContext, err = paramErr);
- require_action(inBounds != NULL, InvalidBounds, err = paramErr);
- require_action(inImage != NULL, InvalidImage, err = paramErr);
-
- CGContextSaveGState( inContext );
- CGContextTranslateCTM (inContext, 0, inBounds->origin.y + CGRectGetMaxY(*inBounds));
- CGContextScaleCTM(inContext, 1, -1);
-
- CGContextDrawImage(inContext, *inBounds, inImage);
-
- CGContextRestoreGState(inContext);
-InvalidImage:
-InvalidBounds:
-InvalidContext:
- return err;
-}
-
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
{
if (buttonNum == 0)
@@ -687,146 +294,9 @@ Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
return Qt::NoButton;
}
-bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) {
- OSStatus err;
- AEDesc scriptTextDesc;
- ComponentInstance theComponent = 0;
- OSAID scriptID = kOSANullScript, resultID = kOSANullScript;
-
- // set up locals to a known state
- AECreateDesc(typeNull, 0, 0, &scriptTextDesc);
- scriptID = kOSANullScript;
- resultID = kOSANullScript;
-
- // open the scripting component
- theComponent = OpenDefaultComponent(kOSAComponentType, typeAppleScript);
- if (!theComponent) {
- err = paramErr;
- goto bail;
- }
-
- // put the script text into an aedesc
- err = AECreateDesc(typeUTF8Text, script, script_len, &scriptTextDesc);
- if (err != noErr)
- goto bail;
-
- // compile the script
- err = OSACompile(theComponent, &scriptTextDesc, kOSAModeNull, &scriptID);
- if (err != noErr)
- goto bail;
-
- // run the script
- err = OSAExecute(theComponent, scriptID, kOSANullScript, kOSAModeNull, &resultID);
-
- // collect the results - if any
- if (ret) {
- AECreateDesc(typeNull, 0, 0, ret);
- if (err == errOSAScriptError)
- OSAScriptError(theComponent, kOSAErrorMessage, typeChar, ret);
- else if (err == noErr && resultID != kOSANullScript)
- OSADisplay(theComponent, resultID, typeChar, kOSAModeNull, ret);
- }
-bail:
- AEDisposeDesc(&scriptTextDesc);
- if (scriptID != kOSANullScript)
- OSADispose(theComponent, scriptID);
- if (resultID != kOSANullScript)
- OSADispose(theComponent, resultID);
- if (theComponent)
- CloseComponent(theComponent);
- return err == noErr;
-}
-
-bool qt_mac_execute_apple_script(const char *script, AEDesc *ret)
-{
- return qt_mac_execute_apple_script(script, qstrlen(script), ret);
-}
-
-bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret)
-{
- const QByteArray l = script.toUtf8(); return qt_mac_execute_apple_script(l.constData(), l.size(), ret);
-}
-
QString qt_mac_removeAmpersandEscapes(QString s)
{
return QPlatformTheme::removeMnemonics(s).trimmed();
}
-/*! \internal
-
- Returns the CoreGraphics CGContextRef of the paint device. 0 is
- returned if it can't be obtained. It is the caller's responsibility to
- CGContextRelease the context when finished using it.
-
- \warning This function is only available on \macos.
- \warning This function is duplicated in qmacstyle_mac.mm
- */
-CGContextRef qt_mac_cg_context(QPaintDevice *pdev)
-{
- // In Qt 5, QWidget and QPixmap (and QImage) paint devices are all QImages under the hood.
- QImage *image = 0;
- if (pdev->devType() == QInternal::Image) {
- image = static_cast<QImage *>(pdev);
- } else if (pdev->devType() == QInternal::Pixmap) {
-
- const QPixmap *pm = static_cast<const QPixmap*>(pdev);
- QPlatformPixmap *data = const_cast<QPixmap *>(pm)->data_ptr().data();
- if (data && data->classId() == QPlatformPixmap::RasterClass) {
- image = data->buffer();
- } else {
- qDebug("qt_mac_cg_context: Unsupported pixmap class");
- }
- } else if (pdev->devType() == QInternal::Widget) {
- // TODO test: image = static_cast<QImage *>(static_cast<const QWidget *>(pdev)->backingStore()->paintDevice());
- qDebug("qt_mac_cg_context: not implemented: Widget class");
- }
-
- if (!image)
- return 0; // Context type not supported.
-
- CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev);
- uint flags = kCGImageAlphaPremultipliedFirst;
- flags |= kCGBitmapByteOrder32Host;
- CGContextRef ret = 0;
- ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
- 8, image->bytesPerLine(), colorspace, flags);
- CGContextTranslateCTM(ret, 0, image->height());
- CGContextScaleCTM(ret, 1, -1);
- return ret;
-}
-
-QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size)
-{
- const NSSize pixmapSize = NSMakeSize(size.width(), size.height());
- QPixmap pixmap(pixmapSize.width, pixmapSize.height);
- pixmap.fill(Qt::transparent);
- [image setSize:pixmapSize];
- const NSRect iconRect = NSMakeRect(0, 0, pixmapSize.width, pixmapSize.height);
- QMacCGContext ctx(&pixmap);
- if (!ctx)
- return QPixmap();
- NSGraphicsContext *gc = [NSGraphicsContext qt_graphicsContextWithCGContext:ctx flipped:YES];
- if (!gc)
- return QPixmap();
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:gc];
- [image drawInRect:iconRect fromRect:iconRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
- [NSGraphicsContext restoreGraphicsState];
- return pixmap;
-}
-
-QImage qt_mac_toQImage(CGImageRef image)
-{
- const size_t w = CGImageGetWidth(image),
- h = CGImageGetHeight(image);
- QImage ret(w, h, QImage::Format_ARGB32_Premultiplied);
- ret.fill(Qt::transparent);
- CGRect rect = CGRectMake(0, 0, w, h);
- CGContextRef ctx = qt_mac_cg_context(&ret);
- qt_mac_drawCGImage(ctx, &rect, image);
- CGContextRelease(ctx);
- return ret;
-}
-
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
index 04d6d6b806..9e3d747cd7 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
@@ -41,6 +41,7 @@
#include "qcocoainputcontext.h"
#include "qcocoanativeinterface.h"
#include "qcocoawindow.h"
+#include "qcocoahelpers.h"
#include <Carbon/Carbon.h>
@@ -102,7 +103,8 @@ void QCocoaInputContext::reset()
if (!mWindow)
return;
- QNSView *view = static_cast<QCocoaWindow *>(mWindow->handle())->qtView();
+ QCocoaWindow *window = static_cast<QCocoaWindow *>(mWindow->handle());
+ QNSView *view = qnsview_cast(window->view());
if (!view)
return;
@@ -131,7 +133,7 @@ void QCocoaInputContext::updateLocale()
CFArrayRef languages = (CFArrayRef) TISGetInputSourceProperty(source, kTISPropertyInputSourceLanguages);
if (CFArrayGetCount(languages) > 0) {
CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(languages, 0);
- QString name = QCFString::toQString(langRef);
+ QString name = QString::fromCFString(langRef);
QLocale locale(name);
if (m_locale != locale) {
m_locale = locale;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 9b0b5959a4..32f6fe0af1 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -54,7 +54,7 @@
#include <QtCore/QScopedPointer>
#include <qpa/qplatformintegration.h>
-#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h>
QT_BEGIN_NAMESPACE
@@ -130,7 +130,9 @@ public:
#ifndef QT_NO_ACCESSIBILITY
QCocoaAccessibility *accessibility() const Q_DECL_OVERRIDE;
#endif
+#ifndef QT_NO_CLIPBOARD
QCocoaClipboard *clipboard() const Q_DECL_OVERRIDE;
+#endif
QCocoaDrag *drag() const Q_DECL_OVERRIDE;
QStringList themeNames() const Q_DECL_OVERRIDE;
@@ -169,7 +171,9 @@ private:
#endif
QScopedPointer<QPlatformTheme> mPlatformTheme;
QList<QCocoaScreen *> mScreens;
+#ifndef QT_NO_CLIPBOARD
QCocoaClipboard *mCocoaClipboard;
+#endif
QScopedPointer<QCocoaDrag> mCocoaDrag;
QScopedPointer<QCocoaNativeInterface> mNativeInterface;
QScopedPointer<QCocoaServices> mServices;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index e481cede17..92fffb4d15 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -58,6 +58,8 @@
#include <qpa/qplatforminputcontextfactory_p.h>
#include <QtCore/qcoreapplication.h>
+#include <QtGui/private/qcoregraphics_p.h>
+
#include <IOKit/graphics/IOGraphicsLib.h>
static void initResources()
@@ -199,8 +201,6 @@ QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
return window;
}
-extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev);
-
QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height) const
{
// TODO window should be handled
@@ -251,9 +251,8 @@ QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height
QPixmap pix(w, h);
pix.fill(Qt::transparent);
CGRect rect = CGRectMake(0, 0, w, h);
- CGContextRef ctx = qt_mac_cg_context(&pix);
+ QMacCGContext ctx(&pix);
qt_mac_drawCGImage(ctx, &rect, image);
- CGContextRelease(ctx);
QPainter painter(&windowPixmap);
painter.drawPixmap(0, 0, pix);
@@ -283,7 +282,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
#ifndef QT_NO_ACCESSIBILITY
, mAccessibility(new QCocoaAccessibility)
#endif
+#ifndef QT_NO_CLIPBOARD
, mCocoaClipboard(new QCocoaClipboard)
+#endif
, mCocoaDrag(new QCocoaDrag)
, mNativeInterface(new QCocoaNativeInterface)
, mServices(new QCocoaServices)
@@ -329,10 +330,8 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
[cocoaApplication setDelegate:newDelegate];
// Load the application menu. This menu contains Preferences, Hide, Quit.
- QCocoaMenuLoader *qtMenuLoader = [[QCocoaMenuLoader alloc] init];
- qt_mac_loadMenuNib(qtMenuLoader);
+ QCocoaMenuLoader *qtMenuLoader = [QCocoaMenuLoader sharedMenuLoader];
[cocoaApplication setMenu:[qtMenuLoader menu]];
- [newDelegate setMenuLoader:qtMenuLoader];
}
// The presentation options such as whether or not the dock and/or menu bar is
@@ -366,11 +365,13 @@ QCocoaIntegration::~QCocoaIntegration()
[[NSApplication sharedApplication] setDelegate: 0];
}
+#ifndef QT_NO_CLIPBOARD
// Delete the clipboard integration and destroy mime type converters.
// Deleting the clipboard integration flushes promised pastes using
// the mime converters - the ordering here is important.
delete mCocoaClipboard;
QMacInternalPasteboardMime::destroyMimeTypes();
+#endif
// Delete screens in reverse order to avoid crash in case of multiple screens
while (!mScreens.isEmpty()) {
@@ -531,10 +532,12 @@ QCocoaAccessibility *QCocoaIntegration::accessibility() const
}
#endif
+#ifndef QT_NO_CLIPBOARD
QCocoaClipboard *QCocoaIntegration::clipboard() const
{
return mCocoaClipboard;
}
+#endif
QCocoaDrag *QCocoaIntegration::drag() const
{
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h
index 93ebc5b9dc..4ba615efeb 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.h
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h
@@ -40,7 +40,7 @@
#ifndef QCOCOAKEYMAPPER_H
#define QCOCOAKEYMAPPER_H
-#include <qcocoahelpers.h>
+#include "qcocoahelpers.h"
#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
index 250f3f3bf7..e7952ae1f6 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
@@ -251,16 +251,20 @@ static qt_mac_enum_mapper qt_mac_private_unicode[] = {
{ 0xF72B, QT_MAC_MAP_ENUM(Qt::Key_End) }, //NSEndFunctionKey
{ 0xF72C, QT_MAC_MAP_ENUM(Qt::Key_PageUp) }, //NSPageUpFunctionKey
{ 0xF72D, QT_MAC_MAP_ENUM(Qt::Key_PageDown) }, //NSPageDownFunctionKey
+ { 0xF72E, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintScreenFunctionKey
{ 0xF72F, QT_MAC_MAP_ENUM(Qt::Key_ScrollLock) }, //NSScrollLockFunctionKey
{ 0xF730, QT_MAC_MAP_ENUM(Qt::Key_Pause) }, //NSPauseFunctionKey
{ 0xF731, QT_MAC_MAP_ENUM(Qt::Key_SysReq) }, //NSSysReqFunctionKey
{ 0xF735, QT_MAC_MAP_ENUM(Qt::Key_Menu) }, //NSMenuFunctionKey
- { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintFunctionKey
+ { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Printer) }, //NSPrintFunctionKey
{ 0xF73A, QT_MAC_MAP_ENUM(Qt::Key_Clear) }, //NSClearDisplayFunctionKey
{ 0xF73D, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertCharFunctionKey
{ 0xF73E, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteCharFunctionKey
{ 0xF741, QT_MAC_MAP_ENUM(Qt::Key_Select) }, //NSSelectFunctionKey
{ 0xF742, QT_MAC_MAP_ENUM(Qt::Key_Execute) }, //NSExecuteFunctionKey
+ { 0xF743, QT_MAC_MAP_ENUM(Qt::Key_Undo) }, //NSUndoFunctionKey
+ { 0xF744, QT_MAC_MAP_ENUM(Qt::Key_Redo) }, //NSRedoFunctionKey
+ { 0xF745, QT_MAC_MAP_ENUM(Qt::Key_Find) }, //NSFindFunctionKey
{ 0xF746, QT_MAC_MAP_ENUM(Qt::Key_Help) }, //NSHelpFunctionKey
{ 0xF747, QT_MAC_MAP_ENUM(Qt::Key_Mode_switch) }, //NSModeSwitchFunctionKey
{ 0, QT_MAC_MAP_ENUM(0) }
@@ -384,7 +388,7 @@ bool QCocoaKeyMapper::updateKeyboard()
iso639Code = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, 0)); // Actually a RFC3066bis, but it's close enough
if (iso639Code) {
- keyboardInputLocale = QLocale(QCFString::toQString(iso639Code));
+ keyboardInputLocale = QLocale(QString::fromCFString(iso639Code));
keyboardInputDirection = keyboardInputLocale.textDirection();
} else {
keyboardInputLocale = QLocale::c();
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 40d593cf0f..566363e01f 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -74,11 +74,6 @@ NSString *qt_mac_removePrivateUnicode(NSString* string)
return string;
}
-static inline QCocoaMenuLoader *getMenuLoader()
-{
- return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
-}
-
QT_END_NAMESPACE
@interface QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) : NSObject <NSMenuDelegate> {
@@ -290,7 +285,7 @@ void QCocoaMenu::setText(const QString &text)
{
QMacAutoReleasePool pool;
QString stripped = qt_mac_removeAmpersandEscapes(text);
- [m_nativeMenu setTitle:QCFString::toNSString(stripped)];
+ [m_nativeMenu setTitle:stripped.toNSString()];
}
void QCocoaMenu::setMinimumWidth(int width)
@@ -301,7 +296,7 @@ void QCocoaMenu::setMinimumWidth(int width)
void QCocoaMenu::setFont(const QFont &font)
{
if (font.resolve()) {
- NSFont *customMenuFont = [NSFont fontWithName:QCFString::toNSString(font.family())
+ NSFont *customMenuFont = [NSFont fontWithName:font.family().toNSString()
size:font.pointSize()];
m_nativeMenu.font = customMenuFont;
}
@@ -414,7 +409,7 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
}
bool wasMerged = cocoaItem->isMerged();
- NSMenu *oldMenu = wasMerged ? [getMenuLoader() applicationMenu] : m_nativeMenu;
+ NSMenu *oldMenu = wasMerged ? [[QCocoaMenuLoader sharedMenuLoader] applicationMenu] : m_nativeMenu;
NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem];
if (cocoaItem->sync() != oldItem) {
@@ -500,7 +495,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect,
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
- NSView *view = cocoaWindow ? cocoaWindow->contentView() : nil;
+ NSView *view = cocoaWindow ? cocoaWindow->view() : nil;
NSMenuItem *nsItem = item ? ((QCocoaMenuItem *)item)->nsItem() : nil;
QScreen *screen = 0;
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index c6e9bd6373..a95ffc2f9f 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -52,11 +52,6 @@ QT_BEGIN_NAMESPACE
static QList<QCocoaMenuBar*> static_menubars;
-static inline QCocoaMenuLoader *getMenuLoader()
-{
- return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
-}
-
QCocoaMenuBar::QCocoaMenuBar() :
m_window(0)
{
@@ -356,7 +351,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
menu->propagateEnabledState(!disableForModal);
}
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
[loader ensureAppMenuInMenu:mb->nsMenu()];
NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain];
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h
index d63f21f598..23f788687c 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h
@@ -90,7 +90,9 @@ public:
void setIsSeparator(bool isSeparator) Q_DECL_OVERRIDE;
void setFont(const QFont &font) Q_DECL_OVERRIDE;
void setRole(MenuRole role) Q_DECL_OVERRIDE;
+#ifndef QT_NO_SHORTCUT
void setShortcut(const QKeySequence& shortcut) Q_DECL_OVERRIDE;
+#endif
void setCheckable(bool checkable) Q_DECL_OVERRIDE { Q_UNUSED(checkable) }
void setChecked(bool isChecked) Q_DECL_OVERRIDE;
void setEnabled(bool isEnabled) Q_DECL_OVERRIDE;
@@ -124,7 +126,9 @@ private:
QFont m_font;
MenuRole m_role;
MenuRole m_detectedRole;
+#ifndef QT_NO_SHORTCUT
QKeySequence m_shortcut;
+#endif
quintptr m_tag;
int m_iconSize;
bool m_textSynced:1;
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index 3979d7169a..b8a64641a8 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -48,17 +48,12 @@
#include "qt_mac_p.h"
#include "qcocoaapplication.h" // for custom application category
#include "qcocoamenuloader.h"
+#include <QtGui/private/qcoregraphics_p.h>
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
-static inline QCocoaMenuLoader *getMenuLoader()
-{
- return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
-}
-
-
static quint32 constructModifierMask(quint32 accel_key)
{
quint32 ret = 0;
@@ -74,6 +69,7 @@ static quint32 constructModifierMask(quint32 accel_key)
return ret;
}
+#ifndef QT_NO_SHORTCUT
// return an autoreleased string given a QKeySequence (currently only looks at the first one).
NSString *keySequenceToKeyEqivalent(const QKeySequence &accel)
{
@@ -92,6 +88,7 @@ NSUInteger keySequenceModifierMask(const QKeySequence &accel)
{
return constructModifierMask(accel[0]);
}
+#endif
QCocoaMenuItem::QCocoaMenuItem() :
m_native(NULL),
@@ -189,10 +186,12 @@ void QCocoaMenuItem::setRole(MenuRole role)
m_role = role;
}
+#ifndef QT_NO_SHORTCUT
void QCocoaMenuItem::setShortcut(const QKeySequence& shortcut)
{
m_shortcut = shortcut;
}
+#endif
void QCocoaMenuItem::setChecked(bool isChecked)
{
@@ -234,7 +233,7 @@ NSMenuItem *QCocoaMenuItem::sync()
if ((m_role != NoRole && !m_textSynced) || m_merged) {
NSMenuItem *mergeItem = nil;
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
switch (m_role) {
case ApplicationSpecificRole:
mergeItem = [loader appSpecificMenuItem:reinterpret_cast<NSInteger>(this)];
@@ -310,7 +309,7 @@ NSMenuItem *QCocoaMenuItem::sync()
}
if (!m_native) {
- m_native = [[NSMenuItem alloc] initWithTitle:QCFString::toNSString(m_text)
+ m_native = [[NSMenuItem alloc] initWithTitle:m_text.toNSString()
action:nil
keyEquivalent:@""];
[m_native setTag:reinterpret_cast<NSInteger>(this)];
@@ -320,36 +319,41 @@ NSMenuItem *QCocoaMenuItem::sync()
[m_native setView:m_itemView];
QString text = mergeText();
+#ifndef QT_NO_SHORTCUT
QKeySequence accel = mergeAccel();
// Show multiple key sequences as part of the menu text.
if (accel.count() > 1)
text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")");
+#endif
QString finalString = QPlatformTheme::removeMnemonics(text);
bool useAttributedTitle = false;
// Cocoa Font and title
if (m_font.resolve()) {
- NSFont *customMenuFont = [NSFont fontWithName:QCFString::toNSString(m_font.family())
+ NSFont *customMenuFont = [NSFont fontWithName:m_font.family().toNSString()
size:m_font.pointSize()];
if (customMenuFont) {
NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil];
NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil];
NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
- NSAttributedString *str = [[[NSAttributedString alloc] initWithString:QCFString::toNSString(finalString)
+ NSAttributedString *str = [[[NSAttributedString alloc] initWithString:finalString.toNSString()
attributes:attributes] autorelease];
[m_native setAttributedTitle: str];
useAttributedTitle = true;
}
}
if (!useAttributedTitle) {
- [m_native setTitle: QCFString::toNSString(finalString)];
+ [m_native setTitle:finalString.toNSString()];
}
+#ifndef QT_NO_SHORTCUT
if (accel.count() == 1) {
[m_native setKeyEquivalent:keySequenceToKeyEqivalent(accel)];
[m_native setKeyEquivalentModifierMask:keySequenceModifierMask(accel)];
- } else {
+ } else
+#endif
+ {
[m_native setKeyEquivalent:@""];
[m_native setKeyEquivalentModifierMask:NSCommandKeyMask];
}
@@ -372,7 +376,7 @@ QT_END_NAMESPACE
QString QCocoaMenuItem::mergeText()
{
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader aboutMenuItem]) {
return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName());
} else if (m_native== [loader aboutQtMenuItem]) {
@@ -390,9 +394,10 @@ QString QCocoaMenuItem::mergeText()
return m_text;
}
+#ifndef QT_NO_SHORTCUT
QKeySequence QCocoaMenuItem::mergeAccel()
{
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader preferencesMenuItem])
return QKeySequence(QKeySequence::Preferences);
else if (m_native == [loader quitMenuItem])
@@ -402,6 +407,7 @@ QKeySequence QCocoaMenuItem::mergeAccel()
return m_shortcut;
}
+#endif
void QCocoaMenuItem::syncMerged()
{
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h
index 6f58b2f24c..95f347646c 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h
@@ -68,6 +68,8 @@
NSMenuItem *hideAllOthersItem;
NSMenuItem *showAllItem;
}
++ (instancetype)sharedMenuLoader;
+- (instancetype)init;
- (void)ensureAppMenuInMenu:(NSMenu *)menu;
- (void)removeActionsFromAppMenu;
- (NSMenu *)applicationMenu;
@@ -92,10 +94,4 @@
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuLoader);
-QT_BEGIN_NAMESPACE
-
-void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader);
-
-QT_END_NAMESPACE
-
#endif // QCOCOAMENULOADER_P_H
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
index e440a9080c..01a3c04afb 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
@@ -55,86 +55,127 @@
QT_FORWARD_DECLARE_CLASS(QCFString)
QT_FORWARD_DECLARE_CLASS(QString)
+@implementation QCocoaMenuLoader
-QT_BEGIN_NAMESPACE
-
-/*
- Loads and instantiates the main app menu from the menu nib file(s).
-
- The main app menu contains the Quit, Hide About, Preferences entries, and
- The reason for having the nib file is that those can not be created
- programmatically. To ease deployment the nib files are stored in Qt resources
- and written to QDir::temp() before loading. (Earlier Qt versions used
- to require having the nib file in the Qt GUI framework.)
-*/
-void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader)
++ (instancetype)sharedMenuLoader
{
- // Create qt_menu.nib dir in temp.
- QDir temp = QDir::temp();
- temp.mkdir("qt_menu.nib");
- QString nibDir = temp.canonicalPath() + QLatin1String("/") + QLatin1String("qt_menu.nib/");
- if (!QDir(nibDir).exists()) {
- qWarning("qt_mac_loadMenuNib: could not create nib directory in temp");
- return;
- }
-
- // Copy nib files from resources to temp.
- QDir nibResource(":/qt-project.org/mac/qt_menu.nib/");
- if (!nibResource.exists()) {
- qWarning("qt_mac_loadMenuNib: could not load nib from resources");
- return;
- }
- foreach (const QFileInfo &file, nibResource.entryInfoList()) {
- QFileInfo destinationFile(nibDir + QLatin1String("/") + file.fileName());
- if (destinationFile.exists() && destinationFile.size() != file.size())
- QFile::remove(destinationFile.absoluteFilePath());
+ static QCocoaMenuLoader *shared = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ shared = [[self alloc] init];
+ });
+ return shared;
+}
- QFile::copy(file.absoluteFilePath(), destinationFile.absoluteFilePath());
+- (instancetype)init
+{
+ if ((self = [super init])) {
+ NSString *appName = qt_mac_applicationName().toNSString();
+
+ // Menubar as menu. Title as set in the NIB file
+ theMenu = [[NSMenu alloc] initWithTitle:@"Main Menu"];
+
+ // Application menu. Since 10.6, the first menu
+ // is always identified as the application menu.
+ NSMenuItem *appItem = [[[NSMenuItem alloc] init] autorelease];
+ appItem.title = appName;
+ [theMenu addItem:appItem];
+ appMenu = [[NSMenu alloc] initWithTitle:appName];
+ appItem.submenu = appMenu;
+
+ // About Application
+ aboutItem = [[NSMenuItem alloc] initWithTitle:[@"About " stringByAppendingString:appName]
+ action:@selector(orderFrontStandardAboutPanel:)
+ keyEquivalent:@""];
+ aboutItem.target = self;
+ // Disable until a QAction is associated
+ aboutItem.enabled = NO;
+ aboutItem.hidden = YES;
+ [appMenu addItem:aboutItem];
+
+ // About Qt (shameless self-promotion)
+ aboutQtItem = [[NSMenuItem alloc] init];
+ aboutQtItem.title = @"About Qt";
+ // Disable until a QAction is associated
+ aboutQtItem.enabled = NO;
+ aboutQtItem.hidden = YES;
+ [appMenu addItem:aboutQtItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Preferences
+ preferencesItem = [[NSMenuItem alloc] initWithTitle:@"Preferences…"
+ action:@selector(qtDispatcherToQPAMenuItem:)
+ keyEquivalent:@","];
+ preferencesItem.target = self;
+ // Disable until a QAction is associated
+ preferencesItem.enabled = NO;
+ preferencesItem.hidden = YES;
+ [appMenu addItem:preferencesItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Services item and menu
+ servicesItem = [[NSMenuItem alloc] init];
+ servicesItem.title = @"Services";
+ NSMenu *servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
+ servicesItem.submenu = servicesMenu;
+ [NSApplication sharedApplication].servicesMenu = servicesMenu;
+ [appMenu addItem:servicesItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Hide Application
+ hideItem = [[NSMenuItem alloc] initWithTitle:[@"Hide " stringByAppendingString:appName]
+ action:@selector(hide:)
+ keyEquivalent:@"h"];
+ hideItem.target = self;
+ [appMenu addItem:hideItem];
+
+ // Hide Others
+ hideAllOthersItem = [[NSMenuItem alloc] initWithTitle:@"Hide Others"
+ action:@selector(hideOtherApplications:)
+ keyEquivalent:@"h"];
+ hideAllOthersItem.target = self;
+ hideAllOthersItem.keyEquivalentModifierMask = NSCommandKeyMask | NSAlternateKeyMask;
+ [appMenu addItem:hideAllOthersItem];
+
+ // Show All
+ showAllItem = [[NSMenuItem alloc] initWithTitle:@"Show All"
+ action:@selector(unhideAllApplications:)
+ keyEquivalent:@""];
+ showAllItem.target = self;
+ [appMenu addItem:showAllItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Quit Application
+ quitItem = [[NSMenuItem alloc] initWithTitle:[@"Quit " stringByAppendingString:appName]
+ action:@selector(terminate:)
+ keyEquivalent:@"q"];
+ quitItem.target = self;
+ [appMenu addItem:quitItem];
}
- // Load and instantiate nib file from temp
- NSURL *nibUrl = [NSURL fileURLWithPath : QCFString::toNSString(nibDir)];
- NSNib *nib = [[NSNib alloc] initWithContentsOfURL : nibUrl];
- [nib autorelease];
- if(!nib) {
- qWarning("qt_mac_loadMenuNib: could not load nib from temp");
- return;
- }
- bool ok = [nib instantiateNibWithOwner : qtMenuLoader topLevelObjects : nil];
- if (!ok) {
- qWarning("qt_mac_loadMenuNib: could not instantiate nib");
- }
+ return self;
}
-QT_END_NAMESPACE
+- (void)dealloc
+{
+ [theMenu release];
+ [appMenu release];
+ [aboutItem release];
+ [aboutQtItem release];
+ [preferencesItem release];
+ [servicesItem release];
+ [hideItem release];
+ [hideAllOthersItem release];
+ [showAllItem release];
+ [quitItem release];
-@implementation QCocoaMenuLoader
+ [lastAppSpecificItem release];
-- (void)awakeFromNib
-{
- servicesItem = [[appMenu itemWithTitle:@"Services"] retain];
- hideAllOthersItem = [[appMenu itemWithTitle:@"Hide Others"] retain];
- showAllItem = [[appMenu itemWithTitle:@"Show All"] retain];
-
- // Get the names in the nib to match the app name set by Qt.
- const NSString *appName = qt_mac_applicationName().toNSString();
- [quitItem setTitle:[[quitItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:const_cast<NSString *>(appName)]];
- [hideItem setTitle:[[hideItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:const_cast<NSString *>(appName)]];
- [aboutItem setTitle:[[aboutItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:const_cast<NSString *>(appName)]];
- // Disable the items that don't do anything. If someone associates a QAction with them
- // They should get synced back in.
- [preferencesItem setEnabled:NO];
- [preferencesItem setHidden:YES];
-
- // should set this in the NIB
- [preferencesItem setTarget: self];
- [preferencesItem setAction: @selector(qtDispatcherToQPAMenuItem:)];
-
- [aboutItem setEnabled:NO];
- [aboutItem setHidden:YES];
+ [super dealloc];
}
- (void)ensureAppMenuInMenu:(NSMenu *)menu
@@ -179,18 +220,6 @@ QT_END_NAMESPACE
[item setTag:0];
}
-- (void)dealloc
-{
- [servicesItem release];
- [hideAllOthersItem release];
- [showAllItem release];
-
- [lastAppSpecificItem release];
- [theMenu release];
- [appMenu release];
- [super dealloc];
-}
-
- (NSMenu *)menu
{
return [[theMenu retain] autorelease];
@@ -285,13 +314,13 @@ QT_END_NAMESPACE
{
#ifndef QT_NO_TRANSLATION
- [servicesItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(0))];
- [hideItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()))];
- [hideAllOthersItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(2))];
- [showAllItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(3))];
- [preferencesItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(4))];
- [quitItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()))];
- [aboutItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()))];
+ [servicesItem setTitle:qt_mac_applicationmenu_string(0).toNSString()];
+ [hideItem setTitle:qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()).toNSString()];
+ [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(2).toNSString()];
+ [showAllItem setTitle:qt_mac_applicationmenu_string(3).toNSString()];
+ [preferencesItem setTitle:qt_mac_applicationmenu_string(4).toNSString()];
+ [quitItem setTitle:qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()).toNSString()];
+ [aboutItem setTitle:qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()).toNSString()];
#endif
}
diff --git a/src/plugins/platforms/cocoa/qcocoamimetypes.mm b/src/plugins/platforms/cocoa/qcocoamimetypes.mm
index e7a3aab845..093f86da6e 100644
--- a/src/plugins/platforms/cocoa/qcocoamimetypes.mm
+++ b/src/plugins/platforms/cocoa/qcocoamimetypes.mm
@@ -38,8 +38,9 @@
****************************************************************************/
#include "qcocoamimetypes.h"
-#include <QtPlatformSupport/private/qmacmime_p.h>
+#include <QtClipboardSupport/private/qmacmime_p.h>
#include "qcocoahelpers.h"
+#include <QtGui/private/qcoregraphics_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index b06fff1375..26fbe3e4bc 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -122,9 +122,6 @@ private:
static CGImageRef qImageToCGImage(const QImage &image);
static QImage cgImageToQImage(CGImageRef image);
- // Embedding NSViews as child QWindows
- static void setWindowContentView(QPlatformWindow *window, void *nsViewContentView);
-
// Set a QWindow as a "guest" (subwindow) of a non-QWindow
static void setEmbeddedInForeignView(QPlatformWindow *window, bool embedded);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index a327750ffd..972230349b 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -65,6 +65,8 @@
#include <qpa/qplatformprintersupport.h>
#endif
+#include <QtGui/private/qcoregraphics_p.h>
+
#include <QtPlatformHeaders/qcocoawindowfunctions.h>
#include <AppKit/AppKit.h>
@@ -95,7 +97,7 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
return 0;
if (resourceString == "nsview") {
- return static_cast<QCocoaWindow *>(window->handle())->m_contentView;
+ return static_cast<QCocoaWindow *>(window->handle())->m_view;
#ifndef QT_NO_OPENGL
} else if (resourceString == "nsopenglcontext") {
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
@@ -124,8 +126,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::qImageToCGImage);
if (resource.toLower() == "cgimagetoqimage")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::cgImageToQImage);
- if (resource.toLower() == "setwindowcontentview")
- return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setWindowContentView);
if (resource.toLower() == "registertouchwindow")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow);
if (resource.toLower() == "setembeddedinforeignview")
@@ -282,12 +282,6 @@ QImage QCocoaNativeInterface::cgImageToQImage(CGImageRef image)
return qt_mac_toQImage(image);
}
-void QCocoaNativeInterface::setWindowContentView(QPlatformWindow *window, void *contentView)
-{
- QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
- cocoaPlatformWindow->setContentView(reinterpret_cast<NSView *>(contentView));
-}
-
void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded)
{
QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
index d5fd523a37..39fcf285ed 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
@@ -71,13 +71,13 @@ QCocoaPrintDevice::QCocoaPrintDevice(const QString &id)
m_ppd(0)
{
if (!id.isEmpty()) {
- m_printer = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(id));
+ m_printer = PMPrinterCreateFromPrinterID(id.toCFString());
if (m_printer) {
- m_name = QCFString::toQString(PMPrinterGetName(m_printer));
- m_location = QCFString::toQString(PMPrinterGetLocation(m_printer));
+ m_name = QString::fromCFString(PMPrinterGetName(m_printer));
+ m_location = QString::fromCFString(PMPrinterGetLocation(m_printer));
CFStringRef cfMakeAndModel;
if (PMPrinterGetMakeAndModelName(m_printer, &cfMakeAndModel) == noErr)
- m_makeAndModel = QCFString::toQString(cfMakeAndModel);
+ m_makeAndModel = QString::fromCFString(cfMakeAndModel);
Boolean isRemote;
if (PMPrinterIsRemote(m_printer, &isRemote) == noErr)
m_isRemote = isRemote;
@@ -420,7 +420,7 @@ void QCocoaPrintDevice::loadMimeTypes() const
int count = CFArrayGetCount(mimeTypes);
for (int i = 0; i < count; ++i) {
CFStringRef mimeName = static_cast<CFStringRef>(const_cast<void *>(CFArrayGetValueAtIndex(mimeTypes, i)));
- QMimeType mimeType = db.mimeTypeForName(QCFString::toQString(mimeName));
+ QMimeType mimeType = db.mimeTypeForName(QString::fromCFString(mimeName));
if (mimeType.isValid())
m_mimeTypes.append(mimeType);
}
diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm
index f8fc23f681..c2f7d5b022 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm
@@ -82,7 +82,7 @@ QStringList QCocoaPrinterSupport::availablePrintDeviceIds() const
CFIndex count = CFArrayGetCount(printerList);
for (CFIndex i = 0; i < count; ++i) {
PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
- list.append(QCFString::toQString(PMPrinterGetID(printer)));
+ list.append(QString::fromCFString(PMPrinterGetID(printer)));
}
}
return list;
@@ -96,7 +96,7 @@ QString QCocoaPrinterSupport::defaultPrintDeviceId() const
for (CFIndex i = 0; i < count; ++i) {
PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
if (PMPrinterIsDefault(printer))
- return QCFString::toQString(PMPrinterGetID(printer));
+ return QString::fromCFString(PMPrinterGetID(printer));
}
}
return QString();
diff --git a/src/plugins/platforms/cocoa/qcocoaresources.qrc b/src/plugins/platforms/cocoa/qcocoaresources.qrc
index 9e0640db7d..4255bfba9d 100644
--- a/src/plugins/platforms/cocoa/qcocoaresources.qrc
+++ b/src/plugins/platforms/cocoa/qcocoaresources.qrc
@@ -9,9 +9,4 @@
<qresource prefix="/qt-project.org/mac/style">
<file>images/leopard-unified-toolbar-on.png</file>
</qresource>
-<qresource prefix="/qt-project.org/mac/">
-<file>qt_menu.nib/classes.nib</file>
-<file>qt_menu.nib/info.nib</file>
-<file>qt_menu.nib/keyedobjects.nib</file>
-</qresource>
</RCC>
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index be5fa61b8b..9ddad7fc7a 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -43,6 +43,7 @@
#include <QtCore/private/qcore_mac_p.h>
#include <QtGui/qfont.h>
+#include <QtGui/private/qcoregraphics_p.h>
#include <Carbon/Carbon.h>
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 0cbdc5d9c8..6af22facf9 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -75,6 +75,9 @@
#define QT_MAC_SYSTEMTRAY_USE_GROWL
#include "qcocoasystemtrayicon.h"
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
#include <qtemporaryfile.h>
#include <qimagewriter.h>
#include <qdebug.h>
@@ -83,6 +86,7 @@
#include "qt_mac_p.h"
#include "qcocoahelpers.h"
+#include <QtGui/private/qcoregraphics_p.h>
#import <AppKit/AppKit.h>
@@ -91,11 +95,8 @@ QT_USE_NAMESPACE
@class QT_MANGLE_NAMESPACE(QNSMenu);
@class QT_MANGLE_NAMESPACE(QNSImageView);
-@interface QT_MANGLE_NAMESPACE(QNSStatusItem) : NSObject
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- <NSUserNotificationCenterDelegate>
-#endif
- {
+@interface QT_MANGLE_NAMESPACE(QNSStatusItem) : NSObject <NSUserNotificationCenterDelegate>
+{
@public
QCocoaSystemTrayIcon *systray;
NSStatusItem *item;
@@ -109,11 +110,8 @@ QT_USE_NAMESPACE
-(QRectF)geometry;
- (void)triggerSelector:(id)sender button:(Qt::MouseButton)mouseButton;
- (void)doubleClickSelector:(id)sender;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification;
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification;
-#endif
@end
@interface QT_MANGLE_NAMESPACE(QNSImageView) : NSImageView {
@@ -142,19 +140,11 @@ class QSystemTrayIconSys
public:
QSystemTrayIconSys(QCocoaSystemTrayIcon *sys) {
item = [[QNSStatusItem alloc] initWithSysTray:sys];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item];
- }
-#endif
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item];
}
~QSystemTrayIconSys() {
[[[item item] view] setHidden: YES];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
- }
-#endif
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
[item release];
}
QNSStatusItem *item;
@@ -280,7 +270,7 @@ void QCocoaSystemTrayIcon::updateToolTip(const QString &toolTip)
{
if (!m_sys)
return;
- [[[m_sys->item item] view] setToolTip:QCFString::toNSString(toolTip)];
+ [[[m_sys->item item] view] setToolTip:toolTip.toNSString()];
}
bool QCocoaSystemTrayIcon::isSystemTrayAvailable() const
@@ -296,71 +286,15 @@ bool QCocoaSystemTrayIcon::supportsMessages() const
void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &message,
const QIcon& icon, MessageIcon, int)
{
+ Q_UNUSED(icon);
if (!m_sys)
return;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- NSUserNotification *notification = [[NSUserNotification alloc] init];
- notification.title = [NSString stringWithUTF8String:title.toUtf8().data()];
- notification.informativeText = [NSString stringWithUTF8String:message.toUtf8().data()];
-
- [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = [NSString stringWithUTF8String:title.toUtf8().data()];
+ notification.informativeText = [NSString stringWithUTF8String:message.toUtf8().data()];
- return;
- }
-#endif
-
-#ifdef QT_MAC_SYSTEMTRAY_USE_GROWL
- // Make sure that we have Growl installed on the machine we are running on.
- QCFType<CFURLRef> cfurl;
- OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator,
- CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
- if (status == kLSApplicationNotFoundErr)
- return;
- QCFType<CFBundleRef> bundle = CFBundleCreate(0, cfurl);
-
- if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"),
- kCFCompareCaseInsensitive | kCFCompareBackwards) != kCFCompareEqualTo)
- return;
- QPixmap notificationIconPixmap = icon.pixmap(32, 32);
- QTemporaryFile notificationIconFile;
- QString notificationType(QLatin1String("Notification")), notificationIcon, notificationApp(qt_mac_applicationName());
- if (notificationApp.isEmpty())
- notificationApp = QLatin1String("Application");
- if (!notificationIconPixmap.isNull() && notificationIconFile.open()) {
- QImageWriter writer(&notificationIconFile, "PNG");
- if (writer.write(notificationIconPixmap.toImage()))
- notificationIcon = QLatin1String("image from location \"file://") + notificationIconFile.fileName() + QLatin1String("\"");
- }
- const QString script(QLatin1String(
- "tell application \"System Events\"\n"
- "set isRunning to (count of (every process whose bundle identifier is \"com.Growl.GrowlHelperApp\")) > 0\n"
- "end tell\n"
- "if isRunning\n"
- "tell application id \"com.Growl.GrowlHelperApp\"\n"
- "-- Make a list of all the notification types (all)\n"
- "set the allNotificationsList to {\"") + notificationType + QLatin1String("\"}\n"
-
- "-- Make a list of the notifications (enabled)\n"
- "set the enabledNotificationsList to {\"") + notificationType + QLatin1String("\"}\n"
-
- "-- Register our script with growl.\n"
- "register as application \"") + notificationApp + QLatin1String("\" all notifications allNotificationsList default notifications enabledNotificationsList\n"
-
- "-- Send a Notification...\n") +
- QLatin1String("notify with name \"") + notificationType +
- QLatin1String("\" title \"") + title +
- QLatin1String("\" description \"") + message +
- QLatin1String("\" application name \"") + notificationApp +
- QLatin1String("\" ") + notificationIcon +
- QLatin1String("\nend tell\nend if"));
- qt_mac_execute_apple_script(script, 0);
-#else
- Q_UNUSED(icon);
- Q_UNUSED(title);
- Q_UNUSED(message);
-#endif
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
QT_END_NAMESPACE
@@ -499,7 +433,6 @@ QT_END_NAMESPACE
emit systray->activated(QPlatformSystemTrayIcon::DoubleClick);
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
Q_UNUSED(center);
Q_UNUSED(notification);
@@ -511,7 +444,6 @@ QT_END_NAMESPACE
Q_UNUSED(notification);
emit systray->messageClicked();
}
-#endif
@end
@@ -536,3 +468,5 @@ private:
return qmenu;
}
@end
+
+#endif // QT_NO_SYSTEMTRAYICON
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
index 282e527b0b..d47e620fbb 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
@@ -70,9 +70,7 @@ public:
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const Q_DECL_OVERRIDE;
- QPixmap fileIconPixmap(const QFileInfo &fileInfo,
- const QSizeF &size,
- QPlatformTheme::IconOptions options = 0) const Q_DECL_OVERRIDE;
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = 0) const override;
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 831f1cfcf4..4d74c11581 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -56,8 +56,10 @@
#include <QtCore/qfileinfo.h>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qcoregraphics_p.h>
#include <QtGui/qpainter.h>
-#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h>
+#include <QtThemeSupport/private/qabstractfileiconengine_p.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
@@ -136,8 +138,10 @@ bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const
QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const
{
switch (dialogType) {
+#ifndef QT_NO_FILEDIALOG
case QPlatformTheme::FileDialog:
return new QCocoaFileDialogHelper();
+#endif
#ifndef QT_NO_COLORDIALOG
case QPlatformTheme::ColorDialog:
return new QCocoaColorDialogHelper();
@@ -194,7 +198,7 @@ QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height)
CGRect rect = CGRectMake(0, 0, width, height);
- CGContextRef ctx = qt_mac_cg_context(&ret);
+ QMacCGContext ctx(&ret);
CGAffineTransform old_xform = CGContextGetCTM(ctx);
CGContextConcatCTM(ctx, CGAffineTransformInvert(old_xform));
CGContextConcatCTM(ctx, CGAffineTransformIdentity);
@@ -202,7 +206,6 @@ QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height)
::RGBColor b;
b.blue = b.green = b.red = 255*255;
PlotIconRefInContext(ctx, &rect, kAlignNone, kTransformNone, &b, kPlotIconRefNormalFlags, icon);
- CGContextRelease(ctx);
return ret;
}
@@ -274,16 +277,42 @@ QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
return QPlatformTheme::standardPixmap(sp, size);
}
-QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions) const
+class QCocoaFileIconEngine : public QAbstractFileIconEngine
{
- Q_UNUSED(iconOptions);
- QMacAutoReleasePool pool;
+public:
+ explicit QCocoaFileIconEngine(const QFileInfo &info,
+ QPlatformTheme::IconOptions opts) :
+ QAbstractFileIconEngine(info, opts) {}
+
+ static QList<QSize> availableIconSizes()
+ {
+ const qreal devicePixelRatio = qGuiApp->devicePixelRatio();
+ const int sizes[] = {
+ qRound(16 * devicePixelRatio), qRound(32 * devicePixelRatio),
+ qRound(64 * devicePixelRatio), qRound(128 * devicePixelRatio),
+ qRound(256 * devicePixelRatio)
+ };
+ return QAbstractFileIconEngine::toSizeList(sizes, sizes + sizeof(sizes) / sizeof(sizes[0]));
+ }
+
+ QList<QSize> availableSizes(QIcon::Mode = QIcon::Normal, QIcon::State = QIcon::Off) const override
+ { return QCocoaFileIconEngine::availableIconSizes(); }
+
+protected:
+ QPixmap filePixmap(const QSize &size, QIcon::Mode, QIcon::State) override
+ {
+ QMacAutoReleasePool pool;
- NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())];
- if (!iconImage)
- return QPixmap();
- return qt_mac_toQPixmap(iconImage, size);
+ NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:fileInfo().canonicalFilePath().toNSString()];
+ if (!iconImage)
+ return QPixmap();
+ return qt_mac_toQPixmap(iconImage, size);
+ }
+};
+
+QIcon QCocoaTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
+{
+ return QIcon(new QCocoaFileIconEngine(fileInfo, iconOptions));
}
QVariant QCocoaTheme::themeHint(ThemeHint hint) const
@@ -298,17 +327,12 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
case TabFocusBehavior:
return QVariant([[NSApplication sharedApplication] isFullKeyboardAccessEnabled] ?
int(Qt::TabFocusAllControls) : int(Qt::TabFocusTextControls | Qt::TabFocusListControls));
- case IconPixmapSizes: {
- qreal devicePixelRatio = qGuiApp->devicePixelRatio();
- QList<int> sizes;
- sizes << 16 * devicePixelRatio
- << 32 * devicePixelRatio
- << 64 * devicePixelRatio
- << 128 * devicePixelRatio;
- return QVariant::fromValue(sizes);
- }
+ case IconPixmapSizes:
+ return QVariant::fromValue(QCocoaFileIconEngine::availableIconSizes());
case QPlatformTheme::PasswordMaskCharacter:
return QVariant(QChar(kBulletUnicode));
+ case QPlatformTheme::UiEffects:
+ return QVariant(int(HoverEffect));
default:
break;
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 849ed858d1..16639fd8b1 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -54,32 +54,6 @@
QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
-QT_BEGIN_NAMESPACE
-
-class QCocoaWindowPointer
-{
-public:
- void assign(QCocoaWindow *w);
- void clear();
-
- QCocoaWindow *data() const
- { return watcher.isNull() ? Q_NULLPTR : window; }
- bool isNull() const
- { return watcher.isNull(); }
- operator QCocoaWindow*() const
- { return data(); }
- QCocoaWindow *operator->() const
- { return data(); }
- QCocoaWindow &operator*() const
- { return *data(); }
-
-private:
- QPointer<QObject> watcher;
- QCocoaWindow *window;
-};
-
-QT_END_NAMESPACE
-
@class QT_MANGLE_NAMESPACE(QNSWindowHelper);
@protocol QNSWindowProtocol
@@ -96,13 +70,13 @@ typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
@interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject
{
QCocoaNSWindow *_window;
- QCocoaWindowPointer _platformWindow;
+ QPointer<QCocoaWindow> _platformWindow;
BOOL _grabbingMouse;
BOOL _releaseOnMouseUp;
}
@property (nonatomic, readonly) QCocoaNSWindow *window;
-@property (nonatomic, readonly) QCocoaWindowPointer platformWindow;
+@property (nonatomic, readonly) QCocoaWindow *platformWindow;
@property (nonatomic) BOOL grabbingMouse;
@property (nonatomic) BOOL releaseOnMouseUp;
@@ -169,8 +143,9 @@ QT_BEGIN_NAMESPACE
class QCocoaMenuBar;
-class QCocoaWindow : public QPlatformWindow
+class QCocoaWindow : public QObject, public QPlatformWindow
{
+ Q_OBJECT
public:
QCocoaWindow(QWindow *tlw);
~QCocoaWindow();
@@ -207,9 +182,7 @@ public:
WId winId() const Q_DECL_OVERRIDE;
void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
- NSView *contentView() const;
- void setContentView(NSView *contentView);
- QNSView *qtView() const;
+ NSView *view() const;
NSWindow *nativeWindow() const;
void setEmbeddedInForeignView(bool subwindow);
@@ -219,6 +192,7 @@ public:
void windowDidResize();
void windowDidEndLiveResize();
bool windowShouldClose();
+ void windowWillClose();
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
void setSynchedWindowStateFromWindow();
@@ -277,6 +251,7 @@ protected:
void syncWindowState(Qt::WindowState newState);
void reinsertChildWindow(QCocoaWindow *child);
void removeChildWindow(QCocoaWindow *child);
+ bool isNativeWindowTypeInconsistent();
// private:
public: // for QNSView
@@ -285,14 +260,13 @@ public: // for QNSView
void removeMonitor();
- NSView *m_contentView;
- QNSView *m_qtView;
+ NSView *m_view;
QCocoaNSWindow *m_nsWindow;
- QCocoaWindowPointer m_forwardWindow;
+ QPointer<QCocoaWindow> m_forwardWindow;
// TODO merge to one variable if possible
- bool m_contentViewIsEmbedded; // true if the m_contentView is actually embedded in a "foreign" NSView hiearchy
- bool m_contentViewIsToBeEmbedded; // true if the m_contentView is intended to be embedded in a "foreign" NSView hiearchy
+ bool m_viewIsEmbedded; // true if the m_view is actually embedded in a "foreign" NSView hiearchy
+ bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy
QCocoaWindow *m_parentCocoaWindow;
bool m_isNSWindowChild; // this window is a non-top level QWindow with a NSWindow.
@@ -351,9 +325,6 @@ public: // for QNSView
QHash<quintptr, BorderRange> m_contentBorderAreas; // identifer -> uppper/lower
QHash<quintptr, bool> m_enabledContentBorderAreas; // identifer -> enabled state (true/false)
- // This object is tracked by QCocoaWindowPointer,
- // preventing the use of dangling pointers.
- QObject sentinel;
bool m_hasWindowFilePath;
};
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index b3cbf9f599..602da0a175 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -52,6 +52,7 @@
#include <private/qwindow_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
+#include <QtGui/private/qcoregraphics_p.h>
#include <AppKit/AppKit.h>
@@ -78,19 +79,31 @@ static bool isMouseEvent(NSEvent *ev)
}
}
+static void qt_closePopups()
+{
+ while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
+ QWindowSystemInterface::handleCloseEvent(popup->window());
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
+}
+
@implementation QNSWindowHelper
@synthesize window = _window;
-@synthesize platformWindow = _platformWindow;
@synthesize grabbingMouse = _grabbingMouse;
@synthesize releaseOnMouseUp = _releaseOnMouseUp;
+- (QCocoaWindow *)platformWindow
+{
+ return _platformWindow.data();
+}
+
- (id)initWithNSWindow:(QCocoaNSWindow *)window platformWindow:(QCocoaWindow *)platformWindow
{
self = [super init];
if (self) {
_window = window;
- _platformWindow.assign(platformWindow);
+ _platformWindow = platformWindow;
_window.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:_platformWindow];
@@ -109,7 +122,7 @@ static bool isMouseEvent(NSEvent *ev)
QCocoaWindow *pw = self.platformWindow;
if (pw && pw->m_forwardWindow) {
if (theEvent.type == NSLeftMouseUp || theEvent.type == NSLeftMouseDragged) {
- QNSView *forwardView = pw->m_qtView;
+ QNSView *forwardView = qnsview_cast(pw->view());
if (theEvent.type == NSLeftMouseUp) {
[forwardView mouseUp:theEvent];
pw->m_forwardWindow.clear();
@@ -150,18 +163,14 @@ static bool isMouseEvent(NSEvent *ev)
NSPoint loc = [theEvent locationInWindow];
NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
NSRect contentFrame = [[self.window contentView] frame];
- if (NSMouseInRect(loc, windowFrame, NO) &&
- !NSMouseInRect(loc, contentFrame, NO))
- {
- QNSView *contentView = pw->m_qtView;
- [contentView handleFrameStrutMouseEvent: theEvent];
- }
+ if (NSMouseInRect(loc, windowFrame, NO) && !NSMouseInRect(loc, contentFrame, NO))
+ [qnsview_cast(pw->view()) handleFrameStrutMouseEvent:theEvent];
}
}
- (void)detachFromPlatformWindow
{
- self.platformWindow.clear();
+ _platformWindow.clear();
[self.window.delegate release];
self.window.delegate = nil;
}
@@ -182,7 +191,7 @@ static bool isMouseEvent(NSEvent *ev)
- (void)dealloc
{
_window = nil;
- self.platformWindow.clear();
+ _platformWindow.clear();
[super dealloc];
}
@@ -334,27 +343,14 @@ static bool isMouseEvent(NSEvent *ev)
@end
-void QCocoaWindowPointer::assign(QCocoaWindow *w)
-{
- window = w;
- watcher = &w->sentinel;
-}
-
-void QCocoaWindowPointer::clear()
-{
- window = Q_NULLPTR;
- watcher.clear();
-}
-
const int QCocoaWindow::NoAlertRequest = -1;
QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
- , m_contentView(nil)
- , m_qtView(nil)
+ , m_view(nil)
, m_nsWindow(0)
- , m_contentViewIsEmbedded(false)
- , m_contentViewIsToBeEmbedded(false)
+ , m_viewIsEmbedded(false)
+ , m_viewIsToBeEmbedded(false)
, m_parentCocoaWindow(0)
, m_isNSWindowChild(false)
, m_effectivelyMaximized(false)
@@ -391,11 +387,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
QMacAutoReleasePool pool;
if (tlw->type() == Qt::ForeignWindow) {
- NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
- setContentView(foreignView);
+ m_view = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
} else {
- m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
- m_contentView = m_qtView;
+ m_view = [[QNSView alloc] initWithCocoaWindow:this];
// Enable high-dpi OpenGL for retina displays. Enabling has the side
// effect that Cocoa will start calling glViewport(0, 0, width, height),
// overriding any glViewport calls in application code. This is usually not a
@@ -404,14 +398,14 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
if (tlw->supportsOpenGL()) {
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
- [m_contentView setWantsBestResolutionOpenGLSurface:enable];
+ [m_view setWantsBestResolutionOpenGLSurface:enable];
}
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
"QT_MAC_WANTS_LAYER");
- [m_contentView setWantsLayer:enable];
+ [m_view setWantsLayer:enable];
}
setGeometry(tlw->geometry());
- recreateWindow(parent());
+ recreateWindow(QPlatformWindow::parent());
tlw->setGeometry(geometry());
if (tlw->isTopLevel())
setWindowIcon(tlw->icon());
@@ -429,25 +423,16 @@ QCocoaWindow::~QCocoaWindow()
if (m_isNSWindowChild) {
if (m_parentCocoaWindow)
m_parentCocoaWindow->removeChildWindow(this);
- } else if ([m_contentView superview]) {
- [m_contentView removeFromSuperview];
+ } else if ([m_view superview]) {
+ [m_view removeFromSuperview];
}
removeMonitor();
// Make sure to disconnect observer in all case if view is valid
// to avoid notifications received when deleting when using Qt::AA_NativeWindows attribute
- if (m_qtView) {
- [[NSNotificationCenter defaultCenter] removeObserver:m_qtView];
- }
-
- // The QNSView object may outlive the corresponding QCocoaWindow object,
- // for example during app shutdown when the QNSView is embedded in a
- // foregin NSView hiearchy. Clear the pointers to the QWindow/QCocoaWindow
- // here to make sure QNSView does not dereference stale pointers.
- if (m_qtView) {
- [m_qtView clearQWindowPointers];
- }
+ if (window()->type() != Qt::ForeignWindow)
+ [[NSNotificationCenter defaultCenter] removeObserver:m_view];
// While it is unlikely that this window will be in the popup stack
// during deletetion we clear any pointers here to make sure.
@@ -460,7 +445,7 @@ QCocoaWindow::~QCocoaWindow()
child->m_parentCocoaWindow = 0;
}
- [m_contentView release];
+ [m_view release];
[m_nsWindow release];
[m_windowCursor release];
}
@@ -501,12 +486,12 @@ QRect QCocoaWindow::geometry() const
// QWindows that are embedded in a NSView hiearchy may be considered
// top-level from Qt's point of view but are not from Cocoa's point
// of view. Embedded QWindows get global (screen) geometry.
- if (m_contentViewIsEmbedded) {
- NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
- NSRect screenRect = [[m_contentView window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
+ if (m_viewIsEmbedded) {
+ NSPoint windowPoint = [m_view convertPoint:NSMakePoint(0, 0) toView:nil];
+ NSRect screenRect = [[m_view window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
NSPoint screenPoint = screenRect.origin;
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
- QSize size = qt_mac_toQRect([m_contentView bounds]).size();
+ QSize size = QRectF::fromCGRect([m_view bounds]).toRect().size();
return QRect(position, size);
}
@@ -518,9 +503,9 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setCocoaGeometry" << window() << rect;
QMacAutoReleasePool pool;
- if (m_contentViewIsEmbedded) {
- if (m_qtView) {
- [m_qtView setFrame:NSMakeRect(0, 0, rect.width(), rect.height())];
+ if (m_viewIsEmbedded) {
+ if (window()->type() != Qt::ForeignWindow) {
+ [m_view setFrame:NSMakeRect(0, 0, rect.width(), rect.height())];
} else {
QPlatformWindow::setGeometry(rect);
}
@@ -540,10 +525,10 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
NSRect bounds = qt_mac_flipRect(rect);
[m_nsWindow setFrame:[m_nsWindow frameRectForContentRect:bounds] display:YES animate:NO];
} else {
- [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
+ [m_view setFrame:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
}
- if (!m_qtView)
+ if (window()->type() == Qt::ForeignWindow)
QPlatformWindow::setGeometry(rect);
// will call QPlatformWindow::setGeometry(rect) during resize confirmation (see qnsview.mm)
@@ -568,7 +553,7 @@ void QCocoaWindow::clipWindow(const NSRect &clipRect)
// Clipping top/left offsets the content. Move it back.
NSPoint contentViewOffset = NSMakePoint(qMax(CGFloat(0), NSMinX(clippedWindowRect) - NSMinX(windowFrame)),
qMax(CGFloat(0), NSMaxY(windowFrame) - NSMaxY(clippedWindowRect)));
- [m_contentView setBoundsOrigin:contentViewOffset];
+ [m_view setBoundsOrigin:contentViewOffset];
}
if (NSIsEmptyRect(clippedWindowRect)) {
@@ -653,8 +638,8 @@ void QCocoaWindow::setVisible(bool visible)
if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating
- if (m_windowModality != window()->modality())
- recreateWindow(parent());
+ if (m_windowModality != window()->modality() || isNativeWindowTypeInconsistent())
+ recreateWindow(QPlatformWindow::parent());
// Register popup windows. The Cocoa platform plugin will forward mouse events
// to them and close them when needed.
@@ -739,8 +724,8 @@ void QCocoaWindow::setVisible(bool visible)
// In some cases, e.g. QDockWidget, the content view is hidden before moving to its own
// Cocoa window, and then shown again. Therefore, we test for the view being hidden even
// if it's attached to an NSWindow.
- if ([m_contentView isHidden])
- [m_contentView setHidden:NO];
+ if ([m_view isHidden])
+ [m_view setHidden:NO];
} else {
// qDebug() << "close" << this;
#ifndef QT_NO_OPENGL
@@ -773,7 +758,7 @@ void QCocoaWindow::setVisible(bool visible)
[mainWindow makeKeyWindow];
}
} else {
- [m_contentView setHidden:YES];
+ [m_view setHidden:YES];
}
removeMonitor();
@@ -938,7 +923,7 @@ void QCocoaWindow::setWindowTitle(const QString &title)
if (!m_nsWindow)
return;
- CFStringRef windowTitle = QCFString::toCFStringRef(title);
+ CFStringRef windowTitle = title.toCFString();
[m_nsWindow setTitle: const_cast<NSString *>(reinterpret_cast<const NSString *>(windowTitle))];
CFRelease(windowTitle);
}
@@ -950,7 +935,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
return;
QFileInfo fi(filePath);
- [m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
+ [m_nsWindow setRepresentedFilename:fi.exists() ? filePath.toNSString() : @""];
m_hasWindowFilePath = fi.exists();
}
@@ -962,7 +947,7 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
if (iconButton == nil) {
if (icon.isNull())
return;
- NSString *title = QCFString::toNSString(window()->title());
+ NSString *title = window()->title().toNSString();
[m_nsWindow setRepresentedURL:[NSURL fileURLWithPath:title]];
iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
}
@@ -1025,9 +1010,7 @@ void QCocoaWindow::raise()
}
static bool raiseProcess = qt_mac_resolveOption(true, "QT_MAC_SET_RAISE_PROCESS");
if (raiseProcess) {
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
+ [NSApp activateIgnoringOtherApps:YES];
}
}
}
@@ -1075,9 +1058,9 @@ bool QCocoaWindow::isOpaque() const
// When ordering below the window must be tranclucent.
static GLint openglSourfaceOrder = qt_mac_resolveOption(1, "QT_MAC_OPENGL_SURFACE_ORDER");
- bool translucent = (window()->format().alphaBufferSize() > 0
+ bool translucent = window()->format().alphaBufferSize() > 0
|| window()->opacity() < 1
- || (m_qtView && [m_qtView hasMask]))
+ || [qnsview_cast(m_view) hasMask]
|| (surface()->supportsOpenGL() && openglSourfaceOrder == -1);
return !translucent;
}
@@ -1109,11 +1092,10 @@ void QCocoaWindow::propagateSizeHints()
// sizeIncrement is observed to take values of (-1, -1) and (0, 0) for windows that should be
// resizable and that have no specific size increment set. Cocoa expects (1.0, 1.0) in this case.
- const QSize sizeIncrement = windowSizeIncrement();
- if (!sizeIncrement.isEmpty())
- [m_nsWindow setResizeIncrements : qt_mac_toNSSize(sizeIncrement)];
- else
- [m_nsWindow setResizeIncrements : NSMakeSize(1.0, 1.0)];
+ QSize sizeIncrement = windowSizeIncrement();
+ if (sizeIncrement.isEmpty())
+ sizeIncrement = QSize(1, 1);
+ [m_nsWindow setResizeIncrements:sizeIncrement.toCGSize()];
QRect rect = geometry();
QSize baseSize = windowBaseSize();
@@ -1137,8 +1119,8 @@ void QCocoaWindow::setMask(const QRegion &region)
if (m_nsWindow)
[m_nsWindow setBackgroundColor:[NSColor clearColor]];
- [m_qtView setMaskRegion:&region];
- [m_nsWindow setOpaque: isOpaque()];
+ [qnsview_cast(m_view) setMaskRegion:&region];
+ [m_nsWindow setOpaque:isOpaque()];
}
bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
@@ -1167,7 +1149,7 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab)
WId QCocoaWindow::winId() const
{
- return WId(m_contentView);
+ return WId(m_view);
}
void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
@@ -1175,38 +1157,16 @@ void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setParent" << window() << (parentWindow ? parentWindow->window() : 0);
// recreate the window for compatibility
- bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden];
+ bool unhideAfterRecreate = parentWindow && !m_viewIsToBeEmbedded && ![m_view isHidden];
recreateWindow(parentWindow);
if (unhideAfterRecreate)
- [m_contentView setHidden:NO];
+ [m_view setHidden:NO];
setCocoaGeometry(geometry());
}
-NSView *QCocoaWindow::contentView() const
-{
- return m_contentView;
-}
-
-void QCocoaWindow::setContentView(NSView *contentView)
+NSView *QCocoaWindow::view() const
{
- // Remove and release the previous content view
- if (m_nsWindow)
- [m_nsWindow setContentView:nil];
- else
- [m_contentView removeFromSuperview];
-
- [m_contentView release];
-
- // Insert and retain the new content view
- [contentView retain];
- m_contentView = contentView;
- m_qtView = 0; // The new content view is not a QNSView.
- recreateWindow(parent()); // Adds the content view to parent NSView
-}
-
-QNSView *QCocoaWindow::qtView() const
-{
- return m_qtView;
+ return m_view;
}
NSWindow *QCocoaWindow::nativeWindow() const
@@ -1216,7 +1176,7 @@ NSWindow *QCocoaWindow::nativeWindow() const
void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
{
- m_contentViewIsToBeEmbedded = embedded;
+ m_viewIsToBeEmbedded = embedded;
// Release any previosly created NSWindow.
[m_nsWindow closeAndRelease];
m_nsWindow = 0;
@@ -1225,10 +1185,7 @@ void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
void QCocoaWindow::windowWillMove()
{
// Close any open popups on window move
- while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
- QWindowSystemInterface::handleCloseEvent(popup->window());
- QWindowSystemInterface::flushWindowSystemEvents();
- }
+ qt_closePopups();
}
void QCocoaWindow::windowDidMove()
@@ -1236,7 +1193,7 @@ void QCocoaWindow::windowDidMove()
if (m_isNSWindowChild)
return;
- [m_qtView updateGeometry];
+ [qnsview_cast(m_view) updateGeometry];
}
void QCocoaWindow::windowDidResize()
@@ -1248,14 +1205,14 @@ void QCocoaWindow::windowDidResize()
return;
clipChildWindows();
- [m_qtView updateGeometry];
+ [qnsview_cast(m_view) updateGeometry];
}
void QCocoaWindow::windowDidEndLiveResize()
{
if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) {
m_effectivelyMaximized = false;
- [m_qtView notifyWindowStateChanged:Qt::WindowNoState];
+ [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
}
}
@@ -1272,6 +1229,13 @@ bool QCocoaWindow::windowShouldClose()
return accepted;
}
+void QCocoaWindow::windowWillClose()
+{
+ // Close any open popups on window closing.
+ if (window() && !windowIsPopupType(window()->type()))
+ qt_closePopups();
+}
+
void QCocoaWindow::setSynchedWindowStateFromWindow()
{
if (QWindow *w = window())
@@ -1324,8 +1288,8 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
bool usesNSPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
// No child QNSWindow should notify its QNSView
- if (m_nsWindow && m_qtView && m_parentCocoaWindow && !oldParentCocoaWindow)
- [[NSNotificationCenter defaultCenter] removeObserver:m_qtView
+ if (m_nsWindow && (window()->type() != Qt::ForeignWindow) && m_parentCocoaWindow && !oldParentCocoaWindow)
+ [[NSNotificationCenter defaultCenter] removeObserver:m_view
name:nil object:m_nsWindow];
// Remove current window (if any)
@@ -1343,8 +1307,8 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
// Only non-child QNSWindows should notify their QNSViews
// (but don't register more than once).
- if (m_qtView && (noPreviousWindow || (wasNSWindowChild && !m_isNSWindowChild)))
- [[NSNotificationCenter defaultCenter] addObserver:m_qtView
+ if ((window()->type() != Qt::ForeignWindow) && (noPreviousWindow || (wasNSWindowChild && !m_isNSWindowChild)))
+ [[NSNotificationCenter defaultCenter] addObserver:m_view
selector:@selector(windowNotification:)
name:nil // Get all notifications
object:m_nsWindow];
@@ -1352,13 +1316,13 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
if (oldParentCocoaWindow) {
if (!m_isNSWindowChild || oldParentCocoaWindow != m_parentCocoaWindow)
oldParentCocoaWindow->removeChildWindow(this);
- m_forwardWindow.assign(oldParentCocoaWindow);
+ m_forwardWindow = oldParentCocoaWindow;
}
setNSWindow(m_nsWindow);
}
- if (m_contentViewIsToBeEmbedded) {
+ if (m_viewIsToBeEmbedded) {
// An embedded window doesn't have its own NSWindow.
} else if (!parentWindow) {
// QPlatformWindow subclasses must sync up with QWindow on creation:
@@ -1388,18 +1352,18 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
}
} else {
// Child windows have no NSWindow, link the NSViews instead.
- if ([m_contentView superview])
- [m_contentView removeFromSuperview];
+ if ([m_view superview])
+ [m_view removeFromSuperview];
- [m_parentCocoaWindow->m_contentView addSubview : m_contentView];
+ [m_parentCocoaWindow->m_view addSubview:m_view];
QRect rect = windowGeometry();
// Prevent setting a (0,0) window size; causes opengl context
// "Invalid Drawable" warnings.
if (rect.isNull())
rect.setSize(QSize(1, 1));
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
- [m_contentView setFrame:frame];
- [m_contentView setHidden: YES];
+ [m_view setFrame:frame];
+ [m_view setHidden:!window()->isVisible()];
}
m_nsWindow.ignoresMouseEvents =
@@ -1430,9 +1394,9 @@ void QCocoaWindow::reinsertChildWindow(QCocoaWindow *child)
void QCocoaWindow::requestActivateWindow()
{
- NSWindow *window = [m_contentView window];
- [ window makeFirstResponder : m_contentView ];
- [ window makeKeyWindow ];
+ NSWindow *window = [m_view window];
+ [window makeFirstResponder:m_view];
+ [window makeKeyWindow];
}
bool QCocoaWindow::shouldUseNSPanel()
@@ -1517,14 +1481,14 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
{
- if (window.contentView != m_contentView) {
- [m_contentView setPostsFrameChangedNotifications: NO];
- [m_contentView retain];
- if (m_contentView.superview) // m_contentView comes from another NSWindow
- [m_contentView removeFromSuperview];
- [window setContentView:m_contentView];
- [m_contentView release];
- [m_contentView setPostsFrameChangedNotifications: YES];
+ if (window.contentView != m_view) {
+ [m_view setPostsFrameChangedNotifications:NO];
+ [m_view retain];
+ if (m_view.superview) // m_view comes from another NSWindow
+ [m_view removeFromSuperview];
+ [window setContentView:m_view];
+ [m_view release];
+ [m_view setPostsFrameChangedNotifications:YES];
}
}
@@ -1534,6 +1498,17 @@ void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
[m_nsWindow removeChildWindow:child->m_nsWindow];
}
+bool QCocoaWindow::isNativeWindowTypeInconsistent()
+{
+ if (!m_nsWindow)
+ return false;
+
+ const bool isPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
+ const bool usePanel = shouldUseNSPanel();
+
+ return isPanel != usePanel;
+}
+
void QCocoaWindow::removeMonitor()
{
if (!monitor)
@@ -1571,7 +1546,7 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
return;
// if content view width or height is 0 then the window animations will crash so
// do nothing except set the new state
- NSRect contentRect = [contentView() frame];
+ NSRect contentRect = m_view.frame;
if (contentRect.size.width <= 0 || contentRect.size.height <= 0) {
qWarning("invalid window content view size, check your window geometry");
m_synchedWindowState = newState;
@@ -1671,9 +1646,9 @@ NSCursor *QCocoaWindow::effectiveWindowCursor() const
if (m_windowCursor)
return m_windowCursor;
- if (!parent())
+ if (!QPlatformWindow::parent())
return nil;
- return static_cast<QCocoaWindow *>(parent())->effectiveWindowCursor();
+ return static_cast<QCocoaWindow *>(QPlatformWindow::parent())->effectiveWindowCursor();
}
// Applies the cursor as returned by effectiveWindowCursor(), handles
@@ -1696,7 +1671,7 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor)
return;
// Setting a cursor in a foregin view is not supported.
- if (!m_qtView)
+ if (window()->type() == Qt::ForeignWindow)
return;
[m_windowCursor release];
@@ -1714,9 +1689,9 @@ void QCocoaWindow::registerTouch(bool enable)
{
m_registerTouchCount += enable ? 1 : -1;
if (enable && m_registerTouchCount == 1)
- [m_contentView setAcceptsTouchEvents:YES];
+ [m_view setAcceptsTouchEvents:YES];
else if (m_registerTouchCount == 0)
- [m_contentView setAcceptsTouchEvents:NO];
+ [m_view setAcceptsTouchEvents:NO];
}
void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness)
@@ -1816,7 +1791,7 @@ qreal QCocoaWindow::devicePixelRatio() const
// methods such as [NSWindow backingScaleFacor] might not give the correct
// result, for example if setWantsBestResolutionOpenGLSurface is not set or
// or ignored by the OpenGL driver.
- NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
+ NSSize backingSize = [m_view convertSizeToBacking:NSMakeSize(1.0, 1.0)];
return backingSize.height;
}
@@ -1826,8 +1801,8 @@ bool QCocoaWindow::isWindowExposable()
{
QSize size = geometry().size();
bool validGeometry = (size.width() > 0 && size.height() > 0);
- bool validScreen = ([[m_contentView window] screen] != 0);
- bool nonHiddenSuperView = ![[m_contentView superview] isHidden];
+ bool validScreen = ([[m_view window] screen] != 0);
+ bool nonHiddenSuperView = ![[m_view superview] isHidden];
return (validGeometry && validScreen && nonHiddenSuperView);
}
@@ -1939,11 +1914,11 @@ QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffsetStatic(QWindow *window)
QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffset() const
{
- if (!m_contentView)
+ if (!m_view)
return QPoint();
- const NSPoint origin = [m_contentView isFlipped] ? NSMakePoint(0, [m_contentView frame].size.height)
+ const NSPoint origin = [m_view isFlipped] ? NSMakePoint(0, [m_view frame].size.height)
: NSMakePoint(0, 0);
- const NSRect visibleRect = [m_contentView visibleRect];
+ const NSRect visibleRect = [m_view visibleRect];
return QPoint(visibleRect.origin.x, -visibleRect.origin.y + (origin.y - visibleRect.size.height));
}
@@ -1963,3 +1938,5 @@ void QCocoaWindow::setFrameStrutEventsEnabled(bool enabled)
{
m_frameStrutEventsEnabled = enabled;
}
+
+#include "moc_qcocoawindow.cpp"
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h
index a3abacf849..1d229a55d2 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.h
+++ b/src/plugins/platforms/cocoa/qmacclipboard.h
@@ -41,9 +41,7 @@
#define QMACCLIPBOARD_H
#include <QtGui>
-#include <QtPlatformSupport/private/qmacmime_p.h>
-
-#undef slots
+#include <QtClipboardSupport/private/qmacmime_p.h>
#import <AppKit/AppKit.h>
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 721b0fb4d1..e09bb1e362 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -113,7 +113,7 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt)
if (err == noErr) {
PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
} else {
- qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QCFString::toQString(name).toLatin1().constData(), (int)err);
+ qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QString::fromCFString(name).toLatin1().constData(), (int)err);
}
resolvingBeforeDestruction = false;
}
@@ -139,7 +139,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
const long promise_id = (long)id;
// Find the kept promise
- const QString flavorAsQString = QCFString::toQString(flavor);
+ const QString flavorAsQString = QString::fromCFString(flavor);
QMacPasteboard::Promise promise;
for (int i = 0; i < qpaste->promises.size(); i++){
QMacPasteboard::Promise tmp = qpaste->promises[i];
@@ -380,7 +380,7 @@ QMacPasteboard::formats() const
const int type_count = CFArrayGetCount(types);
for (int i = 0; i < type_count; ++i) {
- const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
+ const QString flavor = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(types, i));
#ifdef DEBUG_PASTEBOARD
qDebug(" -%s", qPrintable(QString(flavor)));
#endif
@@ -423,7 +423,7 @@ QMacPasteboard::hasFormat(const QString &format) const
const int type_count = CFArrayGetCount(types);
for (int i = 0; i < type_count; ++i) {
- const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
+ const QString flavor = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(types, i));
#ifdef DEBUG_PASTEBOARD
qDebug(" -%s [0x%x]", qPrintable(QString(flavor)), mime_type);
#endif
@@ -487,13 +487,13 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
const int type_count = CFArrayGetCount(types);
for (int i = 0; i < type_count; ++i) {
CFStringRef flavor = static_cast<CFStringRef>(CFArrayGetValueAtIndex(types, i));
- if (c_flavor == QCFString::toQString(flavor)) {
+ if (c_flavor == QString::fromCFString(flavor)) {
QCFType<CFDataRef> macBuffer;
if (PasteboardCopyItemFlavorData(paste, id, flavor, &macBuffer) == noErr) {
QByteArray buffer((const char *)CFDataGetBytePtr(macBuffer), CFDataGetLength(macBuffer));
if (!buffer.isEmpty()) {
#ifdef DEBUG_PASTEBOARD
- qDebug(" - %s [%s] (%s)", qPrintable(format), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
+ qDebug(" - %s [%s] (%s)", qPrintable(format), qPrintable(QString::fromNSString(flavor)), qPrintable(c->convertorName()));
#endif
buffer.detach(); //detach since we release the macBuffer
retList.append(buffer);
@@ -502,7 +502,7 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
}
} else {
#ifdef DEBUG_PASTEBOARD
- qDebug(" - NoMatch %s [%s] (%s)", qPrintable(c_flavor), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
+ qDebug(" - NoMatch %s [%s] (%s)", qPrintable(c_flavor), qPrintable(QString::fromNSString(flavor)), qPrintable(c->convertorName()));
#endif
}
}
@@ -565,7 +565,7 @@ QString qt_mac_get_pasteboardString(PasteboardRef paste)
if (pb) {
NSString *text = [pb stringForType:NSStringPboardType];
if (text)
- return QCFString::toQString(text);
+ return QString::fromNSString(text);
}
return QString();
}
diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h
index e27f805fca..9e229b8dcb 100644
--- a/src/plugins/platforms/cocoa/qmacdefines_mac.h
+++ b/src/plugins/platforms/cocoa/qmacdefines_mac.h
@@ -93,42 +93,31 @@ typedef signed int OSStatus;
typedef signed long OSStatus;
#endif
+typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef;
+typedef struct OpaqueEventRef * EventRef;
+typedef struct OpaqueMenuRef * MenuRef;
+typedef struct OpaquePasteboardRef* PasteboardRef;
+typedef struct OpaqueRgnHandle * RgnHandle;
+typedef const struct __HIShape *HIShapeRef;
+typedef struct __HIShape *HIMutableShapeRef;
+typedef struct CGRect CGRect;
+typedef struct CGImage *CGImageRef;
+typedef struct CGContext *CGContextRef;
+typedef struct GDevice * GDPtr;
+typedef GDPtr * GDHandle;
+typedef struct OpaqueIconRef * IconRef;
+
#ifdef __OBJC__
-# ifdef slots
-# define old_slots slots
-# undef slots
-# endif
-#include <AppKit/AppKit.h>
-# ifdef old_slots
-# undef slots
-# define slots
-# undef old_slots
-# endif
+typedef NSWindow* OSWindowRef;
+typedef NSView *OSViewRef;
+typedef NSMenu *OSMenuRef;
+typedef NSEvent *OSEventRef;
+#else
+typedef void *OSWindowRef;
+typedef void *OSViewRef;
+typedef void *OSMenuRef;
+typedef void *OSEventRef;
#endif
- typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef;
- typedef struct OpaqueEventRef * EventRef;
- typedef struct OpaqueMenuRef * MenuRef;
- typedef struct OpaquePasteboardRef* PasteboardRef;
- typedef struct OpaqueRgnHandle * RgnHandle;
- typedef const struct __HIShape *HIShapeRef;
- typedef struct __HIShape *HIMutableShapeRef;
- typedef struct CGRect CGRect;
- typedef struct CGImage *CGImageRef;
- typedef struct CGContext *CGContextRef;
- typedef struct GDevice * GDPtr;
- typedef GDPtr * GDHandle;
- typedef struct OpaqueIconRef * IconRef;
-# ifdef __OBJC__
- typedef NSWindow* OSWindowRef;
- typedef NSView *OSViewRef;
- typedef NSMenu *OSMenuRef;
- typedef NSEvent *OSEventRef;
-# else
- typedef void *OSWindowRef;
- typedef void *OSViewRef;
- typedef void *OSMenuRef;
- typedef void *OSEventRef;
-# endif
typedef PasteboardRef OSPasteboardRef;
typedef struct AEDesc AEDescList;
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index c30ace35b4..f226547b90 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -64,8 +64,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
CGImageRef m_maskImage;
uchar *m_maskData;
bool m_shouldInvalidateWindowShadow;
- QPointer<QWindow> m_window;
- QCocoaWindow *m_platformWindow;
+ QPointer<QCocoaWindow> m_platformWindow;
NSTrackingArea *m_trackingArea;
Qt::MouseButtons m_buttons;
Qt::MouseButtons m_acceptedMouseDowns;
@@ -85,15 +84,13 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
bool m_resendKeyEvent;
bool m_scrolling;
bool m_updatingDrag;
- bool m_exposedOnMoveToWindow;
NSEvent *m_currentlyInterpretedKeyEvent;
bool m_isMenuView;
QSet<quint32> m_acceptedKeyDowns;
}
- (id)init;
-- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow;
-- (void) clearQWindowPointers;
+- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow;
#ifndef QT_NO_OPENGL
- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
#endif
@@ -102,6 +99,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
- (void)setMaskRegion:(const QRegion *)region;
- (void)invalidateWindowShadowIfNeeded;
- (void)drawRect:(NSRect)dirtyRect;
+- (void)drawBackingStoreUsingCoreGraphics:(NSRect)dirtyRect;
- (void)updateGeometry;
- (void)notifyWindowStateChanged:(Qt::WindowState)newState;
- (void)windowNotification : (NSNotification *) windowNotification;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index ba86b39e5b..a63bc4d570 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -39,8 +39,6 @@
#include <QtCore/qglobal.h>
-#include <dlfcn.h>
-
#include "qnsview.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
@@ -54,6 +52,7 @@
#include <QtCore/QDebug>
#include <QtCore/qsysinfo.h>
#include <private/qguiapplication_p.h>
+#include <private/qcoregraphics_p.h>
#include "qcocoabackingstore.h"
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
@@ -72,9 +71,6 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
static QTouchDevice *touchDevice = 0;
-// ### HACK Remove once 10.8 is unsupported
-static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
-
static bool _q_dontOverrideCtrlLMB = false;
@interface NSEvent (Qt_Compile_Leopard_DeviceDelta)
@@ -130,14 +126,15 @@ static bool _q_dontOverrideCtrlLMB = false;
@end
+// Private interface
+@interface QT_MANGLE_NAMESPACE(QNSView) ()
+- (BOOL)isTransparentForUserInput;
+@end
+
@implementation QT_MANGLE_NAMESPACE(QNSView)
+ (void)initialize
{
- NSString **notificationNameVar = (NSString **)dlsym(RTLD_NEXT, "NSWindowDidChangeOcclusionStateNotification");
- if (notificationNameVar)
- _q_NSWindowDidChangeOcclusionStateNotification = *notificationNameVar;
-
_q_dontOverrideCtrlLMB = qt_mac_resolveOption(false, "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
}
@@ -148,7 +145,6 @@ static bool _q_dontOverrideCtrlLMB = false;
m_backingStore = 0;
m_maskImage = 0;
m_shouldInvalidateWindowShadow = false;
- m_window = 0;
m_buttons = Qt::NoButton;
m_acceptedMouseDowns = Qt::NoButton;
m_frameStrutButtons = Qt::NoButton;
@@ -185,7 +181,6 @@ static bool _q_dontOverrideCtrlLMB = false;
CGImageRelease(m_maskImage);
[m_trackingArea release];
m_maskImage = 0;
- m_window = 0;
m_subscribesForGlobalFrameNotifications = false;
[m_inputSource release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -196,13 +191,12 @@ static bool _q_dontOverrideCtrlLMB = false;
[super dealloc];
}
-- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow
+- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow
{
self = [self init];
if (!self)
return 0;
- m_window = window;
m_platformWindow = platformWindow;
m_sendKeyEvent = false;
m_trackingArea = nil;
@@ -237,12 +231,6 @@ static bool _q_dontOverrideCtrlLMB = false;
return self;
}
-- (void) clearQWindowPointers
-{
- m_window = 0;
- m_platformWindow = 0;
-}
-
#ifndef QT_NO_OPENGL
- (void) setQCocoaGLContext:(QCocoaGLContext *)context
{
@@ -275,40 +263,28 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)viewDidMoveToSuperview
{
- if (!(m_platformWindow->m_contentViewIsToBeEmbedded))
+ if (!(m_platformWindow->m_viewIsToBeEmbedded))
return;
if ([self superview]) {
- m_platformWindow->m_contentViewIsEmbedded = true;
- QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry());
+ m_platformWindow->m_viewIsEmbedded = true;
+ QWindowSystemInterface::handleGeometryChange(m_platformWindow->window(), m_platformWindow->geometry());
m_platformWindow->updateExposedGeometry();
QWindowSystemInterface::flushWindowSystemEvents();
} else {
- m_platformWindow->m_contentViewIsEmbedded = false;
+ m_platformWindow->m_viewIsEmbedded = false;
}
}
- (void)viewDidMoveToWindow
{
m_backingStore = Q_NULLPTR;
- m_isMenuView = [self.window.className isEqualToString:@"NSCarbonMenuWindow"];
- if (self.window) {
- // This is the case of QWidgetAction's generated QWidget inserted in an NSMenu.
- // 10.9 and newer get the NSWindowDidChangeOcclusionStateNotification
- if (!_q_NSWindowDidChangeOcclusionStateNotification && m_isMenuView) {
- m_exposedOnMoveToWindow = true;
- m_platformWindow->exposeWindow();
- }
- } else if (m_exposedOnMoveToWindow) {
- m_exposedOnMoveToWindow = false;
- m_platformWindow->obscureWindow();
- }
}
- (void)viewWillMoveToWindow:(NSWindow *)newWindow
{
// ### Merge "normal" window code path with this one for 5.1.
- if (!(m_window->type() & Qt::SubWindow))
+ if (!(m_platformWindow->window()->type() & Qt::SubWindow))
return;
if (newWindow) {
@@ -323,11 +299,11 @@ static bool _q_dontOverrideCtrlLMB = false;
- (QWindow *)topLevelWindow
{
- QWindow *focusWindow = m_window;
+ QWindow *focusWindow = m_platformWindow->window();
// For widgets we need to do a bit of trickery as the window
// to activate is the window of the top-level widget.
- if (qstrcmp(m_window->metaObject()->className(), "QWidgetWindow") == 0) {
+ if (qstrcmp(focusWindow->metaObject()->className(), "QWidgetWindow") == 0) {
while (focusWindow->parent()) {
focusWindow = focusWindow->parent();
}
@@ -343,9 +319,9 @@ static bool _q_dontOverrideCtrlLMB = false;
if (m_platformWindow->m_isNSWindowChild) {
return;
#if 0
- //geometry = qt_mac_toQRect([self frame]);
+ //geometry = QRectF::fromCGRect([self frame]).toRect();
qDebug() << "nsview updateGeometry" << m_platformWindow->window();
- QRect screenRect = qt_mac_toQRect([m_platformWindow->m_nsWindow convertRectToScreen:[self frame]]);
+ QRect screenRect = QRectF::fromCGRect([m_platformWindow->m_nsWindow convertRectToScreen:[self frame]]).toRect();
qDebug() << "screenRect" << screenRect;
screenRect.moveTop(qt_mac_flipYCoordinate(screenRect.y() + screenRect.height()));
@@ -358,12 +334,12 @@ static bool _q_dontOverrideCtrlLMB = false;
NSRect rect = [self frame];
NSRect windowRect = [[self window] frame];
geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
- } else if (m_platformWindow->m_contentViewIsToBeEmbedded) {
+ } else if (m_platformWindow->m_viewIsToBeEmbedded) {
// embedded child window, use the frame rect ### merge with case below
- geometry = qt_mac_toQRect([self bounds]);
+ geometry = QRectF::fromCGRect([self bounds]).toRect();
} else {
// child window, use the frame rect
- geometry = qt_mac_toQRect([self frame]);
+ geometry = QRectF::fromCGRect([self frame]).toRect();
}
if (m_platformWindow->m_nsWindow && geometry == m_platformWindow->geometry())
@@ -377,7 +353,7 @@ static bool _q_dontOverrideCtrlLMB = false;
if (m_platformWindow->m_inSetStyleMask && !self.window)
return;
- qCDebug(lcQpaCocoaWindow) << "[QNSView udpateGeometry:]" << m_window
+ qCDebug(lcQpaCocoaWindow) << "[QNSView udpateGeometry:]" << m_platformWindow->window()
<< "current" << m_platformWindow->geometry() << "new" << geometry;
// Call setGeometry on QPlatformWindow. (not on QCocoaWindow,
@@ -388,12 +364,12 @@ static bool _q_dontOverrideCtrlLMB = false;
// Don't send the geometry change if the QWindow is designated to be
// embedded in a foreign view hiearchy but has not actually been
// embedded yet - it's too early.
- if (m_platformWindow->m_contentViewIsToBeEmbedded && !m_platformWindow->m_contentViewIsEmbedded)
+ if (m_platformWindow->m_viewIsToBeEmbedded && !m_platformWindow->m_viewIsEmbedded)
return;
// Send a geometry change event to Qt, if it's ready to handle events
if (!m_platformWindow->m_inConstructor) {
- QWindowSystemInterface::handleGeometryChange(m_window, geometry);
+ QWindowSystemInterface::handleGeometryChange(m_platformWindow->window(), geometry);
m_platformWindow->updateExposedGeometry();
// Guard against processing window system events during QWindow::setGeometry
// calles, which Qt and Qt applications do not excpect.
@@ -412,7 +388,7 @@ static bool _q_dontOverrideCtrlLMB = false;
// So we should say that it is maximized because it actually is.
if (newState == Qt::WindowNoState && m_platformWindow->m_effectivelyMaximized)
newState = Qt::WindowMaximized;
- QWindowSystemInterface::handleWindowStateChanged(m_window, newState);
+ QWindowSystemInterface::handleWindowStateChanged(m_platformWindow->window(), newState);
// We want to read the window state back from the window,
// but the event we just sent may be asynchronous.
QWindowSystemInterface::flushWindowSystemEvents();
@@ -421,18 +397,18 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)windowNotification : (NSNotification *) windowNotification
{
- //qDebug() << "windowNotification" << QCFString::toQString([windowNotification name]);
+ //qDebug() << "windowNotification" << QString::fromNSString([windowNotification name]);
NSString *notificationName = [windowNotification name];
if (notificationName == NSWindowDidBecomeKeyNotification) {
if (!m_platformWindow->windowIsPopupType() && !m_isMenuView)
- QWindowSystemInterface::handleWindowActivated(m_window);
+ QWindowSystemInterface::handleWindowActivated(m_platformWindow->window());
} else if (notificationName == NSWindowDidResignKeyNotification) {
// key window will be non-nil if another window became key... do not
// set the active window to zero here, the new key window's
// NSWindowDidBecomeKeyNotification hander will change the active window
NSWindow *keyWindow = [NSApp keyWindow];
- if (!keyWindow) {
+ if (!keyWindow || keyWindow == windowNotification.object) {
// no new key window, go ahead and set the active window to zero
if (!m_platformWindow->windowIsPopupType() && !m_isMenuView)
QWindowSystemInterface::handleWindowActivated(0);
@@ -446,14 +422,7 @@ static bool _q_dontOverrideCtrlLMB = false;
m_platformWindow->obscureWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
m_platformWindow->exposeWindow();
- } else if (_q_NSWindowDidChangeOcclusionStateNotification
- && [notificationName isEqualToString:_q_NSWindowDidChangeOcclusionStateNotification]) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
-// ### HACK Remove the enum declaration, the warning disabling and the cast further down once 10.8 is unsupported
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_CLANG("-Wobjc-method-access")
- enum { NSWindowOcclusionStateVisible = 1UL << 1 };
-#endif
+ } else if ([notificationName isEqualToString:NSWindowDidChangeOcclusionStateNotification]) {
// Several unit tests expect paint and/or expose events for windows that are
// sometimes (unpredictably) occluded and some unit tests depend on QWindow::isExposed -
// don't send Expose/Obscure events when running under QTestLib.
@@ -466,16 +435,13 @@ QT_WARNING_DISABLE_CLANG("-Wobjc-method-access")
m_platformWindow->obscureWindow();
}
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
-QT_WARNING_POP
-#endif
} else if (notificationName == NSWindowDidChangeScreenNotification) {
- if (m_window) {
+ if (m_platformWindow->window()) {
NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen];
if (screenIndex != NSNotFound) {
QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
if (cocoaScreen)
- QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen());
+ QWindowSystemInterface::handleWindowScreenChanged(m_platformWindow->window(), cocoaScreen->screen());
m_platformWindow->updateExposedGeometry();
}
}
@@ -522,11 +488,11 @@ QT_WARNING_POP
- (void) flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset
{
- qCDebug(lcQpaCocoaWindow) << "[QNSView flushBackingStore:]" << m_window << region.rectCount() << region.boundingRect() << offset;
+ qCDebug(lcQpaCocoaWindow) << "[QNSView flushBackingStore:]" << m_platformWindow->window() << region.rectCount() << region.boundingRect() << offset;
m_backingStore = backingStore;
- m_backingStoreOffset = offset * m_backingStore->getBackingStoreDevicePixelRatio();
- foreach (QRect rect, region.rects())
+ m_backingStoreOffset = offset * m_backingStore->paintDevice()->devicePixelRatio();
+ for (const QRect &rect : region)
[self setNeedsDisplayInRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
}
@@ -587,7 +553,7 @@ QT_WARNING_POP
- (void) drawRect:(NSRect)dirtyRect
{
- qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << qt_mac_toQRect(dirtyRect);
+ qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(dirtyRect);
#ifndef QT_NO_OPENGL
if (m_glContext && m_shouldSetGLContextinDrawRect) {
@@ -599,6 +565,18 @@ QT_WARNING_POP
if (m_platformWindow->m_drawContentBorderGradient)
NSDrawWindowBackground(dirtyRect);
+ if (m_backingStore)
+ [self drawBackingStoreUsingCoreGraphics:dirtyRect];
+
+ [self invalidateWindowShadowIfNeeded];
+}
+
+// Draws the backing store content to the QNSView using Core Graphics.
+// This function assumes that the QNSView is in a configuration that
+// supports Core Graphics, such as "classic" mode or layer mode with
+// the default layer.
+- (void)drawBackingStoreUsingCoreGraphics:(NSRect)dirtyRect
+{
if (!m_backingStore)
return;
@@ -607,7 +585,7 @@ QT_WARNING_POP
// The backing store source rect will be larger on retina displays.
// Scale dirtyRect by the device pixel ratio:
- const qreal devicePixelRatio = m_backingStore->getBackingStoreDevicePixelRatio();
+ const qreal devicePixelRatio = m_backingStore->paintDevice()->devicePixelRatio();
CGRect dirtyBackingRect = CGRectMake(dirtyRect.origin.x * devicePixelRatio,
dirtyRect.origin.y * devicePixelRatio,
dirtyRect.size.width * devicePixelRatio,
@@ -653,8 +631,6 @@ QT_WARNING_POP
CGImageRelease(cleanImg);
CGImageRelease(subMask);
CGImageRelease(bsCGImage);
-
- [self invalidateWindowShadowIfNeeded];
}
- (BOOL) isFlipped
@@ -662,11 +638,17 @@ QT_WARNING_POP
return YES;
}
+- (BOOL)isTransparentForUserInput
+{
+ return m_platformWindow->window() &&
+ m_platformWindow->window()->flags() & Qt::WindowTransparentForInput;
+}
+
- (BOOL)becomeFirstResponder
{
- if (!m_window || !m_platformWindow)
+ if (!m_platformWindow)
return NO;
- if (m_window->flags() & Qt::WindowTransparentForInput)
+ if ([self isTransparentForUserInput])
return NO;
if (!m_platformWindow->windowIsPopupType() && !m_isMenuView)
QWindowSystemInterface::handleWindowActivated([self topLevelWindow]);
@@ -675,15 +657,15 @@ QT_WARNING_POP
- (BOOL)acceptsFirstResponder
{
- if (!m_window || !m_platformWindow)
+ if (!m_platformWindow)
return NO;
if (m_isMenuView)
return NO;
if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
return NO;
- if (m_window->flags() & Qt::WindowTransparentForInput)
+ if ([self isTransparentForUserInput])
return NO;
- if ((m_window->flags() & Qt::ToolTip) == Qt::ToolTip)
+ if ((m_platformWindow->window()->flags() & Qt::ToolTip) == Qt::ToolTip)
return NO;
return YES;
}
@@ -691,9 +673,9 @@ QT_WARNING_POP
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
Q_UNUSED(theEvent)
- if (!m_window || !m_platformWindow)
+ if (!m_platformWindow)
return NO;
- if (m_window->flags() & Qt::WindowTransparentForInput)
+ if ([self isTransparentForUserInput])
return NO;
return YES;
}
@@ -702,7 +684,7 @@ QT_WARNING_POP
{
NSView *candidate = [super hitTest:aPoint];
if (candidate == self) {
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput))
+ if ([self isTransparentForUserInput])
return nil;
}
return candidate;
@@ -769,7 +751,7 @@ QT_WARNING_POP
QNSView *targetView = self;
if (m_platformWindow && m_platformWindow->m_forwardWindow) {
if (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp)
- targetView = m_platformWindow->m_forwardWindow->m_qtView;
+ targetView = qnsview_cast(m_platformWindow->m_forwardWindow->view());
else
m_platformWindow->m_forwardWindow.clear();
}
@@ -779,7 +761,7 @@ QT_WARNING_POP
// Tooltips must be transparent for mouse events
// The bug reference is QTBUG-46379
if (!popup->m_windowFlags.testFlag(Qt::ToolTip)) {
- if (QNSView *popupView = popup->qtView())
+ if (QNSView *popupView = qnsview_cast(popup->view()))
targetView = popupView;
}
}
@@ -791,7 +773,7 @@ QT_WARNING_POP
nativeDrag->setLastMouseEvent(theEvent, self);
Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
- QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint,
+ QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint,
m_buttons, keyboardModifiers, Qt::MouseEventNotSynthesized);
}
@@ -845,12 +827,12 @@ QT_WARNING_POP
QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
ulong timestamp = [theEvent timestamp] * 1000;
- QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons);
+ QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons);
}
- (bool)handleMouseDownEvent:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput))
+ if ([self isTransparentForUserInput])
return false;
Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]);
@@ -882,7 +864,7 @@ QT_WARNING_POP
- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput))
+ if ([self isTransparentForUserInput])
return false;
Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]);
@@ -898,7 +880,7 @@ QT_WARNING_POP
- (bool)handleMouseUpEvent:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput))
+ if ([self isTransparentForUserInput])
return false;
Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]);
@@ -921,7 +903,7 @@ QT_WARNING_POP
- (void)mouseDown:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return [super mouseDown:theEvent];
m_sendUpAsRightButton = false;
@@ -1079,7 +1061,7 @@ QT_WARNING_POP
- (void)mouseMovedImpl:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return;
QPointF windowPoint;
@@ -1101,7 +1083,7 @@ QT_WARNING_POP
// Cocoa keeps firing mouse move events for obscured parent views. Qt should not
// send those events so filter them out here.
- if (childWindow != m_window)
+ if (childWindow != m_platformWindow->window())
return;
[self handleMouseEvent: theEvent];
@@ -1112,7 +1094,7 @@ QT_WARNING_POP
Q_UNUSED(theEvent)
m_platformWindow->m_windowUnderMouse = true;
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return;
// Top-level windows generate enter events for sub-windows.
@@ -1131,7 +1113,7 @@ QT_WARNING_POP
Q_UNUSED(theEvent);
m_platformWindow->m_windowUnderMouse = false;
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return;
// Top-level windows generate leave events for sub-windows.
@@ -1207,16 +1189,16 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
windowPoint.x(), windowPoint.y(), screenPoint.x(), screenPoint.y(),
static_cast<uint>(buttons), pressure, xTilt, yTilt, rotation);
- QWindowSystemInterface::handleTabletEvent(m_window, timestamp, windowPoint, screenPoint,
+ QWindowSystemInterface::handleTabletEvent(m_platformWindow->window(), timestamp, windowPoint, screenPoint,
deviceData.device, deviceData.pointerType, buttons, pressure, xTilt, yTilt,
tangentialPressure, rotation, z, deviceData.uid,
keyboardModifiers);
return true;
}
-- (void)tabletPoint: (NSEvent *)theEvent
+- (void)tabletPoint:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return [super tabletPoint:theEvent];
[self handleTabletEvent: theEvent];
@@ -1262,9 +1244,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
return device;
}
-- (void)tabletProximity: (NSEvent *)theEvent
+- (void)tabletProximity:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return [super tabletProximity:theEvent];
ulong timestamp = [theEvent timestamp] * 1000;
@@ -1311,11 +1293,11 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
}
-- (bool) shouldSendSingleTouch
+- (bool)shouldSendSingleTouch
{
// QtWidgets expects single-point touch events, QtDeclarative does not.
// Until there is an API we solve this by looking at the window class type.
- return m_window->inherits("QWidgetWindow");
+ return m_platformWindow->window()->inherits("QWidgetWindow");
}
- (void)touchesBeganWithEvent:(NSEvent *)event
@@ -1323,7 +1305,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
}
- (void)touchesMovedWithEvent:(NSEvent *)event
@@ -1331,7 +1313,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
}
- (void)touchesEndedWithEvent:(NSEvent *)event
@@ -1339,7 +1321,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
}
- (void)touchesCancelledWithEvent:(NSEvent *)event
@@ -1347,7 +1329,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
}
#ifndef QT_NO_GESTURES
@@ -1379,11 +1361,10 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::ZoomNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::ZoomNativeGesture,
[event magnification], windowPoint, screenPoint);
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- (void)smartMagnifyWithEvent:(NSEvent *)event
{
static bool zoomIn = true;
@@ -1392,11 +1373,10 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SmartZoomNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SmartZoomNativeGesture,
zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
zoomIn = !zoomIn;
}
-#endif
- (void)rotateWithEvent:(NSEvent *)event
{
@@ -1407,7 +1387,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::RotateNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::RotateNativeGesture,
-[event rotation], windowPoint, screenPoint);
}
@@ -1429,7 +1409,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
else if ([event deltaY] == -1)
angle = 270.0f;
- QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SwipeNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SwipeNativeGesture,
angle, windowPoint, screenPoint);
}
@@ -1440,7 +1420,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint;
- QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::BeginNativeGesture,
+ QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::BeginNativeGesture,
windowPoint, screenPoint);
}
@@ -1451,7 +1431,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::EndNativeGesture,
+ QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::EndNativeGesture,
windowPoint, screenPoint);
}
#endif // QT_NO_GESTURES
@@ -1459,7 +1439,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
#ifndef QT_NO_WHEELEVENT
- (void)scrollWheel:(NSEvent *)theEvent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return [super scrollWheel:theEvent];
QPoint angleDelta;
@@ -1512,16 +1492,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
NSEventPhase phase = [theEvent phase];
Qt::ScrollPhase ph = Qt::ScrollUpdate;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- // On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
- if (phase == NSEventPhaseMayBegin) {
- m_scrolling = true;
- ph = Qt::ScrollBegin;
- }
- }
-#endif
- if (phase == NSEventPhaseBegan) {
+
+ // MayBegin is likely to happen. We treat it the same as an actual begin.
+ if (phase == NSEventPhaseMayBegin) {
+ m_scrolling = true;
+ ph = Qt::ScrollBegin;
+ } else if (phase == NSEventPhaseBegan) {
// If MayBegin did not happen, Began is the actual beginning.
if (!m_scrolling)
ph = Qt::ScrollBegin;
@@ -1536,7 +1512,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
// "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective.
bool isInverted = [theEvent isDirectionInvertedFromDevice];
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source, isInverted);
+ QWindowSystemInterface::handleWheelEvent(m_platformWindow->window(), qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source, isInverted);
}
#endif //QT_NO_WHEELEVENT
@@ -1595,7 +1571,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
// ignore text for the U+F700-U+F8FF range. This is used by Cocoa when
// delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.)
if (!(modifiers & (Qt::ControlModifier | Qt::MetaModifier)) && (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff))
- text = QCFString::toQString(characters);
+ text = QString::fromNSString(characters);
QWindow *window = [self topLevelWindow];
@@ -1644,7 +1620,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- (void)keyDown:(NSEvent *)nsevent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return [super keyDown:nsevent];
const bool accepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
@@ -1666,7 +1642,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- (void)keyUp:(NSEvent *)nsevent
{
- if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) )
+ if ([self isTransparentForUserInput])
return [super keyUp:nsevent];
const bool keyUpAccepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)];
@@ -1727,7 +1703,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if ((delta & mac_mask) == 0u)
continue;
- QWindowSystemInterface::handleKeyEvent(m_window,
+ QWindowSystemInterface::handleKeyEvent(m_platformWindow->window(),
timestamp,
(lastKnownModifiers & mac_mask) ? QEvent::KeyRelease : QEvent::KeyPress,
modifier_key_symbols[i].qt_code,
@@ -1758,9 +1734,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QString commitString;
if ([aString length]) {
if ([aString isKindOfClass:[NSAttributedString class]]) {
- commitString = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
+ commitString = QString::fromCFString(reinterpret_cast<CFStringRef>([aString string]));
} else {
- commitString = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
+ commitString = QString::fromCFString(reinterpret_cast<CFStringRef>(aString));
};
}
QObject *fo = QGuiApplication::focusObject();
@@ -1790,7 +1766,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if ([aString isKindOfClass:[NSAttributedString class]]) {
// Preedit string has attribution
- preeditString = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
+ preeditString = QString::fromCFString(reinterpret_cast<CFStringRef>([aString string]));
int composingLength = preeditString.length();
int index = 0;
// Create attributes for individual sections of preedit text
@@ -1819,7 +1795,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
} else {
// No attributes specified, take only the preedit text.
- preeditString = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
+ preeditString = QString::fromCFString(reinterpret_cast<CFStringRef>(aString));
}
if (attrs.isEmpty()) {
@@ -1938,12 +1914,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if (!queryEvent.value(Qt::ImEnabled).toBool())
return NSZeroRect;
- if (!m_window)
+ if (!m_platformWindow->window())
return NSZeroRect;
// The returned rect is always based on the internal cursor.
QRect mr = qApp->inputMethod()->cursorRectangle().toRect();
- QPoint mp = m_window->mapToGlobal(mr.bottomLeft());
+ QPoint mp = m_platformWindow->window()->mapToGlobal(mr.bottomLeft());
NSRect rect;
rect.origin.x = mp.x();
@@ -1960,9 +1936,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
return NSNotFound;
}
-- (NSArray*) validAttributesForMarkedText
+- (NSArray*)validAttributesForMarkedText
{
- if (m_window != QGuiApplication::focusWindow())
+ if (m_platformWindow->window() != QGuiApplication::focusWindow())
return nil;
QObject *fo = QGuiApplication::focusObject();
@@ -2000,7 +1976,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];
// Add custom types supported by the application.
for (int i = 0; i < customTypes.size(); i++) {
- [supportedTypes addObject:QCFString::toNSString(customTypes[i])];
+ [supportedTypes addObject:customTypes[i].toNSString()];
}
[self registerForDraggedTypes:supportedTypes];
}
@@ -2137,7 +2113,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]);
- QWindow *target = findEventTargetWindow(m_window);
+ QWindow *target = findEventTargetWindow(m_platformWindow->window());
if (!target)
return NSDragOperationNone;
@@ -2148,11 +2124,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
if (nativeDrag->currentDrag()) {
// The drag was started from within the application
- response = QWindowSystemInterface::handleDrag(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
+ response = QWindowSystemInterface::handleDrag(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed);
[self updateCursorFromDragResponse:response drag:nativeDrag];
} else {
QCocoaDropData mimeData([sender draggingPasteboard]);
- response = QWindowSystemInterface::handleDrag(target, &mimeData, mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
+ response = QWindowSystemInterface::handleDrag(target, &mimeData, mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed);
}
return qt_mac_mapDropAction(response.acceptedAction());
@@ -2160,7 +2136,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
- QWindow *target = findEventTargetWindow(m_window);
+ QWindow *target = findEventTargetWindow(m_platformWindow->window());
if (!target)
return;
@@ -2168,13 +2144,13 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
// Send 0 mime data to indicate drag exit
- QWindowSystemInterface::handleDrag(target, 0, mapWindowCoordinates(m_window, target, qt_windowPoint), Qt::IgnoreAction);
+ QWindowSystemInterface::handleDrag(target, 0, mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), Qt::IgnoreAction);
}
// called on drop, send the drop to Qt and return if it was accepted.
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
- QWindow *target = findEventTargetWindow(m_window);
+ QWindow *target = findEventTargetWindow(m_platformWindow->window());
if (!target)
return false;
@@ -2186,10 +2162,10 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
if (nativeDrag->currentDrag()) {
// The drag was started from within the application
- response = QWindowSystemInterface::handleDrop(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
+ response = QWindowSystemInterface::handleDrop(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed);
} else {
QCocoaDropData mimeData([sender draggingPasteboard]);
- response = QWindowSystemInterface::handleDrop(target, &mimeData, mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
+ response = QWindowSystemInterface::handleDrop(target, &mimeData, mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed);
}
if (response.isAccepted()) {
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
@@ -2204,7 +2180,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
{
Q_UNUSED(session);
Q_UNUSED(operation);
- QWindow *target = findEventTargetWindow(m_window);
+ QWindow *target = findEventTargetWindow(m_platformWindow->window());
if (!target)
return;
@@ -2221,7 +2197,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
- QWindowSystemInterface::handleMouseEvent(target, mapWindowCoordinates(m_window, target, qtWindowPoint), qtScreenPoint, m_buttons);
+ QWindowSystemInterface::handleMouseEvent(target, mapWindowCoordinates(m_platformWindow->window(), target, qtWindowPoint), qtScreenPoint, m_buttons);
}
@end
diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
index bfb4ba8124..73e1f41dd5 100644
--- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
@@ -53,10 +53,10 @@
@implementation QNSView (QNSViewAccessibility)
- (id)childAccessibleElement {
- if (!m_window->accessibleRoot())
+ if (!m_platformWindow->window()->accessibleRoot())
return nil;
- QAccessible::Id childId = QAccessible::uniqueId(m_window->accessibleRoot());
+ QAccessible::Id childId = QAccessible::uniqueId(m_platformWindow->window()->accessibleRoot());
return [QMacAccessibilityElement elementWithId: childId];
}
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index 5cb4b2aca2..f29aa97b68 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -57,6 +57,8 @@
- (void)windowWillMove:(NSNotification *)notification;
- (BOOL)windowShouldClose:(NSNotification *)notification;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
+- (void)windowWillClose:(NSNotification *)notification;
+
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu;
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index 320a7890bf..7f988ac963 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qnswindowdelegate.h"
+#include "qcocoahelpers.h"
#include <QDebug>
#include <qpa/qwindowsysteminterface.h>
@@ -60,7 +61,7 @@
if (m_cocoaWindow->m_windowUnderMouse) {
QPointF windowPoint;
QPointF screenPoint;
- [m_cocoaWindow->m_qtView convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
+ [qnsview_cast(m_cocoaWindow->view()) convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
QWindowSystemInterface::handleEnterEvent(m_cocoaWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
}
}
@@ -110,11 +111,18 @@
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
{
Q_UNUSED(newFrame);
- if (m_cocoaWindow && m_cocoaWindow->m_qtView)
- [m_cocoaWindow->m_qtView notifyWindowWillZoom:![window isZoomed]];
+ if (m_cocoaWindow && m_cocoaWindow->window()->type() != Qt::ForeignWindow)
+ [qnsview_cast(m_cocoaWindow->view()) notifyWindowWillZoom:![window isZoomed]];
return YES;
}
+- (void)windowWillClose:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ if (m_cocoaWindow)
+ m_cocoaWindow->windowWillClose();
+}
+
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
{
Q_UNUSED(window);
diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
index 395c25c915..7e241e3ae6 100644
--- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
@@ -63,6 +63,7 @@
#include <private/qpainter_p.h>
#include <private/qpainterpath_p.h>
#include <private/qtextengine_p.h>
+#include <private/qcoregraphics_p.h>
#include "qcocoahelpers.h"
@@ -74,87 +75,6 @@ QT_BEGIN_NAMESPACE
QCoreGraphicsPaintEngine utility functions
*****************************************************************************/
-static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
-{
- CGAffineTransform old_xform = CGAffineTransformIdentity;
- if (orig_xform) { //setup xforms
- old_xform = CGContextGetCTM(hd);
- CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform));
- CGContextConcatCTM(hd, *orig_xform);
- }
-
- //do the clipping
- CGContextBeginPath(hd);
- if (rgn.isEmpty()) {
- CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
- } else {
- QVector<QRect> rects = rgn.rects();
- const int count = rects.size();
- for (int i = 0; i < count; i++) {
- const QRect &r = rects[i];
- CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
- CGContextAddRect(hd, mac_r);
- }
- }
- CGContextClip(hd);
-
- if (orig_xform) {//reset xforms
- CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
- CGContextConcatCTM(hd, old_xform);
- }
-}
-
-// Implemented for qt_mac_p.h
-QMacCGContext::QMacCGContext(QPainter *p)
-{
- QPaintEngine *pe = p->paintEngine();
-#ifndef QT_NO_PRINTER
- if (pe->type() == QPaintEngine::MacPrinter)
- pe = static_cast<QMacPrintEngine*>(pe)->paintEngine();
-#endif
- pe->syncState();
- context = 0;
- if (pe->type() == QPaintEngine::CoreGraphics)
- context = static_cast<QCoreGraphicsPaintEngine*>(pe)->handle();
-
- int devType = p->device()->devType();
- if (pe->type() == QPaintEngine::Raster
- && (devType == QInternal::Widget || devType == QInternal::Pixmap || devType == QInternal::Image)) {
-
- CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice());
- uint flags = kCGImageAlphaPremultipliedFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
- flags |= kCGBitmapByteOrder32Host;
-#endif
- const QImage *image = (const QImage *) pe->paintDevice();
-
- context = CGBitmapContextCreate((void *) image->bits(), image->width(), image->height(),
- 8, image->bytesPerLine(), colorspace, flags);
-
- CGContextTranslateCTM(context, 0, image->height());
- CGContextScaleCTM(context, 1, -1);
-
- if (devType == QInternal::Widget) {
- QRegion clip = p->paintEngine()->systemClip();
- QTransform native = p->deviceTransform();
-
- if (p->hasClipping()) {
- QRegion r = p->clipRegion();
- r.translate(native.dx(), native.dy());
- if (clip.isEmpty())
- clip = r;
- else
- clip &= r;
- }
- qt_mac_clip_cg(context, clip, 0);
-
- CGContextTranslateCTM(context, native.dx(), native.dy());
- }
- } else {
- CGContextRetain(context);
- }
-}
-
void qt_mac_cgimage_data_free(void *, const void *memoryToFree, size_t)
{
free(const_cast<void *>(memoryToFree));
@@ -456,7 +376,7 @@ static void qt_mac_draw_pattern(void *info, CGContextRef c)
const QColor c0(0, 0, 0, 0), c1(255, 255, 255, 255);
QPixmap pm(w*QMACPATTERN_MASK_MULTIPLIER, h*QMACPATTERN_MASK_MULTIPLIER);
pm.fill(c0);
- CGContextRef pm_ctx = qt_mac_cg_context(&pm);
+ QMacCGContext pm_ctx(&pm);
CGContextSetFillColorWithColor(c, cgColorForQColor(c1, pat->pdev));
CGRect rect = CGRectMake(0, 0, w, h);
for (int x = 0; x < QMACPATTERN_MASK_MULTIPLIER; ++x) {
@@ -546,7 +466,8 @@ QCoreGraphicsPaintEngine::begin(QPaintDevice *pdev)
d->cosmeticPenSize = 1;
d->current.clipEnabled = false;
d->pixelSize = QPoint(1,1);
- d->hd = qt_mac_cg_context(pdev);
+ QMacCGContext ctx(pdev);
+ d->hd = CGContextRetain(ctx);
if (d->hd) {
d->saveGraphicsState();
d->orig_xform = CGContextGetCTM(d->hd);
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 3d0c91c36c..8098c5e829 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -200,7 +200,7 @@ int QMacPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
val = (int)resolution.vRes;
break;
}
- //otherwise fall through
+ Q_FALLTHROUGH();
}
case QPaintDevice::PdmDpiY:
val = (int)d->resolution.vRes;
@@ -673,7 +673,7 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_DocumentName: {
CFStringRef name;
PMPrintSettingsGetJobName(d->settings(), &name);
- ret = QCFString::toQString(name);
+ ret = QString::fromCFString(name);
break;
}
case PPK_Duplex: {
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac_p.h b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
index e3cad3fd57..ee98275b63 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac_p.h
+++ b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
@@ -149,6 +149,9 @@ public:
PMPageFormat format() const { return static_cast<PMPageFormat>([printInfo PMPageFormat]); }
PMPrintSession session() const { return static_cast<PMPrintSession>([printInfo PMPrintSession]); }
PMPrintSettings settings() const { return static_cast<PMPrintSettings>([printInfo PMPrintSettings]); }
+
+ QPaintEngine *aggregateEngine() Q_DECL_OVERRIDE { return paintEngine; }
+ Qt::HANDLE nativeHandle() Q_DECL_OVERRIDE { return q_func()->handle(); }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h
index 03eae1b2e7..fdcf3bcdd3 100644
--- a/src/plugins/platforms/cocoa/qt_mac_p.h
+++ b/src/plugins/platforms/cocoa/qt_mac_p.h
@@ -51,13 +51,13 @@
// We mean it.
//
-#include "qmacdefines_mac.h"
-
#ifdef __OBJC__
#include <AppKit/AppKit.h>
#include <objc/runtime.h>
#endif
+#include "qmacdefines_mac.h"
+
#include <CoreServices/CoreServices.h>
#include "QtCore/qglobal.h"
@@ -90,60 +90,6 @@ public:
}
};
-class Q_WIDGETS_EXPORT QMacWindowChangeEvent
-{
-private:
- static QList<QMacWindowChangeEvent*> *change_events;
-public:
- QMacWindowChangeEvent() {
- }
- virtual ~QMacWindowChangeEvent() {
- }
- static inline void exec(bool ) {
- }
-protected:
- virtual void windowChanged() = 0;
- virtual void flushWindowChanged() = 0;
-};
-
-class QMacCGContext
-{
- CGContextRef context;
-public:
- QMacCGContext(QPainter *p); //qpaintengine_mac.mm
- inline QMacCGContext() { context = 0; }
- inline QMacCGContext(QPaintDevice *pdev) {
- extern CGContextRef qt_mac_cg_context(QPaintDevice *);
- context = qt_mac_cg_context(pdev);
- }
- inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) {
- context = cg;
- if(!takeOwnership)
- CGContextRetain(context);
- }
- inline QMacCGContext(const QMacCGContext &copy) : context(0) { *this = copy; }
- inline ~QMacCGContext() {
- if(context)
- CGContextRelease(context);
- }
- inline bool isNull() const { return context; }
- inline operator CGContextRef() { return context; }
- inline QMacCGContext &operator=(const QMacCGContext &copy) {
- if(context)
- CGContextRelease(context);
- context = copy.context;
- CGContextRetain(context);
- return *this;
- }
- inline QMacCGContext &operator=(CGContextRef cg) {
- if(context)
- CGContextRelease(context);
- context = cg;
- CGContextRetain(context); //we do not take ownership
- return *this;
- }
-};
-
class QMacInternalPasteboardMime;
class QMimeData;
diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/classes.nib b/src/plugins/platforms/cocoa/qt_menu.nib/classes.nib
deleted file mode 100644
index 78941153c2..0000000000
--- a/src/plugins/platforms/cocoa/qt_menu.nib/classes.nib
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBClasses</key>
- <array>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>hide</key>
- <string>id</string>
- <key>hideOtherApplications</key>
- <string>id</string>
- <key>orderFrontStandardAboutPanel</key>
- <string>id</string>
- <key>qtDispatcherToQPAMenuItem</key>
- <string>id</string>
- <key>terminate</key>
- <string>id</string>
- <key>unhideAllApplications</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>QCocoaMenuLoader</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>aboutItem</key>
- <string>NSMenuItem</string>
- <key>aboutQtItem</key>
- <string>NSMenuItem</string>
- <key>appMenu</key>
- <string>NSMenu</string>
- <key>hideItem</key>
- <string>NSMenuItem</string>
- <key>preferencesItem</key>
- <string>NSMenuItem</string>
- <key>quitItem</key>
- <string>NSMenuItem</string>
- <key>theMenu</key>
- <string>NSMenu</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSResponder</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>FirstResponder</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- </array>
- <key>IBVersion</key>
- <string>1</string>
-</dict>
-</plist>
diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/info.nib b/src/plugins/platforms/cocoa/qt_menu.nib/info.nib
deleted file mode 100644
index 02e5cca562..0000000000
--- a/src/plugins/platforms/cocoa/qt_menu.nib/info.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBFramework Version</key>
- <string>672</string>
- <key>IBOldestOS</key>
- <integer>5</integer>
- <key>IBOpenObjects</key>
- <array>
- <integer>57</integer>
- </array>
- <key>IBSystem Version</key>
- <string>9L31a</string>
- <key>targetFramework</key>
- <string>IBCocoaFramework</string>
-</dict>
-</plist>
diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib b/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib
deleted file mode 100644
index 67207ca628..0000000000
--- a/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib
+++ /dev/null
Binary files differ
diff --git a/src/plugins/platforms/direct2d/direct2d.pro b/src/plugins/platforms/direct2d/direct2d.pro
index 005a4da6db..224f122fc4 100644
--- a/src/plugins/platforms/direct2d/direct2d.pro
+++ b/src/plugins/platforms/direct2d/direct2d.pro
@@ -1,10 +1,11 @@
TARGET = qdirect2d
-QT *= core-private
-QT *= gui-private
-QT *= platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private accessibility_support-private \
+ fontdatabase_support-private theme_support-private
-LIBS *= -ld2d1 -ld3d11 -ldwrite -lVersion -lgdi32
+LIBS += -ldwmapi -ld2d1 -ld3d11 -ldwrite -lVersion -lgdi32
include(../windows/windows.pri)
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp
index 97eadb207b..38f2352934 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp
@@ -95,7 +95,7 @@ void QWindowsDirect2DBackingStore::beginPaint(const QRegion &region)
painter.setCompositionMode(QPainter::CompositionMode_Source);
- foreach (const QRect &r, region.rects())
+ for (const QRect &r : region)
painter.fillRect(r, clear);
}
@@ -127,10 +127,14 @@ void QWindowsDirect2DBackingStore::resize(const QSize &size, const QRegion &regi
QPixmap *newPixmap = nativeWindow(window())->pixmap();
if (!old.isNull()) {
- foreach (const QRect &rect, region.rects()) {
+ for (const QRect &rect : region)
platformPixmap(newPixmap)->copy(old.handle(), rect);
- }
}
}
+QImage QWindowsDirect2DBackingStore::toImage() const
+{
+ return nativeWindow(window())->pixmap()->toImage();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h
index 9d754866cc..670c4e9840 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h
@@ -60,6 +60,8 @@ public:
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
void flush(QWindow *targetWindow, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
+
+ QImage toImage() const override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
index 2d107a6e27..b5065ba380 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
@@ -80,7 +80,7 @@ public:
bitmap.Reset();
D2D1_SIZE_U size = {
- width, height
+ UINT32(width), UINT32(height)
};
HRESULT hr = deviceContext->get()->CreateBitmap(size, data, pitch,
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
index 97715ad050..34225bba9a 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
@@ -46,6 +46,13 @@
#include <QtGui/QColor>
#include <QtGui/QTransform>
+#ifdef Q_CC_MINGW
+# include <qt_windows.h>
+# include <d2d1.h>
+# include <d2d1helper.h>
+# include <d2dbasetypes.h>
+# include <d2d1_1.h>
+#endif // Q_CC_MINGW
#include <d2d1_1helper.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
index deabe98fbe..da4a4e6ce6 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
@@ -50,7 +50,9 @@
#include <QtCore/QCoreApplication>
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/qpa/qwindowsysteminterface.h>
-#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
+
+#include <QVarLengthArray>
QT_BEGIN_NAMESPACE
@@ -106,7 +108,7 @@ public:
if (_tcscat_s(filename, bufSize, __TEXT("\\d2d1.dll")) == 0) {
DWORD versionInfoSize = GetFileVersionInfoSize(filename, NULL);
if (versionInfoSize) {
- QVector<BYTE> info(versionInfoSize);
+ QVarLengthArray<BYTE> info(versionInfoSize);
if (GetFileVersionInfo(filename, NULL, versionInfoSize, info.data())) {
UINT size;
DWORD *fi;
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index 730d5de450..69d2e12778 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -45,8 +45,8 @@
#include "qwindowsdirect2dbitmap.h"
#include "qwindowsdirect2ddevicecontext.h"
-#include "qwindowsfontengine.h"
-#include "qwindowsfontdatabase.h"
+#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qwindowsfontengine_p.h>
#include "qwindowsintegration.h"
#include <QtCore/QtMath>
@@ -563,7 +563,7 @@ public:
if (newPen.widthF() <= 1.0)
props.startCap = props.endCap = props.dashCap = D2D1_CAP_STYLE_FLAT;
- // fall through
+ Q_FALLTHROUGH();
default:
props.dashStyle = D2D1_DASH_STYLE_CUSTOM;
break;
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
index 4e677166b2..c750b02078 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
@@ -122,7 +122,7 @@ void QWindowsDirect2DWindow::flush(QWindowsDirect2DBitmap *bitmap, const QRegion
QRegion clipped = region;
clipped &= QRect(QPoint(), size);
- foreach (const QRect &rect, clipped.rects()) {
+ for (const QRect &rect : clipped) {
QRectF rectF(rect);
dc->DrawBitmap(bitmap->bitmap(),
to_d2d_rect_f(rectF),
diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro
index 5c81e0283a..4e95aebe35 100644
--- a/src/plugins/platforms/directfb/directfb.pro
+++ b/src/plugins/platforms/directfb/directfb.pro
@@ -1,9 +1,11 @@
TARGET = qdirectfb
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private service_support-private \
+ fontdatabase_support-private egl_support-private
-LIBS += $$QMAKE_LIBS_DIRECTFB
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_DIRECTFB
+QMAKE_USE += directfb
SOURCES = main.cpp \
qdirectfbintegration.cpp \
@@ -42,9 +44,6 @@ contains(QT_CONFIG, directfb_egl) {
SOURCES += qdirectfbeglhooks_stub.cpp
}
-
-CONFIG += qpa/genericunixfontdatabase
-
OTHER_FILES += directfb.json
PLUGIN_TYPE = platforms
diff --git a/src/plugins/platforms/directfb/qdirectfb_egl.cpp b/src/plugins/platforms/directfb/qdirectfb_egl.cpp
index 2a04c0bba3..dad553c890 100644
--- a/src/plugins/platforms/directfb/qdirectfb_egl.cpp
+++ b/src/plugins/platforms/directfb/qdirectfb_egl.cpp
@@ -46,10 +46,10 @@
#include <qpa/qplatformopenglcontext.h>
#include <QtGui/QScreen>
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglplatformcontext_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qt_egl_p.h>
+#include <QtEglSupport/private/qt_egl_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp b/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
index 0bcf93aa3d..8d5e1e50c4 100644
--- a/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
@@ -70,9 +70,7 @@ void QDirectFbBackingStore::flush(QWindow *, const QRegion &region, const QPoint
{
m_pmdata->blittable()->unlock();
- QVector<QRect> rects = region.rects();
- for (int i = 0 ; i < rects.size(); i++) {
- const QRect rect = rects.at(i);
+ for (const QRect &rect : region) {
DFBRegion dfbReg(rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y());
m_dfbSurface->Flip(m_dfbSurface.data(), &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC));
}
@@ -108,13 +106,15 @@ bool QDirectFbBackingStore::scroll(const QRegion &area, int dx, int dy)
if (area.rectCount() == 1) {
scrollSurface(m_dfbSurface.data(), area.boundingRect(), dx, dy);
} else {
- const QVector<QRect> rects = area.rects();
- const int n = rects.size();
- for (int i=0; i<n; ++i) {
- scrollSurface(m_dfbSurface.data(), rects.at(i), dx, dy);
- }
+ for (const QRect &rect : area)
+ scrollSurface(m_dfbSurface.data(), rect, dx, dy);
}
return true;
}
+QImage QDirectFbBackingStore::toImage() const
+{
+ return m_pixmap.data()->toImage();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbbackingstore.h b/src/plugins/platforms/directfb/qdirectfbbackingstore.h
index 33ab1c111d..af1ce92e64 100644
--- a/src/plugins/platforms/directfb/qdirectfbbackingstore.h
+++ b/src/plugins/platforms/directfb/qdirectfbbackingstore.h
@@ -59,6 +59,8 @@ public:
void resize (const QSize &size, const QRegion &staticContents);
bool scroll(const QRegion &area, int dx, int dy);
+ QImage toImage() const override;
+
private:
void lockSurfaceToImage();
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
index 506432f886..cdf340da7a 100644
--- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
@@ -44,9 +44,9 @@
#include "qdirectfbcursor.h"
#include "qdirectfbwindow.h"
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
#include <QtGui/private/qpixmap_blitter_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
diff --git a/src/plugins/platforms/eglfs/api/api.pri b/src/plugins/platforms/eglfs/api/api.pri
new file mode 100644
index 0000000000..0ea65bd1ff
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/api.pri
@@ -0,0 +1,21 @@
+
+SOURCES += $$PWD/qeglfswindow.cpp \
+ $$PWD/qeglfsscreen.cpp \
+ $$PWD/qeglfscursor.cpp \
+ $$PWD/qeglfshooks.cpp \
+ $$PWD/qeglfsdeviceintegration.cpp \
+ $$PWD/qeglfsintegration.cpp \
+ $$PWD/qeglfscontext.cpp \
+ $$PWD/qeglfsoffscreenwindow.cpp
+
+HEADERS += $$PWD/qeglfswindow_p.h \
+ $$PWD/qeglfsscreen_p.h \
+ $$PWD/qeglfscursor_p.h \
+ $$PWD/qeglfshooks_p.h \
+ $$PWD/qeglfsdeviceintegration_p.h \
+ $$PWD/qeglfsintegration_p.h \
+ $$PWD/qeglfscontext_p.h \
+ $$PWD/qeglfsoffscreenwindow_p.h \
+ $$PWD/qeglfsglobal_p.h
+
+INCLUDEPATH += $$PWD
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
index 6acb362bf0..c5cef34d8e 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
@@ -37,15 +37,15 @@
**
****************************************************************************/
-#include "qeglfsglobal.h"
+#include "qeglfsglobal_p.h"
#include <QtGui/QSurface>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
-#include "qeglfscontext.h"
-#include "qeglfswindow.h"
-#include "qeglfshooks.h"
-#include "qeglfscursor.h"
+#include "qeglfscontext_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
+#include "qeglfscursor_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/api/qeglfscontext_p.h
index 91c5a7910b..ab5bf99c3c 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.h
+++ b/src/plugins/platforms/eglfs/api/qeglfscontext_p.h
@@ -40,8 +40,19 @@
#ifndef QEGLFSCONTEXT_H
#define QEGLFSCONTEXT_H
-#include "qeglfsglobal.h"
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include <QtEglSupport/private/qeglplatformcontext_p.h>
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
index 6c8c35b1dc..2b54251a06 100644
--- a/src/plugins/platforms/eglfs/qeglfscursor.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
@@ -37,9 +37,9 @@
**
****************************************************************************/
-#include "qeglfscursor.h"
-#include "qeglfsintegration.h"
-#include "qeglfsscreen.h"
+#include "qeglfscursor_p.h"
+#include "qeglfsintegration_p.h"
+#include "qeglfsscreen_p.h"
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/QOpenGLContext>
@@ -59,12 +59,11 @@
QT_BEGIN_NAMESPACE
QEglFSCursor::QEglFSCursor(QPlatformScreen *screen)
- : m_visible(true),
- m_screen(static_cast<QEglFSScreen *>(screen)),
- m_program(0),
- m_textureEntry(0),
- m_deviceListener(0),
- m_updateRequested(false)
+ : m_visible(true),
+ m_screen(static_cast<QEglFSScreen *>(screen)),
+ m_activeScreen(nullptr),
+ m_deviceListener(0),
+ m_updateRequested(false)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
if (!hideCursorVal.isEmpty())
@@ -72,6 +71,10 @@ QEglFSCursor::QEglFSCursor(QPlatformScreen *screen)
if (!m_visible)
return;
+ int rotation = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION");
+ if (rotation)
+ m_rotationMatrix.rotate(rotation, 0, 0, 1);
+
// Try to load the cursor atlas. If this fails, m_visible is set to false and
// paintOnScreen() and setCurrentCursor() become no-ops.
initCursorAtlas();
@@ -112,15 +115,14 @@ void QEglFSCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::Device
void QEglFSCursor::resetResources()
{
- if (QOpenGLContext::currentContext()) {
- delete m_program;
- glDeleteTextures(1, &m_cursor.customCursorTexture);
- glDeleteTextures(1, &m_cursorAtlas.texture);
+ if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) {
+ GraphicsContextData &gfx(m_gfx[ctx]);
+ delete gfx.program;
+ glDeleteTextures(1, &gfx.customCursorTexture);
+ glDeleteTextures(1, &gfx.atlasTexture);
+ gfx = GraphicsContextData();
}
- m_program = 0;
- m_cursor.customCursorTexture = 0;
m_cursor.customCursorPending = !m_cursor.customCursorImage.isNull();
- m_cursorAtlas.texture = 0;
}
void QEglFSCursor::createShaderPrograms()
@@ -129,9 +131,10 @@ void QEglFSCursor::createShaderPrograms()
"attribute highp vec2 vertexCoordEntry;\n"
"attribute highp vec2 textureCoordEntry;\n"
"varying highp vec2 textureCoord;\n"
+ "uniform highp mat4 mat;\n"
"void main() {\n"
" textureCoord = textureCoordEntry;\n"
- " gl_Position = vec4(vertexCoordEntry, 1.0, 1.0);\n"
+ " gl_Position = mat * vec4(vertexCoordEntry, 1.0, 1.0);\n"
"}\n";
static const char *textureFragmentProgram =
@@ -141,14 +144,16 @@ void QEglFSCursor::createShaderPrograms()
" gl_FragColor = texture2D(texture, textureCoord).bgra;\n"
"}\n";
- m_program = new QOpenGLShaderProgram;
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
- m_program->bindAttributeLocation("vertexCoordEntry", 0);
- m_program->bindAttributeLocation("textureCoordEntry", 1);
- m_program->link();
+ GraphicsContextData &gfx(m_gfx[QOpenGLContext::currentContext()]);
+ gfx.program = new QOpenGLShaderProgram;
+ gfx.program->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
+ gfx.program->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
+ gfx.program->bindAttributeLocation("vertexCoordEntry", 0);
+ gfx.program->bindAttributeLocation("textureCoordEntry", 1);
+ gfx.program->link();
- m_textureEntry = m_program->uniformLocation("texture");
+ gfx.textureEntry = gfx.program->uniformLocation("texture");
+ gfx.matEntry = gfx.program->uniformLocation("mat");
}
void QEglFSCursor::createCursorTexture(uint *texture, const QImage &image)
@@ -208,7 +213,7 @@ void QEglFSCursor::changeCursor(QCursor *cursor, QWindow *window)
Q_UNUSED(window);
const QRect oldCursorRect = cursorRect();
if (setCurrentCursor(cursor))
- update(oldCursorRect | cursorRect());
+ update(oldCursorRect | cursorRect(), false);
}
bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
@@ -232,16 +237,17 @@ bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
hs * (m_cursor.shape / m_cursorAtlas.cursorsPerRow),
ws, hs);
m_cursor.hotSpot = m_cursorAtlas.hotSpots[m_cursor.shape];
- m_cursor.texture = m_cursorAtlas.texture;
+ m_cursor.useCustomCursor = false;
m_cursor.size = QSize(m_cursorAtlas.cursorWidth, m_cursorAtlas.cursorHeight);
} else {
QImage image = cursor->pixmap().toImage();
m_cursor.textureRect = QRectF(0, 0, 1, 1);
m_cursor.hotSpot = cursor->hotSpot();
- m_cursor.texture = 0; // will get updated in the next render()
+ m_cursor.useCustomCursor = false; // will get updated in the next render()
m_cursor.size = image.size();
m_cursor.customCursorImage = image;
m_cursor.customCursorPending = true;
+ m_cursor.customCursorKey = m_cursor.customCursorImage.cacheKey();
}
return true;
@@ -251,17 +257,20 @@ bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
class CursorUpdateEvent : public QEvent
{
public:
- CursorUpdateEvent(const QPoint &pos, const QRegion &rgn)
+ CursorUpdateEvent(const QPoint &pos, const QRect &rect, bool allScreens)
: QEvent(QEvent::Type(QEvent::User + 1)),
m_pos(pos),
- m_region(rgn)
+ m_rect(rect),
+ m_allScreens(allScreens)
{ }
QPoint pos() const { return m_pos; }
- QRegion region() const { return m_region; }
+ QRegion rect() const { return m_rect; }
+ bool allScreens() const { return m_allScreens; }
private:
QPoint m_pos;
- QRegion m_region;
+ QRect m_rect;
+ bool m_allScreens;
};
bool QEglFSCursor::event(QEvent *e)
@@ -269,21 +278,30 @@ bool QEglFSCursor::event(QEvent *e)
if (e->type() == QEvent::User + 1) {
CursorUpdateEvent *ev = static_cast<CursorUpdateEvent *>(e);
m_updateRequested = false;
- QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(ev->pos()), ev->region());
- QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+ if (!ev->allScreens()) {
+ QWindow *w = m_screen->topLevelAt(ev->pos()); // works for the entire virtual desktop, no need to loop
+ if (w) {
+ QWindowSystemInterface::handleExposeEvent(w, ev->rect());
+ QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+ }
+ } else {
+ for (QWindow *w : qGuiApp->topLevelWindows())
+ QWindowSystemInterface::handleExposeEvent(w, w->geometry());
+ QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+ }
return true;
}
return QPlatformCursor::event(e);
}
-void QEglFSCursor::update(const QRegion &rgn)
+void QEglFSCursor::update(const QRect &rect, bool allScreens)
{
if (!m_updateRequested) {
// Must not flush the window system events directly from here since we are likely to
// be a called directly from QGuiApplication's processMouseEvents. Flushing events
// could cause reentering by dispatching more queued mouse events.
m_updateRequested = true;
- QCoreApplication::postEvent(this, new CursorUpdateEvent(m_cursor.pos, rgn));
+ QCoreApplication::postEvent(this, new CursorUpdateEvent(m_cursor.pos, rect, allScreens));
}
}
@@ -302,8 +320,9 @@ void QEglFSCursor::setPos(const QPoint &pos)
QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos);
const QRect oldCursorRect = cursorRect();
m_cursor.pos = pos;
- update(oldCursorRect | cursorRect());
- m_screen->handleCursorMove(m_cursor.pos);
+ update(oldCursorRect | cursorRect(), false);
+ for (QPlatformScreen *screen : m_screen->virtualSiblings())
+ static_cast<QEglFSScreen *>(screen)->handleCursorMove(m_cursor.pos);
}
void QEglFSCursor::pointerEvent(const QMouseEvent &event)
@@ -312,8 +331,9 @@ void QEglFSCursor::pointerEvent(const QMouseEvent &event)
return;
const QRect oldCursorRect = cursorRect();
m_cursor.pos = event.screenPos().toPoint();
- update(oldCursorRect | cursorRect());
- m_screen->handleCursorMove(m_cursor.pos);
+ update(oldCursorRect | cursorRect(), false);
+ for (QPlatformScreen *screen : m_screen->virtualSiblings())
+ static_cast<QEglFSScreen *>(screen)->handleCursorMove(m_cursor.pos);
}
void QEglFSCursor::paintOnScreen()
@@ -321,15 +341,37 @@ void QEglFSCursor::paintOnScreen()
if (!m_visible)
return;
- const QRectF cr = cursorRect();
- const QRect screenRect(m_screen->geometry());
- const GLfloat x1 = 2 * (cr.left() / screenRect.width()) - 1;
- const GLfloat x2 = 2 * (cr.right() / screenRect.width()) - 1;
- const GLfloat y1 = 1 - (cr.top() / screenRect.height()) * 2;
- const GLfloat y2 = 1 - (cr.bottom() / screenRect.height()) * 2;
- QRectF r(QPointF(x1, y1), QPointF(x2, y2));
+ // cr must be a QRectF, otherwise cr.right() and bottom() would be off by
+ // one in the calculations below.
+ QRectF cr = cursorRect(); // hotspot included
+
+ // Support virtual desktop too. Backends with multi-screen support (e.g. all
+ // variants of KMS/DRM) will enable this by default. In this case all
+ // screens are siblings of each other. When not enabled, the sibling list
+ // only contains m_screen itself.
+ for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+ if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+ && QOpenGLContext::currentContext()->screen() == screen->screen())
+ {
+ cr.translate(-screen->geometry().topLeft());
+ const QSize screenSize = screen->geometry().size();
+ const GLfloat x1 = 2 * (cr.left() / GLfloat(screenSize.width())) - 1;
+ const GLfloat x2 = 2 * (cr.right() / GLfloat(screenSize.width())) - 1;
+ const GLfloat y1 = 1 - (cr.top() / GLfloat(screenSize.height())) * 2;
+ const GLfloat y2 = 1 - (cr.bottom() / GLfloat(screenSize.height())) * 2;
+ QRectF r(QPointF(x1, y1), QPointF(x2, y2));
+
+ draw(r);
+
+ if (screen != m_activeScreen) {
+ m_activeScreen = screen;
+ // Do not want a leftover cursor on the screen the cursor just left.
+ update(cursorRect(), true);
+ }
- draw(r);
+ break;
+ }
+ }
}
// In order to prevent breaking code doing custom OpenGL rendering while
@@ -431,30 +473,33 @@ void QEglFSCursor::draw(const QRectF &r)
{
StateSaver stateSaver;
- if (!m_program) {
+ GraphicsContextData &gfx(m_gfx[QOpenGLContext::currentContext()]);
+ if (!gfx.program) {
// one time initialization
initializeOpenGLFunctions();
createShaderPrograms();
- if (!m_cursorAtlas.texture) {
- createCursorTexture(&m_cursorAtlas.texture, m_cursorAtlas.image);
+ if (!gfx.atlasTexture) {
+ createCursorTexture(&gfx.atlasTexture, m_cursorAtlas.image);
if (m_cursor.shape != Qt::BitmapCursor)
- m_cursor.texture = m_cursorAtlas.texture;
+ m_cursor.useCustomCursor = false;
}
}
- if (m_cursor.shape == Qt::BitmapCursor && m_cursor.customCursorPending) {
+ if (m_cursor.shape == Qt::BitmapCursor && (m_cursor.customCursorPending || m_cursor.customCursorKey != gfx.customCursorKey)) {
// upload the custom cursor
- createCursorTexture(&m_cursor.customCursorTexture, m_cursor.customCursorImage);
- m_cursor.texture = m_cursor.customCursorTexture;
+ createCursorTexture(&gfx.customCursorTexture, m_cursor.customCursorImage);
+ m_cursor.useCustomCursor = true;
m_cursor.customCursorPending = false;
+ gfx.customCursorKey = m_cursor.customCursorKey;
}
- Q_ASSERT(m_cursor.texture);
+ GLuint cursorTexture = !m_cursor.useCustomCursor ? gfx.atlasTexture : gfx.customCursorTexture;
+ Q_ASSERT(cursorTexture);
- m_program->bind();
+ gfx.program->bind();
const GLfloat x1 = r.left();
const GLfloat x2 = r.right();
@@ -479,19 +524,20 @@ void QEglFSCursor::draw(const QRectF &r)
};
glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, m_cursor.texture);
+ glBindTexture(GL_TEXTURE_2D, cursorTexture);
if (stateSaver.vaoHelper->isValid())
stateSaver.vaoHelper->glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- m_program->enableAttributeArray(0);
- m_program->enableAttributeArray(1);
- m_program->setAttributeArray(0, cursorCoordinates, 2);
- m_program->setAttributeArray(1, textureCoordinates, 2);
+ gfx.program->enableAttributeArray(0);
+ gfx.program->enableAttributeArray(1);
+ gfx.program->setAttributeArray(0, cursorCoordinates, 2);
+ gfx.program->setAttributeArray(1, textureCoordinates, 2);
- m_program->setUniformValue(m_textureEntry, 0);
+ gfx.program->setUniformValue(gfx.textureEntry, 0);
+ gfx.program->setUniformValue(gfx.matEntry, m_rotationMatrix);
glDisable(GL_CULL_FACE);
glFrontFace(GL_CCW);
@@ -501,9 +547,9 @@ void QEglFSCursor::draw(const QRectF &r)
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- m_program->disableAttributeArray(0);
- m_program->disableAttributeArray(1);
- m_program->release();
+ gfx.program->disableAttributeArray(0);
+ gfx.program->disableAttributeArray(1);
+ gfx.program->release();
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.h b/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
index bb30d53d6c..bf6dbc8a21 100644
--- a/src/plugins/platforms/eglfs/qeglfscursor.h
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
@@ -51,9 +51,10 @@
// We mean it.
//
-#include "qeglfsglobal.h"
+#include "qeglfsglobal_p.h"
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformscreen.h>
+#include <QtGui/QMatrix4x4>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/private/qinputdevicemanager_p.h>
@@ -104,30 +105,29 @@ private:
bool setCurrentCursor(QCursor *cursor);
#endif
void draw(const QRectF &rect);
- void update(const QRegion &region);
+ void update(const QRect &rect, bool allScreens);
void createShaderPrograms();
void createCursorTexture(uint *texture, const QImage &image);
void initCursorAtlas();
// current cursor information
struct Cursor {
- Cursor() : texture(0), shape(Qt::BlankCursor), customCursorTexture(0), customCursorPending(false) { }
- uint texture; // a texture from 'image' or the atlas
+ Cursor() : shape(Qt::BlankCursor), customCursorPending(false), customCursorKey(0), useCustomCursor(false) { }
Qt::CursorShape shape;
QRectF textureRect; // normalized rect inside texture
QSize size; // size of the cursor
QPoint hotSpot;
QImage customCursorImage;
QPoint pos; // current cursor position
- uint customCursorTexture;
bool customCursorPending;
+ qint64 customCursorKey;
+ bool useCustomCursor;
} m_cursor;
// cursor atlas information
struct CursorAtlas {
- CursorAtlas() : cursorsPerRow(0), texture(0), cursorWidth(0), cursorHeight(0) { }
+ CursorAtlas() : cursorsPerRow(0), cursorWidth(0), cursorHeight(0) { }
int cursorsPerRow;
- uint texture;
int width, height; // width and height of the atlas
int cursorWidth, cursorHeight; // width and height of cursors inside the atlas
QList<QPoint> hotSpots;
@@ -136,10 +136,22 @@ private:
bool m_visible;
QEglFSScreen *m_screen;
- QOpenGLShaderProgram *m_program;
- int m_textureEntry;
+ QPlatformScreen *m_activeScreen;
QEglFSCursorDeviceListener *m_deviceListener;
bool m_updateRequested;
+ QMatrix4x4 m_rotationMatrix;
+
+ struct GraphicsContextData {
+ GraphicsContextData() : program(nullptr), textureEntry(0), matEntry(0),
+ customCursorTexture(0), atlasTexture(0), customCursorKey(0) { }
+ QOpenGLShaderProgram *program;
+ int textureEntry;
+ int matEntry;
+ uint customCursorTexture;
+ uint atlasTexture;
+ qint64 customCursorKey;
+ };
+ QHash<QOpenGLContext *, GraphicsContextData> m_gfx;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index fc41dc5643..3e1e93f1e4 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -37,11 +37,14 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
-#include "qeglfsintegration.h"
-#include "qeglfscursor.h"
-#include "qeglfswindow.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include "qeglfsdeviceintegration_p.h"
+#include "qeglfsintegration_p.h"
+#include "qeglfscursor_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfsscreen_p.h"
+#include "qeglfshooks_p.h"
+
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <QGuiApplication>
#include <private/qguiapplication_p.h>
#include <QScreen>
@@ -64,14 +67,15 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration")
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))
+ (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
- (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+ (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+
#endif // QT_NO_LIBRARY
-QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
+QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath)
{
QStringList list;
#ifndef QT_NO_LIBRARY
@@ -95,19 +99,19 @@ QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
return list;
}
-QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)
+QEglFSDeviceIntegration *QEglFSDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)
{
- QEGLDeviceIntegration *integration = Q_NULLPTR;
+ QEglFSDeviceIntegration *integration = Q_NULLPTR;
#ifndef QT_NO_LIBRARY
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
- integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(directLoader(), key);
+ integration = qLoadPlugin<QEglFSDeviceIntegration, QEglFSDeviceIntegrationPlugin>(directLoader(), key);
}
#else
Q_UNUSED(pluginPath);
#endif
if (!integration)
- integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(loader(), key);
+ integration = qLoadPlugin<QEglFSDeviceIntegration, QEglFSDeviceIntegrationPlugin>(loader(), key);
if (integration)
qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
else
@@ -118,7 +122,7 @@ QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key,
static int framebuffer = -1;
-QByteArray QEGLDeviceIntegration::fbDeviceName() const
+QByteArray QEglFSDeviceIntegration::fbDeviceName() const
{
#ifdef Q_OS_LINUX
QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB");
@@ -131,7 +135,7 @@ QByteArray QEGLDeviceIntegration::fbDeviceName() const
#endif
}
-int QEGLDeviceIntegration::framebufferIndex() const
+int QEglFSDeviceIntegration::framebufferIndex() const
{
int fbIndex = 0;
#ifndef QT_NO_REGULAREXPRESSION
@@ -143,7 +147,7 @@ int QEGLDeviceIntegration::framebufferIndex() const
return fbIndex;
}
-void QEGLDeviceIntegration::platformInit()
+void QEglFSDeviceIntegration::platformInit()
{
#ifdef Q_OS_LINUX
QByteArray fbDev = fbDeviceName();
@@ -161,7 +165,7 @@ void QEGLDeviceIntegration::platformInit()
#endif
}
-void QEGLDeviceIntegration::platformDestroy()
+void QEglFSDeviceIntegration::platformDestroy()
{
#ifdef Q_OS_LINUX
if (framebuffer != -1)
@@ -169,46 +173,46 @@ void QEGLDeviceIntegration::platformDestroy()
#endif
}
-EGLNativeDisplayType QEGLDeviceIntegration::platformDisplay() const
+EGLNativeDisplayType QEglFSDeviceIntegration::platformDisplay() const
{
return EGL_DEFAULT_DISPLAY;
}
-EGLDisplay QEGLDeviceIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
+EGLDisplay QEglFSDeviceIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
{
return eglGetDisplay(nativeDisplay);
}
-bool QEGLDeviceIntegration::usesDefaultScreen()
+bool QEglFSDeviceIntegration::usesDefaultScreen()
{
return true;
}
-void QEGLDeviceIntegration::screenInit()
+void QEglFSDeviceIntegration::screenInit()
{
// Nothing to do here. Called only when usesDefaultScreen is false.
}
-void QEGLDeviceIntegration::screenDestroy()
+void QEglFSDeviceIntegration::screenDestroy()
{
QGuiApplication *app = qGuiApp;
QEglFSIntegration *platformIntegration = static_cast<QEglFSIntegration *>(
QGuiApplicationPrivate::platformIntegration());
while (!app->screens().isEmpty())
- platformIntegration->removeScreen(app->screens().last()->handle());
+ platformIntegration->removeScreen(app->screens().constLast()->handle());
}
-QSizeF QEGLDeviceIntegration::physicalScreenSize() const
+QSizeF QEglFSDeviceIntegration::physicalScreenSize() const
{
return q_physicalScreenSizeFromFb(framebuffer, screenSize());
}
-QSize QEGLDeviceIntegration::screenSize() const
+QSize QEglFSDeviceIntegration::screenSize() const
{
return q_screenSizeFromFb(framebuffer);
}
-QDpi QEGLDeviceIntegration::logicalDpi() const
+QDpi QEglFSDeviceIntegration::logicalDpi() const
{
const QSizeF ps = physicalScreenSize();
const QSize s = screenSize();
@@ -220,42 +224,42 @@ QDpi QEGLDeviceIntegration::logicalDpi() const
return QDpi(100, 100);
}
-qreal QEGLDeviceIntegration::pixelDensity() const
+qreal QEglFSDeviceIntegration::pixelDensity() const
{
return qRound(logicalDpi().first / qreal(100));
}
-Qt::ScreenOrientation QEGLDeviceIntegration::nativeOrientation() const
+Qt::ScreenOrientation QEglFSDeviceIntegration::nativeOrientation() const
{
return Qt::PrimaryOrientation;
}
-Qt::ScreenOrientation QEGLDeviceIntegration::orientation() const
+Qt::ScreenOrientation QEglFSDeviceIntegration::orientation() const
{
return Qt::PrimaryOrientation;
}
-int QEGLDeviceIntegration::screenDepth() const
+int QEglFSDeviceIntegration::screenDepth() const
{
return q_screenDepthFromFb(framebuffer);
}
-QImage::Format QEGLDeviceIntegration::screenFormat() const
+QImage::Format QEglFSDeviceIntegration::screenFormat() const
{
return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
}
-qreal QEGLDeviceIntegration::refreshRate() const
+qreal QEglFSDeviceIntegration::refreshRate() const
{
return q_refreshRateFromFb(framebuffer);
}
-EGLint QEGLDeviceIntegration::surfaceType() const
+EGLint QEglFSDeviceIntegration::surfaceType() const
{
return EGL_WINDOW_BIT;
}
-QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
+QSurfaceFormat QEglFSDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
QSurfaceFormat format = inputFormat;
@@ -269,17 +273,17 @@ QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inp
return format;
}
-bool QEGLDeviceIntegration::filterConfig(EGLDisplay, EGLConfig) const
+bool QEglFSDeviceIntegration::filterConfig(EGLDisplay, EGLConfig) const
{
return true;
}
-QEglFSWindow *QEGLDeviceIntegration::createWindow(QWindow *window) const
+QEglFSWindow *QEglFSDeviceIntegration::createWindow(QWindow *window) const
{
return new QEglFSWindow(window);
}
-EGLNativeWindowType QEGLDeviceIntegration::createNativeWindow(QPlatformWindow *platformWindow,
+EGLNativeWindowType QEglFSDeviceIntegration::createNativeWindow(QPlatformWindow *platformWindow,
const QSize &size,
const QSurfaceFormat &format)
{
@@ -289,29 +293,29 @@ EGLNativeWindowType QEGLDeviceIntegration::createNativeWindow(QPlatformWindow *p
return 0;
}
-EGLNativeWindowType QEGLDeviceIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)
+EGLNativeWindowType QEglFSDeviceIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)
{
Q_UNUSED(format);
return 0;
}
-void QEGLDeviceIntegration::destroyNativeWindow(EGLNativeWindowType window)
+void QEglFSDeviceIntegration::destroyNativeWindow(EGLNativeWindowType window)
{
Q_UNUSED(window);
}
-bool QEGLDeviceIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+bool QEglFSDeviceIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
Q_UNUSED(cap);
return false;
}
-QPlatformCursor *QEGLDeviceIntegration::createCursor(QPlatformScreen *screen) const
+QPlatformCursor *QEglFSDeviceIntegration::createCursor(QPlatformScreen *screen) const
{
- return new QEglFSCursor(screen);
+ return new QEglFSCursor(static_cast<QEglFSScreen *>(screen));
}
-void QEGLDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
+void QEglFSDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
{
Q_UNUSED(surface);
@@ -325,24 +329,42 @@ void QEGLDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
#endif
}
-void QEGLDeviceIntegration::presentBuffer(QPlatformSurface *surface)
+void QEglFSDeviceIntegration::presentBuffer(QPlatformSurface *surface)
{
Q_UNUSED(surface);
}
-bool QEGLDeviceIntegration::supportsPBuffers() const
+bool QEglFSDeviceIntegration::supportsPBuffers() const
{
return true;
}
-bool QEGLDeviceIntegration::supportsSurfacelessContexts() const
+bool QEglFSDeviceIntegration::supportsSurfacelessContexts() const
{
return true;
}
-void *QEGLDeviceIntegration::wlDisplay() const
+void *QEglFSDeviceIntegration::wlDisplay() const
{
return Q_NULLPTR;
}
+EGLConfig QEglFSDeviceIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
+{
+ class Chooser : public QEglConfigChooser {
+ public:
+ Chooser(EGLDisplay display)
+ : QEglConfigChooser(display) { }
+ bool filterConfig(EGLConfig config) const Q_DECL_OVERRIDE {
+ return qt_egl_device_integration()->filterConfig(display(), config)
+ && QEglConfigChooser::filterConfig(config);
+ }
+ };
+
+ Chooser chooser(display);
+ chooser.setSurfaceType(qt_egl_device_integration()->surfaceType());
+ chooser.setSurfaceFormat(format);
+ return chooser.chooseConfig();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
index f1a5bde331..4335554912 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "qeglfsglobal.h"
+#include "qeglfsglobal_p.h"
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
#include <QtCore/QString>
@@ -63,12 +63,12 @@ QT_BEGIN_NAMESPACE
class QPlatformSurface;
class QEglFSWindow;
-#define QEGLDeviceIntegrationFactoryInterface_iid "org.qt-project.qt.qpa.egl.QEGLDeviceIntegrationFactoryInterface.5.5"
+#define QEglFSDeviceIntegrationFactoryInterface_iid "org.qt-project.qt.qpa.egl.QEglFSDeviceIntegrationFactoryInterface.5.5"
-class Q_EGLFS_EXPORT QEGLDeviceIntegration
+class Q_EGLFS_EXPORT QEglFSDeviceIntegration
{
public:
- virtual ~QEGLDeviceIntegration() { }
+ virtual ~QEglFSDeviceIntegration() { }
virtual void platformInit();
virtual void platformDestroy();
@@ -105,25 +105,27 @@ public:
virtual bool supportsSurfacelessContexts() const;
virtual void *wlDisplay() const;
+
+ static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
};
-class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject
+class Q_EGLFS_EXPORT QEglFSDeviceIntegrationPlugin : public QObject
{
Q_OBJECT
public:
- virtual QEGLDeviceIntegration *create() = 0;
+ virtual QEglFSDeviceIntegration *create() = 0;
// the pattern expected by qLoadPlugin calls for a QString argument.
// we don't need it, so don't bother subclasses with it:
- QEGLDeviceIntegration *create(const QString &) { return create(); }
+ QEglFSDeviceIntegration *create(const QString &) { return create(); }
};
-class Q_EGLFS_EXPORT QEGLDeviceIntegrationFactory
+class Q_EGLFS_EXPORT QEglFSDeviceIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
- static QEGLDeviceIntegration *create(const QString &name, const QString &platformPluginPath = QString());
+ static QEglFSDeviceIntegration *create(const QString &name, const QString &platformPluginPath = QString());
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsglobal.h b/src/plugins/platforms/eglfs/api/qeglfsglobal_p.h
index 309655e86c..8d76ff5ee0 100644
--- a/src/plugins/platforms/eglfs/qeglfsglobal.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsglobal_p.h
@@ -40,7 +40,22 @@
#ifndef QEGLFSGLOBAL_H
#define QEGLFSGLOBAL_H
-#include <qglobal.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+#include <QtEglSupport/private/qt_egl_p.h>
+
+QT_BEGIN_NAMESPACE
#ifdef QT_BUILD_EGL_DEVICE_LIB
#define Q_EGLFS_EXPORT Q_DECL_EXPORT
@@ -48,7 +63,6 @@
#define Q_EGLFS_EXPORT Q_DECL_IMPORT
#endif
-#include <QtPlatformSupport/private/qt_egl_p.h>
#undef Status
#undef None
#undef Bool
@@ -61,4 +75,6 @@
#undef Expose
#undef Unsorted
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.cpp b/src/plugins/platforms/eglfs/api/qeglfshooks.cpp
index 7345cfd1f1..d8332a94cb 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfshooks.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qeglfshooks.h"
+#include "qeglfshooks_p.h"
#include <QLoggingCategory>
QT_BEGIN_NAMESPACE
@@ -46,7 +46,7 @@ Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug)
#ifdef EGLFS_PLATFORM_HOOKS
-QEGLDeviceIntegration *qt_egl_device_integration()
+QEglFSDeviceIntegration *qt_egl_device_integration()
{
extern QEglFSHooks *platformHooks;
return platformHooks;
@@ -59,9 +59,9 @@ class DeviceIntegration
public:
DeviceIntegration();
~DeviceIntegration() { delete m_integration; }
- QEGLDeviceIntegration *integration() { return m_integration; }
+ QEglFSDeviceIntegration *integration() { return m_integration; }
private:
- QEGLDeviceIntegration *m_integration;
+ QEglFSDeviceIntegration *m_integration;
};
Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
@@ -69,7 +69,7 @@ Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
DeviceIntegration::DeviceIntegration()
: m_integration(nullptr)
{
- QStringList pluginKeys = QEGLDeviceIntegrationFactory::keys();
+ QStringList pluginKeys = QEglFSDeviceIntegrationFactory::keys();
if (!pluginKeys.isEmpty()) {
// Some built-in logic: Prioritize either X11 or KMS/DRM.
if (qEnvironmentVariableIsSet("DISPLAY")) {
@@ -114,7 +114,7 @@ DeviceIntegration::DeviceIntegration()
while (!m_integration && !pluginKeys.isEmpty()) {
QString key = pluginKeys.takeFirst();
qCDebug(qLcEglDevDebug) << "Trying to load device EGL integration" << key;
- m_integration = QEGLDeviceIntegrationFactory::create(key);
+ m_integration = QEglFSDeviceIntegrationFactory::create(key);
}
}
}
@@ -123,11 +123,11 @@ DeviceIntegration::DeviceIntegration()
// Use a default, non-specialized device integration when no plugin is available.
// For some systems this is sufficient.
qCDebug(qLcEglDevDebug) << "Using base device integration";
- m_integration = new QEGLDeviceIntegration;
+ m_integration = new QEglFSDeviceIntegration;
}
}
-QEGLDeviceIntegration *qt_egl_device_integration()
+QEglFSDeviceIntegration *qt_egl_device_integration()
{
return deviceIntegration()->integration();
}
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/api/qeglfshooks_p.h
index cc6c325b58..4c3149c7c9 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.h
+++ b/src/plugins/platforms/eglfs/api/qeglfshooks_p.h
@@ -40,16 +40,27 @@
#ifndef QEGLFSHOOKS_H
#define QEGLFSHOOKS_H
-#include "qeglfsglobal.h"
-#include "qeglfsdeviceintegration.h"
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include "qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSHooks : public QEGLDeviceIntegration
+class QEglFSHooks : public QEglFSDeviceIntegration
{
};
-Q_EGLFS_EXPORT QEGLDeviceIntegration *qt_egl_device_integration();
+Q_EGLFS_EXPORT QEglFSDeviceIntegration *qt_egl_device_integration();
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
index a4263c490e..7c88c73cc2 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
@@ -49,39 +49,39 @@
#include <QtCore/QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatforminputcontextfactory_p.h>
-#include <private/qgenericunixthemes_p.h>
-#include "qeglfsintegration.h"
-#include "qeglfswindow.h"
-#include "qeglfshooks.h"
-#include "qeglfscontext.h"
-#include "qeglfsoffscreenwindow.h"
-#include "qeglfscursor.h"
+#include "qeglfsintegration_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
+#include "qeglfscontext_p.h"
+#include "qeglfsoffscreenwindow_p.h"
+#include "qeglfscursor_p.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglplatformcontext_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qfbvthandler_p.h>
-#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#include <QtThemeSupport/private/qgenericunixthemes_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFbSupport/private/qfbvthandler_p.h>
+#include <QtPlatformCompositorSupport/private/qopenglcompositorbackingstore_p.h>
#include <QtPlatformHeaders/QEGLNativeContext>
-#ifndef QT_NO_LIBINPUT
-#include <QtPlatformSupport/private/qlibinputhandler_p.h>
+#if QT_CONFIG(libinput)
+#include <QtInputSupport/private/qlibinputhandler_p.h>
#endif
-#if !defined(QT_NO_EVDEV) && !defined(Q_OS_ANDROID)
-#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
-#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
-#include <QtPlatformSupport/private/qevdevtouchmanager_p.h>
+#if QT_CONFIG(evdev)
+#include <QtInputSupport/private/qevdevmousemanager_p.h>
+#include <QtInputSupport/private/qevdevkeyboardmanager_p.h>
+#include <QtInputSupport/private/qevdevtouchmanager_p.h>
#endif
-#if !defined(QT_NO_TSLIB) && !defined(Q_OS_ANDROID)
-#include <QtPlatformSupport/private/qtslib_p.h>
+#if QT_CONFIG(tslib)
+#include <QtInputSupport/private/qtslib_p.h>
#endif
#include <QtPlatformHeaders/qeglfsfunctions.h>
@@ -205,7 +205,7 @@ QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLCo
QEglFSContext *ctx;
QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format());
if (nativeHandle.isNull()) {
- EGLConfig config = QEglFSIntegration::chooseConfig(dpy, adjustedFormat);
+ EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant());
} else {
ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle);
@@ -386,7 +386,7 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::na
QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function) const
{
-#if !defined(QT_NO_EVDEV) && !defined(Q_OS_ANDROID)
+#if QT_CONFIG(evdev)
if (function == QEglFSFunctions::loadKeymapTypeIdentifier())
return QFunctionPointer(loadKeymapStatic);
#else
@@ -398,7 +398,7 @@ QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function)
void QEglFSIntegration::loadKeymapStatic(const QString &filename)
{
-#if !defined(QT_NO_EVDEV) && !defined(Q_OS_ANDROID)
+#if QT_CONFIG(evdev)
QEglFSIntegration *self = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
if (self->m_kbdMgr)
self->m_kbdMgr->loadKeymap(filename);
@@ -411,7 +411,7 @@ void QEglFSIntegration::loadKeymapStatic(const QString &filename)
void QEglFSIntegration::createInputHandlers()
{
-#ifndef QT_NO_LIBINPUT
+#if QT_CONFIG(libinput)
if (!qEnvironmentVariableIntValue("QT_QPA_EGLFS_NO_LIBINPUT")) {
new QLibInputHandler(QLatin1String("libinput"), QString());
return;
@@ -419,13 +419,13 @@ void QEglFSIntegration::createInputHandlers()
#endif
bool useTslib = false;
-#ifndef QT_NO_TSLIB
+#if QT_CONFIG(tslib)
useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB");
if (useTslib)
new QTsLibMouseHandler(QLatin1String("TsLib"), QString() /* spec */);
#endif
-#if !defined(QT_NO_EVDEV) && !defined(Q_OS_ANDROID)
+#if QT_CONFIG(evdev)
m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
if (!useTslib)
@@ -438,22 +438,4 @@ EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
return qt_egl_device_integration()->platformDisplay();
}
-EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
-{
- class Chooser : public QEglConfigChooser {
- public:
- Chooser(EGLDisplay display)
- : QEglConfigChooser(display) { }
- bool filterConfig(EGLConfig config) const Q_DECL_OVERRIDE {
- return qt_egl_device_integration()->filterConfig(display(), config)
- && QEglConfigChooser::filterConfig(config);
- }
- };
-
- Chooser chooser(display);
- chooser.setSurfaceType(qt_egl_device_integration()->surfaceType());
- chooser.setSurfaceFormat(format);
- return chooser.chooseConfig();
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
index 678452a8db..1a3a44d441 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
@@ -40,7 +40,18 @@
#ifndef QEGLFSINTEGRATION_H
#define QEGLFSINTEGRATION_H
-#include "qeglfsglobal.h"
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
#include <QtCore/QVariant>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
@@ -92,8 +103,6 @@ public:
void addScreen(QPlatformScreen *screen);
void removeScreen(QPlatformScreen *screen);
- static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
-
private:
EGLNativeDisplayType nativeDisplay() const;
void createInputHandlers();
diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp
index 11b101970b..864271cd3a 100644
--- a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp
@@ -37,10 +37,10 @@
**
****************************************************************************/
-#include "qeglfsoffscreenwindow.h"
-#include "qeglfshooks.h"
+#include "qeglfsoffscreenwindow_p.h"
+#include "qeglfshooks_p.h"
#include <QtGui/QOffscreenSurface>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow_p.h
index 673fa0d729..ec483c64e2 100644
--- a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow_p.h
@@ -40,7 +40,18 @@
#ifndef QEGLFSOFFSCREENWINDOW_H
#define QEGLFSOFFSCREENWINDOW_H
-#include "qeglfsglobal.h"
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
#include <qpa/qplatformoffscreensurface.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index a1ab854db1..5613179041 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -41,11 +41,11 @@
#include <QtGui/qwindow.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformcursor.h>
-#include <QtPlatformSupport/private/qopenglcompositor_p.h>
+#include <QtPlatformCompositorSupport/private/qopenglcompositor_p.h>
-#include "qeglfsscreen.h"
-#include "qeglfswindow.h"
-#include "qeglfshooks.h"
+#include "qeglfsscreen_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
QT_BEGIN_NAMESPACE
@@ -65,6 +65,31 @@ QEglFSScreen::~QEglFSScreen()
QRect QEglFSScreen::geometry() const
{
+ QRect r = rawGeometry();
+
+ static int rotation = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION");
+ switch (rotation) {
+ case 0:
+ case 180:
+ case -180:
+ break;
+ case 90:
+ case -90: {
+ int h = r.height();
+ r.setHeight(r.width());
+ r.setWidth(h);
+ break;
+ }
+ default:
+ qWarning("Invalid rotation %d specified in QT_QPA_EGLFS_ROTATION", rotation);
+ break;
+ }
+
+ return r;
+}
+
+QRect QEglFSScreen::rawGeometry() const
+{
return QRect(QPoint(0, 0), qt_egl_device_integration()->screenSize());
}
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
index 57d68ca572..131e619e06 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
@@ -40,9 +40,22 @@
#ifndef QEGLFSSCREEN_H
#define QEGLFSSCREEN_H
-#include "qeglfsglobal.h"
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
#include <QtCore/QPointer>
+#include <qpa/qplatformscreen.h>
+
QT_BEGIN_NAMESPACE
class QEglFSWindow;
@@ -55,6 +68,7 @@ public:
~QEglFSScreen();
QRect geometry() const Q_DECL_OVERRIDE;
+ virtual QRect rawGeometry() const;
int depth() const Q_DECL_OVERRIDE;
QImage::Format format() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index 556d3942cd..e79b377d40 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -43,12 +43,13 @@
#include <private/qguiapplication_p.h>
#include <QtGui/private/qopenglcontext_p.h>
#include <QtGui/QOpenGLContext>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include <QtPlatformCompositorSupport/private/qopenglcompositorbackingstore_p.h>
-#include "qeglfswindow.h"
-#include "qeglfscursor.h"
-#include "qeglfshooks.h"
+#include "qeglfswindow_p.h"
+#include "qeglfscursor_p.h"
+#include "qeglfshooks_p.h"
+#include "qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
@@ -141,7 +142,8 @@ void QEglFSWindow::create()
context->setScreen(window()->screen());
if (Q_UNLIKELY(!context->create()))
qFatal("EGLFS: Failed to create compositing context");
- compositor->setTarget(context, window());
+ compositor->setTarget(context, window(), screen->rawGeometry());
+ compositor->setRotation(qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION"));
// If there is a "root" window into which raster and QOpenGLWidget content is
// composited, all other contexts must share with its context.
if (!qt_gl_global_share_context()) {
@@ -186,9 +188,10 @@ void QEglFSWindow::resetSurface()
EGLDisplay display = screen()->display();
QSurfaceFormat platformFormat = qt_egl_device_integration()->surfaceFormatFor(window()->requestedFormat());
- m_config = QEglFSIntegration::chooseConfig(display, platformFormat);
+ m_config = QEglFSDeviceIntegration::chooseConfig(display, platformFormat);
m_format = q_glFormatFromConfig(display, m_config, platformFormat);
- m_window = qt_egl_device_integration()->createNativeWindow(this, screen()->geometry().size(), m_format);
+ const QSize surfaceSize = screen()->rawGeometry().size();
+ m_window = qt_egl_device_integration()->createNativeWindow(this, surfaceSize, m_format);
m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
}
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index d607c8bd62..0889f27ae3 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -40,12 +40,23 @@
#ifndef QEGLFSWINDOW_H
#define QEGLFSWINDOW_H
-#include "qeglfsglobal.h"
-#include "qeglfsintegration.h"
-#include "qeglfsscreen.h"
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include "qeglfsintegration_p.h"
+#include "qeglfsscreen_p.h"
#include <qpa/qplatformwindow.h>
-#include <QtPlatformSupport/private/qopenglcompositor_p.h>
+#include <QtPlatformCompositorSupport/private/qopenglcompositor_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro
index 769c248d0d..d86a67b4f4 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro
@@ -1,12 +1,13 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += gui-private
-contains(QT_CONFIG, egl_x11): SUBDIRS += eglfs_x11
-contains(QT_CONFIG, eglfs_gbm): SUBDIRS += eglfs_kms_support eglfs_kms
-contains(QT_CONFIG, eglfs_egldevice): SUBDIRS += eglfs_kms_support eglfs_kms_egldevice
-contains(QT_CONFIG, eglfs_brcm): SUBDIRS += eglfs_brcm
-contains(QT_CONFIG, eglfs_mali): SUBDIRS += eglfs_mali
-contains(QT_CONFIG, eglfs_viv): SUBDIRS += eglfs_viv
-contains(QT_CONFIG, eglfs_viv_wl): SUBDIRS += eglfs_viv_wl
+qtConfig(egl_x11): SUBDIRS += eglfs_x11
+qtConfig(eglfs_gbm): SUBDIRS += eglfs_kms_support eglfs_kms
+qtConfig(eglfs_egldevice): SUBDIRS += eglfs_kms_support eglfs_kms_egldevice
+qtConfig(eglfs_brcm): SUBDIRS += eglfs_brcm
+qtConfig(eglfs_mali): SUBDIRS += eglfs_mali
+qtConfig(eglfs_viv): SUBDIRS += eglfs_viv
+qtConfig(eglfs_viv_wl): SUBDIRS += eglfs_viv_wl
eglfs_kms_egldevice.depends = eglfs_kms_support
eglfs_kms.depends = eglfs_kms_support
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro
index 2b710ac24c..fee67da2de 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro
@@ -1,8 +1,8 @@
TARGET = qeglfs-brcm-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private eglfsdeviceintegration-private
-INCLUDEPATH += $$PWD/../..
+INCLUDEPATH += $$PWD/../../api
CONFIG += egl
LIBS += -lbcm_host
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h
index 8f78b51190..5af628dedd 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h
@@ -40,11 +40,11 @@
#ifndef QEGLFSBRCMINTEGRATION_H
#define QEGLFSBRCMINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSBrcmIntegration : public QEGLDeviceIntegration
+class QEglFSBrcmIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp
index 0bd54ba239..80d7631931 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsbrcmintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSBrcmIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSBrcmIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_brcm.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_brcm.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSBrcmIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSBrcmIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
index b1791240ab..255db824b7 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
@@ -4,20 +4,14 @@ PLUGIN_TYPE = egldeviceintegrations
PLUGIN_CLASS_NAME = QEglFSKmsGbmIntegrationPlugin
load(qt_plugin)
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private eglfs_kms_support-private
+QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private
-INCLUDEPATH += $$PWD/../.. $$PWD/../eglfs_kms_support
+INCLUDEPATH += $$PWD/../../api $$PWD/../eglfs_kms_support
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
-CONFIG += link_pkgconfig
-!contains(QT_CONFIG, no-pkg-config) {
- PKGCONFIG += libdrm gbm
-} else {
- LIBS += -ldrm -lgbm
-}
-
+QMAKE_USE += gbm drm
CONFIG += egl
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
index 278752bddf..3a220ec942 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
@@ -42,7 +42,7 @@
#include "qeglfskmsgbmdevice.h"
#include "qeglfskmsgbmscreen.h"
-#include "qeglfsintegration.h"
+#include "qeglfsintegration_p.h"
#include <QtCore/QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
@@ -142,10 +142,10 @@ void QEglFSKmsGbmDevice::handleDrmEvent()
drmHandleEvent(fd(), &drmEvent);
}
-QEglFSKmsScreen *QEglFSKmsGbmDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
+QEglFSKmsScreen *QEglFSKmsGbmDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
{
static bool firstScreen = true;
- QEglFSKmsGbmScreen *screen = new QEglFSKmsGbmScreen(integration, device, output, position);
+ QEglFSKmsGbmScreen *screen = new QEglFSKmsGbmScreen(integration, device, output);
if (firstScreen && integration->hwCursor()) {
m_globalCursor = new QEglFSKmsGbmCursor(screen);
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
index 6a45f9ffa0..7c0af84422 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
@@ -68,8 +68,7 @@ public:
virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position) Q_DECL_OVERRIDE;
+ QEglFSKmsOutput output) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QEglFSKmsGbmDevice)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
index 1c0a8e1b5f..38419a55c8 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
@@ -43,9 +43,9 @@
#include "qeglfskmsgbmdevice.h"
#include "qeglfskmsgbmscreen.h"
#include "qeglfskmsgbmcursor.h"
-#include "qeglfscursor.h"
+#include "private/qeglfscursor_p.h"
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h>
#include <QtCore/QLoggingCategory>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
@@ -126,7 +126,7 @@ QEglFSKmsDevice *QEglFSKmsGbmIntegration::createDevice(const QString &devicePath
} else {
QDeviceDiscovery *d = QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask);
- QStringList devices = d->scanConnectedDevices();
+ const QStringList devices = d->scanConnectedDevices();
qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices;
d->deleteLater();
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp
index 8e8779ca10..f34e4859c6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp
@@ -38,18 +38,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfskmsgbmintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSKmsGbmIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSKmsGbmIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsGbmIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsGbmIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index 7a17b60a5e..bed775ff81 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -42,12 +42,12 @@
#include "qeglfskmsgbmscreen.h"
#include "qeglfskmsgbmdevice.h"
#include "qeglfskmsgbmcursor.h"
-#include "qeglfsintegration.h"
+#include "qeglfsintegration_p.h"
#include <QtCore/QLoggingCategory>
#include <QtGui/private/qguiapplication_p.h>
-#include <QtPlatformSupport/private/qfbvthandler_p.h>
+#include <QtFbSupport/private/qfbvthandler_p.h>
QT_BEGIN_NAMESPACE
@@ -93,10 +93,9 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject(
}
QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position)
- : QEglFSKmsScreen(integration, device, output, position)
+ QEglFSKmsDevice *device,
+ QEglFSKmsOutput output)
+ : QEglFSKmsScreen(integration, device, output)
, m_gbm_surface(Q_NULLPTR)
, m_gbm_bo_current(Q_NULLPTR)
, m_gbm_bo_next(Q_NULLPTR)
@@ -130,8 +129,8 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface()
if (!m_gbm_surface) {
qCDebug(qLcEglfsKmsDebug) << "Creating window for screen" << name();
m_gbm_surface = gbm_surface_create(static_cast<QEglFSKmsGbmDevice *>(device())->gbmDevice(),
- geometry().width(),
- geometry().height(),
+ rawGeometry().width(),
+ rawGeometry().height(),
GBM_FORMAT_XRGB8888,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
index 3381bbfdbb..d7ad348291 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
@@ -55,9 +55,8 @@ class QEglFSKmsGbmScreen : public QEglFSKmsScreen
{
public:
QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsDevice *device,
+ QEglFSKmsOutput output);
~QEglFSKmsGbmScreen();
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
index e2263f6cbf..a625021aba 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
@@ -1,19 +1,13 @@
TARGET = qeglfs-kms-egldevice-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private eglfs_kms_support-private
+QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private
-INCLUDEPATH += $$PWD/../.. $$PWD/../eglfs_kms_support
+INCLUDEPATH += $$PWD/../../api $$PWD/../eglfs_kms_support
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
-CONFIG += link_pkgconfig
-!contains(QT_CONFIG, no-pkg-config) {
- PKGCONFIG += libdrm
-} else {
- LIBS += -ldrm
-}
-
+QMAKE_USE += drm
CONFIG += egl
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
index f6e86bf0bc..60989e2bd0 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
@@ -40,11 +40,15 @@
#include "qeglfskmsegldevice.h"
#include "qeglfskmsegldevicescreen.h"
#include "qeglfskmsegldeviceintegration.h"
+#include "private/qeglfscursor_p.h"
#include <QtCore/private/qcore_unix_p.h>
+QT_BEGIN_NAMESPACE
+
QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path)
- : QEglFSKmsDevice(integration, path)
+ : QEglFSKmsDevice(integration, path),
+ m_globalCursor(nullptr)
{
}
@@ -52,6 +56,8 @@ bool QEglFSKmsEglDevice::open()
{
Q_ASSERT(fd() == -1);
+ qCDebug(qLcEglfsKmsDebug, "Opening DRM device %s", qPrintable(devicePath()));
+
int fd = drmOpen(devicePath().toLocal8Bit().constData(), Q_NULLPTR);
if (Q_UNLIKELY(fd < 0))
qFatal("Could not open DRM device");
@@ -63,6 +69,8 @@ bool QEglFSKmsEglDevice::open()
void QEglFSKmsEglDevice::close()
{
+ qCDebug(qLcEglfsKmsDebug, "Closing DRM device");
+
if (qt_safe_close(fd()) == -1)
qErrnoWarning("Could not close DRM device");
@@ -74,7 +82,26 @@ EGLNativeDisplayType QEglFSKmsEglDevice::nativeDisplay() const
return reinterpret_cast<EGLNativeDisplayType>(static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice());
}
-QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
+QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device,
+ QEglFSKmsOutput output)
{
- return new QEglFSKmsEglDeviceScreen(integration, device, output, position);
+ QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(integration, device, output);
+
+ if (!m_globalCursor && !integration->separateScreens()) {
+ qCDebug(qLcEglfsKmsDebug, "Creating new global mouse cursor");
+ m_globalCursor = new QEglFSCursor(screen);
+ }
+
+ return screen;
}
+
+void QEglFSKmsEglDevice::destroyGlobalCursor()
+{
+ if (m_globalCursor) {
+ qCDebug(qLcEglfsKmsDebug, "Destroying global mouse cursor");
+ delete m_globalCursor;
+ m_globalCursor = nullptr;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
index b1c98f3fe6..8c8f79f70c 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
@@ -42,6 +42,10 @@
#include <qeglfskmsdevice.h>
+QT_BEGIN_NAMESPACE
+
+class QPlatformCursor;
+
class QEglFSKmsEglDevice: public QEglFSKmsDevice
{
public:
@@ -54,8 +58,15 @@ public:
virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position) Q_DECL_OVERRIDE;
+ QEglFSKmsOutput output) Q_DECL_OVERRIDE;
+
+ QPlatformCursor *globalCursor() { return m_globalCursor; }
+ void destroyGlobalCursor();
+
+private:
+ QPlatformCursor *m_globalCursor;
};
+QT_END_NAMESPACE
+
#endif // QEGLFSKMSEGLDEVICE_H
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
index 838569d5c6..d0c9c9565e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
@@ -39,8 +39,9 @@
****************************************************************************/
#include "qeglfskmsegldeviceintegration.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include "qeglfswindow.h"
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include "private/qeglfswindow_p.h"
+#include "private/qeglfscursor_p.h"
#include "qeglfskmsegldevice.h"
#include "qeglfskmsscreen.h"
#include <QLoggingCategory>
@@ -189,12 +190,12 @@ void QEglJetsonTK1Window::resetSurface()
if (!m_integration->m_funcs->stream_consumer_output(display, m_egl_stream, layer))
qWarning("resetSurface: Unable to connect stream");
- m_config = QEglFSIntegration::chooseConfig(display, m_integration->surfaceFormatFor(window()->requestedFormat()));
+ m_config = QEglFSDeviceIntegration::chooseConfig(display, m_integration->surfaceFormatFor(window()->requestedFormat()));
m_format = q_glFormatFromConfig(display, m_config);
qCDebug(qLcEglfsKmsDebug) << "Stream producer format is" << m_format;
- const int w = cur_screen->geometry().width();
- const int h = cur_screen->geometry().height();
+ const int w = cur_screen->rawGeometry().width();
+ const int h = cur_screen->rawGeometry().height();
qCDebug(qLcEglfsKmsDebug, "Creating stream producer surface of size %dx%d", w, h);
const EGLint stream_producer_attribs[] = {
@@ -222,11 +223,6 @@ QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const
return eglWindow;
}
-bool QEglFSKmsEglDeviceIntegration::separateScreens() const
-{
- return true;
-}
-
QEglFSKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice(const QString &devicePath)
{
Q_UNUSED(devicePath)
@@ -263,4 +259,9 @@ bool QEglFSKmsEglDeviceIntegration::query_egl_device()
return true;
}
+QPlatformCursor *QEglFSKmsEglDeviceIntegration::createCursor(QPlatformScreen *screen) const
+{
+ return separateScreens() ? new QEglFSCursor(screen) : nullptr;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
index f04c42267a..cddfdbd5c6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
@@ -46,7 +46,7 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include <QtPlatformSupport/private/qeglstreamconvenience_p.h>
+#include <QtEglSupport/private/qeglstreamconvenience_p.h>
QT_BEGIN_NAMESPACE
@@ -61,12 +61,11 @@ public:
bool supportsPBuffers() const Q_DECL_OVERRIDE;
QEglFSWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
- virtual bool separateScreens() const Q_DECL_OVERRIDE;
-
EGLDeviceEXT eglDevice() const { return m_egl_device; }
protected:
QEglFSKmsDevice *createDevice(const QString &devicePath) Q_DECL_OVERRIDE;
+ QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE;
private:
bool setup_kms();
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp
index 63571f796f..42fec073f1 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp
@@ -41,13 +41,13 @@
QT_BEGIN_NAMESPACE
-class QEglFSKmsEglDeviceIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSKmsEglDeviceIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms_egldevice.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms_egldevice.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsEglDeviceIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsEglDeviceIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
index da1b577801..1f672afeb4 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
@@ -39,10 +39,30 @@
#include "qeglfskmsegldevicescreen.h"
#include "qeglfskmsegldevice.h"
+#include <QGuiApplication>
-QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
- : QEglFSKmsScreen(integration, device, output, position)
+QT_BEGIN_NAMESPACE
+
+QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
+ : QEglFSKmsScreen(integration, device, output)
+{
+}
+
+QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen()
{
+ const int remainingScreenCount = qGuiApp->screens().count();
+ qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount);
+ if (!remainingScreenCount && !m_integration->separateScreens())
+ static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor();
+}
+
+QPlatformCursor *QEglFSKmsEglDeviceScreen::cursor() const
+{
+ // The base class creates a cursor via integration->createCursor()
+ // in its ctor. With separateScreens just use that. Otherwise
+ // there's a virtual desktop and the device has a global cursor
+ // and the base class has no dedicated cursor at all.
+ return m_integration->separateScreens() ? QEglFSScreen::cursor() : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor();
}
void QEglFSKmsEglDeviceScreen::waitForFlip()
@@ -68,7 +88,7 @@ void QEglFSKmsEglDeviceScreen::waitForFlip()
qCDebug(qLcEglfsKmsDebug, "Setting mode");
int ret = drmModeSetCrtc(device()->fd(), output().crtc_id,
- -1, 0, 0,
+ uint32_t(-1), 0, 0,
&output().connector_id, 1,
&output().modes[output().mode]);
if (ret)
@@ -76,3 +96,5 @@ void QEglFSKmsEglDeviceScreen::waitForFlip()
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
index 0cd46e9f9d..c57f52c6b7 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
@@ -42,15 +42,21 @@
#include <qeglfskmsscreen.h>
+QT_BEGIN_NAMESPACE
+
class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen
{
public:
QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsOutput output);
+ ~QEglFSKmsEglDeviceScreen();
+
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
void waitForFlip() Q_DECL_OVERRIDE;
};
+QT_END_NAMESPACE
+
#endif // QEGLFSKMSEGLDEVICESCREEN_H
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
index 32f15f33fb..487edb569e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
@@ -2,20 +2,14 @@ TARGET = QtEglFsKmsSupport
CONFIG += no_module_headers internal_module
load(qt_module)
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private eglfsdeviceintegration-private
-INCLUDEPATH += $$PWD/../..
+INCLUDEPATH += $$PWD/../../api
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
-CONFIG += link_pkgconfig
-!contains(QT_CONFIG, no-pkg-config) {
- PKGCONFIG += libdrm
-} else {
- LIBS += -ldrm
-}
-
+QMAKE_USE += drm
CONFIG += egl
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
index f4ffee569d..f6b58d1ba6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
@@ -42,7 +42,7 @@
#include "qeglfskmsdevice.h"
#include "qeglfskmsscreen.h"
-#include "qeglfsintegration.h"
+#include "qeglfsintegration_p.h"
#include <QtCore/QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
@@ -86,7 +86,7 @@ int QEglFSKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorP
return -1;
}
-static const char * const connector_type_names[] = {
+static const char * const connector_type_names[] = { // must match DRM_MODE_CONNECTOR_*
"None",
"VGA",
"DVI",
@@ -102,6 +102,8 @@ static const char * const connector_type_names[] = {
"HDMI",
"TV",
"eDP",
+ "Virtual",
+ "DSI"
};
static QByteArray nameForConnector(const drmModeConnectorPtr connector)
@@ -159,7 +161,9 @@ static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode)
return true;
}
-QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos)
+QEglFSKmsScreen *QEglFSKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ drmModeConnectorPtr connector,
+ VirtualDesktopInfo *vinfo)
{
const QByteArray connectorName = nameForConnector(connector);
@@ -173,8 +177,11 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
QSize configurationSize;
drmModeModeInfo configurationModeline;
- const QByteArray mode = m_integration->outputSettings().value(QString::fromUtf8(connectorName))
- .value(QStringLiteral("mode"), QStringLiteral("preferred")).toByteArray().toLower();
+ auto userConfig = m_integration->outputSettings();
+ auto userConnectorConfig = userConfig.value(QString::fromUtf8(connectorName));
+ // default to the preferred mode unless overridden in the config
+ const QByteArray mode = userConnectorConfig.value(QStringLiteral("mode"), QStringLiteral("preferred"))
+ .toByteArray().toLower();
if (mode == "off") {
configuration = OutputConfigOff;
} else if (mode == "preferred") {
@@ -189,6 +196,16 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
qWarning("Invalid mode \"%s\" for output %s", mode.constData(), connectorName.constData());
configuration = OutputConfigPreferred;
}
+ if (vinfo) {
+ *vinfo = VirtualDesktopInfo();
+ vinfo->virtualIndex = userConnectorConfig.value(QStringLiteral("virtualIndex"), INT_MAX).toInt();
+ if (userConnectorConfig.contains(QStringLiteral("virtualPos"))) {
+ const QByteArray vpos = userConnectorConfig.value(QStringLiteral("virtualPos")).toByteArray();
+ const QByteArrayList vposComp = vpos.split(',');
+ if (vposComp.count() == 2)
+ vinfo->virtualPos = QPoint(vposComp[0].trimmed().toInt(), vposComp[1].trimmed().toInt());
+ }
+ }
const uint32_t crtc_id = resources->crtcs[crtc];
@@ -287,18 +304,26 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
<< '@' << refresh << "hz for output" << connectorName;
}
+
+ // physical size from connector < config values < env vars
static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
- QSizeF size(width, height);
- if (size.isEmpty()) {
- size.setWidth(connector->mmWidth);
- size.setHeight(connector->mmHeight);
+ QSizeF physSize(width, height);
+ if (physSize.isEmpty()) {
+ physSize = QSize(userConnectorConfig.value(QStringLiteral("physicalWidth")).toInt(),
+ userConnectorConfig.value(QStringLiteral("physicalHeight")).toInt());
+ if (physSize.isEmpty()) {
+ physSize.setWidth(connector->mmWidth);
+ physSize.setHeight(connector->mmHeight);
+ }
}
+ qCDebug(qLcEglfsKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName;
+
QEglFSKmsOutput output = {
QString::fromUtf8(connectorName),
connector->connector_id,
crtc_id,
- size,
+ physSize,
selected_mode,
false,
drmModeGetCrtc(m_dri_fd, crtc_id),
@@ -310,7 +335,7 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
m_crtc_allocator |= (1 << output.crtc_id);
m_connector_allocator |= (1 << output.connector_id);
- return createScreen(m_integration, this, output, pos);
+ return createScreen(m_integration, this, output);
}
drmModePropertyPtr QEglFSKmsDevice::connectorProperty(drmModeConnectorPtr connector, const QByteArray &name)
@@ -342,6 +367,28 @@ QEglFSKmsDevice::~QEglFSKmsDevice()
{
}
+struct OrderedScreen
+{
+ OrderedScreen() : screen(nullptr) { }
+ OrderedScreen(QEglFSKmsScreen *screen, const QEglFSKmsDevice::VirtualDesktopInfo &vinfo)
+ : screen(screen), vinfo(vinfo) { }
+ QEglFSKmsScreen *screen;
+ QEglFSKmsDevice::VirtualDesktopInfo vinfo;
+};
+
+QDebug operator<<(QDebug dbg, const OrderedScreen &s)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "OrderedScreen(" << s.screen << " : " << s.vinfo.virtualIndex
+ << " / " << s.vinfo.virtualPos << ")";
+ return dbg;
+}
+
+static bool orderedScreenLessThan(const OrderedScreen &a, const OrderedScreen &b)
+{
+ return a.vinfo.virtualIndex < b.vinfo.virtualIndex;
+}
+
void QEglFSKmsDevice::createScreens()
{
drmModeResPtr resources = drmModeGetResources(m_dri_fd);
@@ -350,32 +397,53 @@ void QEglFSKmsDevice::createScreens()
return;
}
- QEglFSKmsScreen *primaryScreen = Q_NULLPTR;
- QList<QPlatformScreen *> siblings;
- QPoint pos(0, 0);
- QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QVector<OrderedScreen> screens;
for (int i = 0; i < resources->count_connectors; i++) {
drmModeConnectorPtr connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]);
if (!connector)
continue;
- QEglFSKmsScreen *screen = screenForConnector(resources, connector, pos);
- if (screen) {
- integration->addScreen(screen);
- pos.rx() += screen->geometry().width();
- siblings << screen;
-
- if (!primaryScreen)
- primaryScreen = screen;
- }
+ VirtualDesktopInfo vinfo;
+ QEglFSKmsScreen *screen = createScreenForConnector(resources, connector, &vinfo);
+ if (screen)
+ screens.append(OrderedScreen(screen, vinfo));
drmModeFreeConnector(connector);
}
drmModeFreeResources(resources);
+ // Use stable sort to preserve the original order for outputs with unspecified indices.
+ std::stable_sort(screens.begin(), screens.end(), orderedScreenLessThan);
+ qCDebug(qLcEglfsKmsDebug) << "Sorted screen list:" << screens;
+
+ QPoint pos(0, 0);
+ QList<QPlatformScreen *> siblings;
+ QEglFSIntegration *qpaIntegration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
+
+ for (const OrderedScreen &orderedScreen : screens) {
+ QEglFSKmsScreen *s = orderedScreen.screen;
+ // set up a horizontal or vertical virtual desktop
+ if (orderedScreen.vinfo.virtualPos.isNull()) {
+ s->setVirtualPosition(pos);
+ if (m_integration->virtualDesktopLayout() == QEglFSKmsIntegration::VirtualDesktopLayoutVertical)
+ pos.ry() += s->geometry().height();
+ else
+ pos.rx() += s->geometry().width();
+ } else {
+ s->setVirtualPosition(orderedScreen.vinfo.virtualPos);
+ }
+ qCDebug(qLcEglfsKmsDebug) << "Adding screen" << s << "to QPA with geometry" << s->geometry();
+ // The order in qguiapp's screens list will match the order set by
+ // virtualIndex. This is not only handy but also required since for instance
+ // evdevtouch relies on it when performing touch device - screen mapping.
+ qpaIntegration->addScreen(s);
+ siblings << s;
+ }
+
if (!m_integration->separateScreens()) {
+ // enable the virtual desktop
Q_FOREACH (QPlatformScreen *screen, siblings)
static_cast<QEglFSKmsScreen *>(screen)->setVirtualSiblings(siblings);
}
@@ -391,9 +459,9 @@ QString QEglFSKmsDevice::devicePath() const
return m_path;
}
-QEglFSKmsScreen *QEglFSKmsDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
+QEglFSKmsScreen *QEglFSKmsDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
{
- return new QEglFSKmsScreen(integration, device, output, position);
+ return new QEglFSKmsScreen(integration, device, output);
}
void QEglFSKmsDevice::setFd(int fd)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
index 041c063695..3e7ac7e3f0 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
@@ -53,6 +53,12 @@ QT_BEGIN_NAMESPACE
class Q_EGLFS_EXPORT QEglFSKmsDevice
{
public:
+ struct VirtualDesktopInfo {
+ VirtualDesktopInfo() : virtualIndex(0) { }
+ int virtualIndex;
+ QPoint virtualPos;
+ };
+
QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QString &path);
virtual ~QEglFSKmsDevice();
@@ -68,8 +74,7 @@ public:
protected:
virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsOutput output);
void setFd(int fd);
QEglFSKmsIntegration *m_integration;
@@ -80,7 +85,9 @@ protected:
quint32 m_connector_allocator;
int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
- QEglFSKmsScreen *screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos);
+ QEglFSKmsScreen *createScreenForConnector(drmModeResPtr resources,
+ drmModeConnectorPtr connector,
+ VirtualDesktopInfo *vinfo);
drmModePropertyPtr connectorProperty(drmModeConnectorPtr connector, const QByteArray &name);
static void pageFlipHandler(int fd,
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
index 07ea7d4439..5368a6d031 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
@@ -42,15 +42,12 @@
#include "qeglfskmsintegration.h"
#include "qeglfskmsdevice.h"
#include "qeglfskmsscreen.h"
-#include "qeglfswindow.h"
-#include "qeglfscursor.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonArray>
+#include <QtCore/QFile>
#include <QtGui/qpa/qplatformwindow.h>
-#include <QtGui/qpa/qplatformcursor.h>
#include <QtGui/QScreen>
#include <xf86drm.h>
@@ -65,6 +62,7 @@ QEglFSKmsIntegration::QEglFSKmsIntegration()
, m_hwCursor(false)
, m_pbuffers(false)
, m_separateScreens(false)
+ , m_virtualDesktopLayout(VirtualDesktopLayoutHorizontal)
{}
void QEglFSKmsIntegration::platformInit()
@@ -149,6 +147,11 @@ bool QEglFSKmsIntegration::separateScreens() const
return m_separateScreens;
}
+QEglFSKmsIntegration::VirtualDesktopLayout QEglFSKmsIntegration::virtualDesktopLayout() const
+{
+ return m_virtualDesktopLayout;
+}
+
QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const
{
return m_outputSettings;
@@ -169,15 +172,15 @@ void QEglFSKmsIntegration::loadConfig()
QFile file(QString::fromUtf8(json));
if (!file.open(QFile::ReadOnly)) {
- qCDebug(qLcEglfsKmsDebug) << "Could not open config file"
- << json << "for reading";
+ qCWarning(qLcEglfsKmsDebug) << "Could not open config file"
+ << json << "for reading";
return;
}
const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
if (!doc.isObject()) {
- qCDebug(qLcEglfsKmsDebug) << "Invalid config file" << json
- << "- no top-level JSON object";
+ qCWarning(qLcEglfsKmsDebug) << "Invalid config file" << json
+ << "- no top-level JSON object";
return;
}
@@ -188,6 +191,16 @@ void QEglFSKmsIntegration::loadConfig()
m_devicePath = object.value(QLatin1String("device")).toString();
m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens);
+ const QString vdOriString = object.value(QLatin1String("virtualDesktopLayout")).toString();
+ if (!vdOriString.isEmpty()) {
+ if (vdOriString == QLatin1String("horizontal"))
+ m_virtualDesktopLayout = VirtualDesktopLayoutHorizontal;
+ else if (vdOriString == QLatin1String("vertical"))
+ m_virtualDesktopLayout = VirtualDesktopLayoutVertical;
+ else
+ qCWarning(qLcEglfsKmsDebug) << "Unknown virtualDesktopOrientation value" << vdOriString;
+ }
+
const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray();
for (int i = 0; i < outputs.size(); i++) {
const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap();
@@ -207,6 +220,7 @@ void QEglFSKmsIntegration::loadConfig()
<< "\thwcursor:" << m_hwCursor << "\n"
<< "\tpbuffers:" << m_pbuffers << "\n"
<< "\tseparateScreens:" << m_separateScreens << "\n"
+ << "\tvirtualDesktopLayout:" << m_virtualDesktopLayout << "\n"
<< "\toutputs:" << m_outputSettings;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
index 34ac5385a5..ba49945715 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
@@ -42,7 +42,7 @@
#ifndef QEGLFSKMSINTEGRATION_H
#define QEGLFSKMSINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include <QtCore/QMap>
#include <QtCore/QVariant>
#include <QtCore/QLoggingCategory>
@@ -53,9 +53,14 @@ class QEglFSKmsDevice;
Q_EGLFS_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
-class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEGLDeviceIntegration
+class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration
{
public:
+ enum VirtualDesktopLayout {
+ VirtualDesktopLayoutHorizontal,
+ VirtualDesktopLayoutVertical
+ };
+
QEglFSKmsIntegration();
void platformInit() Q_DECL_OVERRIDE;
@@ -70,6 +75,7 @@ public:
virtual bool hwCursor() const;
virtual bool separateScreens() const;
+ virtual VirtualDesktopLayout virtualDesktopLayout() const;
QMap<QString, QVariantMap> outputSettings() const;
QEglFSKmsDevice *device() const;
@@ -83,6 +89,7 @@ protected:
bool m_hwCursor;
bool m_pbuffers;
bool m_separateScreens;
+ VirtualDesktopLayout m_virtualDesktopLayout;
QString m_devicePath;
QMap<QString, QVariantMap> m_outputSettings;
};
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
index e6b256f6b2..4021609407 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
@@ -41,12 +41,12 @@
#include "qeglfskmsscreen.h"
#include "qeglfskmsdevice.h"
-#include "qeglfsintegration.h"
+#include "qeglfsintegration_p.h"
#include <QtCore/QLoggingCategory>
#include <QtGui/private/qguiapplication_p.h>
-#include <QtPlatformSupport/private/qfbvthandler_p.h>
+#include <QtFbSupport/private/qfbvthandler_p.h>
QT_BEGIN_NAMESPACE
@@ -71,17 +71,15 @@ private:
QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position)
+ QEglFSKmsOutput output)
: QEglFSScreen(eglGetDisplay(device->nativeDisplay()))
, m_integration(integration)
, m_device(device)
, m_output(output)
- , m_pos(position)
, m_powerState(PowerStateOn)
, m_interruptHandler(new QEglFSKmsInterruptHandler(this))
{
- m_siblings << this;
+ m_siblings << this; // gets overridden by QEglFSKmsDevice later if !separateScreens
}
QEglFSKmsScreen::~QEglFSKmsScreen()
@@ -98,7 +96,14 @@ QEglFSKmsScreen::~QEglFSKmsScreen()
delete m_interruptHandler;
}
-QRect QEglFSKmsScreen::geometry() const
+void QEglFSKmsScreen::setVirtualPosition(const QPoint &pos)
+{
+ m_pos = pos;
+}
+
+// Reimplement rawGeometry(), not geometry(). The base class implementation of
+// geometry() calls rawGeometry() and may apply additional transforms.
+QRect QEglFSKmsScreen::rawGeometry() const
{
const int mode = m_output.mode;
return QRect(m_pos.x(), m_pos.y(),
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
index aa698e1b5d..2b6a0ffe6c 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
@@ -43,7 +43,7 @@
#define QEGLFSKMSSCREEN_H
#include "qeglfskmsintegration.h"
-#include "qeglfsscreen.h"
+#include "private/qeglfsscreen_p.h"
#include <QtCore/QList>
#include <QtCore/QMutex>
@@ -74,11 +74,13 @@ class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen
public:
QEglFSKmsScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsOutput output);
~QEglFSKmsScreen();
- QRect geometry() const Q_DECL_OVERRIDE;
+ void setVirtualPosition(const QPoint &pos);
+
+ QRect rawGeometry() const Q_DECL_OVERRIDE;
+
int depth() const Q_DECL_OVERRIDE;
QImage::Format format() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro
index 3e486bd1bd..5e6f636e2b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro
@@ -1,11 +1,11 @@
TARGET = qeglfs-mali-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private eglfsdeviceintegration-private
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
-INCLUDEPATH += $$PWD/../..
+INCLUDEPATH += $$PWD/../../api
CONFIG += egl
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp
index ffdb7a686b..cd468c989f 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp
@@ -56,7 +56,7 @@ struct fbdev_window {
void QEglFSMaliIntegration::platformInit()
{
// Keep the non-overridden base class functions based on fb0 working.
- QEGLDeviceIntegration::platformInit();
+ QEglFSDeviceIntegration::platformInit();
int fd = qt_safe_open("/dev/fb0", O_RDWR, 0);
if (fd == -1)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h
index 35a2c64951..56883a3676 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h
@@ -40,11 +40,11 @@
#ifndef QEGLFSMALIINTEGRATION_H
#define QEGLFSMALIINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSMaliIntegration : public QEGLDeviceIntegration
+class QEglFSMaliIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp
index 0754e1af5b..a3c804f54d 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsmaliintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSMaliIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSMaliIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_mali.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_mali.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSMaliIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSMaliIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro
index 6fac2f529a..f9cce8d48b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro
@@ -1,11 +1,10 @@
TARGET = qeglfs-viv-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private eglfsdeviceintegration-private
-INCLUDEPATH += $$PWD/../..
+INCLUDEPATH += $$PWD/../../api
CONFIG += egl
DEFINES += LINUX=1 EGL_API_FB=1
-LIBS += -lGAL
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfsvivmain.cpp \
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
index ca97f6c8f9..f2fcc0d3ff 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
void QEglFSVivIntegration::platformInit()
{
- QEGLDeviceIntegration::platformInit();
+ QEglFSDeviceIntegration::platformInit();
int width, height;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
index 4a8cd5c385..2e98c2b4b1 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
@@ -40,11 +40,11 @@
#ifndef QEGLFSVIVINTEGRATION_H
#define QEGLFSVIVINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSVivIntegration : public QEGLDeviceIntegration
+class QEglFSVivIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp
index d1c9fb4086..ebe2091b1e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsvivintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSVivIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSVivIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro
index 44f75c40e0..065a103376 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro
@@ -1,11 +1,10 @@
TARGET = qeglfs-viv-wl-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private eglfsdeviceintegration-private
-INCLUDEPATH += $$PWD/../..
+INCLUDEPATH += $$PWD/../../api
CONFIG += egl
DEFINES += LINUX=1 EGL_API_FB=1
-LIBS += -lGAL
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfsvivwlmain.cpp \
@@ -15,8 +14,7 @@ HEADERS += $$PWD/qeglfsvivwlintegration.h
OTHER_FILES += $$PWD/eglfs_viv_wl.json
-CONFIG += link_pkgconfig
-PKGCONFIG_PRIVATE += wayland-server
+QMAKE_USE_PRIVATE += wayland_server
PLUGIN_TYPE = egldeviceintegrations
PLUGIN_CLASS_NAME = QEglFSVivWaylandIntegrationPlugin
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp
index 5c113456e4..61e2f17766 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
void QEglFSVivWaylandIntegration::platformInit()
{
- QEGLDeviceIntegration::platformInit();
+ QEglFSDeviceIntegration::platformInit();
int width, height;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h
index 40eacc8f2f..9abbe817a6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h
@@ -40,12 +40,12 @@
#ifndef QEGLFSVIVINTEGRATION_H
#define QEGLFSVIVINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
struct wl_display;
QT_BEGIN_NAMESPACE
-class QEglFSVivWaylandIntegration : public QEGLDeviceIntegration
+class QEglFSVivWaylandIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp
index 02ef9c566c..3b26feda07 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsvivwlintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSVivWaylandIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSVivWaylandIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv_wl.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv_wl.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivWaylandIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivWaylandIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
index 1948d73750..391f63615b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
@@ -1,14 +1,14 @@
TARGET = qeglfs-x11-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private eglfsdeviceintegration-private
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
-INCLUDEPATH += $$PWD/../..
+INCLUDEPATH += $$PWD/../../api
CONFIG += egl
-LIBS += -lX11 -lX11-xcb -lxcb
+QMAKE_USE += xcb_xlib
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfsx11main.cpp \
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
index a3d0b01baf..c0f0ee5f22 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
@@ -40,7 +40,7 @@
#ifndef QEGLFSX11INTEGRATION_H
#define QEGLFSX11INTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformwindow.h>
@@ -64,7 +64,7 @@ namespace Atoms {
class EventReader;
-class QEglFSX11Integration : public QEGLDeviceIntegration
+class QEglFSX11Integration : public QEglFSDeviceIntegration
{
public:
QEglFSX11Integration() : m_connection(0), m_window(0), m_eventReader(0) {}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
index 314a85694b..c15e05b657 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsx11integration.h"
QT_BEGIN_NAMESPACE
-class QEglFSX11IntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSX11IntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_x11.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_x11.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSX11Integration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSX11Integration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/eglfs-plugin.pro b/src/plugins/platforms/eglfs/eglfs-plugin.pro
index a628cdccd9..cf4863975a 100644
--- a/src/plugins/platforms/eglfs/eglfs-plugin.pro
+++ b/src/plugins/platforms/eglfs/eglfs-plugin.pro
@@ -1,11 +1,13 @@
TARGET = qeglfs
-QT += platformsupport-private eglfs_device_lib-private
+QT += eglfsdeviceintegration-private
SOURCES += $$PWD/qeglfsmain.cpp
OTHER_FILES += $$PWD/eglfs.json
+INCLUDEPATH += $$PWD/api
+
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro
index 03c96ca1d9..d91ffd60a1 100644
--- a/src/plugins/platforms/eglfs/eglfs.pro
+++ b/src/plugins/platforms/eglfs/eglfs.pro
@@ -1,6 +1,6 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS += eglfs_device_lib.pro
+SUBDIRS += eglfsdeviceintegration.pro
SUBDIRS += eglfs-plugin.pro
SUBDIRS += deviceintegration
diff --git a/src/plugins/platforms/eglfs/eglfs_device_lib.pro b/src/plugins/platforms/eglfs/eglfs_device_lib.pro
deleted file mode 100644
index 974b85b1dd..0000000000
--- a/src/plugins/platforms/eglfs/eglfs_device_lib.pro
+++ /dev/null
@@ -1,54 +0,0 @@
-# The device integration plugin base class has to live in a shared library,
-# placing it into a static lib like platformsupport is not sufficient since we
-# have to keep the QObject magic like qobject_cast working.
-# Hence this header-less, private-only module.
-
-TARGET = QtEglDeviceIntegration
-CONFIG += no_module_headers internal_module
-
-QT += core-private gui-private platformsupport-private
-LIBS += $$QMAKE_LIBS_DYNLOAD
-
-# Avoid X11 header collision, use generic EGL native types
-DEFINES += QT_EGL_NO_X11
-
-DEFINES += QT_BUILD_EGL_DEVICE_LIB
-
-SOURCES += $$PWD/qeglfsintegration.cpp \
- $$PWD/qeglfswindow.cpp \
- $$PWD/qeglfsscreen.cpp \
- $$PWD/qeglfscursor.cpp \
- $$PWD/qeglfshooks.cpp \
- $$PWD/qeglfscontext.cpp \
- $$PWD/qeglfsoffscreenwindow.cpp \
- $$PWD/qeglfsdeviceintegration.cpp
-
-HEADERS += $$PWD/qeglfsintegration.h \
- $$PWD/qeglfswindow.h \
- $$PWD/qeglfsscreen.h \
- $$PWD/qeglfscursor.h \
- $$PWD/qeglfshooks.h \
- $$PWD/qeglfscontext.h \
- $$PWD/qeglfsoffscreenwindow.h \
- $$PWD/qeglfsdeviceintegration.h
-
-QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
-
-INCLUDEPATH += $$PWD
-
-!isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) {
- HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS
- SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES
- LIBS += $$EGLFS_PLATFORM_HOOKS_LIBS
- DEFINES += EGLFS_PLATFORM_HOOKS
-}
-
-!isEmpty(EGLFS_DEVICE_INTEGRATION) {
- DEFINES += EGLFS_PREFERRED_PLUGIN=$$EGLFS_DEVICE_INTEGRATION
-}
-
-CONFIG += egl qpa/genericunixfontdatabase
-
-!contains(DEFINES, QT_NO_CURSOR): RESOURCES += $$PWD/cursor.qrc
-
-load(qt_module)
diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
new file mode 100644
index 0000000000..35af3615bd
--- /dev/null
+++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
@@ -0,0 +1,50 @@
+# The device integration plugin base class has to live in a shared library,
+# placing it into a static lib like platformsupport is not sufficient since we
+# have to keep the QObject magic like qobject_cast working.
+# Hence this private-only module.
+# By having _p headers, it also enables developing out-of-tree integration plugins.
+
+TARGET = QtEglFSDeviceIntegration
+CONFIG += internal_module
+MODULE = eglfsdeviceintegration
+
+QT += \
+ core-private gui-private \
+ devicediscovery_support-private eventdispatcher_support-private \
+ service_support-private theme_support-private fontdatabase_support-private \
+ fb_support-private egl_support-private platformcompositor_support-private
+
+qtHaveModule(input_support-private): \
+ QT += input_support-private
+
+LIBS += $$QMAKE_LIBS_DYNLOAD
+
+# Avoid X11 header collision, use generic EGL native types
+DEFINES += QT_EGL_NO_X11
+
+DEFINES += QT_BUILD_EGL_DEVICE_LIB
+
+include($$PWD/api/api.pri)
+
+QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
+
+!isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) {
+ HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS
+ SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES
+ LIBS += $$EGLFS_PLATFORM_HOOKS_LIBS
+ DEFINES += EGLFS_PLATFORM_HOOKS
+}
+
+!isEmpty(EGLFS_DEVICE_INTEGRATION) {
+ DEFINES += EGLFS_PREFERRED_PLUGIN=$$EGLFS_DEVICE_INTEGRATION
+}
+
+CONFIG += egl
+
+# Prevent gold linker from crashing.
+# This started happening when QtPlatformSupport was modularized.
+use_gold_linker: CONFIG += no_linker_version_script
+
+!contains(DEFINES, QT_NO_CURSOR): RESOURCES += $$PWD/cursor.qrc
+
+load(qt_module)
diff --git a/src/plugins/platforms/eglfs/qeglfsmain.cpp b/src/plugins/platforms/eglfs/qeglfsmain.cpp
index 50279ad110..2885d397c6 100644
--- a/src/plugins/platforms/eglfs/qeglfsmain.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsmain.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include <qpa/qplatformintegrationplugin.h>
-#include "qeglfsintegration.h"
+#include "qeglfsintegration_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/haiku/haiku.pro b/src/plugins/platforms/haiku/haiku.pro
index ea5bb632db..fd1f47b963 100644
--- a/src/plugins/platforms/haiku/haiku.pro
+++ b/src/plugins/platforms/haiku/haiku.pro
@@ -1,6 +1,6 @@
TARGET = qhaiku
-QT += platformsupport-private core-private gui-private
+QT += core-private gui-private eventdistpatcher_support-private
SOURCES = \
main.cpp \
@@ -36,8 +36,6 @@ LIBS += -lbe
OTHER_FILES += haiku.json
-include (../../../platformsupport/fontdatabases/fontdatabases.pri)
-
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QHaikuIntegrationPlugin
load(qt_plugin)
diff --git a/src/plugins/platforms/haiku/qhaikuclipboard.cpp b/src/plugins/platforms/haiku/qhaikuclipboard.cpp
index 0194a0415a..774da4432a 100644
--- a/src/plugins/platforms/haiku/qhaikuclipboard.cpp
+++ b/src/plugins/platforms/haiku/qhaikuclipboard.cpp
@@ -91,7 +91,7 @@ QMimeData *QHaikuClipboard::mimeData(QClipboard::Mode mode)
const status_t status = clipboard->FindData(name, B_MIME_TYPE, &data, &dataLen);
if (dataLen && (status == B_OK)) {
- const QString format = QString::fromLatin1(name);
+ const QLatin1String format(name);
if (format == QLatin1String("text/plain")) {
m_systemMimeData->setText(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
} else if (format == QLatin1String("text/html")) {
diff --git a/src/plugins/platforms/haiku/qhaikuintegration.cpp b/src/plugins/platforms/haiku/qhaikuintegration.cpp
index d239380866..d46d77ff18 100644
--- a/src/plugins/platforms/haiku/qhaikuintegration.cpp
+++ b/src/plugins/platforms/haiku/qhaikuintegration.cpp
@@ -49,7 +49,7 @@
#include <QCoreApplication>
#include <QFileInfo>
#include <qpa/qplatformwindow.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
#include <Application.h>
diff --git a/src/plugins/platforms/integrity/integrity.pro b/src/plugins/platforms/integrity/integrity.pro
index 07dbf4093d..0fb256793d 100644
--- a/src/plugins/platforms/integrity/integrity.pro
+++ b/src/plugins/platforms/integrity/integrity.pro
@@ -1,6 +1,9 @@
TARGET = integrityfb
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private service_support-private \
+ fontdatabase_support-private fb_support-private
SOURCES = \
main.cpp \
@@ -13,8 +16,6 @@ HEADERS = \
qintegrityfbscreen.h \
qintegrityhidmanager.h
-CONFIG += qpa/genericunixfontdatabase
-
OTHER_FILES += integrity.json
PLUGIN_TYPE = platforms
diff --git a/src/plugins/platforms/integrity/qintegrityfbintegration.cpp b/src/plugins/platforms/integrity/qintegrityfbintegration.cpp
index 5332718c5e..a88c85e30d 100644
--- a/src/plugins/platforms/integrity/qintegrityfbintegration.cpp
+++ b/src/plugins/platforms/integrity/qintegrityfbintegration.cpp
@@ -35,13 +35,13 @@
#include "qintegrityfbscreen.h"
#include "qintegrityhidmanager.h"
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qfbbackingstore_p.h>
-#include <QtPlatformSupport/private/qfbwindow_p.h>
-#include <QtPlatformSupport/private/qfbcursor_p.h>
+#include <QtFbSupport/private/qfbbackingstore_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatforminputcontextfactory_p.h>
diff --git a/src/plugins/platforms/integrity/qintegrityfbscreen.cpp b/src/plugins/platforms/integrity/qintegrityfbscreen.cpp
index e043da7786..256cc117a2 100644
--- a/src/plugins/platforms/integrity/qintegrityfbscreen.cpp
+++ b/src/plugins/platforms/integrity/qintegrityfbscreen.cpp
@@ -32,8 +32,8 @@
****************************************************************************/
#include "qintegrityfbscreen.h"
-#include <QtPlatformSupport/private/qfbcursor_p.h>
-#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
#include <QtCore/QRegularExpression>
#include <QtGui/QPainter>
diff --git a/src/plugins/platforms/integrity/qintegrityfbscreen.h b/src/plugins/platforms/integrity/qintegrityfbscreen.h
index 2a83f3426f..5b4d900a4b 100644
--- a/src/plugins/platforms/integrity/qintegrityfbscreen.h
+++ b/src/plugins/platforms/integrity/qintegrityfbscreen.h
@@ -34,7 +34,7 @@
#ifndef QINTEGRITYFBSCREEN_H
#define QINTEGRITYFBSCREEN_H
-#include <QtPlatformSupport/private/qfbscreen_p.h>
+#include <QtFbSupport/private/qfbscreen_p.h>
#include <device/fbdriver.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro
index 955f8d9642..caafe89730 100644
--- a/src/plugins/platforms/ios/kernel.pro
+++ b/src/plugins/platforms/ios/kernel.pro
@@ -1,6 +1,9 @@
TARGET = qios
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ clipboard_support-private fontdatabase_support-private graphics_support-private
+
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox
OBJECTIVE_SOURCES = \
@@ -19,14 +22,9 @@ OBJECTIVE_SOURCES = \
qiosglobal.mm \
qiosservices.mm \
quiview.mm \
- qiosclipboard.mm \
quiaccessibilityelement.mm \
qiosplatformaccessibility.mm \
- qiostextresponder.mm \
- qiosmenu.mm \
- qiosfiledialog.mm \
- qiosmessagedialog.mm \
- qiostextinputoverlay.mm
+ qiostextresponder.mm
HEADERS = \
qiosintegration.h \
@@ -43,15 +41,25 @@ HEADERS = \
qiosglobal.h \
qiosservices.h \
quiview.h \
- qiosclipboard.h \
quiaccessibilityelement.h \
qiosplatformaccessibility.h \
- qiostextresponder.h \
- qiosmenu.h \
- qiosfiledialog.h \
- qiosmessagedialog.h \
- qiostextinputoverlay.h
+ qiostextresponder.h
+!tvos {
+ LIBS += -framework AssetsLibrary
+ OBJECTIVE_SOURCES += \
+ qiosclipboard.mm \
+ qiosmenu.mm \
+ qiosfiledialog.mm \
+ qiosmessagedialog.mm \
+ qiostextinputoverlay.mm
+ HEADERS += \
+ qiosclipboard.h \
+ qiosmenu.h \
+ qiosfiledialog.h \
+ qiosmessagedialog.h \
+ qiostextinputoverlay.h
+}
OTHER_FILES = \
quiview_textinput.mm \
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h
index 0397b20dfa..b143357aa5 100644
--- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h
+++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h
@@ -53,8 +53,12 @@ public:
{
static QLatin1String assetsScheme("assets-library:");
+#ifndef Q_OS_TVOS
if (fileName.toLower().startsWith(assetsScheme))
return new QIOSFileEngineAssetsLibrary(fileName);
+#else
+ Q_UNUSED(fileName);
+#endif
return 0;
}
diff --git a/src/plugins/platforms/ios/optional/optional.pro b/src/plugins/platforms/ios/optional/optional.pro
index 5e3421a025..6b4ae1ef5e 100644
--- a/src/plugins/platforms/ios/optional/optional.pro
+++ b/src/plugins/platforms/ios/optional/optional.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = nsphotolibrarysupport
+ios: SUBDIRS = nsphotolibrarysupport
diff --git a/src/plugins/platforms/ios/plugin.mm b/src/plugins/platforms/ios/plugin.mm
index b854dfdaa0..83760f2f39 100644
--- a/src/plugins/platforms/ios/plugin.mm
+++ b/src/plugins/platforms/ios/plugin.mm
@@ -54,8 +54,10 @@ class QIOSIntegrationPlugin : public QPlatformIntegrationPlugin
QPlatformIntegration * QIOSIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
- if (!system.compare(QLatin1String("ios"), Qt::CaseInsensitive))
+ if (!system.compare(QLatin1String("ios"), Qt::CaseInsensitive)
+ || !system.compare(QLatin1String("tvos"), Qt::CaseInsensitive)) {
return new QIOSIntegration;
+ }
return 0;
}
diff --git a/src/plugins/platforms/ios/qiosbackingstore.h b/src/plugins/platforms/ios/qiosbackingstore.h
index 5c37be5d38..1c072c0935 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.h
+++ b/src/plugins/platforms/ios/qiosbackingstore.h
@@ -42,7 +42,7 @@
#include <qpa/qplatformbackingstore.h>
-#include <QtPlatformSupport/private/qrasterbackingstore_p.h>
+#include <QtGraphicsSupport/private/qrasterbackingstore_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm
index fb0c9805f9..076e34c1a5 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.mm
+++ b/src/plugins/platforms/ios/qiosbackingstore.mm
@@ -49,6 +49,8 @@
#include <QtDebug>
+QT_BEGIN_NAMESPACE
+
class QIOSPaintDevice : public QOpenGLPaintDevice
{
public:
@@ -64,6 +66,33 @@ void QIOSPaintDevice::ensureActiveTarget()
m_backingStore->makeCurrent();
}
+/*!
+ \class QIOSBackingStore
+
+ \brief The QPlatformBackingStore on iOS.
+
+ QBackingStore enables the use of QPainter to paint on a QWindow, as opposed
+ to rendering to a QWindow through the use of OpenGL with QOpenGLContext.
+
+ Historically, the iOS port initially implemented the backing store by using
+ an QOpenGLPaintDevice as its paint device, triggering the use of the OpenGL
+ paint engine for QPainter based drawing. This was due to raster drawing
+ operations being too slow when not being NEON-optimized, and got the port
+ up and running quickly.
+
+ As of 3e892e4a97, released in Qt 5.7, the backing store now uses a QImage,
+ for its paint device, giving normal raster-based QPainter operations, and
+ enabling features such as antialiased drawing.
+
+ To account for regressions in performance, the old code path is still
+ available by setting the surface type of the QWindow to OpenGLSurface.
+ This surface type is normally used when rendering though QOpenGLContext,
+ but will in the case of QIOSBackingStore trigger the old OpenGL based
+ painter.
+
+ This fallback path is not too intrusive, as the QImage based path still
+ uses OpenGL to composite the image at flush() time using composeAndFlush.
+*/
QIOSBackingStore::QIOSBackingStore(QWindow *window)
: QRasterBackingStore(window)
, m_context(new QOpenGLContext)
diff --git a/src/plugins/platforms/ios/qiosclipboard.h b/src/plugins/platforms/ios/qiosclipboard.h
index b9ba4a2669..f3ccfcace0 100644
--- a/src/plugins/platforms/ios/qiosclipboard.h
+++ b/src/plugins/platforms/ios/qiosclipboard.h
@@ -40,10 +40,13 @@
#ifndef QIOSCLIPBOARD_H
#define QIOSCLIPBOARD_H
+#include <qpa/qplatformclipboard.h>
+
+#ifndef QT_NO_CLIPBOARD
+
#import <UIKit/UIKit.h>
#include <QMimeData>
-#include <qpa/qplatformclipboard.h>
@class QUIClipboard;
@@ -67,4 +70,6 @@ private:
QT_END_NAMESPACE
+#endif // QT_NO_CLIPBOARD
+
#endif // QIOSCLIPBOARD_H
diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm
index fb75cc793c..ef3b453bbf 100644
--- a/src/plugins/platforms/ios/qiosclipboard.mm
+++ b/src/plugins/platforms/ios/qiosclipboard.mm
@@ -39,7 +39,9 @@
#include "qiosclipboard.h"
-#include <QtPlatformSupport/private/qmacmime_p.h>
+#ifndef QT_NO_CLIPBOARD
+
+#include <QtClipboardSupport/private/qmacmime_p.h>
#include <QtCore/QMimeData>
#include <QtGui/QGuiApplication>
@@ -247,3 +249,5 @@ bool QIOSClipboard::ownsMode(QClipboard::Mode mode) const
}
QT_END_NAMESPACE
+
+#endif // QT_NO_CLIPBOARD
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index 50374dc951..2d5286e971 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -48,6 +48,8 @@
#import <OpenGLES/ES2/glext.h>
#import <QuartzCore/CAEAGLLayer.h>
+QT_BEGIN_NAMESPACE
+
Q_LOGGING_CATEGORY(lcQpaGLContext, "qt.qpa.glcontext");
QIOSContext::QIOSContext(QOpenGLContext *context)
@@ -314,3 +316,4 @@ bool QIOSContext::isSharing() const
#include "moc_qioscontext.cpp"
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index 8d82364cc0..f49f81912e 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -493,7 +493,7 @@ void QIOSEventDispatcher::handleRunLoopExit(CFRunLoopActivity activity)
Q_UNUSED(activity);
Q_ASSERT(activity == kCFRunLoopExit);
- if (m_processEventLevel == 1 && !QThreadData::current()->eventLoops.top()->isRunning()) {
+ if (m_processEventLevel == 1 && !currentEventLoop()->isRunning()) {
qEventDispatcherDebug() << "Root runloop level exited";
interruptEventLoopExec();
}
diff --git a/src/plugins/platforms/ios/qiosfiledialog.h b/src/plugins/platforms/ios/qiosfiledialog.h
index 937b56e2f6..0b56bd20bf 100644
--- a/src/plugins/platforms/ios/qiosfiledialog.h
+++ b/src/plugins/platforms/ios/qiosfiledialog.h
@@ -43,10 +43,10 @@
#include <QtCore/qeventloop.h>
#include <qpa/qplatformdialoghelper.h>
-QT_BEGIN_NAMESPACE
-
Q_FORWARD_DECLARE_OBJC_CLASS(UIViewController);
+QT_BEGIN_NAMESPACE
+
class QIOSFileDialog : public QPlatformFileDialogHelper
{
public:
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index 0fe81ceb91..f74e3004cc 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -61,13 +61,10 @@ class QPlatformScreen;
bool isQtApplication();
-CGRect toCGRect(const QRectF &rect);
-QRectF fromCGRect(const CGRect &rect);
-CGPoint toCGPoint(const QPointF &point);
-QPointF fromCGPoint(const CGPoint &point);
-
+#ifndef Q_OS_TVOS
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
+#endif
int infoPlistValue(NSString* key, int defaultValue);
@@ -77,6 +74,8 @@ QT_END_NAMESPACE
+ (id)currentFirstResponder;
@end
+QT_BEGIN_NAMESPACE
+
class FirstResponderCandidate : public QScopedValueRollback<UIResponder *>
{
public:
@@ -87,4 +86,6 @@ private:
static UIResponder *s_firstResponderCandidate;
};
+QT_END_NAMESPACE
+
#endif // QIOSGLOBAL_H
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index c2f3d6b9e1..1482ffc7af 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -58,26 +58,7 @@ bool isQtApplication()
return isQt;
}
-CGRect toCGRect(const QRectF &rect)
-{
- return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-QRectF fromCGRect(const CGRect &rect)
-{
- return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
-CGPoint toCGPoint(const QPointF &point)
-{
- return CGPointMake(point.x(), point.y());
-}
-
-QPointF fromCGPoint(const CGPoint &point)
-{
- return QPointF(point.x, point.y);
-}
-
+#ifndef Q_OS_TVOS
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation)
{
Qt::ScreenOrientation qtOrientation;
@@ -124,6 +105,7 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
}
return uiOrientation;
}
+#endif
int infoPlistValue(NSString* key, int defaultValue)
{
@@ -132,6 +114,8 @@ int infoPlistValue(NSString* key, int defaultValue)
return value ? [value intValue] : defaultValue;
}
+QT_END_NAMESPACE
+
// -------------------------------------------------------------------------
@interface QtFirstResponderEvent : UIEvent
@@ -182,6 +166,8 @@ int infoPlistValue(NSString* key, int defaultValue)
}
@end
+QT_BEGIN_NAMESPACE
+
FirstResponderCandidate::FirstResponderCandidate(UIResponder *responder)
: QScopedValueRollback<UIResponder *>(s_firstResponderCandidate, responder)
{
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index ffb21d6afe..966d1a7e80 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -52,13 +52,13 @@ const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView";
const char kImePlatformDataHideShortcutsBar[] = "hideShortcutsBar";
const char kImePlatformDataReturnKeyType[] = "returnKeyType";
-QT_BEGIN_NAMESPACE
-
@class QIOSLocaleListener;
@class QIOSKeyboardListener;
@class QIOSTextInputResponder;
@protocol KeyboardState;
+QT_BEGIN_NAMESPACE
+
struct KeyboardState
{
KeyboardState() :
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index ef93d68cf0..68088540c6 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -97,14 +97,14 @@ static QUIView *focusView()
@interface QIOSKeyboardListener : UIGestureRecognizer <UIGestureRecognizerDelegate> {
@private
- QIOSInputContext *m_context;
+ QT_PREPEND_NAMESPACE(QIOSInputContext) *m_context;
}
@property BOOL hasDeferredScrollToCursor;
@end
@implementation QIOSKeyboardListener
-- (id)initWithQIOSInputContext:(QIOSInputContext *)context
+- (id)initWithQIOSInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)context
{
if (self = [super initWithTarget:self action:@selector(gestureStateChanged:)]) {
@@ -117,6 +117,7 @@ static QUIView *focusView()
self.cancelsTouchesInView = NO;
self.delaysTouchesEnded = NO;
+#ifndef Q_OS_TVOS
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
@@ -134,6 +135,7 @@ static QUIView *focusView()
[notificationCenter addObserver:self
selector:@selector(keyboardDidChangeFrame:)
name:UIKeyboardDidChangeFrameNotification object:nil];
+#endif
}
return self;
@@ -289,6 +291,8 @@ static QUIView *focusView()
// -------------------------------------------------------------------------
+QT_BEGIN_NAMESPACE
+
Qt::InputMethodQueries ImeState::update(Qt::InputMethodQueries properties)
{
if (!properties)
@@ -377,6 +381,9 @@ void QIOSInputContext::clearCurrentFocusObject()
void QIOSInputContext::updateKeyboardState(NSNotification *notification)
{
+#ifdef Q_OS_TVOS
+ Q_UNUSED(notification);
+#else
static CGRect currentKeyboardRect = CGRectZero;
KeyboardState previousState = m_keyboardState;
@@ -412,7 +419,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification)
m_keyboardState.animationDuration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
m_keyboardState.keyboardAnimating = m_keyboardState.animationDuration > 0 && !atEndOfKeyboardTransition;
- qImDebug() << qPrintable(QString::fromNSString(notification.name)) << "from" << fromCGRect(frameBegin) << "to" << fromCGRect(frameEnd)
+ qImDebug() << qPrintable(QString::fromNSString(notification.name)) << "from" << QRectF::fromCGRect(frameBegin) << "to" << QRectF::fromCGRect(frameEnd)
<< "(curve =" << m_keyboardState.animationCurve << "duration =" << m_keyboardState.animationDuration << "s)";
} else {
qImDebug("No notification to update keyboard state based on, just updating keyboard rect");
@@ -421,7 +428,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification)
if (!focusView() || CGRectIsEmpty(currentKeyboardRect))
m_keyboardState.keyboardRect = QRectF();
else // QInputmethod::keyboardRectangle() is documented to be in window coordinates.
- m_keyboardState.keyboardRect = fromCGRect([focusView() convertRect:currentKeyboardRect fromView:nil]);
+ m_keyboardState.keyboardRect = QRectF::fromCGRect([focusView() convertRect:currentKeyboardRect fromView:nil]);
// Emit for all changed properties
if (m_keyboardState.keyboardVisible != previousState.keyboardVisible)
@@ -430,6 +437,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification)
emitAnimatingChanged();
if (m_keyboardState.keyboardRect != previousState.keyboardRect)
emitKeyboardRectChanged();
+#endif
}
bool QIOSInputContext::isInputPanelVisible() const
@@ -549,7 +557,11 @@ void QIOSInputContext::scroll(int y)
if (keyboardScrollIsActive && !originalWindowLevels.contains(window))
originalWindowLevels.insert(window, window.windowLevel);
+#ifndef Q_OS_TVOS
UIWindowLevel windowLevelAdjustment = keyboardScrollIsActive ? UIWindowLevelStatusBar : 0;
+#else
+ UIWindowLevel windowLevelAdjustment = 0;
+#endif
window.windowLevel = originalWindowLevels.value(window) + windowLevelAdjustment;
if (!keyboardScrollIsActive)
@@ -703,3 +715,5 @@ QLocale QIOSInputContext::locale() const
{
return QLocale(QString::fromNSString([[NSLocale currentLocale] objectForKey:NSLocaleIdentifier]));
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h
index 35f12bcb56..54c1a1dcb7 100644
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -47,7 +47,9 @@
#include <QtCore/private/qfactoryloader_p.h>
#include "qiosapplicationstate.h"
+#ifndef Q_OS_TVOS
#include "qiostextinputoverlay.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -71,7 +73,9 @@ public:
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
+#ifndef QT_NO_CLIPBOARD
QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE;
+#endif
QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE;
QPlatformServices *services() const Q_DECL_OVERRIDE;
@@ -84,7 +88,9 @@ public:
QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
QTouchDevice *touchDevice();
+#ifndef QT_NO_ACCESSIBILITY
QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE;
+#endif
// Called from Objective-C class QIOSScreenTracker, which can't be friended
void addScreen(QPlatformScreen *screen) { screenAdded(screen); }
@@ -105,14 +111,18 @@ public:
private:
QPlatformFontDatabase *m_fontDatabase;
+#ifndef Q_OS_TVOS
QPlatformClipboard *m_clipboard;
+#endif
QPlatformInputContext *m_inputContext;
QTouchDevice *m_touchDevice;
QIOSApplicationState m_applicationState;
QIOSServices *m_platformServices;
mutable QPlatformAccessibility *m_accessibility;
QFactoryLoader *m_optionalPlugins;
+#ifndef Q_OS_TVOS
QIOSTextInputOverlay m_textInputOverlay;
+#endif
bool m_debugWindowManagement;
};
@@ -120,4 +130,3 @@ private:
QT_END_NAMESPACE
#endif
-
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index a9435ef15a..e5b4d6da85 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -45,7 +45,9 @@
#include "qiosscreen.h"
#include "qiosplatformaccessibility.h"
#include "qioscontext.h"
+#ifndef Q_OS_TVOS
#include "qiosclipboard.h"
+#endif
#include "qiosinputcontext.h"
#include "qiostheme.h"
#include "qiosservices.h"
@@ -56,8 +58,8 @@
#include <qoffscreensurface.h>
#include <qpa/qplatformoffscreensurface.h>
-#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
-#include <QtPlatformSupport/private/qmacmime_p.h>
+#include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h>
+#include <QtClipboardSupport/private/qmacmime_p.h>
#include <QDir>
#import <AudioToolbox/AudioServices.h>
@@ -73,7 +75,9 @@ QIOSIntegration *QIOSIntegration::instance()
QIOSIntegration::QIOSIntegration()
: m_fontDatabase(new QCoreTextFontDatabase)
+#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD)
, m_clipboard(new QIOSClipboard)
+#endif
, m_inputContext(0)
, m_platformServices(new QIOSServices)
, m_accessibility(0)
@@ -132,8 +136,10 @@ QIOSIntegration::~QIOSIntegration()
delete m_fontDatabase;
m_fontDatabase = 0;
+#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD)
delete m_clipboard;
m_clipboard = 0;
+#endif
QMacInternalPasteboardMime::destroyMimeTypes();
delete m_inputContext;
@@ -223,10 +229,16 @@ QPlatformFontDatabase * QIOSIntegration::fontDatabase() const
return m_fontDatabase;
}
+#ifndef QT_NO_CLIPBOARD
QPlatformClipboard *QIOSIntegration::clipboard() const
{
+#ifndef Q_OS_TVOS
return m_clipboard;
+#else
+ return QPlatformIntegration::clipboard();
+#endif
}
+#endif
QPlatformInputContext *QIOSIntegration::inputContext() const
{
@@ -274,12 +286,14 @@ QTouchDevice *QIOSIntegration::touchDevice()
return m_touchDevice;
}
+#ifndef QT_NO_ACCESSIBILITY
QPlatformAccessibility *QIOSIntegration::accessibility() const
{
if (!m_accessibility)
m_accessibility = new QIOSPlatformAccessibility;
return m_accessibility;
}
+#endif
QPlatformNativeInterface *QIOSIntegration::nativeInterface() const
{
diff --git a/src/plugins/platforms/ios/qiosmenu.h b/src/plugins/platforms/ios/qiosmenu.h
index dab5720d48..b7371a5f49 100644
--- a/src/plugins/platforms/ios/qiosmenu.h
+++ b/src/plugins/platforms/ios/qiosmenu.h
@@ -68,7 +68,9 @@ public:
void setRole(MenuRole role) Q_DECL_OVERRIDE;
void setCheckable(bool) Q_DECL_OVERRIDE {}
void setChecked(bool) Q_DECL_OVERRIDE {}
+#ifndef QT_NO_SHORTCUT
void setShortcut(const QKeySequence&) Q_DECL_OVERRIDE;
+#endif
void setEnabled(bool enabled) Q_DECL_OVERRIDE;
void setIconSize(int) Q_DECL_OVERRIDE {}
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 24d8559cc8..01cb3badea 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -304,10 +304,12 @@ void QIOSMenuItem::setRole(QPlatformMenuItem::MenuRole role)
m_role = role;
}
+#ifndef QT_NO_SHORTCUT
void QIOSMenuItem::setShortcut(const QKeySequence &sequence)
{
m_shortcut = sequence;
}
+#endif
void QIOSMenuItem::setEnabled(bool enabled)
{
@@ -551,6 +553,7 @@ QIOSMenuItemList QIOSMenu::filterFirstResponderActions(const QIOSMenuItemList &m
for (int i = 0; i < menuItems.count(); ++i) {
QIOSMenuItem *menuItem = menuItems.at(i);
+#ifndef QT_NO_SHORTCUT
QKeySequence shortcut = menuItem->m_shortcut;
if ((shortcut == QKeySequence::Cut && [responder canPerformAction:@selector(cut:) withSender:nil])
|| (shortcut == QKeySequence::Copy && [responder canPerformAction:@selector(copy:) withSender:nil])
@@ -564,6 +567,7 @@ QIOSMenuItemList QIOSMenu::filterFirstResponderActions(const QIOSMenuItemList &m
|| (shortcut == QKeySequence::Underline && [responder canPerformAction:@selector(toggleUnderline:) withSender:nil])) {
continue;
}
+#endif
filteredMenuItems.append(menuItem);
}
return filteredMenuItems;
@@ -574,7 +578,7 @@ void QIOSMenu::repositionMenu()
switch (m_effectiveMenuType) {
case EditMenu: {
UIView *view = reinterpret_cast<UIView *>(m_parentWindow->winId());
- [[UIMenuController sharedMenuController] setTargetRect:toCGRect(m_targetRect) inView:view];
+ [[UIMenuController sharedMenuController] setTargetRect:m_targetRect.toCGRect() inView:view];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
break; }
default:
diff --git a/src/plugins/platforms/ios/qiosmessagedialog.h b/src/plugins/platforms/ios/qiosmessagedialog.h
index 971c8d8b4d..e67e10a5e1 100644
--- a/src/plugins/platforms/ios/qiosmessagedialog.h
+++ b/src/plugins/platforms/ios/qiosmessagedialog.h
@@ -43,11 +43,11 @@
#include <QtCore/qeventloop.h>
#include <qpa/qplatformdialoghelper.h>
-QT_BEGIN_NAMESPACE
-
Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertController);
Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertAction);
+QT_BEGIN_NAMESPACE
+
class QIOSMessageDialog : public QPlatformMessageDialogHelper
{
public:
diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.h b/src/plugins/platforms/ios/qiosplatformaccessibility.h
index 2374457591..989eaa4fb8 100644
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.h
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.h
@@ -42,6 +42,8 @@
#include <qpa/qplatformaccessibility.h>
+#ifndef QT_NO_ACCESSIBILITY
+
QT_BEGIN_NAMESPACE
class QIOSPlatformAccessibility: public QPlatformAccessibility
@@ -56,3 +58,5 @@ public:
QT_END_NAMESPACE
#endif
+
+#endif
diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.mm b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
index 2ebe23c939..aef4216e03 100644
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.mm
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
@@ -39,6 +39,8 @@
#include "qiosplatformaccessibility.h"
+#ifndef QT_NO_ACCESSIBILITY
+
#include <QtGui/QtGui>
#include "qioswindow.h"
@@ -63,7 +65,7 @@ void invalidateCache(QAccessibleInterface *iface)
// when items get added or removed from the screen
foreach (QWindow *win, QGuiApplication::topLevelWindows()) {
if (win && win->handle()) {
- QIOSWindow *window = static_cast<QIOSWindow*>(win->handle());
+ QT_PREPEND_NAMESPACE(QIOSWindow) *window = static_cast<QT_PREPEND_NAMESPACE(QIOSWindow) *>(win->handle());
window->clearAccessibleCache();
}
}
@@ -85,3 +87,5 @@ void QIOSPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *even
break;
}
}
+
+#endif
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h
index cc83e7f3d2..9fcce42825 100644
--- a/src/plugins/platforms/ios/qiosscreen.h
+++ b/src/plugins/platforms/ios/qiosscreen.h
@@ -68,6 +68,8 @@ public:
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE;
void setOrientationUpdateMask(Qt::ScreenOrientations mask) Q_DECL_OVERRIDE;
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const override;
+
UIScreen *uiScreen() const;
UIWindow *uiWindow() const;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index dc14698146..c518f9111d 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -47,6 +47,7 @@
#include "quiview.h"
#include <QtGui/private/qwindow_p.h>
+#include <private/qcoregraphics_p.h>
#include <sys/sysctl.h>
@@ -143,21 +144,25 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
self = [super init];
if (self) {
m_screen = screen;
+#ifndef Q_OS_TVOS
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(orientationChanged:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+#endif
}
return self;
}
- (void)dealloc
{
+#ifndef Q_OS_TVOS
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+#endif
[super dealloc];
}
@@ -171,6 +176,8 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
// -------------------------------------------------------------------------
+QT_BEGIN_NAMESPACE
+
/*!
Returns the model identifier of the device.
@@ -256,9 +263,14 @@ void QIOSScreen::updateProperties()
QRect previousGeometry = m_geometry;
QRect previousAvailableGeometry = m_availableGeometry;
- m_geometry = fromCGRect(m_uiScreen.bounds).toRect();
- m_availableGeometry = fromCGRect(m_uiScreen.applicationFrame).toRect();
+ m_geometry = QRectF::fromCGRect(m_uiScreen.bounds).toRect();
+#ifdef Q_OS_TVOS
+ m_availableGeometry = m_geometry;
+#else
+ m_availableGeometry = QRectF::fromCGRect(m_uiScreen.applicationFrame).toRect();
+#endif
+#ifndef Q_OS_TVOS
if (m_uiScreen == [UIScreen mainScreen]) {
Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
@@ -286,6 +298,7 @@ void QIOSScreen::updateProperties()
m_availableGeometry = transform.mapRect(m_availableGeometry);
}
}
+#endif
if (m_geometry != previousGeometry) {
QRectF physicalGeometry;
@@ -298,7 +311,7 @@ void QIOSScreen::updateProperties()
// before being output on the physical display. We have to take this into account when
// computing the physical size. Note that unlike the native bounds, the physical size
// follows the primary orientation of the screen.
- physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, fromCGRect(m_uiScreen.nativeBounds).toRect());
+ physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, QRectF::fromCGRect(m_uiScreen.nativeBounds).toRect());
} else {
physicalGeometry = QRectF(0, 0, m_geometry.width() * devicePixelRatio(), m_geometry.height() * devicePixelRatio());
}
@@ -393,7 +406,7 @@ qreal QIOSScreen::devicePixelRatio() const
Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
{
CGRect nativeBounds =
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0)
+#if !defined(Q_OS_TVOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0)
QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 ? m_uiScreen.nativeBounds :
#endif
m_uiScreen.bounds;
@@ -406,6 +419,9 @@ Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
Qt::ScreenOrientation QIOSScreen::orientation() const
{
+#ifdef Q_OS_TVOS
+ return Qt::PrimaryOrientation;
+#else
// Auxiliary screens are always the same orientation as their primary orientation
if (m_uiScreen != [UIScreen mainScreen])
return Qt::PrimaryOrientation;
@@ -430,6 +446,7 @@ Qt::ScreenOrientation QIOSScreen::orientation() const
}
return toQtScreenOrientation(deviceOrientation);
+#endif
}
void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
@@ -443,6 +460,38 @@ void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
}
}
+QPixmap QIOSScreen::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ if (window && ![reinterpret_cast<id>(window) isKindOfClass:[UIView class]])
+ return QPixmap();
+
+ UIView *view = window ? reinterpret_cast<UIView *>(window) : m_uiWindow;
+
+ if (width < 0)
+ width = qMax(view.bounds.size.width - x, CGFloat(0));
+ if (height < 0)
+ height = qMax(view.bounds.size.height - y, CGFloat(0));
+
+ CGRect captureRect = [m_uiWindow convertRect:CGRectMake(x, y, width, height) fromView:view];
+ captureRect = CGRectIntersection(captureRect, m_uiWindow.bounds);
+
+ UIGraphicsBeginImageContextWithOptions(captureRect.size, NO, 0.0);
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ CGContextTranslateCTM(context, -captureRect.origin.x, -captureRect.origin.y);
+
+ // Draws the complete view hierarchy of m_uiWindow into the given rect, which
+ // needs to be the same aspect ratio as the m_uiWindow's size. Since we've
+ // translated the graphics context, and are potentially drawing into a smaller
+ // context than the full window, the resulting image will be a subsection of the
+ // full screen.
+ [m_uiWindow drawViewHierarchyInRect:m_uiWindow.bounds afterScreenUpdates:NO];
+
+ UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+
+ return QPixmap::fromImage(qt_mac_toQImage(screenshot.CGImage));
+}
+
UIScreen *QIOSScreen::uiScreen() const
{
return m_uiScreen;
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm
index 54c2e98d71..238d7addf6 100644
--- a/src/plugins/platforms/ios/qiostextinputoverlay.mm
+++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm
@@ -136,7 +136,7 @@ static void executeBlockWithoutAnimation(Block block)
// first responder, which is normally QIOSTextResponder.
QRectF cr = qApp->inputMethod()->cursorRectangle();
QRectF ar = qApp->inputMethod()->anchorRectangle();
- CGRect targetRect = toCGRect(cr.united(ar));
+ CGRect targetRect = cr.united(ar).toCGRect();
UIView *focusView = reinterpret_cast<UIView *>(qApp->focusWindow()->winId());
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:focusView];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
@@ -500,12 +500,12 @@ static void executeBlockWithoutAnimation(Block block)
QGuiApplication::styleHints()->setCursorFlashTime(0);
if (!_loupeLayer)
[self createLoupe];
- [self updateFocalPoint:fromCGPoint(_lastTouchPoint)];
+ [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)];
_loupeLayer.visible = YES;
break;
case UIGestureRecognizerStateChanged:
// Tell the sub class to move the loupe to the correct position
- [self updateFocalPoint:fromCGPoint(_lastTouchPoint)];
+ [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)];
break;
case UIGestureRecognizerStateEnded:
// Restore cursor blinking, and hide the loupe
@@ -530,12 +530,12 @@ static void executeBlockWithoutAnimation(Block block)
- (QPointF)focalPoint
{
- return fromCGPoint([_loupeLayer.targetView convertPoint:_loupeLayer.focalPoint toView:_focusView]);
+ return QPointF::fromCGPoint([_loupeLayer.targetView convertPoint:_loupeLayer.focalPoint toView:_focusView]);
}
- (void)setFocalPoint:(QPointF)point
{
- _loupeLayer.focalPoint = [_loupeLayer.targetView convertPoint:toCGPoint(point) fromView:_focusView];
+ _loupeLayer.focalPoint = [_loupeLayer.targetView convertPoint:point.toCGPoint() fromView:_focusView];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -552,7 +552,7 @@ static void executeBlockWithoutAnimation(Block block)
// If the touch point is accepted by the sub class (e.g touch on cursor), we start a
// press'n'hold timer that eventually will move the state to UIGestureRecognizerStateBegan.
- if ([self acceptTouchesBegan:fromCGPoint(_firstTouchPoint)])
+ if ([self acceptTouchesBegan:QPointF::fromCGPoint(_firstTouchPoint)])
_triggerStateBeganTimer.start();
else
self.state = UIGestureRecognizerStateFailed;
@@ -860,8 +860,8 @@ static void executeBlockWithoutAnimation(Block block)
// Adjust handles and input rect to match the new selection
QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
- CGRect cursorRect = toCGRect(QGuiApplication::inputMethod()->cursorRectangle());
- CGRect anchorRect = toCGRect(QGuiApplication::inputMethod()->anchorRectangle());
+ CGRect cursorRect = QGuiApplication::inputMethod()->cursorRectangle().toCGRect();
+ CGRect anchorRect = QGuiApplication::inputMethod()->anchorRectangle().toCGRect();
if (!_multiLine) {
// Resize the layer a bit bigger to ensure that the handles are
@@ -870,7 +870,7 @@ static void executeBlockWithoutAnimation(Block block)
inputRect.adjust(-margin / 2, -margin, margin / 2, margin);
}
- executeBlockWithoutAnimation(^{ _clipRectLayer.frame = toCGRect(inputRect); });
+ executeBlockWithoutAnimation(^{ _clipRectLayer.frame = inputRect.toCGRect(); });
_cursorLayer.cursorRectangle = [self.focusView.layer convertRect:cursorRect toLayer:_clipRectLayer];
_anchorLayer.cursorRectangle = [self.focusView.layer convertRect:anchorRect toLayer:_clipRectLayer];
_cursorLayer.visible = YES;
@@ -938,7 +938,7 @@ static void executeBlockWithoutAnimation(Block block)
}
QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
- QPointF touchPos = fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
+ QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
if (!inputRect.contains(touchPos))
self.state = UIGestureRecognizerStateFailed;
@@ -947,7 +947,7 @@ static void executeBlockWithoutAnimation(Block block)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
- QPointF touchPos = fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
+ QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
const QTransform mapToLocal = QGuiApplication::inputMethod()->inputItemTransform().inverted();
int cursorPosOnRelease = QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPos * mapToLocal).toInt();
diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h
index f7450df4c8..77be2cf2fe 100644
--- a/src/plugins/platforms/ios/qiostextresponder.h
+++ b/src/plugins/platforms/ios/qiostextresponder.h
@@ -42,19 +42,23 @@
#include <QtCore/qstring.h>
#include <QtGui/qevent.h>
+QT_BEGIN_NAMESPACE
+
class QIOSInputContext;
+QT_END_NAMESPACE
+
@interface QIOSTextInputResponder : UIResponder <UITextInputTraits, UIKeyInput, UITextInput>
{
@private
- QIOSInputContext *m_inputContext;
- QInputMethodQueryEvent *m_configuredImeState;
+ QT_PREPEND_NAMESPACE(QIOSInputContext) *m_inputContext;
+ QT_PREPEND_NAMESPACE(QInputMethodQueryEvent) *m_configuredImeState;
QString m_markedText;
BOOL m_inSendEventToFocusObject;
BOOL m_inSelectionChange;
}
-- (id)initWithInputContext:(QIOSInputContext *)context;
+- (id)initWithInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)context;
- (BOOL)needsKeyboardReconfigure:(Qt::InputMethodQueries)updatedProperties;
- (void)notifyInputDelegate:(Qt::InputMethodQueries)updatedProperties;
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 009f3f8a20..eab6792266 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -163,7 +163,7 @@
@implementation QIOSTextInputResponder
-- (id)initWithInputContext:(QIOSInputContext *)inputContext
+- (id)initWithInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)inputContext
{
if (!(self = [self init]))
return self;
@@ -236,6 +236,8 @@
self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease];
if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>()))
self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease];
+
+#ifndef Q_OS_TVOS
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) {
if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) {
// According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar.
@@ -247,6 +249,7 @@
self.inputAssistantItem.trailingBarButtonGroups = @[trailing];
}
}
+#endif
self.undoManager.groupsByEvent = NO;
[self rebuildUndoStack];
@@ -691,11 +694,7 @@
if (markedTextFormat.isEmpty()) {
// There seems to be no way to query how the preedit text
// should be drawn. So we need to hard-code the color.
- QSysInfo::MacVersion iosVersion = QSysInfo::MacintoshVersion;
- if (iosVersion < QSysInfo::MV_IOS_7_0)
- markedTextFormat.setBackground(QColor(235, 239, 247));
- else
- markedTextFormat.setBackground(QColor(206, 221, 238));
+ markedTextFormat.setBackground(QColor(206, 221, 238));
}
QList<QInputMethodEvent::Attribute> attrs;
@@ -823,7 +822,7 @@
[self sendEventToFocusObject:e];
}
- return toCGRect(startRect.united(endRect));
+ return startRect.united(endRect).toCGRect();
}
- (NSArray *)selectionRectsForRange:(UITextRange *)range
@@ -841,7 +840,7 @@
// Assume for now that position is always the same as
// cursor index until a better API is in place:
QRectF cursorRect = qApp->inputMethod()->cursorRectangle();
- return toCGRect(cursorRect);
+ return cursorRect.toCGRect();
}
- (void)replaceRange:(UITextRange *)range withText:(NSString *)text
@@ -908,6 +907,7 @@
// text instead of just guessing...
}
+#ifndef Q_OS_TVOS
- (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction
{
Q_UNUSED(position);
@@ -927,6 +927,7 @@
return [NSDictionary dictionary];
return [NSDictionary dictionaryWithObject:uifont forKey:NSFontAttributeName];
}
+#endif
- (NSDictionary *)markedTextStyle
{
diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm
index 486c146af9..91980d3f35 100644
--- a/src/plugins/platforms/ios/qiostheme.mm
+++ b/src/plugins/platforms/ios/qiostheme.mm
@@ -44,16 +44,18 @@
#include <QtGui/QFont>
-#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <UIKit/UIFont.h>
#include <UIKit/UIInterface.h>
+#ifndef Q_OS_TVOS
#include "qiosmenu.h"
#include "qiosfiledialog.h"
#include "qiosmessagedialog.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -80,12 +82,20 @@ const QPalette *QIOSTheme::palette(QPlatformTheme::Palette type) const
QPlatformMenuItem* QIOSTheme::createPlatformMenuItem() const
{
+#ifdef Q_OS_TVOS
+ return 0;
+#else
return new QIOSMenuItem();
+#endif
}
QPlatformMenu* QIOSTheme::createPlatformMenu() const
{
+#ifdef Q_OS_TVOS
+ return 0;
+#else
return new QIOSMenu();
+#endif
}
bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
@@ -102,12 +112,14 @@ bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
QPlatformDialogHelper *QIOSTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const
{
switch (type) {
+#ifndef Q_OS_TVOS
case FileDialog:
return new QIOSFileDialog();
break;
case MessageDialog:
return new QIOSMessageDialog();
break;
+#endif
default:
return 0;
}
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h
index e97aeb32ed..07d5535e1a 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.h
+++ b/src/plugins/platforms/ios/qiosviewcontroller.h
@@ -38,20 +38,27 @@
****************************************************************************/
#import <UIKit/UIKit.h>
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_NAMESPACE
class QIOSScreen;
+QT_END_NAMESPACE
+
@interface QIOSViewController : UIViewController
-- (id)initWithQIOSScreen:(QIOSScreen *)screen;
+- (id)initWithQIOSScreen:(QT_PREPEND_NAMESPACE(QIOSScreen) *)screen;
- (void)updateProperties;
+#ifndef Q_OS_TVOS
@property (nonatomic, assign) UIInterfaceOrientation lockedOrientation;
// UIViewController
@property (nonatomic, assign) BOOL prefersStatusBarHidden;
@property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation;
@property (nonatomic, assign) UIStatusBarStyle preferredStatusBarStyle;
+#endif
@end
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index fd88664d15..c47b6d68b1 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -37,6 +37,7 @@
**
****************************************************************************/
+#include "qiosglobal.h"
#import "qiosviewcontroller.h"
#include <QtCore/qscopedvaluerollback.h>
@@ -57,7 +58,7 @@
@interface QIOSViewController () {
@public
- QPointer<QIOSScreen> m_screen;
+ QPointer<QT_PREPEND_NAMESPACE(QIOSScreen)> m_screen;
BOOL m_updatingProperties;
QMetaObject::Connection m_focusWindowChangeConnection;
}
@@ -125,7 +126,7 @@
{
Q_UNUSED(subview);
- QIOSScreen *screen = self.qtViewController->m_screen;
+ QT_PREPEND_NAMESPACE(QIOSScreen) *screen = self.qtViewController->m_screen;
// The 'window' property of our view is not valid until the window
// has been shown, so we have to access it through the QIOSScreen.
@@ -228,42 +229,27 @@
@implementation QIOSViewController
+#ifndef Q_OS_TVOS
@synthesize prefersStatusBarHidden;
@synthesize preferredStatusBarUpdateAnimation;
@synthesize preferredStatusBarStyle;
+#endif
-- (id)initWithQIOSScreen:(QIOSScreen *)screen
+- (id)initWithQIOSScreen:(QT_PREPEND_NAMESPACE(QIOSScreen) *)screen
{
if (self = [self init]) {
m_screen = screen;
-#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_7_0)
- QSysInfo::MacVersion iosVersion = QSysInfo::MacintoshVersion;
-
- // We prefer to keep the root viewcontroller in fullscreen layout, so that
- // we don't have to compensate for the viewcontroller position. This also
- // gives us the same behavior on iOS 5/6 as on iOS 7, where full screen layout
- // is the only way.
- if (iosVersion < QSysInfo::MV_IOS_7_0)
- self.wantsFullScreenLayout = YES;
-
- // Use translucent statusbar by default on iOS6 iPhones (unless the user changed
- // the default in the Info.plist), so that windows placed under the stausbar are
- // still visible, just like on iOS7.
- if (screen->uiScreen() == [UIScreen mainScreen]
- && iosVersion >= QSysInfo::MV_IOS_6_0 && iosVersion < QSysInfo::MV_IOS_7_0
- && [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone
- && [UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleDefault)
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
-#endif
- self.lockedOrientation = UIInterfaceOrientationUnknown;
self.changingOrientation = NO;
+#ifndef Q_OS_TVOS
+ self.lockedOrientation = UIInterfaceOrientationUnknown;
// Status bar may be initially hidden at startup through Info.plist
self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false);
self.preferredStatusBarUpdateAnimation = UIStatusBarAnimationNone;
self.preferredStatusBarStyle = UIStatusBarStyle(infoPlistValue(@"UIStatusBarStyle", UIStatusBarStyleDefault));
+#endif
m_focusWindowChangeConnection = QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() {
[self updateProperties];
@@ -288,6 +274,7 @@
{
[super viewDidLoad];
+#ifndef Q_OS_TVOS
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(willChangeStatusBarFrame:)
name:UIApplicationWillChangeStatusBarFrameNotification
@@ -296,6 +283,7 @@
[center addObserver:self selector:@selector(didChangeStatusBarOrientation:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:[UIApplication sharedApplication]];
+#endif
}
- (void)viewDidUnload
@@ -308,10 +296,13 @@
- (BOOL)shouldAutorotate
{
+#ifndef Q_OS_TVOS
return m_screen && m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
+#else
+ return NO;
+#endif
}
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)
- (NSUInteger)supportedInterfaceOrientations
{
// As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated:
@@ -322,15 +313,6 @@
// supportedInterfaceOrientations says, which states that the method should not return 0.
return [self shouldAutorotate] ? UIInterfaceOrientationMaskAll : 0;
}
-#endif
-
-#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0)
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- Q_UNUSED(interfaceOrientation);
- return [self shouldAutorotate];
-}
-#endif
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
{
@@ -439,6 +421,7 @@
// All decisions are based on the the top level window
focusWindow = qt_window_private(focusWindow)->topLevelWindow();
+#ifndef Q_OS_TVOS
UIApplication *uiApplication = [UIApplication sharedApplication];
// -------------- Status bar style and visbility ---------------
@@ -447,30 +430,16 @@
if (focusWindow->flags() & Qt::MaximizeUsingFullscreenGeometryHint)
self.preferredStatusBarStyle = UIStatusBarStyleDefault;
else
- self.preferredStatusBarStyle = QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0 ?
- UIStatusBarStyleLightContent : UIStatusBarStyleBlackTranslucent;
-
- if (self.preferredStatusBarStyle != oldStatusBarStyle) {
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0)
- [self setNeedsStatusBarAppearanceUpdate];
- else
- [uiApplication setStatusBarStyle:self.preferredStatusBarStyle];
- }
+ self.preferredStatusBarStyle = UIStatusBarStyleLightContent;
+
+ if (self.preferredStatusBarStyle != oldStatusBarStyle)
+ [self setNeedsStatusBarAppearanceUpdate];
bool currentStatusBarVisibility = self.prefersStatusBarHidden;
self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen;
if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
- [self setNeedsStatusBarAppearanceUpdate];
- } else
-#endif
- {
- [uiApplication setStatusBarHidden:self.prefersStatusBarHidden
- withAnimation:self.preferredStatusBarUpdateAnimation];
- }
-
+ [self setNeedsStatusBarAppearanceUpdate];
[self.view setNeedsLayout];
}
@@ -516,6 +485,7 @@
[UIViewController attemptRotationToDeviceOrientation];
}
}
+#endif
}
@end
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index afc2f0f89d..81fad420f6 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -48,10 +48,10 @@
class QIOSContext;
class QIOSWindow;
-QT_BEGIN_NAMESPACE
-
@class QUIView;
+QT_BEGIN_NAMESPACE
+
class QIOSWindow : public QObject, public QPlatformWindow
{
Q_OBJECT
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 8099d13147..8ff0dfbd5f 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -54,6 +54,8 @@
#include <QtDebug>
+QT_BEGIN_NAMESPACE
+
QIOSWindow::QIOSWindow(QWindow *window)
: QPlatformWindow(window)
, m_view([[QUIView alloc] initWithQIOSWindow:this])
@@ -211,7 +213,7 @@ void QIOSWindow::applyGeometry(const QRect &rect)
// The baseclass takes care of persisting this for us.
QPlatformWindow::setGeometry(rect);
- m_view.frame = toCGRect(rect);
+ m_view.frame = rect.toCGRect();
// iOS will automatically trigger -[layoutSubviews:] for resize,
// but not for move, so we force it just in case.
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.h b/src/plugins/platforms/ios/quiaccessibilityelement.h
index 1a9ae2a1a7..03abf5407e 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.h
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.h
@@ -43,6 +43,8 @@
#import <UIKit/UIKit.h>
#import <QtGui/QtGui>
+#ifndef QT_NO_ACCESSIBILITY
+
@interface QMacAccessibilityElement : UIAccessibilityElement
{}
@@ -54,3 +56,4 @@
@end
#endif
+#endif
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm
index 39a879fc23..a26ba61b3c 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -39,6 +39,8 @@
#include "quiaccessibilityelement.h"
+#ifndef QT_NO_ACCESSIBILITY
+
#include "private/qaccessiblecache_p.h"
@implementation QMacAccessibilityElement
@@ -61,7 +63,7 @@
QAccessibleCache *cache = QAccessibleCache::instance();
- QMacAccessibilityElement *element = cache->elementForId(anId);
+ QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element = cache->elementForId(anId);
if (!element) {
Q_ASSERT(QAccessible::accessibleInterface(anId));
element = [[self alloc] initWithId:anId withAccessibilityContainer: view];
@@ -221,3 +223,5 @@
}
@end
+
+#endif
diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h
index fdaae943d8..1500f0b41c 100644
--- a/src/plugins/platforms/ios/quiview.h
+++ b/src/plugins/platforms/ios/quiview.h
@@ -44,14 +44,18 @@
#include <qpa/qwindowsysteminterface.h>
+QT_BEGIN_NAMESPACE
+
class QIOSWindow;
+QT_END_NAMESPACE
+
@class QIOSViewController;
@interface QUIView : UIView
{
@public
- QIOSWindow *m_qioswindow;
+ QT_PREPEND_NAMESPACE(QIOSWindow) *m_qioswindow;
@private
QHash<UITouch *, QWindowSystemInterface::TouchPoint> m_activeTouches;
int m_nextTouchId;
@@ -60,7 +64,7 @@ class QIOSWindow;
NSMutableArray *m_accessibleElements;
};
-- (id)initWithQIOSWindow:(QIOSWindow *)window;
+- (id)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window;
- (void)sendUpdatedExposeEvent;
- (BOOL)isActiveWindow;
@end
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 9c7acc9278..2a1444e9e5 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -44,10 +44,13 @@
#include "qiosviewcontroller.h"
#include "qiostextresponder.h"
#include "qioswindow.h"
+#ifndef Q_OS_TVOS
#include "qiosmenu.h"
+#endif
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qwindow_p.h>
+#include <qpa/qwindowsysteminterface_p.h>
@implementation QUIView
@@ -56,9 +59,9 @@
return [CAEAGLLayer class];
}
-- (id)initWithQIOSWindow:(QIOSWindow *)window
+- (id)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window
{
- if (self = [self initWithFrame:toCGRect(window->geometry())])
+ if (self = [self initWithFrame:window->geometry().toCGRect()])
m_qioswindow = window;
m_accessibleElements = [[NSMutableArray alloc] init];
@@ -78,7 +81,9 @@
if (isQtApplication())
self.hidden = YES;
+#ifndef Q_OS_TVOS
self.multipleTouchEnabled = YES;
+#endif
if (QIOSIntegration::instance()->debugWindowManagement()) {
static CGFloat hue = 0.0;
@@ -149,7 +154,7 @@
// from what we end up with after applying window constraints.
QRect requestedGeometry = m_qioswindow->geometry();
- QRect actualGeometry = fromCGRect(self.frame).toRect();
+ QRect actualGeometry = QRectF::fromCGRect(self.frame).toRect();
// Persist the actual/new geometry so that QWindow::geometry() can
// be queried on the resize event.
@@ -159,8 +164,7 @@
requestedGeometry : qt_window_private(m_qioswindow->window())->geometry;
QWindow *window = m_qioswindow->window();
- QWindowSystemInterface::handleGeometryChange(window, actualGeometry, previousGeometry);
- QWindowSystemInterface::flushWindowSystemEvents(window->inherits("QWidgetWindow") ? QEventLoop::ExcludeUserInputEvents : QEventLoop::AllEvents);
+ QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(window, actualGeometry, previousGeometry);
if (actualGeometry.size() != previousGeometry.size()) {
// Trigger expose event on resize
@@ -184,7 +188,7 @@
QRegion region;
if (m_qioswindow->isExposed()) {
- QSize bounds = fromCGRect(self.layer.bounds).toRect().size();
+ QSize bounds = QRectF::fromCGRect(self.layer.bounds).toRect().size();
Q_ASSERT(m_qioswindow->geometry().size() == bounds);
Q_ASSERT(self.hidden == !m_qioswindow->window()->isVisible());
@@ -192,8 +196,7 @@
region = QRect(QPoint(), bounds);
}
- QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region);
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), region);
}
// -------------------------------------------------------------------------
@@ -218,13 +221,10 @@
qImDebug() << m_qioswindow->window() << "became first responder";
- if (qGuiApp->focusWindow() != m_qioswindow->window()) {
- QWindowSystemInterface::handleWindowActivated(m_qioswindow->window());
- QWindowSystemInterface::flushWindowSystemEvents();
- } else {
- qImDebug() << m_qioswindow->window()
- << "already active, not sending window activation";
- }
+ if (qGuiApp->focusWindow() != m_qioswindow->window())
+ QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window());
+ else
+ qImDebug() << m_qioswindow->window() << "already active, not sending window activation";
return YES;
}
@@ -259,10 +259,8 @@
qImDebug() << m_qioswindow->window() << "resigned first responder";
UIResponder *newResponder = FirstResponderCandidate::currentCandidate();
- if ([self responderShouldTriggerWindowDeactivation:newResponder]) {
- QWindowSystemInterface::handleWindowActivated(0);
- QWindowSystemInterface::flushWindowSystemEvents();
- }
+ if ([self responderShouldTriggerWindowDeactivation:newResponder])
+ QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(0);
return YES;
}
@@ -324,7 +322,8 @@
// Touch positions are expected to be in QScreen global coordinates, and
// as we already have the QWindow positioned at the right place, we can
// just map from the local view position to global coordinates.
- QPoint localViewPosition = fromCGPoint([uiTouch locationInView:self]).toPoint();
+ // tvOS: all touches start at the center of the screen and move from there.
+ QPoint localViewPosition = QPointF::fromCGPoint([uiTouch locationInView:self]).toPoint();
QPoint globalScreenPosition = m_qioswindow->mapToGlobal(localViewPosition);
touchPoint.area = QRectF(globalScreenPosition, QSize(0, 0));
@@ -351,10 +350,8 @@
- (void)sendTouchEventWithTimestamp:(ulong)timeStamp
{
- // Send touch event synchronously
QIOSIntegration *iosIntegration = QIOSIntegration::instance();
- QWindowSystemInterface::handleTouchEvent(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values());
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values());
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -432,22 +429,80 @@
NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime];
- // Send cancel touch event synchronously
QIOSIntegration *iosIntegration = static_cast<QIOSIntegration *>(QGuiApplicationPrivate::platformIntegration());
- QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::handleTouchCancelEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
+}
+
+- (int)mapPressTypeToKey:(UIPress*)press
+{
+ switch (press.type) {
+ case UIPressTypeUpArrow: return Qt::Key_Up;
+ case UIPressTypeDownArrow: return Qt::Key_Down;
+ case UIPressTypeLeftArrow: return Qt::Key_Left;
+ case UIPressTypeRightArrow: return Qt::Key_Right;
+ case UIPressTypeSelect: return Qt::Key_Select;
+ case UIPressTypeMenu: return Qt::Key_Menu;
+ case UIPressTypePlayPause: return Qt::Key_MediaTogglePlayPause;
+ }
+ return Qt::Key_unknown;
+}
+
+- (bool)processPresses:(NSSet *)presses withType:(QEvent::Type)type {
+ // Presses on Menu button will generate a Menu key event. By default, not handling
+ // this event will cause the application to return to Headboard (tvOS launcher).
+ // When handling the event (for example, as a back button), both press and
+ // release events must be handled accordingly.
+
+ bool handled = false;
+ for (UIPress* press in presses) {
+ int key = [self mapPressTypeToKey:press];
+ if (key == Qt::Key_unknown)
+ continue;
+ if (QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), type, key, Qt::NoModifier))
+ handled = true;
+ }
+
+ return handled;
+}
+
+- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+ if (![self processPresses:presses withType:QEvent::KeyPress])
+ [super pressesBegan:presses withEvent:event];
+}
+
+- (void)pressesChanged:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+ if (![self processPresses:presses withType:QEvent::KeyPress])
+ [super pressesChanged:presses withEvent:event];
+}
+
+- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+ if (![self processPresses:presses withType:QEvent::KeyRelease])
+ [super pressesEnded:presses withEvent:event];
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
+#ifndef Q_OS_TVOS
// Check first if QIOSMenu should handle the action before continuing up the responder chain
return [QIOSMenu::menuActionTarget() targetForAction:action withSender:sender] != 0;
+#else
+ Q_UNUSED(action)
+ Q_UNUSED(sender)
+ return false;
+#endif
}
- (id)forwardingTargetForSelector:(SEL)selector
{
Q_UNUSED(selector)
+#ifndef Q_OS_TVOS
return QIOSMenu::menuActionTarget();
+#else
+ return nil;
+#endif
}
@end
@@ -457,7 +512,7 @@
- (QWindow *)qwindow
{
if ([self isKindOfClass:[QUIView class]]) {
- if (QIOSWindow *w = static_cast<QUIView *>(self)->m_qioswindow)
+ if (QT_PREPEND_NAMESPACE(QIOSWindow) *w = static_cast<QUIView *>(self)->m_qioswindow)
return w->window();
}
return nil;
@@ -484,5 +539,7 @@
@end
+#ifndef QT_NO_ACCESSIBILITY
// Include category as an alternative to using -ObjC (Apple QA1490)
#include "quiview_accessibility.mm"
+#endif
diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro
index b5de192346..e2fa31211d 100644
--- a/src/plugins/platforms/linuxfb/linuxfb.pro
+++ b/src/plugins/platforms/linuxfb/linuxfb.pro
@@ -1,12 +1,18 @@
TARGET = qlinuxfb
-QT += core-private gui-private platformsupport-private
+DEFINES += QT_NO_FOREACH
+
+QT += \
+ core-private gui-private \
+ service_support-private eventdispatcher_support-private \
+ fontdatabase_support-private fb_support-private
+
+qtHaveModule(input_support-private): \
+ QT += input_support-private
SOURCES = main.cpp qlinuxfbintegration.cpp qlinuxfbscreen.cpp
HEADERS = qlinuxfbintegration.h qlinuxfbscreen.h
-CONFIG += qpa/genericunixfontdatabase
-
OTHER_FILES += linuxfb.json
PLUGIN_TYPE = platforms
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
index 2037f29a5a..c1c235588e 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
@@ -40,30 +40,30 @@
#include "qlinuxfbintegration.h"
#include "qlinuxfbscreen.h"
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qfbvthandler_p.h>
-#include <QtPlatformSupport/private/qfbbackingstore_p.h>
-#include <QtPlatformSupport/private/qfbwindow_p.h>
-#include <QtPlatformSupport/private/qfbcursor_p.h>
+#include <QtFbSupport/private/qfbvthandler_p.h>
+#include <QtFbSupport/private/qfbbackingstore_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatforminputcontextfactory_p.h>
-#ifndef QT_NO_LIBINPUT
-#include <QtPlatformSupport/private/qlibinputhandler_p.h>
+#if QT_CONFIG(libinput)
+#include <QtInputSupport/private/qlibinputhandler_p.h>
#endif
-#if !defined(QT_NO_EVDEV) && !defined(Q_OS_ANDROID)
-#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
-#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
-#include <QtPlatformSupport/private/qevdevtouchmanager_p.h>
+#if QT_CONFIG(evdev) && !defined(Q_OS_ANDROID)
+#include <QtInputSupport/private/qevdevmousemanager_p.h>
+#include <QtInputSupport/private/qevdevkeyboardmanager_p.h>
+#include <QtInputSupport/private/qevdevtouchmanager_p.h>
#endif
-#if !defined(QT_NO_TSLIB) && !defined(Q_OS_ANDROID)
-#include <QtPlatformSupport/private/qtslib_p.h>
+#if QT_CONFIG(tslib) && !defined(Q_OS_ANDROID)
+#include <QtInputSupport/private/qtslib_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -140,7 +140,7 @@ QPlatformServices *QLinuxFbIntegration::services() const
void QLinuxFbIntegration::createInputHandlers()
{
-#ifndef QT_NO_LIBINPUT
+#if QT_CONFIG(libinput)
if (!qEnvironmentVariableIntValue("QT_QPA_FB_NO_LIBINPUT")) {
new QLibInputHandler(QLatin1String("libinput"), QString());
return;
@@ -148,13 +148,13 @@ void QLinuxFbIntegration::createInputHandlers()
#endif
bool useTslib = false;
-#ifndef QT_NO_TSLIB
+#if QT_CONFIG(tslib)
useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
if (useTslib)
new QTsLibMouseHandler(QLatin1String("TsLib"), QString());
#endif
-#if !defined(QT_NO_EVDEV) && !defined(Q_OS_ANDROID)
+#if QT_CONFIG(evdev) && !defined(Q_OS_ANDROID)
new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this);
new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
if (!useTslib)
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index 1fd2b84e37..246c959fd3 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -38,8 +38,8 @@
****************************************************************************/
#include "qlinuxfbscreen.h"
-#include <QtPlatformSupport/private/qfbcursor_p.h>
-#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
#include <QtCore/QFile>
#include <QtCore/QRegularExpression>
#include <QtGui/QPainter>
@@ -320,7 +320,7 @@ bool QLinuxFbScreen::initialize()
bool doSwitchToGraphicsMode = true;
// Parse arguments
- foreach (const QString &arg, mArgs) {
+ for (const QString &arg : qAsConst(mArgs)) {
QRegularExpressionMatch match;
if (arg == QLatin1String("nographicsmodeswitch"))
doSwitchToGraphicsMode = false;
@@ -412,11 +412,9 @@ QRegion QLinuxFbScreen::doRedraw()
if (!mBlitter)
mBlitter = new QPainter(&mFbScreenImage);
- const QVector<QRect> rects = touched.rects();
mBlitter->setCompositionMode(QPainter::CompositionMode_Source);
-
- for (int i = 0; i < rects.size(); ++i)
- mBlitter->drawImage(rects[i], *mScreenImage, rects[i]);
+ for (const QRect &rect : touched)
+ mBlitter->drawImage(rect, *mScreenImage, rect);
return touched;
}
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
index ada9c4d830..1e98191569 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
@@ -40,7 +40,7 @@
#ifndef QLINUXFBSCREEN_H
#define QLINUXFBSCREEN_H
-#include <QtPlatformSupport/private/qfbscreen_p.h>
+#include <QtFbSupport/private/qfbscreen_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
index 3aca27b555..8cfb68824e 100644
--- a/src/plugins/platforms/minimal/minimal.pro
+++ b/src/plugins/platforms/minimal/minimal.pro
@@ -1,6 +1,10 @@
TARGET = qminimal
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private fontdatabase_support-private
+
+DEFINES += QT_NO_FOREACH
SOURCES = main.cpp \
qminimalintegration.cpp \
@@ -10,9 +14,6 @@ HEADERS = qminimalintegration.h \
OTHER_FILES += minimal.json
-CONFIG += qpa/genericunixfontdatabase
-win32|darwin: DEFINES += QT_NO_FONTCONFIG
-
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
index 7224f4114c..03c72502cb 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.cpp
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -45,15 +45,15 @@
#include <qpa/qplatformwindow.h>
#if defined(Q_OS_WIN)
-#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
-#elif defined(QT_NO_FONTCONFIG)
-#include <qpa/qplatformfontdatabase.h>
+#include <QtFontDatabaseSupport/private/qbasicfontdatabase_p.h>
+#elif QT_CONFIG(fontconfig)
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
#else
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <qpa/qplatformfontdatabase.h>
#endif
#if !defined(Q_OS_WIN)
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
#elif defined(Q_OS_WINRT)
#include <QtCore/private/qeventdispatcher_winrt_p.h>
#else
@@ -67,7 +67,7 @@ static const char debugBackingStoreEnvironmentVariable[] = "QT_DEBUG_BACKINGSTOR
static inline unsigned parseOptions(const QStringList &paramList)
{
unsigned options = 0;
- foreach (const QString &param, paramList) {
+ for (const QString &param : paramList) {
if (param == QLatin1String("enable_fonts"))
options |= QMinimalIntegration::EnableFonts;
}
@@ -118,7 +118,7 @@ public:
QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
{
if (m_options & EnableFonts) {
-#ifndef QT_NO_FONTCONFIG
+#if QT_CONFIG(fontconfig)
if (!m_fontDatabase)
m_fontDatabase = new QGenericUnixFontDatabase;
#else
diff --git a/src/plugins/platforms/minimalegl/minimalegl.pro b/src/plugins/platforms/minimalegl/minimalegl.pro
index b8a91729fd..88466e7f36 100644
--- a/src/plugins/platforms/minimalegl/minimalegl.pro
+++ b/src/plugins/platforms/minimalegl/minimalegl.pro
@@ -1,6 +1,8 @@
TARGET = qminimalegl
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private fontdatabase_support-private egl_support-private
#DEFINES += QEGL_EXTRA_DEBUG
@@ -20,7 +22,7 @@ HEADERS = qminimaleglintegration.h \
qminimaleglbackingstore.h \
qminimaleglscreen.h
-CONFIG += egl qpa/genericunixfontdatabase
+CONFIG += egl
OTHER_FILES += \
minimalegl.json
diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
index 06008e00d8..c564e1e431 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
+++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
@@ -42,15 +42,15 @@
#include "qminimaleglwindow.h"
#include "qminimaleglbackingstore.h"
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
#if defined(Q_OS_UNIX)
-# include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+# include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
#elif defined(Q_OS_WINRT)
# include <QtCore/private/qeventdispatcher_winrt_p.h>
# include <QtGui/qpa/qwindowsysteminterface.h>
#elif defined(Q_OS_WIN)
-# include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
+# include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
#endif
#include <qpa/qplatformwindow.h>
diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
index e8a9641224..d3d091fab7 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
+++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
@@ -40,8 +40,8 @@
#include "qminimaleglscreen.h"
#include "qminimaleglwindow.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglplatformcontext_p.h>
#ifdef Q_OPENKODE
#include <KD/kd.h>
diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.h b/src/plugins/platforms/minimalegl/qminimaleglscreen.h
index 4b53bbd39a..ba605835a8 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglscreen.h
+++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.h
@@ -44,7 +44,7 @@
#include <QtCore/QTextStream>
-#include <QtPlatformSupport/private/qt_egl_p.h>
+#include <QtEglSupport/private/qt_egl_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/mirclient/mirclient.pro b/src/plugins/platforms/mirclient/mirclient.pro
index d5d35f1632..0ba63601a9 100644
--- a/src/plugins/platforms/mirclient/mirclient.pro
+++ b/src/plugins/platforms/mirclient/mirclient.pro
@@ -1,16 +1,16 @@
TARGET = qmirclient
-QT += core-private gui-private platformsupport-private dbus
-
-CONFIG += qpa/genericunixfontdatabase
+QT += \
+ core-private gui-private dbus \
+ theme_support-private eventdispatcher_support-private \
+ fontdatabase_support-private egl_support-private
DEFINES += MESA_EGL_NO_X11_HEADERS
# CONFIG += c++11 # only enables C++0x
QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Werror -Wall
QMAKE_LFLAGS += -std=c++11 -Wl,-no-undefined
-CONFIG += link_pkgconfig
-PKGCONFIG += egl mirclient ubuntu-platform-api
+QMAKE_USE_PRIVATE += mirclient
SOURCES = \
qmirclientbackingstore.cpp \
diff --git a/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp b/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp
index 465ad355b9..a4bb8864ab 100644
--- a/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp
@@ -43,7 +43,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLTexture>
#include <QtGui/QMatrix4x4>
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/qopengltextureblitter.h>
#include <QtGui/qopenglfunctions.h>
QMirClientBackingStore::QMirClientBackingStore(QWindow* window)
@@ -76,7 +76,7 @@ void QMirClientBackingStore::flush(QWindow* window, const QRegion& region, const
mBlitter->create();
mBlitter->bind();
- mBlitter->setSwizzleRB(true);
+ mBlitter->setRedBlueSwizzle(true);
mBlitter->blit(mTexture->textureId(), QMatrix4x4(), QOpenGLTextureBlitter::OriginTopLeft);
mBlitter->release();
@@ -100,7 +100,7 @@ void QMirClientBackingStore::updateTexture()
QRegion fixed;
QRect imageRect = mImage.rect();
- Q_FOREACH (const QRect &rect, mDirty.rects()) {
+ for (const QRect &rect : mDirty) {
// intersect with image rect to be sure
QRect r = imageRect & rect;
@@ -113,7 +113,7 @@ void QMirClientBackingStore::updateTexture()
fixed |= r;
}
- Q_FOREACH (const QRect &rect, fixed.rects()) {
+ for (const QRect &rect : fixed) {
// if the sub-rect is full-width we can pass the image data directly to
// OpenGL instead of copying, since there is no gap between scanlines
if (rect.width() == imageRect.width()) {
diff --git a/src/plugins/platforms/mirclient/qmirclientcursor.cpp b/src/plugins/platforms/mirclient/qmirclientcursor.cpp
index 83ea116c11..a0da3fdd77 100644
--- a/src/plugins/platforms/mirclient/qmirclientcursor.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientcursor.cpp
@@ -167,7 +167,7 @@ void QMirClientCursor::configureMirCursorWithPixmapQCursor(MirSurface *surface,
QImage image = cursor.pixmap().toImage();
if (image.format() != QImage::Format_ARGB32) {
- image.convertToFormat(QImage::Format_ARGB32);
+ image = image.convertToFormat(QImage::Format_ARGB32);
}
MirBufferStream *bufferStream = mir_connection_create_buffer_stream_sync(mConnection,
diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp
index 4092669cfc..38eb0a4609 100644
--- a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp
@@ -41,7 +41,7 @@
#include "qmirclientglcontext.h"
#include "qmirclientwindow.h"
#include "qmirclientlogging.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <QtGui/private/qopenglcontext_p.h>
#include <dlfcn.h>
diff --git a/src/plugins/platforms/mirclient/qmirclientinput.cpp b/src/plugins/platforms/mirclient/qmirclientinput.cpp
index 4817185d41..b3b21ae0e3 100644
--- a/src/plugins/platforms/mirclient/qmirclientinput.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientinput.cpp
@@ -347,6 +347,7 @@ void QMirClientInput::dispatchTouchEvent(QMirClientWindow *window, const MirInpu
// TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left
// as Qt::TouchPointMoved
const unsigned int kPointerCount = mir_touch_event_point_count(tev);
+ touchPoints.reserve(int(kPointerCount));
for (unsigned int i = 0; i < kPointerCount; ++i) {
QWindowSystemInterface::TouchPoint touchPoint;
diff --git a/src/plugins/platforms/mirclient/qmirclientintegration.cpp b/src/plugins/platforms/mirclient/qmirclientintegration.cpp
index cfbcdc937e..2c8740f070 100644
--- a/src/plugins/platforms/mirclient/qmirclientintegration.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientintegration.cpp
@@ -56,8 +56,8 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatforminputcontextfactory_p.h>
#include <qpa/qplatforminputcontext.h>
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
#include <QOpenGLContext>
// platform-api
diff --git a/src/plugins/platforms/mirclient/qmirclientplatformservices.h b/src/plugins/platforms/mirclient/qmirclientplatformservices.h
index 46cf4300f8..a1cd5758ca 100644
--- a/src/plugins/platforms/mirclient/qmirclientplatformservices.h
+++ b/src/plugins/platforms/mirclient/qmirclientplatformservices.h
@@ -42,8 +42,8 @@
#define QMIRCLIENTPLATFORMSERVICES_H
#include <qpa/qplatformservices.h>
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
class QMirClientPlatformServices : public QPlatformServices {
public:
diff --git a/src/plugins/platforms/mirclient/qmirclientscreen.cpp b/src/plugins/platforms/mirclient/qmirclientscreen.cpp
index ca0c3e4733..0a2253e9e2 100644
--- a/src/plugins/platforms/mirclient/qmirclientscreen.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientscreen.cpp
@@ -51,7 +51,7 @@
#include <QScreen>
#include <QThread>
#include <qpa/qwindowsysteminterface.h>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <memory>
diff --git a/src/plugins/platforms/mirclient/qmirclienttheme.h b/src/plugins/platforms/mirclient/qmirclienttheme.h
index 19728741e3..4bab1d0ee0 100644
--- a/src/plugins/platforms/mirclient/qmirclienttheme.h
+++ b/src/plugins/platforms/mirclient/qmirclienttheme.h
@@ -41,7 +41,7 @@
#ifndef QMIRCLIENTTHEME_H
#define QMIRCLIENTTHEME_H
-#include <QtPlatformSupport/private/qgenericunixthemes_p.h>
+#include <QtThemeSupport/private/qgenericunixthemes_p.h>
class QMirClientTheme : public QGenericUnixTheme
{
diff --git a/src/plugins/platforms/offscreen/offscreen.pro b/src/plugins/platforms/offscreen/offscreen.pro
index 999550a7e1..6652cefd86 100644
--- a/src/plugins/platforms/offscreen/offscreen.pro
+++ b/src/plugins/platforms/offscreen/offscreen.pro
@@ -1,6 +1,10 @@
TARGET = qoffscreen
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private fontdatabase_support-private
+
+DEFINES += QT_NO_FOREACH
SOURCES = main.cpp \
qoffscreenintegration.cpp \
@@ -13,9 +17,10 @@ HEADERS = qoffscreenintegration.h \
OTHER_FILES += offscreen.json
-contains(QT_CONFIG, xlib):contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2) {
+qtConfig(xlib):qtConfig(opengl):!qtConfig(opengles2) {
SOURCES += qoffscreenintegration_x11.cpp
HEADERS += qoffscreenintegration_x11.h
+ QT += glx_support-private
system(echo "Using X11 offscreen integration with GLX")
} else {
SOURCES += qoffscreenintegration_dummy.cpp
diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
index ed1a81c2b3..85422071aa 100644
--- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
@@ -59,9 +59,9 @@ public:
void setPos(const QPoint &pos) Q_DECL_OVERRIDE
{
m_pos = pos;
- QWindowList wl = QGuiApplication::topLevelWindows();
+ const QWindowList wl = QGuiApplication::topLevelWindows();
QWindow *containing = 0;
- foreach (QWindow *w, wl) {
+ for (QWindow *w : wl) {
if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(pos)) {
containing = w;
break;
@@ -104,9 +104,9 @@ QPixmap QOffscreenScreen::grabWindow(WId id, int x, int y, int width, int height
QOffscreenWindow *window = QOffscreenWindow::windowForWinId(id);
if (!window || window->window()->type() == Qt::Desktop) {
- QWindowList wl = QGuiApplication::topLevelWindows();
+ const QWindowList wl = QGuiApplication::topLevelWindows();
QWindow *containing = 0;
- foreach (QWindow *w, wl) {
+ for (QWindow *w : wl) {
if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(rect)) {
containing = w;
break;
@@ -179,9 +179,8 @@ bool QOffscreenBackingStore::scroll(const QRegion &area, int dx, int dy)
if (m_image.isNull())
return false;
- const QVector<QRect> rects = area.rects();
- for (int i = 0; i < rects.size(); ++i)
- qt_scrollRectInImage(m_image, rects.at(i), QPoint(dx, dy));
+ for (const QRect &rect : area)
+ qt_scrollRectInImage(m_image, rect, QPoint(dx, dy));
return true;
}
@@ -213,11 +212,10 @@ QOffscreenBackingStore *QOffscreenBackingStore::backingStoreForWinId(WId id)
void QOffscreenBackingStore::clearHash()
{
- QList<WId> ids = m_windowAreaHash.keys();
- foreach (WId id, ids) {
- QHash<WId, QOffscreenBackingStore *>::iterator it = m_backingStoreForWinIdHash.find(id);
- if (it.value() == this)
- m_backingStoreForWinIdHash.remove(id);
+ for (auto it = m_windowAreaHash.cbegin(), end = m_windowAreaHash.cend(); it != end; ++it) {
+ const auto it2 = qAsConst(m_backingStoreForWinIdHash).find(it.key());
+ if (it2.value() == this)
+ m_backingStoreForWinIdHash.erase(it2);
}
m_windowAreaHash.clear();
}
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
index 4c3d62a53b..56e6075cb2 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
@@ -42,14 +42,14 @@
#include "qoffscreencommon.h"
#if defined(Q_OS_UNIX)
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
#if defined(Q_OS_MAC)
#include <qpa/qplatformfontdatabase.h>
#else
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
#endif
#elif defined(Q_OS_WIN)
-#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
+#include <QtFontDatabaseSupport/private/qbasicfontdatabase_p.h>
#ifndef Q_OS_WINRT
#include <QtCore/private/qeventdispatcher_win_p.h>
#else
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
index 2187eceed4..b46d94dfd3 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
@@ -45,7 +45,7 @@
#include <X11/Xlib.h>
#include <GL/glx.h>
-#include <QtPlatformSupport/private/qglxconvenience_p.h>
+#include <QtGlxSupport/private/qglxconvenience_p.h>
#include <qpa/qplatformsurface.h>
#include <qsurface.h>
diff --git a/src/plugins/platforms/openwfd/openwf.pro b/src/plugins/platforms/openwfd/openwf.pro
index 152e4f57d7..6012731b65 100644
--- a/src/plugins/platforms/openwfd/openwf.pro
+++ b/src/plugins/platforms/openwfd/openwf.pro
@@ -1,8 +1,8 @@
TARGET = qopenwf
-QT += core-private gui-private platformsupport-private
-
-CONFIG += qpa/genericunixfontdatabase
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private fontdatabase_support-private
HEADERS += \
qopenwfddevice.h \
@@ -31,7 +31,8 @@ SOURCES += \
qopenwfdportmode.cpp \
qopenwfdwindow.cpp
-LIBS += -lWFD -lgbm -lGLESv2 -lEGL
+LIBS += -lWFD
+QMAKE_USE += gbm opengl_es2 egl
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QOpenWFDIntegrationPlugin
diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
index 71e2b381fc..4850ca2e45 100644
--- a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
+++ b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
@@ -51,8 +51,8 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QScreen>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
#include <stdio.h>
@@ -68,6 +68,7 @@ QOpenWFDIntegration::QOpenWFDIntegration()
int actualNumberOfDevices = wfdEnumerateDevices(devices,numberOfDevices,0);
Q_ASSERT(actualNumberOfDevices == numberOfDevices);
+ mDevices.reserve(actualNumberOfDevices);
for (int i = 0; i < actualNumberOfDevices; i++) {
mDevices.append(new QOpenWFDDevice(this,devices[i]));
}
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index a5b64636af..2a6e059243 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -1,24 +1,23 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += gui-private
android: SUBDIRS += android
!android: SUBDIRS += minimal
-!android:if(!win32|contains(QT_CONFIG, freetype)): SUBDIRS += offscreen
+!android:qtConfig(freetype): SUBDIRS += offscreen
-contains(QT_CONFIG, xcb) {
+qtConfig(xcb) {
SUBDIRS += xcb
}
-mac {
- ios: SUBDIRS += ios
- else: SUBDIRS += cocoa
-}
+uikit:!watchos: SUBDIRS += ios
+osx: SUBDIRS += cocoa
win32:!winrt: SUBDIRS += windows
winrt: SUBDIRS += winrt
-contains(QT_CONFIG, direct2d) {
+qtConfig(direct2d) {
SUBDIRS += direct2d
}
@@ -26,21 +25,27 @@ qnx {
SUBDIRS += qnx
}
-contains(QT_CONFIG, eglfs) {
+qtConfig(eglfs) {
SUBDIRS += eglfs
SUBDIRS += minimalegl
}
-contains(QT_CONFIG, directfb) {
+qtConfig(directfb) {
SUBDIRS += directfb
}
-contains(QT_CONFIG, linuxfb): SUBDIRS += linuxfb
+qtConfig(linuxfb): SUBDIRS += linuxfb
+
+unix:!android:!darwin: SUBDIRS += vnc
+
+freebsd {
+ SUBDIRS += bsdfb
+}
haiku {
SUBDIRS += haiku
}
-contains(QT_CONFIG, mirclient): SUBDIRS += mirclient
+qtConfig(mirclient): SUBDIRS += mirclient
-contains(QT_CONFIG, integrityfb): SUBDIRS += integrity
+qtConfig(integrityfb): SUBDIRS += integrity
diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro
index 5a0f4f5c98..9da3d6811b 100644
--- a/src/plugins/platforms/qnx/qnx.pro
+++ b/src/plugins/platforms/qnx/qnx.pro
@@ -1,6 +1,8 @@
TARGET = qqnx
-QT += platformsupport-private core-private gui-private
+QT += \
+ core-private gui-private \
+ fontdatabase_support-private eventdispatcher_support-private egl_support-private
# Uncomment this to build with support for IMF once it becomes available in the BBNDK
#CONFIG += qqnx_imf
@@ -75,14 +77,14 @@ CONFIG(qqnx_screeneventthread) {
LIBS += -lscreen
-contains(QT_CONFIG, opengles2) {
+qtConfig(opengles2) {
SOURCES += qqnxglcontext.cpp \
qqnxeglwindow.cpp
HEADERS += qqnxglcontext.h \
qqnxeglwindow.h
- LIBS += -lEGL
+ QMAKE_USE += egl
}
CONFIG(qqnx_pps) {
@@ -100,7 +102,7 @@ CONFIG(qqnx_pps) {
qqnxnavigatoreventnotifier.h \
qqnxvirtualkeyboardpps.h
- LIBS += -lpps
+ QMAKE_USE += pps
!contains(DEFINES, QT_NO_CLIPBOARD): LIBS += -lclipboard
CONFIG(qqnx_imf) {
@@ -116,16 +118,11 @@ CONFIG(qqnx_pps) {
lgmon {
DEFINES += QQNX_LGMON
SOURCES += qqnxlgmon.cpp
- LIBS += -llgmon
+ QMAKE_USE += lgmon
}
OTHER_FILES += qnx.json
-QMAKE_CXXFLAGS += -I./private
-
-include (../../../platformsupport/eglconvenience/eglconvenience.pri)
-include (../../../platformsupport/fontdatabases/fontdatabases.pri)
-
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QQnxIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
index a08ac2b839..a6236f2376 100644
--- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
+++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
@@ -67,6 +67,7 @@ QQnxButtonEventNotifier::QQnxButtonEventNotifier(QObject *parent)
// fetch the new button ids
int enumeratorIndex = QQnxButtonEventNotifier::staticMetaObject.indexOfEnumerator(QByteArrayLiteral("ButtonId"));
QMetaEnum enumerator = QQnxButtonEventNotifier::staticMetaObject.enumerator(enumeratorIndex);
+ m_buttonKeys.reserve(ButtonCount - bid_minus);
for (int buttonId = bid_minus; buttonId < ButtonCount; ++buttonId) {
m_buttonKeys.append(enumerator.valueToKey(buttonId));
m_state[buttonId] = ButtonUp;
@@ -97,7 +98,7 @@ void QQnxButtonEventNotifier::start()
m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read);
QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(updateButtonStates()));
- qButtonDebug() << "successfully connected to Navigator. fd =" << m_fd;
+ qButtonDebug("successfully connected to Navigator. fd = %d", m_fd);
}
void QQnxButtonEventNotifier::updateButtonStates()
@@ -121,7 +122,7 @@ void QQnxButtonEventNotifier::updateButtonStates()
// Ensure data is null terminated
buffer[bytes] = '\0';
- qButtonDebug() << "received PPS message:\n" << buffer;
+ qButtonDebug("received PPS message:\n%s", buffer);
// Process received message
QByteArray ppsData = QByteArray::fromRawData(buffer, bytes);
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
index 79ff74b113..ce3a445d7c 100644
--- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
+++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
@@ -721,7 +721,7 @@ void QQnxInputContext::update(Qt::InputMethodQueries queries)
initEvent(&caretEvent.event, sInputSession, EVENT_CARET, CARET_POS_CHANGED, sizeof(caretEvent));
caretEvent.old_pos = lastCaret;
caretEvent.new_pos = m_caretPosition;
- qInputContextDebug() << "ictrl_dispatch_event caret changed" << lastCaret << m_caretPosition;
+ qInputContextDebug("ictrl_dispatch_event caret changed %d %d", lastCaret, m_caretPosition);
p_ictrl_dispatch_event(&caretEvent.event);
}
}
@@ -914,7 +914,7 @@ bool QQnxInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan
navigation_event_t navEvent;
initEvent(&navEvent.event, sInputSession, EVENT_NAVIGATION, key, sizeof(navEvent));
navEvent.magnitude = 1;
- qInputContextDebug() << "ictrl_dispatch_even navigation" << key;
+ qInputContextDebug("ictrl_dispatch_even navigation %d", key);
p_ictrl_dispatch_event(&navEvent.event);
}
} else {
@@ -927,7 +927,7 @@ bool QQnxInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan
keyEvent.sequence_id = sequenceId;
p_ictrl_dispatch_event(&keyEvent.event);
- qInputContextDebug() << "ictrl_dispatch_even key" << key;
+ qInputContextDebug("ictrl_dispatch_even key %d", key);
}
return true;
@@ -943,7 +943,7 @@ void QQnxInputContext::updateCursorPosition()
QCoreApplication::sendEvent(input, &query);
m_caretPosition = query.value(Qt::ImCursorPosition).toInt();
- qInputContextDebug() << m_caretPosition;
+ qInputContextDebug("%d", m_caretPosition);
}
void QQnxInputContext::endComposition()
@@ -1116,7 +1116,7 @@ int32_t QQnxInputContext::processEvent(event_t *event)
int flags = KEY_SYM_VALID | KEY_CAP_VALID;
if (event->event_id == IMF_KEY_DOWN)
flags |= KEY_DOWN;
- qInputContextDebug() << "EVENT_KEY" << flags << keySym;
+ qInputContextDebug("EVENT_KEY %d %d", flags, keySym);
QQnxScreenEventHandler::injectKeyboardEvent(flags, keySym, modifiers, 0, keyCap);
result = 0;
break;
@@ -1156,7 +1156,7 @@ int32_t QQnxInputContext::onCommitText(spannable_string_t *text, int32_t new_cur
int32_t QQnxInputContext::onDeleteSurroundingText(int32_t left_length, int32_t right_length)
{
- qInputContextDebug() << "L:" << left_length << " R:" << right_length;
+ qInputContextDebug("L: %d R: %d", int(left_length), int(right_length));
QObject *input = qGuiApp->focusObject();
if (!input)
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index e06d9a25c4..7229d7d2a8 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -453,11 +453,11 @@ void QQnxIntegration::createDisplays()
Q_SCREEN_CHECKERROR(result, "Failed to query display attachment");
if (!isAttached) {
- qIntegrationDebug() << "Skipping non-attached display" << i;
+ qIntegrationDebug("Skipping non-attached display %d", i);
continue;
}
- qIntegrationDebug() << "Creating screen for display" << i;
+ qIntegrationDebug("Creating screen for display %d", i);
createDisplay(displays[i], /*isPrimary=*/false);
} // of displays iteration
}
diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
index 4955938a3a..0e16764b79 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
@@ -63,14 +63,14 @@ bool QQnxNavigatorEventHandler::handleOrientationCheck(int angle)
{
// reply to navigator that (any) orientation is acceptable
// TODO: check if top window flags prohibit orientation change
- qNavigatorEventHandlerDebug() << "angle=" << angle;
+ qNavigatorEventHandlerDebug("angle=%d", angle);
return true;
}
void QQnxNavigatorEventHandler::handleOrientationChange(int angle)
{
// update screen geometry and reply to navigator that we're ready
- qNavigatorEventHandlerDebug() << "angle=" << angle;
+ qNavigatorEventHandlerDebug("angle=%d", angle);
emit rotationChanged(angle);
}
diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp
index 9ccda2d94a..1f630863b7 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp
@@ -91,8 +91,7 @@ void QQnxNavigatorEventNotifier::start()
errno = 0;
m_fd = open(navigatorControlPath, O_RDWR);
if (m_fd == -1) {
- qNavigatorEventNotifierDebug() << "failed to open navigator pps:"
- << strerror(errno);
+ qNavigatorEventNotifierDebug("failed to open navigator pps: %s", strerror(errno));
return;
}
diff --git a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp
index fd1bbc4a85..d5234ca92f 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp
@@ -79,7 +79,7 @@ bool QQnxNavigatorPps::openPpsConnection()
return false;
}
- qNavigatorDebug() << "successfully connected to Navigator. fd=" << m_fd;
+ qNavigatorDebug("successfully connected to Navigator. fd=%d", m_fd);
return true;
}
diff --git a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
index c9a89def41..a758bdf7f4 100644
--- a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
+++ b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
@@ -139,7 +139,7 @@ void QQnxRasterBackingStore::beginPaint(const QRegion &region)
platformWindow()->adjustBufferSize();
if (window()->requestedFormat().alphaBufferSize() > 0) {
- foreach (const QRect &r, region.rects()) {
+ for (const QRect &r : region) {
// Clear transparent regions
const int bg[] = {
SCREEN_BLIT_COLOR, 0x00000000,
diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
index 3ac3d23c88..7f11de228e 100644
--- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
@@ -215,10 +215,9 @@ void QQnxRasterWindow::blitPreviousToCurrent(const QRegion &region, int dx, int
QQnxBuffer &previousBuffer = m_buffers[m_previousBufferIndex];
// Break down region into non-overlapping rectangles
- const QVector<QRect> rects = region.rects();
- for (int i = rects.size() - 1; i >= 0; i--) {
+ for (auto rit = region.rbegin(), rend = region.rend(); rit != rend; ++rit) {
// Clip rectangle to bounds of target
- const QRect rect = rects[i].intersected(currentBuffer.rect());
+ const QRect rect = rit->intersected(currentBuffer.rect());
if (rect.isEmpty())
continue;
diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp
index 16ddcd784b..46df500330 100644
--- a/src/plugins/platforms/qnx/qqnxscreen.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreen.cpp
@@ -90,7 +90,7 @@ static QSize determineScreenSize(screen_display_t display, bool primaryScreen) {
const QString envPhySizeStr = qgetenv("QQNX_PHYSICAL_SCREEN_SIZE");
if (!envPhySizeStr.isEmpty()) {
- const QStringList envPhySizeStrList = envPhySizeStr.split(QLatin1Char(','));
+ const auto envPhySizeStrList = envPhySizeStr.splitRef(QLatin1Char(','));
const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;
@@ -340,11 +340,12 @@ qreal QQnxScreen::refreshRate() const
qWarning("QQnxScreen: Failed to query screen mode. Using default value of 60Hz");
return 60.0;
}
- qScreenDebug() << "screen mode:" << endl
- << " width =" << displayMode.width << endl
- << " height =" << displayMode.height << endl
- << " refresh =" << displayMode.refresh << endl
- << " interlaced =" << displayMode.interlaced;
+ qScreenDebug("screen mode:\n"
+ " width = %u\n"
+ " height = %u\n"
+ " refresh = %u\n"
+ " interlaced = %u",
+ uint(displayMode.width), uint(displayMode.height), uint(displayMode.refresh), uint(displayMode.interlaced));
return static_cast<qreal>(displayMode.refresh);
}
@@ -384,10 +385,8 @@ Qt::ScreenOrientation QQnxScreen::orientation() const
QWindow *QQnxScreen::topLevelAt(const QPoint &point) const
{
- QListIterator<QQnxWindow*> it(m_childWindows);
- it.toBack();
- while (it.hasPrevious()) {
- QWindow *win = it.previous()->window();
+ for (auto it = m_childWindows.rbegin(), end = m_childWindows.rend(); it != end; ++it) {
+ QWindow *win = (*it)->window();
if (win->geometry().contains(point))
return win;
}
@@ -404,7 +403,7 @@ static bool isOrthogonal(int angle1, int angle2)
void QQnxScreen::setRotation(int rotation)
{
- qScreenDebug() << "orientation =" << rotation;
+ qScreenDebug("orientation = %d", rotation);
// Check if rotation changed
// We only want to rotate if we are the primary screen
if (m_currentRotation != rotation && isPrimaryScreen()) {
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index f7a87b6073..beda6e1a49 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -147,7 +147,7 @@ bool QQnxScreenEventHandler::handleEvent(screen_event_t event, int qnxType)
default:
// event ignored
- qScreenEventDebug() << "unknown event" << qnxType;
+ qScreenEventDebug("unknown event %d", qnxType);
return false;
}
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp
index 1174dc6ab3..025c03c058 100644
--- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp
+++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp
@@ -164,7 +164,7 @@ void QQnxVirtualKeyboardPps::ppsDataReady()
{
ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1);
- qVirtualKeyboardDebug() << "keyboardMessage size: " << nread;
+ qVirtualKeyboardDebug("keyboardMessage size: %zd", nread);
if (nread < 0){
connect(); // reconnect
return;
@@ -230,7 +230,7 @@ void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage()
}
setHeight(newHeight);
- qVirtualKeyboardDebug() << "size=" << newHeight;
+ qVirtualKeyboardDebug("size=%d", newHeight);
}
bool QQnxVirtualKeyboardPps::showKeyboard()
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 7b3a5ec70c..6fd0191e43 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -569,7 +569,7 @@ void QQnxWindow::requestActivateWindow()
for (int i = 1; i < windowList.size(); ++i)
windowList.at(i-1)->setFocus(windowList.at(i)->nativeHandle());
- windowList.last()->setFocus(windowList.last()->nativeHandle());
+ windowList.last()->setFocus(windowList.constLast()->nativeHandle());
}
screen_flush_context(m_screenContext, 0);
diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.h b/src/plugins/platforms/vnc/main.cpp
index c96ca7937a..6ee8bf1ec6 100644
--- a/src/plugins/platforms/windows/qwindowsnativeimage.h
+++ b/src/plugins/platforms/vnc/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,42 +37,29 @@
**
****************************************************************************/
-#ifndef QWINDOWSNATIVEIMAGE_H
-#define QWINDOWSNATIVEIMAGE_H
-
-#include "qtwindows_additional.h"
-
-#include <QtGui/QImage>
+#include <qpa/qplatformintegrationplugin.h>
+#include "qvncintegration.h"
+#include "qvnc_p.h"
QT_BEGIN_NAMESPACE
-class QWindowsNativeImage
+class QVncIntegrationPlugin : public QPlatformIntegrationPlugin
{
- Q_DISABLE_COPY(QWindowsNativeImage)
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "vnc.json")
public:
- QWindowsNativeImage(int width, int height,
- QImage::Format format);
-
- ~QWindowsNativeImage();
-
- inline int width() const { return m_image.width(); }
- inline int height() const { return m_image.height(); }
-
- QImage &image() { return m_image; }
- const QImage &image() const { return m_image; }
-
- HDC hdc() const { return m_hdc; }
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
+};
- static QImage::Format systemFormat();
+QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive))
+ return new QVncIntegration(paramList);
-private:
- const HDC m_hdc;
- QImage m_image;
-
- HBITMAP m_bitmap;
- HBITMAP m_null_bitmap;
-};
+ return 0;
+}
QT_END_NAMESPACE
-#endif // QWINDOWSNATIVEIMAGE_H
+#include "main.moc"
+
diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp
new file mode 100644
index 0000000000..a45bb1c19c
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvnc.cpp
@@ -0,0 +1,685 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qvnc_p.h"
+#include "qvncscreen.h"
+#include "qvncclient.h"
+#include "QtNetwork/qtcpserver.h"
+#include "QtNetwork/qtcpsocket.h"
+#include <qendian.h>
+#include <qthread.h>
+
+#include <QtGui/qguiapplication.h>
+#include <QtGui/QWindow>
+
+#ifdef Q_OS_WIN
+#include <Winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcVnc, "qt.qpa.vnc");
+
+QVncDirtyMap::QVncDirtyMap(QVncScreen *screen)
+ : screen(screen), bytesPerPixel(0), numDirty(0)
+{
+ bytesPerPixel = (screen->depth() + 7) / 8;
+ bufferWidth = screen->geometry().width();
+ bufferHeight = screen->geometry().height();
+ bufferStride = bufferWidth * bytesPerPixel;
+ buffer = new uchar[bufferHeight * bufferStride];
+
+ mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
+ mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
+ numTiles = mapWidth * mapHeight;
+ map = new uchar[numTiles];
+}
+
+QVncDirtyMap::~QVncDirtyMap()
+{
+ delete[] map;
+ delete[] buffer;
+}
+
+void QVncDirtyMap::reset()
+{
+ memset(map, 1, numTiles);
+ memset(buffer, 0, bufferHeight * bufferStride);
+ numDirty = numTiles;
+}
+
+inline bool QVncDirtyMap::dirty(int x, int y) const
+{
+ return map[y * mapWidth + x];
+}
+
+inline void QVncDirtyMap::setClean(int x, int y)
+{
+ map[y * mapWidth + x] = 0;
+ --numDirty;
+}
+
+template <class T>
+void QVncDirtyMapOptimized<T>::setDirty(int tileX, int tileY, bool force)
+{
+ static bool alwaysForce = qEnvironmentVariableIsSet("QT_VNC_NO_COMPAREBUFFER");
+ if (alwaysForce)
+ force = true;
+
+ bool changed = false;
+
+ if (!force) {
+ const int lstep = bufferStride;
+ const int startX = tileX * MAP_TILE_SIZE;
+ const int startY = tileY * MAP_TILE_SIZE;
+ const uchar *scrn = screen->image()->constBits()
+ + startY * lstep + startX * bytesPerPixel;
+ uchar *old = buffer + startY * bufferStride + startX * sizeof(T);
+
+ const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ?
+ bufferHeight - startY : MAP_TILE_SIZE);
+ const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ?
+ bufferWidth - startX : MAP_TILE_SIZE);
+ const bool doInlines = (tileWidth == MAP_TILE_SIZE);
+
+ int y = tileHeight;
+
+ if (doInlines) { // hw: memcmp/memcpy is inlined when using constants
+ while (y) {
+ if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) {
+ changed = true;
+ break;
+ }
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+
+ while (y) {
+ memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE);
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+ } else {
+ while (y) {
+ if (memcmp(old, scrn, sizeof(T) * tileWidth)) {
+ changed = true;
+ break;
+ }
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+
+ while (y) {
+ memcpy(old, scrn, sizeof(T) * tileWidth);
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+ }
+ }
+
+ const int mapIndex = tileY * mapWidth + tileX;
+ if ((force || changed) && !map[mapIndex]) {
+ map[mapIndex] = 1;
+ ++numDirty;
+ }
+}
+
+template class QVncDirtyMapOptimized<unsigned char>;
+template class QVncDirtyMapOptimized<unsigned short>;
+template class QVncDirtyMapOptimized<unsigned int>;
+
+static const struct {
+ int keysym;
+ int keycode;
+} keyMap[] = {
+ { 0xff08, Qt::Key_Backspace },
+ { 0xff09, Qt::Key_Tab },
+ { 0xff0d, Qt::Key_Return },
+ { 0xff1b, Qt::Key_Escape },
+ { 0xff63, Qt::Key_Insert },
+ { 0xffff, Qt::Key_Delete },
+ { 0xff50, Qt::Key_Home },
+ { 0xff57, Qt::Key_End },
+ { 0xff55, Qt::Key_PageUp },
+ { 0xff56, Qt::Key_PageDown },
+ { 0xff51, Qt::Key_Left },
+ { 0xff52, Qt::Key_Up },
+ { 0xff53, Qt::Key_Right },
+ { 0xff54, Qt::Key_Down },
+ { 0xffbe, Qt::Key_F1 },
+ { 0xffbf, Qt::Key_F2 },
+ { 0xffc0, Qt::Key_F3 },
+ { 0xffc1, Qt::Key_F4 },
+ { 0xffc2, Qt::Key_F5 },
+ { 0xffc3, Qt::Key_F6 },
+ { 0xffc4, Qt::Key_F7 },
+ { 0xffc5, Qt::Key_F8 },
+ { 0xffc6, Qt::Key_F9 },
+ { 0xffc7, Qt::Key_F10 },
+ { 0xffc8, Qt::Key_F11 },
+ { 0xffc9, Qt::Key_F12 },
+ { 0xffe1, Qt::Key_Shift },
+ { 0xffe2, Qt::Key_Shift },
+ { 0xffe3, Qt::Key_Control },
+ { 0xffe4, Qt::Key_Control },
+ { 0xffe7, Qt::Key_Meta },
+ { 0xffe8, Qt::Key_Meta },
+ { 0xffe9, Qt::Key_Alt },
+ { 0xffea, Qt::Key_Alt },
+
+ { 0xffb0, Qt::Key_0 },
+ { 0xffb1, Qt::Key_1 },
+ { 0xffb2, Qt::Key_2 },
+ { 0xffb3, Qt::Key_3 },
+ { 0xffb4, Qt::Key_4 },
+ { 0xffb5, Qt::Key_5 },
+ { 0xffb6, Qt::Key_6 },
+ { 0xffb7, Qt::Key_7 },
+ { 0xffb8, Qt::Key_8 },
+ { 0xffb9, Qt::Key_9 },
+
+ { 0xff8d, Qt::Key_Return },
+ { 0xffaa, Qt::Key_Asterisk },
+ { 0xffab, Qt::Key_Plus },
+ { 0xffad, Qt::Key_Minus },
+ { 0xffae, Qt::Key_Period },
+ { 0xffaf, Qt::Key_Slash },
+
+ { 0xff95, Qt::Key_Home },
+ { 0xff96, Qt::Key_Left },
+ { 0xff97, Qt::Key_Up },
+ { 0xff98, Qt::Key_Right },
+ { 0xff99, Qt::Key_Down },
+ { 0xff9a, Qt::Key_PageUp },
+ { 0xff9b, Qt::Key_PageDown },
+ { 0xff9c, Qt::Key_End },
+ { 0xff9e, Qt::Key_Insert },
+ { 0xff9f, Qt::Key_Delete },
+
+ { 0, 0 }
+};
+
+void QRfbRect::read(QTcpSocket *s)
+{
+ quint16 buf[4];
+ s->read((char*)buf, 8);
+ x = ntohs(buf[0]);
+ y = ntohs(buf[1]);
+ w = ntohs(buf[2]);
+ h = ntohs(buf[3]);
+}
+
+void QRfbRect::write(QTcpSocket *s) const
+{
+ quint16 buf[4];
+ buf[0] = htons(x);
+ buf[1] = htons(y);
+ buf[2] = htons(w);
+ buf[3] = htons(h);
+ s->write((char*)buf, 8);
+}
+
+void QRfbPixelFormat::read(QTcpSocket *s)
+{
+ char buf[16];
+ s->read(buf, 16);
+ bitsPerPixel = buf[0];
+ depth = buf[1];
+ bigEndian = buf[2];
+ trueColor = buf[3];
+
+ quint16 a = ntohs(*(quint16 *)(buf + 4));
+ redBits = 0;
+ while (a) { a >>= 1; redBits++; }
+
+ a = ntohs(*(quint16 *)(buf + 6));
+ greenBits = 0;
+ while (a) { a >>= 1; greenBits++; }
+
+ a = ntohs(*(quint16 *)(buf + 8));
+ blueBits = 0;
+ while (a) { a >>= 1; blueBits++; }
+
+ redShift = buf[10];
+ greenShift = buf[11];
+ blueShift = buf[12];
+}
+
+void QRfbPixelFormat::write(QTcpSocket *s)
+{
+ char buf[16];
+ buf[0] = bitsPerPixel;
+ buf[1] = depth;
+ buf[2] = bigEndian;
+ buf[3] = trueColor;
+
+ quint16 a = 0;
+ for (int i = 0; i < redBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 4) = htons(a);
+
+ a = 0;
+ for (int i = 0; i < greenBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 6) = htons(a);
+
+ a = 0;
+ for (int i = 0; i < blueBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 8) = htons(a);
+
+ buf[10] = redShift;
+ buf[11] = greenShift;
+ buf[12] = blueShift;
+ s->write(buf, 16);
+}
+
+
+void QRfbServerInit::setName(const char *n)
+{
+ delete[] name;
+ name = new char [strlen(n) + 1];
+ strcpy(name, n);
+}
+
+void QRfbServerInit::read(QTcpSocket *s)
+{
+ s->read((char *)&width, 2);
+ width = ntohs(width);
+ s->read((char *)&height, 2);
+ height = ntohs(height);
+ format.read(s);
+
+ quint32 len;
+ s->read((char *)&len, 4);
+ len = ntohl(len);
+
+ name = new char [len + 1];
+ s->read(name, len);
+ name[len] = '\0';
+}
+
+void QRfbServerInit::write(QTcpSocket *s)
+{
+ quint16 t = htons(width);
+ s->write((char *)&t, 2);
+ t = htons(height);
+ s->write((char *)&t, 2);
+ format.write(s);
+ quint32 len = strlen(name);
+ len = htonl(len);
+ s->write((char *)&len, 4);
+ s->write(name, strlen(name));
+}
+
+bool QRfbSetEncodings::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 3)
+ return false;
+
+ char tmp;
+ s->read(&tmp, 1); // padding
+ s->read((char *)&count, 2);
+ count = ntohs(count);
+
+ return true;
+}
+
+bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 9)
+ return false;
+
+ s->read(&incremental, 1);
+ rect.read(s);
+
+ return true;
+}
+
+bool QRfbKeyEvent::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 7)
+ return false;
+
+ s->read(&down, 1);
+ quint16 tmp;
+ s->read((char *)&tmp, 2); // padding
+
+ quint32 key;
+ s->read((char *)&key, 4);
+ key = ntohl(key);
+
+ unicode = 0;
+ keycode = 0;
+ int i = 0;
+ while (keyMap[i].keysym && !keycode) {
+ if (keyMap[i].keysym == (int)key)
+ keycode = keyMap[i].keycode;
+ i++;
+ }
+
+ if (keycode >= ' ' && keycode <= '~')
+ unicode = keycode;
+
+ if (!keycode) {
+ if (key <= 0xff) {
+ unicode = key;
+ if (key >= 'a' && key <= 'z')
+ keycode = Qt::Key_A + key - 'a';
+ else if (key >= ' ' && key <= '~')
+ keycode = Qt::Key_Space + key - ' ';
+ }
+ }
+
+ return true;
+}
+
+bool QRfbPointerEvent::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 5)
+ return false;
+
+ char buttonMask;
+ s->read(&buttonMask, 1);
+ buttons = Qt::NoButton;
+ if (buttonMask & 1)
+ buttons |= Qt::LeftButton;
+ if (buttonMask & 2)
+ buttons |= Qt::MidButton;
+ if (buttonMask & 4)
+ buttons |= Qt::RightButton;
+
+ quint16 tmp;
+ s->read((char *)&tmp, 2);
+ x = ntohs(tmp);
+ s->read((char *)&tmp, 2);
+ y = ntohs(tmp);
+
+ return true;
+}
+
+bool QRfbClientCutText::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 7)
+ return false;
+
+ char tmp[3];
+ s->read(tmp, 3); // padding
+ s->read((char *)&length, 4);
+ length = ntohl(length);
+
+ return true;
+}
+
+void QRfbRawEncoder::write()
+{
+// QVncDirtyMap *map = server->dirtyMap();
+ QTcpSocket *socket = client->clientSocket();
+
+ const int bytesPerPixel = client->clientBytesPerPixel();
+
+ // create a region from the dirty rects and send the region's merged rects.
+ // ### use the tile map again
+ QRegion rgn = client->dirtyRegion();
+ qCDebug(lcVnc) << "QRfbRawEncoder::write()" << rgn;
+// if (map) {
+// for (int y = 0; y < map->mapHeight; ++y) {
+// for (int x = 0; x < map->mapWidth; ++x) {
+// if (!map->dirty(x, y))
+// continue;
+// rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE,
+// MAP_TILE_SIZE, MAP_TILE_SIZE);
+// map->setClean(x, y);
+// }
+// }
+
+// rgn &= QRect(0, 0, server->screen()->geometry().width(),
+// server->screen()->geometry().height());
+// }
+ const QVector<QRect> rects = rgn.rects();
+
+ {
+ const char tmp[2] = { 0, 0 }; // msg type, padding
+ socket->write(tmp, sizeof(tmp));
+ }
+
+ {
+ const quint16 count = htons(rects.size());
+ socket->write((char *)&count, sizeof(count));
+ }
+
+ if (rects.size() <= 0)
+ return;
+
+ const QImage screenImage = client->server()->screenImage();
+
+ for (const QRect &tileRect: rects) {
+ const QRfbRect rect(tileRect.x(), tileRect.y(),
+ tileRect.width(), tileRect.height());
+ rect.write(socket);
+
+ const quint32 encoding = htonl(0); // raw encoding
+ socket->write((char *)&encoding, sizeof(encoding));
+
+ int linestep = screenImage.bytesPerLine();
+ const uchar *screendata = screenImage.scanLine(rect.y)
+ + rect.x * screenImage.depth() / 8;
+
+ if (client->doPixelConversion()) {
+ const int bufferSize = rect.w * rect.h * bytesPerPixel;
+ if (bufferSize > buffer.size())
+ buffer.resize(bufferSize);
+
+ // convert pixels
+ char *b = buffer.data();
+ const int bstep = rect.w * bytesPerPixel;
+ for (int i = 0; i < rect.h; ++i) {
+ client->convertPixels(b, (const char*)screendata, rect.w);
+ screendata += linestep;
+ b += bstep;
+ }
+ socket->write(buffer.constData(), bufferSize);
+ } else {
+ for (int i = 0; i < rect.h; ++i) {
+ socket->write((const char*)screendata, rect.w * bytesPerPixel);
+ screendata += linestep;
+ }
+ }
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ break;
+ }
+ socket->flush();
+}
+
+QVncClientCursor::QVncClientCursor()
+{
+#ifndef QT_NO_CURSOR
+ QWindow *w = QGuiApplication::focusWindow();
+ QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor);
+ changeCursor(&c, 0);
+#endif
+}
+
+QVncClientCursor::~QVncClientCursor()
+{
+}
+
+void QVncClientCursor::write(QVncClient *client) const
+{
+ QTcpSocket *socket = client->clientSocket();
+
+ // FramebufferUpdate header
+ {
+ const quint16 tmp[6] = { htons(0),
+ htons(1),
+ htons(hotspot.x()), htons(hotspot.y()),
+ htons(cursor.width()),
+ htons(cursor.height()) };
+ socket->write((char*)tmp, sizeof(tmp));
+
+ const qint32 encoding = qToBigEndian(-239);
+ socket->write((char*)(&encoding), sizeof(encoding));
+ }
+
+ if (cursor.isNull())
+ return;
+
+ // write pixels
+ Q_ASSERT(cursor.hasAlphaChannel());
+ const QImage img = cursor.convertToFormat(client->server()->screen()->format());
+ const int n = client->clientBytesPerPixel() * img.width();
+ char *buffer = new char[n];
+ for (int i = 0; i < img.height(); ++i) {
+ client->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
+ socket->write(buffer, n);
+ }
+ delete[] buffer;
+
+ // write mask
+ const QImage bitmap = cursor.createAlphaMask().convertToFormat(QImage::Format_Mono);
+ Q_ASSERT(bitmap.depth() == 1);
+ Q_ASSERT(bitmap.size() == img.size());
+ const int width = (bitmap.width() + 7) / 8;
+ for (int i = 0; i < bitmap.height(); ++i)
+ socket->write((const char*)bitmap.scanLine(i), width);
+}
+
+void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
+{
+ Q_UNUSED(window);
+#ifndef QT_NO_CURSOR
+ const Qt::CursorShape shape = widgetCursor ? widgetCursor->shape() : Qt::ArrowCursor;
+
+ if (shape == Qt::BitmapCursor) {
+ // application supplied cursor
+ hotspot = widgetCursor->hotSpot();
+ cursor = widgetCursor->pixmap().toImage();
+ } else {
+ // system cursor
+ QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0);
+ platformImage.set(shape);
+ cursor = *platformImage.image();
+ hotspot = platformImage.hotspot();
+ }
+#else // !QT_NO_CURSOR
+ Q_UNUSED(widgetCursor);
+#endif
+ for (auto client : clients)
+ client->setDirtyCursor();
+}
+
+void QVncClientCursor::addClient(QVncClient *client)
+{
+ if (!clients.contains(client))
+ clients.append(client);
+}
+
+uint QVncClientCursor::removeClient(QVncClient *client)
+{
+ clients.removeOne(client);
+ return clients.count();
+}
+
+QVncServer::QVncServer(QVncScreen *screen, quint16 port)
+ : qvnc_screen(screen)
+ , m_port(port)
+{
+ QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
+}
+
+void QVncServer::init()
+{
+ serverSocket = new QTcpServer(this);
+ if (!serverSocket->listen(QHostAddress::Any, m_port))
+ qWarning() << "QVncServer could not connect:" << serverSocket->errorString();
+ else
+ qWarning("QVncServer created on port %d", m_port);
+
+ connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection()));
+
+}
+
+QVncServer::~QVncServer()
+{
+ for (auto client : clients) {
+ delete client;
+ }
+}
+
+void QVncServer::setDirty()
+{
+ for (auto client : clients) {
+ client->setDirty(qvnc_screen->dirtyRegion);
+ }
+ qvnc_screen->clearDirty();
+}
+
+
+void QVncServer::newConnection()
+{
+ auto clientSocket = serverSocket->nextPendingConnection();
+ clients.append(new QVncClient(clientSocket, this));
+
+ dirtyMap()->reset();
+
+ qCDebug(lcVnc) << "new Connection from: " << clientSocket->localAddress();
+
+ qvnc_screen->setPowerState(QPlatformScreen::PowerStateOn);
+}
+
+void QVncServer::discardClient(QVncClient *client)
+{
+ clients.removeOne(client);
+ client->deleteLater();
+ if (clients.isEmpty()) {
+ qvnc_screen->disableClientCursor(client);
+ qvnc_screen->setPowerState(QPlatformScreen::PowerStateOff);
+ }
+}
+
+inline QImage QVncServer::screenImage() const
+{
+ return *qvnc_screen->image();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvnc_p.h b/src/plugins/platforms/vnc/qvnc_p.h
new file mode 100644
index 0000000000..1c44cd1569
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvnc_p.h
@@ -0,0 +1,417 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVNC_P_H
+#define QVNC_P_H
+
+#include "qvncscreen.h"
+
+#include <QtCore/QLoggingCategory>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qvarlengtharray.h>
+#include <qpa/qplatformcursor.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(lcVnc)
+
+class QTcpSocket;
+class QTcpServer;
+
+class QVncScreen;
+class QVncServer;
+class QVncClientCursor;
+class QVncClient;
+
+// This fits with the VNC hextile messages
+#define MAP_TILE_SIZE 16
+
+class QVncDirtyMap
+{
+public:
+ QVncDirtyMap(QVncScreen *screen);
+ virtual ~QVncDirtyMap();
+
+ void reset();
+ bool dirty(int x, int y) const;
+ virtual void setDirty(int x, int y, bool force = false) = 0;
+ void setClean(int x, int y);
+
+ QVncScreen *screen;
+ int bytesPerPixel;
+ int numDirty;
+ int mapWidth;
+ int mapHeight;
+
+protected:
+ uchar *map;
+ uchar *buffer;
+ int bufferWidth;
+ int bufferHeight;
+ int bufferStride;
+ int numTiles;
+};
+
+template <class T>
+class QVncDirtyMapOptimized : public QVncDirtyMap
+{
+public:
+ QVncDirtyMapOptimized(QVncScreen *screen) : QVncDirtyMap(screen) {}
+ ~QVncDirtyMapOptimized() {}
+
+ void setDirty(int x, int y, bool force = false);
+};
+
+
+class QRfbRect
+{
+public:
+ QRfbRect() {}
+ QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) {
+ x = _x; y = _y; w = _w; h = _h;
+ }
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s) const;
+
+ quint16 x;
+ quint16 y;
+ quint16 w;
+ quint16 h;
+};
+
+class QRfbPixelFormat
+{
+public:
+ static int size() { return 16; }
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s);
+
+ int bitsPerPixel;
+ int depth;
+ bool bigEndian;
+ bool trueColor;
+ int redBits;
+ int greenBits;
+ int blueBits;
+ int redShift;
+ int greenShift;
+ int blueShift;
+};
+
+class QRfbServerInit
+{
+public:
+ QRfbServerInit() { name = 0; }
+ ~QRfbServerInit() { delete[] name; }
+
+ int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); }
+ void setName(const char *n);
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s);
+
+ quint16 width;
+ quint16 height;
+ QRfbPixelFormat format;
+ char *name;
+};
+
+class QRfbSetEncodings
+{
+public:
+ bool read(QTcpSocket *s);
+
+ quint16 count;
+};
+
+class QRfbFrameBufferUpdateRequest
+{
+public:
+ bool read(QTcpSocket *s);
+
+ char incremental;
+ QRfbRect rect;
+};
+
+class QRfbKeyEvent
+{
+public:
+ bool read(QTcpSocket *s);
+
+ char down;
+ int keycode;
+ int unicode;
+};
+
+class QRfbPointerEvent
+{
+public:
+ bool read(QTcpSocket *s);
+
+ Qt::MouseButtons buttons;
+ quint16 x;
+ quint16 y;
+};
+
+class QRfbClientCutText
+{
+public:
+ bool read(QTcpSocket *s);
+
+ quint32 length;
+};
+
+class QRfbEncoder
+{
+public:
+ QRfbEncoder(QVncClient *s) : client(s) {}
+ virtual ~QRfbEncoder() {}
+
+ virtual void write() = 0;
+
+protected:
+ QVncClient *client;
+};
+
+class QRfbRawEncoder : public QRfbEncoder
+{
+public:
+ QRfbRawEncoder(QVncClient *s) : QRfbEncoder(s) {}
+
+ void write();
+
+private:
+ QByteArray buffer;
+};
+
+template <class SRC> class QRfbHextileEncoder;
+
+template <class SRC>
+class QRfbSingleColorHextile
+{
+public:
+ QRfbSingleColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ QRfbHextileEncoder<SRC> *encoder;
+};
+
+template <class SRC>
+class QRfbDualColorHextile
+{
+public:
+ QRfbDualColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ struct Rect {
+ quint8 xy;
+ quint8 wh;
+ } Q_PACKED rects[8 * 16];
+
+ quint8 numRects;
+ QRfbHextileEncoder<SRC> *encoder;
+
+private:
+ inline int lastx() const { return rectx(numRects); }
+ inline int lasty() const { return recty(numRects); }
+ inline int rectx(int r) const { return rects[r].xy >> 4; }
+ inline int recty(int r) const { return rects[r].xy & 0x0f; }
+ inline int width(int r) const { return (rects[r].wh >> 4) + 1; }
+ inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; }
+
+ inline void setX(int r, int x) {
+ rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
+ }
+ inline void setY(int r, int y) {
+ rects[r].xy = (rects[r].xy & 0xf0) | y;
+ }
+ inline void setWidth(int r, int width) {
+ rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
+ }
+ inline void setHeight(int r, int height) {
+ rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
+ }
+
+ inline void setWidth(int width) { setWidth(numRects, width); }
+ inline void setHeight(int height) { setHeight(numRects, height); }
+ inline void setX(int x) { setX(numRects, x); }
+ inline void setY(int y) { setY(numRects, y); }
+ void next();
+};
+
+template <class SRC>
+class QRfbMultiColorHextile
+{
+public:
+ QRfbMultiColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ inline quint8* rect(int r) {
+ return rects.data() + r * (bpp + 2);
+ }
+ inline const quint8* rect(int r) const {
+ return rects.constData() + r * (bpp + 2);
+ }
+ inline void setX(int r, int x) {
+ quint8 *ptr = rect(r) + bpp;
+ *ptr = (x << 4) | (*ptr & 0x0f);
+ }
+ inline void setY(int r, int y) {
+ quint8 *ptr = rect(r) + bpp;
+ *ptr = (*ptr & 0xf0) | y;
+ }
+ void setColor(SRC color);
+ inline int rectx(int r) const {
+ const quint8 *ptr = rect(r) + bpp;
+ return *ptr >> 4;
+ }
+ inline int recty(int r) const {
+ const quint8 *ptr = rect(r) + bpp;
+ return *ptr & 0x0f;
+ }
+ inline void setWidth(int r, int width) {
+ quint8 *ptr = rect(r) + bpp + 1;
+ *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
+ }
+ inline void setHeight(int r, int height) {
+ quint8 *ptr = rect(r) + bpp + 1;
+ *ptr = (*ptr & 0xf0) | (height - 1);
+ }
+
+ bool beginRect();
+ void endRect();
+
+ static const int maxRectsSize = 16 * 16;
+ QVarLengthArray<quint8, maxRectsSize> rects;
+
+ quint8 bpp;
+ quint8 numRects;
+ QRfbHextileEncoder<SRC> *encoder;
+};
+
+template <class SRC>
+class QRfbHextileEncoder : public QRfbEncoder
+{
+public:
+ QRfbHextileEncoder(QVncServer *s);
+ void write();
+
+private:
+ enum SubEncoding {
+ Raw = 1,
+ BackgroundSpecified = 2,
+ ForegroundSpecified = 4,
+ AnySubrects = 8,
+ SubrectsColoured = 16
+ };
+
+ QByteArray buffer;
+ QRfbSingleColorHextile<SRC> singleColorHextile;
+ QRfbDualColorHextile<SRC> dualColorHextile;
+ QRfbMultiColorHextile<SRC> multiColorHextile;
+
+ SRC bg;
+ SRC fg;
+ bool newBg;
+ bool newFg;
+
+ friend class QRfbSingleColorHextile<SRC>;
+ friend class QRfbDualColorHextile<SRC>;
+ friend class QRfbMultiColorHextile<SRC>;
+};
+
+class QVncClientCursor : public QPlatformCursor
+{
+public:
+ QVncClientCursor();
+ ~QVncClientCursor();
+
+ void write(QVncClient *client) const;
+
+ void changeCursor(QCursor *widgetCursor, QWindow *window);
+
+ void addClient(QVncClient *client);
+ uint removeClient(QVncClient *client);
+
+ QImage cursor;
+ QPoint hotspot;
+ QVector<QVncClient *> clients;
+};
+
+
+class QVncServer : public QObject
+{
+ Q_OBJECT
+public:
+ QVncServer(QVncScreen *screen, quint16 port = 5900);
+ ~QVncServer();
+
+ enum ServerMsg { FramebufferUpdate = 0,
+ SetColourMapEntries = 1 };
+
+ void setDirty();
+
+
+ inline QVncScreen* screen() const { return qvnc_screen; }
+ inline QVncDirtyMap* dirtyMap() const { return qvnc_screen->dirty; }
+ QImage screenImage() const;
+ void discardClient(QVncClient *client);
+
+private slots:
+ void newConnection();
+ void init();
+
+private:
+ QTcpServer *serverSocket;
+ QVector<QVncClient*> clients;
+ QVncScreen *qvnc_screen;
+ quint16 m_port;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp
new file mode 100644
index 0000000000..dae3e83f37
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncclient.cpp
@@ -0,0 +1,662 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncclient.h"
+#include "qvnc_p.h"
+
+#include <QtNetwork/QTcpSocket>
+#include <QtCore/QCoreApplication>
+
+#include <qpa/qwindowsysteminterface.h>
+#include <QtGui/qguiapplication.h>
+
+#ifdef Q_OS_WIN
+#include <Winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QVncClient::QVncClient(QTcpSocket *clientSocket, QVncServer *server)
+ : QObject(server)
+ , m_server(server)
+ , m_clientSocket(clientSocket)
+ , m_encoder(nullptr)
+ , m_msgType(0)
+ , m_handleMsg(false)
+ , m_encodingsPending(0)
+ , m_cutTextPending(0)
+ , m_supportHextile(false)
+ , m_wantUpdate(false)
+ , m_keymod(0)
+ , m_dirtyCursor(false)
+ , m_updatePending(false)
+ , m_protocolVersion(V3_3)
+{
+ connect(m_clientSocket,SIGNAL(readyRead()),this,SLOT(readClient()));
+ connect(m_clientSocket,SIGNAL(disconnected()),this,SLOT(discardClient()));
+
+ // send protocol version
+ const char *proto = "RFB 003.003\n";
+ m_clientSocket->write(proto, 12);
+ m_state = Protocol;
+}
+
+QVncClient::~QVncClient()
+{
+ delete m_encoder;
+}
+
+QTcpSocket *QVncClient::clientSocket() const
+{
+ return m_clientSocket;
+}
+
+void QVncClient::setDirty(const QRegion &region)
+{
+ m_dirtyRegion += region;
+ if (m_state == Connected &&
+ ((m_server->dirtyMap()->numDirty > 0) || m_dirtyCursor)) {
+ scheduleUpdate();
+ }
+}
+
+void QVncClient::convertPixels(char *dst, const char *src, int count) const
+{
+ const int screendepth = m_server->screen()->depth();
+
+ // cutoffs
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (!m_swapBytes)
+#endif
+ if (m_sameEndian) {
+ if (screendepth == m_pixelFormat.bitsPerPixel) { // memcpy cutoffs
+
+ switch (screendepth) {
+ case 32:
+ memcpy(dst, src, count * sizeof(quint32));
+ return;
+ case 16:
+ if (m_pixelFormat.redBits == 5
+ && m_pixelFormat.greenBits == 6
+ && m_pixelFormat.blueBits == 5)
+ {
+ memcpy(dst, src, count * sizeof(quint16));
+ return;
+ }
+ }
+ }
+ }
+
+ const int bytesPerPixel = (m_pixelFormat.bitsPerPixel + 7) / 8;
+
+ for (int i = 0; i < count; ++i) {
+ int r, g, b;
+
+ switch (screendepth) {
+ case 8: {
+ QRgb rgb = m_server->screen()->image()->colorTable()[int(*src)];
+ r = qRed(rgb);
+ g = qGreen(rgb);
+ b = qBlue(rgb);
+ src++;
+ break;
+ }
+ case 16: {
+ quint16 p = *reinterpret_cast<const quint16*>(src);
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (swapBytes)
+ p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
+#endif
+ r = (p >> 11) & 0x1f;
+ g = (p >> 5) & 0x3f;
+ b = p & 0x1f;
+ r <<= 3;
+ g <<= 2;
+ b <<= 3;
+ src += sizeof(quint16);
+ break;
+ }
+ case 32: {
+ quint32 p = *reinterpret_cast<const quint32*>(src);
+ r = (p >> 16) & 0xff;
+ g = (p >> 8) & 0xff;
+ b = p & 0xff;
+ src += sizeof(quint32);
+ break;
+ }
+ default: {
+ r = g = b = 0;
+ qWarning("QVNCServer: don't support %dbpp display", screendepth);
+ return;
+ }
+ }
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (m_swapBytes)
+ qSwap(r, b);
+#endif
+
+ r >>= (8 - m_pixelFormat.redBits);
+ g >>= (8 - m_pixelFormat.greenBits);
+ b >>= (8 - m_pixelFormat.blueBits);
+
+ int pixel = (r << m_pixelFormat.redShift) |
+ (g << m_pixelFormat.greenShift) |
+ (b << m_pixelFormat.blueShift);
+
+ if (m_sameEndian || m_pixelFormat.bitsPerPixel == 8) {
+ memcpy(dst, &pixel, bytesPerPixel);
+ dst += bytesPerPixel;
+ continue;
+ }
+
+
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ switch (m_pixelFormat.bitsPerPixel) {
+ case 16:
+ pixel = (((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ case 32:
+ pixel = (((pixel & 0xff000000) >> 24) |
+ ((pixel & 0x00ff0000) >> 8) |
+ ((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ default:
+ qWarning("Cannot handle %d bpp client", m_pixelFormat.bitsPerPixel);
+ }
+ } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian
+ switch (m_pixelFormat.bitsPerPixel) {
+ case 16:
+ pixel = (((pixel & 0xff000000) >> 8) |
+ ((pixel & 0x00ff0000) << 8));
+ break;
+ case 32:
+ pixel = (((pixel & 0xff000000) >> 24) |
+ ((pixel & 0x00ff0000) >> 8) |
+ ((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ default:
+ qWarning("Cannot handle %d bpp client",
+ m_pixelFormat.bitsPerPixel);
+ break;
+ }
+ }
+ memcpy(dst, &pixel, bytesPerPixel);
+ dst += bytesPerPixel;
+ }
+}
+
+void QVncClient::readClient()
+{
+ qCDebug(lcVnc) << "readClient" << m_state;
+ switch (m_state) {
+ case Disconnected:
+
+ break;
+ case Protocol:
+ if (m_clientSocket->bytesAvailable() >= 12) {
+ char proto[13];
+ m_clientSocket->read(proto, 12);
+ proto[12] = '\0';
+ qCDebug(lcVnc, "Client protocol version %s", proto);
+ if (!strcmp(proto, "RFB 003.008\n")) {
+ m_protocolVersion = V3_8;
+ } else if (!strcmp(proto, "RFB 003.007\n")) {
+ m_protocolVersion = V3_7;
+ } else {
+ m_protocolVersion = V3_3;
+ }
+
+ if (m_protocolVersion == V3_3) {
+ // No authentication
+ quint32 auth = htonl(1);
+ m_clientSocket->write((char *) &auth, sizeof(auth));
+ m_state = Init;
+ }
+ }
+ break;
+ case Authentication:
+
+ break;
+ case Init:
+ if (m_clientSocket->bytesAvailable() >= 1) {
+ quint8 shared;
+ m_clientSocket->read((char *) &shared, 1);
+
+ // Server Init msg
+ QRfbServerInit sim;
+ QRfbPixelFormat &format = sim.format;
+ switch (m_server->screen()->depth()) {
+ case 32:
+ format.bitsPerPixel = 32;
+ format.depth = 32;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 8;
+ format.greenBits = 8;
+ format.blueBits = 8;
+ format.redShift = 16;
+ format.greenShift = 8;
+ format.blueShift = 0;
+ break;
+
+ case 24:
+ format.bitsPerPixel = 24;
+ format.depth = 24;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 8;
+ format.greenBits = 8;
+ format.blueBits = 8;
+ format.redShift = 16;
+ format.greenShift = 8;
+ format.blueShift = 0;
+ break;
+
+ case 18:
+ format.bitsPerPixel = 24;
+ format.depth = 18;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 6;
+ format.greenBits = 6;
+ format.blueBits = 6;
+ format.redShift = 12;
+ format.greenShift = 6;
+ format.blueShift = 0;
+ break;
+
+ case 16:
+ format.bitsPerPixel = 16;
+ format.depth = 16;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 5;
+ format.greenBits = 6;
+ format.blueBits = 5;
+ format.redShift = 11;
+ format.greenShift = 5;
+ format.blueShift = 0;
+ break;
+
+ case 15:
+ format.bitsPerPixel = 16;
+ format.depth = 15;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 5;
+ format.greenBits = 5;
+ format.blueBits = 5;
+ format.redShift = 10;
+ format.greenShift = 5;
+ format.blueShift = 0;
+ break;
+
+ case 12:
+ format.bitsPerPixel = 16;
+ format.depth = 12;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 4;
+ format.greenBits = 4;
+ format.blueBits = 4;
+ format.redShift = 8;
+ format.greenShift = 4;
+ format.blueShift = 0;
+ break;
+
+ case 8:
+ case 4:
+ format.bitsPerPixel = 8;
+ format.depth = 8;
+ format.bigEndian = 0;
+ format.trueColor = false;
+ format.redBits = 0;
+ format.greenBits = 0;
+ format.blueBits = 0;
+ format.redShift = 0;
+ format.greenShift = 0;
+ format.blueShift = 0;
+ break;
+
+ default:
+ qWarning("QVNC cannot drive depth %d", m_server->screen()->depth());
+ discardClient();
+ return;
+ }
+ sim.width = m_server->screen()->geometry().width();
+ sim.height = m_server->screen()->geometry().height();
+ sim.setName("Qt for Embedded Linux VNC Server");
+ sim.write(m_clientSocket);
+ m_state = Connected;
+ }
+ break;
+
+ case Connected:
+ do {
+ if (!m_handleMsg) {
+ m_clientSocket->read((char *)&m_msgType, 1);
+ m_handleMsg = true;
+ }
+ if (m_handleMsg) {
+ switch (m_msgType ) {
+ case SetPixelFormat:
+ setPixelFormat();
+ break;
+ case FixColourMapEntries:
+ qWarning("Not supported: FixColourMapEntries");
+ m_handleMsg = false;
+ break;
+ case SetEncodings:
+ setEncodings();
+ break;
+ case FramebufferUpdateRequest:
+ frameBufferUpdateRequest();
+ break;
+ case KeyEvent:
+ keyEvent();
+ break;
+ case PointerEvent:
+ pointerEvent();
+ break;
+ case ClientCutText:
+ clientCutText();
+ break;
+ default:
+ qWarning("Unknown message type: %d", (int)m_msgType);
+ m_handleMsg = false;
+ }
+ }
+ } while (!m_handleMsg && m_clientSocket->bytesAvailable());
+ break;
+ default:
+ break;
+ }
+}
+
+void QVncClient::discardClient()
+{
+ m_state = Disconnected;
+ m_server->discardClient(this);
+}
+
+void QVncClient::checkUpdate()
+{
+ if (!m_wantUpdate)
+ return;
+
+ if (m_dirtyCursor) {
+ m_server->screen()->clientCursor->write(this);
+ m_dirtyCursor = false;
+ m_wantUpdate = false;
+ return;
+ }
+
+ if (!m_dirtyRegion.isEmpty()) {
+ if (m_encoder)
+ m_encoder->write();
+ m_wantUpdate = false;
+ m_dirtyRegion = QRegion();
+ }
+}
+
+void QVncClient::scheduleUpdate()
+{
+ if (!m_updatePending) {
+ m_updatePending = true;
+ QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
+ }
+}
+
+bool QVncClient::event(QEvent *event)
+{
+ if (event->type() == QEvent::UpdateRequest) {
+ m_updatePending = false;
+ checkUpdate();
+ return true;
+ }
+ return QObject::event(event);
+}
+
+void QVncClient::setPixelFormat()
+{
+ if (m_clientSocket->bytesAvailable() >= 19) {
+ char buf[3];
+ m_clientSocket->read(buf, 3); // just padding
+ m_pixelFormat.read(m_clientSocket);
+ qCDebug(lcVnc, "Want format: %d %d %d %d %d %d %d %d %d %d",
+ int(m_pixelFormat.bitsPerPixel),
+ int(m_pixelFormat.depth),
+ int(m_pixelFormat.bigEndian),
+ int(m_pixelFormat.trueColor),
+ int(m_pixelFormat.redBits),
+ int(m_pixelFormat.greenBits),
+ int(m_pixelFormat.blueBits),
+ int(m_pixelFormat.redShift),
+ int(m_pixelFormat.greenShift),
+ int(m_pixelFormat.blueShift));
+ if (!m_pixelFormat.trueColor) {
+ qWarning("Can only handle true color clients");
+ discardClient();
+ }
+ m_handleMsg = false;
+ m_sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!m_pixelFormat.bigEndian;
+ m_needConversion = pixelConversionNeeded();
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ m_swapBytes = qvnc_screen->swapBytes();
+#endif
+ }
+}
+
+void QVncClient::setEncodings()
+{
+ QRfbSetEncodings enc;
+
+ if (!m_encodingsPending && enc.read(m_clientSocket)) {
+ m_encodingsPending = enc.count;
+ if (!m_encodingsPending)
+ m_handleMsg = false;
+ }
+
+ if (m_encoder) {
+ delete m_encoder;
+ m_encoder = nullptr;
+ }
+
+ enum Encodings {
+ Raw = 0,
+ CopyRect = 1,
+ RRE = 2,
+ CoRRE = 4,
+ Hextile = 5,
+ ZRLE = 16,
+ Cursor = -239,
+ DesktopSize = -223
+ };
+
+ if (m_encodingsPending && (unsigned)m_clientSocket->bytesAvailable() >=
+ m_encodingsPending * sizeof(quint32)) {
+ for (int i = 0; i < m_encodingsPending; ++i) {
+ qint32 enc;
+ m_clientSocket->read((char *)&enc, sizeof(qint32));
+ enc = ntohl(enc);
+ qCDebug(lcVnc, "QVncServer::setEncodings: %d", enc);
+ switch (enc) {
+ case Raw:
+ if (!m_encoder) {
+ m_encoder = new QRfbRawEncoder(this);
+ qCDebug(lcVnc, "QVncServer::setEncodings: using raw");
+ }
+ break;
+ case CopyRect:
+ m_supportCopyRect = true;
+ break;
+ case RRE:
+ m_supportRRE = true;
+ break;
+ case CoRRE:
+ m_supportCoRRE = true;
+ break;
+ case Hextile:
+ m_supportHextile = true;
+ if (m_encoder)
+ break;
+ break;
+ case ZRLE:
+ m_supportZRLE = true;
+ break;
+ case Cursor:
+ m_supportCursor = true;
+ m_server->screen()->enableClientCursor(this);
+ break;
+ case DesktopSize:
+ m_supportDesktopSize = true;
+ break;
+ default:
+ break;
+ }
+ }
+ m_handleMsg = false;
+ m_encodingsPending = 0;
+ }
+
+ if (!m_encoder) {
+ m_encoder = new QRfbRawEncoder(this);
+ qCDebug(lcVnc, "QVncServer::setEncodings: fallback using raw");
+ }
+}
+
+void QVncClient::frameBufferUpdateRequest()
+{
+ qCDebug(lcVnc) << "FramebufferUpdateRequest";
+ QRfbFrameBufferUpdateRequest ev;
+
+ if (ev.read(m_clientSocket)) {
+ if (!ev.incremental) {
+ QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h);
+ r.translate(m_server->screen()->geometry().topLeft());
+ setDirty(r);
+ }
+ m_wantUpdate = true;
+ checkUpdate();
+ m_handleMsg = false;
+ }
+}
+
+void QVncClient::pointerEvent()
+{
+ QRfbPointerEvent ev;
+ if (ev.read(m_clientSocket)) {
+ const QPoint pos = m_server->screen()->geometry().topLeft() + QPoint(ev.x, ev.y);
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, ev.buttons, QGuiApplication::keyboardModifiers());
+ m_handleMsg = false;
+ }
+}
+
+void QVncClient::keyEvent()
+{
+ QRfbKeyEvent ev;
+
+ if (ev.read(m_clientSocket)) {
+ if (ev.keycode == Qt::Key_Shift)
+ m_keymod = ev.down ? m_keymod | Qt::ShiftModifier :
+ m_keymod & ~Qt::ShiftModifier;
+ else if (ev.keycode == Qt::Key_Control)
+ m_keymod = ev.down ? m_keymod | Qt::ControlModifier :
+ m_keymod & ~Qt::ControlModifier;
+ else if (ev.keycode == Qt::Key_Alt)
+ m_keymod = ev.down ? m_keymod | Qt::AltModifier :
+ m_keymod & ~Qt::AltModifier;
+ if (ev.unicode || ev.keycode)
+ QWindowSystemInterface::handleKeyEvent(0, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode));
+ m_handleMsg = false;
+ }
+}
+
+void QVncClient::clientCutText()
+{
+ QRfbClientCutText ev;
+
+ if (m_cutTextPending == 0 && ev.read(m_clientSocket)) {
+ m_cutTextPending = ev.length;
+ if (!m_cutTextPending)
+ m_handleMsg = false;
+ }
+
+ if (m_cutTextPending && m_clientSocket->bytesAvailable() >= m_cutTextPending) {
+ char *text = new char [m_cutTextPending+1];
+ m_clientSocket->read(text, m_cutTextPending);
+ delete [] text;
+ m_cutTextPending = 0;
+ m_handleMsg = false;
+ }
+}
+
+bool QVncClient::pixelConversionNeeded() const
+{
+ if (!m_sameEndian)
+ return true;
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (qvnc_screen->swapBytes())
+ return true;
+#endif
+
+ const int screendepth = m_server->screen()->depth();
+ if (screendepth != m_pixelFormat.bitsPerPixel)
+ return true;
+
+ switch (screendepth) {
+ case 32:
+ case 24:
+ return false;
+ case 16:
+ return (m_pixelFormat.redBits == 5
+ && m_pixelFormat.greenBits == 6
+ && m_pixelFormat.blueBits == 5);
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvncclient.h b/src/plugins/platforms/vnc/qvncclient.h
new file mode 100644
index 0000000000..a7a6b6b361
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncclient.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVNCCLIENT_H
+#define QVNCCLIENT_H
+
+#include <QObject>
+
+#include "qvnc_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTcpSocket;
+class QVncServer;
+
+class QVncClient : public QObject
+{
+ Q_OBJECT
+public:
+ enum ClientMsg {
+ SetPixelFormat = 0,
+ FixColourMapEntries = 1,
+ SetEncodings = 2,
+ FramebufferUpdateRequest = 3,
+ KeyEvent = 4,
+ PointerEvent = 5,
+ ClientCutText = 6
+ };
+
+ explicit QVncClient(QTcpSocket *clientSocket, QVncServer *server);
+ ~QVncClient();
+ QTcpSocket *clientSocket() const;
+ QVncServer *server() const { return m_server; }
+
+ void setDirty(const QRegion &region);
+ void setDirtyCursor() { m_dirtyCursor = true; scheduleUpdate(); }
+ QRegion dirtyRegion() const { return m_dirtyRegion; }
+ inline bool isConnected() const { return m_state == Connected; }
+
+ inline int clientBytesPerPixel() const {
+ return m_pixelFormat.bitsPerPixel / 8;
+ }
+
+ void convertPixels(char *dst, const char *src, int count) const;
+ inline bool doPixelConversion() const { return m_needConversion; }
+
+signals:
+
+private slots:
+ void readClient();
+ void discardClient();
+ void checkUpdate();
+ void scheduleUpdate();
+
+protected:
+ bool event(QEvent *event) override;
+
+private:
+ enum ClientState {
+ Disconnected,
+ Protocol,
+ Authentication,
+ Init,
+ Connected
+ };
+ enum ProtocolVersion {
+ V3_3,
+ V3_7,
+ V3_8
+ };
+
+ void setPixelFormat();
+ void setEncodings();
+ void frameBufferUpdateRequest();
+ void pointerEvent();
+ void keyEvent();
+ void clientCutText();
+ bool pixelConversionNeeded() const;
+
+ QVncServer *m_server;
+ QTcpSocket *m_clientSocket;
+ QRfbEncoder *m_encoder;
+
+ // Client State
+ ClientState m_state;
+ quint8 m_msgType;
+ bool m_handleMsg;
+ QRfbPixelFormat m_pixelFormat;
+ bool m_sameEndian;
+ bool m_needConversion;
+ int m_encodingsPending;
+ int m_cutTextPending;
+ uint m_supportCopyRect : 1;
+ uint m_supportRRE : 1;
+ uint m_supportCoRRE : 1;
+ uint m_supportHextile : 1;
+ uint m_supportZRLE : 1;
+ uint m_supportCursor : 1;
+ uint m_supportDesktopSize : 1;
+ bool m_wantUpdate;
+ Qt::KeyboardModifiers m_keymod;
+ bool m_dirtyCursor;
+ bool m_updatePending;
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ bool m_swapBytes;
+#endif
+ QRegion m_dirtyRegion;
+ ProtocolVersion m_protocolVersion;
+};
+
+QT_END_NAMESPACE
+
+#endif // QVNCCLIENT_H
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp
new file mode 100644
index 0000000000..025112c790
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncintegration.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncintegration.h"
+#include "qvncscreen.h"
+#include "qvnc_p.h"
+
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
+
+#include <QtFbSupport/private/qfbbackingstore_p.h>
+#include <QtFbSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatforminputcontextfactory_p.h>
+#include <private/qinputdevicemanager_p_p.h>
+#if QT_CONFIG(libinput)
+#include <QtInputSupport/private/qlibinputhandler_p.h>
+#endif
+
+#include <QtCore/QRegularExpression>
+
+QT_BEGIN_NAMESPACE
+
+QVncIntegration::QVncIntegration(const QStringList &paramList)
+ : m_fontDb(new QGenericUnixFontDatabase),
+ m_services(new QGenericUnixServices)
+{
+ QRegularExpression portRx(QLatin1String("port=(\\d+)"));
+ quint16 port = 5900;
+ for (const QString &arg : paramList) {
+ QRegularExpressionMatch match;
+ if (arg.contains(portRx, &match))
+ port = match.captured(1).toInt();
+ }
+
+ m_primaryScreen = new QVncScreen(paramList);
+ m_server = new QVncServer(m_primaryScreen, port);
+ m_primaryScreen->vncServer = m_server;
+}
+
+QVncIntegration::~QVncIntegration()
+{
+ delete m_server;
+ destroyScreen(m_primaryScreen);
+}
+
+void QVncIntegration::initialize()
+{
+ if (m_primaryScreen->initialize())
+ screenAdded(m_primaryScreen);
+ else
+ qWarning("vnc: Failed to initialize screen");
+
+ m_inputContext = QPlatformInputContextFactory::create();
+
+ m_nativeInterface.reset(new QPlatformNativeInterface);
+
+ // we always have exactly one mouse and keyboard
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypePointer, 1);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeKeyboard, 1);
+
+}
+
+bool QVncIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ case WindowManagement: return false;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPlatformBackingStore *QVncIntegration::createPlatformBackingStore(QWindow *window) const
+{
+ return new QFbBackingStore(window);
+}
+
+QPlatformWindow *QVncIntegration::createPlatformWindow(QWindow *window) const
+{
+ return new QFbWindow(window);
+}
+
+QAbstractEventDispatcher *QVncIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
+QList<QPlatformScreen *> QVncIntegration::screens() const
+{
+ QList<QPlatformScreen *> list;
+ list.append(m_primaryScreen);
+ return list;
+}
+
+QPlatformFontDatabase *QVncIntegration::fontDatabase() const
+{
+ return m_fontDb.data();
+}
+
+QPlatformServices *QVncIntegration::services() const
+{
+ return m_services.data();
+}
+
+QPlatformNativeInterface *QVncIntegration::nativeInterface() const
+{
+ return m_nativeInterface.data();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.h b/src/plugins/platforms/vnc/qvncintegration.h
index 8539bcb9db..293ff54376 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.h
+++ b/src/plugins/platforms/vnc/qvncintegration.h
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,43 +37,49 @@
**
****************************************************************************/
-#ifndef QWINRTFONTDATABASE_H
-#define QWINRTFONTDATABASE_H
+#ifndef QVNCINTEGRATION_H
+#define QVNCINTEGRATION_H
-#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
-#include <QtCore/QLoggingCategory>
-
-struct IDWriteFontFile;
-struct IDWriteFontFamily;
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
-Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts)
-
-struct FontDescription
-{
- quint32 index;
- QByteArray uuid;
-};
+class QAbstractEventDispatcher;
+class QVncScreen;
+class QVncServer;
-class QWinRTFontDatabase : public QBasicFontDatabase
+class QVncIntegration : public QPlatformIntegration, public QPlatformNativeInterface
{
public:
- QString fontDir() const;
- ~QWinRTFontDatabase();
- QFont defaultFont() const Q_DECL_OVERRIDE;
- bool fontsAlwaysScalable() const Q_DECL_OVERRIDE;
- void populateFontDatabase() Q_DECL_OVERRIDE;
- void populateFamily(const QString &familyName) Q_DECL_OVERRIDE;
- QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
- QStringList fallbacksForFamily(const QString &family, QFont::Style style,
- QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE;
- void releaseHandle(void *handle) Q_DECL_OVERRIDE;
+ QVncIntegration(const QStringList &paramList);
+ ~QVncIntegration();
+
+ void initialize() Q_DECL_OVERRIDE;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
+
+ QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
+
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
+
+ QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
+ QPlatformServices *services() const Q_DECL_OVERRIDE;
+ QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE { return m_inputContext; }
+
+ QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
+
+ QList<QPlatformScreen *> screens() const;
+
private:
- QHash<IDWriteFontFile *, FontDescription> m_fonts;
- QHash<QString, IDWriteFontFamily *> m_fontFamilies;
+ mutable QVncServer *m_server;
+ QVncScreen *m_primaryScreen;
+ QPlatformInputContext *m_inputContext;
+ QScopedPointer<QPlatformFontDatabase> m_fontDb;
+ QScopedPointer<QPlatformServices> m_services;
+ QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
};
QT_END_NAMESPACE
-#endif // QWINRTFONTDATABASE_H
+#endif // QVNCINTEGRATION_H
diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp
new file mode 100644
index 0000000000..34def45767
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncscreen.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncscreen.h"
+#include "qvnc_p.h"
+#include <QtFbSupport/private/qfbwindow_p.h>
+#include <QtFbSupport/private/qfbcursor_p.h>
+
+#include <QtGui/QPainter>
+#include <QtCore/QRegularExpression>
+
+
+QT_BEGIN_NAMESPACE
+
+
+QVncScreen::QVncScreen(const QStringList &args)
+ : mArgs(args)
+{
+ initialize();
+}
+
+QVncScreen::~QVncScreen()
+{
+ if (clientCursor)
+ delete clientCursor;
+}
+
+bool QVncScreen::initialize()
+{
+ QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)"));
+ QRegularExpression mmSizeRx(QLatin1String("mmsize=(?<width>(\\d*\\.)?\\d+)x(?<height>(\\d*\\.)?\\d+)"));
+ QRegularExpression depthRx(QLatin1String("depth=(\\d+)"));
+
+ mGeometry = QRect(0, 0, 1024, 768);
+ mFormat = QImage::Format_ARGB32_Premultiplied;
+ mDepth = 32;
+ mPhysicalSize = QSizeF(mGeometry.width()/96.*25.4, mGeometry.height()/96.*25.4);
+
+ for (const QString &arg : mArgs) {
+ QRegularExpressionMatch match;
+ if (arg.contains(mmSizeRx, &match)) {
+ mPhysicalSize = QSizeF(match.captured("width").toDouble(), match.captured("height").toDouble());
+ } else if (arg.contains(sizeRx, &match)) {
+ mGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
+ } else if (arg.contains(depthRx, &match)) {
+ mDepth = match.captured(1).toInt();
+ }
+ }
+
+ QFbScreen::initializeCompositor();
+
+ switch (depth()) {
+ case 32:
+ dirty = new QVncDirtyMapOptimized<quint32>(this);
+ break;
+ case 16:
+ dirty = new QVncDirtyMapOptimized<quint16>(this);
+ break;
+ case 8:
+ dirty = new QVncDirtyMapOptimized<quint8>(this);
+ break;
+ default:
+ qWarning("QVNCScreen::initDevice: No support for screen depth %d",
+ depth());
+ dirty = 0;
+ return false;
+ }
+
+ setPowerState(PowerStateOff);
+
+ return true;
+}
+
+QRegion QVncScreen::doRedraw()
+{
+ QRegion touched = QFbScreen::doRedraw();
+
+ if (touched.isEmpty())
+ return touched;
+ dirtyRegion += touched;
+
+ vncServer->setDirty();
+ return touched;
+}
+
+void QVncScreen::enableClientCursor(QVncClient *client)
+{
+ delete mCursor;
+ mCursor = nullptr;
+ if (!clientCursor)
+ clientCursor = new QVncClientCursor();
+ clientCursor->addClient(client);
+}
+
+void QVncScreen::disableClientCursor(QVncClient *client)
+{
+ uint clientCount = clientCursor->removeClient(client);
+ if (clientCount == 0) {
+ delete clientCursor;
+ clientCursor = nullptr;
+ }
+
+ mCursor = new QFbCursor(this);
+}
+
+QPlatformCursor *QVncScreen::cursor() const
+{
+ return mCursor ? static_cast<QPlatformCursor *>(mCursor) : static_cast<QPlatformCursor *>(clientCursor);
+}
+
+// grabWindow() grabs "from the screen" not from the backingstores.
+// In linuxfb's case it will also include the mouse cursor.
+QPixmap QVncScreen::grabWindow(WId wid, int x, int y, int width, int height) const
+{
+ if (!wid) {
+ if (width < 0)
+ width = mScreenImage->width() - x;
+ if (height < 0)
+ height = mScreenImage->height() - y;
+ return QPixmap::fromImage(*mScreenImage).copy(x, y, width, height);
+ }
+
+ QFbWindow *window = windowForId(wid);
+ if (window) {
+ const QRect geom = window->geometry();
+ if (width < 0)
+ width = geom.width() - x;
+ if (height < 0)
+ height = geom.height() - y;
+ QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
+ rect &= window->geometry();
+ return QPixmap::fromImage(*mScreenImage).copy(rect);
+ }
+
+ return QPixmap();
+}
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+bool QVNCScreen::swapBytes() const
+{
+ if (depth() != 16)
+ return false;
+
+ if (screen())
+ return screen()->frameBufferLittleEndian();
+ return frameBufferLittleEndian();
+}
+#endif
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/platforms/vnc/qvncscreen.h b/src/plugins/platforms/vnc/qvncscreen.h
new file mode 100644
index 0000000000..785abd6dc2
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncscreen.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVncScreen_H
+#define QVncScreen_H
+
+#include <QtFbSupport/private/qfbscreen_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+class QFbCursor;
+class QTcpSocket;
+class QVncServer;
+class QVncDirtyMap;
+class QVncClientCursor;
+class QVncClient;
+
+class QVncScreen : public QFbScreen
+{
+ Q_OBJECT
+public:
+ QVncScreen(const QStringList &args);
+ ~QVncScreen();
+
+ bool initialize();
+
+ QPixmap grabWindow(WId wid, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
+
+ QRegion doRedraw() Q_DECL_OVERRIDE;
+ QImage *image() const { return mScreenImage; }
+
+ void enableClientCursor(QVncClient *client);
+ void disableClientCursor(QVncClient *client);
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
+
+ void clearDirty() { dirtyRegion = QRegion(); }
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ bool swapBytes() const
+#endif
+
+ QStringList mArgs;
+
+ qreal dpiX = 96;
+ qreal dpiY = 96;
+ QVncDirtyMap *dirty = 0;
+ QRegion dirtyRegion;
+ int refreshRate = 30;
+ QVncServer *vncServer = 0;
+ QVncClientCursor *clientCursor = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QVncScreen_H
+
diff --git a/src/plugins/platforms/vnc/vnc.json b/src/plugins/platforms/vnc/vnc.json
new file mode 100644
index 0000000000..6a16b08ca8
--- /dev/null
+++ b/src/plugins/platforms/vnc/vnc.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "vnc" ]
+}
diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro
new file mode 100644
index 0000000000..3cd7e9b160
--- /dev/null
+++ b/src/plugins/platforms/vnc/vnc.pro
@@ -0,0 +1,31 @@
+TARGET = qvnc
+
+PLUGIN_TYPE = platforms
+PLUGIN_CLASS_NAME = QVncIntegrationPlugin
+!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
+load(qt_plugin)
+
+QT += \
+ core-private network gui-private \
+ service_support-private theme_support-private fb_support-private \
+ eventdispatcher_support-private fontdatabase_support-private
+
+qtHaveModule(input_support-private): \
+ QT += input_support-private
+
+DEFINES += QT_NO_FOREACH
+
+SOURCES = \
+ main.cpp \
+ qvncintegration.cpp \
+ qvncscreen.cpp \
+ qvnc.cpp \
+ qvncclient.cpp
+
+HEADERS = \
+ qvncintegration.h \
+ qvncscreen.h \
+ qvnc_p.h \
+ qvncclient.h
+
+OTHER_FILES += vnc.json
diff --git a/src/plugins/platforms/windows/accessible/accessible.pri b/src/plugins/platforms/windows/accessible/accessible.pri
index 0774d907f2..0e3aacc558 100644
--- a/src/plugins/platforms/windows/accessible/accessible.pri
+++ b/src/plugins/platforms/windows/accessible/accessible.pri
@@ -6,15 +6,13 @@ HEADERS += \
$$PWD/qwindowsaccessibility.h \
$$PWD/comutils.h
-!wince: {
- SOURCES += $$PWD/qwindowsmsaaaccessible.cpp
- HEADERS += $$PWD/qwindowsmsaaaccessible.h
+SOURCES += $$PWD/qwindowsmsaaaccessible.cpp
+HEADERS += $$PWD/qwindowsmsaaaccessible.h
- !mingw: {
- SOURCES += $$PWD/iaccessible2.cpp
- HEADERS += $$PWD/iaccessible2.h
- include(../../../../3rdparty/iaccessible2/iaccessible2.pri)
- }
+!mingw: {
+ SOURCES += $$PWD/iaccessible2.cpp
+ HEADERS += $$PWD/iaccessible2.h
+ include(../../../../3rdparty/iaccessible2/iaccessible2.pri)
}
mingw: LIBS *= -luuid
diff --git a/src/plugins/platforms/windows/accessible/comutils.cpp b/src/plugins/platforms/windows/accessible/comutils.cpp
index 7655bdf622..1c072c5e2c 100644
--- a/src/plugins/platforms/windows/accessible/comutils.cpp
+++ b/src/plugins/platforms/windows/accessible/comutils.cpp
@@ -170,7 +170,6 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
case QVariant::LongLong:
if (out && arg.vt == (VT_CY|VT_BYREF)) {
arg.pcyVal->int64 = qvar.toLongLong();
-#if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
} else if (out && arg.vt == (VT_I8|VT_BYREF)) {
*arg.pllVal = qvar.toLongLong();
} else {
@@ -181,22 +180,11 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
arg.vt |= VT_BYREF;
}
}
-#else
- } else {
- arg.vt = VT_CY;
- arg.cyVal.int64 = qvar.toLongLong();
- if (out) {
- arg.pcyVal = new CY(arg.cyVal);
- arg.vt |= VT_BYREF;
- }
- }
-#endif
break;
case QVariant::ULongLong:
if (out && arg.vt == (VT_CY|VT_BYREF)) {
arg.pcyVal->int64 = qvar.toULongLong();
-#if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
} else if (out && arg.vt == (VT_UI8|VT_BYREF)) {
*arg.pullVal = qvar.toULongLong();
} else {
@@ -207,18 +195,6 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
arg.vt |= VT_BYREF;
}
}
-#else
- } else {
- arg.vt = VT_CY;
- arg.cyVal.int64 = qvar.toULongLong();
- if (out) {
- arg.pcyVal = new CY(arg.cyVal);
- arg.vt |= VT_BYREF;
- }
- }
-
-#endif
-
break;
case QVariant::Bool:
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
index 5ba49a8a98..d5cd9ac6db 100644
--- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp
+++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
@@ -41,7 +41,7 @@
#include "iaccessible2.h"
#include "qwindowsaccessibility.h"
-#include <QtPlatformSupport/private/qaccessiblebridgeutils_p.h>
+#include <QtAccessibilitySupport/private/qaccessiblebridgeutils_p.h>
#include <QtGui/qaccessible.h>
#include <QtGui/qclipboard.h>
#include <QtGui/qguiapplication.h>
diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
index 4a3f0ccb2b..aed9c94003 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
@@ -47,21 +47,19 @@
#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
#include <QtCore/qpointer.h>
-#include <QtCore/qsettings.h>
#include <QtGui/qaccessible.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformintegration.h>
#include <QtGui/qwindow.h>
#include <QtGui/qguiapplication.h>
+#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h> // registry helper
#include "qwindowsaccessibility.h"
-#if !defined(Q_OS_WINCE)
-# ifdef Q_CC_MINGW
-# include "qwindowsmsaaaccessible.h"
-# else
-# include "iaccessible2.h"
-# endif
+#ifdef Q_CC_MINGW
+# include "qwindowsmsaaaccessible.h"
+#else
+# include "iaccessible2.h"
#endif
#include "comutils.h"
@@ -74,11 +72,7 @@
#include <winuser.h>
#if !defined(WINABLEAPI)
-# if defined(Q_OS_WINCE)
-# include <bldver.h>
-# else
-# include <winable.h>
-# endif
+# include <winable.h>
#endif
#include <servprov.h>
@@ -86,7 +80,7 @@
#include <comdef.h>
#endif
-#include "../qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
@@ -120,6 +114,14 @@ static inline QString messageBoxAlertSound(const QObject *messageBox)
return QString();
}
+static QString soundFileName(const QString &soundName)
+{
+ const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\")
+ + soundName + QStringLiteral("\\.Current");
+ return QWindowsFontDatabase::readRegistryString(HKEY_CURRENT_USER,
+ reinterpret_cast<const wchar_t *>(key.utf16()), L"");
+}
+
void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
{
QString soundName;
@@ -140,23 +142,11 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
break;
}
- if (!soundName.isEmpty()) {
-#ifndef QT_NO_SETTINGS
- QSettings settings(QLatin1String("HKEY_CURRENT_USER\\AppEvents\\Schemes\\Apps\\.Default\\") + soundName,
- QSettings::NativeFormat);
- QString file = settings.value(QLatin1String(".Current/.")).toString();
-#else
- QString file;
-#endif
- if (!file.isEmpty()) {
- PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), 0, SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT);
- }
+ if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) {
+ PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), 0,
+ SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT);
}
-#if defined(Q_OS_WINCE) // ### TODO: check for NotifyWinEvent in CE 6.0
- // There is no user32.lib nor NotifyWinEvent for CE
- return;
-#else
// An event has to be associated with a window,
// so find the first parent that is a widget and that has a WId
QAccessibleInterface *iface = event->accessibleInterface();
@@ -179,7 +169,6 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
event->type() != QAccessible::ObjectDestroyed) {
::NotifyWinEvent(event->type(), hWnd, OBJID_CLIENT, QAccessible::uniqueId(iface));
}
-#endif // Q_OS_WINCE
}
QWindow *QWindowsAccessibility::windowHelper(const QAccessibleInterface *iface)
@@ -202,11 +191,6 @@ QWindow *QWindowsAccessibility::windowHelper(const QAccessibleInterface *iface)
*/
IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc)
{
-#if defined(Q_OS_WINCE)
- Q_UNUSED(acc);
-
- return 0;
-#else
if (!acc)
return 0;
@@ -222,12 +206,10 @@ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc)
IAccessible *iacc = 0;
wacc->QueryInterface(IID_IAccessible, reinterpret_cast<void **>(&iacc));
return iacc;
-#endif // defined(Q_OS_WINCE)
}
bool QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(HWND hwnd, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{
-#if !defined(Q_OS_WINCE)
if (static_cast<long>(lParam) == static_cast<long>(UiaRootObjectId)) {
/* For UI Automation */
} else if (DWORD(lParam) == DWORD(OBJID_CLIENT)) {
@@ -263,12 +245,6 @@ bool QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(HWND hwnd, W
}
}
}
-#else
- Q_UNUSED(hwnd);
- Q_UNUSED(wParam);
- Q_UNUSED(lParam);
- Q_UNUSED(lResult);
-#endif // !defined(Q_OS_WINCE)
return false;
}
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
index 0e2165cdcb..9803dedb1e 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
@@ -50,7 +50,6 @@
#include <QtCore/qdebug.h>
#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
-#include <QtCore/qsettings.h>
#include <QtGui/qaccessible.h>
#include <QtGui/qguiapplication.h>
#include <qpa/qplatformnativeinterface.h>
@@ -67,7 +66,7 @@
#endif
-#include "../qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
index 2f8602e320..fd00f8ac8b 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
@@ -43,7 +43,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include <QtCore/qglobal.h>
-#include "../qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/qsharedpointer.h>
#include <QtGui/qaccessible.h>
#ifndef Q_CC_MINGW
diff --git a/src/plugins/platforms/windows/qplatformfunctions_wince.h b/src/plugins/platforms/windows/qplatformfunctions_wince.h
deleted file mode 100644
index 309191537a..0000000000
--- a/src/plugins/platforms/windows/qplatformfunctions_wince.h
+++ /dev/null
@@ -1,371 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMFUNCTIONS_WCE_H
-#define QPLATFORMFUNCTIONS_WCE_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is part of the QPA API and is not meant to be used
-// in applications. Usage of this API may make your code
-// source and binary incompatible with future versions of Qt.
-//
-
-#ifdef Q_OS_WINCE
-#include <QtCore/qfunctions_wince.h>
-#define UNDER_NT
-#include <wingdi.h>
-#include <objidl.h>
-
-#ifndef WM_MOUSELEAVE
-# define WM_MOUSELEAVE 0x02A3
-#endif
-
-#ifndef WM_TOUCH
-# define WM_TOUCH 0x0240
-#endif
-
-#ifndef WM_GETOBJECT
-#define WM_GETOBJECT 0x003D
-#endif
-
-#define GetWindowLongPtr GetWindowLong
-#define SetWindowLongPtr SetWindowLong
-#define GWLP_USERDATA GWL_USERDATA
-
-#ifndef CWP_SKIPINVISIBLE
-#define CWP_SKIPINVISIBLE 0x0001
-#define CWP_SKIPTRANSPARENT 0x0004
-#endif
-
-#ifndef CS_OWNDC
-#define CS_OWNDC 0x0020
-#endif
-
-#ifndef HWND_MESSAGE
-#define HWND_MESSAGE 0
-#endif
-
-// Real Value would be 0x40000000, but if we pass this to Windows Embedded Compact
-// he blits it wrongly, so lets not do any harm and define it to 0
-#ifndef CAPTUREBLT
-#define CAPTUREBLT (DWORD)0x0
-#endif
-
-#define SW_SHOWMINIMIZED SW_MINIMIZE
-#define SW_SHOWMINNOACTIVE SW_MINIMIZE
-
-#ifndef CF_DIBV5
-#define CF_DIBV5 17
-#endif
-
-#ifndef WM_MOUSEACTIVATE
-#define WM_MOUSEACTIVATE 0x0021
-#endif
-
-#ifndef WM_CHILDACTIVATE
-#define WM_CHILDACTIVATE 0x0022
-#endif
-
-#ifndef WM_PARENTNOTIFY
-#define WM_PARENTNOTIFY 0x0210
-#endif
-
-#ifndef WM_ENTERIDLE
-#define WM_ENTERIDLE 0x0121
-#endif
-
-#ifndef WM_GETMINMAXINFO
-#define WM_GETMINMAXINFO 0x0024
-#endif
-
-#ifndef WM_WINDOWPOSCHANGING
-#define WM_WINDOWPOSCHANGING 0x0046
-#endif
-
-#ifndef WM_NCMOUSEMOVE
-#define WM_NCMOUSEMOVE 0x00A0
-#endif
-
-#ifndef WM_NCMBUTTONDBLCLK
-#define WM_NCMBUTTONDBLCLK 0x00A
-#endif
-
-#ifndef WM_NCCREATE
-#define WM_NCCREATE 0x0081
-#endif
-
-#ifndef WM_NCCALCSIZE
-#define WM_NCCALCSIZE 0x0083
-#endif
-
-#ifndef WM_NCACTIVATE
-#define WM_NCACTIVATE 0x0086
-#endif
-
-#ifndef WM_NCMOUSELEAVE
-#define WM_NCMOUSELEAVE 0x02A2
-#endif
-
-#ifndef WM_NCLBUTTONDOWN
-#define WM_NCLBUTTONDOWN 0x00A1
-#endif
-
-#ifndef WM_NCLBUTTONUP
-#define WM_NCLBUTTONUP 0x00A2
-#endif
-
-#ifndef WM_NCPAINT
-#define WM_NCPAINT 0x0085
-#endif
-
-#ifndef WM_NCHITTEST
-#define WM_NCHITTEST 0x0084
-#endif
-
-#ifndef WM_THEMECHANGED
-#define WM_THEMECHANGED 0x031A
-#endif
-
-#ifndef WM_DISPLAYCHANGE
-#define WM_DISPLAYCHANGE 0x007E
-#endif
-
-#ifndef VREFRESH
-#define VREFRESH 116
-#endif
-
-#ifndef SM_SWAPBUTTON
-#define SM_SWAPBUTTON 23
-#endif
-
-// application defines
-#define SPI_SETNONCLIENTMETRICS 72
-#define SPI_SETICONTITLELOGFONT 0x0022
-#define WM_ACTIVATEAPP 0x001c
-#define SW_PARENTCLOSING 1
-#define SW_OTHERMAXIMIZED 2
-#define SW_PARENTOPENING 3
-#define SW_OTHERRESTORED 4
-#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
-
-// drag n drop
-#ifndef CFSTR_PERFORMEDDROPEFFECT
-#define CFSTR_PERFORMEDDROPEFFECT TEXT("Performed DropEffect")
-#endif
-
-// QWidget
-#define SW_SHOWMINIMIZED SW_MINIMIZE
-
-// QRegion
-#define ALTERNATE 0
-#define WINDING 1
-
-// QFontEngine
-typedef struct _FIXED {
- WORD fract;
- short value;
-} FIXED;
-
-typedef struct tagPOINTFX {
- FIXED x;
- FIXED y;
-} POINTFX;
-
-typedef struct _MAT2 {
- FIXED eM11;
- FIXED eM12;
- FIXED eM21;
- FIXED eM22;
-} MAT2;
-
-typedef struct _GLYPHMETRICS {
- UINT gmBlackBoxX;
- UINT gmBlackBoxY;
- POINT gmptGlyphOrigin;
- short gmCellIncX;
- short gmCellIncY;
-} GLYPHMETRICS;
-
-typedef struct tagTTPOLYGONHEADER
-{
- DWORD cb;
- DWORD dwType;
- POINTFX pfxStart;
-} TTPOLYGONHEADER;
-
-typedef struct tagTTPOLYCURVE
-{
- WORD wType;
- WORD cpfx;
- POINTFX apfx[1];
-} TTPOLYCURVE;
-
-#define GGO_NATIVE 2
-#define GGO_GLYPH_INDEX 0x0080
-#define TT_PRIM_LINE 1
-#define TT_PRIM_QSPLINE 2
-#define TT_PRIM_CSPLINE 3
-#define ANSI_VAR_FONT 12
-
-#ifndef OleInitialize
-#define OleInitialize(a) 0
-#endif
-
-#ifndef SPI_GETSNAPTODEFBUTTON
-#define SPI_GETSNAPTODEFBUTTON 95
-#endif
-
-#ifndef WS_EX_LAYERED
-#define WS_EX_LAYERED 0x00080000
-#endif
-
-// Clipboard --------------------------------------------------------
-#ifndef WM_CHANGECBCHAIN
-#define WM_CHANGECBCHAIN 0x030D
-#endif
-
-#ifndef WM_DRAWCLIPBOARD
-#define WM_DRAWCLIPBOARD 0x0308
-#endif
-
-#include <QFileInfo>
-
-inline bool IsIconic( HWND /*hWnd*/ )
-{
- return false;
-}
-
-inline int AddFontResourceExW( LPCWSTR name, DWORD /*fl*/, PVOID /*res*/)
-{
- QString fName = QString::fromWCharArray(name);
- QFileInfo fileinfo(fName);
- fName = fileinfo.absoluteFilePath();
- return AddFontResource((LPCWSTR)fName.utf16());
-}
-
-inline bool RemoveFontResourceExW( LPCWSTR /*name*/, DWORD /*fl*/, PVOID /*pdv*/)
-{
- return 0;
-}
-
-inline void OleUninitialize()
-{
-}
-
-inline DWORD GetGlyphOutline( HDC /*hdc*/, UINT /*uChar*/, INT /*fuFormat*/, GLYPHMETRICS * /*lpgm*/,
- DWORD /*cjBuffer*/, LPVOID /*pvBuffer*/, CONST MAT2 * /*lpmat2*/ )
-{
- qFatal("GetGlyphOutline() not supported under Windows CE. Please try using freetype font-rendering, by "
- "passing the command line argument -platform windows:fontengine=freetype to the application.");
- return GDI_ERROR;
-}
-
-inline HWND GetAncestor(HWND hWnd, UINT /*gaFlags*/)
-{
- return GetParent(hWnd);
-}
-
-#ifndef GA_PARENT
-# define GA_PARENT 1
-#endif
-
-#ifndef SPI_SETFONTSMOOTHINGTYPE
-# define SPI_SETFONTSMOOTHINGTYPE 0x200B
-#endif
-#ifndef SPI_GETFONTSMOOTHINGTYPE
-# define SPI_GETFONTSMOOTHINGTYPE 0x200A
-#endif
-#ifndef FE_FONTSMOOTHINGCLEARTYPE
-# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
-#endif
-
-#ifndef DEVICE_FONTTYPE
-#define DEVICE_FONTTYPE 0x0002
-#endif
-
-#ifndef RASTER_FONTTYPE
-#define RASTER_FONTTYPE 0x0001
-#endif
-
-#ifndef WM_DISPLAYCHANGE
-#define WM_DISPLAYCHANGE 0x007E
-#endif
-
-BOOL qt_wince_ChangeClipboardChain(
- HWND hWndRemove, // handle to window to remove
- HWND hWndNewNext // handle to next window
-);
-#define ChangeClipboardChain(a,b) qt_wince_ChangeClipboardChain(a,b);
-
-HWND qt_wince_SetClipboardViewer(
- HWND hWndNewViewer // handle to clipboard viewer window
-);
-#define SetClipboardViewer(a) qt_wince_SetClipboardViewer(a)
-
-/* Shell stock icon IDs
- SHGetStockIconInfo() is not available on CE, but we're using these
- constants in code that is built on CE as well */
- enum
- {
- SIID_INVALID = -1,
- SIID_DOCNOASSOC = 0,
- SIID_FOLDER = 3,
- SIID_FOLDEROPEN = 4,
- SIID_DRIVE35 = 6,
- SIID_DRIVEFIXED = 8,
- SIID_DRIVENET = 9,
- SIID_DRIVECD = 11,
- SIID_HELP = 23,
- SIID_RECYCLER = 31,
- SIID_DRIVEDVD = 59,
- SIID_SHIELD = 77,
- SIID_WARNING = 78,
- SIID_INFO = 79,
- SIID_ERROR = 80
-};
-
-#ifndef SHGSI_LINKOVERLAY
-// Value is wrong, but doesn't matter, not used at runtime
-#define SHGSI_LINKOVERLAY 0
-#endif
-
-#endif // Q_OS_WINCE
-#endif // QPLATFORMFUNCTIONS_WCE_H
diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h
deleted file mode 100644
index 898a09fba7..0000000000
--- a/src/plugins/platforms/windows/qtwindows_additional.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTWINDOWS_ADDITIONAL_H
-#define QTWINDOWS_ADDITIONAL_H
-
-#include <QtCore/QtGlobal> // get compiler define
-#include <QtCore/qt_windows.h>
-
-#ifndef WM_THEMECHANGED
-# define WM_THEMECHANGED 0x031A
-#endif
-
-#ifndef WM_DWMCOMPOSITIONCHANGED
-# define WM_DWMCOMPOSITIONCHANGED 0x31E
-#endif
-
-#ifndef GWL_HWNDPARENT
-# define GWL_HWNDPARENT (-8)
-#endif
-
-/* Complement the definitions and declarations missing
- * when using MinGW or older Windows SDKs. */
-
-#if defined(Q_CC_MINGW)
-# if !defined(ULW_ALPHA)
-# define ULW_ALPHA 0x00000002
-# define LWA_ALPHA 0x00000002
-# endif // !defined(ULW_ALPHA)
-# define SPI_GETFONTSMOOTHINGTYPE 0x200A
-# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
-# define CLEARTYPE_QUALITY 5
-# define SPI_GETDROPSHADOW 0x1024
-# define COLOR_MENUHILIGHT 29
-# define COLOR_MENUBAR 30
-# define CF_DIBV5 17
-
-#if !defined(CO_E_NOT_SUPPORTED)
-#define CO_E_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x80004021L)
-#endif
-
-#define IFMETHOD HRESULT STDMETHODCALLTYPE
-#define IFACEMETHODIMP STDMETHODIMP
-#define IFACEMETHODIMP_(type) STDMETHODIMP_(type)
-
-// For accessibility:
-#ifdef __cplusplus
- #define EXTERN_C extern "C"
-#else
- #define EXTERN_C extern
-#endif
-
-#define CHILDID_SELF 0
-#define WM_GETOBJECT 0x003D
-
-#ifndef SHGFI_ADDOVERLAYS // Shell structures for icons.
-typedef struct _SHSTOCKICONINFO
-{
- DWORD cbSize;
- HICON hIcon;
- int iSysImageIndex;
- int iIcon;
- WCHAR szPath[MAX_PATH];
-} SHSTOCKICONINFO;
-
-# define SIID_SHIELD 77
-# define SHGFI_ADDOVERLAYS 0x20
-# define SHGFI_OVERLAYINDEX 0x40
-#endif // SIID_SHIELD
-
-#if !defined(__MINGW64_VERSION_MAJOR)
-
-#define STATE_SYSTEM_HASPOPUP 0x40000000
-#define STATE_SYSTEM_PROTECTED 0x20000000
-
-typedef struct tagUPDATELAYEREDWINDOWINFO {
- DWORD cbSize;
- HDC hdcDst;
- const POINT *pptDst;
- const SIZE *psize;
- HDC hdcSrc;
- const POINT *pptSrc;
- COLORREF crKey;
- const BLENDFUNCTION *pblend;
- DWORD dwFlags;
- const RECT *prcDirty;
-} UPDATELAYEREDWINDOWINFO, *PUPDATELAYEREDWINDOWINFO;
-
-#endif // if !defined(__MINGW64_VERSION_MAJOR)
-
-// OpenGL Pixelformat flags.
-#define PFD_SUPPORT_DIRECTDRAW 0x00002000
-#define PFD_DIRECT3D_ACCELERATED 0x00004000
-#define PFD_SUPPORT_COMPOSITION 0x00008000
-
-// IME.
-#define IMR_CONFIRMRECONVERTSTRING 0x0005
-
-#ifndef MAPVK_VK_TO_CHAR
-# define MAPVK_VK_TO_CHAR 2
-#endif
-
-#endif // if defined(Q_CC_MINGW)
-
-/* Touch is supported from Windows 7 onwards and data structures
- * are present in the Windows SDK's, but not in older MSVC Express
- * versions. */
-
-#if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
-
-#define WM_TOUCH 0x0240
-
-typedef struct tagTOUCHINPUT {
- LONG x;
- LONG y;
- HANDLE hSource;
- DWORD dwID;
- DWORD dwFlags;
- DWORD dwMask;
- DWORD dwTime;
- ULONG_PTR dwExtraInfo;
- DWORD cxContact;
- DWORD cyContact;
-} TOUCHINPUT, *PTOUCHINPUT;
-typedef TOUCHINPUT const * PCTOUCHINPUT;
-
-# define TOUCHEVENTF_MOVE 0x0001
-# define TOUCHEVENTF_DOWN 0x0002
-# define TOUCHEVENTF_UP 0x0004
-# define TOUCHEVENTF_INRANGE 0x0008
-# define TOUCHEVENTF_PRIMARY 0x0010
-# define TOUCHEVENTF_NOCOALESCE 0x0020
-# define TOUCHEVENTF_PALM 0x0080
-# define TOUCHINPUTMASKF_CONTACTAREA 0x0004
-# define TOUCHINPUTMASKF_EXTRAINFO 0x0002
-
-#endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
-
-#ifndef WM_GESTURE
-# define WM_GESTURE 0x0119
-#endif
-
-#endif // QTWINDOWS_ADDITIONAL_H
diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h
index 90008663e7..ec6a8f62ae 100644
--- a/src/plugins/platforms/windows/qtwindowsglobal.h
+++ b/src/plugins/platforms/windows/qtwindowsglobal.h
@@ -41,10 +41,19 @@
#ifndef QTWINDOWSGLOBAL_H
#define QTWINDOWSGLOBAL_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/qnamespace.h>
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
+
+#ifndef WM_DWMCOMPOSITIONCHANGED // MinGW.
+# define WM_DWMCOMPOSITIONCHANGED 0x31E
+#endif
+
+#ifndef WM_TOUCH
+# define WM_TOUCH 0x0240
+#endif
+
+#ifndef WM_GESTURE
+# define WM_GESTURE 0x0119
#endif
QT_BEGIN_NAMESPACE
@@ -158,10 +167,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
return QtWindows::MouseWheelEvent;
-#ifndef Q_OS_WINCE
case WM_WINDOWPOSCHANGING:
return QtWindows::GeometryChangingEvent;
-#endif
case WM_MOVE:
return QtWindows::MoveEvent;
case WM_SHOWWINDOW:
@@ -172,10 +179,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
return QtWindows::ResizeEvent;
case WM_NCCALCSIZE:
return QtWindows::CalculateSize;
-#ifndef Q_OS_WINCE
case WM_NCHITTEST:
return QtWindows::NonClientHitTest;
-#endif // !Q_OS_WINCE
case WM_GETMINMAXINFO:
return QtWindows::QuerySizeHints;
case WM_KEYDOWN: // keyboard event
@@ -243,12 +248,10 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
return QtWindows::ContextMenu;
#endif
case WM_SYSCOMMAND:
-#ifndef Q_OS_WINCE
if ((wParamIn & 0xfff0) == SC_CONTEXTHELP)
return QtWindows::WhatsThisEvent;
-#endif
break;
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
case WM_QUERYENDSESSION:
return QtWindows::QueryEndSessionApplicationEvent;
case WM_ENDSESSION:
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index 7123ed826d..49c7144221 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -39,11 +39,11 @@
#include "qwindowsbackingstore.h"
#include "qwindowswindow.h"
-#include "qwindowsnativeimage.h"
#include "qwindowscontext.h"
#include <QtGui/QWindow>
#include <QtGui/QPainter>
+#include <QtFontDatabaseSupport/private/qwindowsnativeimage_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qimage_p.h>
@@ -87,7 +87,6 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
QWindowsWindow *rw = QWindowsWindow::windowsWindowOf(window);
Q_ASSERT(rw);
-#ifndef Q_OS_WINCE
const bool hasAlpha = rw->format().hasAlpha();
const Qt::WindowFlags flags = window->flags();
if ((flags & Qt::FramelessWindowHint) && QWindowsWindow::setWindowLayered(rw->handle(), flags, hasAlpha, rw->opacity()) && hasAlpha) {
@@ -101,21 +100,16 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
POINT ptDst = {r.x(), r.y()};
POINT ptSrc = {0, 0};
BLENDFUNCTION blend = {AC_SRC_OVER, 0, BYTE(qRound(255.0 * rw->opacity())), AC_SRC_ALPHA};
- if (QWindowsContext::user32dll.updateLayeredWindowIndirect) {
- RECT dirty = {dirtyRect.x(), dirtyRect.y(),
- dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
- UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty};
- const BOOL result = QWindowsContext::user32dll.updateLayeredWindowIndirect(rw->handle(), &info);
- if (!result)
- qErrnoWarning("UpdateLayeredWindowIndirect failed for ptDst=(%d, %d),"
- " size=(%dx%d), dirty=(%dx%d %d, %d)", r.x(), r.y(),
- r.width(), r.height(), dirtyRect.width(), dirtyRect.height(),
- dirtyRect.x(), dirtyRect.y());
- } else {
- QWindowsContext::user32dll.updateLayeredWindow(rw->handle(), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA);
- }
+ RECT dirty = {dirtyRect.x(), dirtyRect.y(),
+ dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
+ UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty};
+ const BOOL result = UpdateLayeredWindowIndirect(rw->handle(), &info);
+ if (!result)
+ qErrnoWarning("UpdateLayeredWindowIndirect failed for ptDst=(%d, %d),"
+ " size=(%dx%d), dirty=(%dx%d %d, %d)", r.x(), r.y(),
+ r.width(), r.height(), dirtyRect.width(), dirtyRect.height(),
+ dirtyRect.x(), dirtyRect.y());
} else {
-#endif
const HDC dc = rw->getDC();
if (!dc) {
qErrnoWarning("%s: GetDC failed", __FUNCTION__);
@@ -129,9 +123,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
qErrnoWarning(int(lastError), "%s: BitBlt failed", __FUNCTION__);
}
rw->releaseDC();
-#ifndef Q_OS_WINCE
}
-#endif
// Write image for debug purposes.
if (QWindowsContext::verbose > 2 && lcQpaBackingStore().isDebugEnabled()) {
@@ -175,7 +167,7 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
staticRegion &= QRect(0, 0, newimg.width(), newimg.height());
QPainter painter(&newimg);
painter.setCompositionMode(QPainter::CompositionMode_Source);
- foreach (const QRect &rect, staticRegion.rects())
+ for (const QRect &rect : staticRegion)
painter.drawImage(rect, oldimg, rect);
}
@@ -190,10 +182,9 @@ bool QWindowsBackingStore::scroll(const QRegion &area, int dx, int dy)
if (m_image.isNull() || m_image->image().isNull())
return false;
- const QVector<QRect> rects = area.rects();
const QPoint offset(dx, dy);
- for (int i = 0; i < rects.size(); ++i)
- qt_scrollRectInImage(m_image->image(), rects.at(i), offset);
+ for (const QRect &rect : area)
+ qt_scrollRectInImage(m_image->image(), rect, offset);
return true;
}
@@ -207,7 +198,7 @@ void QWindowsBackingStore::beginPaint(const QRegion &region)
QPainter p(&m_image->image());
p.setCompositionMode(QPainter::CompositionMode_Source);
const QColor blank = Qt::transparent;
- foreach (const QRect &r, region.rects())
+ for (const QRect &r : region)
p.fillRect(r, blank);
}
}
@@ -219,8 +210,6 @@ HDC QWindowsBackingStore::getDC() const
return 0;
}
-#ifndef QT_NO_OPENGL
-
QImage QWindowsBackingStore::toImage() const
{
if (m_image.isNull()) {
@@ -230,6 +219,4 @@ QImage QWindowsBackingStore::toImage() const
return m_image.data()->image();
}
-#endif // !QT_NO_OPENGL
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.h b/src/plugins/platforms/windows/qwindowsbackingstore.h
index 26c79348a9..46a7fcc676 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.h
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSBACKINGSTORE_H
#define QWINDOWSBACKINGSTORE_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <qpa/qplatformbackingstore.h>
#include <QtCore/QScopedPointer>
@@ -65,9 +65,7 @@ public:
HDC getDC() const;
-#ifndef QT_NO_OPENGL
QImage toImage() const Q_DECL_OVERRIDE;
-#endif
private:
QScopedPointer<QWindowsNativeImage> m_image;
diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp
index d527e07308..d4a7e27762 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -53,7 +53,7 @@
#include <QtCore/QVariant>
#include <QtCore/QUrl>
-#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
QT_BEGIN_NAMESPACE
@@ -237,8 +237,7 @@ void QWindowsClipboard::propagateClipboardMessage(UINT message, WPARAM wParam, L
return;
// In rare cases, a clipboard viewer can hang (application crashed,
// suspended by a shell prompt 'Select' or debugger).
- if (QWindowsContext::user32dll.isHungAppWindow
- && QWindowsContext::user32dll.isHungAppWindow(m_nextClipboardViewer)) {
+ if (IsHungAppWindow(m_nextClipboardViewer)) {
qWarning("Cowardly refusing to send clipboard message to hung application...");
return;
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 1dbac78fca..1a03df6ac2 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -52,7 +52,7 @@
#ifndef QT_NO_ACCESSIBILITY
# include "accessible/qwindowsaccessibility.h"
#endif
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
# include <private/qsessionmanager_p.h>
# include "qwindowssessionmanager.h"
#endif
@@ -72,21 +72,18 @@
#include <QtCore/QScopedArrayPointer>
#include <QtCore/private/qsystemlibrary_p.h>
-#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
#include <stdlib.h>
#include <stdio.h>
#include <windowsx.h>
-#ifndef Q_OS_WINCE
-# include <comdef.h>
-#endif
+#include <comdef.h>
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaWindows, "qt.qpa.windows")
Q_LOGGING_CATEGORY(lcQpaBackingStore, "qt.qpa.backingstore")
Q_LOGGING_CATEGORY(lcQpaEvents, "qt.qpa.events")
-Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
Q_LOGGING_CATEGORY(lcQpaGl, "qt.qpa.gl")
Q_LOGGING_CATEGORY(lcQpaMime, "qt.qpa.mime")
Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods")
@@ -100,45 +97,29 @@ int QWindowsContext::verbose = 0;
# define LANG_SYRIAC 0x5a
#endif
-static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
+static inline bool useRTL_Extensions()
{
- // This is SDK dependent on CE so out of scope for now
- if (QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
- return false;
- if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) {
- // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
- // Vista, check the Keyboard Layouts for enabling RTL.
- if (const int nLayouts = GetKeyboardLayoutList(0, 0)) {
- QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
- GetKeyboardLayoutList(nLayouts, lpList.data());
- for (int i = 0; i < nLayouts; ++i) {
- switch (PRIMARYLANGID((quintptr)lpList[i])) {
- case LANG_ARABIC:
- case LANG_HEBREW:
- case LANG_FARSI:
- case LANG_SYRIAC:
- return true;
- default:
- break;
- }
+ // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
+ // Vista, check the Keyboard Layouts for enabling RTL.
+ if (const int nLayouts = GetKeyboardLayoutList(0, 0)) {
+ QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
+ GetKeyboardLayoutList(nLayouts, lpList.data());
+ for (int i = 0; i < nLayouts; ++i) {
+ switch (PRIMARYLANGID((quintptr)lpList[i])) {
+ case LANG_ARABIC:
+ case LANG_HEBREW:
+ case LANG_FARSI:
+ case LANG_SYRIAC:
+ return true;
+ default:
+ break;
}
}
- return false;
- } // NT/Vista
-#ifndef Q_OS_WINCE
- // Pre-NT: figure out whether a RTL language is installed
- return IsValidLanguageGroup(LGRPID_ARABIC, LGRPID_INSTALLED)
- || IsValidLanguageGroup(LGRPID_HEBREW, LGRPID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_FARSI, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED);
-#else
+ }
return false;
-#endif
}
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
static inline QWindowsSessionManager *platformSessionManager() {
QGuiApplicationPrivate *guiPrivate = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(qApp));
QSessionManagerPrivate *managerPrivate = static_cast<QSessionManagerPrivate*>(QObjectPrivate::get(guiPrivate->session_manager));
@@ -161,13 +142,8 @@ static inline QWindowsSessionManager *platformSessionManager() {
\internal
\ingroup qt-lighthouse-win
*/
-
-#ifndef Q_OS_WINCE
-
QWindowsUser32DLL::QWindowsUser32DLL() :
- setLayeredWindowAttributes(0), updateLayeredWindow(0),
- updateLayeredWindowIndirect(0),
- isHungAppWindow(0), isTouchWindow(0),
+ isTouchWindow(0),
registerTouchWindow(0), unregisterTouchWindow(0),
getTouchInputInfo(0), closeTouchInputHandle(0), setProcessDPIAware(0),
addClipboardFormatListener(0), removeClipboardFormatListener(0),
@@ -178,20 +154,11 @@ QWindowsUser32DLL::QWindowsUser32DLL() :
void QWindowsUser32DLL::init()
{
QSystemLibrary library(QStringLiteral("user32"));
- // MinGW (g++ 3.4.5) accepts only C casts.
- setLayeredWindowAttributes = (SetLayeredWindowAttributes)(library.resolve("SetLayeredWindowAttributes"));
- updateLayeredWindow = (UpdateLayeredWindow)(library.resolve("UpdateLayeredWindow"));
- if (Q_UNLIKELY(!setLayeredWindowAttributes || !updateLayeredWindow))
- qFatal("This version of Windows is not supported (User32.dll is missing the symbols 'SetLayeredWindowAttributes', 'UpdateLayeredWindow').");
-
- updateLayeredWindowIndirect = (UpdateLayeredWindowIndirect)(library.resolve("UpdateLayeredWindowIndirect"));
- isHungAppWindow = (IsHungAppWindow)library.resolve("IsHungAppWindow");
setProcessDPIAware = (SetProcessDPIAware)library.resolve("SetProcessDPIAware");
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
- addClipboardFormatListener = (AddClipboardFormatListener)library.resolve("AddClipboardFormatListener");
- removeClipboardFormatListener = (RemoveClipboardFormatListener)library.resolve("RemoveClipboardFormatListener");
- }
+ addClipboardFormatListener = (AddClipboardFormatListener)library.resolve("AddClipboardFormatListener");
+ removeClipboardFormatListener = (RemoveClipboardFormatListener)library.resolve("RemoveClipboardFormatListener");
+
getDisplayAutoRotationPreferences = (GetDisplayAutoRotationPreferences)library.resolve("GetDisplayAutoRotationPreferences");
setDisplayAutoRotationPreferences = (SetDisplayAutoRotationPreferences)library.resolve("SetDisplayAutoRotationPreferences");
}
@@ -209,38 +176,6 @@ bool QWindowsUser32DLL::initTouch()
return isTouchWindow && registerTouchWindow && unregisterTouchWindow && getTouchInputInfo && closeTouchInputHandle;
}
-/*!
- \class QWindowsShell32DLL
- \brief Struct that contains dynamically resolved symbols of Shell32.dll.
-
- The stub libraries shipped with the MinGW compiler miss some of the
- functions. They need to be retrieved dynamically.
-
- \sa QWindowsUser32DLL
-
- \internal
- \ingroup qt-lighthouse-win
-*/
-
-QWindowsShell32DLL::QWindowsShell32DLL()
- : sHCreateItemFromParsingName(0)
- , sHGetKnownFolderIDList(0)
- , sHGetStockIconInfo(0)
- , sHGetImageList(0)
- , sHCreateItemFromIDList(0)
-{
-}
-
-void QWindowsShell32DLL::init()
-{
- QSystemLibrary library(QStringLiteral("shell32"));
- sHCreateItemFromParsingName = (SHCreateItemFromParsingName)(library.resolve("SHCreateItemFromParsingName"));
- sHGetKnownFolderIDList = (SHGetKnownFolderIDList)(library.resolve("SHGetKnownFolderIDList"));
- sHGetStockIconInfo = (SHGetStockIconInfo)library.resolve("SHGetStockIconInfo");
- sHGetImageList = (SHGetImageList)library.resolve("SHGetImageList");
- sHCreateItemFromIDList = (SHCreateItemFromIDList)library.resolve("SHCreateItemFromIDList");
-}
-
QWindowsShcoreDLL::QWindowsShcoreDLL()
: getProcessDpiAwareness(0)
, setProcessDpiAwareness(0)
@@ -259,11 +194,8 @@ void QWindowsShcoreDLL::init()
}
QWindowsUser32DLL QWindowsContext::user32dll;
-QWindowsShell32DLL QWindowsContext::shell32dll;
QWindowsShcoreDLL QWindowsContext::shcoredll;
-#endif // !Q_OS_WINCE
-
QWindowsContext *QWindowsContext::m_instance = 0;
/*!
@@ -292,7 +224,7 @@ struct QWindowsContextPrivate {
QWindowsMimeConverter m_mimeConverter;
QWindowsScreenManager m_screenManager;
QSharedPointer<QWindowCreationContext> m_creationContext;
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
QScopedPointer<QWindowsTabletSupport> m_tabletSupport;
#endif
const HRESULT m_oleInitializeResult;
@@ -307,18 +239,14 @@ QWindowsContextPrivate::QWindowsContextPrivate()
, m_eventType(QByteArrayLiteral("windows_generic_MSG"))
, m_lastActiveWindow(0), m_asyncExpose(0)
{
- const QSysInfo::WinVersion ver = QSysInfo::windowsVersion();
-#ifndef Q_OS_WINCE
QWindowsContext::user32dll.init();
- QWindowsContext::shell32dll.init();
QWindowsContext::shcoredll.init();
if (m_mouseHandler.touchDevice() && QWindowsContext::user32dll.initTouch())
m_systemInfo |= QWindowsContext::SI_SupportsTouch;
-#endif // !Q_OS_WINCE
m_displayContext = GetDC(0);
m_defaultDPI = GetDeviceCaps(m_displayContext, LOGPIXELSY);
- if (useRTL_Extensions(ver)) {
+ if (useRTL_Extensions()) {
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
@@ -339,7 +267,7 @@ QWindowsContext::QWindowsContext() :
const QByteArray bv = qgetenv("QT_QPA_VERBOSE");
if (!bv.isEmpty())
QLoggingCategory::setFilterRules(QString::fromLocal8Bit(bv));
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
d->m_tabletSupport.reset(QWindowsTabletSupport::create());
qCDebug(lcQpaTablet) << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description());
#endif
@@ -347,7 +275,7 @@ QWindowsContext::QWindowsContext() :
QWindowsContext::~QWindowsContext()
{
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes.
#endif
unregisterWindowClasses();
@@ -372,12 +300,10 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
if (!touchDevice)
return false;
-#ifndef Q_OS_WINCE
if (!QWindowsContext::user32dll.initTouch()) {
delete touchDevice;
return false;
}
-#endif // !Q_OS_WINCE
if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
@@ -390,7 +316,7 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
void QWindowsContext::setTabletAbsoluteRange(int a)
{
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
if (!d->m_tabletSupport.isNull())
d->m_tabletSupport->setAbsoluteRange(a);
#else
@@ -400,19 +326,16 @@ void QWindowsContext::setTabletAbsoluteRange(int a)
int QWindowsContext::processDpiAwareness()
{
-#ifndef Q_OS_WINCE
int result;
if (QWindowsContext::shcoredll.getProcessDpiAwareness
&& SUCCEEDED(QWindowsContext::shcoredll.getProcessDpiAwareness(NULL, &result))) {
return result;
}
-#endif // !Q_OS_WINCE
return -1;
}
void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness)
{
-#ifndef Q_OS_WINCE
qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness;
if (QWindowsContext::shcoredll.isValid()) {
const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness);
@@ -429,9 +352,6 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA
qErrnoWarning("SetProcessDPIAware() failed");
}
}
-#else // !Q_OS_WINCE
- Q_UNUSED(dpiAwareness)
-#endif
}
QWindowsContext *QWindowsContext::instance()
@@ -563,19 +483,14 @@ QString QWindowsContext::registerWindowClass(QString cname,
if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
return cname;
-#ifndef Q_OS_WINCE
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
-#else
- WNDCLASS wc;
-#endif
wc.style = style;
wc.lpfnWndProc = proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = appInstance;
wc.hCursor = 0;
-#ifndef Q_OS_WINCE
wc.hbrBackground = brush;
if (icon) {
wc.hIcon = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE));
@@ -591,22 +506,10 @@ QString QWindowsContext::registerWindowClass(QString cname,
wc.hIcon = 0;
wc.hIconSm = 0;
}
-#else
- if (icon) {
- wc.hIcon = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
- } else {
- wc.hIcon = 0;
- }
-#endif
wc.lpszMenuName = 0;
wc.lpszClassName = reinterpret_cast<LPCWSTR>(cname.utf16());
-#ifndef Q_OS_WINCE
ATOM atom = RegisterClassEx(&wc);
-#else
- ATOM atom = RegisterClass(&wc);
-#endif
-
if (!atom)
qErrnoWarning("QApplication::regClass: Registering window class '%s' failed.",
qPrintable(cname));
@@ -724,28 +627,14 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c
POINT point = screenPoint;
ScreenToClient(*hwnd, &point);
// Returns parent if inside & none matched.
-#ifndef Q_OS_WINCE
const HWND child = ChildWindowFromPointEx(*hwnd, point, cwexFlags);
-#else
-// Under Windows CE we don't use ChildWindowFromPointEx as it's not available
-// and ChildWindowFromPoint does not work properly.
- Q_UNUSED(cwexFlags)
- const HWND child = WindowFromPoint(point);
-#endif
if (!child || child == *hwnd)
return false;
if (QWindowsWindow *window = context->findPlatformWindow(child)) {
*result = window;
*hwnd = child;
-#ifndef Q_OS_WINCE
return true;
-#else
-// WindowFromPoint does not return same handle in two sequential calls, which leads
-// to an endless loop, but calling WindowFromPoint once is good enough.
- return false;
-#endif
}
-#ifndef Q_OS_WINCE // Does not have WS_EX_TRANSPARENT .
// QTBUG-40555: despite CWP_SKIPINVISIBLE, it is possible to hit on invisible
// full screen windows of other applications that have WS_EX_TRANSPARENT set
// (for example created by screen sharing applications). In that case, try to
@@ -761,7 +650,6 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c
return true;
}
}
-#endif // !Q_OS_WINCE
*hwnd = child;
return true;
}
@@ -788,7 +676,7 @@ QWindowsScreenManager &QWindowsContext::screenManager()
QWindowsTabletSupport *QWindowsContext::tabletSupport() const
{
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
return d->m_tabletSupport.data();
#else
return 0;
@@ -814,7 +702,6 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
HWND_MESSAGE, NULL, static_cast<HINSTANCE>(GetModuleHandle(0)), NULL);
}
-#ifndef Q_OS_WINCE
// Re-engineered from the inline function _com_error::ErrorMessage().
// We cannot use it directly since it uses swprintf_s(), which is not
// present in the MSVCRT.DLL found on Windows XP (QTBUG-35617).
@@ -833,7 +720,6 @@ static inline QString errorMessageFromComError(const _com_error &comError)
return QString::asprintf("IDispatch error #%u", uint(wCode));
return QString::asprintf("Unknown error 0x0%x", uint(comError.Error()));
}
-#endif // !Q_OS_WINCE
/*!
\brief Common COM error strings.
@@ -901,12 +787,10 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr)
default:
break;
}
-#ifndef Q_OS_WINCE
_com_error error(hr);
result += QByteArrayLiteral(" (");
result += errorMessageFromComError(error);
result += ')';
-#endif // !Q_OS_WINCE
return result;
}
@@ -942,9 +826,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
ClientToScreen(msg.hwnd, &msg.pt);
}
} else {
-#ifndef Q_OS_WINCE
GetCursorPos(&msg.pt);
-#endif
}
// Run the native event filters.
@@ -987,7 +869,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
switch (et) {
case QtWindows::GestureEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result);
@@ -1028,11 +910,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
// Pass on to current creation context
if (!platformWindow && !d->m_creationContext.isNull()) {
switch (et) {
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints:
d->m_creationContext->applyToMinMaxInfo(reinterpret_cast<MINMAXINFO *>(lParam));
return true;
-#endif
case QtWindows::ResizeEvent:
d->m_creationContext->obtainedGeometry.setSize(QSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
return true;
@@ -1064,13 +944,14 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
switch (et) {
case QtWindows::KeyboardLayoutChangeEvent:
if (QWindowsInputContext *wic = windowsInputContext())
- wic->handleInputLanguageChanged(wParam, lParam); // fallthrough intended.
+ wic->handleInputLanguageChanged(wParam, lParam);
+ Q_FALLTHROUGH();
case QtWindows::KeyDownEvent:
case QtWindows::KeyEvent:
case QtWindows::InputMethodKeyEvent:
case QtWindows::InputMethodKeyDownEvent:
case QtWindows::AppCommandEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
#else
return d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
@@ -1081,7 +962,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::ResizeEvent:
platformWindow->handleResized(static_cast<int>(wParam));
return true;
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints:
platformWindow->getSizeHints(reinterpret_cast<MINMAXINFO *>(lParam));
return true;// maybe available on some SDKs revisit WM_NCCALCSIZE
@@ -1091,30 +971,18 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return platformWindow->handleNonClientHitTest(QPoint(msg.pt.x, msg.pt.y), result);
case QtWindows::GeometryChangingEvent:
return platformWindow->QWindowsWindow::handleGeometryChanging(&msg);
-#endif // !Q_OS_WINCE
case QtWindows::ExposeEvent:
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
case QtWindows::NonClientMouseEvent:
if (platformWindow->frameStrutEventsEnabled())
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#endif
break;
-/* the mouse tracking on windows already handles the reset of the cursor
- * and does not like somebody else handling it.
- * on WINCE its necessary to handle this event to get the correct cursor
- */
-#ifdef Q_OS_WINCE
- case QtWindows::CursorEvent:
- {
- QWindowsWindow::baseWindowOf(platformWindow->window())->applyCursor();
- return true;
- }
-#endif
case QtWindows::ScrollEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result);
#else
return d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result);
@@ -1122,13 +990,13 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::MouseWheelEvent:
case QtWindows::MouseEvent:
case QtWindows::LeaveEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#endif
case QtWindows::TouchEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
@@ -1161,7 +1029,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::CompositionSettingsChanged:
platformWindow->handleCompositionSettingsChanged();
return true;
-#ifndef Q_OS_WINCE
case QtWindows::ActivateWindowEvent:
if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) {
*result = LRESULT(MA_NOACTIVATE);
@@ -1184,7 +1051,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true;
}
break;
-#endif
#ifndef QT_NO_CONTEXTMENU
case QtWindows::ContextMenu:
return handleContextMenuEvent(platformWindow->window(), msg);
@@ -1195,7 +1061,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true;
#endif
} break;
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
case QtWindows::QueryEndSessionApplicationEvent: {
QWindowsSessionManager *sessionManager = platformSessionManager();
if (sessionManager->isActive()) { // bogus message from windows
@@ -1235,7 +1101,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
}
return true;
}
-#endif // !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#endif // !defined(QT_NO_SESSIONMANAGER)
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 3559335747..9dfde67797 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -41,7 +41,7 @@
#define QWINDOWSCONTEXT_H
#include "qtwindowsglobal.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedPointer>
@@ -59,7 +59,6 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaWindows)
Q_DECLARE_LOGGING_CATEGORY(lcQpaBackingStore)
Q_DECLARE_LOGGING_CATEGORY(lcQpaEvents)
-Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts)
Q_DECLARE_LOGGING_CATEGORY(lcQpaGl)
Q_DECLARE_LOGGING_CATEGORY(lcQpaMime)
Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods)
@@ -79,38 +78,23 @@ class QPoint;
class QKeyEvent;
class QTouchDevice;
-#ifndef Q_OS_WINCE
struct QWindowsUser32DLL
{
QWindowsUser32DLL();
inline void init();
inline bool initTouch();
- typedef BOOL (WINAPI *IsTouchWindow)(HWND, PULONG);
+ typedef BOOL (WINAPI *IsTouchWindow)(HWND, PULONG); // Windows 7
typedef BOOL (WINAPI *RegisterTouchWindow)(HWND, ULONG);
typedef BOOL (WINAPI *UnregisterTouchWindow)(HWND);
typedef BOOL (WINAPI *GetTouchInputInfo)(HANDLE, UINT, PVOID, int);
typedef BOOL (WINAPI *CloseTouchInputHandle)(HANDLE);
- typedef BOOL (WINAPI *SetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD);
- typedef BOOL (WINAPI *UpdateLayeredWindow)(HWND, HDC , const POINT *,
- const SIZE *, HDC, const POINT *, COLORREF,
- const BLENDFUNCTION *, DWORD);
- typedef BOOL (WINAPI *UpdateLayeredWindowIndirect)(HWND, const UPDATELAYEREDWINDOWINFO *);
- typedef BOOL (WINAPI *IsHungAppWindow)(HWND);
typedef BOOL (WINAPI *SetProcessDPIAware)();
typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND);
typedef BOOL (WINAPI *RemoveClipboardFormatListener)(HWND);
typedef BOOL (WINAPI *GetDisplayAutoRotationPreferences)(DWORD *);
typedef BOOL (WINAPI *SetDisplayAutoRotationPreferences)(DWORD);
- // Functions missing in Q_CC_GNU stub libraries.
- SetLayeredWindowAttributes setLayeredWindowAttributes;
- UpdateLayeredWindow updateLayeredWindow;
-
- // Functions missing in older versions of Windows
- UpdateLayeredWindowIndirect updateLayeredWindowIndirect;
- IsHungAppWindow isHungAppWindow;
-
// Touch functions from Windows 7 onwards (also for use with Q_CC_MSVC).
IsTouchWindow isTouchWindow;
RegisterTouchWindow registerTouchWindow;
@@ -121,7 +105,8 @@ struct QWindowsUser32DLL
// Windows Vista onwards
SetProcessDPIAware setProcessDPIAware;
- // Clipboard listeners, Windows Vista onwards
+ // Clipboard listeners are present on Windows Vista onwards
+ // but missing in MinGW 4.9 stub libs. Can be removed in MinGW 5.
AddClipboardFormatListener addClipboardFormatListener;
RemoveClipboardFormatListener removeClipboardFormatListener;
@@ -130,24 +115,6 @@ struct QWindowsUser32DLL
SetDisplayAutoRotationPreferences setDisplayAutoRotationPreferences;
};
-struct QWindowsShell32DLL
-{
- QWindowsShell32DLL();
- inline void init();
-
- typedef HRESULT (WINAPI *SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **);
- typedef HRESULT (WINAPI *SHGetKnownFolderIDList)(const GUID &, DWORD, HANDLE, PIDLIST_ABSOLUTE *);
- typedef HRESULT (WINAPI *SHGetStockIconInfo)(int , int , _SHSTOCKICONINFO *);
- typedef HRESULT (WINAPI *SHGetImageList)(int, REFIID , void **);
- typedef HRESULT (WINAPI *SHCreateItemFromIDList)(PCIDLIST_ABSOLUTE, REFIID, void **);
-
- SHCreateItemFromParsingName sHCreateItemFromParsingName;
- SHGetKnownFolderIDList sHGetKnownFolderIDList;
- SHGetStockIconInfo sHGetStockIconInfo;
- SHGetImageList sHGetImageList;
- SHCreateItemFromIDList sHCreateItemFromIDList;
-};
-
// Shell scaling library (Windows 8.1 onwards)
struct QWindowsShcoreDLL {
QWindowsShcoreDLL();
@@ -163,8 +130,6 @@ struct QWindowsShcoreDLL {
GetDpiForMonitor getDpiForMonitor;
};
-#endif // Q_OS_WINCE
-
class QWindowsContext
{
Q_DISABLE_COPY(QWindowsContext)
@@ -236,11 +201,9 @@ public:
QWindowsMimeConverter &mimeConverter() const;
QWindowsScreenManager &screenManager();
QWindowsTabletSupport *tabletSupport() const;
-#ifndef Q_OS_WINCE
+
static QWindowsUser32DLL user32dll;
- static QWindowsShell32DLL shell32dll;
static QWindowsShcoreDLL shcoredll;
-#endif
static QByteArray comErrorString(HRESULT hr);
bool asyncExpose() const;
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index d02648fade..1bebe88df7 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -56,7 +56,7 @@
static bool initResources()
{
-#if !defined (Q_OS_WINCE) && !defined (QT_NO_IMAGEFORMAT_PNG)
+#if !defined (QT_NO_IMAGEFORMAT_PNG)
Q_INIT_RESOURCE(cursors);
#endif
return true;
@@ -143,7 +143,6 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
if (hotSpot.y() < 0)
hotSpot.setY(height / 2);
const int n = qMax(1, width / 8);
-#if !defined(Q_OS_WINCE)
QScopedArrayPointer<uchar> xBits(new uchar[height * n]);
QScopedArrayPointer<uchar> xMask(new uchar[height * n]);
int x = 0;
@@ -164,54 +163,6 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
}
return CreateCursor(GetModuleHandle(0), hotSpot.x(), hotSpot.y(), width, height,
xBits.data(), xMask.data());
-#elif defined(GWES_ICONCURS) // Q_OS_WINCE
- // Windows CE only supports fixed cursor size.
- int sysW = GetSystemMetrics(SM_CXCURSOR);
- int sysH = GetSystemMetrics(SM_CYCURSOR);
- int sysN = qMax(1, sysW / 8);
- uchar* xBits = new uchar[sysH * sysN];
- uchar* xMask = new uchar[sysH * sysN];
- int x = 0;
- for (int i = 0; i < sysH; ++i) {
- if (i >= height) {
- memset(&xBits[x] , 255, sysN);
- memset(&xMask[x] , 0, sysN);
- x += sysN;
- } else {
- int fillWidth = n > sysN ? sysN : n;
- const uchar *bits = bbits.constScanLine(i);
- const uchar *mask = mbits.constScanLine(i);
- for (int j = 0; j < fillWidth; ++j) {
- uchar b = bits[j];
- uchar m = mask[j];
- if (invb)
- b ^= 0xFF;
- if (invm)
- m ^= 0xFF;
- xBits[x] = ~m;
- xMask[x] = b ^ m;
- ++x;
- }
- for (int j = fillWidth; j < sysN; ++j ) {
- xBits[x] = 255;
- xMask[x] = 0;
- ++x;
- }
- }
- }
-
- HCURSOR hcurs = CreateCursor(qWinAppInst(), hotSpot.x(), hotSpot.y(), sysW, sysH,
- xBits, xMask);
- delete [] xBits;
- delete [] xMask;
- return hcurs;
-#else
- Q_UNUSED(n);
- Q_UNUSED(invm);
- Q_UNUSED(invb);
- Q_UNUSED(mbits);
- return 0;
-#endif
}
// Create a cursor from image and mask of the format QImage::Format_Mono.
@@ -252,7 +203,7 @@ static QSize systemCursorSize(const QPlatformScreen *screen = Q_NULLPTR)
return primaryScreenCursorSize;
}
-#if defined (Q_OS_WINCE) || defined (QT_NO_IMAGEFORMAT_PNG)
+#if defined (QT_NO_IMAGEFORMAT_PNG)
static inline QSize standardCursorSize() { return QSize(32, 32); }
@@ -468,7 +419,7 @@ QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursor
return QWindowsCursor::PixmapCursor();
}
-#else // Q_OS_WINCE || QT_NO_IMAGEFORMAT_PNG
+#else // QT_NO_IMAGEFORMAT_PNG
struct QWindowsCustomPngCursor {
Qt::CursorShape shape;
int size;
@@ -526,7 +477,7 @@ QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursor
QString::fromLatin1(bestFit->fileName));
return PixmapCursor(rawImage, QPoint(bestFit->hotSpotX, bestFit->hotSpotY));
}
-#endif // Q_OS_WINCE || QT_NO_IMAGEFORMAT_PNG
+#endif // !QT_NO_IMAGEFORMAT_PNG
struct QWindowsStandardCursorMapping {
Qt::CursorShape shape;
@@ -575,13 +526,8 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const
// Load available standard cursors from resources
const QWindowsStandardCursorMapping *sEnd = standardCursors + sizeof(standardCursors) / sizeof(standardCursors[0]);
for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) {
- if (s->shape == cursorShape) {
-#ifndef Q_OS_WINCE
+ if (s->shape == cursorShape)
return static_cast<HCURSOR>(LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
-#else
- return LoadCursor(0, s->resource);
-#endif
- }
}
qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cursorShape);
@@ -677,7 +623,6 @@ QPoint QWindowsCursor::mousePosition()
QWindowsCursor::CursorState QWindowsCursor::cursorState()
{
-#ifndef Q_OS_WINCE
enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; // Windows 8: CURSOR_SUPPRESSED
CURSORINFO cursorInfo;
cursorInfo.cbSize = sizeof(CURSORINFO);
@@ -687,7 +632,6 @@ QWindowsCursor::CursorState QWindowsCursor::cursorState()
if (cursorInfo.flags & cursorSuppressed)
return CursorSuppressed;
}
-#endif // !Q_OS_WINCE
return CursorHidden;
}
@@ -758,7 +702,6 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
"...............XXXX....."};
if (m_ignoreDragCursor.isNull()) {
-#if !defined (Q_OS_WINCE)
HCURSOR cursor = LoadCursor(NULL, IDC_NO);
ICONINFO iconInfo = {0, 0, 0, 0, 0};
GetIconInfo(cursor, &iconInfo);
@@ -782,9 +725,6 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
DeleteObject(iconInfo.hbmMask);
DeleteObject(iconInfo.hbmColor);
DestroyCursor(cursor);
-#else // !Q_OS_WINCE
- m_ignoreDragCursor = QPixmap(ignoreDragCursorXpmC);
-#endif // !Q_OS_WINCE
}
return m_ignoreDragCursor;
}
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index c0f9235c30..6fff5f9ab1 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSCURSOR_H
#define QWINDOWSCURSOR_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <qpa/qplatformcursor.h>
#include <QtCore/QSharedPointer>
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 817728dca2..8f1358de6c 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -70,300 +70,10 @@
#include <algorithm>
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
// #define USE_NATIVE_COLOR_DIALOG /* Testing purposes only */
-#ifdef Q_CC_MINGW /* Add missing declarations for MinGW */
-
-#ifndef __IShellLibrary_FWD_DEFINED__
-
-/* Constants obtained by running the below stream operator for
- * CLSID, IID on the constants in the Windows SDK libraries. */
-
-static const IID IID_IFileOpenDialog = {0xd57c7288, 0xd4ad, 0x4768, {0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60}};
-static const IID IID_IFileSaveDialog = {0x84bccd23, 0x5fde, 0x4cdb,{0xae, 0xa4, 0xaf, 0x64, 0xb8, 0x3d, 0x78, 0xab}};
-#ifdef __MINGW64_VERSION_MAJOR
-static const IID q_IID_IShellItem = {0x43826d1e, 0xe718, 0x42ee, {0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe}};
-#define IID_IShellItem q_IID_IShellItem
-#else
-static const IID IID_IShellItem = {0x43826d1e, 0xe718, 0x42ee, {0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe}};
-static const IID IID_IShellItemArray = {0xb63ea76d, 0x1f85, 0x456f, {0xa1, 0x9c, 0x48, 0x15, 0x9e, 0xfa, 0x85, 0x8b}};
-# define LFF_FORCEFILESYSTEM 1
-#endif
-static const IID IID_IFileDialogEvents = {0x973510db, 0x7d7f, 0x452b,{0x89, 0x75, 0x74, 0xa8, 0x58, 0x28, 0xd3, 0x54}};
-static const CLSID CLSID_FileOpenDialog = {0xdc1c5a9c, 0xe88a, 0x4dde, {0xa5, 0xa1, 0x60, 0xf8, 0x2a, 0x20, 0xae, 0xf7}};
-static const CLSID CLSID_FileSaveDialog = {0xc0b4e2f3, 0xba21, 0x4773,{0x8d, 0xba, 0x33, 0x5e, 0xc9, 0x46, 0xeb, 0x8b}};
-
-typedef struct _COMDLG_FILTERSPEC
-{
- LPCWSTR pszName;
- LPCWSTR pszSpec;
-} COMDLG_FILTERSPEC;
-
-
-#define FOS_OVERWRITEPROMPT 0x2
-#define FOS_STRICTFILETYPES 0x4
-#define FOS_NOCHANGEDIR 0x8
-#define FOS_PICKFOLDERS 0x20
-#define FOS_FORCEFILESYSTEM 0x40
-#define FOS_ALLNONSTORAGEITEMS 0x80
-#define FOS_NOVALIDATE 0x100
-#define FOS_ALLOWMULTISELECT 0x200
-#define FOS_PATHMUSTEXIST 0x800
-#define FOS_FILEMUSTEXIST 0x1000
-#define FOS_CREATEPROMPT 0x2000
-#define FOS_SHAREAWARE 0x4000
-#define FOS_NOREADONLYRETURN 0x8000
-#define FOS_NOTESTFILECREATE 0x10000
-#define FOS_HIDEMRUPLACES 0x20000
-#define FOS_HIDEPINNEDPLACES 0x40000
-#define FOS_NODEREFERENCELINKS 0x100000
-#define FOS_DONTADDTORECENT 0x2000000
-#define FOS_FORCESHOWHIDDEN 0x10000000
-#define FOS_DEFAULTNOMINIMODE 0x20000000
-#define FOS_FORCEPREVIEWPANEON 0x40000000
-
-#if __MINGW64_VERSION_MAJOR < 2
-typedef int GETPROPERTYSTOREFLAGS;
-#define GPS_DEFAULT 0x00000000
-#define GPS_HANDLERPROPERTIESONLY 0x00000001
-#define GPS_READWRITE 0x00000002
-#define GPS_TEMPORARY 0x00000004
-#define GPS_FASTPROPERTIESONLY 0x00000008
-#define GPS_OPENSLOWITEM 0x00000010
-#define GPS_DELAYCREATION 0x00000020
-#define GPS_BESTEFFORT 0x00000040
-#define GPS_MASK_VALID 0x0000007F
-#endif
-
-typedef int (QT_WIN_CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
-// message from browser
-#define BFFM_INITIALIZED 1
-#define BFFM_SELCHANGED 2
-#define BFFM_ENABLEOK (WM_USER + 101)
-// Browsing for directory.
-#define BIF_NONEWFOLDERBUTTON 0x0200
-#define BIF_NOTRANSLATETARGETS 0x0400
-#define BIF_BROWSEFORCOMPUTER 0x1000
-#define BIF_BROWSEFORPRINTER 0x2000
-#define BIF_BROWSEINCLUDEFILES 0x4000
-#define BIF_SHAREABLE 0x8000
-
-//the enums
-typedef enum {
- SIATTRIBFLAGS_AND = 0x1,
- SIATTRIBFLAGS_OR = 0x2,
- SIATTRIBFLAGS_APPCOMPAT = 0x3,
- SIATTRIBFLAGS_MASK = 0x3
-} SIATTRIBFLAGS;
-#ifndef __MINGW64_VERSION_MAJOR
-typedef enum {
- SIGDN_NORMALDISPLAY = 0x00000000,
- SIGDN_PARENTRELATIVEPARSING = 0x80018001,
- SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
- SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000,
- SIGDN_PARENTRELATIVEEDITING = 0x80031001,
- SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000,
- SIGDN_FILESYSPATH = 0x80058000,
- SIGDN_URL = 0x80068000
-} SIGDN;
-#endif
-typedef enum {
- FDAP_BOTTOM = 0x00000000,
- FDAP_TOP = 0x00000001
-} FDAP;
-typedef enum {
- FDESVR_DEFAULT = 0x00000000,
- FDESVR_ACCEPT = 0x00000001,
- FDESVR_REFUSE = 0x00000002
-} FDE_SHAREVIOLATION_RESPONSE;
-typedef FDE_SHAREVIOLATION_RESPONSE FDE_OVERWRITE_RESPONSE;
-
-//the structs
-typedef struct {
- LPCWSTR pszName;
- LPCWSTR pszSpec;
-} qt_COMDLG_FILTERSPEC;
-typedef struct {
- GUID fmtid;
- DWORD pid;
-} qt_PROPERTYKEY;
-
-typedef struct {
- USHORT cb;
- BYTE abID[1];
-} qt_SHITEMID, *qt_LPSHITEMID;
-typedef struct {
- qt_SHITEMID mkid;
-} qt_ITEMIDLIST, *qt_LPITEMIDLIST;
-typedef const qt_ITEMIDLIST *qt_LPCITEMIDLIST;
-typedef struct {
- HWND hwndOwner;
- qt_LPCITEMIDLIST pidlRoot;
- LPWSTR pszDisplayName;
- LPCWSTR lpszTitle;
- UINT ulFlags;
- BFFCALLBACK lpfn;
- LPARAM lParam;
- int iImage;
-} qt_BROWSEINFO;
-
-#endif // __IShellLibrary_FWD_DEFINED__
-
-#ifndef __IFileDialogEvents_FWD_DEFINED__
-DECLARE_INTERFACE(IFileDialogEvents);
-#endif
-
-#ifndef __IShellItem_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IShellItem, IUnknown)
-{
- STDMETHOD(BindToHandler)(THIS_ IBindCtx *pbc, REFGUID bhid, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetParent)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(GetDisplayName)(THIS_ SIGDN sigdnName, LPWSTR *ppszName) PURE;
- STDMETHOD(GetAttributes)(THIS_ ULONG sfgaoMask, ULONG *psfgaoAttribs) PURE;
- STDMETHOD(Compare)(THIS_ IShellItem *psi, DWORD hint, int *piOrder) PURE;
-};
-#endif
-
-#ifndef __IShellItemFilter_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IShellItemFilter, IUnknown)
-{
- STDMETHOD(IncludeItem)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(GetEnumFlagsForItem)(THIS_ IShellItem *psi, DWORD *pgrfFlags) PURE;
-};
-#endif
-
-#ifndef __IEnumShellItems_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IEnumShellItems, IUnknown)
-{
- STDMETHOD(Next)(THIS_ ULONG celt, IShellItem **rgelt, ULONG *pceltFetched) PURE;
- STDMETHOD(Skip)(THIS_ ULONG celt) PURE;
- STDMETHOD(Reset)(THIS_) PURE;
- STDMETHOD(Clone)(THIS_ IEnumShellItems **ppenum) PURE;
-};
-#endif
-
-#ifndef __IShellItemArray_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IShellItemArray, IUnknown)
-{
- STDMETHOD(BindToHandler)(THIS_ IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut) PURE;
- STDMETHOD(GetPropertyStore)(THIS_ GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetPropertyDescriptionList)(THIS_ const qt_PROPERTYKEY *keyType, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetAttributes)(THIS_ SIATTRIBFLAGS dwAttribFlags, ULONG sfgaoMask, ULONG *psfgaoAttribs) PURE;
- STDMETHOD(GetCount)(THIS_ DWORD *pdwNumItems) PURE;
- STDMETHOD(GetItemAt)(THIS_ DWORD dwIndex, IShellItem **ppsi) PURE;
- STDMETHOD(EnumItems)(THIS_ IEnumShellItems **ppenumShellItems) PURE;
-};
-#endif
-
-#ifndef __IShellLibrary_INTERFACE_DEFINED__
-
-enum LIBRARYOPTIONFLAGS {};
-enum DEFAULTSAVEFOLDERTYPE { DSFT_DETECT = 1 };
-enum LIBRARYSAVEFLAGS {};
-
-DECLARE_INTERFACE_(IShellLibrary, IUnknown)
-{
- STDMETHOD(LoadLibraryFromItem)(THIS_ IShellItem *psiLibrary, DWORD grfMode) PURE;
- STDMETHOD(LoadLibraryFromKnownFolder)(THIS_ const GUID &kfidLibrary, DWORD grfMode) PURE;
- STDMETHOD(AddFolder)(THIS_ IShellItem *psiLocation) PURE;
- STDMETHOD(RemoveFolder)(THIS_ IShellItem *psiLocation) PURE;
- STDMETHOD(GetFolders)(THIS_ int lff, REFIID riid, void **ppv) PURE;
- STDMETHOD(ResolveFolder)(THIS_ IShellItem *psiFolderToResolve, DWORD dwTimeout, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetDefaultSaveFolder)(THIS_ DEFAULTSAVEFOLDERTYPE dsft, REFIID riid, void **ppv) PURE;
- STDMETHOD(SetDefaultSaveFolder)(THIS_ DEFAULTSAVEFOLDERTYPE dsft, IShellItem *psi) PURE;
- STDMETHOD(GetOptions)(THIS_ LIBRARYOPTIONFLAGS *plofOptions) PURE;
- STDMETHOD(SetOptions)(THIS_ LIBRARYOPTIONFLAGS lofMask, LIBRARYOPTIONFLAGS lofOptions) PURE;
- STDMETHOD(GetFolderType)(THIS_ GUID *pftid) PURE;
- STDMETHOD(SetFolderType)(THIS_ const GUID &ftid) PURE;
- STDMETHOD(GetIcon)(THIS_ LPWSTR *ppszIcon) PURE;
- STDMETHOD(SetIcon)(THIS_ LPCWSTR pszIcon) PURE;
- STDMETHOD(Commit)(THIS_) PURE;
- STDMETHOD(Save)(THIS_ IShellItem *psiFolderToSaveIn, LPCWSTR pszLibraryName, LIBRARYSAVEFLAGS lsf, IShellItem **ppsiSavedTo) PURE;
- STDMETHOD(SaveInKnownFolder)(THIS_ const GUID &kfidToSaveIn, LPCWSTR pszLibraryName, LIBRARYSAVEFLAGS lsf,IShellItem **ppsiSavedTo) PURE;
-};
-#endif
-
-#ifndef __IModalWindow_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IModalWindow, IUnknown)
-{
- STDMETHOD(Show)(THIS_ HWND hwndParent) PURE;
-};
-#endif
-
-#ifndef __IFileDialog_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileDialog, IModalWindow)
-{
- STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec) PURE;
- STDMETHOD(SetFileTypeIndex)(THIS_ UINT iFileType) PURE;
- STDMETHOD(GetFileTypeIndex)(THIS_ UINT *piFileType) PURE;
- STDMETHOD(Advise)(THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE;
- STDMETHOD(Unadvise)(THIS_ DWORD dwCookie) PURE;
- STDMETHOD(SetOptions)(THIS_ DWORD fos) PURE;
- STDMETHOD(GetOptions)(THIS_ DWORD *pfos) PURE;
- STDMETHOD(SetDefaultFolder)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(SetFolder)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(GetFolder)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(GetCurrentSelection)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(SetFileName)(THIS_ LPCWSTR pszName) PURE;
- STDMETHOD(GetFileName)(THIS_ LPWSTR *pszName) PURE;
- STDMETHOD(SetTitle)(THIS_ LPCWSTR pszTitle) PURE;
- STDMETHOD(SetOkButtonLabel)(THIS_ LPCWSTR pszText) PURE;
- STDMETHOD(SetFileNameLabel)(THIS_ LPCWSTR pszLabel) PURE;
- STDMETHOD(GetResult)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(AddPlace)(THIS_ IShellItem *psi, FDAP fdap) PURE;
- STDMETHOD(SetDefaultExtension)(THIS_ LPCWSTR pszDefaultExtension) PURE;
- STDMETHOD(Close)(THIS_ HRESULT hr) PURE;
- STDMETHOD(SetClientGuid)(THIS_ REFGUID guid) PURE;
- STDMETHOD(ClearClientData)(THIS_) PURE;
- STDMETHOD(SetFilter)(THIS_ IShellItemFilter *pFilter) PURE;
-};
-#endif
-
-#ifndef __IFileDialogEvents_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileDialogEvents, IUnknown)
-{
- STDMETHOD(OnFileOk)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnFolderChanging)(THIS_ IFileDialog *pfd, IShellItem *psiFolder) PURE;
- STDMETHOD(OnFolderChange)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnSelectionChange)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnShareViolation)(THIS_ IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse) PURE;
- STDMETHOD(OnTypeChange)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnOverwrite)(THIS_ IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse) PURE;
-};
-#endif
-
-#ifndef __IFileOpenDialog_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileOpenDialog, IFileDialog)
-{
- STDMETHOD(GetResults)(THIS_ IShellItemArray **ppenum) PURE;
- STDMETHOD(GetSelectedItems)(THIS_ IShellItemArray **ppsai) PURE;
-};
-#endif
-
-#ifndef __IPropertyStore_FWD_DEFINED__
-typedef IUnknown IPropertyStore;
-#endif
-
-#ifndef __IFileOperationProgressSink_FWD_DEFINED__
-typedef IUnknown IFileOperationProgressSink;
-#endif
-
-#ifndef __IFileSaveDialog_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileSaveDialog, IFileDialog)
-{
-public:
- STDMETHOD(SetSaveAsItem)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(SetProperties)(THIS_ IPropertyStore *pStore) PURE;
- STDMETHOD(SetCollectedProperties)(THIS_ IPropertyStore *pStore) PURE;
- STDMETHOD(GetProperties)(THIS_ IPropertyStore **ppStore) PURE;
- STDMETHOD(ApplyProperties)(THIS_ IShellItem *psi, IPropertyStore *pStore, HWND hwnd, IFileOperationProgressSink *pSink) PURE;
-};
-#endif
-
-#endif // Q_CC_MINGW
-
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG_STREAM
@@ -637,7 +347,6 @@ void QWindowsDialogHelperBase<BaseClass>::stopTimer()
}
}
-#ifndef Q_OS_WINCE
// Find a file dialog window created by IFileDialog by process id, window
// title and class, which starts with a hash '#'.
@@ -673,7 +382,6 @@ static inline HWND findDialogWindow(const QString &title)
EnumWindows(findDialogEnumWindowsProc, reinterpret_cast<LPARAM>(&context));
return context.hwnd;
}
-#endif // !Q_OS_WINCE
template <class BaseClass>
void QWindowsDialogHelperBase<BaseClass>::hide()
@@ -989,24 +697,19 @@ void QWindowsNativeFileDialogBase::setWindowTitle(const QString &title)
IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
{
-#ifndef Q_OS_WINCE
if (url.isLocalFile()) {
- if (!QWindowsContext::shell32dll.sHCreateItemFromParsingName)
- return Q_NULLPTR;
IShellItem *result = Q_NULLPTR;
const QString native = QDir::toNativeSeparators(url.toLocalFile());
const HRESULT hr =
- QWindowsContext::shell32dll.sHCreateItemFromParsingName(reinterpret_cast<const wchar_t *>(native.utf16()),
- NULL, IID_IShellItem,
- reinterpret_cast<void **>(&result));
+ SHCreateItemFromParsingName(reinterpret_cast<const wchar_t *>(native.utf16()),
+ NULL, IID_IShellItem,
+ reinterpret_cast<void **>(&result));
if (FAILED(hr)) {
qErrnoWarning("%s: SHCreateItemFromParsingName(%s)) failed", __FUNCTION__, qPrintable(url.toString()));
return Q_NULLPTR;
}
return result;
} else if (url.scheme() == QLatin1String("clsid")) {
- if (!QWindowsContext::shell32dll.sHGetKnownFolderIDList || !QWindowsContext::shell32dll.sHCreateItemFromIDList)
- return Q_NULLPTR;
// Support for virtual folders via GUID
// (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx)
// specified as "clsid:<GUID>" (without '{', '}').
@@ -1017,12 +720,12 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
return Q_NULLPTR;
}
PIDLIST_ABSOLUTE idList;
- HRESULT hr = QWindowsContext::shell32dll.sHGetKnownFolderIDList(uuid, 0, 0, &idList);
+ HRESULT hr = SHGetKnownFolderIDList(uuid, 0, 0, &idList);
if (FAILED(hr)) {
qErrnoWarning("%s: SHGetKnownFolderIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString()));
return Q_NULLPTR;
}
- hr = QWindowsContext::shell32dll.sHCreateItemFromIDList(idList, IID_IShellItem, reinterpret_cast<void **>(&result));
+ hr = SHCreateItemFromIDList(idList, IID_IShellItem, reinterpret_cast<void **>(&result));
CoTaskMemFree(idList);
if (FAILED(hr)) {
qErrnoWarning("%s: SHCreateItemFromIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString()));
@@ -1032,9 +735,6 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
} else {
qWarning() << __FUNCTION__ << ": Unhandled scheme: " << url.scheme();
}
-#else // !Q_OS_WINCE
- Q_UNUSED(url)
-#endif
return 0;
}
@@ -1051,13 +751,11 @@ void QWindowsNativeFileDialogBase::setDirectory(const QUrl &directory)
QString QWindowsNativeFileDialogBase::directory() const
{
QString result;
-#ifndef Q_OS_WINCE
IShellItem *item = 0;
if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) {
result = QWindowsNativeFileDialogBase::itemPath(item);
item->Release();
}
-#endif
return result;
}
@@ -1109,7 +807,7 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode,
qErrnoWarning("%s: SetOptions() failed", __FUNCTION__);
}
-#if !defined(Q_OS_WINCE) && defined(__IShellLibrary_INTERFACE_DEFINED__) // Windows SDK 7
+#if defined(__IShellLibrary_INTERFACE_DEFINED__) // Windows SDK 7
// Helper for "Libraries": collections of folders appearing from Windows 7
// on, visible in the file dialogs.
@@ -1162,7 +860,7 @@ QString QWindowsNativeFileDialogBase::libraryItemDefaultSaveFolder(IShellItem *i
return result;
}
-#else // !Q_OS_WINCE && __IShellLibrary_INTERFACE_DEFINED__
+#else // __IShellLibrary_INTERFACE_DEFINED__
QList<QUrl> QWindowsNativeFileDialogBase::libraryItemFolders(IShellItem *)
{
@@ -1174,7 +872,7 @@ QString QWindowsNativeFileDialogBase::libraryItemDefaultSaveFolder(IShellItem *)
return QString();
}
-#endif // Q_OS_WINCE || !__IShellLibrary_INTERFACE_DEFINED__
+#endif // !__IShellLibrary_INTERFACE_DEFINED__
QString QWindowsNativeFileDialogBase::itemPath(IShellItem *item)
{
@@ -1420,14 +1118,12 @@ bool QWindowsNativeFileDialogBase::onFileOk()
void QWindowsNativeFileDialogBase::close()
{
m_fileDialog->Close(S_OK);
-#ifndef Q_OS_WINCE
// IFileDialog::Close() does not work unless invoked from a callback.
// Try to find the window and send it a WM_CLOSE in addition.
const HWND hwnd = findDialogWindow(m_title);
qCDebug(lcQpaDialogs) << __FUNCTION__ << "closing" << hwnd;
if (hwnd && IsWindowVisible(hwnd))
PostMessageW(hwnd, WM_CLOSE, 0, 0);
-#endif // !Q_OS_WINCE
}
HRESULT QWindowsNativeFileDialogEventHandler::OnFolderChanging(IFileDialog *, IShellItem *item)
@@ -1730,8 +1426,6 @@ QString QWindowsFileDialogHelper::selectedNameFilter() const
return m_data.selectedNameFilter();
}
-#ifndef Q_OS_WINCE
-
/*!
\class QWindowsXpNativeFileDialog
\brief Native Windows directory dialog for Windows XP using SHlib-functions.
@@ -2055,8 +1749,6 @@ QString QWindowsXpFileDialogHelper::selectedNameFilter() const
return m_data.selectedNameFilter();
}
-#endif // Q_OS_WINCE
-
/*!
\class QWindowsNativeColorDialog
\brief Native Windows color dialog.
@@ -2184,7 +1876,6 @@ namespace QWindowsDialogs {
// QWindowsDialogHelperBase creation functions
bool useHelper(QPlatformTheme::DialogType type)
{
-#if !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs)
return false;
switch (type) {
@@ -2203,28 +1894,20 @@ bool useHelper(QPlatformTheme::DialogType type)
break;
}
return false;
-#else
- return false;
-#endif // !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
}
QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type)
{
-#if !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs)
return 0;
switch (type) {
- case QPlatformTheme::FileDialog:
-#ifndef Q_OS_WINCE // Note: "Windows XP Professional x64 Edition has version number WV_5_2 (WV_2003).
+ case QPlatformTheme::FileDialog: // Note: "Windows XP Professional x64 Edition has version number WV_5_2 (WV_2003).
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs
|| QSysInfo::windowsVersion() <= QSysInfo::WV_2003) {
return new QWindowsXpFileDialogHelper();
}
if (QSysInfo::windowsVersion() > QSysInfo::WV_2003)
return new QWindowsFileDialogHelper();
-#else
- return new QWindowsFileDialogHelper();
-#endif // Q_OS_WINCE
case QPlatformTheme::ColorDialog:
#ifdef USE_NATIVE_COLOR_DIALOG
return new QWindowsColorDialogHelper();
@@ -2238,9 +1921,6 @@ QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type)
break;
}
return 0;
-#else
- return 0;
-#endif // !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
}
} // namespace QWindowsDialogs
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h
index b643d9a920..b3101a1419 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSDIALOGHELPER_H
#define QWINDOWSDIALOGHELPER_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
#include <QtCore/QStringList>
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 246f53ef2f..26a5131927 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -45,7 +45,7 @@
#endif
#include "qwindowsintegration.h"
#include "qwindowsole.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include "qwindowswindow.h"
#include "qwindowsmousehandler.h"
#include "qwindowscursor.h"
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 4261c01ac8..a4738dc100 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -95,13 +95,9 @@ static void *resolveFunc(HMODULE lib, const char *name)
return proc;
}
#else
-static void *resolveFunc(HMODULE lib, const char *name)
+static inline void *resolveFunc(HMODULE lib, const char *name)
{
-# ifndef Q_OS_WINCE
- return (void *) ::GetProcAddress(lib, name);
-# else
- return (void *) ::GetProcAddress(lib, (const wchar_t *) QString::fromLatin1(name).utf16());
-# endif // Q_OS_WINCE
+ return ::GetProcAddress(lib, name);
}
#endif // Q_CC_MINGW
@@ -121,7 +117,7 @@ void *QWindowsLibEGL::resolve(const char *name)
bool QWindowsLibEGL::init()
{
const char dllName[] = QT_STRINGIFY(LIBEGL_NAME)
-#if defined(QT_DEBUG) && !defined(Q_OS_WINCE)
+#if defined(QT_DEBUG)
"d"
#endif
"";
@@ -178,7 +174,7 @@ bool QWindowsLibGLESv2::init()
{
const char dllName[] = QT_STRINGIFY(LIBGLESV2_NAME)
-#if defined(QT_DEBUG) && !defined(Q_OS_WINCE)
+#if defined(QT_DEBUG)
"d"
#endif
"";
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
deleted file mode 100644
index bc237bc88c..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ /dev/null
@@ -1,1907 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsfontdatabase.h"
-#include "qwindowsfontdatabase_ft.h" // for default font
-#include "qwindowscontext.h"
-#include "qwindowsintegration.h"
-#include "qwindowsfontengine.h"
-#include "qwindowsfontenginedirectwrite.h"
-#include "qtwindows_additional.h"
-
-#include <QtGui/QFont>
-#include <QtGui/QGuiApplication>
-#include <QtGui/private/qhighdpiscaling_p.h>
-
-#include <QtCore/qmath.h>
-#include <QtCore/QDebug>
-#include <QtCore/QFile>
-#include <QtCore/QtEndian>
-#include <QtCore/QThreadStorage>
-#include <QtCore/private/qsystemlibrary_p.h>
-
-#include <wchar.h>
-
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
-
-#if !defined(QT_NO_DIRECTWRITE)
-# if defined(QT_USE_DIRECTWRITE2)
-# include <dwrite_2.h>
-# else
-# include <dwrite.h>
-# endif
-# include <d2d1.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_DIRECTWRITE
-// ### fixme: Consider direct linking of dwrite.dll once Windows Vista pre SP2 is dropped (QTBUG-49711)
-
-typedef HRESULT (WINAPI *DWriteCreateFactoryType)(DWRITE_FACTORY_TYPE, const IID &, IUnknown **);
-
-static inline DWriteCreateFactoryType resolveDWriteCreateFactory()
-{
- if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA)
- return Q_NULLPTR;
- QSystemLibrary library(QStringLiteral("dwrite"));
- QFunctionPointer result = library.resolve("DWriteCreateFactory");
- if (Q_UNLIKELY(!result)) {
- qWarning("Unable to load dwrite.dll");
- return Q_NULLPTR;
- }
- return reinterpret_cast<DWriteCreateFactoryType>(result);
-}
-
-static void createDirectWriteFactory(IDWriteFactory **factory)
-{
- *factory = Q_NULLPTR;
-
- static const DWriteCreateFactoryType dWriteCreateFactory = resolveDWriteCreateFactory();
- if (!dWriteCreateFactory)
- return;
-
- IUnknown *result = NULL;
-#if defined(QT_USE_DIRECTWRITE2)
- dWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory2), &result);
-#endif
-
- if (result == NULL) {
- if (FAILED(dWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), &result))) {
- qErrnoWarning("DWriteCreateFactory failed");
- return;
- }
- }
-
- *factory = static_cast<IDWriteFactory *>(result);
-}
-
-static inline bool useDirectWrite(QFont::HintingPreference hintingPreference, bool isColorFont = false)
-{
- const unsigned options = QWindowsIntegration::instance()->options();
- if (Q_UNLIKELY(options & QWindowsIntegration::DontUseDirectWriteFonts))
- return false;
- if (isColorFont)
- return (options & QWindowsIntegration::DontUseColorFonts) == 0;
- return hintingPreference == QFont::PreferNoHinting
- || hintingPreference == QFont::PreferVerticalHinting
- || (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting);
-}
-#endif // !QT_NO_DIRECTWRITE
-
-// Helper classes for creating font engines directly from font data
-namespace {
-
-# pragma pack(1)
-
- // Common structure for all formats of the "name" table
- struct NameTable
- {
- quint16 format;
- quint16 count;
- quint16 stringOffset;
- };
-
- struct NameRecord
- {
- quint16 platformID;
- quint16 encodingID;
- quint16 languageID;
- quint16 nameID;
- quint16 length;
- quint16 offset;
- };
-
- struct OffsetSubTable
- {
- quint32 scalerType;
- quint16 numTables;
- quint16 searchRange;
- quint16 entrySelector;
- quint16 rangeShift;
- };
-
- struct TableDirectory
- {
- quint32 identifier;
- quint32 checkSum;
- quint32 offset;
- quint32 length;
- };
-
- struct OS2Table
- {
- quint16 version;
- qint16 avgCharWidth;
- quint16 weightClass;
- quint16 widthClass;
- quint16 type;
- qint16 subscriptXSize;
- qint16 subscriptYSize;
- qint16 subscriptXOffset;
- qint16 subscriptYOffset;
- qint16 superscriptXSize;
- qint16 superscriptYSize;
- qint16 superscriptXOffset;
- qint16 superscriptYOffset;
- qint16 strikeOutSize;
- qint16 strikeOutPosition;
- qint16 familyClass;
- quint8 panose[10];
- quint32 unicodeRanges[4];
- quint8 vendorID[4];
- quint16 selection;
- quint16 firstCharIndex;
- quint16 lastCharIndex;
- qint16 typoAscender;
- qint16 typoDescender;
- qint16 typoLineGap;
- quint16 winAscent;
- quint16 winDescent;
- quint32 codepageRanges[2];
- qint16 height;
- qint16 capHeight;
- quint16 defaultChar;
- quint16 breakChar;
- quint16 maxContext;
- };
-
-# pragma pack()
-
- class EmbeddedFont
- {
- public:
- EmbeddedFont(const QByteArray &fontData) : m_fontData(fontData) {}
-
- QString changeFamilyName(const QString &newFamilyName);
- QByteArray data() const { return m_fontData; }
- TableDirectory *tableDirectoryEntry(const QByteArray &tagName);
- QString familyName(TableDirectory *nameTableDirectory = 0);
-
- private:
- QByteArray m_fontData;
- };
-
- TableDirectory *EmbeddedFont::tableDirectoryEntry(const QByteArray &tagName)
- {
- Q_ASSERT(tagName.size() == 4);
- quint32 tagId = *(reinterpret_cast<const quint32 *>(tagName.constData()));
- const size_t fontDataSize = m_fontData.size();
- if (Q_UNLIKELY(fontDataSize < sizeof(OffsetSubTable)))
- return 0;
-
- OffsetSubTable *offsetSubTable = reinterpret_cast<OffsetSubTable *>(m_fontData.data());
- TableDirectory *tableDirectory = reinterpret_cast<TableDirectory *>(offsetSubTable + 1);
-
- const size_t tableCount = qFromBigEndian<quint16>(offsetSubTable->numTables);
- if (Q_UNLIKELY(fontDataSize < sizeof(OffsetSubTable) + sizeof(TableDirectory) * tableCount))
- return 0;
-
- TableDirectory *tableDirectoryEnd = tableDirectory + tableCount;
- for (TableDirectory *entry = tableDirectory; entry < tableDirectoryEnd; ++entry) {
- if (entry->identifier == tagId)
- return entry;
- }
-
- return 0;
- }
-
- QString EmbeddedFont::familyName(TableDirectory *nameTableDirectoryEntry)
- {
- QString name;
-
- if (nameTableDirectoryEntry == 0)
- nameTableDirectoryEntry = tableDirectoryEntry("name");
-
- if (nameTableDirectoryEntry != 0) {
- quint32 offset = qFromBigEndian<quint32>(nameTableDirectoryEntry->offset);
- if (Q_UNLIKELY(quint32(m_fontData.size()) < offset + sizeof(NameTable)))
- return QString();
-
- NameTable *nameTable = reinterpret_cast<NameTable *>(m_fontData.data() + offset);
- NameRecord *nameRecord = reinterpret_cast<NameRecord *>(nameTable + 1);
-
- quint16 nameTableCount = qFromBigEndian<quint16>(nameTable->count);
- if (Q_UNLIKELY(quint32(m_fontData.size()) < offset + sizeof(NameRecord) * nameTableCount))
- return QString();
-
- for (int i = 0; i < nameTableCount; ++i, ++nameRecord) {
- if (qFromBigEndian<quint16>(nameRecord->nameID) == 1
- && qFromBigEndian<quint16>(nameRecord->platformID) == 3 // Windows
- && qFromBigEndian<quint16>(nameRecord->languageID) == 0x0409) { // US English
- quint16 stringOffset = qFromBigEndian<quint16>(nameTable->stringOffset);
- quint16 nameOffset = qFromBigEndian<quint16>(nameRecord->offset);
- quint16 nameLength = qFromBigEndian<quint16>(nameRecord->length);
-
- if (Q_UNLIKELY(quint32(m_fontData.size()) < offset + stringOffset + nameOffset + nameLength))
- return QString();
-
- const void *ptr = reinterpret_cast<const quint8 *>(nameTable)
- + stringOffset
- + nameOffset;
-
- const quint16 *s = reinterpret_cast<const quint16 *>(ptr);
- const quint16 *e = s + nameLength / sizeof(quint16);
- while (s != e)
- name += QChar( qFromBigEndian<quint16>(*s++));
- break;
- }
- }
- }
-
- return name;
- }
-
- QString EmbeddedFont::changeFamilyName(const QString &newFamilyName)
- {
- TableDirectory *nameTableDirectoryEntry = tableDirectoryEntry("name");
- if (nameTableDirectoryEntry == 0)
- return QString();
-
- QString oldFamilyName = familyName(nameTableDirectoryEntry);
-
- // Reserve size for name table header, five required name records and string
- const int requiredRecordCount = 5;
- quint16 nameIds[requiredRecordCount] = { 1, 2, 3, 4, 6 };
-
- int sizeOfHeader = sizeof(NameTable) + sizeof(NameRecord) * requiredRecordCount;
- int newFamilyNameSize = newFamilyName.size() * int(sizeof(quint16));
-
- const QString regularString = QString::fromLatin1("Regular");
- int regularStringSize = regularString.size() * int(sizeof(quint16));
-
- // Align table size of table to 32 bits (pad with 0)
- int fullSize = ((sizeOfHeader + newFamilyNameSize + regularStringSize) & ~3) + 4;
-
- QByteArray newNameTable(fullSize, char(0));
-
- {
- NameTable *nameTable = reinterpret_cast<NameTable *>(newNameTable.data());
- nameTable->count = qbswap<quint16>(requiredRecordCount);
- nameTable->stringOffset = qbswap<quint16>(sizeOfHeader);
-
- NameRecord *nameRecord = reinterpret_cast<NameRecord *>(nameTable + 1);
- for (int i = 0; i < requiredRecordCount; ++i, nameRecord++) {
- nameRecord->nameID = qbswap<quint16>(nameIds[i]);
- nameRecord->encodingID = qbswap<quint16>(1);
- nameRecord->languageID = qbswap<quint16>(0x0409);
- nameRecord->platformID = qbswap<quint16>(3);
- nameRecord->length = qbswap<quint16>(newFamilyNameSize);
-
- // Special case for sub-family
- if (nameIds[i] == 4) {
- nameRecord->offset = qbswap<quint16>(newFamilyNameSize);
- nameRecord->length = qbswap<quint16>(regularStringSize);
- }
- }
-
- // nameRecord now points to string data
- quint16 *stringStorage = reinterpret_cast<quint16 *>(nameRecord);
- const quint16 *sourceString = newFamilyName.utf16();
- for (int i = 0; i < newFamilyName.size(); ++i)
- stringStorage[i] = qbswap<quint16>(sourceString[i]);
- stringStorage += newFamilyName.size();
-
- sourceString = regularString.utf16();
- for (int i = 0; i < regularString.size(); ++i)
- stringStorage[i] = qbswap<quint16>(sourceString[i]);
- }
-
- quint32 *p = reinterpret_cast<quint32 *>(newNameTable.data());
- quint32 *tableEnd = reinterpret_cast<quint32 *>(newNameTable.data() + fullSize);
-
- quint32 checkSum = 0;
- while (p < tableEnd)
- checkSum += qFromBigEndian<quint32>(*(p++));
-
- nameTableDirectoryEntry->checkSum = qbswap<quint32>(checkSum);
- nameTableDirectoryEntry->offset = qbswap<quint32>(m_fontData.size());
- nameTableDirectoryEntry->length = qbswap<quint32>(fullSize);
-
- m_fontData.append(newNameTable);
-
- return oldFamilyName;
- }
-
-#if !defined(QT_NO_DIRECTWRITE)
-
- class DirectWriteFontFileStream: public IDWriteFontFileStream
- {
- public:
- DirectWriteFontFileStream(const QByteArray &fontData)
- : m_fontData(fontData)
- , m_referenceCount(0)
- {
- }
- virtual ~DirectWriteFontFileStream()
- {
- }
-
- HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **object);
- ULONG STDMETHODCALLTYPE AddRef();
- ULONG STDMETHODCALLTYPE Release();
-
- HRESULT STDMETHODCALLTYPE ReadFileFragment(const void **fragmentStart, UINT64 fileOffset,
- UINT64 fragmentSize, OUT void **fragmentContext);
- void STDMETHODCALLTYPE ReleaseFileFragment(void *fragmentContext);
- HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64 *fileSize);
- HRESULT STDMETHODCALLTYPE GetLastWriteTime(OUT UINT64 *lastWriteTime);
-
- private:
- QByteArray m_fontData;
- ULONG m_referenceCount;
- };
-
- HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::QueryInterface(REFIID iid, void **object)
- {
- if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileStream)) {
- *object = this;
- AddRef();
- return S_OK;
- } else {
- *object = NULL;
- return E_NOINTERFACE;
- }
- }
-
- ULONG STDMETHODCALLTYPE DirectWriteFontFileStream::AddRef()
- {
- return InterlockedIncrement(&m_referenceCount);
- }
-
- ULONG STDMETHODCALLTYPE DirectWriteFontFileStream::Release()
- {
- ULONG newCount = InterlockedDecrement(&m_referenceCount);
- if (newCount == 0)
- delete this;
- return newCount;
- }
-
- HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::ReadFileFragment(
- const void **fragmentStart,
- UINT64 fileOffset,
- UINT64 fragmentSize,
- OUT void **fragmentContext)
- {
- *fragmentContext = NULL;
- if (fileOffset + fragmentSize <= quint64(m_fontData.size())) {
- *fragmentStart = m_fontData.data() + fileOffset;
- return S_OK;
- } else {
- *fragmentStart = NULL;
- return E_FAIL;
- }
- }
-
- void STDMETHODCALLTYPE DirectWriteFontFileStream::ReleaseFileFragment(void *)
- {
- }
-
- HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::GetFileSize(UINT64 *fileSize)
- {
- *fileSize = m_fontData.size();
- return S_OK;
- }
-
- HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::GetLastWriteTime(UINT64 *lastWriteTime)
- {
- *lastWriteTime = 0;
- return E_NOTIMPL;
- }
-
- class DirectWriteFontFileLoader: public IDWriteFontFileLoader
- {
- public:
- DirectWriteFontFileLoader() : m_referenceCount(0) {}
- virtual ~DirectWriteFontFileLoader()
- {
- }
-
- inline void addKey(const void *key, const QByteArray &fontData)
- {
- Q_ASSERT(!m_fontDatas.contains(key));
- m_fontDatas.insert(key, fontData);
- }
-
- inline void removeKey(const void *key)
- {
- m_fontDatas.remove(key);
- }
-
- HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **object);
- ULONG STDMETHODCALLTYPE AddRef();
- ULONG STDMETHODCALLTYPE Release();
-
- HRESULT STDMETHODCALLTYPE CreateStreamFromKey(void const *fontFileReferenceKey,
- UINT32 fontFileReferenceKeySize,
- OUT IDWriteFontFileStream **fontFileStream);
-
- private:
- ULONG m_referenceCount;
- QHash<const void *, QByteArray> m_fontDatas;
- };
-
- HRESULT STDMETHODCALLTYPE DirectWriteFontFileLoader::QueryInterface(const IID &iid,
- void **object)
- {
- if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) {
- *object = this;
- AddRef();
- return S_OK;
- } else {
- *object = NULL;
- return E_NOINTERFACE;
- }
- }
-
- ULONG STDMETHODCALLTYPE DirectWriteFontFileLoader::AddRef()
- {
- return InterlockedIncrement(&m_referenceCount);
- }
-
- ULONG STDMETHODCALLTYPE DirectWriteFontFileLoader::Release()
- {
- ULONG newCount = InterlockedDecrement(&m_referenceCount);
- if (newCount == 0)
- delete this;
- return newCount;
- }
-
- HRESULT STDMETHODCALLTYPE DirectWriteFontFileLoader::CreateStreamFromKey(
- void const *fontFileReferenceKey,
- UINT32 fontFileReferenceKeySize,
- IDWriteFontFileStream **fontFileStream)
- {
- Q_UNUSED(fontFileReferenceKeySize);
-
- if (fontFileReferenceKeySize != sizeof(const void *)) {
- qWarning("%s: Wrong key size", __FUNCTION__);
- return E_FAIL;
- }
-
- const void *key = *reinterpret_cast<void * const *>(fontFileReferenceKey);
- *fontFileStream = NULL;
- if (!m_fontDatas.contains(key))
- return E_FAIL;
-
- QByteArray fontData = m_fontDatas.value(key);
- DirectWriteFontFileStream *stream = new DirectWriteFontFileStream(fontData);
- stream->AddRef();
- *fontFileStream = stream;
-
- return S_OK;
- }
-
- class CustomFontFileLoader
- {
- public:
- CustomFontFileLoader() : m_directWriteFontFileLoader(Q_NULLPTR)
- {
- createDirectWriteFactory(&m_directWriteFactory);
-
- if (m_directWriteFactory) {
- m_directWriteFontFileLoader = new DirectWriteFontFileLoader();
- m_directWriteFactory->RegisterFontFileLoader(m_directWriteFontFileLoader);
- }
- }
-
- ~CustomFontFileLoader()
- {
- if (m_directWriteFactory != 0 && m_directWriteFontFileLoader != 0)
- m_directWriteFactory->UnregisterFontFileLoader(m_directWriteFontFileLoader);
-
- if (m_directWriteFactory != 0)
- m_directWriteFactory->Release();
- }
-
- void addKey(const void *key, const QByteArray &fontData)
- {
- if (m_directWriteFontFileLoader != 0)
- m_directWriteFontFileLoader->addKey(key, fontData);
- }
-
- void removeKey(const void *key)
- {
- if (m_directWriteFontFileLoader != 0)
- m_directWriteFontFileLoader->removeKey(key);
- }
-
- IDWriteFontFileLoader *loader() const
- {
- return m_directWriteFontFileLoader;
- }
-
- private:
- IDWriteFactory *m_directWriteFactory;
- DirectWriteFontFileLoader *m_directWriteFontFileLoader;
- };
-
-#endif
-
-} // Anonymous namespace
-
-/*!
- \struct QWindowsFontEngineData
- \brief Static constant data shared by the font engines.
- \ingroup qt-lighthouse-win
-*/
-
-QWindowsFontEngineData::QWindowsFontEngineData()
- : clearTypeEnabled(false)
- , fontSmoothingGamma(QWindowsFontDatabase::fontSmoothingGamma())
-#if !defined(QT_NO_DIRECTWRITE)
- , directWriteFactory(0)
- , directWriteGdiInterop(0)
-#endif
-{
- // from qapplication_win.cpp
- UINT result = 0;
- if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0))
- clearTypeEnabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
-
- const qreal gray_gamma = 2.31;
- for (int i=0; i<256; ++i)
- pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047));
-
- HDC displayDC = GetDC(0);
- hdc = CreateCompatibleDC(displayDC);
- ReleaseDC(0, displayDC);
-}
-
-QWindowsFontEngineData::~QWindowsFontEngineData()
-{
- if (hdc)
- DeleteDC(hdc);
-#if !defined(QT_NO_DIRECTWRITE)
- if (directWriteGdiInterop)
- directWriteGdiInterop->Release();
- if (directWriteFactory)
- directWriteFactory->Release();
-#endif
-}
-
-qreal QWindowsFontDatabase::fontSmoothingGamma()
-{
- int winSmooth;
- qreal result = 1;
- if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0))
- result = qreal(winSmooth) / qreal(1000.0);
-
- // Safeguard ourselves against corrupt registry values...
- if (result > 5 || result < 1)
- result = qreal(1.4);
- return result;
-}
-
-#if !defined(QT_NO_DIRECTWRITE)
-static inline bool initDirectWrite(QWindowsFontEngineData *d)
-{
- if (!d->directWriteFactory) {
- createDirectWriteFactory(&d->directWriteFactory);
- if (!d->directWriteFactory)
- return false;
- }
- if (!d->directWriteGdiInterop) {
- const HRESULT hr = d->directWriteFactory->GetGdiInterop(&d->directWriteGdiInterop);
- if (FAILED(hr)) {
- qErrnoWarning("%s: GetGdiInterop failed", __FUNCTION__);
- return false;
- }
- }
- return true;
-}
-
-#endif // !defined(QT_NO_DIRECTWRITE)
-
-/*!
- \class QWindowsFontDatabase
- \brief Font database for Windows
-
- \note The Qt 4.8 WIndows font database employed a mechanism of
- delayed population of the database again passing a font name
- to EnumFontFamiliesEx(), working around the fact that
- EnumFontFamiliesEx() does not list all fonts by default.
- This should be introduced to Lighthouse as well?
-
- \internal
- \ingroup qt-lighthouse-win
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const QFontDef &def)
-{
- QDebugStateSaver saver(d);
- d.nospace();
- d.noquote();
- d << "QFontDef(Family=\"" << def.family << '"';
- if (!def.styleName.isEmpty())
- d << ", stylename=" << def.styleName;
- d << ", pointsize=" << def.pointSize << ", pixelsize=" << def.pixelSize
- << ", styleHint=" << def.styleHint << ", weight=" << def.weight
- << ", stretch=" << def.stretch << ", hintingPreference="
- << def.hintingPreference << ')';
- return d;
-}
-
-QDebug operator<<(QDebug d, const LOGFONT &lf)
-{
- QDebugStateSaver saver(d);
- d.nospace();
- d.noquote();
- d << "LOGFONT(\"" << QString::fromWCharArray(lf.lfFaceName)
- << "\", lfWidth=" << lf.lfWidth << ", lfHeight=" << lf.lfHeight << ')';
- return d;
-}
-#endif // !QT_NO_DEBUG_STREAM
-
-static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet)
-{
- switch (charSet) {
- case ANSI_CHARSET:
- case EASTEUROPE_CHARSET:
- case BALTIC_CHARSET:
- case TURKISH_CHARSET:
- return QFontDatabase::Latin;
- case GREEK_CHARSET:
- return QFontDatabase::Greek;
- case RUSSIAN_CHARSET:
- return QFontDatabase::Cyrillic;
- case HEBREW_CHARSET:
- return QFontDatabase::Hebrew;
- case ARABIC_CHARSET:
- return QFontDatabase::Arabic;
- case THAI_CHARSET:
- return QFontDatabase::Thai;
- case GB2312_CHARSET:
- return QFontDatabase::SimplifiedChinese;
- case CHINESEBIG5_CHARSET:
- return QFontDatabase::TraditionalChinese;
- case SHIFTJIS_CHARSET:
- return QFontDatabase::Japanese;
- case HANGUL_CHARSET:
- case JOHAB_CHARSET:
- return QFontDatabase::Korean;
- case VIETNAMESE_CHARSET:
- return QFontDatabase::Vietnamese;
- case SYMBOL_CHARSET:
- return QFontDatabase::Symbol;
- default:
- break;
- }
- return QFontDatabase::Any;
-}
-
-#ifdef MAKE_TAG
-#undef MAKE_TAG
-#endif
-// GetFontData expects the tags in little endian ;(
-#define MAKE_TAG(ch1, ch2, ch3, ch4) (\
- (((quint32)(ch4)) << 24) | \
- (((quint32)(ch3)) << 16) | \
- (((quint32)(ch2)) << 8) | \
- ((quint32)(ch1)) \
- )
-
-bool localizedName(const QString &name)
-{
- const QChar *c = name.unicode();
- for (int i = 0; i < name.length(); ++i) {
- if (c[i].unicode() >= 0x100)
- return true;
- }
- return false;
-}
-
-static inline quint16 getUShort(const unsigned char *p)
-{
- quint16 val;
- val = *p++ << 8;
- val |= *p;
-
- return val;
-}
-
-static QString getEnglishName(const uchar *table, quint32 bytes)
-{
- QString i18n_name;
- enum {
- NameRecordSize = 12,
- FamilyId = 1,
- MS_LangIdEnglish = 0x009
- };
-
- // get the name table
- quint16 count;
- quint16 string_offset;
- const unsigned char *names;
-
- int microsoft_id = -1;
- int apple_id = -1;
- int unicode_id = -1;
-
- if (getUShort(table) != 0)
- goto error;
-
- count = getUShort(table+2);
- string_offset = getUShort(table+4);
- names = table + 6;
-
- if (string_offset >= bytes || 6 + count*NameRecordSize > string_offset)
- goto error;
-
- for (int i = 0; i < count; ++i) {
- // search for the correct name entry
-
- quint16 platform_id = getUShort(names + i*NameRecordSize);
- quint16 encoding_id = getUShort(names + 2 + i*NameRecordSize);
- quint16 language_id = getUShort(names + 4 + i*NameRecordSize);
- quint16 name_id = getUShort(names + 6 + i*NameRecordSize);
-
- if (name_id != FamilyId)
- continue;
-
- enum {
- PlatformId_Unicode = 0,
- PlatformId_Apple = 1,
- PlatformId_Microsoft = 3
- };
-
- quint16 length = getUShort(names + 8 + i*NameRecordSize);
- quint16 offset = getUShort(names + 10 + i*NameRecordSize);
- if (DWORD(string_offset + offset + length) >= bytes)
- continue;
-
- if ((platform_id == PlatformId_Microsoft
- && (encoding_id == 0 || encoding_id == 1))
- && (language_id & 0x3ff) == MS_LangIdEnglish
- && microsoft_id == -1)
- microsoft_id = i;
- // not sure if encoding id 4 for Unicode is utf16 or ucs4...
- else if (platform_id == PlatformId_Unicode && encoding_id < 4 && unicode_id == -1)
- unicode_id = i;
- else if (platform_id == PlatformId_Apple && encoding_id == 0 && language_id == 0)
- apple_id = i;
- }
- {
- bool unicode = false;
- int id = -1;
- if (microsoft_id != -1) {
- id = microsoft_id;
- unicode = true;
- } else if (apple_id != -1) {
- id = apple_id;
- unicode = false;
- } else if (unicode_id != -1) {
- id = unicode_id;
- unicode = true;
- }
- if (id != -1) {
- quint16 length = getUShort(names + 8 + id*NameRecordSize);
- quint16 offset = getUShort(names + 10 + id*NameRecordSize);
- if (unicode) {
- // utf16
-
- length /= 2;
- i18n_name.resize(length);
- QChar *uc = const_cast<QChar *>(i18n_name.unicode());
- const unsigned char *string = table + string_offset + offset;
- for (int i = 0; i < length; ++i)
- uc[i] = getUShort(string + 2*i);
- } else {
- // Apple Roman
-
- i18n_name.resize(length);
- QChar *uc = const_cast<QChar *>(i18n_name.unicode());
- const unsigned char *string = table + string_offset + offset;
- for (int i = 0; i < length; ++i)
- uc[i] = QLatin1Char(char(string[i]));
- }
- }
- }
-error:
- //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data());
- return i18n_name;
-}
-
-QString getEnglishName(const QString &familyName)
-{
- QString i18n_name;
-
- HDC hdc = GetDC( 0 );
- LOGFONT lf;
- memset(&lf, 0, sizeof(LOGFONT));
- memcpy(lf.lfFaceName, familyName.utf16(), qMin(familyName.length(), LF_FACESIZE - 1) * sizeof(wchar_t));
- lf.lfCharSet = DEFAULT_CHARSET;
- HFONT hfont = CreateFontIndirect(&lf);
-
- if (!hfont) {
- ReleaseDC(0, hdc);
- return QString();
- }
-
- HGDIOBJ oldobj = SelectObject( hdc, hfont );
-
- const DWORD name_tag = MAKE_TAG( 'n', 'a', 'm', 'e' );
-
- // get the name table
- unsigned char *table = 0;
-
- DWORD bytes = GetFontData( hdc, name_tag, 0, 0, 0 );
- if ( bytes == GDI_ERROR ) {
- // ### Unused variable
- // int err = GetLastError();
- goto error;
- }
-
- table = new unsigned char[bytes];
- GetFontData(hdc, name_tag, 0, table, bytes);
- if ( bytes == GDI_ERROR )
- goto error;
-
- i18n_name = getEnglishName(table, bytes);
-error:
- delete [] table;
- SelectObject( hdc, oldobj );
- DeleteObject( hfont );
- ReleaseDC( 0, hdc );
-
- //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data());
- return i18n_name;
-}
-
-static bool addFontToDatabase(const QString &familyName, uchar charSet,
- const TEXTMETRIC *textmetric,
- const FONTSIGNATURE *signature,
- int type,
- bool registerAlias)
-{
- // the "@family" fonts are just the same as "family". Ignore them.
- if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QLatin1String("WST_")))
- return false;
-
- static const int SMOOTH_SCALABLE = 0xffff;
- const QString foundryName; // No such concept.
- const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
- const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
- const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
- const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
- const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
- const bool antialias = false;
- const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(textmetric->tmWeight);
- const QFont::Stretch stretch = QFont::Unstretched;
-
-#ifndef QT_NO_DEBUG_OUTPUT
- if (QWindowsContext::verbose > 2) {
- QString message;
- QTextStream str(&message);
- str << __FUNCTION__ << ' ' << familyName << ' ' << charSet << " TTF=" << ttf;
- if (type & DEVICE_FONTTYPE)
- str << " DEVICE";
- if (type & RASTER_FONTTYPE)
- str << " RASTER";
- if (type & TRUETYPE_FONTTYPE)
- str << " TRUETYPE";
- str << " scalable=" << scalable << " Size=" << size
- << " Style=" << style << " Weight=" << weight
- << " stretch=" << stretch;
- qCDebug(lcQpaFonts) << message;
- }
-#endif
-
- QString englishName;
- if (registerAlias && ttf && localizedName(familyName))
- englishName = getEnglishName(familyName);
-
- QSupportedWritingSystems writingSystems;
- if (type & TRUETYPE_FONTTYPE) {
- Q_ASSERT(signature);
- quint32 unicodeRange[4] = {
- signature->fsUsb[0], signature->fsUsb[1],
- signature->fsUsb[2], signature->fsUsb[3]
- };
- quint32 codePageRange[2] = {
- signature->fsCsb[0], signature->fsCsb[1]
- };
-#ifdef Q_OS_WINCE
- if (signature->fsUsb[0] == 0) {
- // If the unicode ranges bit mask is zero then
- // EnumFontFamiliesEx failed to determine it properly.
- // In this case we just pretend that the font supports all languages.
- unicodeRange[0] = 0xbfffffff; // second most significant bit must be zero
- unicodeRange[1] = 0xffffffff;
- unicodeRange[2] = 0xffffffff;
- unicodeRange[3] = 0xffffffff;
- }
-#endif
- writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
- // ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains
- // the symbol for Baht, and Windows thus reports that it supports the Thai script.
- // Since it's the default UI font on this platform, most widgets will be unable to
- // display Thai text by default. As a temporary work around, we special case Segoe UI
- // and remove the Thai script from its list of supported writing systems.
- if (writingSystems.supported(QFontDatabase::Thai) &&
- familyName == QLatin1String("Segoe UI"))
- writingSystems.setSupported(QFontDatabase::Thai, false);
- } else {
- const QFontDatabase::WritingSystem ws = writingSystemFromCharSet(charSet);
- if (ws != QFontDatabase::Any)
- writingSystems.setSupported(ws);
- }
-
- QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight,
- style, stretch, antialias, scalable, size, fixed, writingSystems, 0);
- // add fonts windows can generate for us:
- if (weight <= QFont::DemiBold)
- QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
- style, stretch, antialias, scalable, size, fixed, writingSystems, 0);
- if (style != QFont::StyleItalic)
- QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight,
- QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, 0);
- if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
- QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
- QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, 0);
-
- if (!englishName.isEmpty())
- QPlatformFontDatabase::registerAliasToFontFamily(familyName, englishName);
-
- return true;
-}
-
-static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
- DWORD type, LPARAM lParam)
-{
- const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
- const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
- const uchar charSet = f->elfLogFont.lfCharSet;
- const bool registerAlias = bool(lParam);
-
- // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
- // to the documentation is identical to a TEXTMETRIC except for the last four
- // members, which we don't use anyway
- const FONTSIGNATURE *signature = Q_NULLPTR;
- if (type & TRUETYPE_FONTTYPE)
- signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
- addFontToDatabase(familyName, charSet, textmetric, signature, type, registerAlias);
-
- // keep on enumerating
- return 1;
-}
-
-void QWindowsFontDatabase::populateFamily(const QString &familyName, bool registerAlias)
-{
- qCDebug(lcQpaFonts) << familyName;
- if (familyName.size() >= LF_FACESIZE) {
- qCWarning(lcQpaFonts) << "Unable to enumerate family '" << familyName << '\'';
- return;
- }
- HDC dummy = GetDC(0);
- LOGFONT lf;
- lf.lfCharSet = DEFAULT_CHARSET;
- familyName.toWCharArray(lf.lfFaceName);
- lf.lfFaceName[familyName.size()] = 0;
- lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, storeFont, LPARAM(registerAlias), 0);
- ReleaseDC(0, dummy);
-}
-
-void QWindowsFontDatabase::populateFamily(const QString &familyName)
-{
- populateFamily(familyName, false);
-}
-
-namespace {
-// Context for enumerating system fonts, records whether the default font has been encountered,
-// which is normally not enumerated by EnumFontFamiliesEx().
-struct PopulateFamiliesContext
-{
- PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {}
-
- QString systemDefaultFont;
- bool seenSystemDefaultFont;
-};
-} // namespace
-
-static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
- DWORD, LPARAM lparam)
-{
- // the "@family" fonts are just the same as "family". Ignore them.
- const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
- const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
- if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
- const QString faceName = QString::fromWCharArray(faceNameW);
- QPlatformFontDatabase::registerFontFamily(faceName);
- PopulateFamiliesContext *context = reinterpret_cast<PopulateFamiliesContext *>(lparam);
- if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont)
- context->seenSystemDefaultFont = true;
-
- // Register current font's english name as alias
- const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
- if (ttf && localizedName(faceName)) {
- const QString englishName = getEnglishName(faceName);
- if (!englishName.isEmpty()) {
- QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName);
- // Check whether the system default font name is an alias of the current font family name,
- // as on Chinese Windows, where the system font "SimSun" is an alias to a font registered under a local name
- if (!context->seenSystemDefaultFont && englishName == context->systemDefaultFont)
- context->seenSystemDefaultFont = true;
- }
- }
- }
- return 1; // continue
-}
-
-void QWindowsFontDatabase::populateFontDatabase()
-{
- removeApplicationFonts();
- HDC dummy = GetDC(0);
- LOGFONT lf;
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfFaceName[0] = 0;
- lf.lfPitchAndFamily = 0;
- PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
- ReleaseDC(0, dummy);
- // Work around EnumFontFamiliesEx() not listing the system font.
- if (!context.seenSystemDefaultFont)
- QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont);
-}
-
-typedef QSharedPointer<QWindowsFontEngineData> QWindowsFontEngineDataPtr;
-
-#ifndef QT_NO_THREAD
-typedef QThreadStorage<QWindowsFontEngineDataPtr> FontEngineThreadLocalData;
-
-Q_GLOBAL_STATIC(FontEngineThreadLocalData, fontEngineThreadLocalData)
-
-QSharedPointer<QWindowsFontEngineData> sharedFontData()
-{
- FontEngineThreadLocalData *data = fontEngineThreadLocalData();
- if (!data->hasLocalData())
- data->setLocalData(QSharedPointer<QWindowsFontEngineData>::create());
- return data->localData();
-}
-#else // !QT_NO_THREAD
-Q_GLOBAL_STATIC(QWindowsFontEngineDataPtr, fontEngineData)
-
-QWindowsFontEngineDataPtr sharedFontData()
-{
- QWindowsFontEngineDataPtr *data = fontEngineData();
- if (data->isNull())
- *data = QWindowsFontEngineDataPtr::create();
- return *data;
-}
-#endif // QT_NO_THREAD
-
-#ifndef Q_OS_WINCE
-extern Q_GUI_EXPORT bool qt_needs_a8_gamma_correction;
-#endif
-QWindowsFontDatabase::QWindowsFontDatabase()
-{
- // Properties accessed by QWin32PrintEngine (Qt Print Support)
- static const int hfontMetaTypeId = qRegisterMetaType<HFONT>();
- static const int logFontMetaTypeId = qRegisterMetaType<LOGFONT>();
- Q_UNUSED(hfontMetaTypeId)
- Q_UNUSED(logFontMetaTypeId)
-
- if (lcQpaFonts().isDebugEnabled()) {
- const QWindowsFontEngineDataPtr data = sharedFontData();
- qCDebug(lcQpaFonts) << __FUNCTION__ << "Clear type: "
- << data->clearTypeEnabled << "gamma: " << data->fontSmoothingGamma;
- }
-#ifndef Q_OS_WINCE
- qt_needs_a8_gamma_correction = true;
-#endif
-}
-
-QWindowsFontDatabase::~QWindowsFontDatabase()
-{
- removeApplicationFonts();
-}
-
-QFontEngineMulti *QWindowsFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
-{
- return new QWindowsMultiFontEngine(fontEngine, script);
-}
-
-QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, void *handle)
-{
- QFontEngine *fe = QWindowsFontDatabase::createEngine(fontDef,
- QWindowsContext::instance()->defaultDPI(),
- sharedFontData());
- qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef << fe << handle;
- return fe;
-}
-
-QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
-{
- EmbeddedFont font(fontData);
- QFontEngine *fontEngine = 0;
-
-#if !defined(QT_NO_DIRECTWRITE)
- if (!useDirectWrite(hintingPreference))
-#endif
- {
- GUID guid;
- CoCreateGuid(&guid);
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_GCC("-Wstrict-aliasing")
- QString uniqueFamilyName = QLatin1Char('f')
- + QString::number(guid.Data1, 36) + QLatin1Char('-')
- + QString::number(guid.Data2, 36) + QLatin1Char('-')
- + QString::number(guid.Data3, 36) + QLatin1Char('-')
- + QString::number(*reinterpret_cast<quint64 *>(guid.Data4), 36);
-QT_WARNING_POP
-
- QString actualFontName = font.changeFamilyName(uniqueFamilyName);
- if (actualFontName.isEmpty()) {
- qWarning("%s: Can't change family name of font", __FUNCTION__);
- return 0;
- }
-
- DWORD count = 0;
- QByteArray newFontData = font.data();
- HANDLE fontHandle =
- AddFontMemResourceEx(const_cast<char *>(newFontData.constData()),
- DWORD(newFontData.size()), 0, &count);
- if (count == 0 && fontHandle != 0) {
- RemoveFontMemResourceEx(fontHandle);
- fontHandle = 0;
- }
-
- if (fontHandle == 0) {
- qWarning("%s: AddFontMemResourceEx failed", __FUNCTION__);
- } else {
- QFontDef request;
- request.family = uniqueFamilyName;
- request.pixelSize = pixelSize;
- request.styleStrategy = QFont::PreferMatch;
- request.hintingPreference = hintingPreference;
-
- fontEngine = QWindowsFontDatabase::createEngine(request,
- QWindowsContext::instance()->defaultDPI(),
- sharedFontData());
-
- if (fontEngine) {
- if (request.family != fontEngine->fontDef.family) {
- qWarning("%s: Failed to load font. Got fallback instead: %s",
- __FUNCTION__, qPrintable(fontEngine->fontDef.family));
- if (fontEngine->ref.load() == 0)
- delete fontEngine;
- fontEngine = 0;
- } else {
- Q_ASSERT(fontEngine->ref.load() == 0);
-
- // Override the generated font name
- switch (fontEngine->type()) {
- case QFontEngine::Win:
- static_cast<QWindowsFontEngine *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName);
- fontEngine->fontDef.family = actualFontName;
- break;
-
-#if !defined(QT_NO_DIRECTWRITE)
- case QFontEngine::DirectWrite:
- static_cast<QWindowsFontEngineDirectWrite *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName);
- fontEngine->fontDef.family = actualFontName;
- break;
-#endif // !QT_NO_DIRECTWRITE
-
- default:
- Q_ASSERT_X(false, Q_FUNC_INFO, "Unhandled font engine.");
- }
-
- UniqueFontData uniqueData;
- uniqueData.handle = fontHandle;
- uniqueData.refCount.ref();
- m_uniqueFontData[uniqueFamilyName] = uniqueData;
- }
- } else {
- RemoveFontMemResourceEx(fontHandle);
- }
- }
- }
-#if !defined(QT_NO_DIRECTWRITE)
- else {
- CustomFontFileLoader fontFileLoader;
- fontFileLoader.addKey(this, fontData);
-
- QSharedPointer<QWindowsFontEngineData> fontEngineData = sharedFontData();
- if (!initDirectWrite(fontEngineData.data()))
- return 0;
-
- IDWriteFontFile *fontFile = 0;
- void *key = this;
-
- HRESULT hres = fontEngineData->directWriteFactory->CreateCustomFontFileReference(&key,
- sizeof(void *),
- fontFileLoader.loader(),
- &fontFile);
- if (FAILED(hres)) {
- qErrnoWarning(hres, "%s: CreateCustomFontFileReference failed", __FUNCTION__);
- return 0;
- }
-
- BOOL isSupportedFontType;
- DWRITE_FONT_FILE_TYPE fontFileType;
- DWRITE_FONT_FACE_TYPE fontFaceType;
- UINT32 numberOfFaces;
- fontFile->Analyze(&isSupportedFontType, &fontFileType, &fontFaceType, &numberOfFaces);
- if (!isSupportedFontType) {
- fontFile->Release();
- return 0;
- }
-
- IDWriteFontFace *directWriteFontFace = 0;
- hres = fontEngineData->directWriteFactory->CreateFontFace(fontFaceType,
- 1,
- &fontFile,
- 0,
- DWRITE_FONT_SIMULATIONS_NONE,
- &directWriteFontFace);
- if (FAILED(hres)) {
- qErrnoWarning(hres, "%s: CreateFontFace failed", __FUNCTION__);
- fontFile->Release();
- return 0;
- }
-
- fontFile->Release();
-
- fontEngine = new QWindowsFontEngineDirectWrite(directWriteFontFace,
- pixelSize,
- fontEngineData);
-
- // Get font family from font data
- fontEngine->fontDef.family = font.familyName();
- fontEngine->fontDef.hintingPreference = hintingPreference;
-
- directWriteFontFace->Release();
- }
-#endif
-
- // Get style and weight info
- if (fontEngine != 0) {
- TableDirectory *os2TableEntry = font.tableDirectoryEntry("OS/2");
- if (os2TableEntry != 0) {
- const OS2Table *os2Table =
- reinterpret_cast<const OS2Table *>(fontData.constData()
- + qFromBigEndian<quint32>(os2TableEntry->offset));
-
- bool italic = qFromBigEndian<quint16>(os2Table->selection) & 1;
- bool oblique = qFromBigEndian<quint16>(os2Table->selection) & 128;
-
- if (italic)
- fontEngine->fontDef.style = QFont::StyleItalic;
- else if (oblique)
- fontEngine->fontDef.style = QFont::StyleOblique;
- else
- fontEngine->fontDef.style = QFont::StyleNormal;
-
- fontEngine->fontDef.weight = QPlatformFontDatabase::weightFromInteger(qFromBigEndian<quint16>(os2Table->weightClass));
- }
- }
-
- qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDATA" << fontData << pixelSize << hintingPreference << fontEngine;
- return fontEngine;
-}
-
-static QList<quint32> getTrueTypeFontOffsets(const uchar *fontData)
-{
- QList<quint32> offsets;
- const quint32 headerTag = *reinterpret_cast<const quint32 *>(fontData);
- if (headerTag != MAKE_TAG('t', 't', 'c', 'f')) {
- if (headerTag != MAKE_TAG(0, 1, 0, 0)
- && headerTag != MAKE_TAG('O', 'T', 'T', 'O')
- && headerTag != MAKE_TAG('t', 'r', 'u', 'e')
- && headerTag != MAKE_TAG('t', 'y', 'p', '1'))
- return offsets;
- offsets << 0;
- return offsets;
- }
- const quint32 numFonts = qFromBigEndian<quint32>(fontData + 8);
- for (uint i = 0; i < numFonts; ++i) {
- offsets << qFromBigEndian<quint32>(fontData + 12 + i * 4);
- }
- return offsets;
-}
-
-static void getFontTable(const uchar *fileBegin, const uchar *data, quint32 tag, const uchar **table, quint32 *length)
-{
- const quint16 numTables = qFromBigEndian<quint16>(data + 4);
- for (uint i = 0; i < numTables; ++i) {
- const quint32 offset = 12 + 16 * i;
- if (*reinterpret_cast<const quint32 *>(data + offset) == tag) {
- *table = fileBegin + qFromBigEndian<quint32>(data + offset + 8);
- *length = qFromBigEndian<quint32>(data + offset + 12);
- return;
- }
- }
- *table = 0;
- *length = 0;
- return;
-}
-
-static void getFamiliesAndSignatures(const QByteArray &fontData,
- QStringList *families,
- QVector<FONTSIGNATURE> *signatures)
-{
- const uchar *data = reinterpret_cast<const uchar *>(fontData.constData());
-
- QList<quint32> offsets = getTrueTypeFontOffsets(data);
- if (offsets.isEmpty())
- return;
-
- for (int i = 0; i < offsets.count(); ++i) {
- const uchar *font = data + offsets.at(i);
- const uchar *table;
- quint32 length;
- getFontTable(data, font, MAKE_TAG('n', 'a', 'm', 'e'), &table, &length);
- if (!table)
- continue;
- QString name = getEnglishName(table, length);
- if (name.isEmpty())
- continue;
-
- families->append(name);
-
- if (signatures) {
- FONTSIGNATURE signature;
- getFontTable(data, font, MAKE_TAG('O', 'S', '/', '2'), &table, &length);
- if (table && length >= 86) {
- // Offsets taken from OS/2 table in the TrueType spec
- signature.fsUsb[0] = qFromBigEndian<quint32>(table + 42);
- signature.fsUsb[1] = qFromBigEndian<quint32>(table + 46);
- signature.fsUsb[2] = qFromBigEndian<quint32>(table + 50);
- signature.fsUsb[3] = qFromBigEndian<quint32>(table + 54);
-
- signature.fsCsb[0] = qFromBigEndian<quint32>(table + 78);
- signature.fsCsb[1] = qFromBigEndian<quint32>(table + 82);
- } else {
- memset(&signature, 0, sizeof(signature));
- }
- signatures->append(signature);
- }
- }
-}
-
-QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)
-{
- WinApplicationFont font;
- font.fileName = fileName;
- QVector<FONTSIGNATURE> signatures;
- QStringList families;
-
- if (!fontData.isEmpty()) {
- getFamiliesAndSignatures(fontData, &families, &signatures);
- if (families.isEmpty())
- return families;
-
- DWORD dummy = 0;
- font.handle =
- AddFontMemResourceEx(const_cast<char *>(fontData.constData()),
- DWORD(fontData.size()), 0, &dummy);
- if (font.handle == 0)
- return QStringList();
-
- // Memory fonts won't show up in enumeration, so do add them the hard way.
- for (int j = 0; j < families.count(); ++j) {
- const QString familyName = families.at(j);
- HDC hdc = GetDC(0);
- LOGFONT lf;
- memset(&lf, 0, sizeof(LOGFONT));
- memcpy(lf.lfFaceName, familyName.utf16(), sizeof(wchar_t) * qMin(LF_FACESIZE - 1, familyName.size()));
- lf.lfCharSet = DEFAULT_CHARSET;
- HFONT hfont = CreateFontIndirect(&lf);
- HGDIOBJ oldobj = SelectObject(hdc, hfont);
-
- TEXTMETRIC textMetrics;
- GetTextMetrics(hdc, &textMetrics);
-
- addFontToDatabase(familyName, lf.lfCharSet, &textMetrics, &signatures.at(j),
- TRUETYPE_FONTTYPE, true);
-
- SelectObject(hdc, oldobj);
- DeleteObject(hfont);
- ReleaseDC(0, hdc);
- }
- } else {
- QFile f(fileName);
- if (!f.open(QIODevice::ReadOnly))
- return families;
- QByteArray data = f.readAll();
- f.close();
-
- getFamiliesAndSignatures(data, &families, 0);
- if (families.isEmpty())
- return families;
-
- if (AddFontResourceExW((wchar_t*)fileName.utf16(), FR_PRIVATE, 0) == 0)
- return QStringList();
-
- font.handle = 0;
-
- // Fonts based on files are added via populate, as they will show up in font enumeration.
- for (int j = 0; j < families.count(); ++j)
- populateFamily(families.at(j), true);
- }
-
- m_applicationFonts << font;
-
- return families;
-}
-
-void QWindowsFontDatabase::removeApplicationFonts()
-{
- foreach (const WinApplicationFont &font, m_applicationFonts) {
- if (font.handle) {
- RemoveFontMemResourceEx(font.handle);
- } else {
- RemoveFontResourceExW((LPCWSTR)font.fileName.utf16(), FR_PRIVATE, 0);
- }
- }
- m_applicationFonts.clear();
-}
-
-void QWindowsFontDatabase::releaseHandle(void * /* handle */)
-{
-}
-
-QString QWindowsFontDatabase::fontDir() const
-{
- const QString result = QPlatformFontDatabase::fontDir();
- qCDebug(lcQpaFonts) << __FUNCTION__ << result;
- return result;
-}
-
-bool QWindowsFontDatabase::fontsAlwaysScalable() const
-{
- return true;
-}
-
-void QWindowsFontDatabase::derefUniqueFont(const QString &uniqueFont)
-{
- if (m_uniqueFontData.contains(uniqueFont)) {
- if (!m_uniqueFontData[uniqueFont].refCount.deref()) {
- RemoveFontMemResourceEx(m_uniqueFontData[uniqueFont].handle);
- m_uniqueFontData.remove(uniqueFont);
- }
- }
-}
-
-void QWindowsFontDatabase::refUniqueFont(const QString &uniqueFont)
-{
- if (m_uniqueFontData.contains(uniqueFont))
- m_uniqueFontData[uniqueFont].refCount.ref();
-}
-
-HFONT QWindowsFontDatabase::systemFont()
-{
- static const HFONT stock_sysfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- return stock_sysfont;
-}
-
-// Creation functions
-
-static const char *other_tryFonts[] = {
- "Arial",
- "MS UI Gothic",
- "Gulim",
- "SimSun",
- "PMingLiU",
- "Arial Unicode MS",
- 0
-};
-
-static const char *jp_tryFonts [] = {
- "MS UI Gothic",
- "Arial",
- "Gulim",
- "SimSun",
- "PMingLiU",
- "Arial Unicode MS",
- 0
-};
-
-static const char *ch_CN_tryFonts [] = {
- "SimSun",
- "Arial",
- "PMingLiU",
- "Gulim",
- "MS UI Gothic",
- "Arial Unicode MS",
- 0
-};
-
-static const char *ch_TW_tryFonts [] = {
- "PMingLiU",
- "Arial",
- "SimSun",
- "Gulim",
- "MS UI Gothic",
- "Arial Unicode MS",
- 0
-};
-
-static const char *kr_tryFonts[] = {
- "Gulim",
- "Arial",
- "PMingLiU",
- "SimSun",
- "MS UI Gothic",
- "Arial Unicode MS",
- 0
-};
-
-static const char **tryFonts = 0;
-
-LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request)
-{
- LOGFONT lf;
- memset(&lf, 0, sizeof(LOGFONT));
-
- lf.lfHeight = -qRound(request.pixelSize);
- lf.lfWidth = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- if (request.weight == 50)
- lf.lfWeight = FW_DONTCARE;
- else
- lf.lfWeight = (request.weight*900)/99;
- lf.lfItalic = request.style != QFont::StyleNormal;
- lf.lfCharSet = DEFAULT_CHARSET;
-
- int strat = OUT_DEFAULT_PRECIS;
- if (request.styleStrategy & QFont::PreferBitmap) {
- strat = OUT_RASTER_PRECIS;
-#ifndef Q_OS_WINCE
- } else if (request.styleStrategy & QFont::PreferDevice) {
- strat = OUT_DEVICE_PRECIS;
- } else if (request.styleStrategy & QFont::PreferOutline) {
- strat = OUT_OUTLINE_PRECIS;
- } else if (request.styleStrategy & QFont::ForceOutline) {
- strat = OUT_TT_ONLY_PRECIS;
-#endif
- }
-
- lf.lfOutPrecision = strat;
-
- int qual = DEFAULT_QUALITY;
-
- if (request.styleStrategy & QFont::PreferMatch)
- qual = DRAFT_QUALITY;
-#ifndef Q_OS_WINCE
- else if (request.styleStrategy & QFont::PreferQuality)
- qual = PROOF_QUALITY;
-#endif
-
- if (request.styleStrategy & QFont::PreferAntialias) {
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && !(request.styleStrategy & QFont::NoSubpixelAntialias)) {
- qual = CLEARTYPE_QUALITY;
- } else {
- qual = ANTIALIASED_QUALITY;
- }
- } else if (request.styleStrategy & QFont::NoAntialias) {
- qual = NONANTIALIASED_QUALITY;
- } else if ((request.styleStrategy & QFont::NoSubpixelAntialias) && sharedFontData()->clearTypeEnabled) {
- qual = ANTIALIASED_QUALITY;
- }
-
- lf.lfQuality = qual;
-
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
-
- int hint = FF_DONTCARE;
- switch (request.styleHint) {
- case QFont::Helvetica:
- hint = FF_SWISS;
- break;
- case QFont::Times:
- hint = FF_ROMAN;
- break;
- case QFont::Courier:
- hint = FF_MODERN;
- break;
- case QFont::OldEnglish:
- hint = FF_DECORATIVE;
- break;
- case QFont::System:
- hint = FF_MODERN;
- break;
- default:
- break;
- }
-
- lf.lfPitchAndFamily = DEFAULT_PITCH | hint;
-
- QString fam = request.family;
- if (Q_UNLIKELY(fam.size() >= LF_FACESIZE)) {
- qCritical("%s: Family name '%s' is too long.", __FUNCTION__, qPrintable(fam));
- fam.truncate(LF_FACESIZE - 1);
- }
-
- if (fam.isEmpty())
- fam = QStringLiteral("MS Sans Serif");
-
- if (fam == QLatin1String("MS Sans Serif")
- && (request.style == QFont::StyleItalic || (-lf.lfHeight > 18 && -lf.lfHeight != 24))) {
- fam = QStringLiteral("Arial"); // MS Sans Serif has bearing problems in italic, and does not scale
- }
- if (fam == QLatin1String("Courier") && !(request.styleStrategy & QFont::PreferBitmap))
- fam = QStringLiteral("Courier New");
-
- memcpy(lf.lfFaceName, fam.utf16(), fam.size() * sizeof(wchar_t));
-
- return lf;
-}
-
-QStringList QWindowsFontDatabase::extraTryFontsForFamily(const QString &family)
-{
- QStringList result;
- QFontDatabase db;
- if (!db.writingSystems(family).contains(QFontDatabase::Symbol)) {
- if (!tryFonts) {
- LANGID lid = GetUserDefaultLangID();
- switch (lid&0xff) {
- case LANG_CHINESE: // Chinese
- if ( lid == 0x0804 || lid == 0x1004) // China mainland and Singapore
- tryFonts = ch_CN_tryFonts;
- else
- tryFonts = ch_TW_tryFonts; // Taiwan, Hong Kong and Macau
- break;
- case LANG_JAPANESE:
- tryFonts = jp_tryFonts;
- break;
- case LANG_KOREAN:
- tryFonts = kr_tryFonts;
- break;
- default:
- tryFonts = other_tryFonts;
- break;
- }
- }
- QFontDatabase db;
- const QStringList families = db.families();
- const char **tf = tryFonts;
- while (tf && *tf) {
- // QTBUG-31689, family might be an English alias for a localized font name.
- const QString family = QString::fromLatin1(*tf);
- if (families.contains(family) || db.hasFamily(family))
- result << family;
- ++tf;
- }
- }
- result.append(QStringLiteral("Segoe UI Emoji"));
- result.append(QStringLiteral("Segoe UI Symbol"));
- return result;
-}
-
-QString QWindowsFontDatabase::familyForStyleHint(QFont::StyleHint styleHint)
-{
- switch (styleHint) {
- case QFont::Times:
- return QStringLiteral("Times New Roman");
- case QFont::Courier:
- return QStringLiteral("Courier New");
- case QFont::Monospace:
- return QStringLiteral("Courier New");
- case QFont::Cursive:
- return QStringLiteral("Comic Sans MS");
- case QFont::Fantasy:
- return QStringLiteral("Impact");
- case QFont::Decorative:
- return QStringLiteral("Old English");
- case QFont::Helvetica:
- return QStringLiteral("Arial");
- case QFont::System:
- default:
- break;
- }
- return QStringLiteral("MS Shell Dlg 2");
-}
-
-QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
-{
- QStringList result;
- result.append(QWindowsFontDatabase::familyForStyleHint(styleHint));
- result.append(QWindowsFontDatabase::extraTryFontsForFamily(family));
- result.append(QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script));
-
- qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint
- << script << result;
- return result;
-}
-
-
-QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
- int dpi,
- const QSharedPointer<QWindowsFontEngineData> &data)
-{
- QFontEngine *fe = 0;
-
- LOGFONT lf = fontDefToLOGFONT(request);
- const bool preferClearTypeAA = lf.lfQuality == CLEARTYPE_QUALITY;
-
- if (request.stretch != 100) {
- HFONT hfont = CreateFontIndirect(&lf);
- if (!hfont) {
- qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__);
- hfont = QWindowsFontDatabase::systemFont();
- }
-
- HGDIOBJ oldObj = SelectObject(data->hdc, hfont);
- TEXTMETRIC tm;
- if (!GetTextMetrics(data->hdc, &tm))
- qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__);
- else
- lf.lfWidth = tm.tmAveCharWidth * request.stretch / 100;
- SelectObject(data->hdc, oldObj);
-
- DeleteObject(hfont);
- }
-
-#if !defined(QT_NO_DIRECTWRITE)
- if (initDirectWrite(data.data())) {
- const QString fam = QString::fromWCharArray(lf.lfFaceName);
- const QString nameSubstitute = QWindowsFontEngineDirectWrite::fontNameSubstitute(fam);
- if (nameSubstitute != fam) {
- const int nameSubstituteLength = qMin(nameSubstitute.length(), LF_FACESIZE - 1);
- memcpy(lf.lfFaceName, nameSubstitute.utf16(), nameSubstituteLength * sizeof(wchar_t));
- lf.lfFaceName[nameSubstituteLength] = 0;
- }
-
- HFONT hfont = CreateFontIndirect(&lf);
- if (!hfont) {
- qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__);
- } else {
- HGDIOBJ oldFont = SelectObject(data->hdc, hfont);
-
- IDWriteFontFace *directWriteFontFace = NULL;
- HRESULT hr = data->directWriteGdiInterop->CreateFontFaceFromHdc(data->hdc, &directWriteFontFace);
- if (FAILED(hr)) {
- const QString errorString = qt_error_string(int(hr));
- qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed ("
- << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
- } else {
- bool isColorFont = false;
-#if defined(QT_USE_DIRECTWRITE2)
- IDWriteFontFace2 *directWriteFontFace2 = Q_NULLPTR;
- if (SUCCEEDED(directWriteFontFace->QueryInterface(__uuidof(IDWriteFontFace2),
- reinterpret_cast<void **>(&directWriteFontFace2)))) {
- if (directWriteFontFace2->IsColorFont())
- isColorFont = directWriteFontFace2->GetPaletteEntryCount() > 0;
- }
-#endif
- const QFont::HintingPreference hintingPreference =
- static_cast<QFont::HintingPreference>(request.hintingPreference);
- const bool useDw = useDirectWrite(hintingPreference, isColorFont);
- qCDebug(lcQpaFonts) << __FUNCTION__ << request.family << request.pointSize
- << "pt" << "hintingPreference=" << hintingPreference << "color=" << isColorFont
- << dpi << "dpi" << "useDirectWrite=" << useDw;
- if (useDw) {
- QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
- request.pixelSize,
- data);
-
- wchar_t n[64];
- GetTextFace(data->hdc, 64, n);
-
- QFontDef fontDef = request;
- fontDef.family = QString::fromWCharArray(n);
-
- if (isColorFont)
- fedw->glyphFormat = QFontEngine::Format_ARGB;
- fedw->initFontInfo(fontDef, dpi);
- fe = fedw;
- } else {
- directWriteFontFace->Release();
- }
- }
-
- SelectObject(data->hdc, oldFont);
- DeleteObject(hfont);
- }
- }
-#endif // QT_NO_DIRECTWRITE
-
- if (!fe) {
- QWindowsFontEngine *few = new QWindowsFontEngine(request.family, lf, data);
- if (preferClearTypeAA)
- few->glyphFormat = QFontEngine::Format_A32;
- few->initFontInfo(request, dpi);
- fe = few;
- }
-
- return fe;
-}
-
-static inline int verticalDPI()
-{
- return GetDeviceCaps(QWindowsContext::instance()->displayContext(), LOGPIXELSY);
-}
-
-QFont QWindowsFontDatabase::systemDefaultFont()
-{
- LOGFONT lf;
- GetObject(QWindowsFontDatabase::systemFont(), sizeof(lf), &lf);
- QFont systemFont = QWindowsFontDatabase::LOGFONT_to_QFont(lf);
- // "MS Shell Dlg 2" is the correct system font >= Win2k
- if (systemFont.family() == QLatin1String("MS Shell Dlg"))
- systemFont.setFamily(QStringLiteral("MS Shell Dlg 2"));
- qCDebug(lcQpaFonts) << __FUNCTION__ << systemFont;
- return systemFont;
-}
-
-QFont QWindowsFontDatabase::LOGFONT_to_QFont(const LOGFONT& logFont, int verticalDPI_In)
-{
- if (verticalDPI_In <= 0)
- verticalDPI_In = verticalDPI();
- QFont qFont(QString::fromWCharArray(logFont.lfFaceName));
- qFont.setItalic(logFont.lfItalic);
- if (logFont.lfWeight != FW_DONTCARE)
- qFont.setWeight(QPlatformFontDatabase::weightFromInteger(logFont.lfWeight));
- const qreal logFontHeight = qAbs(logFont.lfHeight);
- qFont.setPointSizeF(logFontHeight * 72.0 / qreal(verticalDPI_In));
- qFont.setUnderline(logFont.lfUnderline);
- qFont.setOverline(false);
- qFont.setStrikeOut(logFont.lfStrikeOut);
- return qFont;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h
deleted file mode 100644
index 574e20ef30..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSFONTDATABASE_H
-#define QWINDOWSFONTDATABASE_H
-
-#include <qpa/qplatformfontdatabase.h>
-#include <QtCore/QSharedPointer>
-#include "qtwindows_additional.h"
-
-#if !defined(QT_NO_DIRECTWRITE)
- struct IDWriteFactory;
- struct IDWriteGdiInterop;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QWindowsFontEngineData
-{
- Q_DISABLE_COPY(QWindowsFontEngineData)
-public:
- QWindowsFontEngineData();
- ~QWindowsFontEngineData();
-
- uint pow_gamma[256];
-
- bool clearTypeEnabled;
- qreal fontSmoothingGamma;
- HDC hdc;
-#if !defined(QT_NO_DIRECTWRITE)
- IDWriteFactory *directWriteFactory;
- IDWriteGdiInterop *directWriteGdiInterop;
-#endif
-};
-
-class QWindowsFontDatabase : public QPlatformFontDatabase
-{
-public:
- QWindowsFontDatabase();
- ~QWindowsFontDatabase();
-
- void populateFontDatabase() Q_DECL_OVERRIDE;
- void populateFamily(const QString &familyName) Q_DECL_OVERRIDE;
- QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE;
- QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
- QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
- QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE;
- QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) Q_DECL_OVERRIDE;
- void releaseHandle(void *handle) Q_DECL_OVERRIDE;
- QString fontDir() const Q_DECL_OVERRIDE;
-
- QFont defaultFont() const Q_DECL_OVERRIDE { return systemDefaultFont(); }
- bool fontsAlwaysScalable() const Q_DECL_OVERRIDE;
- void derefUniqueFont(const QString &uniqueFont);
- void refUniqueFont(const QString &uniqueFont);
-
- static QFont systemDefaultFont();
-
- static QFontEngine *createEngine(const QFontDef &request,
- int dpi,
- const QSharedPointer<QWindowsFontEngineData> &data);
-
- static HFONT systemFont();
- static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0);
-
- static qreal fontSmoothingGamma();
- static LOGFONT fontDefToLOGFONT(const QFontDef &fontDef);
-
- static QStringList extraTryFontsForFamily(const QString &family);
- static QString familyForStyleHint(QFont::StyleHint styleHint);
-
-private:
- void populateFamily(const QString &familyName, bool registerAlias);
- void removeApplicationFonts();
-
- struct WinApplicationFont {
- HANDLE handle;
- QString fileName;
- };
-
- QList<WinApplicationFont> m_applicationFonts;
-
- struct UniqueFontData {
- HANDLE handle;
- QAtomicInt refCount;
- };
-
- QMap<QString, UniqueFontData> m_uniqueFontData;
-};
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug, const QFontDef &def);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSFONTDATABASE_H
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
deleted file mode 100644
index fb75e75dcd..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsfontdatabase_ft.h"
-#include "qwindowsfontdatabase.h"
-#include "qwindowscontext.h"
-
-#include <ft2build.h>
-#include FT_TRUETYPE_TABLES_H
-
-#include <QtCore/QDir>
-#include <QtCore/QDirIterator>
-#include <QtCore/QSettings>
-#include <QtCore/QRegularExpression>
-#include <QtGui/private/qfontengine_ft_p.h>
-#include <QtGui/QGuiApplication>
-#include <QtGui/QFontDatabase>
-
-#include <wchar.h>
-#ifdef Q_OS_WINCE
-#include <QtCore/QFile>
-#include <QtEndian>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet)
-{
- switch (charSet) {
- case ANSI_CHARSET:
- case EASTEUROPE_CHARSET:
- case BALTIC_CHARSET:
- case TURKISH_CHARSET:
- return QFontDatabase::Latin;
- case GREEK_CHARSET:
- return QFontDatabase::Greek;
- case RUSSIAN_CHARSET:
- return QFontDatabase::Cyrillic;
- case HEBREW_CHARSET:
- return QFontDatabase::Hebrew;
- case ARABIC_CHARSET:
- return QFontDatabase::Arabic;
- case THAI_CHARSET:
- return QFontDatabase::Thai;
- case GB2312_CHARSET:
- return QFontDatabase::SimplifiedChinese;
- case CHINESEBIG5_CHARSET:
- return QFontDatabase::TraditionalChinese;
- case SHIFTJIS_CHARSET:
- return QFontDatabase::Japanese;
- case HANGUL_CHARSET:
- case JOHAB_CHARSET:
- return QFontDatabase::Korean;
- case VIETNAMESE_CHARSET:
- return QFontDatabase::Vietnamese;
- case SYMBOL_CHARSET:
- return QFontDatabase::Symbol;
- default:
- break;
- }
- return QFontDatabase::Any;
-}
-
-static FontFile * createFontFile(const QString &fileName, int index)
-{
- FontFile *fontFile = new FontFile;
- fontFile->fileName = fileName;
- fontFile->indexValue = index;
- return fontFile;
-}
-
-extern bool localizedName(const QString &name);
-extern QString getEnglishName(const QString &familyName);
-
-#ifndef Q_OS_WINCE
-
-namespace {
-struct FontKey
-{
- QString fileName;
- QStringList fontNames;
-};
-} // namespace
-
-typedef QVector<FontKey> FontKeys;
-
-static FontKeys &fontKeys()
-{
- static FontKeys result;
- if (result.isEmpty()) {
- const QSettings fontRegistry(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"),
- QSettings::NativeFormat);
- const QStringList allKeys = fontRegistry.allKeys();
- const QString trueType = QStringLiteral("(TrueType)");
- const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
- Q_ASSERT(sizeListMatch.isValid());
- const int size = allKeys.size();
- result.reserve(size);
- for (int i = 0; i < size; ++i) {
- FontKey fontKey;
- const QString &registryFontKey = allKeys.at(i);
- fontKey.fileName = fontRegistry.value(registryFontKey).toString();
- QString realKey = registryFontKey;
- realKey.remove(trueType);
- realKey.remove(sizeListMatch);
- const QStringList fontNames = realKey.trimmed().split(QLatin1Char('&'));
- fontKey.fontNames.reserve(fontNames.size());
- foreach (const QString &fontName, fontNames)
- fontKey.fontNames.append(fontName.trimmed());
- result.append(fontKey);
- }
- }
- return result;
-}
-
-static const FontKey *findFontKey(const QString &name, int *indexIn = Q_NULLPTR)
-{
- const FontKeys &keys = fontKeys();
- for (auto it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) {
- const int index = it->fontNames.indexOf(name);
- if (index >= 0) {
- if (indexIn)
- *indexIn = index;
- return &(*it);
- }
- }
- if (indexIn)
- *indexIn = -1;
- return Q_NULLPTR;
-}
-
-#else // Q_OS_WINCE
-
-typedef struct {
- quint16 majorVersion;
- quint16 minorVersion;
- quint16 numTables;
- quint16 searchRange;
- quint16 entrySelector;
- quint16 rangeShift;
-} OFFSET_TABLE;
-
-typedef struct {
- quint32 tag;
- quint32 checkSum;
- quint32 offset;
- quint32 length;
-} TABLE_DIRECTORY;
-
-typedef struct {
- quint16 fontSelector;
- quint16 nrCount;
- quint16 storageOffset;
-} NAME_TABLE_HEADER;
-
-typedef struct {
- quint16 platformID;
- quint16 encodingID;
- quint16 languageID;
- quint16 nameID;
- quint16 stringLength;
- quint16 stringOffset;
-} NAME_RECORD;
-
-typedef struct {
- quint32 tag;
- quint16 majorVersion;
- quint16 minorVersion;
- quint32 numFonts;
-} TTC_TABLE_HEADER;
-
-static QString fontNameFromTTFile(const QString &filename, int startPos = 0)
-{
- QFile f(filename);
- QString retVal;
- qint64 bytesRead;
- qint64 bytesToRead;
-
- if (f.open(QIODevice::ReadOnly)) {
- f.seek(startPos);
- OFFSET_TABLE ttOffsetTable;
- bytesToRead = sizeof(OFFSET_TABLE);
- bytesRead = f.read((char*)&ttOffsetTable, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttOffsetTable.numTables = qFromBigEndian(ttOffsetTable.numTables);
- ttOffsetTable.majorVersion = qFromBigEndian(ttOffsetTable.majorVersion);
- ttOffsetTable.minorVersion = qFromBigEndian(ttOffsetTable.minorVersion);
-
- if (ttOffsetTable.majorVersion != 1 || ttOffsetTable.minorVersion != 0)
- return retVal;
-
- TABLE_DIRECTORY tblDir;
- bool found = false;
-
- for (int i = 0; i < ttOffsetTable.numTables; i++) {
- bytesToRead = sizeof(TABLE_DIRECTORY);
- bytesRead = f.read((char*)&tblDir, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- if (qFromBigEndian(tblDir.tag) == MAKE_TAG('n', 'a', 'm', 'e')) {
- found = true;
- tblDir.length = qFromBigEndian(tblDir.length);
- tblDir.offset = qFromBigEndian(tblDir.offset);
- break;
- }
- }
-
- if (found) {
- f.seek(tblDir.offset);
- NAME_TABLE_HEADER ttNTHeader;
- bytesToRead = sizeof(NAME_TABLE_HEADER);
- bytesRead = f.read((char*)&ttNTHeader, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttNTHeader.nrCount = qFromBigEndian(ttNTHeader.nrCount);
- ttNTHeader.storageOffset = qFromBigEndian(ttNTHeader.storageOffset);
- NAME_RECORD ttRecord;
- found = false;
-
- for (int i = 0; i < ttNTHeader.nrCount; i++) {
- bytesToRead = sizeof(NAME_RECORD);
- bytesRead = f.read((char*)&ttRecord, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttRecord.nameID = qFromBigEndian(ttRecord.nameID);
- if (ttRecord.nameID == 1) {
- ttRecord.stringLength = qFromBigEndian(ttRecord.stringLength);
- ttRecord.stringOffset = qFromBigEndian(ttRecord.stringOffset);
- int nPos = f.pos();
- f.seek(tblDir.offset + ttRecord.stringOffset + ttNTHeader.storageOffset);
-
- QByteArray nameByteArray = f.read(ttRecord.stringLength);
- if (!nameByteArray.isEmpty()) {
- if (ttRecord.encodingID == 256 || ttRecord.encodingID == 768) {
- //This is UTF-16 in big endian
- int stringLength = ttRecord.stringLength / 2;
- retVal.resize(stringLength);
- QChar *data = retVal.data();
- const ushort *srcData = (const ushort *)nameByteArray.data();
- for (int i = 0; i < stringLength; ++i)
- data[i] = qFromBigEndian(srcData[i]);
- return retVal;
- } else if (ttRecord.encodingID == 0) {
- //This is Latin1
- retVal = QString::fromLatin1(nameByteArray);
- } else {
- qWarning("Could not retrieve Font name from file: %s", qPrintable(QDir::toNativeSeparators(filename)));
- }
- break;
- }
- f.seek(nPos);
- }
- }
- }
- f.close();
- }
- return retVal;
-}
-
-static QStringList fontNamesFromTTCFile(const QString &filename)
-{
- QFile f(filename);
- QStringList retVal;
- qint64 bytesRead;
- qint64 bytesToRead;
-
- if (f.open(QIODevice::ReadOnly)) {
- TTC_TABLE_HEADER ttcTableHeader;
- bytesToRead = sizeof(TTC_TABLE_HEADER);
- bytesRead = f.read((char*)&ttcTableHeader, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttcTableHeader.majorVersion = qFromBigEndian(ttcTableHeader.majorVersion);
- ttcTableHeader.minorVersion = qFromBigEndian(ttcTableHeader.minorVersion);
- ttcTableHeader.numFonts = qFromBigEndian(ttcTableHeader.numFonts);
-
- if (ttcTableHeader.majorVersion < 1 || ttcTableHeader.majorVersion > 2)
- return retVal;
- QVarLengthArray<quint32> offsetTable(ttcTableHeader.numFonts);
- bytesToRead = sizeof(quint32) * ttcTableHeader.numFonts;
- bytesRead = f.read((char*)offsetTable.data(), bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- f.close();
- for (int i = 0; i < (int)ttcTableHeader.numFonts; ++i)
- retVal << fontNameFromTTFile(filename, qFromBigEndian(offsetTable[i]));
- }
- return retVal;
-}
-
-static inline QString fontSettingsOrganization() { return QStringLiteral("Qt-Project"); }
-static inline QString fontSettingsApplication() { return QStringLiteral("Qtbase"); }
-static inline QString fontSettingsGroup() { return QStringLiteral("CEFontCache"); }
-
-static QString findFontFile(const QString &faceName)
-{
- static QHash<QString, QString> fontCache;
-
- if (fontCache.isEmpty()) {
- QSettings settings(QSettings::SystemScope, fontSettingsOrganization(), fontSettingsApplication());
- settings.beginGroup(fontSettingsGroup());
- foreach (const QString &fontName, settings.allKeys())
- fontCache.insert(fontName, settings.value(fontName).toString());
- settings.endGroup();
- }
-
- QString value = fontCache.value(faceName);
-
- //Fallback if we haven't cached the font yet or the font got removed/renamed iterate again over all fonts
- if (value.isEmpty() || !QFile::exists(value)) {
- QSettings settings(QSettings::SystemScope, fontSettingsOrganization(), fontSettingsApplication());
- settings.beginGroup(fontSettingsGroup());
-
- //empty the cache first, as it seems that it is dirty
- settings.remove(QString());
-
- QDirIterator it(QStringLiteral("/Windows"), QStringList() << QStringLiteral("*.ttf") << QStringLiteral("*.ttc"), QDir::Files | QDir::Hidden | QDir::System);
- const QLatin1Char lowerF('f');
- const QLatin1Char upperF('F');
- while (it.hasNext()) {
- const QString fontFile = it.next();
- QStringList fontNames;
- const QChar c = fontFile[fontFile.size() - 1];
- if (c == lowerF || c == upperF)
- fontNames << fontNameFromTTFile(fontFile);
- else
- fontNames << fontNamesFromTTCFile(fontFile);
- foreach (const QString fontName, fontNames) {
- if (fontName.isEmpty())
- continue;
- fontCache.insert(fontName, fontFile);
- settings.setValue(fontName, fontFile);
-
- if (localizedName(fontName)) {
- QString englishFontName = getEnglishName(fontName);
- fontCache.insert(englishFontName, fontFile);
- settings.setValue(englishFontName, fontFile);
- }
- }
- }
- settings.endGroup();
- value = fontCache.value(faceName);
- }
- return value;
-}
-#endif // Q_OS_WINCE
-
-static bool addFontToDatabase(const QString &faceName,
- const QString &fullName,
- uchar charSet,
- const TEXTMETRIC *textmetric,
- const FONTSIGNATURE *signature,
- int type,
- bool registerAlias)
-{
- // the "@family" fonts are just the same as "family". Ignore them.
- if (faceName.isEmpty() || faceName.at(0) == QLatin1Char('@') || faceName.startsWith(QLatin1String("WST_")))
- return false;
-
- static const int SMOOTH_SCALABLE = 0xffff;
- const QString foundryName; // No such concept.
- const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
- const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
- const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
- const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
- const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
- const bool antialias = false;
- const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(textmetric->tmWeight);
- const QFont::Stretch stretch = QFont::Unstretched;
-
-#ifndef QT_NO_DEBUG_STREAM
- if (QWindowsContext::verbose > 2) {
- QString message;
- QTextStream str(&message);
- str << __FUNCTION__ << ' ' << faceName << "::" << fullName << ' ' << charSet << " TTF=" << ttf;
- if (type & DEVICE_FONTTYPE)
- str << " DEVICE";
- if (type & RASTER_FONTTYPE)
- str << " RASTER";
- if (type & TRUETYPE_FONTTYPE)
- str << " TRUETYPE";
- str << " scalable=" << scalable << " Size=" << size
- << " Style=" << style << " Weight=" << weight
- << " stretch=" << stretch;
- qCDebug(lcQpaFonts) << message;
- }
-#endif
-
- QString englishName;
- if (registerAlias & ttf && localizedName(faceName))
- englishName = getEnglishName(faceName);
-
- QSupportedWritingSystems writingSystems;
- if (type & TRUETYPE_FONTTYPE) {
- Q_ASSERT(signature);
- quint32 unicodeRange[4] = {
- signature->fsUsb[0], signature->fsUsb[1],
- signature->fsUsb[2], signature->fsUsb[3]
- };
- quint32 codePageRange[2] = {
- signature->fsCsb[0], signature->fsCsb[1]
- };
- writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
- // ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains
- // the symbol for Baht, and Windows thus reports that it supports the Thai script.
- // Since it's the default UI font on this platform, most widgets will be unable to
- // display Thai text by default. As a temporary work around, we special case Segoe UI
- // and remove the Thai script from its list of supported writing systems.
- if (writingSystems.supported(QFontDatabase::Thai) &&
- faceName == QLatin1String("Segoe UI"))
- writingSystems.setSupported(QFontDatabase::Thai, false);
- } else {
- const QFontDatabase::WritingSystem ws = writingSystemFromCharSet(charSet);
- if (ws != QFontDatabase::Any)
- writingSystems.setSupported(ws);
- }
-
- int index = 0;
-#ifndef Q_OS_WINCE
- const FontKey *key = findFontKey(faceName, &index);
- if (!key) {
- key = findFontKey(fullName, &index);
- if (!key && !registerAlias && englishName.isEmpty() && localizedName(faceName))
- englishName = getEnglishName(faceName);
- if (!key && !englishName.isEmpty())
- key = findFontKey(englishName, &index);
- if (!key)
- return false;
- }
- QString value = key->fileName;
-#else
- QString value = findFontFile(faceName);
-#endif
-
- if (value.isEmpty())
- return false;
-
- if (!QDir::isAbsolutePath(value))
-#ifndef Q_OS_WINCE
- value.prepend(QFile::decodeName(qgetenv("windir") + "\\Fonts\\"));
-#else
- value.prepend(QFile::decodeName("/Windows/"));
-#endif
-
- QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, weight, style, stretch,
- antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
-
- // add fonts windows can generate for us:
- if (weight <= QFont::DemiBold)
- QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, QFont::Bold, style, stretch,
- antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
-
- if (style != QFont::StyleItalic)
- QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, weight, QFont::StyleItalic, stretch,
- antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
-
- if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
- QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, QFont::Bold, QFont::StyleItalic, stretch,
- antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
-
- if (!englishName.isEmpty())
- QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName);
-
- return true;
-}
-
-#ifdef Q_OS_WINCE
-static QByteArray getFntTable(HFONT hfont, uint tag)
-{
- HDC hdc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(hdc, hfont);
- quint32 t = qFromBigEndian<quint32>(tag);
- QByteArray buffer;
-
- DWORD length = GetFontData(hdc, t, 0, NULL, 0);
- if (length != GDI_ERROR) {
- buffer.resize(length);
- GetFontData(hdc, t, 0, reinterpret_cast<uchar *>(buffer.data()), length);
- }
- SelectObject(hdc, oldFont);
- return buffer;
-}
-#endif
-
-static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
- DWORD type, LPARAM)
-{
- const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
- const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
- const QString fullName = QString::fromWCharArray(f->elfFullName);
- const uchar charSet = f->elfLogFont.lfCharSet;
-
- // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
- // to the documentation is identical to a TEXTMETRIC except for the last four
- // members, which we don't use anyway
- const FONTSIGNATURE *signature = Q_NULLPTR;
- if (type & TRUETYPE_FONTTYPE)
- signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
- addFontToDatabase(faceName, fullName, charSet, textmetric, signature, type, false);
-
- // keep on enumerating
- return 1;
-}
-
-/*!
- \brief Populate font database using EnumFontFamiliesEx().
-
- Normally, leaving the name empty should enumerate
- all fonts, however, system fonts like "MS Shell Dlg 2"
- are only found when specifying the name explicitly.
-*/
-
-void QWindowsFontDatabaseFT::populateFamily(const QString &familyName)
-{
- qCDebug(lcQpaFonts) << familyName;
- if (familyName.size() >= LF_FACESIZE) {
- qCWarning(lcQpaFonts) << "Unable to enumerate family '" << familyName << '\'';
- return;
- }
- HDC dummy = GetDC(0);
- LOGFONT lf;
- lf.lfCharSet = DEFAULT_CHARSET;
- familyName.toWCharArray(lf.lfFaceName);
- lf.lfFaceName[familyName.size()] = 0;
- lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0);
- ReleaseDC(0, dummy);
-}
-
-namespace {
-// Context for enumerating system fonts, records whether the default font has been
-// encountered, which is normally not enumerated.
-struct PopulateFamiliesContext
-{
- PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {}
-
- QString systemDefaultFont;
- bool seenSystemDefaultFont;
-};
-} // namespace
-
-#ifndef Q_OS_WINCE
-
-// Delayed population of font families
-
-static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
- DWORD, LPARAM lparam)
-{
- const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
- // the "@family" fonts are just the same as "family". Ignore them.
- const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
- if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
- // Register only font families for which a font file exists for delayed population
- const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
- const QString faceName = QString::fromWCharArray(faceNameW);
- const FontKey *key = findFontKey(faceName);
- if (!key) {
- key = findFontKey(QString::fromWCharArray(f->elfFullName));
- if (!key && ttf && localizedName(faceName))
- key = findFontKey(getEnglishName(faceName));
- }
- if (key) {
- QPlatformFontDatabase::registerFontFamily(faceName);
- PopulateFamiliesContext *context = reinterpret_cast<PopulateFamiliesContext *>(lparam);
- if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont)
- context->seenSystemDefaultFont = true;
-
- // Register current font's english name as alias
- if (ttf && localizedName(faceName)) {
- const QString englishName = getEnglishName(faceName);
- if (!englishName.isEmpty()) {
- QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName);
- // Check whether the system default font name is an alias of the current font family name,
- // as on Chinese Windows, where the system font "SimSun" is an alias to a font registered under a local name
- if (!context->seenSystemDefaultFont && englishName == context->systemDefaultFont)
- context->seenSystemDefaultFont = true;
- }
- }
- }
- }
- return 1; // continue
-}
-
-void QWindowsFontDatabaseFT::populateFontDatabase()
-{
- HDC dummy = GetDC(0);
- LOGFONT lf;
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfFaceName[0] = 0;
- lf.lfPitchAndFamily = 0;
- PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
- ReleaseDC(0, dummy);
- // Work around EnumFontFamiliesEx() not listing the system font
- if (!context.seenSystemDefaultFont)
- QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont);
-}
-
-#else // !Q_OS_WINCE
-
-// Non-delayed population of fonts (Windows CE).
-
-static int QT_WIN_CALLBACK populateFontCe(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
- int type, LPARAM lparam)
-{
- // the "@family" fonts are just the same as "family". Ignore them.
- const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
- if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
- const uchar charSet = f->elfLogFont.lfCharSet;
-
- FONTSIGNATURE signature;
- QByteArray table;
-
- if (type & TRUETYPE_FONTTYPE) {
- HFONT hfont = CreateFontIndirect(&f->elfLogFont);
- table = getFntTable(hfont, MAKE_TAG('O', 'S', '/', '2'));
- DeleteObject((HGDIOBJ)hfont);
- }
-
- if (table.length() >= 86) {
- // See also qfontdatabase_mac.cpp, offsets taken from OS/2 table in the TrueType spec
- uchar *tableData = reinterpret_cast<uchar *>(table.data());
-
- signature.fsUsb[0] = qFromBigEndian<quint32>(tableData + 42);
- signature.fsUsb[1] = qFromBigEndian<quint32>(tableData + 46);
- signature.fsUsb[2] = qFromBigEndian<quint32>(tableData + 50);
- signature.fsUsb[3] = qFromBigEndian<quint32>(tableData + 54);
-
- signature.fsCsb[0] = qFromBigEndian<quint32>(tableData + 78);
- signature.fsCsb[1] = qFromBigEndian<quint32>(tableData + 82);
- } else {
- memset(&signature, 0, sizeof(signature));
- }
-
- // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
- // identical to a TEXTMETRIC except for the last four members, which we don't use
- // anyway
- const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
- if (addFontToDatabase(faceName, QString::fromWCharArray(f->elfFullName),
- charSet, (TEXTMETRIC *)textmetric, &signature, type, true)) {
- PopulateFamiliesContext *context = reinterpret_cast<PopulateFamiliesContext *>(lparam);
- if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont)
- context->seenSystemDefaultFont = true;
- }
- }
-
- // keep on enumerating
- return 1;
-}
-
-void QWindowsFontDatabaseFT::populateFontDatabase()
-{
- LOGFONT lf;
- lf.lfCharSet = DEFAULT_CHARSET;
- HDC dummy = GetDC(0);
- lf.lfFaceName[0] = 0;
- lf.lfPitchAndFamily = 0;
- PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontCe, reinterpret_cast<LPARAM>(&context), 0);
- ReleaseDC(0, dummy);
- // Work around EnumFontFamiliesEx() not listing the system font, see below.
- if (!context.seenSystemDefaultFont)
- populateFamily(context.systemDefaultFont);
-}
-#endif // Q_OS_WINCE
-
-QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle)
-{
- QFontEngine *fe = QBasicFontDatabase::fontEngine(fontDef, handle);
- qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef.family << fe << handle;
- return fe;
-}
-
-QFontEngine *QWindowsFontDatabaseFT::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
-{
- QFontEngine *fe = QBasicFontDatabase::fontEngine(fontData, pixelSize, hintingPreference);
- qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDATA" << fontData << pixelSize << hintingPreference << fe;
- return fe;
-}
-
-QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
-{
- QStringList result;
-
- result.append(QWindowsFontDatabase::familyForStyleHint(styleHint));
-
-#ifdef Q_OS_WINCE
- QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\FontLink\\SystemLink"), QSettings::NativeFormat);
- const QStringList fontList = settings.value(family).toStringList();
- foreach (const QString &fallback, fontList) {
- const int sep = fallback.indexOf(QLatin1Char(','));
- if (sep > 0)
- result << fallback.mid(sep + 1);
- }
-#endif
-
- result.append(QWindowsFontDatabase::extraTryFontsForFamily(family));
-
- result.append(QBasicFontDatabase::fallbacksForFamily(family, style, styleHint, script));
-
- qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint
- << script << result;
-
- return result;
-}
-QString QWindowsFontDatabaseFT::fontDir() const
-{
- const QString result = QLatin1String(qgetenv("windir")) + QLatin1String("/Fonts");//QPlatformFontDatabase::fontDir();
- qCDebug(lcQpaFonts) << __FUNCTION__ << result;
- return result;
-}
-
-QFont QWindowsFontDatabaseFT::defaultFont() const
-{
- return QWindowsFontDatabase::systemDefaultFont();
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h
deleted file mode 100644
index 988b0012f7..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSFONTDATABASEFT_H
-#define QWINDOWSFONTDATABASEFT_H
-
-#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
-#include <QtCore/QSharedPointer>
-#include "qtwindows_additional.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWindowsFontDatabaseFT : public QBasicFontDatabase
-{
-public:
- void populateFontDatabase() Q_DECL_OVERRIDE;
- void populateFamily(const QString &familyName) Q_DECL_OVERRIDE;
- QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
- QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize,
- QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
-
- QStringList fallbacksForFamily(const QString &family, QFont::Style style,
- QFont::StyleHint styleHint,
- QChar::Script script) const Q_DECL_OVERRIDE;
-
- QString fontDir() const Q_DECL_OVERRIDE;
- QFont defaultFont() const Q_DECL_OVERRIDE;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSFONTDATABASEFT_H
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
deleted file mode 100644
index 4f3df32f16..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ /dev/null
@@ -1,1381 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsintegration.h"
-#include "qwindowsfontengine.h"
-#include "qwindowsnativeimage.h"
-#include "qwindowscontext.h"
-#include "qwindowsfontdatabase.h"
-#include "qtwindows_additional.h"
-#include "qwindowsfontenginedirectwrite.h"
-
-#include <QtGui/private/qtextengine_p.h> // glyph_metrics_t
-#include <QtGui/private/qguiapplication_p.h>
-#include <QtGui/QPaintDevice>
-#include <QtGui/QBitmap>
-#include <QtGui/QPainter>
-#include <QtGui/private/qpainter_p.h>
-#include <QtGui/QPaintEngine>
-#include <QtGui/private/qpaintengine_raster_p.h>
-
-#include <QtCore/QtEndian>
-#include <QtCore/QFile>
-#include <QtCore/qmath.h>
-#include <QtCore/QThreadStorage>
-#include <QtCore/private/qsystemlibrary_p.h>
-#include <QtCore/private/qstringiterator_p.h>
-
-#include <QtCore/QDebug>
-
-#include <limits.h>
-
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
-
-#if !defined(QT_NO_DIRECTWRITE)
-# include <dwrite.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-//### mingw needed define
-#ifndef TT_PRIM_CSPLINE
-#define TT_PRIM_CSPLINE 3
-#endif
-
-// GetFontData expects the tags in little endian ;(
-#define MAKE_LITTLE_ENDIAN_TAG(ch1, ch2, ch3, ch4) (\
- (((quint32)(ch4)) << 24) | \
- (((quint32)(ch3)) << 16) | \
- (((quint32)(ch2)) << 8) | \
- ((quint32)(ch1)) \
- )
-
-// common DC for all fonts
-
-typedef BOOL (WINAPI *PtrGetCharWidthI)(HDC, UINT, UINT, LPWORD, LPINT);
-static PtrGetCharWidthI ptrGetCharWidthI = 0;
-static bool resolvedGetCharWidthI = false;
-
-static void resolveGetCharWidthI()
-{
- if (resolvedGetCharWidthI)
- return;
- resolvedGetCharWidthI = true;
- ptrGetCharWidthI = (PtrGetCharWidthI)QSystemLibrary::resolve(QStringLiteral("gdi32"), "GetCharWidthI");
-}
-
-static inline quint16 getUShort(unsigned char *p)
-{
- quint16 val;
- val = *p++ << 8;
- val |= *p;
-
- return val;
-}
-
-// general font engine
-
-QFixed QWindowsFontEngine::lineThickness() const
-{
- if(lineWidth > 0)
- return lineWidth;
-
- return QFontEngine::lineThickness();
-}
-
-static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc)
-{
- int size;
- size = GetOutlineTextMetrics(hdc, 0, 0);
- OUTLINETEXTMETRIC *otm = (OUTLINETEXTMETRIC *)malloc(size);
- GetOutlineTextMetrics(hdc, size, otm);
- return otm;
-}
-
-bool QWindowsFontEngine::hasCFFTable() const
-{
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR;
-}
-
-bool QWindowsFontEngine::hasCMapTable() const
-{
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR;
-}
-
-bool QWindowsFontEngine::hasGlyfTable() const
-{
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR;
-}
-
-bool QWindowsFontEngine::hasEbdtTable() const
-{
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR;
-}
-
-static inline QString stringFromOutLineTextMetric(const OUTLINETEXTMETRIC *otm, PSTR offset)
-{
- const uchar *p = reinterpret_cast<const uchar *>(otm) + quintptr(offset);
- return QString::fromWCharArray(reinterpret_cast<const wchar_t *>(p));
-}
-
-void QWindowsFontEngine::getCMap()
-{
- ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
-
- cffTable = hasCFFTable();
-
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- bool symb = false;
- if (ttf) {
- cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p'));
- cmap = QFontEngine::getCMap(reinterpret_cast<const uchar *>(cmapTable.constData()),
- cmapTable.size(), &symb, &cmapSize);
- }
- if (!cmap) {
- ttf = false;
- symb = false;
- }
- symbol = symb;
- designToDevice = 1;
- _faceId.index = 0;
- if(cmap) {
- OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc);
- unitsPerEm = int(otm->otmEMSquare);
- const QFixed unitsPerEmF(unitsPerEm);
- designToDevice = unitsPerEmF / QFixed::fromReal(fontDef.pixelSize);
- x_height = int(otm->otmsXHeight);
- loadKerningPairs(designToDevice);
- _faceId.filename = QFile::encodeName(stringFromOutLineTextMetric(otm, otm->otmpFullName));
- lineWidth = otm->otmsUnderscoreSize;
- fsType = otm->otmfsType;
- free(otm);
- } else {
- unitsPerEm = tm.tmHeight;
- }
-}
-
-int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout *glyphs) const
-{
- int glyph_pos = 0;
- {
-#if defined(Q_OS_WINCE)
- {
-#else
- if (symbol) {
- QStringIterator it(str, str + numChars);
- while (it.hasNext()) {
- const uint uc = it.next();
- glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc);
- if(!glyphs->glyphs[glyph_pos] && uc < 0x100)
- glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000);
- ++glyph_pos;
- }
- } else if (ttf) {
- QStringIterator it(str, str + numChars);
- while (it.hasNext()) {
- const uint uc = it.next();
- glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc);
- ++glyph_pos;
- }
- } else {
-#endif
- QStringIterator it(str, str + numChars);
- while (it.hasNext()) {
- const uint uc = it.next();
- if (uc >= tm.tmFirstChar && uc <= tm.tmLastChar)
- glyphs->glyphs[glyph_pos] = uc;
- else
- glyphs->glyphs[glyph_pos] = 0;
- ++glyph_pos;
- }
- }
- }
- glyphs->numGlyphs = glyph_pos;
- return glyph_pos;
-}
-
-/*!
- \class QWindowsFontEngine
- \brief Standard Windows font engine.
- \internal
- \ingroup qt-lighthouse-win
-
- Will probably be superseded by a common Free Type font engine in Qt 5.X.
-*/
-
-QWindowsFontEngine::QWindowsFontEngine(const QString &name,
- LOGFONT lf,
- const QSharedPointer<QWindowsFontEngineData> &fontEngineData)
- : QFontEngine(Win),
- m_fontEngineData(fontEngineData),
- _name(name),
- hfont(0),
- m_logfont(lf),
- ttf(0),
- hasOutline(0),
- cmap(0),
- cmapSize(0),
- lbearing(SHRT_MIN),
- rbearing(SHRT_MIN),
- x_height(-1),
- synthesized_flags(-1),
- lineWidth(-1),
- widthCache(0),
- widthCacheSize(0),
- designAdvances(0),
- designAdvancesSize(0)
-{
- qCDebug(lcQpaFonts) << __FUNCTION__ << name << lf.lfHeight;
- hfont = CreateFontIndirect(&m_logfont);
- if (!hfont) {
- qErrnoWarning("%s: CreateFontIndirect failed for family '%s'", __FUNCTION__, qPrintable(name));
- hfont = QWindowsFontDatabase::systemFont();
- }
-
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- const BOOL res = GetTextMetrics(hdc, &tm);
- if (!res) {
- qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__);
- ZeroMemory(&tm, sizeof(TEXTMETRIC));
- }
-
- fontDef.pixelSize = -lf.lfHeight;
- fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
-
- cache_cost = tm.tmHeight * tm.tmAveCharWidth * 2000;
- getCMap();
-
- if (!resolvedGetCharWidthI)
- resolveGetCharWidthI();
-
- // ### Properties accessed by QWin32PrintEngine (QtPrintSupport)
- QVariantMap userData;
- userData.insert(QStringLiteral("logFont"), QVariant::fromValue(m_logfont));
- userData.insert(QStringLiteral("hFont"), QVariant::fromValue(hfont));
- userData.insert(QStringLiteral("trueType"), QVariant(bool(ttf)));
- setUserData(userData);
-
- hasUnreliableOutline = hasGlyfTable() && hasEbdtTable();
-}
-
-QWindowsFontEngine::~QWindowsFontEngine()
-{
- if (designAdvances)
- free(designAdvances);
-
- if (widthCache)
- free(widthCache);
-
- // make sure we aren't by accident still selected
- SelectObject(m_fontEngineData->hdc, QWindowsFontDatabase::systemFont());
-
- if (!DeleteObject(hfont))
- qErrnoWarning("%s: QFontEngineWin: failed to delete font...", __FUNCTION__);
- qCDebug(lcQpaFonts) << __FUNCTION__ << _name;
-
- if (!uniqueFamilyName.isEmpty()) {
- QPlatformFontDatabase *pfdb = QWindowsIntegration::instance()->fontDatabase();
- static_cast<QWindowsFontDatabase *>(pfdb)->derefUniqueFont(uniqueFamilyName);
- }
-}
-
-glyph_t QWindowsFontEngine::glyphIndex(uint ucs4) const
-{
- glyph_t glyph;
-
-#if !defined(Q_OS_WINCE)
- if (symbol) {
- glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4);
- if (glyph == 0 && ucs4 < 0x100)
- glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4 + 0xf000);
- } else if (ttf) {
- glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4);
- } else
-#endif
- if (ucs4 >= tm.tmFirstChar && ucs4 <= tm.tmLastChar) {
- glyph = ucs4;
- } else {
- glyph = 0;
- }
-
- return glyph;
-}
-
-HGDIOBJ QWindowsFontEngine::selectDesignFont() const
-{
- LOGFONT f = m_logfont;
- f.lfHeight = -unitsPerEm;
- f.lfWidth = 0;
- HFONT designFont = CreateFontIndirect(&f);
- return SelectObject(m_fontEngineData->hdc, designFont);
-}
-
-bool QWindowsFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const
-{
- Q_ASSERT(glyphs->numGlyphs >= *nglyphs);
- if (*nglyphs < len) {
- *nglyphs = len;
- return false;
- }
-
- glyphs->numGlyphs = *nglyphs;
- *nglyphs = getGlyphIndexes(str, len, glyphs);
-
- if (!(flags & GlyphIndicesOnly))
- recalcAdvances(glyphs, flags);
-
- return true;
-}
-
-inline void calculateTTFGlyphWidth(HDC hdc, UINT glyph, int &width)
-{
-#if defined(Q_OS_WINCE)
- GetCharWidth32(hdc, glyph, glyph, &width);
-#else
- if (ptrGetCharWidthI)
- ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
-#endif
-}
-
-void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
-{
- HGDIOBJ oldFont = 0;
- HDC hdc = m_fontEngineData->hdc;
- if (ttf && (flags & DesignMetrics)) {
- for(int i = 0; i < glyphs->numGlyphs; i++) {
- unsigned int glyph = glyphs->glyphs[i];
- if(int(glyph) >= designAdvancesSize) {
- const int newSize = int(glyph + 256) >> 8 << 8;
- designAdvances = reinterpret_cast<QFixed *>(realloc(designAdvances, size_t(newSize) * sizeof(QFixed)));
- Q_CHECK_PTR(designAdvances);
- for(int i = designAdvancesSize; i < newSize; ++i)
- designAdvances[i] = -1000000;
- designAdvancesSize = newSize;
- }
- if (designAdvances[glyph] < -999999) {
- if (!oldFont)
- oldFont = selectDesignFont();
-
- int width = 0;
- calculateTTFGlyphWidth(hdc, glyph, width);
- designAdvances[glyph] = QFixed(width) / designToDevice;
- }
- glyphs->advances[i] = designAdvances[glyph];
- }
- if(oldFont)
- DeleteObject(SelectObject(hdc, oldFont));
- } else {
- for(int i = 0; i < glyphs->numGlyphs; i++) {
- unsigned int glyph = glyphs->glyphs[i];
-
- if (glyph >= widthCacheSize) {
- const uint newSize = (glyph + 256) >> 8 << 8;
- widthCache = reinterpret_cast<unsigned char *>(realloc(widthCache, newSize * sizeof(QFixed)));
- Q_CHECK_PTR(widthCache);
- memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
- widthCacheSize = newSize;
- }
- glyphs->advances[i] = widthCache[glyph];
- // font-width cache failed
- if (glyphs->advances[i].value() == 0) {
- int width = 0;
- if (!oldFont)
- oldFont = SelectObject(hdc, hfont);
-
- if (!ttf) {
- QChar ch[2] = { ushort(glyph), 0 };
- int chrLen = 1;
- if (QChar::requiresSurrogates(glyph)) {
- ch[0] = QChar::highSurrogate(glyph);
- ch[1] = QChar::lowSurrogate(glyph);
- ++chrLen;
- }
- SIZE size = {0, 0};
- GetTextExtentPoint32(hdc, reinterpret_cast<const wchar_t *>(ch), chrLen, &size);
- width = size.cx;
- } else {
- calculateTTFGlyphWidth(hdc, glyph, width);
- }
- glyphs->advances[i] = width;
- // if glyph's within cache range, store it for later
- if (width > 0 && width < 0x100)
- widthCache[glyph] = uchar(width);
- }
- }
-
- if (oldFont)
- SelectObject(hdc, oldFont);
- }
-}
-
-glyph_metrics_t QWindowsFontEngine::boundingBox(const QGlyphLayout &glyphs)
-{
- if (glyphs.numGlyphs == 0)
- return glyph_metrics_t();
-
- QFixed w = 0;
- for (int i = 0; i < glyphs.numGlyphs; ++i)
- w += glyphs.effectiveAdvance(i);
-
- return glyph_metrics_t(0, -tm.tmAscent, w - lastRightBearing(glyphs), tm.tmHeight, w, 0);
-}
-#ifndef Q_OS_WINCE
-bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const
-{
- Q_ASSERT(metrics != 0);
-
- HDC hdc = m_fontEngineData->hdc;
-
- GLYPHMETRICS gm;
- DWORD res = 0;
- MAT2 mat;
- mat.eM11.value = mat.eM22.value = 1;
- mat.eM11.fract = mat.eM22.fract = 0;
- mat.eM21.value = mat.eM12.value = 0;
- mat.eM21.fract = mat.eM12.fract = 0;
-
- if (t.type() > QTransform::TxTranslate) {
- // We need to set the transform using the HDC's world
- // matrix rather than using the MAT2 above, because the
- // results provided when transforming via MAT2 does not
- // match the glyphs that are drawn using a WorldTransform
- XFORM xform;
- xform.eM11 = FLOAT(t.m11());
- xform.eM12 = FLOAT(t.m12());
- xform.eM21 = FLOAT(t.m21());
- xform.eM22 = FLOAT(t.m22());
- xform.eDx = 0;
- xform.eDy = 0;
- SetGraphicsMode(hdc, GM_ADVANCED);
- SetWorldTransform(hdc, &xform);
- }
-
- uint format = GGO_METRICS;
- if (ttf)
- format |= GGO_GLYPH_INDEX;
- res = GetGlyphOutline(hdc, glyph, format, &gm, 0, 0, &mat);
-
- if (t.type() > QTransform::TxTranslate) {
- XFORM xform;
- xform.eM11 = xform.eM22 = 1;
- xform.eM12 = xform.eM21 = xform.eDx = xform.eDy = 0;
- SetWorldTransform(hdc, &xform);
- SetGraphicsMode(hdc, GM_COMPATIBLE);
- }
-
- if (res != GDI_ERROR) {
- *metrics = glyph_metrics_t(gm.gmptGlyphOrigin.x, -gm.gmptGlyphOrigin.y,
- int(gm.gmBlackBoxX), int(gm.gmBlackBoxY),
- gm.gmCellIncX, gm.gmCellIncY);
- return true;
- } else {
- return false;
- }
-}
-#endif
-
-glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform &t)
-{
-#ifndef Q_OS_WINCE
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
-
- glyph_metrics_t glyphMetrics;
- bool success = getOutlineMetrics(glyph, t, &glyphMetrics);
-
- if (!ttf && !success) {
- // Bitmap fonts
- wchar_t ch = wchar_t(glyph);
- ABCFLOAT abc;
- GetCharABCWidthsFloat(hdc, ch, ch, &abc);
- int width = qRound(abc.abcfB);
-
- return glyph_metrics_t(QFixed::fromReal(abc.abcfA), -tm.tmAscent, width, tm.tmHeight, width, 0).transformed(t);
- }
-
- return glyphMetrics;
-#else
- HDC hdc = m_fontEngineData->hdc;
- HGDIOBJ oldFont = SelectObject(hdc, hfont);
-
- ABC abc;
- int width;
- int advance;
-#ifdef GWES_MGTT // true type fonts
- if (GetCharABCWidths(hdc, glyph, glyph, &abc)) {
- width = qAbs(abc.abcA) + abc.abcB + qAbs(abc.abcC);
- advance = abc.abcA + abc.abcB + abc.abcC;
- }
- else
-#endif
-#if defined(GWES_MGRAST) || defined(GWES_MGRAST2) // raster fonts
- if (GetCharWidth32(hdc, glyph, glyph, &width)) {
- advance = width;
- }
- else
-#endif
- { // fallback
- width = tm.tmMaxCharWidth;
- advance = width;
- }
-
- SelectObject(hdc, oldFont);
- return glyph_metrics_t(0, -tm.tmAscent, width, tm.tmHeight, advance, 0).transformed(t);
-#endif
-}
-
-QFixed QWindowsFontEngine::ascent() const
-{
- return tm.tmAscent;
-}
-
-QFixed QWindowsFontEngine::descent() const
-{
- return tm.tmDescent;
-}
-
-QFixed QWindowsFontEngine::leading() const
-{
- return tm.tmExternalLeading;
-}
-
-
-QFixed QWindowsFontEngine::xHeight() const
-{
- if(x_height >= 0)
- return x_height;
- return QFontEngine::xHeight();
-}
-
-QFixed QWindowsFontEngine::averageCharWidth() const
-{
- return tm.tmAveCharWidth;
-}
-
-qreal QWindowsFontEngine::maxCharWidth() const
-{
- return tm.tmMaxCharWidth;
-}
-
-enum { max_font_count = 256 };
-static const ushort char_table[] = {
- 40,
- 67,
- 70,
- 75,
- 86,
- 88,
- 89,
- 91,
- 102,
- 114,
- 124,
- 127,
- 205,
- 645,
- 884,
- 922,
- 1070,
- 12386,
- 0
-};
-
-static const int char_table_entries = sizeof(char_table)/sizeof(ushort);
-
-#ifndef Q_CC_MINGW
-void QWindowsFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
-{
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
-
-#ifndef Q_OS_WINCE
- if (ttf)
-#endif
- {
- ABC abcWidths;
- GetCharABCWidthsI(hdc, glyph, 1, 0, &abcWidths);
- if (leftBearing)
- *leftBearing = abcWidths.abcA;
- if (rightBearing)
- *rightBearing = abcWidths.abcC;
- }
-#ifndef Q_OS_WINCE
- else {
- QFontEngine::getGlyphBearings(glyph, leftBearing, rightBearing);
- }
-#endif
-}
-#endif // Q_CC_MINGW
-
-bool QWindowsFontEngine::hasUnreliableGlyphOutline() const
-{
- return hasUnreliableOutline || QFontEngine::hasUnreliableGlyphOutline();
-}
-
-qreal QWindowsFontEngine::minLeftBearing() const
-{
- if (lbearing == SHRT_MIN)
- minRightBearing(); // calculates both
-
- return lbearing;
-}
-
-qreal QWindowsFontEngine::minRightBearing() const
-{
-#ifndef Q_OS_WINCE
- if (rbearing == SHRT_MIN) {
- int ml = 0;
- int mr = 0;
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- if (ttf) {
- ABC *abc = 0;
- int n = tm.tmLastChar - tm.tmFirstChar;
- if (n <= max_font_count) {
- abc = new ABC[n+1];
- GetCharABCWidths(hdc, tm.tmFirstChar, tm.tmLastChar, abc);
- } else {
- abc = new ABC[char_table_entries+1];
- for(int i = 0; i < char_table_entries; i++)
- GetCharABCWidths(hdc, char_table[i], char_table[i], abc + i);
- n = char_table_entries;
- }
- ml = abc[0].abcA;
- mr = abc[0].abcC;
- for (int i = 1; i < n; i++) {
- if (abc[i].abcA + abc[i].abcB + abc[i].abcC != 0) {
- ml = qMin(ml,abc[i].abcA);
- mr = qMin(mr,abc[i].abcC);
- }
- }
- delete [] abc;
- } else {
- ABCFLOAT *abc = 0;
- int n = tm.tmLastChar - tm.tmFirstChar+1;
- if (n <= max_font_count) {
- abc = new ABCFLOAT[n];
- GetCharABCWidthsFloat(hdc, tm.tmFirstChar, tm.tmLastChar, abc);
- } else {
- abc = new ABCFLOAT[char_table_entries];
- for(int i = 0; i < char_table_entries; i++)
- GetCharABCWidthsFloat(hdc, char_table[i], char_table[i], abc+i);
- n = char_table_entries;
- }
- float fml = abc[0].abcfA;
- float fmr = abc[0].abcfC;
- for (int i=1; i<n; i++) {
- if (abc[i].abcfA + abc[i].abcfB + abc[i].abcfC != 0) {
- fml = qMin(fml,abc[i].abcfA);
- fmr = qMin(fmr,abc[i].abcfC);
- }
- }
- ml = int(fml - 0.9999);
- mr = int(fmr - 0.9999);
- delete [] abc;
- }
- lbearing = ml;
- rbearing = mr;
- }
-
- return rbearing;
-#else // !Q_OS_WINCE
- if (rbearing == SHRT_MIN) {
- int ml = 0;
- int mr = 0;
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- if (ttf) {
- ABC *abc = 0;
- int n = tm.tmLastChar - tm.tmFirstChar;
- if (n <= max_font_count) {
- abc = new ABC[n+1];
- GetCharABCWidths(hdc, tm.tmFirstChar, tm.tmLastChar, abc);
- } else {
- abc = new ABC[char_table_entries+1];
- for (int i = 0; i < char_table_entries; i++)
- GetCharABCWidths(hdc, char_table[i], char_table[i], abc+i);
- n = char_table_entries;
- }
- ml = abc[0].abcA;
- mr = abc[0].abcC;
- for (int i = 1; i < n; i++) {
- if (abc[i].abcA + abc[i].abcB + abc[i].abcC != 0) {
- ml = qMin(ml,abc[i].abcA);
- mr = qMin(mr,abc[i].abcC);
- }
- }
- delete [] abc;
- }
- lbearing = ml;
- rbearing = mr;
- }
-
- return rbearing;
-#endif // Q_OS_WINCE
-}
-
-static inline double qt_fixed_to_double(const FIXED &p) {
- return ((p.value << 16) + p.fract) / 65536.0;
-}
-
-static inline QPointF qt_to_qpointf(const POINTFX &pt, qreal scale) {
- return QPointF(qt_fixed_to_double(pt.x) * scale, -qt_fixed_to_double(pt.y) * scale);
-}
-
-#ifndef GGO_UNHINTED
-#define GGO_UNHINTED 0x0100
-#endif
-
-static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
- QPainterPath *path, bool ttf, glyph_metrics_t *metric = 0, qreal scale = 1)
-{
- MAT2 mat;
- mat.eM11.value = mat.eM22.value = 1;
- mat.eM11.fract = mat.eM22.fract = 0;
- mat.eM21.value = mat.eM12.value = 0;
- mat.eM21.fract = mat.eM12.fract = 0;
-
- GLYPHMETRICS gMetric;
- memset(&gMetric, 0, sizeof(GLYPHMETRICS));
-
-#ifndef Q_OS_WINCE
- if (metric) {
- // If metrics requested, retrieve first using GGO_METRICS, because the returned
- // values are incorrect for OpenType PS fonts if obtained at the same time as the
- // glyph paths themselves (ie. with GGO_NATIVE as the format).
- uint format = GGO_METRICS;
- if (ttf)
- format |= GGO_GLYPH_INDEX;
- if (GetGlyphOutline(hdc, glyph, format, &gMetric, 0, 0, &mat) == GDI_ERROR)
- return false;
- // #### obey scale
- *metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
- int(gMetric.gmBlackBoxX), int(gMetric.gmBlackBoxY),
- gMetric.gmCellIncX, gMetric.gmCellIncY);
- }
-#endif
-
- uint glyphFormat = GGO_NATIVE;
-
- if (ttf)
- glyphFormat |= GGO_GLYPH_INDEX;
-
- const DWORD bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat);
- if (bufferSize == GDI_ERROR)
- return false;
-
- char *dataBuffer = new char[bufferSize];
- DWORD ret = GDI_ERROR;
- ret = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, bufferSize, dataBuffer, &mat);
- if (ret == GDI_ERROR) {
- delete [] dataBuffer;
- return false;
- }
-
-#ifdef Q_OS_WINCE
- if (metric) {
- // #### obey scale
- *metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
- (int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
- gMetric.gmCellIncX, gMetric.gmCellIncY);
- }
-#endif
-
- DWORD offset = 0;
- DWORD headerOffset = 0;
-
- QPointF oset = position.toPointF();
- while (headerOffset < bufferSize) {
- const TTPOLYGONHEADER *ttph = reinterpret_cast<const TTPOLYGONHEADER *>(dataBuffer + headerOffset);
-
- QPointF lastPoint(qt_to_qpointf(ttph->pfxStart, scale));
- path->moveTo(lastPoint + oset);
- offset += sizeof(TTPOLYGONHEADER);
- while (offset < headerOffset + ttph->cb) {
- const TTPOLYCURVE *curve = reinterpret_cast<const TTPOLYCURVE *>(dataBuffer + offset);
- switch (curve->wType) {
- case TT_PRIM_LINE: {
- for (int i=0; i<curve->cpfx; ++i) {
- QPointF p = qt_to_qpointf(curve->apfx[i], scale) + oset;
- path->lineTo(p);
- }
- break;
- }
- case TT_PRIM_QSPLINE: {
- const QPainterPath::Element &elm = path->elementAt(path->elementCount()-1);
- QPointF prev(elm.x, elm.y);
- QPointF endPoint;
- for (int i=0; i<curve->cpfx - 1; ++i) {
- QPointF p1 = qt_to_qpointf(curve->apfx[i], scale) + oset;
- QPointF p2 = qt_to_qpointf(curve->apfx[i+1], scale) + oset;
- if (i < curve->cpfx - 2) {
- endPoint = QPointF((p1.x() + p2.x()) / 2, (p1.y() + p2.y()) / 2);
- } else {
- endPoint = p2;
- }
-
- path->quadTo(p1, endPoint);
- prev = endPoint;
- }
-
- break;
- }
- case TT_PRIM_CSPLINE: {
- for (int i=0; i<curve->cpfx; ) {
- QPointF p2 = qt_to_qpointf(curve->apfx[i++], scale) + oset;
- QPointF p3 = qt_to_qpointf(curve->apfx[i++], scale) + oset;
- QPointF p4 = qt_to_qpointf(curve->apfx[i++], scale) + oset;
- path->cubicTo(p2, p3, p4);
- }
- break;
- }
- default:
- qWarning("QFontEngineWin::addOutlineToPath, unhandled switch case");
- }
- offset += sizeof(TTPOLYCURVE) + (curve->cpfx-1) * sizeof(POINTFX);
- }
- path->closeSubpath();
- headerOffset += ttph->cb;
- }
- delete [] dataBuffer;
-
- return true;
-}
-
-void QWindowsFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
- QPainterPath *path, QTextItem::RenderFlags)
-{
- LOGFONT lf = m_logfont;
- // The sign must be negative here to make sure we match against character height instead of
- // hinted cell height. This ensures that we get linear matching, and we need this for
- // paths since we later on apply a scaling transform to the glyph outline to get the
- // font at the correct pixel size.
- lf.lfHeight = -unitsPerEm;
- lf.lfWidth = 0;
- HFONT hf = CreateFontIndirect(&lf);
- HDC hdc = m_fontEngineData->hdc;
- HGDIOBJ oldfont = SelectObject(hdc, hf);
-
- for(int i = 0; i < nglyphs; ++i) {
- if (!addGlyphToPath(glyphs[i], positions[i], hdc, path, ttf, /*metric*/0,
- qreal(fontDef.pixelSize) / unitsPerEm)) {
- // Some windows fonts, like "Modern", are vector stroke
- // fonts, which are reported as TMPF_VECTOR but do not
- // support GetGlyphOutline, and thus we set this bit so
- // that addOutLineToPath can check it and return safely...
- hasOutline = false;
- break;
- }
- }
- DeleteObject(SelectObject(hdc, oldfont));
-}
-
-void QWindowsFontEngine::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
- QPainterPath *path, QTextItem::RenderFlags flags)
-{
- if(tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)) {
- hasOutline = true;
- QFontEngine::addOutlineToPath(x, y, glyphs, path, flags);
- if (hasOutline) {
- // has_outline is set to false if addGlyphToPath gets
- // false from GetGlyphOutline, meaning its not an outline
- // font.
- return;
- }
- }
- QFontEngine::addBitmapFontToPath(x, y, glyphs, path, flags);
-}
-
-QFontEngine::FaceId QWindowsFontEngine::faceId() const
-{
- return _faceId;
-}
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qdebug.h>
-QT_END_INCLUDE_NAMESPACE
-
-int QWindowsFontEngine::synthesized() const
-{
- if(synthesized_flags == -1) {
- synthesized_flags = 0;
- if(ttf) {
- const DWORD HEAD = MAKE_LITTLE_ENDIAN_TAG('h', 'e', 'a', 'd');
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- uchar data[4];
- GetFontData(hdc, HEAD, 44, &data, 4);
- USHORT macStyle = getUShort(data);
- if (tm.tmItalic && !(macStyle & 2))
- synthesized_flags = SynthesizedItalic;
- if (fontDef.stretch != 100 && ttf)
- synthesized_flags |= SynthesizedStretch;
- if (tm.tmWeight >= 500 && !(macStyle & 1))
- synthesized_flags |= SynthesizedBold;
- //qDebug() << "font is" << _name <<
- // "it=" << (macStyle & 2) << fontDef.style << "flags=" << synthesized_flags;
- }
- }
- return synthesized_flags;
-}
-
-QFixed QWindowsFontEngine::emSquareSize() const
-{
- return unitsPerEm;
-}
-
-QFontEngine::Properties QWindowsFontEngine::properties() const
-{
- LOGFONT lf = m_logfont;
- lf.lfHeight = unitsPerEm;
- HFONT hf = CreateFontIndirect(&lf);
- HDC hdc = m_fontEngineData->hdc;
- HGDIOBJ oldfont = SelectObject(hdc, hf);
- OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc);
- Properties p;
- p.emSquare = unitsPerEm;
- p.italicAngle = otm->otmItalicAngle;
- const QByteArray name = stringFromOutLineTextMetric(otm, otm->otmpFamilyName).toLatin1()
- + stringFromOutLineTextMetric(otm, otm->otmpStyleName).toLatin1();
- p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(name);
- p.boundingBox = QRectF(otm->otmrcFontBox.left, -otm->otmrcFontBox.top,
- otm->otmrcFontBox.right - otm->otmrcFontBox.left,
- otm->otmrcFontBox.top - otm->otmrcFontBox.bottom);
- p.ascent = otm->otmAscent;
- p.descent = -otm->otmDescent;
- p.leading = int(otm->otmLineGap);
- p.capHeight = 0;
- p.lineWidth = otm->otmsUnderscoreSize;
- free(otm);
- DeleteObject(SelectObject(hdc, oldfont));
- return p;
-}
-
-void QWindowsFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
-{
- LOGFONT lf = m_logfont;
- lf.lfHeight = -unitsPerEm;
- int flags = synthesized();
- if(flags & SynthesizedItalic)
- lf.lfItalic = false;
- lf.lfWidth = 0;
- HFONT hf = CreateFontIndirect(&lf);
- HDC hdc = m_fontEngineData->hdc;
- HGDIOBJ oldfont = SelectObject(hdc, hf);
- QFixedPoint p;
- p.x = 0;
- p.y = 0;
- addGlyphToPath(glyph, p, hdc, path, ttf, metrics);
- DeleteObject(SelectObject(hdc, oldfont));
-}
-
-bool QWindowsFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const
-{
- if (!ttf && !cffTable)
- return false;
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- DWORD t = qbswap<quint32>(tag);
- *length = GetFontData(hdc, t, 0, buffer, *length);
- Q_ASSERT(*length == GDI_ERROR || int(*length) > 0);
- return *length != GDI_ERROR;
-}
-
-#if !defined(CLEARTYPE_QUALITY)
-# define CLEARTYPE_QUALITY 5
-#endif
-
-QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, int margin,
- const QTransform &t,
- QImage::Format mask_format)
-{
- Q_UNUSED(mask_format)
- glyph_metrics_t gm = boundingBox(glyph);
-
-// printf(" -> for glyph %4x\n", glyph);
-
- int gx = gm.x.toInt();
- int gy = gm.y.toInt();
- int iw = gm.width.toInt();
- int ih = gm.height.toInt();
-
- if (iw <= 0 || ih <= 0)
- return 0;
-
- bool has_transformation = t.type() > QTransform::TxTranslate;
-
-#ifndef Q_OS_WINCE
- unsigned int options = ttf ? ETO_GLYPH_INDEX : 0;
- XFORM xform;
-
- if (has_transformation) {
- xform.eM11 = FLOAT(t.m11());
- xform.eM12 = FLOAT(t.m12());
- xform.eM21 = FLOAT(t.m21());
- xform.eM22 = FLOAT(t.m22());
- xform.eDx = margin;
- xform.eDy = margin;
-
- const HDC hdc = m_fontEngineData->hdc;
-
- SetGraphicsMode(hdc, GM_ADVANCED);
- SetWorldTransform(hdc, &xform);
- HGDIOBJ old_font = SelectObject(hdc, font);
-
- const UINT ggo_options = GGO_METRICS | (ttf ? GGO_GLYPH_INDEX : 0);
- GLYPHMETRICS tgm;
- MAT2 mat;
- memset(&mat, 0, sizeof(mat));
- mat.eM11.value = mat.eM22.value = 1;
-
- const DWORD result = GetGlyphOutline(hdc, glyph, ggo_options, &tgm, 0, 0, &mat);
-
- XFORM identity = {1, 0, 0, 1, 0, 0};
- SetWorldTransform(hdc, &identity);
- SetGraphicsMode(hdc, GM_COMPATIBLE);
- SelectObject(hdc, old_font);
-
- if (result == GDI_ERROR) {
- const int errorCode = int(GetLastError());
- qErrnoWarning(errorCode, "QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error %d)...", errorCode);
- return 0;
- }
-
- iw = int(tgm.gmBlackBoxX);
- ih = int(tgm.gmBlackBoxY);
-
- xform.eDx -= tgm.gmptGlyphOrigin.x;
- xform.eDy += tgm.gmptGlyphOrigin.y;
- }
-#else // else wince
- unsigned int options = 0;
- if (has_transformation) {
- qWarning() << "QWindowsFontEngine is unable to apply transformations other than translations for fonts on Windows CE."
- << "If you need them anyway, start your application with -platform windows:fontengine=freetype.";
- }
-#endif // wince
-
- // The padding here needs to be kept in sync with the values in alphaMapBoundingBox.
- QWindowsNativeImage *ni = new QWindowsNativeImage(iw + 2 * margin,
- ih + 2 * margin,
- QWindowsNativeImage::systemFormat());
-
- /*If cleartype is enabled we use the standard system format even on Windows CE
- and not the special textbuffer format we have to use if cleartype is disabled*/
-
- ni->image().fill(0xffffffff);
-
- HDC hdc = ni->hdc();
-
- SelectObject(hdc, GetStockObject(NULL_BRUSH));
- SelectObject(hdc, GetStockObject(BLACK_PEN));
- SetTextColor(hdc, RGB(0,0,0));
- SetBkMode(hdc, TRANSPARENT);
- SetTextAlign(hdc, TA_BASELINE);
-
- HGDIOBJ old_font = SelectObject(hdc, font);
-
-#ifndef Q_OS_WINCE
- if (has_transformation) {
- SetGraphicsMode(hdc, GM_ADVANCED);
- SetWorldTransform(hdc, &xform);
- ExtTextOut(hdc, 0, 0, options, 0, reinterpret_cast<LPCWSTR>(&glyph), 1, 0);
- } else
-#endif // !Q_OS_WINCE
- {
- ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, reinterpret_cast<LPCWSTR>(&glyph), 1, 0);
- }
-
- SelectObject(hdc, old_font);
- return ni;
-}
-
-glyph_metrics_t QWindowsFontEngine::alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat format)
-{
- int margin = 0;
- if (format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB)
- margin = glyphMargin(QFontEngine::Format_A32);
- glyph_metrics_t gm = boundingBox(glyph, matrix);
- gm.width += margin * 2;
- gm.height += margin * 2;
- return gm;
-}
-
-QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
-{
- HFONT font = hfont;
-
- bool clearTypeTemporarilyDisabled = (m_fontEngineData->clearTypeEnabled && m_logfont.lfQuality != NONANTIALIASED_QUALITY);
- if (clearTypeTemporarilyDisabled) {
- LOGFONT lf = m_logfont;
- lf.lfQuality = ANTIALIASED_QUALITY;
- font = CreateFontIndirect(&lf);
- }
- QImage::Format mask_format = QWindowsNativeImage::systemFormat();
- mask_format = QImage::Format_RGB32;
-
- const QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
- if (mask == 0) {
- if (m_fontEngineData->clearTypeEnabled)
- DeleteObject(font);
- return QImage();
- }
-
- QImage alphaMap(mask->width(), mask->height(), QImage::Format_Alpha8);
-
-
- // Copy data... Cannot use QPainter here as GDI has messed up the
- // Alpha channel of the ni.image pixels...
- for (int y=0; y<mask->height(); ++y) {
- uchar *dest = alphaMap.scanLine(y);
- if (mask->image().format() == QImage::Format_RGB16) {
- const qint16 *src = reinterpret_cast<const qint16 *>(mask->image().constScanLine(y));
- for (int x=0; x<mask->width(); ++x)
- dest[x] = 255 - qGray(src[x]);
- } else {
- const uint *src = reinterpret_cast<const uint *>(mask->image().constScanLine(y));
- for (int x=0; x<mask->width(); ++x) {
- if (QWindowsNativeImage::systemFormat() == QImage::Format_RGB16)
- dest[x] = 255 - qGray(src[x]);
- else
- dest[x] = 255 - (m_fontEngineData->pow_gamma[qGray(src[x])] * 255. / 2047.);
- }
- }
- }
-
- // Cleanup...
- delete mask;
- if (clearTypeTemporarilyDisabled) {
- DeleteObject(font);
- }
-
- return alphaMap;
-}
-
-#define SPI_GETFONTSMOOTHINGCONTRAST 0x200C
-#define SPI_SETFONTSMOOTHINGCONTRAST 0x200D
-
-QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTransform &t)
-{
- HFONT font = hfont;
-
- UINT contrast;
- SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
- SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, reinterpret_cast<void *>(quintptr(1000)), 0);
-
- int margin = glyphMargin(QFontEngine::Format_A32);
- QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
- SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, reinterpret_cast<void *>(quintptr(contrast)), 0);
-
- if (mask == 0)
- return QImage();
-
- // Gracefully handle the odd case when the display is 16-bit
- const QImage source = mask->image().depth() == 32
- ? mask->image()
- : mask->image().convertToFormat(QImage::Format_RGB32);
-
- QImage rgbMask(mask->width(), mask->height(), QImage::Format_RGB32);
- for (int y=0; y<mask->height(); ++y) {
- uint *dest = (uint *) rgbMask.scanLine(y);
- const uint *src = reinterpret_cast<const uint *>(source.constScanLine(y));
- for (int x=0; x<mask->width(); ++x) {
- dest[x] = 0xffffffff - (0x00ffffff & src[x]);
- }
- }
-
- delete mask;
-
- return rgbMask;
-}
-
-QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
-{
- QFontDef request = fontDef;
- QString actualFontName = request.family;
- if (!uniqueFamilyName.isEmpty())
- request.family = uniqueFamilyName;
- request.pixelSize = pixelSize;
-
- QFontEngine *fontEngine =
- QWindowsFontDatabase::createEngine(request,
- QWindowsContext::instance()->defaultDPI(),
- m_fontEngineData);
- if (fontEngine) {
- fontEngine->fontDef.family = actualFontName;
- if (!uniqueFamilyName.isEmpty()) {
- static_cast<QWindowsFontEngine *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName);
- QPlatformFontDatabase *pfdb = QWindowsIntegration::instance()->fontDatabase();
- static_cast<QWindowsFontDatabase *>(pfdb)->refUniqueFont(uniqueFamilyName);
- }
- }
- return fontEngine;
-}
-
-Qt::HANDLE QWindowsFontEngine::handle() const
-{
- return hfont;
-}
-
-void QWindowsFontEngine::initFontInfo(const QFontDef &request,
- int dpi)
-{
- fontDef = request; // most settings are equal
- HDC dc = m_fontEngineData->hdc;
- SelectObject(dc, hfont);
- wchar_t n[64];
- GetTextFace(dc, 64, n);
- fontDef.family = QString::fromWCharArray(n);
- fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
- if (fontDef.pointSize < 0) {
- fontDef.pointSize = fontDef.pixelSize * 72. / dpi;
- } else if (fontDef.pixelSize == -1) {
- fontDef.pixelSize = qRound(fontDef.pointSize * dpi / 72.);
- }
-}
-
-/*!
- \class QWindowsMultiFontEngine
- \brief Standard Windows Multi font engine.
- \internal
- \ingroup qt-lighthouse-win
-
- "Merges" several font engines that have gaps in the
- supported writing systems.
-
- Will probably be superseded by a common Free Type font engine in Qt 5.X.
-*/
-QWindowsMultiFontEngine::QWindowsMultiFontEngine(QFontEngine *fe, int script)
- : QFontEngineMulti(fe, script)
-{
-}
-
-QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
-{
- QFontEngine *fontEngine = engine(0);
- QSharedPointer<QWindowsFontEngineData> data;
- LOGFONT lf;
-
-#ifndef QT_NO_DIRECTWRITE
- if (fontEngine->type() == QFontEngine::DirectWrite) {
- QWindowsFontEngineDirectWrite *fe = static_cast<QWindowsFontEngineDirectWrite *>(fontEngine);
- lf = QWindowsFontDatabase::fontDefToLOGFONT(fe->fontDef);
-
- data = fe->fontEngineData();
- } else
-#endif
- {
- QWindowsFontEngine *fe = static_cast<QWindowsFontEngine*>(fontEngine);
- lf = fe->m_logfont;
-
- data = fe->fontEngineData();
- }
-
- const QString fam = fallbackFamilyAt(at - 1);
- const int faceNameLength = qMin(fam.length(), LF_FACESIZE - 1);
- memcpy(lf.lfFaceName, fam.utf16(), faceNameLength * sizeof(wchar_t));
- lf.lfFaceName[faceNameLength] = 0;
-
-#ifndef QT_NO_DIRECTWRITE
- if (fontEngine->type() == QFontEngine::DirectWrite) {
- const QString nameSubstitute = QWindowsFontEngineDirectWrite::fontNameSubstitute(fam);
- if (nameSubstitute != fam) {
- const int nameSubstituteLength = qMin(nameSubstitute.length(), LF_FACESIZE - 1);
- memcpy(lf.lfFaceName, nameSubstitute.utf16(), nameSubstituteLength * sizeof(wchar_t));
- lf.lfFaceName[nameSubstituteLength] = 0;
- }
-
- IDWriteFont *directWriteFont = 0;
- HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont);
- if (FAILED(hr)) {
- qErrnoWarning("%s: CreateFontFromLOGFONT failed", __FUNCTION__);
- } else {
- Q_ASSERT(directWriteFont);
- IDWriteFontFace *directWriteFontFace = NULL;
- HRESULT hr = directWriteFont->CreateFontFace(&directWriteFontFace);
- if (SUCCEEDED(hr)) {
- Q_ASSERT(directWriteFontFace);
- QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
- fontEngine->fontDef.pixelSize,
- data);
- fedw->fontDef.weight = fontEngine->fontDef.weight;
- if (fontEngine->fontDef.style > QFont::StyleNormal)
- fedw->fontDef.style = fontEngine->fontDef.style;
- fedw->fontDef.family = fam;
- fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
- return fedw;
- } else {
- qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
- }
- }
- }
-#endif
-
- // Get here if original font is not DirectWrite or DirectWrite creation failed for some
- // reason
-
- QFontEngine *fe = new QWindowsFontEngine(fam, lf, data);
- fe->fontDef.weight = fontEngine->fontDef.weight;
- if (fontEngine->fontDef.style > QFont::StyleNormal)
- fe->fontDef.style = fontEngine->fontDef.style;
- fe->fontDef.family = fam;
- fe->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
- return fe;
-}
-
-bool QWindowsFontEngine::supportsTransformation(const QTransform &transform) const
-{
- // Support all transformations for ttf files, and translations for raster fonts
- return ttf || transform.type() <= QTransform::TxTranslate;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h
deleted file mode 100644
index d4d98422a1..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontengine.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSFONTENGINE_H
-#define QWINDOWSFONTENGINE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qfontengine_p.h>
-
-#include <QtGui/QImage>
-#include <QtCore/QSharedPointer>
-#include <QtCore/QMetaType>
-
-#include "qtwindows_additional.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWindowsNativeImage;
-class QWindowsFontEngineData;
-
-class QWindowsFontEngine : public QFontEngine
-{
- friend class QWindowsMultiFontEngine;
-
-public:
- QWindowsFontEngine(const QString &name, LOGFONT lf,
- const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
-
- ~QWindowsFontEngine();
- void initFontInfo(const QFontDef &request,
- int dpi);
-
- QFixed lineThickness() const Q_DECL_OVERRIDE;
- Properties properties() const Q_DECL_OVERRIDE;
- void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE;
- FaceId faceId() const Q_DECL_OVERRIDE;
- bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE;
- int synthesized() const Q_DECL_OVERRIDE;
- QFixed emSquareSize() const Q_DECL_OVERRIDE;
-
- glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
- bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
- void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const Q_DECL_OVERRIDE;
-
- void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
- virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
- QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
-
- HGDIOBJ selectDesignFont() const;
-
- glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
- glyph_metrics_t boundingBox(glyph_t g) Q_DECL_OVERRIDE { return boundingBox(g, QTransform()); }
- glyph_metrics_t boundingBox(glyph_t g, const QTransform &t) Q_DECL_OVERRIDE;
-
-
- QFixed ascent() const Q_DECL_OVERRIDE;
- QFixed descent() const Q_DECL_OVERRIDE;
- QFixed leading() const Q_DECL_OVERRIDE;
- QFixed xHeight() const Q_DECL_OVERRIDE;
- QFixed averageCharWidth() const Q_DECL_OVERRIDE;
- qreal maxCharWidth() const Q_DECL_OVERRIDE;
- qreal minLeftBearing() const Q_DECL_OVERRIDE;
- qreal minRightBearing() const Q_DECL_OVERRIDE;
-
- QImage alphaMapForGlyph(glyph_t t) Q_DECL_OVERRIDE { return alphaMapForGlyph(t, QTransform()); }
- QImage alphaMapForGlyph(glyph_t, const QTransform &xform) Q_DECL_OVERRIDE;
- QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, const QTransform &xform) Q_DECL_OVERRIDE;
- glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat) Q_DECL_OVERRIDE;
-
- QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
- Qt::HANDLE handle() const Q_DECL_OVERRIDE;
- bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE;
-
-#ifndef Q_CC_MINGW
- void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) Q_DECL_OVERRIDE;
-#endif
-
- bool hasUnreliableGlyphOutline() const Q_DECL_OVERRIDE;
-
- int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs) const;
- void getCMap();
-
- bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const;
-
- const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; }
-
- void setUniqueFamilyName(const QString &newName) { uniqueFamilyName = newName; }
-
-private:
- QWindowsNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
- QImage::Format mask_format);
- bool hasCFFTable() const;
- bool hasCMapTable() const;
- bool hasGlyfTable() const;
- bool hasEbdtTable() const;
-
- const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
-
- const QString _name;
- QString uniqueFamilyName;
- HFONT hfont;
- const LOGFONT m_logfont;
- uint ttf : 1;
- uint hasOutline : 1;
- uint hasUnreliableOutline : 1;
- uint cffTable : 1;
- TEXTMETRIC tm;
- const unsigned char *cmap;
- int cmapSize;
- QByteArray cmapTable;
- mutable qreal lbearing;
- mutable qreal rbearing;
- QFixed designToDevice;
- int unitsPerEm;
- QFixed x_height;
- FaceId _faceId;
-
- mutable int synthesized_flags;
- mutable QFixed lineWidth;
- mutable unsigned char *widthCache;
- mutable uint widthCacheSize;
- mutable QFixed *designAdvances;
- mutable int designAdvancesSize;
-};
-
-class QWindowsMultiFontEngine : public QFontEngineMulti
-{
-public:
- explicit QWindowsMultiFontEngine(QFontEngine *fe, int script);
-
- QFontEngine *loadEngine(int at) Q_DECL_OVERRIDE;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(HFONT)
-Q_DECLARE_METATYPE(LOGFONT)
-
-#endif // QWINDOWSFONTENGINE_H
-
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
deleted file mode 100644
index 0fdd4615f6..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ /dev/null
@@ -1,891 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_DIRECTWRITE
-
-#include "qwindowsfontenginedirectwrite.h"
-#include "qwindowsfontdatabase.h"
-#include "qwindowscontext.h"
-
-#include <QtCore/QSettings>
-#include <QtCore/QtEndian>
-#include <QtCore/QVarLengthArray>
-#include <private/qstringiterator_p.h>
-#include <QtCore/private/qsystemlibrary_p.h>
-#include <QtGui/private/qguiapplication_p.h>
-#include <qpa/qplatformintegration.h>
-
-#if defined(QT_USE_DIRECTWRITE2)
-# include <dwrite_2.h>
-#else
-# include <dwrite.h>
-#endif
-
-#include <d2d1.h>
-
-QT_BEGIN_NAMESPACE
-
-// Convert from design units to logical pixels
-#define DESIGN_TO_LOGICAL(DESIGN_UNIT_VALUE) \
- QFixed::fromReal((qreal(DESIGN_UNIT_VALUE) / qreal(m_unitsPerEm)) * fontDef.pixelSize)
-
-namespace {
-
- class GeometrySink: public IDWriteGeometrySink
- {
- public:
- GeometrySink(QPainterPath *path)
- : m_refCount(0), m_path(path)
- {
- Q_ASSERT(m_path != 0);
- }
- virtual ~GeometrySink()
- {
- }
-
- IFACEMETHOD_(void, AddBeziers)(const D2D1_BEZIER_SEGMENT *beziers, UINT bezierCount);
- IFACEMETHOD_(void, AddLines)(const D2D1_POINT_2F *points, UINT pointCount);
- IFACEMETHOD_(void, BeginFigure)(D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin);
- IFACEMETHOD(Close)();
- IFACEMETHOD_(void, EndFigure)(D2D1_FIGURE_END figureEnd);
- IFACEMETHOD_(void, SetFillMode)(D2D1_FILL_MODE fillMode);
- IFACEMETHOD_(void, SetSegmentFlags)(D2D1_PATH_SEGMENT vertexFlags);
-
- IFACEMETHOD_(unsigned long, AddRef)();
- IFACEMETHOD_(unsigned long, Release)();
- IFACEMETHOD(QueryInterface)(IID const &riid, void **ppvObject);
-
- private:
- inline static QPointF fromD2D1_POINT_2F(const D2D1_POINT_2F &inp)
- {
- return QPointF(inp.x, inp.y);
- }
-
- unsigned long m_refCount;
- QPointF m_startPoint;
- QPainterPath *m_path;
- };
-
- void GeometrySink::AddBeziers(const D2D1_BEZIER_SEGMENT *beziers,
- UINT bezierCount)
- {
- for (uint i=0; i<bezierCount; ++i) {
- QPointF c1 = fromD2D1_POINT_2F(beziers[i].point1);
- QPointF c2 = fromD2D1_POINT_2F(beziers[i].point2);
- QPointF p2 = fromD2D1_POINT_2F(beziers[i].point3);
-
- m_path->cubicTo(c1, c2, p2);
- }
- }
-
- void GeometrySink::AddLines(const D2D1_POINT_2F *points, UINT pointsCount)
- {
- for (uint i=0; i<pointsCount; ++i)
- m_path->lineTo(fromD2D1_POINT_2F(points[i]));
- }
-
- void GeometrySink::BeginFigure(D2D1_POINT_2F startPoint,
- D2D1_FIGURE_BEGIN /*figureBegin*/)
- {
- m_startPoint = fromD2D1_POINT_2F(startPoint);
- m_path->moveTo(m_startPoint);
- }
-
- IFACEMETHODIMP GeometrySink::Close()
- {
- return E_NOTIMPL;
- }
-
- void GeometrySink::EndFigure(D2D1_FIGURE_END figureEnd)
- {
- if (figureEnd == D2D1_FIGURE_END_CLOSED)
- m_path->closeSubpath();
- }
-
- void GeometrySink::SetFillMode(D2D1_FILL_MODE fillMode)
- {
- m_path->setFillRule(fillMode == D2D1_FILL_MODE_ALTERNATE
- ? Qt::OddEvenFill
- : Qt::WindingFill);
- }
-
- void GeometrySink::SetSegmentFlags(D2D1_PATH_SEGMENT /*vertexFlags*/)
- {
- /* Not implemented */
- }
-
- IFACEMETHODIMP_(unsigned long) GeometrySink::AddRef()
- {
- return InterlockedIncrement(&m_refCount);
- }
-
- IFACEMETHODIMP_(unsigned long) GeometrySink::Release()
- {
- unsigned long newCount = InterlockedDecrement(&m_refCount);
- if (newCount == 0)
- {
- delete this;
- return 0;
- }
-
- return newCount;
- }
-
- IFACEMETHODIMP GeometrySink::QueryInterface(IID const &riid, void **ppvObject)
- {
- if (__uuidof(IDWriteGeometrySink) == riid) {
- *ppvObject = this;
- } else if (__uuidof(IUnknown) == riid) {
- *ppvObject = this;
- } else {
- *ppvObject = NULL;
- return E_FAIL;
- }
-
- AddRef();
- return S_OK;
- }
-
-}
-
-/*!
- \class QWindowsFontEngineDirectWrite
- \brief Windows font engine using Direct Write.
- \internal
- \ingroup qt-lighthouse-win
-
- Font engine for subpixel positioned text on Windows Vista
- (with platform update) and Windows 7. If selected during
- configuration, the engine will be selected only when the hinting
- preference of a font is set to None or Vertical hinting. The font
- database uses most of the same logic but creates a direct write
- font based on the LOGFONT rather than a GDI handle.
-
- Will probably be superseded by a common Free Type font engine in Qt 5.X.
-*/
-
-QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace,
- qreal pixelSize,
- const QSharedPointer<QWindowsFontEngineData> &d)
- : QFontEngine(DirectWrite)
- , m_fontEngineData(d)
- , m_directWriteFontFace(directWriteFontFace)
- , m_directWriteBitmapRenderTarget(0)
- , m_lineThickness(-1)
- , m_unitsPerEm(-1)
- , m_ascent(-1)
- , m_descent(-1)
- , m_xHeight(-1)
- , m_lineGap(-1)
-{
- qCDebug(lcQpaFonts) << __FUNCTION__ << pixelSize;
-
- Q_ASSERT(m_directWriteFontFace);
-
- m_fontEngineData->directWriteFactory->AddRef();
- m_directWriteFontFace->AddRef();
-
- fontDef.pixelSize = pixelSize;
- collectMetrics();
- cache_cost = (m_ascent.toInt() + m_descent.toInt()) * m_xHeight.toInt() * 2000;
-}
-
-QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite()
-{
- qCDebug(lcQpaFonts) << __FUNCTION__;
-
- m_fontEngineData->directWriteFactory->Release();
- m_directWriteFontFace->Release();
-
- if (m_directWriteBitmapRenderTarget != 0)
- m_directWriteBitmapRenderTarget->Release();
-
- if (!m_uniqueFamilyName.isEmpty()) {
- QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
- static_cast<QWindowsFontDatabase *>(pfdb)->derefUniqueFont(m_uniqueFamilyName);
- }
-}
-
-void QWindowsFontEngineDirectWrite::collectMetrics()
-{
- DWRITE_FONT_METRICS metrics;
-
- m_directWriteFontFace->GetMetrics(&metrics);
- m_unitsPerEm = metrics.designUnitsPerEm;
-
- m_lineThickness = DESIGN_TO_LOGICAL(metrics.underlineThickness);
- m_ascent = DESIGN_TO_LOGICAL(metrics.ascent);
- m_descent = DESIGN_TO_LOGICAL(metrics.descent);
- m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight);
- m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap);
- m_underlinePosition = DESIGN_TO_LOGICAL(metrics.underlinePosition);
-}
-
-QFixed QWindowsFontEngineDirectWrite::underlinePosition() const
-{
- if (m_underlinePosition > 0)
- return m_underlinePosition;
- else
- return QFontEngine::underlinePosition();
-}
-
-QFixed QWindowsFontEngineDirectWrite::lineThickness() const
-{
- if (m_lineThickness > 0)
- return m_lineThickness;
- else
- return QFontEngine::lineThickness();
-}
-
-bool QWindowsFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, uint *length) const
-{
- bool ret = false;
-
- const void *tableData = 0;
- UINT32 tableSize;
- void *tableContext = 0;
- BOOL exists;
- HRESULT hr = m_directWriteFontFace->TryGetFontTable(qbswap<quint32>(tag),
- &tableData, &tableSize,
- &tableContext, &exists);
- if (SUCCEEDED(hr)) {
- if (exists) {
- ret = true;
- if (buffer && *length >= tableSize)
- memcpy(buffer, tableData, tableSize);
- *length = tableSize;
- Q_ASSERT(int(*length) > 0);
- }
- m_directWriteFontFace->ReleaseFontTable(tableContext);
- } else {
- qErrnoWarning("%s: TryGetFontTable failed", __FUNCTION__);
- }
-
- return ret;
-}
-
-QFixed QWindowsFontEngineDirectWrite::emSquareSize() const
-{
- if (m_unitsPerEm > 0)
- return m_unitsPerEm;
- else
- return QFontEngine::emSquareSize();
-}
-
-glyph_t QWindowsFontEngineDirectWrite::glyphIndex(uint ucs4) const
-{
- UINT16 glyphIndex;
-
- HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(&ucs4, 1, &glyphIndex);
- if (FAILED(hr)) {
- qErrnoWarning("%s: glyphIndex failed", __FUNCTION__);
- glyphIndex = 0;
- }
-
- return glyphIndex;
-}
-
-bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
- int *nglyphs, QFontEngine::ShaperFlags flags) const
-{
- Q_ASSERT(glyphs->numGlyphs >= *nglyphs);
- if (*nglyphs < len) {
- *nglyphs = len;
- return false;
- }
-
- QVarLengthArray<UINT32> codePoints(len);
- int actualLength = 0;
- QStringIterator it(str, str + len);
- while (it.hasNext())
- codePoints[actualLength++] = it.next();
-
- QVarLengthArray<UINT16> glyphIndices(actualLength);
- HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), actualLength,
- glyphIndices.data());
- if (FAILED(hr)) {
- qErrnoWarning("%s: GetGlyphIndicesW failed", __FUNCTION__);
- return false;
- }
-
- for (int i = 0; i < actualLength; ++i)
- glyphs->glyphs[i] = glyphIndices.at(i);
-
- *nglyphs = actualLength;
- glyphs->numGlyphs = actualLength;
-
- if (!(flags & GlyphIndicesOnly))
- recalcAdvances(glyphs, 0);
-
- return true;
-}
-
-void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
-{
- QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs);
-
- // ### Caching?
- for(int i=0; i<glyphs->numGlyphs; i++)
- glyphIndices[i] = UINT16(glyphs->glyphs[i]);
-
- QVarLengthArray<DWRITE_GLYPH_METRICS> glyphMetrics(glyphIndices.size());
- HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(glyphIndices.data(),
- glyphIndices.size(),
- glyphMetrics.data());
- if (SUCCEEDED(hr)) {
- qreal stretch = fontDef.stretch / 100.0;
- for (int i = 0; i < glyphs->numGlyphs; ++i)
- glyphs->advances[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth * stretch);
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
- for (int i = 0; i < glyphs->numGlyphs; ++i)
- glyphs->advances[i] = glyphs->advances[i].round();
- }
- } else {
- qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__);
- }
-}
-
-void QWindowsFontEngineDirectWrite::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
- QPainterPath *path, QTextItem::RenderFlags flags)
-{
- QVarLengthArray<UINT16> glyphIndices(nglyphs);
- QVarLengthArray<DWRITE_GLYPH_OFFSET> glyphOffsets(nglyphs);
- QVarLengthArray<FLOAT> glyphAdvances(nglyphs);
-
- for (int i=0; i<nglyphs; ++i) {
- glyphIndices[i] = glyphs[i];
- glyphOffsets[i].advanceOffset = positions[i].x.toReal();
- glyphOffsets[i].ascenderOffset = -positions[i].y.toReal();
- glyphAdvances[i] = 0.0;
- }
-
- GeometrySink geometrySink(path);
- HRESULT hr = m_directWriteFontFace->GetGlyphRunOutline(
- fontDef.pixelSize,
- glyphIndices.data(),
- glyphAdvances.data(),
- glyphOffsets.data(),
- nglyphs,
- false,
- flags & QTextItem::RightToLeft,
- &geometrySink
- );
-
- if (FAILED(hr))
- qErrnoWarning("%s: GetGlyphRunOutline failed", __FUNCTION__);
-}
-
-glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(const QGlyphLayout &glyphs)
-{
- if (glyphs.numGlyphs == 0)
- return glyph_metrics_t();
-
- bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
-
- QFixed w = 0;
- for (int i = 0; i < glyphs.numGlyphs; ++i) {
- w += round ? glyphs.effectiveAdvance(i).round() : glyphs.effectiveAdvance(i);
-
- }
-
- return glyph_metrics_t(0, -m_ascent, w - lastRightBearing(glyphs), m_ascent + m_descent, w, 0);
-}
-
-glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g)
-{
- UINT16 glyphIndex = g;
-
- DWRITE_GLYPH_METRICS glyphMetrics;
- HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(&glyphIndex, 1, &glyphMetrics);
- if (SUCCEEDED(hr)) {
- QFixed advanceWidth = DESIGN_TO_LOGICAL(glyphMetrics.advanceWidth);
- QFixed leftSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.leftSideBearing);
- QFixed rightSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.rightSideBearing);
- QFixed advanceHeight = DESIGN_TO_LOGICAL(glyphMetrics.advanceHeight);
- QFixed verticalOriginY = DESIGN_TO_LOGICAL(glyphMetrics.verticalOriginY);
- QFixed topSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.topSideBearing);
- QFixed bottomSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.bottomSideBearing);
-
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
- advanceWidth = advanceWidth.round();
- advanceHeight = advanceHeight.round();
- }
-
- QFixed width = advanceWidth - leftSideBearing - rightSideBearing;
- QFixed height = advanceHeight - topSideBearing - bottomSideBearing;
- return glyph_metrics_t(leftSideBearing,
- -verticalOriginY + topSideBearing,
- width,
- height,
- advanceWidth,
- 0);
- } else {
- qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__);
- }
-
- return glyph_metrics_t();
-}
-
-QFixed QWindowsFontEngineDirectWrite::ascent() const
-{
- return fontDef.styleStrategy & QFont::ForceIntegerMetrics
- ? m_ascent.round()
- : m_ascent;
-}
-
-QFixed QWindowsFontEngineDirectWrite::descent() const
-{
- return fontDef.styleStrategy & QFont::ForceIntegerMetrics
- ? m_descent.round()
- : m_descent;
-}
-
-QFixed QWindowsFontEngineDirectWrite::leading() const
-{
- return fontDef.styleStrategy & QFont::ForceIntegerMetrics
- ? m_lineGap.round()
- : m_lineGap;
-}
-
-QFixed QWindowsFontEngineDirectWrite::xHeight() const
-{
- return fontDef.styleStrategy & QFont::ForceIntegerMetrics
- ? m_xHeight.round()
- : m_xHeight;
-}
-
-qreal QWindowsFontEngineDirectWrite::maxCharWidth() const
-{
- // ###
- return 0;
-}
-
-QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
-{
- QImage im = alphaRGBMapForGlyph(glyph, subPixelPosition, t);
-
- QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
-
- for (int y=0; y<im.height(); ++y) {
- const uint *src = reinterpret_cast<const uint *>(im.constScanLine(y));
- uchar *dst = alphaMap.scanLine(y);
- for (int x=0; x<im.width(); ++x) {
- *dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.);
- ++dst;
- ++src;
- }
- }
-
- return alphaMap;
-}
-
-QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
-{
- return alphaMapForGlyph(glyph, subPixelPosition, QTransform());
-}
-
-bool QWindowsFontEngineDirectWrite::supportsSubPixelPositions() const
-{
- return true;
-}
-
-QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
- QFixed subPixelPosition,
- int margin,
- const QTransform &originalTransform)
-{
- UINT16 glyphIndex = t;
- FLOAT glyphAdvance = 0;
-
- DWRITE_GLYPH_OFFSET glyphOffset;
- glyphOffset.advanceOffset = 0;
- glyphOffset.ascenderOffset = 0;
-
- DWRITE_GLYPH_RUN glyphRun;
- glyphRun.fontFace = m_directWriteFontFace;
- glyphRun.fontEmSize = fontDef.pixelSize;
- glyphRun.glyphCount = 1;
- glyphRun.glyphIndices = &glyphIndex;
- glyphRun.glyphAdvances = &glyphAdvance;
- glyphRun.isSideways = false;
- glyphRun.bidiLevel = 0;
- glyphRun.glyphOffsets = &glyphOffset;
-
- QTransform xform = originalTransform;
- if (fontDef.stretch != 100)
- xform.scale(fontDef.stretch / 100.0, 1.0);
-
- DWRITE_MATRIX transform;
- transform.dx = subPixelPosition.toReal();
- transform.dy = 0;
- transform.m11 = xform.m11();
- transform.m12 = xform.m12();
- transform.m21 = xform.m21();
- transform.m22 = xform.m22();
-
- DWRITE_RENDERING_MODE renderMode =
- fontDef.hintingPreference == QFont::PreferNoHinting
- ? DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
- : DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
-
- IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
- HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
- &glyphRun,
- 1.0f,
- &transform,
- renderMode,
- DWRITE_MEASURING_MODE_NATURAL,
- 0.0, 0.0,
- &glyphAnalysis
- );
-
- if (SUCCEEDED(hr)) {
- RECT rect;
- glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
-
- QRect boundingRect = QRect(QPoint(rect.left - margin,
- rect.top - margin),
- QPoint(rect.right + margin,
- rect.bottom + margin));
-
-
- const int width = boundingRect.width() - 1; // -1 due to Qt's off-by-one definition of a QRect
- const int height = boundingRect.height() - 1;
-
- QImage image;
-#if defined(QT_USE_DIRECTWRITE2)
- HRESULT hr = DWRITE_E_NOCOLOR;
- IDWriteColorGlyphRunEnumerator *enumerator = 0;
- IDWriteFactory2 *factory2 = Q_NULLPTR;
- if (glyphFormat == QFontEngine::Format_ARGB
- && SUCCEEDED(m_fontEngineData->directWriteFactory->QueryInterface(__uuidof(IDWriteFactory2),
- reinterpret_cast<void **>(&factory2)))) {
- hr = factory2->TranslateColorGlyphRun(0.0f,
- 0.0f,
- &glyphRun,
- NULL,
- DWRITE_MEASURING_MODE_NATURAL,
- NULL,
- 0,
- &enumerator);
- image = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
- image.fill(0);
- } else
-#endif
- {
- image = QImage(width, height, QImage::Format_RGB32);
- image.fill(0xffffffff);
- }
-
-#if defined(QT_USE_DIRECTWRITE2)
- BOOL ok = true;
- if (SUCCEEDED(hr)) {
- while (SUCCEEDED(hr) && ok) {
- const DWRITE_COLOR_GLYPH_RUN *colorGlyphRun = 0;
- hr = enumerator->GetCurrentRun(&colorGlyphRun);
- if (FAILED(hr)) { // No colored runs, only outline
- qErrnoWarning(hr, "%s: IDWriteColorGlyphRunEnumerator::GetCurrentRun failed", __FUNCTION__);
- break;
- }
-
- IDWriteGlyphRunAnalysis *colorGlyphsAnalysis = NULL;
- hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
- &colorGlyphRun->glyphRun,
- 1.0f,
- &transform,
- renderMode,
- DWRITE_MEASURING_MODE_NATURAL,
- 0.0, 0.0,
- &colorGlyphsAnalysis
- );
- if (FAILED(hr)) {
- qErrnoWarning(hr, "%s: CreateGlyphRunAnalysis failed for color run", __FUNCTION__);
- break;
- }
-
- float r = qBound(0.0f, colorGlyphRun->runColor.r, 1.0f);
- float g = qBound(0.0f, colorGlyphRun->runColor.g, 1.0f);
- float b = qBound(0.0f, colorGlyphRun->runColor.b, 1.0f);
- float a = qBound(0.0f, colorGlyphRun->runColor.a, 1.0f);
-
- if (!qFuzzyIsNull(a)) {
- renderGlyphRun(&image,
- r,
- g,
- b,
- a,
- colorGlyphsAnalysis,
- boundingRect);
- }
- colorGlyphsAnalysis->Release();
-
- hr = enumerator->MoveNext(&ok);
- if (FAILED(hr)) {
- qErrnoWarning(hr, "%s: IDWriteColorGlyphRunEnumerator::MoveNext failed", __FUNCTION__);
- break;
- }
- }
- } else
-#endif
- {
- renderGlyphRun(&image,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- glyphAnalysis,
- boundingRect);
- }
-
- glyphAnalysis->Release();
- return image;
- } else {
- qErrnoWarning(hr, "%s: CreateGlyphRunAnalysis failed", __FUNCTION__);
- return QImage();
- }
-}
-
-
-void QWindowsFontEngineDirectWrite::renderGlyphRun(QImage *destination,
- float r,
- float g,
- float b,
- float a,
- IDWriteGlyphRunAnalysis *glyphAnalysis,
- const QRect &boundingRect)
-{
- const int width = destination->width();
- const int height = destination->height();
-
- r *= 255.0;
- g *= 255.0;
- b *= 255.0;
-
- const int size = width * height * 3;
- if (size > 0) {
- RECT rect;
- rect.left = boundingRect.left();
- rect.top = boundingRect.top();
- rect.right = boundingRect.right();
- rect.bottom = boundingRect.bottom();
-
- QVarLengthArray<BYTE, 1024> alphaValueArray(size);
- BYTE *alphaValues = alphaValueArray.data();
- memset(alphaValues, 0, size);
-
- HRESULT hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1,
- &rect,
- alphaValues,
- size);
- if (SUCCEEDED(hr)) {
- if (destination->hasAlphaChannel()) {
- for (int y = 0; y < height; ++y) {
- uint *dest = reinterpret_cast<uint *>(destination->scanLine(y));
- BYTE *src = alphaValues + width * 3 * y;
-
- for (int x = 0; x < width; ++x) {
- float redAlpha = a * *src++ / 255.0;
- float greenAlpha = a * *src++ / 255.0;
- float blueAlpha = a * *src++ / 255.0;
- float averageAlpha = (redAlpha + greenAlpha + blueAlpha) / 3.0;
-
- QRgb currentRgb = dest[x];
- dest[x] = qRgba(qRound(qRed(currentRgb) * (1.0 - averageAlpha) + averageAlpha * r),
- qRound(qGreen(currentRgb) * (1.0 - averageAlpha) + averageAlpha * g),
- qRound(qBlue(currentRgb) * (1.0 - averageAlpha) + averageAlpha * b),
- qRound(qAlpha(currentRgb) * (1.0 - averageAlpha) + averageAlpha * 255));
- }
- }
-
- } else {
- for (int y = 0; y < height; ++y) {
- uint *dest = reinterpret_cast<uint *>(destination->scanLine(y));
- BYTE *src = alphaValues + width * 3 * y;
-
- for (int x = 0; x < width; ++x) {
- dest[x] = *(src + 0) << 16
- | *(src + 1) << 8
- | *(src + 2);
-
- src += 3;
- }
- }
- }
- } else {
- qErrnoWarning("%s: CreateAlphaTexture failed", __FUNCTION__);
- }
- } else {
- glyphAnalysis->Release();
- qWarning("%s: Glyph has no bounds", __FUNCTION__);
- }
-}
-
-QImage QWindowsFontEngineDirectWrite::alphaRGBMapForGlyph(glyph_t t,
- QFixed subPixelPosition,
- const QTransform &xform)
-{
- QImage mask = imageForGlyph(t,
- subPixelPosition,
- glyphMargin(QFontEngine::Format_A32),
- xform);
-
- return mask.depth() == 32
- ? mask
- : mask.convertToFormat(QImage::Format_RGB32);
-}
-
-QFontEngine *QWindowsFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const
-{
- QWindowsFontEngineDirectWrite *fontEngine = new QWindowsFontEngineDirectWrite(m_directWriteFontFace,
- pixelSize,
- m_fontEngineData);
-
- fontEngine->fontDef = fontDef;
- fontEngine->fontDef.pixelSize = pixelSize;
- if (!m_uniqueFamilyName.isEmpty()) {
- fontEngine->setUniqueFamilyName(m_uniqueFamilyName);
- QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
- static_cast<QWindowsFontDatabase *>(pfdb)->refUniqueFont(m_uniqueFamilyName);
- }
-
- return fontEngine;
-}
-
-Qt::HANDLE QWindowsFontEngineDirectWrite::handle() const
-{
- return m_directWriteFontFace;
-}
-
-void QWindowsFontEngineDirectWrite::initFontInfo(const QFontDef &request,
- int dpi)
-{
- fontDef = request;
-
- if (fontDef.pointSize < 0)
- fontDef.pointSize = fontDef.pixelSize * 72. / dpi;
- else if (fontDef.pixelSize == -1)
- fontDef.pixelSize = qRound(fontDef.pointSize * dpi / 72.);
-}
-
-QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyName)
-{
- static const char keyC[] = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\"
- "FontSubstitutes";
- return QSettings(QLatin1String(keyC), QSettings::NativeFormat).value(familyName, familyName).toString();
-}
-
-glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph,
- QFixed subPixelPosition,
- const QTransform &originalTransform,
- GlyphFormat format)
-{
- Q_UNUSED(format);
-
- QTransform matrix = originalTransform;
- if (fontDef.stretch != 100)
- matrix.scale(fontDef.stretch / 100.0, 1.0);
-
- glyph_metrics_t bbox = QFontEngine::boundingBox(glyph, matrix); // To get transformed advance
-
- UINT16 glyphIndex = glyph;
- FLOAT glyphAdvance = 0;
-
- DWRITE_GLYPH_OFFSET glyphOffset;
- glyphOffset.advanceOffset = 0;
- glyphOffset.ascenderOffset = 0;
-
- DWRITE_GLYPH_RUN glyphRun;
- glyphRun.fontFace = m_directWriteFontFace;
- glyphRun.fontEmSize = fontDef.pixelSize;
- glyphRun.glyphCount = 1;
- glyphRun.glyphIndices = &glyphIndex;
- glyphRun.glyphAdvances = &glyphAdvance;
- glyphRun.isSideways = false;
- glyphRun.bidiLevel = 0;
- glyphRun.glyphOffsets = &glyphOffset;
-
- DWRITE_MATRIX transform;
- transform.dx = subPixelPosition.toReal();
- transform.dy = 0;
- transform.m11 = matrix.m11();
- transform.m12 = matrix.m12();
- transform.m21 = matrix.m21();
- transform.m22 = matrix.m22();
-
- DWRITE_RENDERING_MODE renderMode =
- fontDef.hintingPreference == QFont::PreferNoHinting
- ? DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
- : DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
-
- IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
- HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
- &glyphRun,
- 1.0f,
- &transform,
- renderMode,
- DWRITE_MEASURING_MODE_NATURAL,
- 0.0, 0.0,
- &glyphAnalysis
- );
-
- if (SUCCEEDED(hr)) {
- RECT rect;
- glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
- glyphAnalysis->Release();
-
- int margin = glyphMargin(QFontEngine::Format_A32);
-
- return glyph_metrics_t(rect.left,
- rect.top,
- rect.right - rect.left + margin * 2,
- rect.bottom - rect.top + margin * 2,
- bbox.xoff, bbox.yoff);
- } else {
- return glyph_metrics_t();
- }
-}
-
-QImage QWindowsFontEngineDirectWrite::bitmapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
-{
- return imageForGlyph(glyph, subPixelPosition, glyphMargin(QFontEngine::Format_A32), t);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DIRECTWRITE
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
deleted file mode 100644
index 37e511ce3e..0000000000
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSFONTENGINEDIRECTWRITE_H
-#define QWINDOWSFONTENGINEDIRECTWRITE_H
-
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_DIRECTWRITE
-
-#include <QtGui/private/qfontengine_p.h>
-#include <QtCore/QSharedPointer>
-
-struct IDWriteFont;
-struct IDWriteFontFace;
-struct IDWriteFactory;
-struct IDWriteBitmapRenderTarget;
-struct IDWriteGdiInterop;
-struct IDWriteGlyphRunAnalysis;
-
-QT_BEGIN_NAMESPACE
-
-class QWindowsFontEngineData;
-
-class QWindowsFontEngineDirectWrite : public QFontEngine
-{
-public:
- explicit QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace,
- qreal pixelSize,
- const QSharedPointer<QWindowsFontEngineData> &d);
- ~QWindowsFontEngineDirectWrite();
-
- void initFontInfo(const QFontDef &request, int dpi);
-
- QFixed lineThickness() const Q_DECL_OVERRIDE;
- QFixed underlinePosition() const Q_DECL_OVERRIDE;
- bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE;
- QFixed emSquareSize() const Q_DECL_OVERRIDE;
-
- glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
- bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
- ShaperFlags flags) const Q_DECL_OVERRIDE;
- void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const Q_DECL_OVERRIDE;
-
- void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
- QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
-
- glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
- glyph_metrics_t boundingBox(glyph_t g) Q_DECL_OVERRIDE;
- glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed,
- const QTransform &matrix, GlyphFormat) Q_DECL_OVERRIDE;
-
- QFixed ascent() const Q_DECL_OVERRIDE;
- QFixed descent() const Q_DECL_OVERRIDE;
- QFixed leading() const Q_DECL_OVERRIDE;
- QFixed xHeight() const Q_DECL_OVERRIDE;
- qreal maxCharWidth() const Q_DECL_OVERRIDE;
-
- bool supportsSubPixelPositions() const Q_DECL_OVERRIDE;
-
- QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition) Q_DECL_OVERRIDE;
- QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
- QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, const QTransform &xform) Q_DECL_OVERRIDE;
- QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
-
- QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
- Qt::HANDLE handle() const Q_DECL_OVERRIDE;
-
- const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; }
-
- static QString fontNameSubstitute(const QString &familyName);
-
- IDWriteFontFace *directWriteFontFace() const { return m_directWriteFontFace; }
-
- void setUniqueFamilyName(const QString &newName) { m_uniqueFamilyName = newName; }
-
-private:
- QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
- void collectMetrics();
- void renderGlyphRun(QImage *destination, float r, float g, float b, float a, IDWriteGlyphRunAnalysis *glyphAnalysis, const QRect &boundingRect);
-
- const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
-
- IDWriteFontFace *m_directWriteFontFace;
- IDWriteBitmapRenderTarget *m_directWriteBitmapRenderTarget;
-
- QFixed m_lineThickness;
- QFixed m_underlinePosition;
- int m_unitsPerEm;
- QFixed m_ascent;
- QFixed m_descent;
- QFixed m_xHeight;
- QFixed m_lineGap;
- FaceId m_faceId;
- QString m_uniqueFamilyName;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DIRECTWRITE
-
-#endif // QWINDOWSFONTENGINEDIRECTWRITE_H
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 0a2d30319e..c1eb664324 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -149,15 +149,9 @@ QT_BEGIN_NAMESPACE
QWindowsOpengl32DLL QOpenGLStaticContext::opengl32;
-PROC QWindowsOpengl32DLL::resolve(const char *name)
+FARPROC QWindowsOpengl32DLL::resolve(const char *name)
{
-#ifndef Q_OS_WINCE
- PROC proc = m_lib ? ::GetProcAddress(m_lib, name) : 0;
-#else
- PROC proc = m_lib ? ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0;
-#endif
-
- return proc;
+ return m_lib ? ::GetProcAddress(m_lib, name) : nullptr;
}
bool QWindowsOpengl32DLL::init(bool softwareRendering)
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h
index 2944ab7192..4c804a612e 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.h
+++ b/src/plugins/platforms/windows/qwindowsglcontext.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSGLCONTEXT_H
#define QWINDOWSGLCONTEXT_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include "qwindowsopenglcontext.h"
#include <QtGui/QOpenGLContext>
@@ -122,7 +122,7 @@ struct QWindowsOpengl32DLL
void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params);
const GLubyte * (APIENTRY * glGetString)(GLenum name);
- PROC resolve(const char *name);
+ FARPROC resolve(const char *name);
private:
HMODULE m_lib;
bool m_nonOpengl32;
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index 501b956a68..8adbd494c4 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -190,11 +190,7 @@ bool QWindowsInputContext::hasCapability(Capability capability) const
{
switch (capability) {
case QPlatformInputContext::HiddenTextCapability:
-#ifndef Q_OS_WINCE
return false; // QTBUG-40691, do not show IME on desktop for password entry fields.
-#else
- break; // Windows CE: Show software keyboard.
-#endif
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.h b/src/plugins/platforms/windows/qwindowsinputcontext.h
index 4c08fa0ef2..a7fa2c4f94 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.h
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSINPUTCONTEXT_H
#define QWINDOWSINPUTCONTEXT_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QLocale>
#include <QtCore/QPointer>
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index b6d2c16f89..004b03d9a9 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -47,9 +47,8 @@
#include "qwindowstheme.h"
#include "qwindowsservices.h"
#ifndef QT_NO_FREETYPE
-# include "qwindowsfontdatabase_ft.h"
+# include <QtFontDatabaseSupport/private/qwindowsfontdatabase_ft_p.h>
#endif
-#include "qwindowsfontdatabase.h"
#ifndef QT_NO_CLIPBOARD
# include "qwindowsclipboard.h"
# ifndef QT_NO_DRAGANDDROP
@@ -64,7 +63,7 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qwindowsysteminterface.h>
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#ifndef QT_NO_SESSIONMANAGER
# include "qwindowssessionmanager.h"
#endif
#include <QtGui/qtouchdevice.h>
@@ -72,7 +71,7 @@
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/qpa/qplatforminputcontextfactory_p.h>
-#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
#include <QtCore/QDebug>
#include <QtCore/QVariant>
@@ -102,7 +101,7 @@ QT_BEGIN_NAMESPACE
It should compile with:
\list
- \li Microsoft Visual Studio 2008 or later (using the Microsoft Windows SDK,
+ \li Microsoft Visual Studio 2013 or later (using the Microsoft Windows SDK,
(\c Q_CC_MSVC).
\li Stock \l{http://mingw.org/}{MinGW} (\c Q_CC_MINGW).
This version ships with headers that are missing a lot of WinAPI.
@@ -112,15 +111,8 @@ QT_BEGIN_NAMESPACE
(\c Q_CC_MINGW and \c __MINGW64_VERSION_MAJOR indicating the version).
MinGW-w64 provides more complete headers (compared to stock MinGW from mingw.org),
including a considerable part of the Windows SDK.
- \li Visual Studio 2008 for Windows Embedded (\c Q_OS_WINCE).
\endlist
- The file \c qtwindows_additional.h contains defines and declarations that
- are missing in MinGW. When encountering missing declarations, it should
- be added there so that \c #ifdefs for MinGW can be avoided. Similarly,
- \c qplatformfunctions_wince.h contains defines and declarations for
- Windows Embedded.
-
When using a function from the WinAPI, the minimum supported Windows version
and Windows Embedded support should be checked. If the function is not supported
on Windows XP or is not present in the MinGW-headers, it should be dynamically
@@ -219,9 +211,7 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
: m_options(0)
, m_fontDatabase(0)
{
-#ifndef Q_OS_WINCE
Q_INIT_RESOURCE(openglblacklists);
-#endif
static bool dpiAwarenessSet = false;
int tabletAbsoluteRange = -1;
@@ -229,6 +219,7 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
// are connected to Windows 8.1
QtWindows::ProcessDpiAwareness dpiAwareness = QtWindows::ProcessPerMonitorDpiAware;
m_options = parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness);
+ QWindowsFontDatabase::setFontOptions(m_options);
if (tabletAbsoluteRange >= 0)
m_context.setTabletAbsoluteRange(tabletAbsoluteRange);
if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication.
@@ -483,46 +474,16 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext()
}
#endif // !QT_NO_OPENGL
-/* Workaround for QTBUG-24205: In 'Auto', pick the FreeType engine for
- * QML2 applications. */
-
-#ifdef Q_OS_WINCE
-// It's not easy to detect if we are running a QML application
-// Let's try to do so by checking if the Qt Quick module is loaded.
-inline bool isQMLApplication()
-{
- // check if the Qt Quick module is loaded
-#ifdef _DEBUG
- HMODULE handle = GetModuleHandle(L"Qt5Quick" QT_LIBINFIX L"d.dll");
-#else
- HMODULE handle = GetModuleHandle(L"Qt5Quick" QT_LIBINFIX L".dll");
-#endif
- return (handle != NULL);
-}
-#endif
-
QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const
{
if (!d->m_fontDatabase) {
#ifdef QT_NO_FREETYPE
d->m_fontDatabase = new QWindowsFontDatabase();
#else // QT_NO_FREETYPE
- if (d->m_options & QWindowsIntegration::FontDatabaseFreeType) {
+ if (d->m_options & QWindowsIntegration::FontDatabaseFreeType)
d->m_fontDatabase = new QWindowsFontDatabaseFT;
- } else if (d->m_options & QWindowsIntegration::FontDatabaseNative){
- d->m_fontDatabase = new QWindowsFontDatabase;
- } else {
-#ifndef Q_OS_WINCE
+ else
d->m_fontDatabase = new QWindowsFontDatabase;
-#else
- if (isQMLApplication()) {
- qCDebug(lcQpaFonts) << "QML application detected, using FreeType rendering";
- d->m_fontDatabase = new QWindowsFontDatabaseFT;
- }
- else
- d->m_fontDatabase = new QWindowsFontDatabase;
-#endif
- }
#endif // QT_NO_FREETYPE
}
return d->m_fontDatabase;
@@ -610,7 +571,7 @@ unsigned QWindowsIntegration::options() const
return d->m_options;
}
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
QPlatformSessionManager *QWindowsIntegration::createPlatformSessionManager(const QString &id, const QString &key) const
{
return new QWindowsSessionManager(id, key);
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index 0c03274799..a668470993 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -43,6 +43,7 @@
#include <qpa/qplatformintegration.h>
#include <QtCore/QScopedPointer>
+#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h>
QT_BEGIN_NAMESPACE
@@ -61,8 +62,9 @@ public:
NoNativeDialogs = 0x8,
XpNativeDialogs = 0x10,
DontPassOsMouseEventsSynthesizedFromTouch = 0x20, // Do not pass OS-generated mouse events from touch.
- DontUseDirectWriteFonts = 0x40,
- DontUseColorFonts = 0x80
+ // Keep in sync with QWindowsFontDatabase::FontOptions
+ DontUseDirectWriteFonts = QWindowsFontDatabase::DontUseDirectWriteFonts,
+ DontUseColorFonts = QWindowsFontDatabase::DontUseColorFonts
};
explicit QWindowsIntegration(const QStringList &paramList);
@@ -106,7 +108,7 @@ public:
void beep() const Q_DECL_OVERRIDE;
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE;
#endif
diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp
index 2dfe7fc5f9..21ebee6262 100644
--- a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp
+++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp
@@ -39,7 +39,6 @@
#include "qwindowsinternalmimedata.h"
#include "qwindowscontext.h"
-#include "qplatformfunctions_wince.h"
#include "qwindowsmime.h"
#include <QDebug>
/*!
diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h
index 4ac7a303af..4d775b1f21 100644
--- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h
+++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSINTERNALMIME_H
#define QWINDOWSINTERNALMIME_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtGui/private/qdnd_p.h> // QInternalMime
#include <QtCore/QVariant>
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 1afce9cde9..b8c4f0b736 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -49,7 +49,7 @@
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
#include <QtGui/QKeyEvent>
-#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
+#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
#if defined(WM_APPCOMMAND)
# ifndef FAPPCOMMAND_MOUSE
@@ -553,34 +553,6 @@ inline quint32 winceKeyBend(quint32 keyCode)
return KeyTbl[keyCode];
}
-#ifdef Q_OS_WINCE
-QT_BEGIN_INCLUDE_NAMESPACE
-int ToUnicode(UINT vk, int /*scancode*/, unsigned char* /*kbdBuffer*/, LPWSTR unicodeBuffer, int, int)
-{
- QT_USE_NAMESPACE
- QChar* buf = reinterpret_cast< QChar*>(unicodeBuffer);
- if (KeyTbl[vk] == 0) {
- buf[0] = vk;
- return 1;
- }
- return 0;
-}
-
-int ToAscii(UINT vk, int scancode, unsigned char *kbdBuffer, LPWORD unicodeBuffer, int flag)
-{
- return ToUnicode(vk, scancode, kbdBuffer, (LPWSTR) unicodeBuffer, 0, flag);
-
-}
-
-bool GetKeyboardState(unsigned char* kbuffer)
-{
- for (int i=0; i< 256; ++i)
- kbuffer[i] = GetAsyncKeyState(i);
- return true;
-}
-QT_END_INCLUDE_NAMESPACE
-#endif // Q_OS_WINCE
-
// Translate a VK into a Qt key code, or unicode character
static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0)
{
@@ -781,7 +753,6 @@ static void showSystemMenu(QWindow* w)
if (!menu)
return; // no menu for this window
-#ifndef Q_OS_WINCE
#define enabled (MF_BYCOMMAND | MF_ENABLED)
#define disabled (MF_BYCOMMAND | MF_GRAYED)
@@ -806,7 +777,6 @@ static void showSystemMenu(QWindow* w)
#undef enabled
#undef disabled
-#endif // !Q_OS_WINCE
const QPoint pos = QHighDpi::toNativePixels(topLevel->geometry().topLeft(), topLevel);
const int ret = TrackPopupMenuEx(menu,
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD,
@@ -1188,7 +1158,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
modifiers, scancode, quint32(msg.wParam), nModifiers, text, false);
result =true;
bool store = true;
-#ifndef Q_OS_WINCE
// Alt+<alphanumerical> go to the Win32 menu system if unhandled by Qt
if (msgType == WM_SYSKEYDOWN && !result && a) {
HWND parent = GetParent(QWindowsWindow::handleOf(receiver));
@@ -1202,7 +1171,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
parent = GetParent(parent);
}
}
-#endif // !Q_OS_WINCE
if (!store)
key_recorder.findKey(int(msg.wParam), true);
}
@@ -1232,7 +1200,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
nModifiers,
(rec ? rec->text : QString()), false);
result = true;
-#ifndef Q_OS_WINCE
// don't pass Alt to Windows unless we are embedded in a non-Qt window
if (code == Qt::Key_Alt) {
const QWindowsContext *context = QWindowsContext::instance();
@@ -1245,7 +1212,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
parent = GetParent(parent);
}
}
-#endif
}
}
return result;
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h
index 1e32ddabcc..2657644780 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.h
+++ b/src/plugins/platforms/windows/qwindowskeymapper.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSKEYMAPPER_H
#define QWINDOWSKEYMAPPER_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QLocale>
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index b86972996c..30d438a127 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -403,11 +403,9 @@ QDebug operator<<(QDebug d, const FORMATETC &tc)
case CF_UNICODETEXT:
d << "CF_UNICODETEXT";
break;
-#ifndef Q_OS_WINCE
case CF_ENHMETAFILE:
d << "CF_ENHMETAFILE";
break;
-#endif // !Q_OS_WINCE
default:
d << QWindowsMimeConverter::clipboardFormatName(tc.cfFormat);
break;
diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h
index b727f13747..4c0cbf9f31 100644
--- a/src/plugins/platforms/windows/qwindowsmime.h
+++ b/src/plugins/platforms/windows/qwindowsmime.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSMIME_H
#define QWINDOWSMIME_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QVector>
#include <QtCore/QList>
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index b92387d397..3f6230172e 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -56,6 +56,37 @@
#include <windowsx.h>
+/* Touch is supported from Windows 7 onwards and data structures
+ * are present in the Windows SDK's, but not in older MSVC Express
+ * versions. */
+
+#if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
+
+typedef struct tagTOUCHINPUT {
+ LONG x;
+ LONG y;
+ HANDLE hSource;
+ DWORD dwID;
+ DWORD dwFlags;
+ DWORD dwMask;
+ DWORD dwTime;
+ ULONG_PTR dwExtraInfo;
+ DWORD cxContact;
+ DWORD cyContact;
+} TOUCHINPUT, *PTOUCHINPUT;
+typedef TOUCHINPUT const * PCTOUCHINPUT;
+
+# define TOUCHEVENTF_MOVE 0x0001
+# define TOUCHEVENTF_DOWN 0x0002
+# define TOUCHEVENTF_UP 0x0004
+# define TOUCHEVENTF_INRANGE 0x0008
+# define TOUCHEVENTF_PRIMARY 0x0010
+# define TOUCHEVENTF_NOCOALESCE 0x0020
+# define TOUCHEVENTF_PALM 0x0080
+# define TOUCHINPUTMASKF_CONTACTAREA 0x0004
+# define TOUCHINPUTMASKF_EXTRAINFO 0x0002
+#endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
+
QT_BEGIN_NAMESPACE
static inline void compressMouseMove(MSG *msg)
@@ -203,7 +234,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
-#ifndef Q_OS_WINCE
// Check for events synthesized from touch. Lower byte is touch index, 0 means pen.
static const bool passSynthesizedMouseEvents =
!(QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch);
@@ -218,7 +248,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
return false;
}
}
-#endif // !Q_OS_WINCE
const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam));
if (et & QtWindows::NonClientEventFlag) {
@@ -320,7 +349,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
const bool hasCapture = platformWindow->hasMouseCapture();
const bool currentNotCapturing = hasCapture && currentWindowUnderMouse != window;
-#ifndef Q_OS_WINCE
// Enter new window: track to generate leave event.
// If there is an active capture, only track if the current window is capturing,
// so we don't get extra leave when cursor leaves the application.
@@ -334,7 +362,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
qWarning("TrackMouseEvent failed.");
m_trackedWindow = window;
}
-#endif // !Q_OS_WINCE
// No enter or leave events are sent as long as there is an autocapturing window.
if (!hasCapture || !platformWindow->testFlag(QWindowsWindow::AutoMouseCapture)) {
@@ -489,7 +516,6 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
-#ifndef Q_OS_WINCE
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
@@ -565,109 +591,17 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QWindowSystemInterface::handleTouchEvent(window,
m_touchDevice,
touchPoints);
-#else // !Q_OS_WINCE
- Q_UNUSED(window)
- Q_UNUSED(msg)
-#endif
return true;
-
}
bool QWindowsMouseHandler::translateGestureEvent(QWindow *window, HWND hwnd,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
-#ifndef Q_OS_WINCE
Q_UNUSED(window)
Q_UNUSED(hwnd)
Q_UNUSED(msg)
return false;
-#else // !Q_OS_WINCE
- GESTUREINFO gi;
- memset(&gi, 0, sizeof(GESTUREINFO));
- gi.cbSize = sizeof(GESTUREINFO);
-
- if (!GetGestureInfo((HGESTUREINFO)msg.lParam, &gi))
- return false;
-
- const QPoint position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
-
- if (gi.dwID != GID_DIRECTMANIPULATION)
- return true;
- static QPoint lastTouchPos;
- const QScreen *screen = window->screen();
- if (!screen)
- screen = QGuiApplication::primaryScreen();
- if (!screen)
- return true;
- const QRect screenGeometry = screen->geometry();
- QWindowSystemInterface::TouchPoint touchPoint;
- static QWindowSystemInterface::TouchPoint touchPoint2;
- touchPoint.id = 0;//gi.dwInstanceID;
- touchPoint.pressure = 1.0;
-
- if (gi.dwFlags & GF_BEGIN)
- touchPoint.state = Qt::TouchPointPressed;
- else if (gi.dwFlags & GF_END)
- touchPoint.state = Qt::TouchPointReleased;
- else if (gi.dwFlags == 0)
- touchPoint.state = Qt::TouchPointMoved;
- else
- return true;
- touchPoint2.pressure = 1.0;
- touchPoint2.id = 1;
- const QPoint winEventPosition = position;
- const int deltaX = GID_DIRECTMANIPULATION_DELTA_X(gi.ullArguments);
- const int deltaY = GID_DIRECTMANIPULATION_DELTA_Y(gi.ullArguments);
- //Touch points are taken from the whole screen so map the position to the screen
- const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition);
- const QPoint globalPosition2 = QWindowsGeometryHint::mapToGlobal(hwnd, QPoint(position.x() + deltaX, position.y() + deltaY));
-
- touchPoint.normalPosition =
- QPointF( (qreal)globalPosition.x() / screenGeometry.width(), (qreal)globalPosition.y() / screenGeometry.height() );
-
- touchPoint.area.moveCenter(globalPosition);
-
- QList<QWindowSystemInterface::TouchPoint> pointList;
- pointList.append(touchPoint);
- if (deltaX != 0 && deltaY != 0) {
- touchPoint2.state = m_had2ndTouchPoint ? Qt::TouchPointMoved : Qt::TouchPointPressed;
- m_had2ndTouchPoint = true;
- touchPoint2.normalPosition =
- QPointF( (qreal)globalPosition2.x() / screenGeometry.width(), (qreal)globalPosition2.y() / screenGeometry.height() );
-
- touchPoint2.area.moveCenter(globalPosition2);
- lastTouchPos = globalPosition2;
- pointList.append(touchPoint2);
- } else if (m_had2ndTouchPoint) {
- touchPoint2.normalPosition =
- QPointF( (qreal)lastTouchPos.x() / screenGeometry.width(), (qreal)lastTouchPos.y() / screenGeometry.height() );
-
- touchPoint2.area.moveCenter(lastTouchPos);
- touchPoint2.state = Qt::TouchPointReleased;
- pointList.append(touchPoint2);
- m_had2ndTouchPoint = false;
- }
-
- if (!m_touchDevice) {
- m_touchDevice = new QTouchDevice;
- // TODO: Device used to be hardcoded to screen in previous code.
- m_touchDevice->setType(QTouchDevice::TouchScreen);
- m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
- }
-
- QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, pointList);
- // handle window focusing in/out
- if (window != m_windowUnderMouse) {
- if (m_windowUnderMouse)
- QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse);
- if (window)
- QWindowSystemInterface::handleEnterEvent(window);
- m_windowUnderMouse = window;
- }
- return true;
-#endif // Q_OS_WINCE
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h
index d16c9f9e02..bd36d9f44c 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.h
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.h
@@ -41,7 +41,7 @@
#define QWINDOWSMOUSEHANDLER_H
#include "qtwindowsglobal.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QPointer>
#include <QtCore/QHash>
@@ -91,10 +91,6 @@ private:
QTouchDevice *m_touchDevice;
bool m_leftButtonDown;
QWindow *m_previousCaptureWindow;
-#ifdef Q_OS_WINCE
-//This is required to send a touch up if we don't get a second touch position any more
- bool m_had2ndTouchPoint;
-#endif
};
Qt::MouseButtons QWindowsMouseHandler::keyStateToMouseButtons(int wParam)
diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.cpp b/src/plugins/platforms/windows/qwindowsnativeimage.cpp
deleted file mode 100644
index bc8bfda32b..0000000000
--- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsnativeimage.h"
-#include "qwindowscontext.h"
-
-#include <QtGui/private/qpaintengine_p.h>
-#include <QtGui/private/qpaintengine_raster_p.h>
-
-QT_BEGIN_NAMESPACE
-
-typedef struct {
- BITMAPINFOHEADER bmiHeader;
- DWORD redMask;
- DWORD greenMask;
- DWORD blueMask;
-} BITMAPINFO_MASK;
-
-/*!
- \class QWindowsNativeImage
- \brief Windows Native image
-
- Note that size can be 0 (widget autotests with zero size), which
- causes CreateDIBSection() to fail.
-
- \sa QWindowsBackingStore
- \internal
- \ingroup qt-lighthouse-win
-*/
-
-static inline HDC createDC()
-{
- HDC display_dc = GetDC(0);
- HDC hdc = CreateCompatibleDC(display_dc);
- ReleaseDC(0, display_dc);
- Q_ASSERT(hdc);
- return hdc;
-}
-
-static inline HBITMAP createDIB(HDC hdc, int width, int height,
- QImage::Format format,
- uchar **bitsIn)
-{
- BITMAPINFO_MASK bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = width;
- bmi.bmiHeader.biHeight = -height; // top-down.
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biSizeImage = 0;
-
- if (format == QImage::Format_RGB16) {
- bmi.bmiHeader.biBitCount = 16;
- bmi.bmiHeader.biCompression = BI_BITFIELDS;
- bmi.redMask = 0xF800;
- bmi.greenMask = 0x07E0;
- bmi.blueMask = 0x001F;
- } else {
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.redMask = 0;
- bmi.greenMask = 0;
- bmi.blueMask = 0;
- }
-
- uchar *bits = Q_NULLPTR;
- HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi),
- DIB_RGB_COLORS, reinterpret_cast<void **>(&bits), 0, 0);
- if (Q_UNLIKELY(!bitmap || !bits))
- qFatal("%s: CreateDIBSection failed.", __FUNCTION__);
-
- *bitsIn = bits;
- return bitmap;
-}
-
-QWindowsNativeImage::QWindowsNativeImage(int width, int height,
- QImage::Format format) :
- m_hdc(createDC()),
- m_bitmap(0),
- m_null_bitmap(0)
-{
- if (width != 0 && height != 0) {
- uchar *bits;
- m_bitmap = createDIB(m_hdc, width, height, format, &bits);
- m_null_bitmap = static_cast<HBITMAP>(SelectObject(m_hdc, m_bitmap));
- m_image = QImage(bits, width, height, format);
- Q_ASSERT(m_image.paintEngine()->type() == QPaintEngine::Raster);
- static_cast<QRasterPaintEngine *>(m_image.paintEngine())->setDC(m_hdc);
- } else {
- m_image = QImage(width, height, format);
- }
-
-#ifndef Q_OS_WINCE
- GdiFlush();
-#endif
-}
-
-QWindowsNativeImage::~QWindowsNativeImage()
-{
- if (m_hdc) {
- if (m_bitmap) {
- if (m_null_bitmap)
- SelectObject(m_hdc, m_null_bitmap);
- DeleteObject(m_bitmap);
- }
- DeleteDC(m_hdc);
- }
-}
-
-QImage::Format QWindowsNativeImage::systemFormat()
-{
- static const int depth = QWindowsContext::instance()->screenDepth();
- return depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index e0ae111b9a..eaa6e45b9f 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -41,7 +41,6 @@
#include "qwindowswindow.h"
#include "qwindowscontext.h"
#include "qwindowscursor.h"
-#include "qwindowsfontdatabase.h"
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
@@ -51,6 +50,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QScreen>
#include <qpa/qplatformscreen.h>
+#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsole.h b/src/plugins/platforms/windows/qwindowsole.h
index 009111e55c..dc31c793e9 100644
--- a/src/plugins/platforms/windows/qwindowsole.h
+++ b/src/plugins/platforms/windows/qwindowsole.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSOLE_H
#define QWINDOWSOLE_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QMap>
#include <QtCore/QPointer>
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index c24e0ba0ae..5283d6b260 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -54,17 +54,14 @@
#include <private/qopengl_p.h>
#endif
-#ifndef Q_OS_WINCE
-# include <QtCore/qt_windows.h>
-# include <private/qsystemlibrary_p.h>
-# include <d3d9.h>
-#endif
+#include <QtCore/qt_windows.h>
+#include <private/qsystemlibrary_p.h>
+#include <d3d9.h>
QT_BEGIN_NAMESPACE
GpuDescription GpuDescription::detect()
{
-#ifndef Q_OS_WINCE
typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT);
GpuDescription result;
@@ -95,13 +92,6 @@ GpuDescription GpuDescription::detect()
result.description = adapterIdentifier.Description;
}
return result;
-#else // !Q_OS_WINCE
- GpuDescription result;
- result.vendorId = result.deviceId = result.revision =1;
- result.driverVersion = QVersionNumber(1, 1, 1);
- result.driverName = result.description = QByteArrayLiteral("Generic");
- return result;
-#endif
}
#ifndef QT_NO_DEBUG_STREAM
@@ -155,7 +145,6 @@ QVariant GpuDescription::toVariant() const
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer()
{
-#ifndef Q_OS_WINCE
const char platformVar[] = "QT_ANGLE_PLATFORM";
if (qEnvironmentVariableIsSet(platformVar)) {
const QByteArray anglePlatform = qgetenv(platformVar);
@@ -167,13 +156,11 @@ QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer()
return QWindowsOpenGLTester::AngleRendererD3d11Warp;
qCWarning(lcQpaGl) << "Invalid value set for " << platformVar << ": " << anglePlatform;
}
-#endif // !Q_OS_WINCE
return QWindowsOpenGLTester::InvalidRenderer;
}
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer()
{
-#ifndef Q_OS_WINCE
const char openGlVar[] = "QT_OPENGL";
if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) {
const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer();
@@ -195,12 +182,9 @@ QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer()
return QWindowsOpenGLTester::SoftwareRasterizer;
qCWarning(lcQpaGl) << "Invalid value set for " << openGlVar << ": " << requested;
}
-#endif // !Q_OS_WINCE
return QWindowsOpenGLTester::InvalidRenderer;
}
-#ifndef Q_OS_WINCE
-
static inline QString resolveBugListFile(const QString &fileName)
{
if (QFileInfo(fileName).isAbsolute())
@@ -216,12 +200,10 @@ static inline QString resolveBugListFile(const QString &fileName)
return QStandardPaths::locate(QStandardPaths::ConfigLocation, fileName);
}
-# ifndef QT_NO_OPENGL
+#ifndef QT_NO_OPENGL
typedef QHash<QOpenGLConfig::Gpu, QWindowsOpenGLTester::Renderers> SupportedRenderersCache;
Q_GLOBAL_STATIC(SupportedRenderersCache, supportedRenderersCache)
-# endif
-
-#endif // !Q_OS_WINCE
+#endif
QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly)
{
@@ -229,8 +211,6 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
Q_UNUSED(glesOnly)
#if defined(QT_NO_OPENGL)
return 0;
-#elif defined(Q_OS_WINCE)
- return QWindowsOpenGLTester::Gles;
#else
QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.vendorId, gpu.deviceId, gpu.driverVersion, gpu.description);
SupportedRenderersCache *srCache = supportedRenderersCache();
@@ -281,7 +261,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
}
srCache->insert(qgpu, result);
return result;
-#endif // !Q_OS_WINCE && !QT_NO_OPENGL
+#endif // !QT_NO_OPENGL
}
QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers()
@@ -302,7 +282,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers()
bool QWindowsOpenGLTester::testDesktopGL()
{
-#if !defined(QT_NO_OPENGL) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_OPENGL)
HMODULE lib = 0;
HWND wnd = 0;
HDC dc = 0;
@@ -429,7 +409,7 @@ cleanup:
return result;
#else
return false;
-#endif // !QT_NO_OPENGL && !Q_OS_WINCE
+#endif // !QT_NO_OPENGL
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index b476c9be1d..23d43a95a5 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -43,7 +43,7 @@
#include "qwindowsintegration.h"
#include "qwindowscursor.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QSettings>
#include <QtGui/QPixmap>
@@ -68,8 +68,6 @@ static inline QDpi deviceDPI(HDC hdc)
return QDpi(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY));
}
-#ifndef Q_OS_WINCE
-
static inline QDpi monitorDPI(HMONITOR hMonitor)
{
if (QWindowsContext::shcoredll.isValid()) {
@@ -81,8 +79,6 @@ static inline QDpi monitorDPI(HMONITOR hMonitor)
return QDpi(0, 0);
}
-#endif // !Q_OS_WINCE
-
typedef QList<QWindowsScreenData> WindowsScreenDataList;
static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
@@ -99,20 +95,9 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
if (data->name == QLatin1String("WinDisc")) {
data->flags |= QWindowsScreenData::LockScreen;
} else {
-#ifdef Q_OS_WINCE
- //Windows CE, just supports one Display and expects to get only DISPLAY,
- //instead of DISPLAY0 and so on, which are passed by info.szDevice
- HDC hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
-#else
- HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL);
-#endif
- if (hdc) {
-#ifndef Q_OS_WINCE
+ if (const HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL)) {
const QDpi dpi = monitorDPI(hMonitor);
data->dpi = dpi.first ? dpi : deviceDPI(hdc);
-#else
- data->dpi = deviceDPI(hdc);
-#endif
data->depth = GetDeviceCaps(hdc, BITSPIXEL);
data->format = data->depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
data->physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), GetDeviceCaps(hdc, VERTSIZE));
@@ -330,7 +315,6 @@ enum OrientationPreference // matching Win32 API ORIENTATION_PREFERENCE
bool QWindowsScreen::setOrientationPreference(Qt::ScreenOrientation o)
{
bool result = false;
-#ifndef Q_OS_WINCE
if (QWindowsContext::user32dll.setDisplayAutoRotationPreferences) {
DWORD orientationPreference = 0;
switch (o) {
@@ -352,14 +336,12 @@ bool QWindowsScreen::setOrientationPreference(Qt::ScreenOrientation o)
}
result = QWindowsContext::user32dll.setDisplayAutoRotationPreferences(orientationPreference);
}
-#endif // !Q_OS_WINCE
return result;
}
Qt::ScreenOrientation QWindowsScreen::orientationPreference()
{
Qt::ScreenOrientation result = Qt::PrimaryOrientation;
-#ifndef Q_OS_WINCE
if (QWindowsContext::user32dll.getDisplayAutoRotationPreferences) {
DWORD orientationPreference = 0;
if (QWindowsContext::user32dll.getDisplayAutoRotationPreferences(&orientationPreference)) {
@@ -379,7 +361,6 @@ Qt::ScreenOrientation QWindowsScreen::orientationPreference()
}
}
}
-#endif // !Q_OS_WINCE
return result;
}
@@ -388,7 +369,7 @@ Qt::ScreenOrientation QWindowsScreen::orientationPreference()
*/
QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTypeHint() const
{
-#if defined(Q_OS_WINCE) || !defined(FT_LCD_FILTER_H) || !defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING)
+#if !defined(FT_LCD_FILTER_H) || !defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING)
return QPlatformScreen::Subpixel_None;
#else
QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 2afc410e07..02a9dc3bc3 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -41,9 +41,6 @@
#define QWINDOWSSCREEN_H
#include "qtwindowsglobal.h"
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
#include <QtCore/QList>
#include <QtCore/QVector>
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index d8058fcd06..7f9c9bd205 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -39,16 +39,14 @@
#define QT_NO_URL_CAST_FROM_STRING
#include "qwindowsservices.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QUrl>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <shlobj.h>
-#ifndef Q_OS_WINCE
-# include <intshcut.h>
-#endif
+#include <intshcut.h>
QT_BEGIN_NAMESPACE
@@ -56,7 +54,6 @@ enum { debug = 0 };
static inline bool shellExecute(const QUrl &url)
{
-#ifndef Q_OS_WINCE
const QString nativeFilePath = url.isLocalFile() && !url.hasFragment() && !url.hasQuery()
? QDir::toNativeSeparators(url.toLocalFile())
: url.toString(QUrl::FullyEncoded);
@@ -70,10 +67,6 @@ static inline bool shellExecute(const QUrl &url)
return false;
}
return true;
-#else
- Q_UNUSED(url);
- return false;
-#endif
}
// Retrieve the commandline for the default mail client. It contains a
@@ -107,13 +100,9 @@ static inline QString mailCommand()
}
if (!command[0])
return QString();
-#ifndef Q_OS_WINCE
wchar_t expandedCommand[MAX_PATH] = {0};
return ExpandEnvironmentStrings(command, expandedCommand, MAX_PATH) ?
QString::fromWCharArray(expandedCommand) : QString::fromWCharArray(command);
-#else
- return QString();
-#endif
}
static inline bool launchMail(const QUrl &url)
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index 4a24d62770..2c05dcddfc 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -42,7 +42,7 @@
#include "qtwindowsglobal.h"
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
#include <QtCore/QVector>
#include <QtCore/QPointF>
@@ -143,5 +143,5 @@ private:
QT_END_NAMESPACE
-#endif // !QT_NO_TABLETEVENT && !Q_OS_WINCE
+#endif // !QT_NO_TABLETEVENT
#endif // QWINDOWSTABLETSUPPORT_H
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index ff4cfe63cb..ed12c8124e 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -48,18 +48,12 @@
#include "qwindowscontext.h"
#include "qwindowsintegration.h"
#include "qt_windows.h"
-#include "qwindowsfontdatabase.h"
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-# include "winuser.h"
-#else
-# include <commctrl.h>
-# include <objbase.h>
-# ifndef Q_CC_MINGW
-# include <commoncontrols.h>
-# endif
-# include <shellapi.h>
+#include <commctrl.h>
+#include <objbase.h>
+#ifndef Q_CC_MINGW
+# include <commoncontrols.h>
#endif
+#include <shellapi.h>
#include <QtCore/QVariant>
#include <QtCore/QCoreApplication>
@@ -73,6 +67,8 @@
#include <QtGui/QPainter>
#include <QtGui/QPixmapCache>
#include <qpa/qwindowsysteminterface.h>
+#include <QtThemeSupport/private/qabstractfileiconengine_p.h>
+#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qsystemlibrary_p.h>
@@ -128,7 +124,6 @@ static inline QColor getSysColor(int index)
return COLORREFToQColor(GetSysColor(index));
}
-#ifndef QT_NO_WINCE_SHELLSDK
// QTBUG-48823/Windows 10: SHGetFileInfo() (as called by item views on file system
// models has been observed to trigger a WM_PAINT on the mainwindow. Suppress the
// behavior by running it in a thread.
@@ -170,7 +165,6 @@ static bool shGetFileInfoBackground(QWindowsThreadPoolRunner &r,
}
return result;
}
-#endif // !QT_NO_WINCE_SHELLSDK
// from QStyle::standardPalette
static inline QPalette standardPalette()
@@ -281,14 +275,9 @@ static inline QPalette menuPalette(const QPalette &systemPalette)
result.setColor(QPalette::Active, QPalette::ButtonText, menuTextColor);
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
-#ifndef Q_OS_WINCE
const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false);
result.setColor(QPalette::Disabled, QPalette::Highlight,
getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT));
-#else
- result.setColor(QPalette::Disabled, QPalette::Highlight,
- getSysColor(COLOR_HIGHLIGHT));
-#endif
result.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
result.setColor(QPalette::Disabled, QPalette::Button,
result.color(QPalette::Active, QPalette::Button));
@@ -314,11 +303,7 @@ static inline QPalette *menuBarPalette(const QPalette &menuPalette)
QPalette *result = 0;
if (booleanSystemParametersInfo(SPI_GETFLATMENU, false)) {
result = new QPalette(menuPalette);
-#ifndef Q_OS_WINCE
const QColor menubar(getSysColor(COLOR_MENUBAR));
-#else
- const QColor menubar(getSysColor(COLOR_MENU));
-#endif
result->setColor(QPalette::Active, QPalette::Button, menubar);
result->setColor(QPalette::Disabled, QPalette::Button, menubar);
result->setColor(QPalette::Inactive, QPalette::Button, menubar);
@@ -330,6 +315,7 @@ const char *QWindowsTheme::name = "windows";
QWindowsTheme *QWindowsTheme::m_instance = 0;
QWindowsTheme::QWindowsTheme()
+ : m_threadPoolRunner(new QWindowsThreadPoolRunner)
{
m_instance = this;
std::fill(m_fonts, m_fonts + NFonts, static_cast<QFont *>(0));
@@ -364,7 +350,7 @@ static inline QStringList styleNames()
static inline int uiEffects()
{
- int result = 0;
+ int result = QPlatformTheme::HoverEffect;
if (booleanSystemParametersInfo(SPI_GETUIEFFECTS, false))
result |= QPlatformTheme::GeneralUiEffect;
if (booleanSystemParametersInfo(SPI_GETMENUANIMATION, false))
@@ -389,12 +375,10 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
return QVariant(iconThemeSearchPaths());
case StyleNames:
return QVariant(styleNames());
-#ifndef Q_OS_WINCE
case TextCursorWidth:
return QVariant(int(dWordSystemParametersInfo(SPI_GETCARETWIDTH, 1u)));
case DropShadow:
return QVariant(booleanSystemParametersInfo(SPI_GETDROPSHADOW, false));
-#endif // !Q_OS_WINCE
case MaximumScrollBarDragDistance:
return QVariant(qRound(qreal(QWindowsContext::instance()->defaultDPI()) * 1.375));
case KeyboardScheme:
@@ -402,7 +386,7 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
case UiEffects:
return QVariant(uiEffects());
case IconPixmapSizes:
- return m_fileIconSizes;
+ return QVariant::fromValue(m_fileIconSizes);
case DialogSnapToDefaultButton:
return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
case ContextMenuOnMouseRelease:
@@ -445,7 +429,6 @@ void QWindowsTheme::clearFonts()
void QWindowsTheme::refreshFonts()
{
-#ifndef Q_OS_WINCE // ALL THIS FUNCTIONALITY IS MISSING ON WINCE
clearFonts();
if (!QGuiApplication::desktopSettingsAware())
return;
@@ -474,7 +457,6 @@ void QWindowsTheme::refreshFonts()
m_fonts[DockWidgetTitleFont] = new QFont(titleFont);
m_fonts[ItemViewFont] = new QFont(iconTitleFont);
m_fonts[FixedFont] = new QFont(fixedFont);
-#endif // !Q_OS_WINCE
}
enum FileIconSize {
@@ -512,15 +494,14 @@ void QWindowsTheme::refreshIconPixmapSizes()
fileIconSizes[ExtraLargeFileIcon] =
fileIconSizes[LargeFileIcon] + fileIconSizes[LargeFileIcon] / 2;
fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work
- QList<int> sizes;
- sizes << fileIconSizes[SmallFileIcon] << fileIconSizes[LargeFileIcon];
+
#ifdef USE_IIMAGELIST
- sizes << fileIconSizes[ExtraLargeFileIcon]; // sHIL_EXTRALARGE
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
- sizes << fileIconSizes[JumboFileIcon]; // SHIL_JUMBO
+ int *availEnd = fileIconSizes + JumboFileIcon + 1;
+#else
+ int *availEnd = fileIconSizes + LargeFileIcon + 1;
#endif // USE_IIMAGELIST
- qCDebug(lcQpaWindows) << __FUNCTION__ << sizes;
- m_fileIconSizes = QVariant::fromValue(sizes);
+ m_fileIconSizes = QAbstractFileIconEngine::toSizeList(fileIconSizes, availEnd);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << m_fileIconSizes;
}
// Defined in qpixmap_win.cpp
@@ -528,12 +509,7 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
{
-#ifdef Q_OS_WINCE
- HMODULE hmod = LoadLibrary(L"ceshell");
-#else
- HMODULE hmod = QSystemLibrary::load(L"shell32");
-#endif
- if (hmod) {
+ if (const HMODULE hmod = QSystemLibrary::load(L"shell32")) {
HICON iconHandle =
static_cast<HICON>(LoadImage(hmod, MAKEINTRESOURCE(resourceId),
IMAGE_ICON, int(size.width()), int(size.height()), 0));
@@ -549,7 +525,7 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSize) const
{
int resourceId = -1;
- int stockId = SIID_INVALID;
+ SHSTOCKICONID stockId = SIID_INVALID;
UINT stockFlags = 0;
LPCTSTR iconName = 0;
switch (sp) {
@@ -575,14 +551,14 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz
break;
case FileLinkIcon:
stockFlags = SHGSI_LINKOVERLAY;
- // Fall through
+ Q_FALLTHROUGH();
case FileIcon:
stockId = SIID_DOCNOASSOC;
resourceId = 1;
break;
case DirLinkIcon:
stockFlags = SHGSI_LINKOVERLAY;
- // Fall through
+ Q_FALLTHROUGH();
case DirClosedIcon:
case DirIcon:
stockId = SIID_FOLDER;
@@ -596,7 +572,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz
break;
case DirLinkOpenIcon:
stockFlags = SHGSI_LINKOVERLAY;
- // Fall through
+ Q_FALLTHROUGH();
case DirOpenIcon:
stockId = SIID_FOLDEROPEN;
resourceId = 5;
@@ -612,7 +588,6 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz
stockId = SIID_RECYCLER;
resourceId = 191;
break;
-#ifndef Q_OS_WINCE
case MessageBoxInformation:
stockId = SIID_INFO;
iconName = IDI_INFORMATION;
@@ -632,29 +607,22 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz
case VistaShield:
stockId = SIID_SHIELD;
break;
-#endif
default:
break;
}
-#ifndef Q_OS_WINCE
if (stockId != SIID_INVALID) {
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
- && QWindowsContext::shell32dll.sHGetStockIconInfo) {
- QPixmap pixmap;
- SHSTOCKICONINFO iconInfo;
- memset(&iconInfo, 0, sizeof(iconInfo));
- iconInfo.cbSize = sizeof(iconInfo);
- stockFlags |= (pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON);
- if (QWindowsContext::shell32dll.sHGetStockIconInfo(stockId, SHGFI_ICON | stockFlags, &iconInfo) == S_OK) {
- pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
- DestroyIcon(iconInfo.hIcon);
- return pixmap;
- }
+ QPixmap pixmap;
+ SHSTOCKICONINFO iconInfo;
+ memset(&iconInfo, 0, sizeof(iconInfo));
+ iconInfo.cbSize = sizeof(iconInfo);
+ stockFlags |= (pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON);
+ if (SHGetStockIconInfo(stockId, SHGFI_ICON | stockFlags, &iconInfo) == S_OK) {
+ pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
+ DestroyIcon(iconInfo.hIcon);
+ return pixmap;
}
}
-#endif
if (resourceId != -1) {
QPixmap pixmap = loadIconFromShell32(resourceId, pixmapSize);
@@ -729,14 +697,8 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
// For MinGW:
static const IID iID_IImageList = {0x46eb5926, 0x582e, 0x4017, {0x9f, 0xdf, 0xe8, 0x99, 0x8d, 0xaa, 0x9, 0x50}};
- if (!QWindowsContext::shell32dll.sHGetImageList)
- return result;
- if (iImageList == sHIL_JUMBO && QSysInfo::WindowsVersion < QSysInfo::WV_VISTA)
- return result;
-
IImageList *imageList = 0;
- HRESULT hr = QWindowsContext::shell32dll.sHGetImageList(iImageList, iID_IImageList,
- reinterpret_cast<void **>(&imageList));
+ HRESULT hr = SHGetImageList(iImageList, iID_IImageList, reinterpret_cast<void **>(&imageList));
if (hr != S_OK)
return result;
HICON hIcon;
@@ -753,8 +715,46 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
return result;
}
-QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions) const
+class QWindowsFileIconEngine : public QAbstractFileIconEngine
+{
+public:
+ explicit QWindowsFileIconEngine(const QFileInfo &info,
+ QPlatformTheme::IconOptions opts,
+ const QSharedPointer<QWindowsThreadPoolRunner> &runner) :
+ QAbstractFileIconEngine(info, opts), m_threadPoolRunner(runner) {}
+
+ QList<QSize> availableSizes(QIcon::Mode = QIcon::Normal, QIcon::State = QIcon::Off) const override
+ { return QWindowsTheme::instance()->availableFileIconSizes(); }
+
+protected:
+ QString cacheKey() const override;
+ QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
+
+private:
+ const QSharedPointer<QWindowsThreadPoolRunner> m_threadPoolRunner;
+};
+
+QString QWindowsFileIconEngine::cacheKey() const
+{
+ // Cache directories unless custom or drives, which have custom icons depending on type
+ if ((options() & QPlatformTheme::DontUseCustomDirectoryIcons) && fileInfo().isDir() && !fileInfo().isRoot())
+ return QStringLiteral("qt_/directory/");
+ if (!fileInfo().isFile())
+ return QString();
+ // Return "" for .exe, .lnk and .ico extensions.
+ // It is faster to just look at the file extensions;
+ // avoiding slow QFileInfo::isExecutable() (QTBUG-13182)
+ const QString &suffix = fileInfo().suffix();
+ if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive)
+ || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive)
+ || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) {
+ return QString();
+ }
+ return QLatin1String("qt_.")
+ + (suffix.isEmpty() ? fileInfo().fileName() : suffix.toUpper()); // handle "Makefile" ;)
+}
+
+QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon::State)
{
/* We don't use the variable, but by storing it statically, we
* ensure CoInitialize is only called once. */
@@ -764,10 +764,10 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
static QCache<QString, FakePointer<int> > dirIconEntryCache(1000);
static QMutex mx;
static int defaultFolderIIcon = -1;
- const bool useDefaultFolderIcon = iconOptions & QPlatformTheme::DontUseCustomDirectoryIcons;
+ const bool useDefaultFolderIcon = options() & QPlatformTheme::DontUseCustomDirectoryIcons;
QPixmap pixmap;
- const QString filePath = QDir::toNativeSeparators(fileInfo.filePath());
+ const QString filePath = QDir::toNativeSeparators(fileInfo().filePath());
const int width = int(size.width());
const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON;
const int requestedImageListSize =
@@ -778,7 +778,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
#else
0;
#endif // !USE_IIMAGELIST
- bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot();
+ bool cacheableDirIcon = fileInfo().isDir() && !fileInfo().isRoot();
if (cacheableDirIcon) {
QMutexLocker locker(&mx);
int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon
@@ -794,22 +794,13 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
SHFILEINFO info;
const unsigned int flags =
-#ifndef Q_OS_WINCE
SHGFI_ICON|iconSize|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX;
-#else
- iconSize|SHGFI_SYSICONINDEX;
-#endif // Q_OS_WINCE
-
-#if !defined(QT_NO_WINCE_SHELLSDK)
const bool val = cacheableDirIcon && useDefaultFolderIcon
- ? shGetFileInfoBackground(m_threadPoolRunner, L"dummy", FILE_ATTRIBUTE_DIRECTORY,
+ ? shGetFileInfoBackground(*m_threadPoolRunner.data(), L"dummy", FILE_ATTRIBUTE_DIRECTORY,
&info, flags | SHGFI_USEFILEATTRIBUTES)
- : shGetFileInfoBackground(m_threadPoolRunner, reinterpret_cast<const wchar_t *>(filePath.utf16()), 0,
+ : shGetFileInfoBackground(*m_threadPoolRunner.data(), reinterpret_cast<const wchar_t *>(filePath.utf16()), 0,
&info, flags);
-#else
- const bool val = false;
-#endif // !QT_NO_WINCE_SHELLSDK
// Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
if (val && info.hIcon) {
@@ -848,9 +839,12 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
DestroyIcon(info.hIcon);
}
- if (!pixmap.isNull())
- return pixmap;
- return QPlatformTheme::fileIconPixmap(fileInfo, size);
+ return pixmap;
+}
+
+QIcon QWindowsTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
+{
+ return QIcon(new QWindowsFileIconEngine(fileInfo, iconOptions, m_threadPoolRunner));
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index fa1fb4d998..0384899efa 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -43,6 +43,7 @@
#include "qwindowsthreadpoolrunner.h"
#include <qpa/qplatformtheme.h>
+#include <QtCore/QSharedPointer>
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
@@ -66,12 +67,14 @@ public:
{ return m_fonts[type]; }
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const Q_DECL_OVERRIDE;
- QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE;
+
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = 0) const override;
void windowsThemeChanged(QWindow *window);
void displayChanged() { refreshIconPixmapSizes(); }
+ QList<QSize> availableFileIconSizes() const { return m_fileIconSizes; }
+
static const char *name;
private:
@@ -85,8 +88,8 @@ private:
static QWindowsTheme *m_instance;
QPalette *m_palettes[NPalettes];
QFont *m_fonts[NFonts];
- mutable QWindowsThreadPoolRunner m_threadPoolRunner;
- QVariant m_fileIconSizes;
+ const QSharedPointer<QWindowsThreadPoolRunner> m_threadPoolRunner;
+ QList<QSize> m_fileIconSizes;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 434d0ad953..a9b061ad73 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qwindowswindow.h"
-#include "qwindowsnativeimage.h"
#include "qwindowscontext.h"
#include "qwindowsdrag.h"
#include "qwindowsscreen.h"
@@ -62,6 +61,8 @@
#include <QtCore/QDebug>
+#include <dwmapi.h>
+
QT_BEGIN_NAMESPACE
enum {
@@ -147,7 +148,6 @@ QDebug operator<<(QDebug d, const POINT &p)
return d;
}
-# ifndef Q_OS_WINCE
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p)
{
QDebugStateSaver saver(d);
@@ -178,14 +178,12 @@ QDebug operator<<(QDebug d, const WINDOWPLACEMENT &wp)
<< ", rcNormalPosition=" << wp.rcNormalPosition;
return d;
}
-# endif // !Q_OS_WINCE
#endif // !QT_NO_DEBUG_STREAM
// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT
// is in workspace/available area coordinates.
static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
{
-#ifndef Q_OS_WINCE
if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
return QPoint(0, 0);
const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager();
@@ -193,10 +191,6 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
? screenManager.screens().constFirst() : screenManager.screenAtDp(point);
if (screen)
return screen->availableGeometry().topLeft() - screen->geometry().topLeft();
-#else
- Q_UNUSED(hwnd)
- Q_UNUSED(point)
-#endif
return QPoint(0, 0);
}
@@ -205,7 +199,6 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
static inline QRect frameGeometry(HWND hwnd, bool topLevel)
{
RECT rect = { 0, 0, 0, 0 };
-#ifndef Q_OS_WINCE
if (topLevel) {
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
@@ -215,7 +208,6 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel)
return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
}
}
-#endif // !Q_OS_WINCE
GetWindowRect(hwnd, &rect); // Screen coordinates.
const HWND parent = GetParent(hwnd);
if (parent && !topLevel) {
@@ -236,7 +228,6 @@ static QWindow::Visibility windowVisibility_sys(HWND hwnd)
{
if (!IsWindowVisible(hwnd))
return QWindow::Hidden;
-#ifndef Q_OS_WINCE
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(hwnd, &windowPlacement)) {
@@ -251,7 +242,6 @@ static QWindow::Visibility windowVisibility_sys(HWND hwnd)
break;
}
}
-#endif // !Q_OS_WINCE
return QWindow::Windowed;
}
@@ -269,65 +259,27 @@ static inline bool windowIsOpenGL(const QWindow *w)
static bool applyBlurBehindWindow(HWND hwnd)
{
-#ifdef Q_OS_WINCE
- Q_UNUSED(hwnd);
- return false;
-#else
- enum { dwmBbEnable = 0x1, dwmBbBlurRegion = 0x2 };
-
- struct DwmBlurBehind {
- DWORD dwFlags;
- BOOL fEnable;
- HRGN hRgnBlur;
- BOOL fTransitionOnMaximized;
- };
-
- typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND, const DwmBlurBehind*);
- typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL *);
-
- // DWM API is available only from Windows Vista
- if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA)
- return false;
-
- static bool functionPointersResolved = false;
- static PtrDwmEnableBlurBehindWindow dwmBlurBehind = 0;
- static PtrDwmIsCompositionEnabled dwmIsCompositionEnabled = 0;
-
- if (Q_UNLIKELY(!functionPointersResolved)) {
- QSystemLibrary library(QStringLiteral("dwmapi"));
- if (library.load()) {
- dwmBlurBehind = (PtrDwmEnableBlurBehindWindow)(library.resolve("DwmEnableBlurBehindWindow"));
- dwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)(library.resolve("DwmIsCompositionEnabled"));
- }
-
- functionPointersResolved = true;
- }
-
- if (Q_UNLIKELY(!dwmBlurBehind || !dwmIsCompositionEnabled))
- return false;
-
BOOL compositionEnabled;
- if (dwmIsCompositionEnabled(&compositionEnabled) != S_OK)
+ if (DwmIsCompositionEnabled(&compositionEnabled) != S_OK)
return false;
- DwmBlurBehind blurBehind = {0, 0, 0, 0};
+ DWM_BLURBEHIND blurBehind = {0, 0, 0, 0};
if (compositionEnabled) {
- blurBehind.dwFlags = dwmBbEnable | dwmBbBlurRegion;
+ blurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
blurBehind.fEnable = TRUE;
blurBehind.hRgnBlur = CreateRectRgn(0, 0, -1, -1);
} else {
- blurBehind.dwFlags = dwmBbEnable;
+ blurBehind.dwFlags = DWM_BB_ENABLE;
blurBehind.fEnable = FALSE;
}
- const bool result = dwmBlurBehind(hwnd, &blurBehind) == S_OK;
+ const bool result = DwmEnableBlurBehindWindow(hwnd, &blurBehind) == S_OK;
if (blurBehind.hRgnBlur)
DeleteObject(blurBehind.hRgnBlur);
return result;
-#endif // Q_OS_WINCE
}
// from qwidget_win.cpp, pass flags separately in case they have been "autofixed".
@@ -346,7 +298,6 @@ static bool shouldShowMaximizeButton(const QWindow *w, Qt::WindowFlags flags)
// Qt::WindowTransparentForInput (in combination with WS_EX_TRANSPARENT).
bool QWindowsWindow::setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qreal opacity)
{
-#ifndef Q_OS_WINCE // maybe needs revisiting WS_EX_LAYERED
const LONG exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
const bool needsLayered = (flags & Qt::WindowTransparentForInput)
|| (hasAlpha && (flags & Qt::FramelessWindowHint)) || opacity < 1.0;
@@ -359,36 +310,22 @@ bool QWindowsWindow::setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool has
}
}
return needsLayered;
-#else // !Q_OS_WINCE
- Q_UNUSED(hwnd);
- Q_UNUSED(flags);
- Q_UNUSED(hasAlpha);
- Q_UNUSED(opacity);
- return false;
-#endif // Q_OS_WINCE
}
static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bool openGL, qreal level)
{
-#ifdef Q_OS_WINCE // WINCE does not support that feature and microsoft explicitly warns to use those calls
- Q_UNUSED(hwnd);
- Q_UNUSED(flags);
- Q_UNUSED(hasAlpha);
- Q_UNUSED(level);
-#else
if (QWindowsWindow::setWindowLayered(hwnd, flags, hasAlpha, level)) {
const BYTE alpha = BYTE(qRound(255.0 * level));
if (hasAlpha && !openGL && (flags & Qt::FramelessWindowHint)) {
// Non-GL windows with alpha: Use blend function to update.
BLENDFUNCTION blend = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
- QWindowsContext::user32dll.updateLayeredWindow(hwnd, NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA);
+ UpdateLayeredWindow(hwnd, NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA);
} else {
- QWindowsContext::user32dll.setLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
}
} else if (IsWindowVisible(hwnd)) { // Repaint when switching from layered.
InvalidateRect(hwnd, NULL, TRUE);
}
-#endif // !Q_OS_WINCE
}
static inline void updateGLWindowSettings(const QWindow *w, HWND hwnd, Qt::WindowFlags flags, qreal opacity)
@@ -486,11 +423,9 @@ static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags)
|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint;
break;
case Qt::Dialog:
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
- break;
case Qt::Tool:
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
- break;
+ flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
+ break;
default:
break;
}
@@ -604,12 +539,10 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
exStyle |= WS_EX_TOOLWINDOW;
}
-#ifndef Q_OS_WINCE
// make mouse events fall through this window
// NOTE: WS_EX_TRANSPARENT flag can make mouse inputs fall through a layered window
if (flagsIn & Qt::WindowTransparentForInput)
exStyle |= WS_EX_LAYERED | WS_EX_TRANSPARENT;
-#endif
}
}
@@ -650,10 +583,6 @@ QWindowsWindowData
context->frameX, context->frameY,
context->frameWidth, context->frameHeight,
parentHandle, NULL, appinst, NULL);
-#ifdef Q_OS_WINCE
- if (DisableGestures(result.hwnd, TGF_GID_ALL, TGF_SCOPE_WINDOW))
- EnableGestures(result.hwnd, TGF_GID_DIRECTMANIPULATION, TGF_SCOPE_WINDOW);
-#endif
qCDebug(lcQpaWindows).nospace()
<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "
<< context->obtainedGeometry << ' ' << context->margins;
@@ -764,9 +693,7 @@ bool QWindowsGeometryHint::validSize(const QSize &s) const
QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
{
RECT rect = {0,0,0,0};
-#ifndef Q_OS_WINCE
style &= ~(WS_OVERLAPPED); // Not permitted, see docs.
-#endif
if (!AdjustWindowRectEx(&rect, style, FALSE, exStyle))
qErrnoWarning("%s: AdjustWindowRectEx failed", __FUNCTION__);
const QMargins result(qAbs(rect.left), qAbs(rect.top),
@@ -779,7 +706,6 @@ QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result)
{
-#ifndef Q_OS_WINCE
// NCCALCSIZE_PARAMS structure if wParam==TRUE
if (!msg.wParam || customMargins.isNull())
return false;
@@ -795,15 +721,8 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co
<< ncp->rgrc[0] << ' ' << ncp->rgrc[1] << ' ' << ncp->rgrc[2]
<< ' ' << ncp->lppos->cx << ',' << ncp->lppos->cy;
return true;
-#else
- Q_UNUSED(customMargins)
- Q_UNUSED(msg)
- Q_UNUSED(result)
- return false;
-#endif
}
-#ifndef Q_OS_WINCE
void QWindowsGeometryHint::applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const
{
return applyToMinMaxInfo(DWORD(GetWindowLong(hwnd, GWL_STYLE)),
@@ -835,7 +754,6 @@ void QWindowsGeometryHint::applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXI
<< " frame=" << margins << ' ' << frameWidth << ',' << frameHeight
<< " out " << *mmi;
}
-#endif // !Q_OS_WINCE
bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w)
{
@@ -1080,9 +998,6 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
m_dropTarget(0),
m_savedStyle(0),
m_format(aWindow->requestedFormat()),
-#ifdef Q_OS_WINCE
- m_previouslyHidden(false),
-#endif
m_iconSmall(0),
m_iconBig(0),
m_surface(0)
@@ -1116,10 +1031,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
QWindowsWindow::~QWindowsWindow()
{
setFlag(WithinDestroy);
-#ifndef Q_OS_WINCE
if (testFlag(TouchRegistered))
QWindowsContext::user32dll.unregisterTouchWindow(m_data.hwnd);
-#endif // !Q_OS_WINCE
destroyWindow();
destroyIcon();
}
@@ -1163,14 +1076,6 @@ void QWindowsWindow::destroyWindow()
m_surface = 0;
}
#endif
-#ifdef Q_OS_WINCE
- if ((m_windowState & Qt::WindowFullScreen) && !m_previouslyHidden) {
- HWND handle = FindWindow(L"HHTaskBar", L"");
- if (handle) {
- ShowWindow(handle, SW_SHOW);
- }
- }
-#endif // !Q_OS_WINCE
DestroyWindow(m_data.hwnd);
context->removeWindow(m_data.hwnd);
m_data.hwnd = 0;
@@ -1338,7 +1243,6 @@ QPoint QWindowsWindow::mapFromGlobal(const QPoint &pos) const
return pos;
}
-#ifndef Q_OS_WINCE
static inline HWND transientParentHwnd(HWND hwnd)
{
if (GetAncestor(hwnd, GA_PARENT) == GetDesktopWindow()) {
@@ -1348,15 +1252,18 @@ static inline HWND transientParentHwnd(HWND hwnd)
}
return 0;
}
-#endif // !Q_OS_WINCE
// Update the transient parent for a toplevel window. The concept does not
// really exist on Windows, the relationship is set by passing a parent along with !WS_CHILD
// to window creation or by setting the parent using GWL_HWNDPARENT (as opposed to
// SetParent, which would make it a real child).
+
+#ifndef GWL_HWNDPARENT
+# define GWL_HWNDPARENT (-8)
+#endif
+
void QWindowsWindow::updateTransientParent() const
{
-#ifndef Q_OS_WINCE
if (window()->type() == Qt::Popup)
return; // QTBUG-34503, // a popup stays on top, no parent, see also WindowCreationData::fromWindow().
// Update transient parent.
@@ -1368,7 +1275,6 @@ void QWindowsWindow::updateTransientParent() const
newTransientParent = tw->handle();
if (newTransientParent != oldTransientParent)
SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, LONG_PTR(newTransientParent));
-#endif // !Q_OS_WINCE
}
static inline bool testShowWithoutActivating(const QWindow *window)
@@ -1486,16 +1392,12 @@ void QWindowsWindow::handleCompositionSettingsChanged()
static QRect normalFrameGeometry(HWND hwnd)
{
-#ifndef Q_OS_WINCE
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(hwnd, &wp)) {
const QRect result = qrectFromRECT(wp.rcNormalPosition);
return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
}
-#else
- Q_UNUSED(hwnd)
-#endif
return QRect();
}
@@ -1615,7 +1517,6 @@ void QWindowsBaseWindow::setGeometry_sys(const QRect &rect) const
<< " new frame: " << frameGeometry;
bool result = false;
-#ifndef Q_OS_WINCE
const HWND hwnd = handle();
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
@@ -1628,9 +1529,7 @@ void QWindowsBaseWindow::setGeometry_sys(const QRect &rect) const
RECTfromQRect(frameGeometry.translated(-windowPlacementOffset(hwnd, frameGeometry.topLeft())));
windowPlacement.showCmd = windowPlacement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWMINIMIZED : SW_HIDE;
result = SetWindowPlacement(hwnd, &windowPlacement);
- } else
-#endif // !Q_OS_WINCE
- {
+ } else {
result = MoveWindow(hwnd, frameGeometry.x(), frameGeometry.y(),
frameGeometry.width(), frameGeometry.height(), true);
}
@@ -1667,6 +1566,12 @@ void QWindowsWindow::releaseDC()
}
}
+static inline bool dwmIsCompositionEnabled()
+{
+ BOOL dWmCompositionEnabled = FALSE;
+ return SUCCEEDED(DwmIsCompositionEnabled(&dWmCompositionEnabled)) && dWmCompositionEnabled == TRUE;
+}
+
bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
WPARAM, LPARAM)
{
@@ -1680,8 +1585,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
BeginPaint(hwnd, &ps);
// Observed painting problems with Aero style disabled (QTBUG-7865).
- // 5.8: Consider making it dependent on !DwmIsCompositionEnabled().
- if (testFlag(OpenGLSurface) && testFlag(OpenGLDoubleBuffered))
+ if (Q_UNLIKELY(testFlag(OpenGLSurface) && testFlag(OpenGLDoubleBuffered) && !dwmIsCompositionEnabled()))
SelectClipRgn(ps.hdc, NULL);
// If the a window is obscured by another window (such as a child window)
@@ -1823,18 +1727,6 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
setFlag(FrameDirty);
if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) {
-#ifdef Q_OS_WINCE
- HWND handle = FindWindow(L"HHTaskBar", L"");
- if (handle) {
- if (newState == Qt::WindowFullScreen) {
- BOOL hidden = ShowWindow(handle, SW_HIDE);
- if (!hidden)
- m_previouslyHidden = true;
- } else if (!m_previouslyHidden){
- ShowWindow(handle, SW_SHOW);
- }
- }
-#endif
if (newState == Qt::WindowFullScreen) {
#ifndef Q_FLATTEN_EXPOSE
UINT newStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
@@ -1846,17 +1738,13 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
// Window state but emulated by changing geometry and style.
if (!m_savedStyle) {
m_savedStyle = style();
-#ifndef Q_OS_WINCE
if (oldState == Qt::WindowMinimized || oldState == Qt::WindowMaximized) {
const QRect nf = normalFrameGeometry(m_data.hwnd);
if (nf.isValid())
m_savedFrameGeometry = nf;
} else {
-#endif
m_savedFrameGeometry = frameGeometry_sys();
-#ifndef Q_OS_WINCE
}
-#endif
}
if (m_savedStyle & WS_SYSMENU)
newStyle |= WS_SYSMENU;
@@ -1969,7 +1857,6 @@ void QWindowsWindow::propagateSizeHints()
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &margins)
{
-#ifndef Q_OS_WINCE
if (!qWindow->isTopLevel()) // Implement hasHeightForWidth().
return false;
WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
@@ -1989,10 +1876,6 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
windowPos->cx = correctedFrameGeometry.width();
windowPos->cy = correctedFrameGeometry.height();
return true;
-#else // !Q_OS_WINCE
- Q_UNUSED(message)
- return false;
-#endif
}
bool QWindowsWindow::handleGeometryChanging(MSG *message) const
@@ -2050,15 +1933,13 @@ static inline void addRectToWinRegion(const QRect &rect, HRGN *winRegion)
static HRGN qRegionToWinRegion(const QRegion &region)
{
- const QVector<QRect> rects = region.rects();
- if (rects.isEmpty())
- return NULL;
- const int rectCount = rects.size();
- if (rectCount == 1)
- return createRectRegion(region.boundingRect());
- HRGN hRegion = createRectRegion(rects.front());
- for (int i = 1; i < rectCount; ++i)
- addRectToWinRegion(rects.at(i), &hRegion);
+ auto it = region.begin();
+ const auto end = region.end();
+ if (it == end)
+ return nullptr;
+ HRGN hRegion = createRectRegion(*it);
+ while (++it != end)
+ addRectToWinRegion(*it, &hRegion);
return hRegion;
}
@@ -2087,7 +1968,6 @@ void QWindowsWindow::requestActivateWindow()
// 'Active' state handling is based in focus since it needs to work for
// child windows as well.
if (m_data.hwnd) {
-#ifndef Q_OS_WINCE
const DWORD currentThread = GetCurrentThreadId();
bool attached = false;
DWORD foregroundThread = 0;
@@ -2104,13 +1984,10 @@ void QWindowsWindow::requestActivateWindow()
attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE;
}
}
-#endif // !Q_OS_WINCE
SetForegroundWindow(m_data.hwnd);
SetFocus(m_data.hwnd);
-#ifndef Q_OS_WINCE
if (attached)
AttachThreadInput(foregroundThread, currentThread, FALSE);
-#endif // !Q_OS_WINCE
}
}
@@ -2192,7 +2069,6 @@ void QWindowsWindow::setFrameStrutEventsEnabled(bool enabled)
}
}
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
{
const QWindowsGeometryHint hint(window(), m_data.customMargins);
@@ -2263,8 +2139,6 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
return false;
}
-#endif // !Q_OS_WINCE
-
#ifndef QT_NO_CURSOR
// Return the default cursor (Arrow) from QWindowsCursor's cache.
static inline CursorHandlePtr defaultCursor(const QWindow *w)
@@ -2331,7 +2205,6 @@ void QWindowsWindow::setCursor(const CursorHandlePtr &c)
#endif
}
-#ifndef Q_OS_WINCE
void QWindowsWindow::setAlertState(bool enabled)
{
if (isAlertState() == enabled)
@@ -2370,7 +2243,6 @@ void QWindowsWindow::stopAlertWindow()
info.uCount = 0;
FlashWindowEx(&info);
}
-#endif // !Q_OS_WINCE
bool QWindowsWindow::isEnabled() const
{
@@ -2486,7 +2358,6 @@ void QWindowsWindow::setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWind
void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes)
{
-#ifndef Q_OS_WINCE
if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)) {
ULONG touchFlags = 0;
const bool ret = QWindowsContext::user32dll.isTouchWindow(m_data.hwnd, &touchFlags);
@@ -2499,7 +2370,6 @@ void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTou
else
qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
}
-#endif // !Q_OS_WINCE
}
void QWindowsWindow::aboutToMakeCurrent()
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index df7d2295a9..924f242e6e 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -40,10 +40,7 @@
#ifndef QWINDOWSWINDOW_H
#define QWINDOWSWINDOW_H
-#include "qtwindows_additional.h"
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
+#include <QtCore/qt_windows.h>
#include "qwindowscursor.h"
#include <qpa/qplatformwindow.h>
@@ -60,10 +57,8 @@ struct QWindowsGeometryHint
explicit QWindowsGeometryHint(const QWindow *w, const QMargins &customMargins);
static QMargins frame(DWORD style, DWORD exStyle);
static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result);
-#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
void applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXINFO *mmi) const;
void applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const;
-#endif
bool validSize(const QSize &s) const;
static inline QPoint mapToGlobal(HWND hwnd, const QPoint &);
@@ -83,10 +78,8 @@ struct QWindowCreationContext
QWindowCreationContext(const QWindow *w, const QRect &r,
const QMargins &customMargins,
DWORD style, DWORD exStyle);
-#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
void applyToMinMaxInfo(MINMAXINFO *mmi) const
{ geometryHint.applyToMinMaxInfo(style, exStyle, mmi); }
-#endif
QWindowsGeometryHint geometryHint;
const QWindow *window;
@@ -293,10 +286,8 @@ public:
HDC getDC();
void releaseDC();
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
void getSizeHints(MINMAXINFO *mmi) const;
bool handleNonClientHitTest(const QPoint &globalPos, LRESULT *result) const;
-#endif // !Q_OS_WINCE
#ifndef QT_NO_CURSOR
CursorHandlePtr cursor() const { return m_cursor; }
@@ -316,12 +307,10 @@ public:
void invalidateSurface() Q_DECL_OVERRIDE;
void aboutToMakeCurrent();
-#ifndef Q_OS_WINCE
void setAlertState(bool enabled) Q_DECL_OVERRIDE;
bool isAlertState() const Q_DECL_OVERRIDE { return testFlag(AlertState); }
void alertWindow(int durationMs = 0);
void stopAlertWindow();
-#endif
static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes);
void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
@@ -357,9 +346,6 @@ private:
unsigned m_savedStyle;
QRect m_savedFrameGeometry;
const QSurfaceFormat m_format;
-#ifdef Q_OS_WINCE
- bool m_previouslyHidden;
-#endif
HICON m_iconSmall;
HICON m_iconBig;
void *m_surface;
@@ -368,11 +354,9 @@ private:
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const RECT &r);
QDebug operator<<(QDebug d, const POINT &);
-# ifndef Q_OS_WINCE
QDebug operator<<(QDebug d, const MINMAXINFO &i);
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p);
QDebug operator<<(QDebug d, const WINDOWPLACEMENT &);
-# endif // !Q_OS_WINCE
#endif // !QT_NO_DEBUG_STREAM
// ---------- QWindowsGeometryHint inline functions.
@@ -436,11 +420,7 @@ inline void QWindowsWindow::destroyIcon()
inline bool QWindowsWindow::isLayered() const
{
-#ifndef Q_OS_WINCE
return GetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE) & WS_EX_LAYERED;
-#else
- return false;
-#endif
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
index 48c53592d6..d97e49309f 100644
--- a/src/plugins/platforms/windows/windows.pri
+++ b/src/plugins/platforms/windows/windows.pri
@@ -1,35 +1,20 @@
# Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
-LIBS *= -lole32
-!wince: LIBS *= -luser32 -lwinspool -limm32 -lwinmm -loleaut32
+LIBS += -lole32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32
-contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):!contains(QT_CONFIG, dynamicgl): LIBS *= -lopengl32
+qtConfig(opengl):!qtConfig(opengles2):!qtConfig(dynamicgl): LIBS *= -lopengl32
mingw: LIBS *= -luuid
# For the dialog helpers:
-!wince: LIBS *= -lshlwapi -lshell32
-!wince: LIBS *= -ladvapi32
-wince: DEFINES *= QT_LIBINFIX=L"\"\\\"$${QT_LIBINFIX}\\\"\""
+LIBS += -lshlwapi -lshell32 -ladvapi32
DEFINES *= QT_NO_CAST_FROM_ASCII
-contains(QT_CONFIG, directwrite) {
- contains(QT_CONFIG, directwrite2): \
- DEFINES *= QT_USE_DIRECTWRITE2
-
- SOURCES += $$PWD/qwindowsfontenginedirectwrite.cpp
- HEADERS += $$PWD/qwindowsfontenginedirectwrite.h
-} else {
- DEFINES *= QT_NO_DIRECTWRITE
-}
-
SOURCES += \
$$PWD/qwindowswindow.cpp \
$$PWD/qwindowsintegration.cpp \
$$PWD/qwindowscontext.cpp \
$$PWD/qwindowsscreen.cpp \
$$PWD/qwindowskeymapper.cpp \
- $$PWD/qwindowsfontengine.cpp \
- $$PWD/qwindowsfontdatabase.cpp \
$$PWD/qwindowsmousehandler.cpp \
$$PWD/qwindowsole.cpp \
$$PWD/qwindowsmime.cpp \
@@ -39,7 +24,6 @@ SOURCES += \
$$PWD/qwindowstheme.cpp \
$$PWD/qwindowsdialoghelpers.cpp \
$$PWD/qwindowsservices.cpp \
- $$PWD/qwindowsnativeimage.cpp \
$$PWD/qwindowsnativeinterface.cpp \
$$PWD/qwindowsopengltester.cpp
@@ -49,11 +33,8 @@ HEADERS += \
$$PWD/qwindowscontext.h \
$$PWD/qwindowsscreen.h \
$$PWD/qwindowskeymapper.h \
- $$PWD/qwindowsfontengine.h \
- $$PWD/qwindowsfontdatabase.h \
$$PWD/qwindowsmousehandler.h \
$$PWD/qtwindowsglobal.h \
- $$PWD/qtwindows_additional.h \
$$PWD/qwindowsole.h \
$$PWD/qwindowsmime.h \
$$PWD/qwindowsinternalmimedata.h \
@@ -62,26 +43,24 @@ HEADERS += \
$$PWD/qwindowstheme.h \
$$PWD/qwindowsdialoghelpers.h \
$$PWD/qwindowsservices.h \
- $$PWD/qplatformfunctions_wince.h \
- $$PWD/qwindowsnativeimage.h \
$$PWD/qwindowsnativeinterface.h \
$$PWD/qwindowsopengltester.h \
$$PWD/qwindowsthreadpoolrunner.h
INCLUDEPATH += $$PWD
-contains(QT_CONFIG,opengl): HEADERS += $$PWD/qwindowsopenglcontext.h
+qtConfig(opengl): HEADERS += $$PWD/qwindowsopenglcontext.h
-contains(QT_CONFIG, opengles2) {
+qtConfig(opengles2) {
SOURCES += $$PWD/qwindowseglcontext.cpp
HEADERS += $$PWD/qwindowseglcontext.h
-} else: contains(QT_CONFIG,opengl) {
+} else: qtConfig(opengl) {
SOURCES += $$PWD/qwindowsglcontext.cpp
HEADERS += $$PWD/qwindowsglcontext.h
}
# Dynamic GL needs both WGL and EGL
-contains(QT_CONFIG,dynamicgl) {
+qtConfig(dynamicgl) {
SOURCES += $$PWD/qwindowseglcontext.cpp
HEADERS += $$PWD/qwindowseglcontext.h
}
@@ -101,40 +80,22 @@ contains(QT_CONFIG,dynamicgl) {
}
}
-!wince:!contains( DEFINES, QT_NO_TABLETEVENT ) {
+!contains( DEFINES, QT_NO_TABLETEVENT ) {
INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/wintab
HEADERS += $$PWD/qwindowstabletsupport.h
SOURCES += $$PWD/qwindowstabletsupport.cpp
}
-!wince:!contains( DEFINES, QT_NO_SESSIONMANAGER ) {
+!contains( DEFINES, QT_NO_SESSIONMANAGER ) {
SOURCES += $$PWD/qwindowssessionmanager.cpp
HEADERS += $$PWD/qwindowssessionmanager.h
}
-!wince:!contains( DEFINES, QT_NO_IMAGEFORMAT_PNG ) {
- RESOURCES += $$PWD/cursors.qrc
-}
+!contains( DEFINES, QT_NO_IMAGEFORMAT_PNG ):RESOURCES += $$PWD/cursors.qrc
-!wince: RESOURCES += $$PWD/openglblacklists.qrc
-
-contains(QT_CONFIG, freetype) {
- DEFINES *= QT_NO_FONTCONFIG
- include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
- HEADERS += \
- $$PWD/qwindowsfontdatabase_ft.h
- SOURCES += \
- $$PWD/qwindowsfontdatabase_ft.cpp
-} else:contains(QT_CONFIG, system-freetype) {
- CONFIG += qpa/basicunixfontdatabase
- include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri)
- HEADERS += \
- $$PWD/qwindowsfontdatabase_ft.h
- SOURCES += \
- $$PWD/qwindowsfontdatabase_ft.cpp
-}
+RESOURCES += $$PWD/openglblacklists.qrc
-contains(QT_CONFIG, accessibility):include($$PWD/accessible/accessible.pri)
+qtConfig(accessibility): include($$PWD/accessible/accessible.pri)
DEFINES *= LIBEGL_NAME=$${LIBEGL_NAME}
DEFINES *= LIBGLESV2_NAME=$${LIBGLESV2_NAME}
diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index 2e0f723693..23168c10dc 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -1,10 +1,11 @@
TARGET = qwindows
-QT *= core-private
-QT *= gui-private
-QT *= platformsupport-private
+QT += \
+ core-private gui-private \
+ eventdispatcher_support-private accessibility_support-private \
+ fontdatabase_support-private theme_support-private
-!wince:LIBS *= -lgdi32
+LIBS += -lgdi32 -ldwmapi
include(windows.pri)
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index 5c3ecd8726..8a250c516a 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -51,8 +51,8 @@
#include <QOffscreenSurface>
#include <QOpenGLContext>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
deleted file mode 100644
index d4f2ba1bd6..0000000000
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwinrtfontdatabase.h"
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QFile>
-
-#include <QtCore/QUuid>
-#include <QtGui/private/qfontengine_ft_p.h>
-#include <dwrite_1.h>
-#include <wrl.h>
-using namespace Microsoft::WRL;
-
-QT_BEGIN_NAMESPACE
-
-Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
-
-QDebug operator<<(QDebug d, const QFontDef &def)
-{
- QDebugStateSaver saver(d);
- d.nospace();
- d << "Family=" << def.family << " Stylename=" << def.styleName
- << " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize
- << " styleHint=" << def.styleHint << " weight=" << def.weight
- << " stretch=" << def.stretch << " hintingPreference="
- << def.hintingPreference;
- return d;
-}
-
-// Based on unicode range tables at http://www.microsoft.com/typography/otspec/os2.htm#ur
-static QFontDatabase::WritingSystem writingSystemFromUnicodeRange(const DWRITE_UNICODE_RANGE &range)
-{
- if (range.first >= 0x0000 && range.last <= 0x007F)
- return QFontDatabase::Latin;
- if (range.first >= 0x0370 && range.last <= 0x03FF)
- return QFontDatabase::Greek;
- if (range.first >= 0x0400 && range.last <= 0x04FF)
- return QFontDatabase::Cyrillic;
- if (range.first >= 0x0530 && range.last <= 0x058F)
- return QFontDatabase::Armenian;
- if (range.first >= 0x0590 && range.last <= 0x05FF)
- return QFontDatabase::Hebrew;
- if (range.first >= 0x0600 && range.last <= 0x06FF)
- return QFontDatabase::Arabic;
- if (range.first >= 0x0700 && range.last <= 0x074F)
- return QFontDatabase::Syriac;
- if (range.first >= 0x0780 && range.last <= 0x07BF)
- return QFontDatabase::Thaana;
- if (range.first >= 0x0900 && range.last <= 0x097F)
- return QFontDatabase::Devanagari;
- if (range.first >= 0x0980 && range.last <= 0x09FF)
- return QFontDatabase::Bengali;
- if (range.first >= 0x0A00 && range.last <= 0x0A7F)
- return QFontDatabase::Gurmukhi;
- if (range.first >= 0x0A80 && range.last <= 0x0AFF)
- return QFontDatabase::Gujarati;
- if (range.first >= 0x0B00 && range.last <= 0x0B7F)
- return QFontDatabase::Oriya;
- if (range.first >= 0x0B80 && range.last <= 0x0BFF)
- return QFontDatabase::Tamil;
- if (range.first >= 0x0C00 && range.last <= 0x0C7F)
- return QFontDatabase::Telugu;
- if (range.first >= 0x0C80 && range.last <= 0x0CFF)
- return QFontDatabase::Kannada;
- if (range.first >= 0x0D00 && range.last <= 0x0D7F)
- return QFontDatabase::Malayalam;
- if (range.first >= 0x0D80 && range.last <= 0x0DFF)
- return QFontDatabase::Sinhala;
- if (range.first >= 0x0E00 && range.last <= 0x0E7F)
- return QFontDatabase::Thai;
- if (range.first >= 0x0E80 && range.last <= 0x0EFF)
- return QFontDatabase::Lao;
- if (range.first >= 0x0F00 && range.last <= 0x0FFF)
- return QFontDatabase::Tibetan;
- if (range.first >= 0x1000 && range.last <= 0x109F)
- return QFontDatabase::Myanmar;
- if (range.first >= 0x10A0 && range.last <= 0x10FF)
- return QFontDatabase::Georgian;
- if (range.first >= 0x1780 && range.last <= 0x17FF)
- return QFontDatabase::Khmer;
- if (range.first >= 0x4E00 && range.last <= 0x9FFF)
- return QFontDatabase::SimplifiedChinese;
- if (range.first >= 0xAC00 && range.last <= 0xD7AF)
- return QFontDatabase::Korean;
- if (range.first >= 0x1680 && range.last <= 0x169F)
- return QFontDatabase::Ogham;
- if (range.first >= 0x16A0 && range.last <= 0x16FF)
- return QFontDatabase::Runic;
- if (range.first >= 0x07C0 && range.last <= 0x07FF)
- return QFontDatabase::Nko;
-
- return QFontDatabase::Other;
-}
-
-QString QWinRTFontDatabase::fontDir() const
-{
- qCDebug(lcQpaFonts) << __FUNCTION__;
- QString fontDirectory = QBasicFontDatabase::fontDir();
- if (!QFile::exists(fontDirectory)) {
- // Fall back to app directory + fonts, and just app directory after that
- const QString applicationDirPath = QCoreApplication::applicationDirPath();
- fontDirectory = applicationDirPath + QLatin1String("/fonts");
- if (!QFile::exists(fontDirectory)) {
- if (m_fontFamilies.isEmpty())
- qWarning("No fonts directory found in application package.");
- fontDirectory = applicationDirPath;
- }
- }
- return fontDirectory;
-}
-
-QWinRTFontDatabase::~QWinRTFontDatabase()
-{
- qCDebug(lcQpaFonts) << __FUNCTION__;
-
- foreach (IDWriteFontFile *fontFile, m_fonts.keys())
- fontFile->Release();
-
- foreach (IDWriteFontFamily *fontFamily, m_fontFamilies)
- fontFamily->Release();
-}
-
-QFont QWinRTFontDatabase::defaultFont() const
-{
- return QFont(QStringLiteral("Segoe UI"));
-}
-
-bool QWinRTFontDatabase::fontsAlwaysScalable() const
-{
- return true;
-}
-
-void QWinRTFontDatabase::populateFontDatabase()
-{
- qCDebug(lcQpaFonts) << __FUNCTION__;
-
- ComPtr<IDWriteFactory1> factory;
- HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory1), &factory);
- if (FAILED(hr)) {
- qWarning("Failed to create DirectWrite factory: %s", qPrintable(qt_error_string(hr)));
- QBasicFontDatabase::populateFontDatabase();
- return;
- }
-
- ComPtr<IDWriteFontCollection> fontCollection;
- hr = factory->GetSystemFontCollection(&fontCollection);
- if (FAILED(hr)) {
- qWarning("Failed to open system font collection: %s", qPrintable(qt_error_string(hr)));
- QBasicFontDatabase::populateFontDatabase();
- return;
- }
-
- int fontFamilyCount = fontCollection->GetFontFamilyCount();
- for (int i = 0; i < fontFamilyCount; ++i) {
- ComPtr<IDWriteFontFamily> fontFamily;
- hr = fontCollection->GetFontFamily(i, &fontFamily);
- if (FAILED(hr)) {
- qWarning("Unable to get font family: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
-
- ComPtr<IDWriteLocalizedStrings> names;
- hr = fontFamily->GetFamilyNames(&names);
- if (FAILED(hr)) {
- qWarning("Unable to get font family names: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- quint32 familyNameLength;
- hr = names->GetStringLength(0, &familyNameLength);
- if (FAILED(hr)) {
- qWarning("Unable to get family name length: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- QVector<wchar_t> familyBuffer(familyNameLength + 1);
- hr = names->GetString(0, familyBuffer.data(), familyBuffer.size());
- if (FAILED(hr)) {
- qWarning("Unable to create font family name: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- QString familyName = QString::fromWCharArray(familyBuffer.data(), familyNameLength);
-
- m_fontFamilies.insert(familyName, fontFamily.Detach());
-
- registerFontFamily(familyName);
- }
-
- QBasicFontDatabase::populateFontDatabase();
-}
-
-void QWinRTFontDatabase::populateFamily(const QString &familyName)
-{
- qCDebug(lcQpaFonts) << __FUNCTION__ << familyName;
-
- IDWriteFontFamily *fontFamily = m_fontFamilies.value(familyName);
- if (!fontFamily) {
- qWarning("The font family %s was not found.", qPrintable(familyName));
- return;
- }
-
- bool fontRegistered = false;
- const int fontCount = fontFamily->GetFontCount();
- for (int j = 0; j < fontCount; ++j) {
- ComPtr<IDWriteFont> font;
- HRESULT hr = fontFamily->GetFont(j, &font);
- if (FAILED(hr)) {
- qWarning("Unable to get font: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
-
- // Skip simulated faces
- if (font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE)
- continue;
-
- ComPtr<IDWriteFontFace> baseFontFace;
- hr = font->CreateFontFace(&baseFontFace);
- if (FAILED(hr)) {
- qWarning("Unable to create base font face: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- ComPtr<IDWriteFontFace1> fontFace;
- hr = baseFontFace.As(&fontFace);
- if (FAILED(hr)) {
- qWarning("Unable to create font face: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
-
- // We can't deal with multi-file fonts
- quint32 fileCount;
- hr = fontFace->GetFiles(&fileCount, NULL);
- if (FAILED(hr)) {
- qWarning("Unable to get font file count: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- if (fileCount != 1)
- continue;
-
- ComPtr<IDWriteLocalizedStrings> informationalStrings;
- BOOL exists;
- hr = font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_MANUFACTURER,
- &informationalStrings, &exists);
- if (FAILED(hr)) {
- qWarning("Unable to get font foundry: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- QString foundryName;
- if (exists) {
- quint32 length;
- hr = informationalStrings->GetStringLength(0, &length);
- if (FAILED(hr))
- qWarning("Unable to get foundry name length: %s", qPrintable(qt_error_string(hr)));
- if (SUCCEEDED(hr)) {
- QVector<wchar_t> buffer(length + 1);
- hr = informationalStrings->GetString(0, buffer.data(), buffer.size());
- if (FAILED(hr))
- qWarning("Unable to get foundry name: %s", qPrintable(qt_error_string(hr)));
- if (SUCCEEDED(hr))
- foundryName = QString::fromWCharArray(buffer.data(), length);
- }
- }
-
- QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(font->GetWeight());
-
- QFont::Style style;
- switch (font->GetStyle()) {
- default:
- case DWRITE_FONT_STYLE_NORMAL:
- style = QFont::StyleNormal;
- break;
- case DWRITE_FONT_STYLE_OBLIQUE:
- style = QFont::StyleOblique;
- break;
- case DWRITE_FONT_STYLE_ITALIC:
- style = QFont::StyleItalic;
- break;
- }
-
- QFont::Stretch stretch;
- switch (font->GetStretch()) {
- default:
- case DWRITE_FONT_STRETCH_UNDEFINED:
- case DWRITE_FONT_STRETCH_NORMAL:
- stretch = QFont::Unstretched;
- break;
- case DWRITE_FONT_STRETCH_ULTRA_CONDENSED:
- stretch = QFont::UltraCondensed;
- break;
- case DWRITE_FONT_STRETCH_EXTRA_CONDENSED:
- stretch = QFont::ExtraCondensed;
- break;
- case DWRITE_FONT_STRETCH_CONDENSED:
- stretch = QFont::Condensed;
- break;
- case DWRITE_FONT_STRETCH_SEMI_CONDENSED:
- stretch = QFont::SemiCondensed;
- break;
- case DWRITE_FONT_STRETCH_SEMI_EXPANDED:
- stretch = QFont::SemiExpanded;
- break;
- case DWRITE_FONT_STRETCH_EXPANDED:
- stretch = QFont::Expanded;
- break;
- case DWRITE_FONT_STRETCH_EXTRA_EXPANDED:
- stretch = QFont::ExtraExpanded;
- break;
- case DWRITE_FONT_STRETCH_ULTRA_EXPANDED:
- stretch = QFont::UltraExpanded;
- break;
- }
-
- const bool fixedPitch = fontFace->IsMonospacedFont();
-
- // Get writing systems from unicode ranges
- quint32 actualRangeCount;
- hr = fontFace->GetUnicodeRanges(0, nullptr, &actualRangeCount);
- Q_ASSERT(hr == E_NOT_SUFFICIENT_BUFFER);
- QVector<DWRITE_UNICODE_RANGE> unicodeRanges(actualRangeCount);
- hr = fontFace->GetUnicodeRanges(actualRangeCount, unicodeRanges.data(), &actualRangeCount);
- if (FAILED(hr)) {
- qWarning("Unable to get font unicode range: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
- QSupportedWritingSystems writingSystems;
- for (quint32 i = 0; i < actualRangeCount; ++i) {
- const QFontDatabase::WritingSystem writingSystem = writingSystemFromUnicodeRange(unicodeRanges.at(i));
- writingSystems.setSupported(writingSystem);
- }
- if (writingSystems.supported(QFontDatabase::SimplifiedChinese)) {
- writingSystems.setSupported(QFontDatabase::TraditionalChinese);
- writingSystems.setSupported(QFontDatabase::Japanese);
- }
- if (writingSystems.supported(QFontDatabase::Latin))
- writingSystems.setSupported(QFontDatabase::Vietnamese);
-
- IDWriteFontFile *fontFile;
- hr = fontFace->GetFiles(&fileCount, &fontFile);
- if (FAILED(hr)) {
- qWarning("Unable to get font file: %s", qPrintable(qt_error_string(hr)));
- continue;
- }
-
- FontDescription description = { fontFace->GetIndex(), QUuid::createUuid().toByteArray() };
- m_fonts.insert(fontFile, description);
- registerFont(familyName, QString(), foundryName, weight, style, stretch,
- true, true, 0, fixedPitch, writingSystems, fontFile);
- fontRegistered = true;
- }
-
- // Always populate something to avoid an assert
- if (!fontRegistered) {
- registerFont(familyName, QString(), QString(), QFont::Normal, QFont::StyleNormal,
- QFont::Unstretched, false, false, 0, false, QSupportedWritingSystems(), 0);
- }
-}
-
-QFontEngine *QWinRTFontDatabase::fontEngine(const QFontDef &fontDef, void *handle)
-{
- qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef << handle;
-
- if (!handle) // Happens if a font family population failed
- return 0;
-
- IDWriteFontFile *fontFile = reinterpret_cast<IDWriteFontFile *>(handle);
- if (!m_fonts.contains(fontFile))
- return QBasicFontDatabase::fontEngine(fontDef, handle);
-
- const void *referenceKey;
- quint32 referenceKeySize;
- HRESULT hr = fontFile->GetReferenceKey(&referenceKey, &referenceKeySize);
- if (FAILED(hr)) {
- qWarning("Unable to get font file reference key: %s", qPrintable(qt_error_string(hr)));
- return 0;
- }
-
- ComPtr<IDWriteFontFileLoader> loader;
- hr = fontFile->GetLoader(&loader);
- if (FAILED(hr)) {
- qWarning("Unable to get font file loader: %s", qPrintable(qt_error_string(hr)));
- return 0;
- }
-
- ComPtr<IDWriteFontFileStream> stream;
- hr =loader->CreateStreamFromKey(referenceKey, referenceKeySize, &stream);
- if (FAILED(hr)) {
- qWarning("Unable to get font file stream: %s", qPrintable(qt_error_string(hr)));
- return 0;
- }
-
- quint64 fileSize;
- hr = stream->GetFileSize(&fileSize);
- if (FAILED(hr)) {
- qWarning("Unable to get font file size: %s", qPrintable(qt_error_string(hr)));
- return 0;
- }
-
- const void *data;
- void *context;
- hr = stream->ReadFileFragment(&data, 0, fileSize, &context);
- if (FAILED(hr)) {
- qWarning("Unable to get font file data: %s", qPrintable(qt_error_string(hr)));
- return 0;
- }
- const QByteArray fontData((const char *)data, fileSize);
- stream->ReleaseFileFragment(context);
-
- QFontEngine::FaceId faceId;
- const FontDescription description = m_fonts.value(fontFile);
- faceId.uuid = description.uuid;
- faceId.index = description.index;
- const bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
- QFontEngineFT::GlyphFormat format = antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
- QFontEngineFT *engine = new QFontEngineFT(fontDef);
- if (!engine->init(faceId, antialias, format, fontData) || engine->invalid()) {
- delete engine;
- return 0;
- }
-
- return engine;
-}
-
-QStringList QWinRTFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style,
- QFont::StyleHint styleHint,
- QChar::Script script) const
-{
- Q_UNUSED(style)
- Q_UNUSED(styleHint)
- Q_UNUSED(script)
-
- qCDebug(lcQpaFonts) << __FUNCTION__ << family;
-
- QStringList result;
- if (family == QLatin1String("Helvetica"))
- result.append(QStringLiteral("Arial"));
- result.append(QBasicFontDatabase::fallbacksForFamily(family, style, styleHint, script));
- return result;
-}
-
-void QWinRTFontDatabase::releaseHandle(void *handle)
-{
- qCDebug(lcQpaFonts) << __FUNCTION__ << handle;
-
- if (!handle)
- return;
-
- IDWriteFontFile *fontFile = reinterpret_cast<IDWriteFontFile *>(handle);
- if (m_fonts.contains(fontFile)) {
- m_fonts.remove(fontFile);
- fontFile->Release();
- return;
- }
-
- QBasicFontDatabase::releaseHandle(handle);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
index 3f476556ee..63e5b0cf27 100644
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
@@ -39,6 +39,7 @@
#include "qwinrtinputcontext.h"
#include "qwinrtscreen.h"
+#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <private/qeventdispatcher_winrt_p.h>
@@ -59,7 +60,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods")
-inline QRectF getInputPaneRect(IInputPane *pane, qreal scaleFactor)
+inline QRectF getInputPaneRect(ComPtr<IInputPane> pane, qreal scaleFactor)
{
Rect rect;
pane->get_OccludedRect(&rect);
@@ -85,28 +86,33 @@ QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen)
{
qCDebug(lcQpaInputMethods) << __FUNCTION__ << screen;
- IInputPaneStatics *statics;
- if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
- &statics))) {
- qWarning("failed to retrieve input pane statics.");
- return;
- }
+ QEventDispatcherWinRT::runOnXamlThread([this]() {
+ ComPtr<IInputPaneStatics> statics;
+ if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
+ &statics))) {
+ qWarning("failed to retrieve input pane statics.");
+ return S_OK;
+ }
+
+ ComPtr<IInputPane> inputPane;
+ statics->GetForCurrentView(&inputPane);
+ if (inputPane) {
+ EventRegistrationToken showToken, hideToken;
+ inputPane->add_Showing(Callback<InputPaneVisibilityHandler>(
+ this, &QWinRTInputContext::onShowing).Get(), &showToken);
+ inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
+ this, &QWinRTInputContext::onHiding).Get(), &hideToken);
+
+ m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor());
+ m_isInputPanelVisible = !m_keyboardRect.isEmpty();
+ } else {
+ qWarning("failed to retrieve InputPane.");
+ }
+ return S_OK;
+ });
- IInputPane *inputPane;
- statics->GetForCurrentView(&inputPane);
- statics->Release();
- if (inputPane) {
- EventRegistrationToken showToken, hideToken;
- inputPane->add_Showing(Callback<InputPaneVisibilityHandler>(
- this, &QWinRTInputContext::onShowing).Get(), &showToken);
- inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
- this, &QWinRTInputContext::onHiding).Get(), &hideToken);
-
- m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor());
- m_isInputPanelVisible = !m_keyboardRect.isEmpty();
- } else {
- qWarning("failed to retrieve InputPane.");
- }
+ connect(QGuiApplication::inputMethod(), &QInputMethod::cursorRectangleChanged,
+ this, &QWinRTInputContext::updateScreenCursorRect);
}
QRectF QWinRTInputContext::keyboardRect() const
@@ -119,6 +125,11 @@ bool QWinRTInputContext::isInputPanelVisible() const
return m_isInputPanelVisible;
}
+void QWinRTInputContext::updateScreenCursorRect()
+{
+ m_screen->setCursorRect(QGuiApplication::inputMethod()->cursorRectangle());
+}
+
HRESULT QWinRTInputContext::onShowing(IInputPane *pane, IInputPaneVisibilityEventArgs *)
{
qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
@@ -141,6 +152,7 @@ HRESULT QWinRTInputContext::handleVisibilityChange(IInputPane *pane)
const QRectF keyboardRect = getInputPaneRect(pane, m_screen->scaleFactor());
if (m_keyboardRect != keyboardRect) {
m_keyboardRect = keyboardRect;
+ m_screen->setKeyboardRect(m_keyboardRect);
emitKeyboardRectChanged();
}
return S_OK;
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.h b/src/plugins/platforms/winrt/qwinrtinputcontext.h
index 5e416bb99f..9d5c4187e2 100644
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.h
+++ b/src/plugins/platforms/winrt/qwinrtinputcontext.h
@@ -79,6 +79,9 @@ public:
void hideInputPanel();
#endif
+private slots:
+ void updateScreenCursorRect();
+
private:
HRESULT onShowing(ABI::Windows::UI::ViewManagement::IInputPane *,
ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs *);
@@ -89,6 +92,7 @@ private:
QWinRTScreen *m_screen;
QRectF m_keyboardRect;
+ QRectF m_cursorRect;
bool m_isInputPanelVisible;
};
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 42b7f7e909..ffc3bbf077 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -45,7 +45,6 @@
#include "qwinrtinputcontext.h"
#include "qwinrtservices.h"
#include "qwinrteglcontext.h"
-#include "qwinrtfontdatabase.h"
#include "qwinrttheme.h"
#include "qwinrtclipboard.h"
#ifndef QT_NO_DRAGANDDROP
@@ -56,7 +55,8 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QSurface>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtFontDatabaseSupport/private/qwinrtfontdatabase_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformoffscreensurface.h>
@@ -197,9 +197,9 @@ QWinRTIntegration::QWinRTIntegration() : d_ptr(new QWinRTIntegrationPrivate)
QEventDispatcherWinRT::runOnXamlThread([d]() {
d->mainScreen = new QWinRTScreen;
- d->inputContext.reset(new QWinRTInputContext(d->mainScreen));
return S_OK;
});
+ d->inputContext.reset(new QWinRTInputContext(d->mainScreen));
screenAdded(d->mainScreen);
d->platformServices = new QWinRTServices;
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index c120de9d8f..6d4edcc8dc 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -625,7 +625,7 @@ int QWinRTScreen::depth() const
QImage::Format QWinRTScreen::format() const
{
- return QImage::Format_ARGB32_Premultiplied;
+ return QImage::Format_RGB32;
}
QSizeF QWinRTScreen::physicalSize() const
@@ -753,12 +753,66 @@ void QWinRTScreen::initialize()
onVisibilityChanged(nullptr, nullptr);
}
+void QWinRTScreen::setCursorRect(const QRectF &cursorRect)
+{
+ mCursorRect = cursorRect;
+}
+
+void QWinRTScreen::setKeyboardRect(const QRectF &keyboardRect)
+{
+ Q_D(QWinRTScreen);
+ QRectF visibleRectF;
+ HRESULT hr;
+ Rect windowSize;
+
+ hr = d->coreWindow->get_Bounds(&windowSize);
+ if (FAILED(hr)) {
+ qErrnoWarning(hr, "Failed to get window bounds");
+ return;
+ }
+ d->logicalRect = QRectF(windowSize.X, windowSize.Y, windowSize.Width, windowSize.Height);
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
+ Rect visibleRect;
+ hr = d->view2->get_VisibleBounds(&visibleRect);
+ if (FAILED(hr)) {
+ qErrnoWarning(hr, "Failed to get window visible bounds");
+ return;
+ }
+ visibleRectF = QRectF(visibleRect.X, visibleRect.Y, visibleRect.Width, visibleRect.Height);
+#else
+ visibleRectF = d->logicalRect;
+#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
+ // if keyboard is snapped to the bottom of the screen and would cover the cursor the content is
+ // moved up to make it visible
+ if (keyboardRect.intersects(mCursorRect)
+ && qFuzzyCompare(geometry().height(), keyboardRect.y() + keyboardRect.height())) {
+ visibleRectF.moveTop(visibleRectF.top() - keyboardRect.height() / d->scaleFactor);
+ }
+ d->visibleRect = visibleRectF;
+
+ qCDebug(lcQpaWindows) << __FUNCTION__ << d->visibleRect;
+ QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry());
+ QPlatformScreen::resizeMaximizedWindows();
+ handleExpose();
+}
+
QWindow *QWinRTScreen::topWindow() const
{
Q_D(const QWinRTScreen);
return d->visibleWindows.isEmpty() ? 0 : d->visibleWindows.first();
}
+QWindow *QWinRTScreen::windowAt(const QPoint &pos)
+{
+ Q_D(const QWinRTScreen);
+ for (auto w : qAsConst(d->visibleWindows)) {
+ if (w->geometry().contains(pos))
+ return w;
+ }
+ qCDebug(lcQpaWindows) << __FUNCTION__ << ": No window found at:" << pos;
+ return nullptr;
+}
+
void QWinRTScreen::addWindow(QWindow *window)
{
Q_D(QWinRTScreen);
@@ -767,8 +821,12 @@ void QWinRTScreen::addWindow(QWindow *window)
return;
d->visibleWindows.prepend(window);
- updateWindowTitle(window->title());
- QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason);
+ const Qt::WindowType type = window->type();
+ if (type != Qt::Popup && type != Qt::ToolTip && type != Qt::Tool) {
+ updateWindowTitle(window->title());
+ QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason);
+ }
+
handleExpose();
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
@@ -785,7 +843,9 @@ void QWinRTScreen::removeWindow(QWindow *window)
const bool wasTopWindow = window == topWindow();
if (!d->visibleWindows.removeAll(window))
return;
- if (wasTopWindow)
+
+ const Qt::WindowType type = window->type();
+ if (wasTopWindow && type != Qt::Popup && type != Qt::ToolTip && type != Qt::Tool)
QWindowSystemInterface::handleWindowActivated(Q_NULLPTR, Qt::OtherFocusReason);
handleExpose();
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
@@ -1001,9 +1061,12 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args)
pointerPoint->get_Position(&point);
QPointF pos(point.X * d->scaleFactor, point.Y * d->scaleFactor);
QPointF localPos = pos;
- if (topWindow()) {
- const QPointF globalPosDelta = pos - pos.toPoint();
- localPos = topWindow()->mapFromGlobal(pos.toPoint()) + globalPosDelta;
+
+ const QPoint posPoint = pos.toPoint();
+ QWindow *targetWindow = windowAt(posPoint);
+ if (targetWindow) {
+ const QPointF globalPosDelta = pos - posPoint;
+ localPos = targetWindow->mapFromGlobal(posPoint) + globalPosDelta;
}
VirtualKeyModifiers modifiers;
@@ -1038,7 +1101,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args)
boolean isHorizontal;
properties->get_IsHorizontalMouseWheel(&isHorizontal);
QPoint angleDelta(isHorizontal ? delta : 0, isHorizontal ? 0 : delta);
- QWindowSystemInterface::handleWheelEvent(topWindow(), localPos, pos, QPoint(), angleDelta, mods);
+ QWindowSystemInterface::handleWheelEvent(targetWindow, localPos, pos, QPoint(), angleDelta, mods);
break;
}
@@ -1064,7 +1127,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args)
if (isPressed)
buttons |= Qt::XButton2;
- QWindowSystemInterface::handleMouseEvent(topWindow(), localPos, pos, buttons, mods);
+ QWindowSystemInterface::handleMouseEvent(targetWindow, localPos, pos, buttons, mods);
break;
}
@@ -1122,7 +1185,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args)
it.value().normalPosition = QPointF(point.X/d->logicalRect.width(), point.Y/d->logicalRect.height());
it.value().pressure = pressure;
- QWindowSystemInterface::handleTouchEvent(topWindow(), d->touchDevice, d->touchPoints.values(), mods);
+ QWindowSystemInterface::handleTouchEvent(targetWindow, d->touchDevice, d->touchPoints.values(), mods);
// Fall-through for pen to generate tablet event
if (pointerDeviceType != PointerDeviceType_Pen)
@@ -1141,7 +1204,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args)
float rotation;
properties->get_Twist(&rotation);
- QWindowSystemInterface::handleTabletEvent(topWindow(), isPressed, pos, pos, 0,
+ QWindowSystemInterface::handleTabletEvent(targetWindow, isPressed, pos, pos, 0,
pointerType, pressure, xTilt, yTilt,
0, rotation, 0, id, mods);
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h
index 0e753b748b..e489e208d5 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.h
+++ b/src/plugins/platforms/winrt/qwinrtscreen.h
@@ -104,6 +104,7 @@ public:
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE;
QWindow *topWindow() const;
+ QWindow *windowAt(const QPoint &pos);
void addWindow(QWindow *window);
void removeWindow(QWindow *window);
void raise(QWindow *window);
@@ -116,6 +117,9 @@ public:
void initialize();
+ void setCursorRect(const QRectF &cursorRect);
+ void setKeyboardRect(const QRectF &keyboardRect);
+
private:
void handleExpose();
@@ -140,6 +144,7 @@ private:
#endif
QScopedPointer<QWinRTScreenPrivate> d_ptr;
+ QRectF mCursorRect;
Q_DECLARE_PRIVATE(QWinRTScreen)
};
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
index e9938894e6..f84688f045 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.cpp
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -369,6 +369,17 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint)
return QVariant();
}
+QVariant QWinRTTheme::themeHint(ThemeHint hint) const
+{
+ qCDebug(lcQpaTheme) << __FUNCTION__ << hint;
+ switch (hint) {
+ case StyleNames:
+ return QStringList() << QStringLiteral("fusion") << QStringLiteral("windows");
+ default:
+ return QPlatformTheme::themeHint(hint);
+ }
+}
+
const QPalette *QWinRTTheme::palette(Palette type) const
{
Q_D(const QWinRTTheme);
diff --git a/src/plugins/platforms/winrt/qwinrttheme.h b/src/plugins/platforms/winrt/qwinrttheme.h
index 2b8817d014..bd244f9fdb 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.h
+++ b/src/plugins/platforms/winrt/qwinrttheme.h
@@ -60,7 +60,7 @@ public:
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
static QVariant styleHint(QPlatformIntegration::StyleHint hint);
-
+ QVariant themeHint(ThemeHint hint) const override;
private:
QScopedPointer<QWinRTThemePrivate> d_ptr;
Q_DECLARE_PRIVATE(QWinRTTheme)
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp
index 5b82183d40..297e6618d1 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.cpp
+++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp
@@ -50,7 +50,7 @@
#include <QtGui/QGuiApplication>
#include <QtGui/QOpenGLContext>
#include <QtGui/QWindow>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <functional>
#include <wrl.h>
diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro
index 28456f66ec..be2f5ca7e2 100644
--- a/src/plugins/platforms/winrt/winrt.pro
+++ b/src/plugins/platforms/winrt/winrt.pro
@@ -2,12 +2,13 @@ TARGET = qwinrt
CONFIG -= precompile_header
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ fontdatabase_support-private egl_support-private
DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__
-LIBS += $$QMAKE_LIBS_CORE -ldwrite -ld3d11
-INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/freetype/include
+LIBS += $$QMAKE_LIBS_CORE -ld3d11
SOURCES = \
main.cpp \
@@ -19,7 +20,6 @@ SOURCES = \
qwinrteventdispatcher.cpp \
qwinrtfiledialoghelper.cpp \
qwinrtfileengine.cpp \
- qwinrtfontdatabase.cpp \
qwinrtinputcontext.cpp \
qwinrtintegration.cpp \
qwinrtmessagedialoghelper.cpp \
@@ -38,7 +38,6 @@ HEADERS = \
qwinrteventdispatcher.h \
qwinrtfiledialoghelper.h \
qwinrtfileengine.h \
- qwinrtfontdatabase.h \
qwinrtinputcontext.h \
qwinrtintegration.h \
qwinrtmessagedialoghelper.h \
diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README
index 15cf4cf241..5efc9b7f99 100644
--- a/src/plugins/platforms/xcb/README
+++ b/src/plugins/platforms/xcb/README
@@ -21,3 +21,13 @@ REDUCING RUNTIME DEPENDENCIES
The '-qt-xcb' configure option can be used to get rid of most xcb- dependencies. Only libxcb will
still be linked dynamically, since it will be most likely be pulled in via other dependencies anyway.
This should allow for binaries that are portable across most modern Linux distributions.
+
+PACKAGE VERSION REQUIREMENTS
+
+When using touch input via XInput 2.2 or higher, there is a potential issue on systems that ship with
+a libXi older than 1.7.4. This is because XIAllowTouchEvents can deadlock with libXi 1.7.3 and earlier.
+When touch events are never received, this is not an issue, so plain mouse/keyboard systems are not affected.
+See http://lists.x.org/archives/xorg-devel/2014-July/043059.html for details on the libXi patch.
+Qt versions before 5.8 attempted to recognize this scenario based on the pkg-config package version and skip
+the call. This has been removed starting from 5.8 since relying on pkg-config package versions is unsafe given
+that Qt must also support systems with limited or incomplete pkg-config setups.
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
index 9de0476810..b8f878ffe8 100644
--- a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
@@ -1,9 +1,10 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += gui-private
-contains(QT_CONFIG, egl): contains(QT_CONFIG, egl_x11): contains(QT_CONFIG, opengl) {
+qtConfig(egl):qtConfig(egl_x11):qtConfig(opengl) {
SUBDIRS += xcb_egl
}
-contains(QT_CONFIG, xcb-xlib): contains(QT_CONFIG, opengl): !contains(QT_CONFIG, opengles2) {
+qtConfig(xcb-xlib):qtConfig(opengl):!qtConfig(opengles2) {
SUBDIRS += xcb_glx
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri
index 68cb91ff3d..4ab406acb9 100644
--- a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri
@@ -1,4 +1,4 @@
-QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
+QT += core-private gui-private xcb_qpa_lib-private
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/../
@@ -6,35 +6,26 @@ INCLUDEPATH += $$PWD/../
load(qt_build_paths)
# needed by Xcursor ...
-contains(QT_CONFIG, xcb-xlib) {
+qtConfig(xcb-xlib) {
DEFINES += XCB_USE_XLIB
- contains(QT_CONFIG, xinput2) {
+ qtConfig(xinput2) {
DEFINES += XCB_USE_XINPUT2
}
}
-# to support custom cursors with depth > 1
-contains(QT_CONFIG, xcb-render) {
- DEFINES += XCB_USE_RENDER
-}
-
# build with session management support
-contains(QT_CONFIG, xcb-sm) {
+qtConfig(xcb-sm) {
DEFINES += XCB_USE_SM
}
-DEFINES += $$QMAKE_DEFINES_XCB
-LIBS += $$QMAKE_LIBS_XCB
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
-
-CONFIG += qpa/genericunixfontdatabase
-
-contains(QT_CONFIG, xcb-qt) {
+!qtConfig(system-xcb) {
DEFINES += XCB_USE_RENDER
- XCB_DIR = $$clean_path($$PWD/../../../../3rdparty/xcb)
- INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/include/xcb $$XCB_DIR/sysinclude
- LIBS += -lxcb -L$$MODULE_BASE_OUTDIR/lib -lxcb-static$$qtPlatformTargetSuffix()
+ QMAKE_USE += xcb-static xcb
} else {
- LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms
- !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb
+ qtConfig(xkb): QMAKE_USE += xcb_xkb
+ # to support custom cursors with depth > 1
+ qtConfig(xcb-render) {
+ DEFINES += XCB_USE_RENDER
+ }
+ QMAKE_USE += xcb_syslibs
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
index 64e9bec6db..48e774bbb2 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
@@ -41,8 +41,8 @@
#define QXCBEGLCONTEXT_H
#include "qxcbeglwindow.h"
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtEglSupport/private/qeglplatformcontext_p.h>
+#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <QtPlatformHeaders/QEGLNativeContext>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
index 7c6524c8ee..a5a47dd0bb 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
@@ -46,7 +46,7 @@
#include <QtGui/private/qcssparser_p.h>
#include <QtGui/private/qtextengine_p.h>
-#include <QtPlatformSupport/private/qt_egl_p.h>
+#include <QtEglSupport/private/qt_egl_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
index 079f0466dc..4852d38f7e 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
@@ -42,6 +42,7 @@
#include "qxcbeglcontext.h"
#include <QtGui/QOffscreenSurface>
+#include <QtEglSupport/private/qeglstreamconvenience_p.h>
#include "qxcbeglnativeinterfacehandler.h"
@@ -63,7 +64,18 @@ QXcbEglIntegration::~QXcbEglIntegration()
bool QXcbEglIntegration::initialize(QXcbConnection *connection)
{
m_connection = connection;
- m_egl_display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(xlib_display()));
+
+ const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+
+ if (extensions && strstr(extensions, "EGL_EXT_platform_x11")) {
+ QEGLStreamConvenience streamFuncs;
+ m_egl_display = streamFuncs.get_platform_display(EGL_PLATFORM_X11_KHR,
+ xlib_display(),
+ nullptr);
+ }
+
+ if (!m_egl_display)
+ m_egl_display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(xlib_display()));
EGLint major, minor;
bool success = eglInitialize(m_egl_display, &major, &minor);
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
index 69b7dfbdbf..3f7ef94238 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
@@ -41,8 +41,8 @@
#include "qxcbeglintegration.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qxlibeglintegration_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
index 6d52332bad..1c193849ca 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
@@ -1,10 +1,13 @@
TARGET = qxcb-egl-integration
include(../gl_integrations_plugin_base.pri)
+QT += egl_support-private
CONFIG += egl
-contains(QT_CONFIG, xcb-xlib): DEFINES += XCB_USE_XLIB
+qtConfig(xcb-xlib): DEFINES += XCB_USE_XLIB
+
+DEFINES += QT_NO_FOREACH
HEADERS += \
qxcbeglcontext.h \
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index 4c4176a063..1f36a1ad2a 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -51,7 +51,7 @@
#include <QtGui/QOffscreenSurface>
#include "qglxintegration.h"
-#include <QtPlatformSupport/private/qglxconvenience_p.h>
+#include <QtGlxSupport/private/qglxconvenience_p.h>
#include <QtPlatformHeaders/QGLXNativeContext>
#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
index a8d51d5e8c..8df8b28f72 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
@@ -40,7 +40,7 @@
#include "qxcbglxwindow.h"
#include "qxcbscreen.h"
-#include <QtPlatformSupport/private/qglxconvenience_p.h>
+#include <QtGlxSupport/private/qglxconvenience_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
index 67fd68765a..8aa6e1febd 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
@@ -1,15 +1,15 @@
TARGET = qxcb-glx-integration
include(../gl_integrations_plugin_base.pri)
+QT += glx_support-private
#should be removed from the sources
DEFINES += XCB_USE_GLX XCB_USE_XLIB
+DEFINES += QT_NO_FOREACH
-LIBS += -lxcb
-
-contains(QT_CONFIG, xcb-glx) {
+qtConfig(xcb-glx) {
DEFINES += XCB_HAS_XCB_GLX
- LIBS += -lxcb-glx
+ QMAKE_USE += xcb_glx
}
LIBS += $$QMAKE_LIBS_DYNLOAD
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index ce9e5d926e..3d09b1c139 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -225,14 +225,14 @@ bool QXcbShmImage::scroll(const QRegion &area, int dx, int dy)
preparePaint(area);
const QPoint delta(dx, dy);
- foreach (const QRect &rect, area.rects())
+ for (const QRect &rect : area)
qt_scrollRectInImage(*image(), rect, delta);
if (m_xcb_pixmap) {
flushPixmap(area);
ensureGC(m_xcb_pixmap);
const QRect bounds(QPoint(0, 0), size());
- foreach (const QRect &src, area.rects()) {
+ for (const QRect &src : area) {
const QRect dst = src.translated(delta).intersected(bounds);
Q_XCB_CALL(xcb_copy_area(xcb_connection(),
m_xcb_pixmap,
@@ -533,11 +533,9 @@ void QXcbBackingStore::beginPaint(const QRegion &region)
if (m_image->hasAlpha()) {
QPainter p(paintDevice());
p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = region.rects();
const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
- }
+ for (const QRect &rect : region)
+ p.fillRect(rect, blank);
}
}
@@ -557,22 +555,21 @@ void QXcbBackingStore::endPaint()
// Slow path: the paint device was m_rgbImage. Now copy with swapping red
// and blue into m_image.
- const QVector<QRect> rects = region.rects();
- if (rects.isEmpty())
+ auto it = region.begin();
+ const auto end = region.end();
+ if (it == end)
return;
QPainter p(m_image->image());
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ while (it != end) {
const QRect rect = *it;
p.drawImage(rect.topLeft(), m_rgbImage.copy(rect).rgbSwapped());
}
}
-#ifndef QT_NO_OPENGL
QImage QXcbBackingStore::toImage() const
{
return m_image && m_image->image() ? *m_image->image() : QImage();
}
-#endif
QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const
{
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h
index 5a8f385c1b..6af679d28a 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.h
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.h
@@ -63,8 +63,8 @@ public:
void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground) Q_DECL_OVERRIDE;
- QImage toImage() const Q_DECL_OVERRIDE;
#endif
+ QImage toImage() const Q_DECL_OVERRIDE;
QPlatformGraphicsBuffer *graphicsBuffer() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 7052e88141..7bd233f387 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -602,7 +602,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
xcb_extension_t *extensions[] = {
&xcb_shm_id, &xcb_xfixes_id, &xcb_randr_id, &xcb_shape_id, &xcb_sync_id,
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
&xcb_xkb_id,
#endif
#ifdef XCB_USE_RENDER
@@ -1072,7 +1072,7 @@ Qt::MouseButton QXcbConnection::translateMouseButton(xcb_button_t s)
}
}
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
namespace {
typedef union {
/* All XKB events share these fields. */
@@ -1258,7 +1258,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
s->handleScreenChange(change_event);
}
handled = true;
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
} else if (response_type == xkb_first_event) { // https://bugs.freedesktop.org/show_bug.cgi?id=51295
_xkb_event *xkb_event = reinterpret_cast<_xkb_event *>(event);
if (xkb_event->any.deviceID == m_keyboard->coreDeviceId()) {
@@ -1725,11 +1725,13 @@ void QXcbConnection::processXcbEvents()
compressEvent(event, i, eventqueue))
continue;
+#ifndef QT_NO_CLIPBOARD
bool accepted = false;
if (clipboard()->processIncr())
clipboard()->incrTransactionPeeker(event, accepted);
if (accepted)
continue;
+#endif
auto isWaitingFor = [=](PeekFunc peekFunc) {
// These callbacks return true if the event is what they were
@@ -1779,24 +1781,6 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t *
window->handleClientMessageEvent(event);
}
-xcb_generic_event_t *QXcbConnection::checkEvent(int type)
-{
- QXcbEventArray *eventqueue = m_reader->lock();
-
- for (int i = 0; i < eventqueue->size(); ++i) {
- xcb_generic_event_t *event = eventqueue->at(i);
- if (event && event->response_type == type) {
- (*eventqueue)[i] = 0;
- m_reader->unlock();
- return event;
- }
- }
-
- m_reader->unlock();
-
- return 0;
-}
-
static const char * xcb_atomnames = {
// window-manager <-> client protocols
"WM_PROTOCOLS\0"
@@ -2198,7 +2182,7 @@ void QXcbConnection::initializeXShape()
void QXcbConnection::initializeXKB()
{
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_xkb_id);
if (!reply || !reply->present) {
qWarning("Qt: XKEYBOARD extension not present on the X server.");
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index ebea8d5460..f6ba828a15 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -43,6 +43,7 @@
#include <xcb/xcb.h>
#include <xcb/randr.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include "qxcbexport.h"
#include <QHash>
#include <QList>
@@ -53,10 +54,11 @@
#include <QVarLengthArray>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/QLoggingCategory>
+#include <QtCore/private/qglobal_p.h>
// This is needed to make Qt compile together with XKB. xkb.h is using a variable
// which is called 'explicit', this is a reserved keyword in c++
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
#define explicit dont_use_cxx_explicit
#include <xcb/xkb.h>
#undef explicit
@@ -448,7 +450,6 @@ public:
QXcbWindowEventListener *windowEventListenerFromId(xcb_window_t id);
QXcbWindow *platformWindowFromId(xcb_window_t id);
- xcb_generic_event_t *checkEvent(int type);
template<typename T>
inline xcb_generic_event_t *checkEvent(T &checker);
@@ -582,6 +583,8 @@ private:
};
QHash<int, ValuatorClassInfo> valuatorInfo;
};
+ friend class QTypeInfo<TabletData>;
+ friend class QTypeInfo<TabletData::ValuatorClassInfo>;
bool xi2HandleTabletEvent(const void *event, TabletData *tabletData);
void xi2ReportTabletEvent(const void *event, TabletData *tabletData);
QVector<TabletData> m_tabletData;
@@ -684,6 +687,12 @@ private:
friend class QXcbEventReader;
};
+#ifdef XCB_USE_XINPUT2
+#ifndef QT_NO_TABLETEVENT
+Q_DECLARE_TYPEINFO(QXcbConnection::TabletData::ValuatorClassInfo, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QXcbConnection::TabletData, Q_MOVABLE_TYPE);
+#endif
+#endif
#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
#define CREATE_VISUALINFO_FROM_DEFAULT_VISUALID(object) ((XVisualInfo *)(object->connection()->createVisualInfoForDefaultVisualId()))
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index f2824b6d65..93f8db92bf 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -697,23 +697,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
if (m_xiGrab) {
// XIAllowTouchEvents deadlocks with libXi < 1.7.4 (this has nothing to do with the XI2 versions like 2.2)
// http://lists.x.org/archives/xorg-devel/2014-July/043059.html
-#ifndef LIBXI_MAJOR
- static bool allowTouchWarningShown = false;
- if (!allowTouchWarningShown) {
- allowTouchWarningShown = true;
- qWarning("Skipping XIAllowTouchEvents() because it was not possible to detect libXi version at build time."
- " Minimum libXi version required is 1.7.4."
- " Expect issues with touch behavior.");
- }
-#elif LIBXI_MAJOR == 1 && (LIBXI_MINOR < 7 || (LIBXI_MINOR == 7 && LIBXI_PATCH < 4))
- static bool allowTouchWarningShown = false;
- if (!allowTouchWarningShown) {
- allowTouchWarningShown = true;
- qWarning("Skipping XIAllowTouchEvents() due to not having libXi >= 1.7.4."
- " libXi version at build time was %d.%d.%d."
- " Expect issues with touch behavior.", LIBXI_MAJOR, LIBXI_MINOR, LIBXI_PATCH);
- }
-#else
+#ifdef XCB_USE_XINPUT2
XIAllowTouchEvents(static_cast<Display *>(m_xlib_display), xiDeviceEvent->deviceid,
xiDeviceEvent->detail, xiDeviceEvent->event, XIAcceptTouch);
#endif
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index 4de4be43d1..80fe5a2199 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -74,6 +74,8 @@ static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = 0;
static xcb_font_t cursorFont = 0;
static int cursorCount = 0;
+#ifndef QT_NO_CURSOR
+
static uint8_t cur_blank_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -276,8 +278,6 @@ static const char * const cursorNames[] = {
"link"
};
-#ifndef QT_NO_CURSOR
-
QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c)
: shape(c.shape()), bitmapCacheKey(0), maskCacheKey(0)
{
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index dd0c557de6..4915bb1b11 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -194,8 +194,10 @@ void QXcbDrag::startDrag()
init();
+#ifndef QT_NO_CLIPBOARD
xcb_set_selection_owner(xcb_connection(), connection()->clipboard()->owner(),
atom(QXcbAtom::XdndSelection), connection()->time());
+#endif
QStringList fmts = QXcbMime::formatsHelper(drag()->mimeData());
for (int i = 0; i < fmts.size(); ++i) {
@@ -205,10 +207,12 @@ void QXcbDrag::startDrag()
drag_types.append(atoms.at(j));
}
}
+#ifndef QT_NO_CLIPBOARD
if (drag_types.size() > 3)
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->clipboard()->owner(),
atom(QXcbAtom::XdndTypelist),
XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
+#endif
setUseCompositing(current_virtual_desktop->compositingActive());
setScreen(current_virtual_desktop->screens().constFirst()->screen());
@@ -447,7 +451,11 @@ void QXcbDrag::move(const QPoint &globalPos)
enter.window = target;
enter.format = 32;
enter.type = atom(QXcbAtom::XdndEnter);
+#ifndef QT_NO_CLIPBOARD
enter.data.data32[0] = connection()->clipboard()->owner();
+#else
+ enter.data.data32[0] = 0;
+#endif
enter.data.data32[1] = flags;
enter.data.data32[2] = drag_types.size()>0 ? drag_types.at(0) : 0;
enter.data.data32[3] = drag_types.size()>1 ? drag_types.at(1) : 0;
@@ -476,7 +484,11 @@ void QXcbDrag::move(const QPoint &globalPos)
move.window = target;
move.format = 32;
move.type = atom(QXcbAtom::XdndPosition);
+#ifndef QT_NO_CLIPBOARD
move.data.data32[0] = connection()->clipboard()->owner();
+#else
+ move.data.data32[0] = 0;
+#endif
move.data.data32[1] = 0; // flags
move.data.data32[2] = (globalPos.x() << 16) + globalPos.y();
move.data.data32[3] = connection()->time();
@@ -505,7 +517,11 @@ void QXcbDrag::drop(const QPoint &globalPos)
drop.window = current_target;
drop.format = 32;
drop.type = atom(QXcbAtom::XdndDrop);
+#ifndef QT_NO_CLIPBOARD
drop.data.data32[0] = connection()->clipboard()->owner();
+#else
+ drop.data.data32[0] = 0;
+#endif
drop.data.data32[1] = 0; // flags
drop.data.data32[2] = connection()->time();
@@ -791,9 +807,11 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message
// reset
target_time = XCB_CURRENT_TIME;
+#ifndef QT_NO_CLIPBOARD
if (xdnd_dragsource == connection()->clipboard()->owner())
handle_xdnd_status(&response);
else
+#endif
Q_XCB_CALL(xcb_send_event(xcb_connection(), false, current_proxy_target,
XCB_EVENT_MASK_NO_EVENT, (const char *)&response));
}
@@ -859,7 +877,11 @@ void QXcbDrag::handle_xdnd_status(const xcb_client_message_event_t *event)
void QXcbDrag::handleStatus(const xcb_client_message_event_t *event)
{
- if (event->window != connection()->clipboard()->owner() || !drag())
+ if (
+#ifndef QT_NO_CLIPBOARD
+ event->window != connection()->clipboard()->owner() ||
+#endif
+ !drag())
return;
xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event);
@@ -914,7 +936,11 @@ void QXcbDrag::send_leave()
leave.window = current_target;
leave.format = 32;
leave.type = atom(QXcbAtom::XdndLeave);
+#ifndef QT_NO_CLIPBOARD
leave.data.data32[0] = connection()->clipboard()->owner();
+#else
+ leave.data.data32[0] = 0;
+#endif
leave.data.data32[1] = 0; // flags
leave.data.data32[2] = 0; // x, y
leave.data.data32[3] = 0; // w, h
@@ -1006,8 +1032,10 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e
void QXcbDrag::handleFinished(const xcb_client_message_event_t *event)
{
DEBUG("xdndHandleFinished");
+#ifndef QT_NO_CLIPBOARD
if (event->window != connection()->clipboard()->owner())
return;
+#endif
const unsigned long *l = (const unsigned long *)event->data.data32;
@@ -1287,11 +1315,13 @@ QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type r
if (a == XCB_NONE)
return result;
+#ifndef QT_NO_CLIPBOARD
if (c->clipboard()->getSelectionOwner(drag->atom(QXcbAtom::XdndSelection)) == XCB_NONE)
return result; // should never happen?
xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection);
result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection, drag->targetTime());
+#endif
return mimeConvertToFormat(c, a, result, QLatin1String(format), requestedType, encoding);
}
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h
index f65dbda05d..cb6e95cc9a 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.h
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -159,6 +159,7 @@ private:
QPointer<QDrag> drag;
QTime time;
};
+ friend class QTypeInfo<Transaction>;
QVector<Transaction> transactions;
int transaction_expiry_timer;
@@ -167,6 +168,7 @@ private:
int findTransactionByTime(xcb_timestamp_t timestamp);
xcb_window_t findRealWindow(const QPoint & pos, xcb_window_t w, int md, bool ignoreNonXdndAwareWindows);
};
+Q_DECLARE_TYPEINFO(QXcbDrag::Transaction, Q_MOVABLE_TYPE);
#endif // QT_NO_DRAGANDDROP
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 802f7b85ce..f4da7ba033 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -55,19 +55,14 @@
#include <xcb/xcb.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
+#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtServiceSupport/private/qgenericunixservices_p.h>
#include <stdio.h>
-//this has to be included before egl, since egl pulls in X headers
#include <QtGui/private/qguiapplication_p.h>
-#ifdef XCB_USE_EGL
-# include <QtPlatformSupport/private/qt_egl_p.h>
-#endif
-
#ifdef XCB_USE_XLIB
#include <X11/Xlib.h>
#endif
@@ -82,7 +77,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include <qpa/qplatformaccessibility.h>
#ifndef QT_NO_ACCESSIBILITY_ATSPI_BRIDGE
-#include "../../../platformsupport/linuxaccessibility/bridge_p.h"
+#include <QtLinuxAccessibilitySupport/private/bridge_p.h>
#endif
#endif
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 4e4bfad1d6..a5aff7f11f 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -711,7 +711,7 @@ void QXcbKeyboard::updateKeymap()
xkb_keymap = 0;
struct xkb_state *new_state = 0;
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
if (connection()->hasXKB()) {
xkb_keymap = xkb_x11_keymap_new_from_device(xkb_context, xcb_connection(), core_device_id, (xkb_keymap_compile_flags)0);
if (xkb_keymap) {
@@ -753,7 +753,7 @@ void QXcbKeyboard::updateKeymap()
checkForLatinLayout();
}
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state)
{
if (m_config && connection()->hasXKB()) {
@@ -1144,7 +1144,7 @@ QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
, m_hasLatinLayout(false)
{
memset(&xkb_names, 0, sizeof(xkb_names));
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
core_device_id = 0;
if (connection->hasXKB()) {
updateVModMapping();
@@ -1158,7 +1158,7 @@ QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
#endif
m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
updateModifiers();
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
}
#endif
updateKeymap();
@@ -1177,7 +1177,7 @@ QXcbKeyboard::~QXcbKeyboard()
void QXcbKeyboard::updateVModMapping()
{
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
xcb_xkb_get_names_cookie_t names_cookie;
xcb_xkb_get_names_reply_t *name_reply;
xcb_xkb_get_names_value_list_t names_list;
@@ -1246,7 +1246,7 @@ void QXcbKeyboard::updateVModMapping()
void QXcbKeyboard::updateVModToRModMapping()
{
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
xcb_xkb_get_map_cookie_t map_cookie;
xcb_xkb_get_map_reply_t *map_reply;
xcb_xkb_get_map_map_t map;
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index 18f1aa5732..dfd2926435 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -45,7 +45,7 @@
#include <xcb/xcb_keysyms.h>
#include <xkbcommon/xkbcommon.h>
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
#include <xkbcommon/xkbcommon-x11.h>
#endif
@@ -77,7 +77,7 @@ public:
#ifdef XCB_USE_XINPUT22
void updateXKBStateFromXI(void *modInfo, void *groupInfo);
#endif
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
// when XKEYBOARD is present on the X server
int coreDeviceId() const { return core_device_id; }
void updateXKBState(xcb_xkb_state_notify_event_t *state);
@@ -138,7 +138,7 @@ private:
xkb_mod_index_t mod5;
};
_xkb_mods xkb_mods;
-#ifndef QT_NO_XKB
+#if QT_CONFIG(xkb)
// when XKEYBOARD is present on the X server
_mod_masks vmod_masks;
int core_device_id;
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index f7244739a5..7592eb2887 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -121,9 +121,7 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa
// so QXcbConnection::atomName() has to be used.
if (atomName == QLatin1String("text/uri-list")
&& connection->atomName(a) == "text/x-moz-url") {
- const QByteArray uri = data->split('\n').first();
- QString mozUri = QString::fromLatin1(uri, uri.size());
- mozUri += QLatin1Char('\n');
+ const QString mozUri = QLatin1String(data->split('\n').constFirst()) + QLatin1Char('\n');
*data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()),
mozUri.length() * 2);
} else if (atomName == QLatin1String("application/x-color"))
@@ -175,7 +173,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
// qDebug() << "mimeConvertDataToFormat" << format << atomName << data;
if (!encoding.isEmpty()
- && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
+ && atomName == format + QLatin1String(";charset=") + QLatin1String(encoding)) {
#ifndef QT_NO_TEXTCODEC
if (requestedType == QVariant::String) {
@@ -210,10 +208,11 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
reinterpret_cast<const ushort *>(data.constData()), data.size() / 2);
if (!str.isNull()) {
if (format == QLatin1String("text/uri-list")) {
- const QStringList urls = str.split(QLatin1Char('\n'));
+ const auto urls = str.splitRef(QLatin1Char('\n'));
QList<QVariant> list;
- foreach (const QString &s, urls) {
- const QUrl url(s.trimmed());
+ list.reserve(urls.size());
+ for (const QStringRef &s : urls) {
+ const QUrl url(s.trimmed().toString());
if (url.isValid())
list.append(url);
}
@@ -221,7 +220,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
// The atomName variable is not used because mimeAtomToString()
// converts "text/x-moz-url" to "text/uri-list".
if (!list.isEmpty() && connection->atomName(a) == "text/x-moz-url")
- return list.first();
+ return list.constFirst();
return list;
} else {
return str;
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index a3e8da7df8..b1575cbee4 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -57,10 +57,6 @@
#include <QtPlatformHeaders/qxcbintegrationfunctions.h>
#include <QtPlatformHeaders/qxcbscreenfunctions.h>
-#ifndef QT_NO_DBUS
-#include "QtPlatformSupport/private/qdbusmenuconnection_p.h"
-#endif
-
#ifdef XCB_USE_XLIB
# include <X11/Xlib.h>
#else
@@ -85,7 +81,6 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
QByteArrayLiteral("rootwindow"),
QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingenabled"),
- QByteArrayLiteral("nofonthinting"),
QByteArrayLiteral("atspibus"),
QByteArrayLiteral("compositingenabled")
};
@@ -242,9 +237,6 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
case GetTimestamp:
result = getTimestamp(xcbScreen);
break;
- case NoFontHinting:
- result = xcbScreen->noFontHinting() ? this : 0; //qboolptr...
- break;
case RootWindow:
result = reinterpret_cast<void *>(xcbScreen->root());
break;
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index ba19cd869c..acecbf4116 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -53,7 +53,6 @@ class QWidget;
class QXcbScreen;
class QXcbConnection;
class QXcbNativeInterfaceHandler;
-class QDBusMenuConnection;
class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
{
@@ -73,7 +72,6 @@ public:
RootWindow,
ScreenSubpixelType,
ScreenAntialiasingEnabled,
- NoFontHinting,
AtspiBus,
CompositingEnabled
};
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index dc6846b20b..a9675935f4 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -61,8 +61,7 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t
, m_number(number)
, m_xSettings(Q_NULLPTR)
{
- QByteArray cmAtomName("_NET_WM_CM_S");
- cmAtomName += QByteArray::number(m_number);
+ const QByteArray cmAtomName = "_NET_WM_CM_S" + QByteArray::number(m_number);
m_net_wm_cm_atom = connection->internAtom(cmAtomName.constData());
m_compositingActive = connection->getSelectionOwner(m_net_wm_cm_atom);
@@ -188,7 +187,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
, m_forcedDpi(-1)
, m_pixelDensity(1)
, m_hintStyle(QFontEngine::HintStyle(-1))
- , m_noFontHinting(false)
, m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1))
, m_antialiasingEnabled(-1)
{
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index 8716af29b5..0d32c3d624 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -172,7 +172,6 @@ public:
void readXResources();
QFontEngine::HintStyle hintStyle() const { return m_hintStyle; }
- bool noFontHinting() const { return m_noFontHinting; }
QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; }
int antialiasingEnabled() const { return m_antialiasingEnabled; }
@@ -208,7 +207,6 @@ private:
int m_forcedDpi;
int m_pixelDensity;
QFontEngine::HintStyle m_hintStyle;
- bool m_noFontHinting;
QFontEngine::SubpixelAntialiasingType m_subpixelType;
int m_antialiasingEnabled;
};
diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
index 802e4cfe08..2303ccf806 100644
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
@@ -40,6 +40,8 @@
#include "qxcbsessionmanager.h"
+#ifndef QT_NO_SESSIONMANAGER
+
#include <qguiapplication.h>
#include <qdatetime.h>
#include <qfileinfo.h>
@@ -144,7 +146,7 @@ static void sm_setProperty(const QString &name, const QStringList &value)
for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) {
prop[count].length = (*it).length();
vl.append((*it).toUtf8());
- prop[count].value = (char*)vl.last().data();
+ prop[count].value = (char*)vl.constLast().data();
++count;
}
sm_setProperty(name.toLatin1().data(), SmLISTofARRAY8, count, prop);
@@ -491,3 +493,5 @@ void QXcbSessionManager::exitEventLoop()
}
#include "qxcbsessionmanager.moc"
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.h b/src/plugins/platforms/xcb/qxcbsessionmanager.h
index cba0ab91ad..a184282034 100644
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.h
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.h
@@ -52,6 +52,8 @@
#include <qpa/qplatformsessionmanager.h>
+#ifndef QT_NO_SESSIONMANAGER
+
QT_BEGIN_NAMESPACE
class QEventLoop;
@@ -89,4 +91,6 @@ private:
QT_END_NAMESPACE
+#endif //QT_NO_SESSIONMANAGER
+
#endif //QXCBSESSIONMANAGER_H
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index f744b34901..0c8e78491e 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -119,6 +119,8 @@ enum {
QT_BEGIN_NAMESPACE
+Q_DECLARE_TYPEINFO(xcb_rectangle_t, Q_PRIMITIVE_TYPE);
+
#undef FocusIn
enum QX11EmbedFocusInDetail {
@@ -256,6 +258,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
free_prop = true;
}
+#if QT_CONFIG(textcodec)
static const QTextCodec* mapper = QTextCodec::codecForLocale();
int errCode = 0;
if (mapper) {
@@ -271,6 +274,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
mapper = QTextCodec::codecForName("latin1");
if (!mapper || !mapper->canEncode(s))
return Q_NULLPTR;
+#endif
static QByteArray qcs;
qcs = s.toLatin1();
tp.value = (uchar*)qcs.data();
@@ -278,7 +282,9 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
tp.format = 8;
tp.nitems = qcs.length();
free_prop = false;
+#if QT_CONFIG(textcodec)
}
+#endif
return &tp;
}
#endif // XCB_USE_XLIB
@@ -2417,6 +2423,17 @@ static inline int fixed1616ToInt(FP1616 val)
return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF);
}
+void QXcbWindow::handleXIMouseButtonState(const xcb_ge_event_t *event)
+{
+ QXcbConnection *conn = connection();
+ const xXIDeviceEvent *ev = reinterpret_cast<const xXIDeviceEvent *>(event);
+ if (ev->buttons_len > 0) {
+ unsigned char *buttonMask = (unsigned char *) &ev[1];
+ for (int i = 1; i <= 15; ++i)
+ conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i));
+ }
+}
+
// With XI 2.2+ press/release/motion comes here instead of the above handlers.
void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source)
{
@@ -2432,12 +2449,6 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail);
- if (ev->buttons_len > 0) {
- unsigned char *buttonMask = (unsigned char *) &ev[1];
- for (int i = 1; i <= 15; ++i)
- conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i));
- }
-
const char *sourceName = 0;
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) {
const QMetaObject *metaObject = qt_getEnumMetaObject(source);
@@ -2447,18 +2458,23 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
switch (ev->evtype) {
case XI_ButtonPress:
+ handleXIMouseButtonState(event);
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName);
conn->setButton(button, true);
handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source);
break;
case XI_ButtonRelease:
+ handleXIMouseButtonState(event);
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName);
conn->setButton(button, false);
handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source);
break;
case XI_Motion:
+ // Here we do NOT call handleXIMouseButtonState because we don't expect button state change to be bundled with motion.
+ // When a touchscreen is pressed, an XI_Motion event occurs in which XIMaskIsSet says the left button is pressed,
+ // but we don't want QGuiApplicationPrivate::processMouseEvent() to react by generating a mouse press event.
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName);
handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source);
@@ -2856,9 +2872,8 @@ void QXcbWindow::setMask(const QRegion &region)
XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE);
} else {
QVector<xcb_rectangle_t> rects;
- const QVector<QRect> regionRects = region.rects();
- rects.reserve(regionRects.count());
- foreach (const QRect &r, regionRects)
+ rects.reserve(region.rectCount());
+ for (const QRect &r : region)
rects.push_back(qRectToXCBRectangle(r));
xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 717c424e11..92f3f7a67c 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -139,6 +139,7 @@ public:
void handleFocusOutEvent(const xcb_focus_out_event_t *event) Q_DECL_OVERRIDE;
void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) Q_DECL_OVERRIDE;
#ifdef XCB_USE_XINPUT22
+ void handleXIMouseButtonState(const xcb_ge_event_t *);
void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) Q_DECL_OVERRIDE;
void handleXIEnterLeave(xcb_ge_event_t *) Q_DECL_OVERRIDE;
#endif
diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro
index 75684a769b..01d493156d 100644
--- a/src/plugins/platforms/xcb/xcb-plugin.pro
+++ b/src/plugins/platforms/xcb/xcb-plugin.pro
@@ -1,6 +1,8 @@
TARGET = qxcb
-QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
+QT += core-private gui-private xcb_qpa_lib-private
+
+DEFINES += QT_NO_FOREACH
SOURCES = \
qxcbmain.cpp
diff --git a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
index 20481e4834..20d8b83e7c 100644
--- a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
+++ b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
@@ -5,14 +5,13 @@
# libxcb-xinerama
#
CONFIG += static
-load(qt_helper_lib)
-XCB_DIR = ../../../../3rdparty/xcb
+XCB_DIR = $$QT_SOURCE_TREE/src/3rdparty/xcb
-INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/include/xcb $$XCB_DIR/sysinclude
+MODULE_INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
+INCLUDEPATH += $$XCB_DIR/include/xcb
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
-QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
+QMAKE_USE += xcb/nolink
# ignore compiler warnings in 3rdparty code
QMAKE_CFLAGS_STATIC_LIB+=-w
@@ -76,3 +75,5 @@ SOURCES += \
OTHER_FILES = $$XCB_DIR/README
TR_EXCLUDE += $$XCB_DIR/*
+
+load(qt_helper_lib)
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index 5915a59c0b..0d27645a60 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -1,7 +1,8 @@
TEMPLATE = subdirs
CONFIG += ordered
+QT_FOR_CONFIG += gui-private
-contains(QT_CONFIG, xcb-qt):SUBDIRS+=xcb-static
+!qtConfig(system-xcb): SUBDIRS += xcb-static
SUBDIRS += xcb_qpa_lib.pro
SUBDIRS += xcb-plugin.pro
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index 9ca8872cb2..6db0c76dea 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -1,7 +1,14 @@
TARGET = QtXcbQpa
CONFIG += no_module_headers internal_module
+DEFINES += QT_NO_FOREACH
-QT += core-private gui-private platformsupport-private
+QT += \
+ core-private gui-private \
+ service_support-private theme_support-private \
+ eventdispatcher_support-private fontdatabase_support-private
+
+qtHaveModule(linuxaccessibility_support-private): \
+ QT += linuxaccessibility_support-private
SOURCES = \
qxcbclipboard.cpp \
@@ -42,67 +49,50 @@ load(qt_build_paths)
DEFINES += QT_BUILD_XCB_PLUGIN
# needed by Xcursor ...
-contains(QT_CONFIG, xcb-xlib) {
+qtConfig(xcb-xlib) {
DEFINES += XCB_USE_XLIB
- LIBS += -lX11 -lX11-xcb
+ QMAKE_USE += xcb_xlib
- contains(QT_CONFIG, xinput2) {
+ qtConfig(xinput2) {
DEFINES += XCB_USE_XINPUT2
SOURCES += qxcbconnection_xi2.cpp
- LIBS += -lXi
- !isEmpty(QMAKE_LIBXI_VERSION_MAJOR) {
- DEFINES += LIBXI_MAJOR=$$QMAKE_LIBXI_VERSION_MAJOR \
- LIBXI_MINOR=$$QMAKE_LIBXI_VERSION_MINOR \
- LIBXI_PATCH=$$QMAKE_LIBXI_VERSION_PATCH
- }
+ QMAKE_USE += xinput2
}
}
-# to support custom cursors with depth > 1
-contains(QT_CONFIG, xcb-render) {
- DEFINES += XCB_USE_RENDER
- LIBS += -lxcb-render -lxcb-render-util
-}
-
# build with session management support
-contains(QT_CONFIG, xcb-sm) {
+qtConfig(xcb-sm) {
DEFINES += XCB_USE_SM
- LIBS += -lSM -lICE
+ QMAKE_USE += x11sm
SOURCES += qxcbsessionmanager.cpp
HEADERS += qxcbsessionmanager.h
}
include(gl_integrations/gl_integrations.pri)
-DEFINES += $$QMAKE_DEFINES_XCB
-LIBS += $$QMAKE_LIBS_XCB
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
-QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
-
-CONFIG += qpa/genericunixfontdatabase
-
-contains(QT_CONFIG, dbus-linked) {
- QT += dbus
- LIBS += $$QT_LIBS_DBUS
-}
-
-contains(QT_CONFIG, xcb-qt) {
+!qtConfig(system-xcb) {
DEFINES += XCB_USE_RENDER
- XCB_DIR = ../../../3rdparty/xcb
- INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
- LIBS += -lxcb -L$$MODULE_BASE_OUTDIR/lib -lxcb-static$$qtPlatformTargetSuffix()
+ QMAKE_USE += xcb-static xcb
} else {
- LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama
- !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb
+ LIBS += -lxcb-xinerama ### there is no configure test for this!
+ qtConfig(xkb): QMAKE_USE += xcb_xkb
+ # to support custom cursors with depth > 1
+ qtConfig(xcb-render) {
+ DEFINES += XCB_USE_RENDER
+ QMAKE_USE += xcb_render
+ }
+ QMAKE_USE += xcb_syslibs
}
# libxkbcommon
-contains(QT_CONFIG, xkbcommon-qt) {
- QT_CONFIG += use-xkbcommon-x11support
- include(../../../3rdparty/xkbcommon.pri)
+!qtConfig(xkbcommon-system) {
+ qtConfig(xkb) {
+ include(../../../3rdparty/xkbcommon-x11.pri)
+ } else {
+ include(../../../3rdparty/xkbcommon.pri)
+ }
} else {
- LIBS += $$QMAKE_LIBS_XKBCOMMON
- QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
+ QMAKE_USE += xkbcommon
}
load(qt_module)