summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/generic/main.cpp2
-rw-r--r--src/plugins/bearer/generic/qgenericengine.h18
-rw-r--r--src/plugins/bearer/linux_common/qofonoservice_linux.cpp8
-rw-r--r--src/plugins/bearer/linux_common/qofonoservice_linux_p.h4
-rw-r--r--src/plugins/bearer/qnetworksession_impl.h44
-rw-r--r--src/plugins/generic/evdevkeyboard/main.cpp2
-rw-r--r--src/plugins/generic/evdevmouse/main.cpp2
-rw-r--r--src/plugins/generic/evdevtablet/main.cpp2
-rw-r--r--src/plugins/generic/evdevtouch/main.cpp2
-rw-r--r--src/plugins/generic/generic.pro6
-rw-r--r--src/plugins/generic/libinput/README18
-rw-r--r--src/plugins/generic/libinput/libinput.json3
-rw-r--r--src/plugins/generic/libinput/libinput.pro12
-rw-r--r--src/plugins/generic/libinput/main.cpp58
-rw-r--r--src/plugins/generic/tslib/main.cpp15
-rw-r--r--src/plugins/generic/tslib/qtslib.cpp136
-rw-r--r--src/plugins/generic/tslib/tslib.pro7
-rw-r--r--src/plugins/generic/tuiotouch/README.md54
-rw-r--r--src/plugins/generic/tuiotouch/main.cpp68
-rw-r--r--src/plugins/generic/tuiotouch/qoscbundle.cpp186
-rw-r--r--src/plugins/generic/tuiotouch/qoscbundle_p.h62
-rw-r--r--src/plugins/generic/tuiotouch/qoscmessage.cpp138
-rw-r--r--src/plugins/generic/tuiotouch/qoscmessage_p.h (renamed from src/plugins/generic/tslib/qtslib.h)34
-rw-r--r--src/plugins/generic/tuiotouch/qtuio_p.h62
-rw-r--r--src/plugins/generic/tuiotouch/qtuiocursor_p.h102
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp337
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler_p.h79
-rw-r--r--src/plugins/generic/tuiotouch/tuiotouch.json3
-rw-r--r--src/plugins/generic/tuiotouch/tuiotouch.pro26
-rw-r--r--src/plugins/imageformats/gif/main.h4
-rw-r--r--src/plugins/imageformats/ico/main.h4
-rw-r--r--src/plugins/imageformats/ico/qicohandler.h18
-rw-r--r--src/plugins/imageformats/jpeg/main.h4
-rw-r--r--src/plugins/platforminputcontexts/compose/main.cpp2
-rw-r--r--src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h10
-rw-r--r--src/plugins/platforminputcontexts/ibus/main.cpp2
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h12
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp2
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp10
-rw-r--r--src/plugins/platforms/android/androidjnimenu.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformwindow.cpp8
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm4
-rwxr-xr-xsrc/plugins/platforms/cocoa/qcocoasystemtrayicon.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm7
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm46
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.json3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro32
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp218
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h94
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp408
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h93
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp268
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h90
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsmain.cpp58
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp286
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h130
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.json3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro24
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp (renamed from src/plugins/platforms/eglfs/qeglfshooks_x11.cpp)118
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h95
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp58
-rw-r--r--src/plugins/platforms/eglfs/eglfs-plugin.pro12
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pri44
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pro14
-rw-r--r--src/plugins/platforms/eglfs/eglfs_device_lib.pro59
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.cpp35
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.h8
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp311
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.h113
-rw-r--r--src/plugins/platforms/eglfs/qeglfsglobal.h45
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks.cpp130
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks.h49
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_kms.cpp422
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_stub.cpp199
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp80
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h10
-rw-r--r--src/plugins/platforms/eglfs/qeglfsmain.cpp (renamed from src/plugins/platforms/eglfs/main.cpp)4
-rw-r--r--src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp85
-rw-r--r--src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h69
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.cpp22
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h17
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp45
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h6
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.h4
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.mm16
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.h2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm106
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.h1
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm96
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm15
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.mm29
-rw-r--r--src/plugins/platforms/kms/main.cpp2
-rw-r--r--src/plugins/platforms/kms/qkmsbackingstore.h8
-rw-r--r--src/plugins/platforms/kms/qkmscontext.h12
-rw-r--r--src/plugins/platforms/kms/qkmscursor.h4
-rw-r--r--src/plugins/platforms/kms/qkmsintegration.cpp2
-rw-r--r--src/plugins/platforms/kms/qkmsnativeinterface.cpp24
-rw-r--r--src/plugins/platforms/kms/qkmsnativeinterface.h6
-rw-r--r--src/plugins/platforms/kms/qkmsscreen.cpp2
-rw-r--r--src/plugins/platforms/kms/qkmsscreen.h10
-rw-r--r--src/plugins/platforms/linuxfb/main.cpp2
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp30
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.h5
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp21
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.h2
-rw-r--r--src/plugins/platforms/minimal/main.cpp2
-rw-r--r--src/plugins/platforms/minimal/qminimalbackingstore.h6
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp4
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h16
-rw-r--r--src/plugins/platforms/minimalegl/main.cpp2
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglbackingstore.h10
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglintegration.cpp2
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglintegration.h14
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.cpp2
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.h6
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglwindow.h4
-rw-r--r--src/plugins/platforms/offscreen/main.cpp2
-rw-r--r--src/plugins/platforms/offscreen/qoffscreencommon.cpp6
-rw-r--r--src/plugins/platforms/offscreen/qoffscreencommon.h22
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.h14
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.h18
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenwindow.h12
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdintegration.cpp5
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdintegration.h1
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdport.cpp2
-rw-r--r--src/plugins/platforms/platforms.pro4
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.h4
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp6
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp6
-rw-r--r--src/plugins/platforms/windows/accessible/iaccessible2.cpp2
-rw-r--r--src/plugins/platforms/windows/accessible/iaccessible2.h19
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp24
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp103
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp143
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp77
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.h10
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp49
-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/qwindowsintegration.h1
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp32
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp36
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h6
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp40
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h5
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.cpp31
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.h3
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri13
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro9
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri38
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp62
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h76
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp108
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h61
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h67
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp94
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h72
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h104
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h57
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp112
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h85
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp62
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp140
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h72
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp92
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h75
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json3
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro27
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp (renamed from src/plugins/platforms/xcb/qglxintegration.cpp)0
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h (renamed from src/plugins/platforms/xcb/qglxintegration.h)18
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp223
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h75
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp62
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp95
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h67
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp71
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h63
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json3
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro31
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp45
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.h17
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp27
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.h12
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp194
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h31
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp10
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbexport.h (renamed from src/plugins/platforms/xcb/qxcbeglsurface.h)33
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp142
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h44
-rw-r--r--src/plugins/platforms/xcb/qxcbmain.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp310
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h39
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp9
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h31
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp191
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h81
-rw-r--r--src/plugins/platforms/xcb/xcb-plugin.pro112
-rw-r--r--src/plugins/platforms/xcb/xcb.pro3
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro111
-rw-r--r--src/plugins/platformthemes/gtk2/main.cpp2
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp24
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h34
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2theme.h4
-rw-r--r--src/plugins/plugins.pro1
-rw-r--r--src/plugins/printsupport/cups/main.cpp2
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp2
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine_p.h8
-rw-r--r--src/plugins/sqldrivers/mysql/main.cpp2
-rw-r--r--src/plugins/sqldrivers/psql/main.cpp2
-rw-r--r--src/plugins/sqldrivers/sqlite/smain.cpp2
-rw-r--r--src/plugins/sqldrivers/sqlite/sqlite.pro2
-rw-r--r--src/plugins/styles/bb10style/bb10lightstyle.qrc54
-rw-r--r--src/plugins/styles/bb10style/bb10style.pro28
-rw-r--r--src/plugins/styles/bb10style/bright/button/core_button_disabled.pngbin0 -> 1510 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.pngbin0 -> 1782 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.pngbin0 -> 1830 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/button/core_button_inactive.pngbin0 -> 2428 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/button/core_button_pressed.pngbin0 -> 3221 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.pngbin0 -> 2048 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.pngbin0 -> 935 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.pngbin0 -> 1702 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.pngbin0 -> 1082 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.pngbin0 -> 2776 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.pngbin0 -> 2652 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.pngbin0 -> 1605 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.pngbin0 -> 1419 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.pngbin0 -> 1404 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.pngbin0 -> 1398 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.pngbin0 -> 1587 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.pngbin0 -> 1801 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.pngbin0 -> 1769 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.pngbin0 -> 134 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.pngbin0 -> 874 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.pngbin0 -> 996 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/combobox/core_listitem_active.pngbin0 -> 182 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.pngbin0 -> 1315 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.pngbin0 -> 454 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.pngbin0 -> 394 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/listitem/core_listitem_active.pngbin0 -> 164 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/listitem/core_listitem_divider.pngbin0 -> 135 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.pngbin0 -> 1802 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.pngbin0 -> 635 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.pngbin0 -> 629 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.pngbin0 -> 903 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.pngbin0 -> 614 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.pngbin0 -> 594 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.pngbin0 -> 4471 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.pngbin0 -> 3652 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.pngbin0 -> 4094 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.pngbin0 -> 4245 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.pngbin0 -> 5460 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.pngbin0 -> 1242 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.pngbin0 -> 385 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_active.pngbin0 -> 1167 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_cache.pngbin0 -> 1154 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_disabled.pngbin0 -> 1134 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_enabled.pngbin0 -> 1049 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_handle.pngbin0 -> 2843 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.pngbin0 -> 2708 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.pngbin0 -> 6577 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_inactive.pngbin0 -> 1162 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_vactive.pngbin0 -> 1077 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_vcache.pngbin0 -> 1063 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.pngbin0 -> 1064 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_venabled.pngbin0 -> 996 bytes
-rw-r--r--src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.pngbin0 -> 1071 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/button/core_button_disabled.pngbin0 -> 1291 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.pngbin0 -> 1655 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.pngbin0 -> 1665 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/button/core_button_inactive.pngbin0 -> 2262 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/button/core_button_pressed.pngbin0 -> 2853 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.pngbin0 -> 1947 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.pngbin0 -> 787 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.pngbin0 -> 1578 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.pngbin0 -> 925 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.pngbin0 -> 2478 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.pngbin0 -> 2256 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.pngbin0 -> 1425 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.pngbin0 -> 1404 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.pngbin0 -> 1465 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.pngbin0 -> 1383 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.pngbin0 -> 1291 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.pngbin0 -> 1583 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.pngbin0 -> 1588 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.pngbin0 -> 134 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.pngbin0 -> 662 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.pngbin0 -> 688 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/combobox/core_listitem_active.pngbin0 -> 149 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.pngbin0 -> 1315 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.pngbin0 -> 454 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.pngbin0 -> 394 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/listitem/core_listitem_active.pngbin0 -> 164 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/listitem/core_listitem_divider.pngbin0 -> 136 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.pngbin0 -> 1724 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.pngbin0 -> 635 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.pngbin0 -> 658 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.pngbin0 -> 815 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.pngbin0 -> 614 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.pngbin0 -> 602 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.pngbin0 -> 4298 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.pngbin0 -> 3125 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.pngbin0 -> 3539 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.pngbin0 -> 3968 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.pngbin0 -> 4777 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.pngbin0 -> 1245 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.pngbin0 -> 369 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_active.pngbin0 -> 1160 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_cache.pngbin0 -> 1154 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_disabled.pngbin0 -> 1105 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_enabled.pngbin0 -> 983 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_handle.pngbin0 -> 3019 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.pngbin0 -> 1715 bytes
-rwxr-xr-xsrc/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.pngbin0 -> 6593 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_inactive.pngbin0 -> 1158 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_vactive.pngbin0 -> 1066 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_vcache.pngbin0 -> 1058 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.pngbin0 -> 1009 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_venabled.pngbin0 -> 929 bytes
-rw-r--r--src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.pngbin0 -> 1067 bytes
-rw-r--r--src/plugins/styles/bb10style/qbb10brightstyle.cpp352
-rw-r--r--src/plugins/styles/bb10style/qbb10brightstyle.h70
-rw-r--r--src/plugins/styles/bb10style/qbb10brightstyle.qrc57
-rw-r--r--src/plugins/styles/bb10style/qbb10darkstyle.cpp357
-rw-r--r--src/plugins/styles/bb10style/qbb10darkstyle.h70
-rw-r--r--src/plugins/styles/bb10style/qbb10darkstyle.qrc57
-rw-r--r--src/plugins/styles/bb10style/qbb10styleplugin.cpp74
-rw-r--r--src/plugins/styles/bb10style/qbb10styleplugin.h64
-rw-r--r--src/plugins/styles/bb10style/qbb10styleplugin.json3
-rw-r--r--src/plugins/styles/bb10style/qpixmapstyle.cpp994
-rw-r--r--src/plugins/styles/bb10style/qpixmapstyle.h236
-rw-r--r--src/plugins/styles/styles.pro3
352 files changed, 10275 insertions, 2454 deletions
diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp
index e825cd494b..57c5589e1b 100644
--- a/src/plugins/bearer/generic/main.cpp
+++ b/src/plugins/bearer/generic/main.cpp
@@ -50,7 +50,7 @@ public:
QGenericEnginePlugin();
~QGenericEnginePlugin();
- QBearerEngine *create(const QString &key) const;
+ QBearerEngine *create(const QString &key) const Q_DECL_OVERRIDE;
};
QGenericEnginePlugin::QGenericEnginePlugin()
diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h
index f688cae3d0..b56ce9ae29 100644
--- a/src/plugins/bearer/generic/qgenericengine.h
+++ b/src/plugins/bearer/generic/qgenericengine.h
@@ -54,24 +54,24 @@ public:
QGenericEngine(QObject *parent = 0);
~QGenericEngine();
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
+ QString getInterfaceFromId(const QString &id) Q_DECL_OVERRIDE;
+ bool hasIdentifier(const QString &id) Q_DECL_OVERRIDE;
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
+ void connectToId(const QString &id) Q_DECL_OVERRIDE;
+ void disconnectFromId(const QString &id) Q_DECL_OVERRIDE;
Q_INVOKABLE void initialize();
Q_INVOKABLE void requestUpdate();
- QNetworkSession::State sessionStateForId(const QString &id);
+ QNetworkSession::State sessionStateForId(const QString &id) Q_DECL_OVERRIDE;
- QNetworkConfigurationManager::Capabilities capabilities() const;
+ QNetworkConfigurationManager::Capabilities capabilities() const Q_DECL_OVERRIDE;
- QNetworkSessionPrivate *createSessionBackend();
+ QNetworkSessionPrivate *createSessionBackend() Q_DECL_OVERRIDE;
- QNetworkConfigurationPrivatePointer defaultConfiguration();
+ QNetworkConfigurationPrivatePointer defaultConfiguration() Q_DECL_OVERRIDE;
- bool requiresPolling() const;
+ bool requiresPolling() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void doRequestUpdate();
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
index abbfd445a5..f4460c1be0 100644
--- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
+++ b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
@@ -295,14 +295,10 @@ QString QOfonoDataConnectionManagerInterface::bearer()
QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
{
- QVariant var;
- QVariantMap map = getProperties();
- if (map.contains(property))
- var = map.value(property);
- return var;
+ return getProperties().value(property);
}
-QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
+QVariantMap &QOfonoDataConnectionManagerInterface::getProperties()
{
if (propertiesMap.isEmpty()) {
QList<QVariant> argumentList;
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
index 3b97e06dd3..8adb8db19c 100644
--- a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
+++ b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
@@ -160,11 +160,11 @@ public:
Q_SIGNALS:
void roamingAllowedChanged(bool);
private:
- QVariantMap getProperties();
+ QVariantMap &getProperties();
QVariantMap propertiesMap;
QStringList contextList;
PathPropertiesList contextListProperties;
-private slots:
+private Q_SLOTS:
void propertyChanged(const QString &, const QDBusVariant &value);
};
diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h
index f5c9ab393f..3570166b11 100644
--- a/src/plugins/bearer/qnetworksession_impl.h
+++ b/src/plugins/bearer/qnetworksession_impl.h
@@ -71,31 +71,31 @@ public:
//that the state is immediately updated (w/o actually opening
//a session). Also this function should take care of
//notification hooks to discover future state changes.
- void syncStateWithInterface();
+ void syncStateWithInterface() Q_DECL_OVERRIDE;
#ifndef QT_NO_NETWORKINTERFACE
- QNetworkInterface currentInterface() const;
+ QNetworkInterface currentInterface() const Q_DECL_OVERRIDE;
#endif
- QVariant sessionProperty(const QString& key) const;
- void setSessionProperty(const QString& key, const QVariant& value);
-
- void open();
- void close();
- void stop();
- void migrate();
- void accept();
- void ignore();
- void reject();
-
- QString errorString() const; //must return translated string
- QNetworkSession::SessionError error() const;
-
- quint64 bytesWritten() const;
- quint64 bytesReceived() const;
- quint64 activeTime() const;
-
- QNetworkSession::UsagePolicies usagePolicies() const;
- void setUsagePolicies(QNetworkSession::UsagePolicies);
+ QVariant sessionProperty(const QString& key) const Q_DECL_OVERRIDE;
+ void setSessionProperty(const QString& key, const QVariant& value) Q_DECL_OVERRIDE;
+
+ void open() Q_DECL_OVERRIDE;
+ void close() Q_DECL_OVERRIDE;
+ void stop() Q_DECL_OVERRIDE;
+ void migrate() Q_DECL_OVERRIDE;
+ void accept() Q_DECL_OVERRIDE;
+ void ignore() Q_DECL_OVERRIDE;
+ void reject() Q_DECL_OVERRIDE;
+
+ QString errorString() const Q_DECL_OVERRIDE; //must return translated string
+ QNetworkSession::SessionError error() const Q_DECL_OVERRIDE;
+
+ quint64 bytesWritten() const Q_DECL_OVERRIDE;
+ quint64 bytesReceived() const Q_DECL_OVERRIDE;
+ quint64 activeTime() const Q_DECL_OVERRIDE;
+
+ QNetworkSession::UsagePolicies usagePolicies() const Q_DECL_OVERRIDE;
+ void setUsagePolicies(QNetworkSession::UsagePolicies) Q_DECL_OVERRIDE;
private Q_SLOTS:
void networkConfigurationsChanged();
diff --git a/src/plugins/generic/evdevkeyboard/main.cpp b/src/plugins/generic/evdevkeyboard/main.cpp
index c913aff787..92ef063450 100644
--- a/src/plugins/generic/evdevkeyboard/main.cpp
+++ b/src/plugins/generic/evdevkeyboard/main.cpp
@@ -44,7 +44,7 @@ class QEvdevKeyboardPlugin : public QGenericPlugin
public:
QEvdevKeyboardPlugin();
- QObject* create(const QString &key, const QString &specification);
+ QObject* create(const QString &key, const QString &specification) Q_DECL_OVERRIDE;
};
QEvdevKeyboardPlugin::QEvdevKeyboardPlugin()
diff --git a/src/plugins/generic/evdevmouse/main.cpp b/src/plugins/generic/evdevmouse/main.cpp
index b460502c9c..54ff554c6f 100644
--- a/src/plugins/generic/evdevmouse/main.cpp
+++ b/src/plugins/generic/evdevmouse/main.cpp
@@ -44,7 +44,7 @@ class QEvdevMousePlugin : public QGenericPlugin
public:
QEvdevMousePlugin();
- QObject* create(const QString &key, const QString &specification);
+ QObject* create(const QString &key, const QString &specification) Q_DECL_OVERRIDE;
};
QEvdevMousePlugin::QEvdevMousePlugin()
diff --git a/src/plugins/generic/evdevtablet/main.cpp b/src/plugins/generic/evdevtablet/main.cpp
index b3a73de4f7..a19efba660 100644
--- a/src/plugins/generic/evdevtablet/main.cpp
+++ b/src/plugins/generic/evdevtablet/main.cpp
@@ -45,7 +45,7 @@ public:
QEvdevTabletPlugin();
QStringList keys() const;
- QObject* create(const QString &key, const QString &specification);
+ QObject* create(const QString &key, const QString &specification) Q_DECL_OVERRIDE;
};
QEvdevTabletPlugin::QEvdevTabletPlugin()
diff --git a/src/plugins/generic/evdevtouch/main.cpp b/src/plugins/generic/evdevtouch/main.cpp
index 1c6d0fba0d..a79c9b43c4 100644
--- a/src/plugins/generic/evdevtouch/main.cpp
+++ b/src/plugins/generic/evdevtouch/main.cpp
@@ -44,7 +44,7 @@ class QEvdevTouchScreenPlugin : public QGenericPlugin
public:
QEvdevTouchScreenPlugin();
- QObject* create(const QString &key, const QString &specification);
+ QObject* create(const QString &key, const QString &specification) Q_DECL_OVERRIDE;
};
QEvdevTouchScreenPlugin::QEvdevTouchScreenPlugin()
diff --git a/src/plugins/generic/generic.pro b/src/plugins/generic/generic.pro
index 767b9a55c1..82a4ad4ce8 100644
--- a/src/plugins/generic/generic.pro
+++ b/src/plugins/generic/generic.pro
@@ -7,3 +7,9 @@ contains(QT_CONFIG, evdev) {
contains(QT_CONFIG, tslib) {
SUBDIRS += tslib
}
+
+SUBDIRS += tuiotouch
+
+contains(QT_CONFIG, libinput) {
+ SUBDIRS += libinput
+}
diff --git a/src/plugins/generic/libinput/README b/src/plugins/generic/libinput/README
new file mode 100644
index 0000000000..4312ccbf3a
--- /dev/null
+++ b/src/plugins/generic/libinput/README
@@ -0,0 +1,18 @@
+This is a generic plug-in for libinput 0.6.0
+(http://www.freedesktop.org/wiki/Software/libinput)
+
+Supports relative pointer, axis, keyboard and touch events. udev is
+required. xkbcommon is used to perform keyboard mapping. The dependency on
+xkbcommon is optional. However, no key events will be generated without it.
+
+The plugin is integrated with configure and is built automatically when the
+necessary dependencies are present.
+
+To use this plugin with eglfs, set QT_QPA_EGLFS_DISABLE_INPUT=1 before launching
+the application and pass -plugin libinput.
+
+To get info and debug messages from libinput, enable the logging category
+qt.qpa.input.
+
+For the time being xkbcommon's default keymap is used always. Support for
+changing it will be added in the future.
diff --git a/src/plugins/generic/libinput/libinput.json b/src/plugins/generic/libinput/libinput.json
new file mode 100644
index 0000000000..4a93f271f3
--- /dev/null
+++ b/src/plugins/generic/libinput/libinput.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "libinput" ]
+}
diff --git a/src/plugins/generic/libinput/libinput.pro b/src/plugins/generic/libinput/libinput.pro
new file mode 100644
index 0000000000..17dbb23ef0
--- /dev/null
+++ b/src/plugins/generic/libinput/libinput.pro
@@ -0,0 +1,12 @@
+TARGET = qlibinputplugin
+
+PLUGIN_TYPE = generic
+PLUGIN_EXTENDS = -
+PLUGIN_CLASS_NAME = QLibInputPlugin
+load(qt_plugin)
+
+QT += core-private platformsupport-private gui-private
+
+SOURCES = main.cpp
+
+OTHER_FILES = libinput.json
diff --git a/src/plugins/generic/libinput/main.cpp b/src/plugins/generic/libinput/main.cpp
new file mode 100644
index 0000000000..16c391cc22
--- /dev/null
+++ b/src/plugins/generic/libinput/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgenericplugin.h>
+#include <QtPlatformSupport/private/qlibinputhandler_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QLibInputPlugin : public QGenericPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "libinput.json")
+
+public:
+ QObject *create(const QString &key, const QString &specification);
+};
+
+QObject *QLibInputPlugin::create(const QString &key, const QString &specification)
+{
+ if (!key.compare(QLatin1String("libinput"), Qt::CaseInsensitive))
+ return new QLibInputHandler(key, specification);
+
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp
index 737b175941..1fbe440bb5 100644
--- a/src/plugins/generic/tslib/main.cpp
+++ b/src/plugins/generic/tslib/main.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
#include <QtGui/qgenericplugin.h>
-#include "qtslib.h"
+#include <QtPlatformSupport/private/qtslib_p.h>
QT_BEGIN_NAMESPACE
@@ -42,21 +42,16 @@ class QTsLibPlugin : public QGenericPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "tslib.json")
public:
- QTsLibPlugin();
-
QObject* create(const QString &key, const QString &specification);
};
-QTsLibPlugin::QTsLibPlugin()
- : QGenericPlugin()
-{
-}
-
QObject* QTsLibPlugin::create(const QString &key,
- const QString &specification)
+ const QString &specification)
{
- if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive))
+ if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive)
+ || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive))
return new QTsLibMouseHandler(key, specification);
+
return 0;
}
diff --git a/src/plugins/generic/tslib/qtslib.cpp b/src/plugins/generic/tslib/qtslib.cpp
deleted file mode 100644
index a8f60b69ff..0000000000
--- a/src/plugins/generic/tslib/qtslib.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtGui module 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "qtslib.h"
-
-
-#include <QSocketNotifier>
-#include <QStringList>
-#include <QPoint>
-#include <qpa/qwindowsysteminterface.h>
-
-#include <errno.h>
-#include <tslib.h>
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QTsLibMouseHandler::QTsLibMouseHandler(const QString &key,
- const QString &specification)
- : m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false)
-{
- qDebug() << "QTsLibMouseHandler" << key << specification;
- setObjectName(QLatin1String("TSLib Mouse Handler"));
-
- QByteArray device = qgetenv("TSLIB_TSDEVICE");
-
- if (specification.startsWith("/dev/"))
- device = specification.toLocal8Bit();
-
- if (device.isEmpty())
- device = QByteArrayLiteral("/dev/input/event1");
-
- m_dev = ts_open(device.constData(), 1);
- if (!m_dev) {
- qErrnoWarning(errno, "ts_open() failed");
- return;
- }
-
- if (ts_config(m_dev))
- perror("Error configuring\n");
-
- m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive);
-
- int fd = ts_fd(m_dev);
- if (fd >= 0) {
- m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
- } else {
- qWarning("Cannot open mouse input device '%s': %s", device.constData(), strerror(errno));
- }
-}
-
-
-QTsLibMouseHandler::~QTsLibMouseHandler()
-{
- if (m_dev)
- ts_close(m_dev);
-}
-
-
-static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode)
-{
- if (rawMode)
- return (ts_read_raw(dev, sample, 1) == 1);
- else
- return (ts_read(dev, sample, 1) == 1);
-}
-
-
-void QTsLibMouseHandler::readMouseData()
-{
- ts_sample sample;
-
- while (get_sample(m_dev, &sample, m_rawMode)) {
- bool pressed = sample.pressure;
- int x = sample.x;
- int y = sample.y;
-
- // work around missing coordinates on mouse release
- if (sample.pressure == 0 && sample.x == 0 && sample.y == 0) {
- x = m_x;
- y = m_y;
- }
-
- if (!m_rawMode) {
- //filtering: ignore movements of 2 pixels or less
- int dx = x - m_x;
- int dy = y - m_y;
- if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed)
- continue;
- }
- QPoint pos(x, y);
-
- //printf("handleMouseEvent %d %d %d %ld\n", m_x, m_y, pressed, sample.tv.tv_usec);
-
- QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
-
- m_x = x;
- m_y = y;
- m_pressed = pressed;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro
index bc05efcc32..be6fc4fbea 100644
--- a/src/plugins/generic/tslib/tslib.pro
+++ b/src/plugins/generic/tslib/tslib.pro
@@ -5,12 +5,9 @@ PLUGIN_EXTENDS = -
PLUGIN_CLASS_NAME = QTsLibPlugin
load(qt_plugin)
-HEADERS = qtslib.h
+SOURCES = main.cpp
-SOURCES = main.cpp \
- qtslib.cpp
-
-QT += gui-private
+QT += gui-private platformsupport-private
LIBS += -lts
diff --git a/src/plugins/generic/tuiotouch/README.md b/src/plugins/generic/tuiotouch/README.md
new file mode 100644
index 0000000000..2675803896
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/README.md
@@ -0,0 +1,54 @@
+# TuioTouch plugin for Qt 5
+
+## Introduction
+
+This is a QPA-using plugin (meaning, it uses Qt internals) that provides touch
+events from TUIO-based sources (such as [TUIOPad](https://code.google.com/p/tuiopad/)).
+
+[TUIO](http://www.tuio.org/) is a framework for providing touch events over the
+network (implemented here using a UDP transport).
+
+This repository also includes a simple [OSC](http://opensoundcontrol.org/spec-1_0)
+parser. OSC is the binary format that TUIO uses for over-the-wire communication.
+
+## Use
+
+Run your application with -plugin TuioTouch, e.g.
+
+`qmlscene foo.qml -plugin TuioTouch`
+
+Or make sure the plugin is loaded using the QT_QPA_GENERIC_PLUGINS environment
+variable.
+
+By default, you must direct TUIO packets to the IP of the machine the application
+is running on, protocol UDP, port 3333. If you want to customize the port, you
+may provide a port number like this:
+
+`qmlscene foo.qml -plugin TuioTouch:udp=3333`
+
+At present, UDP is the only supported transport mechanism.
+
+## Advanced use
+
+If you have the need to invert the X/Y axis, you can do so, by adding an
+additional option when loading the plugin.
+
+For example:
+
+`qmlscene foo.qml -plugin TuioTouch:udp=4000:invertx:inverty`
+
+Would invert the X and Y coordinates of all input coming in on port 4000.
+
+You can also rotate the coordinates directly, using the rotate option:
+
+`qmlscene foo.qml -plugin TuioTouch:udp=4000:rotate=180`
+
+Supported rotations are 90, 180, and 270.
+
+## Further work
+
+* Support other profiles (we implement 2Dcur, we want 2Dobj, 2Dblb?)
+* Support multiple simultaneous sources, generating distinct QTouchEvents
+ * We'd need to somehow not rely on FSEQ for removing touchpoints, else our
+ currently minor memory exhaustion problem could become a real issue
+* Support TCP transports?
diff --git a/src/plugins/generic/tuiotouch/main.cpp b/src/plugins/generic/tuiotouch/main.cpp
new file mode 100644
index 0000000000..c750a4f9a0
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgenericplugin.h>
+#include <QCoreApplication>
+
+#include "qtuiohandler_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTuioTouchPlugin : public QGenericPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "tuiotouch.json")
+
+public:
+ QTuioTouchPlugin();
+
+ QObject* create(const QString &key, const QString &specification);
+};
+
+QTuioTouchPlugin::QTuioTouchPlugin()
+{
+}
+
+QObject* QTuioTouchPlugin::create(const QString &key,
+ const QString &spec)
+{
+ if (!key.compare(QLatin1String("TuioTouch"), Qt::CaseInsensitive))
+ return new QTuioHandler(spec);
+
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/generic/tuiotouch/qoscbundle.cpp b/src/plugins/generic/tuiotouch/qoscbundle.cpp
new file mode 100644
index 0000000000..39e1bdcd81
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qoscbundle.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtEndian>
+#include <QDebug>
+#include <QLoggingCategory>
+
+#include "qoscbundle_p.h"
+#include "qtuio_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcTuioBundle, "qt.qpa.tuio.bundle")
+
+// TUIO packets are transmitted using the OSC protocol, located at:
+// http://opensoundcontrol.org/specification
+// Snippets of this specification have been pasted into the source as a means of
+// easily communicating requirements.
+
+QOscBundle::QOscBundle(const QByteArray &data)
+ : m_isValid(false)
+ , m_immediate(false)
+ , m_timeEpoch(0)
+ , m_timePico(0)
+{
+ // 8 16 24 32 40 48 56 64
+ // # b u n d l e \0
+ // 23 62 75 6e 64 6c 65 00 // OSC string bundle identifier
+ // 00 00 00 00 00 00 00 01 // osc time-tag, "immediately"
+ // 00 00 00 30 // element length
+ // => message or bundle(s), preceded by length each time
+ qCDebug(lcTuioBundle) << data.toHex();
+ quint32 parsedBytes = 0;
+
+ // "An OSC Bundle consists of the OSC-string "#bundle""
+ QByteArray identifier;
+ if (!qt_readOscString(data, identifier, parsedBytes) || identifier != "#bundle")
+ return;
+
+ // "followed by an OSC Time
+ // Tag, followed by zero or more OSC Bundle Elements. The OSC-timetag is a
+ // 64-bit fixed point time tag whose semantics are described below."
+ if (parsedBytes > (quint32)data.size() || data.size() - parsedBytes < sizeof(quint64))
+ return;
+
+ // "Time tags are represented by a 64 bit fixed point number. The first 32
+ // bits specify the number of seconds since midnight on January 1, 1900,
+ // and the last 32 bits specify fractional parts of a second to a precision
+ // of about 200 picoseconds. This is the representation used by Internet NTP
+ // timestamps."
+ //
+ // (editor's note: one may wonder how a 64bit big-endian number can also be
+ // two 32bit numbers, without specifying in which order they occur or
+ // anything, and one may indeed continue to wonder.)
+ quint32 oscTimeEpoch = qFromBigEndian<quint32>((const uchar*)data.constData() + parsedBytes);
+ parsedBytes += sizeof(quint32);
+ quint32 oscTimePico = qFromBigEndian<quint32>((const uchar*)data.constData() + parsedBytes);
+ parsedBytes += sizeof(quint32);
+
+ bool isImmediate = false;
+
+ if (oscTimeEpoch == 0 && oscTimePico == 1) {
+ // "The time tag value consisting of 63 zero bits followed by a
+ // one in the least signifigant bit is a special case meaning
+ // "immediately.""
+ isImmediate = true;
+ }
+
+ while (parsedBytes < (quint32)data.size()) {
+ // "An OSC Bundle Element consists of its size and its contents. The size is an
+ // int32 representing the number of 8-bit bytes in the contents, and will
+ // always be a multiple of 4."
+ //
+ // in practice, a bundle can contain multiple bundles or messages,
+ // though, and each is prefixed by a size.
+ if (data.size() - parsedBytes < sizeof(quint32))
+ return;
+
+ quint32 size = qFromBigEndian<quint32>((const uchar*)data.constData() + parsedBytes);
+ parsedBytes += sizeof(quint32);
+
+ if (data.size() - parsedBytes < size)
+ return;
+
+ if (size == 0) {
+ // empty bundle; these are valid, but should they be allowed? the
+ // spec is unclear on this...
+ qWarning() << "Empty bundle?";
+ m_isValid = true;
+ m_immediate = isImmediate;
+ m_timeEpoch = oscTimeEpoch;
+ m_timePico = oscTimePico;
+ return;
+ }
+
+ // "The contents are either an OSC Message or an OSC Bundle.
+ // Note this recursive definition: bundle may contain bundles."
+ QByteArray subdata = data.mid(parsedBytes, size);
+ parsedBytes += size;
+
+ // "The contents of an OSC packet must be either an OSC Message or an OSC Bundle.
+ // The first byte of the packet's contents unambiguously distinguishes between
+ // these two alternatives."
+ //
+ // we're not dealing with a packet here, but the same trick works just
+ // the same.
+ QByteArray bundleIdentifier = QByteArray("#bundle\0", 8);
+ if (subdata.startsWith('/')) {
+ // starts with / => address pattern => start of a message
+ QOscMessage subMessage(subdata);
+ if (subMessage.isValid()) {
+ m_isValid = true;
+ m_immediate = isImmediate;
+ m_timeEpoch = oscTimeEpoch;
+ m_timePico = oscTimePico;
+ m_messages.append(subMessage);
+ } else {
+ qWarning() << "Invalid sub-message";
+ return;
+ }
+ } else if (subdata.startsWith(bundleIdentifier)) {
+ // bundle identifier start => bundle
+ QOscBundle subBundle(subdata);
+ if (subBundle.isValid()) {
+ m_isValid = true;
+ m_immediate = isImmediate;
+ m_timeEpoch = oscTimeEpoch;
+ m_timePico = oscTimePico;
+ m_bundles.append(subBundle);
+ }
+ } else {
+ qWarning() << "Malformed sub-data!";
+ return;
+ }
+ }
+}
+
+
+bool QOscBundle::isValid() const
+{
+ return m_isValid;
+}
+
+QList<QOscBundle> QOscBundle::bundles() const
+{
+ return m_bundles;
+}
+
+QList<QOscMessage> QOscBundle::messages() const
+{
+ return m_messages;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/generic/tuiotouch/qoscbundle_p.h b/src/plugins/generic/tuiotouch/qoscbundle_p.h
new file mode 100644
index 0000000000..b97cd1e761
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qoscbundle_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOSCBUNDLE_P_H
+#define QOSCBUNDLE_P_H
+
+#include "qoscmessage_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QOscBundle
+{
+public:
+ QOscBundle(const QByteArray &data);
+
+ bool isValid() const;
+ QList<QOscBundle> bundles() const;
+ QList<QOscMessage> messages() const;
+
+private:
+ bool m_isValid;
+ bool m_immediate;
+ quint32 m_timeEpoch;
+ quint32 m_timePico;
+ QList<QOscBundle> m_bundles;
+ QList<QOscMessage> m_messages;
+};
+
+QT_END_NAMESPACE
+
+#endif // QOSCBUNDLE_P_H
diff --git a/src/plugins/generic/tuiotouch/qoscmessage.cpp b/src/plugins/generic/tuiotouch/qoscmessage.cpp
new file mode 100644
index 0000000000..1ebc4ee434
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qoscmessage.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QByteArray>
+#include <QDebug>
+#include <QtEndian>
+#include <QVariant>
+#include <QLoggingCategory>
+
+#include "qoscmessage_p.h"
+#include "qtuio_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcTuioMessage, "qt.qpa.tuio.message")
+
+// TUIO packets are transmitted using the OSC protocol, located at:
+// http://opensoundcontrol.org/specification
+// Snippets of this specification have been pasted into the source as a means of
+// easily communicating requirements.
+
+QOscMessage::QOscMessage(const QByteArray &data)
+ : m_isValid(false)
+{
+ qCDebug(lcTuioMessage) << data.toHex();
+ quint32 parsedBytes = 0;
+
+ // "An OSC message consists of an OSC Address Pattern"
+ QByteArray addressPattern;
+ if (!qt_readOscString(data, addressPattern, parsedBytes) || addressPattern.size() == 0)
+ return;
+
+ // "followed by an OSC Type Tag String"
+ QByteArray typeTagString;
+ if (!qt_readOscString(data, typeTagString, parsedBytes))
+ return;
+
+ // "Note: some older implementations of OSC may omit the OSC Type Tag string.
+ // Until all such implementations are updated, OSC implementations should be
+ // robust in the case of a missing OSC Type Tag String."
+ //
+ // (although, the editor notes one may question how exactly the hell one is
+ // supposed to be robust when the behavior is unspecified.)
+ if (typeTagString.size() == 0 || typeTagString.at(0) != ',')
+ return;
+
+ QList<QVariant> arguments;
+
+ // "followed by zero or more OSC Arguments."
+ for (int i = 1; i < typeTagString.size(); ++i) {
+ char typeTag = typeTagString.at(i);
+ if (typeTag == 's') { // osc-string
+ QByteArray aString;
+ if (!qt_readOscString(data, aString, parsedBytes))
+ return;
+ arguments.append(aString);
+ } else if (typeTag == 'i') { // int32
+ if (parsedBytes > (quint32)data.size() || data.size() - parsedBytes < sizeof(quint32))
+ return;
+
+ quint32 anInt = qFromBigEndian<quint32>((const uchar*)data.constData() + parsedBytes);
+ parsedBytes += sizeof(quint32);
+
+ // TODO: is int32 in OSC signed, or unsigned?
+ arguments.append((int)anInt);
+ } else if (typeTag == 'f') { // float32
+ if (parsedBytes > (quint32)data.size() || data.size() - parsedBytes < sizeof(quint32))
+ return;
+
+ Q_STATIC_ASSERT(sizeof(float) == sizeof(quint32));
+ union {
+ quint32 u;
+ float f;
+ } value;
+ value.u = qFromBigEndian<quint32>((const uchar*)data.constData() + parsedBytes);
+ parsedBytes += sizeof(quint32);
+ arguments.append(value.f);
+ } else {
+ qWarning() << "Reading argument of unknown type " << typeTag;
+ return;
+ }
+ }
+
+ m_isValid = true;
+ m_addressPattern = addressPattern;
+ m_arguments = arguments;
+
+ qCDebug(lcTuioMessage) << "Message with address pattern: " << addressPattern << " arguments: " << arguments;
+}
+
+bool QOscMessage::isValid() const
+{
+ return m_isValid;
+}
+
+QByteArray QOscMessage::addressPattern() const
+{
+ return m_addressPattern;
+}
+
+QList<QVariant> QOscMessage::arguments() const
+{
+ return m_arguments;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/generic/tslib/qtslib.h b/src/plugins/generic/tuiotouch/qoscmessage_p.h
index cd11ca5e2f..4282dce9d4 100644
--- a/src/plugins/generic/tslib/qtslib.h
+++ b/src/plugins/generic/tuiotouch/qoscmessage_p.h
@@ -1,9 +1,10 @@
/****************************************************************************
**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,35 +32,26 @@
**
****************************************************************************/
-#ifndef QTSLIB_H
-#define QTSLIB_H
-
-#include <qobject.h>
-//#include <Qt>
+#ifndef QOSCMESSAGE_P_H
+#define QOSCMESSAGE_P_H
QT_BEGIN_NAMESPACE
-class QSocketNotifier;
-struct tsdev;
-
-class QTsLibMouseHandler : public QObject
+class QOscMessage
{
- Q_OBJECT
public:
- QTsLibMouseHandler(const QString &key, const QString &specification);
- ~QTsLibMouseHandler();
+ QOscMessage(const QByteArray &data);
+ bool isValid() const;
-private slots:
- void readMouseData();
+ QByteArray addressPattern() const;
+ QList<QVariant> arguments() const;
private:
- QSocketNotifier * m_notify;
- tsdev *m_dev;
- int m_x, m_y;
- bool m_pressed;
- bool m_rawMode;
+ bool m_isValid;
+ QByteArray m_addressPattern;
+ QList<QVariant> m_arguments;
};
QT_END_NAMESPACE
-#endif // QTSLIB_H
+#endif
diff --git a/src/plugins/generic/tuiotouch/qtuio_p.h b/src/plugins/generic/tuiotouch/qtuio_p.h
new file mode 100644
index 0000000000..ac8e5a128c
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qtuio_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTUIO_P_H
+#define QTUIO_P_H
+
+QT_BEGIN_NAMESPACE
+
+inline bool qt_readOscString(const QByteArray &source, QByteArray &dest, quint32 &pos)
+{
+ int end = source.indexOf('\0', pos);
+ if (end < 0) {
+ pos = source.size();
+ dest = QByteArray();
+ return false;
+ }
+
+ dest = source.mid(pos, end - pos);
+
+ // Skip additional NULL bytes at the end of the string to make sure the
+ // total number of bits a multiple of 32 bits ("OSC-string" in the
+ // specification).
+ end += 4 - ((end - pos) % 4);
+
+ pos = end;
+ return true;
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/generic/tuiotouch/qtuiocursor_p.h b/src/plugins/generic/tuiotouch/qtuiocursor_p.h
new file mode 100644
index 0000000000..b58ab0fbae
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qtuiocursor_p.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTUIOCURSOR_P_H
+#define QTUIOCURSOR_P_H
+
+#include <Qt>
+
+QT_BEGIN_NAMESPACE
+
+class QTuioCursor
+{
+public:
+ QTuioCursor(int id = -1)
+ : m_id(id)
+ , m_x(0)
+ , m_y(0)
+ , m_vx(0)
+ , m_vy(0)
+ , m_acceleration(0)
+ , m_state(Qt::TouchPointPressed)
+ {
+ }
+
+ int id() const { return m_id; }
+
+ void setX(float x)
+ {
+ if (state() == Qt::TouchPointStationary &&
+ !qFuzzyCompare(m_x + 2.0, x + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
+ setState(Qt::TouchPointMoved);
+ }
+ m_x = x;
+ }
+ float x() const { return m_x; }
+
+ void setY(float y)
+ {
+ if (state() == Qt::TouchPointStationary &&
+ !qFuzzyCompare(m_y + 2.0, y + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
+ setState(Qt::TouchPointMoved);
+ }
+ m_y = y;
+ }
+ float y() const { return m_y; }
+
+ void setVX(float vx) { m_vx = vx; }
+ float vx() const { return m_vx; }
+
+ void setVY(float vy) { m_vy = vy; }
+ float vy() const { return m_vy; }
+
+ void setAcceleration(float acceleration) { m_acceleration = acceleration; }
+ float acceleration() const { return m_acceleration; }
+
+ void setState(const Qt::TouchPointState &state) { m_state = state; }
+ Qt::TouchPointState state() const { return m_state; }
+
+private:
+ int m_id;
+ float m_x;
+ float m_y;
+ float m_vx;
+ float m_vy;
+ float m_acceleration;
+ Qt::TouchPointState m_state;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTUIOCURSOR_P_H
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
new file mode 100644
index 0000000000..cf588afebc
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -0,0 +1,337 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QLoggingCategory>
+#include <QRect>
+#include <QWindow>
+#include <QGuiApplication>
+
+#include <qpa/qwindowsysteminterface.h>
+
+#include "qtuiocursor_p.h"
+#include "qtuiohandler_p.h"
+#include "qoscbundle_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcTuioSource, "qt.qpa.tuio.source")
+Q_LOGGING_CATEGORY(lcTuioSet, "qt.qpa.tuio.set")
+
+QTuioHandler::QTuioHandler(const QString &specification)
+ : m_device(new QTouchDevice) // not leaked, QTouchDevice cleans up registered devices itself
+{
+ QStringList args = specification.split(':');
+ int portNumber = 3333;
+ int rotationAngle = 0;
+ bool invertx = false;
+ bool inverty = false;
+
+ for (int i = 0; i < args.count(); ++i) {
+ if (args.at(i).startsWith("udp=")) {
+ QString portString = args.at(i).section('=', 1, 1);
+ portNumber = portString.toInt();
+ } else if (args.at(i).startsWith("tcp=")) {
+ QString portString = args.at(i).section('=', 1, 1);
+ portNumber = portString.toInt();
+ qWarning() << "TCP is not yet supported. Falling back to UDP on " << portNumber;
+ } else if (args.at(i) == "invertx") {
+ invertx = true;
+ } else if (args.at(i) == "inverty") {
+ inverty = true;
+ } else if (args.at(i).startsWith("rotate=")) {
+ QString rotateArg = args.at(i).section('=', 1, 1);
+ int argValue = rotateArg.toInt();
+ switch (argValue) {
+ case 90:
+ case 180:
+ case 270:
+ rotationAngle = argValue;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (rotationAngle)
+ m_transform = QTransform::fromTranslate(0.5, 0.5).rotate(rotationAngle).translate(-0.5, -0.5);
+
+ if (invertx)
+ m_transform *= QTransform::fromTranslate(0.5, 0.5).scale(-1.0, 1.0).translate(-0.5, -0.5);
+
+ if (inverty)
+ m_transform *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5);
+
+ m_device->setName("TUIO"); // TODO: multiple based on SOURCE?
+ m_device->setType(QTouchDevice::TouchScreen);
+ m_device->setCapabilities(QTouchDevice::Position |
+ QTouchDevice::Area |
+ QTouchDevice::Velocity |
+ QTouchDevice::NormalizedPosition);
+ QWindowSystemInterface::registerTouchDevice(m_device);
+
+ if (!m_socket.bind(QHostAddress::Any, portNumber)) {
+ qWarning() << "Failed to bind TUIO socket: " << m_socket.errorString();
+ return;
+ }
+
+ connect(&m_socket, &QUdpSocket::readyRead, this, &QTuioHandler::processPackets);
+}
+
+QTuioHandler::~QTuioHandler()
+{
+}
+
+void QTuioHandler::processPackets()
+{
+ while (m_socket.hasPendingDatagrams()) {
+ QByteArray datagram;
+ datagram.resize(m_socket.pendingDatagramSize());
+ QHostAddress sender;
+ quint16 senderPort;
+
+ qint64 size = m_socket.readDatagram(datagram.data(), datagram.size(),
+ &sender, &senderPort);
+
+ if (size == -1)
+ continue;
+
+ if (size != datagram.size())
+ datagram.resize(size);
+
+ QOscBundle bundle(datagram);
+ if (!bundle.isValid())
+ continue;
+
+ // "A typical TUIO bundle will contain an initial ALIVE message,
+ // followed by an arbitrary number of SET messages that can fit into the
+ // actual bundle capacity and a concluding FSEQ message. A minimal TUIO
+ // bundle needs to contain at least the compulsory ALIVE and FSEQ
+ // messages. The FSEQ frame ID is incremented for each delivered bundle,
+ // while redundant bundles can be marked using the frame sequence ID
+ // -1."
+ QList<QOscMessage> messages = bundle.messages();
+
+ foreach (const QOscMessage &message, messages) {
+ if (message.addressPattern() != "/tuio/2Dcur") {
+ qWarning() << "Ignoring unknown address pattern " << message.addressPattern();
+ continue;
+ }
+
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() == 0) {
+ qWarning() << "Ignoring TUIO message with no arguments";
+ continue;
+ }
+
+ QByteArray messageType = arguments.at(0).toByteArray();
+ if (messageType == "source") {
+ process2DCurSource(message);
+ } else if (messageType == "alive") {
+ process2DCurAlive(message);
+ } else if (messageType == "set") {
+ process2DCurSet(message);
+ } else if (messageType == "fseq") {
+ process2DCurFseq(message);
+ } else {
+ qWarning() << "Ignoring unknown TUIO message type: " << messageType;
+ continue;
+ }
+ }
+ }
+}
+
+void QTuioHandler::process2DCurSource(const QOscMessage &message)
+{
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() != 2) {
+ qWarning() << "Ignoring malformed TUIO source message: " << arguments.count();
+ return;
+ }
+
+ if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) {
+ qWarning() << "Ignoring malformed TUIO source message (bad argument type)";
+ return;
+ }
+
+ qCDebug(lcTuioSource) << "Got TUIO source message from: " << arguments.at(1).toByteArray();
+}
+
+void QTuioHandler::process2DCurAlive(const QOscMessage &message)
+{
+ QList<QVariant> arguments = message.arguments();
+
+ // delta the notified cursors that are active, against the ones we already
+ // know of.
+ //
+ // TBD: right now we're assuming one 2Dcur alive message corresponds to a
+ // new data source from the input. is this correct, or do we need to store
+ // changes and only process the deltas on fseq?
+ QMap<int, QTuioCursor> oldActiveCursors = m_activeCursors;
+ QMap<int, QTuioCursor> newActiveCursors;
+
+ for (int i = 1; i < arguments.count(); ++i) {
+ if (QMetaType::Type(arguments.at(i).type()) != QMetaType::Int) {
+ qWarning() << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ")";
+ return;
+ }
+
+ int cursorId = arguments.at(i).toInt();
+ if (!oldActiveCursors.contains(cursorId)) {
+ // newly active
+ QTuioCursor cursor(cursorId);
+ cursor.setState(Qt::TouchPointPressed);
+ newActiveCursors.insert(cursorId, cursor);
+ } else {
+ // we already know about it, remove it so it isn't marked as released
+ QTuioCursor cursor = oldActiveCursors.value(cursorId);
+ cursor.setState(Qt::TouchPointStationary); // position change in SET will update if needed
+ newActiveCursors.insert(cursorId, cursor);
+ oldActiveCursors.remove(cursorId);
+ }
+ }
+
+ // anything left is dead now
+ QMap<int, QTuioCursor>::ConstIterator it = oldActiveCursors.constBegin();
+
+ // deadCursors should be cleared from the last FSEQ now
+ m_deadCursors.reserve(oldActiveCursors.size());
+
+ // TODO: there could be an issue of resource exhaustion here if FSEQ isn't
+ // sent in a timely fashion. we should probably track message counts and
+ // force-flush if we get too many built up.
+ while (it != oldActiveCursors.constEnd()) {
+ m_deadCursors.append(it.value());
+ ++it;
+ }
+
+ m_activeCursors = newActiveCursors;
+}
+
+void QTuioHandler::process2DCurSet(const QOscMessage &message)
+{
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() < 7) {
+ qWarning() << "Ignoring malformed TUIO set message with too few arguments: " << arguments.count();
+ return;
+ }
+
+ if (QMetaType::Type(arguments.at(1).type()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(2).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(3).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(4).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(5).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(6).type()) != QMetaType::Float
+ ) {
+ qWarning() << "Ignoring malformed TUIO set message with bad types: " << arguments;
+ return;
+ }
+
+ int cursorId = arguments.at(1).toInt();
+ float x = arguments.at(2).toFloat();
+ float y = arguments.at(3).toFloat();
+ float vx = arguments.at(4).toFloat();
+ float vy = arguments.at(5).toFloat();
+ float acceleration = arguments.at(6).toFloat();
+
+ QMap<int, QTuioCursor>::Iterator it = m_activeCursors.find(cursorId);
+ if (it == m_activeCursors.end()) {
+ qWarning() << "Ignoring malformed TUIO set for nonexistent cursor " << cursorId;
+ return;
+ }
+
+ qCDebug(lcTuioSet) << "Processing SET for " << cursorId << " x: " << x << y << vx << vy << acceleration;
+ QTuioCursor &cur = *it;
+ cur.setX(x);
+ cur.setY(y);
+ cur.setVX(vx);
+ cur.setVY(vy);
+ cur.setAcceleration(acceleration);
+}
+
+QWindowSystemInterface::TouchPoint QTuioHandler::cursorToTouchPoint(const QTuioCursor &tc, QWindow *win)
+{
+ QWindowSystemInterface::TouchPoint tp;
+ tp.id = tc.id();
+ tp.pressure = 1.0f;
+
+ tp.normalPosition = QPointF(tc.x(), tc.y());
+
+ if (!m_transform.isIdentity())
+ tp.normalPosition = m_transform.map(tp.normalPosition);
+
+ tp.state = tc.state();
+ tp.area = QRectF(0, 0, 1, 1);
+
+ // we map the touch to the size of the window. we do this, because frankly,
+ // trying to figure out which part of the screen to hit in order to press an
+ // element on the UI is pretty tricky when one is not using an overlay-style
+ // TUIO device.
+ //
+ // in the future, it might make sense to make this choice optional,
+ // dependent on the spec.
+ QPointF relPos = QPointF(win->size().width() * tp.normalPosition.x(), win->size().height() * tp.normalPosition.y());
+ QPointF delta = relPos - relPos.toPoint();
+ tp.area.moveCenter(win->mapToGlobal(relPos.toPoint()) + delta);
+ tp.velocity = QVector2D(win->size().width() * tc.vx(), win->size().height() * tc.vy());
+ return tp;
+}
+
+
+void QTuioHandler::process2DCurFseq(const QOscMessage &message)
+{
+ Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
+
+ QWindow *win = QGuiApplication::focusWindow();
+ if (!win)
+ return;
+
+ QList<QWindowSystemInterface::TouchPoint> tpl;
+
+ foreach (const QTuioCursor &tc, m_activeCursors) {
+ QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
+ tpl.append(tp);
+ }
+
+ foreach (const QTuioCursor &tc, m_deadCursors) {
+ QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
+ tp.state = Qt::TouchPointReleased;
+ tpl.append(tp);
+ }
+ QWindowSystemInterface::handleTouchEvent(win, m_device, tpl);
+
+ m_deadCursors.clear();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler_p.h b/src/plugins/generic/tuiotouch/qtuiohandler_p.h
new file mode 100644
index 0000000000..99111fec8b
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qtuiohandler_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTUIOHANDLER_P_H
+#define QTUIOHANDLER_P_H
+
+#include <QObject>
+#include <QMap>
+#include <QUdpSocket>
+#include <QVector>
+#include <QTransform>
+
+#include <qpa/qwindowsysteminterface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTouchDevice;
+class QOscMessage;
+class QTuioCursor;
+
+class QTuioHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QTuioHandler(const QString &specification);
+ virtual ~QTuioHandler();
+
+private slots:
+ void processPackets();
+ void process2DCurSource(const QOscMessage &message);
+ void process2DCurAlive(const QOscMessage &message);
+ void process2DCurSet(const QOscMessage &message);
+ void process2DCurFseq(const QOscMessage &message);
+
+private:
+ QWindowSystemInterface::TouchPoint cursorToTouchPoint(const QTuioCursor &tc, QWindow *win);
+
+ QTouchDevice *m_device;
+ QUdpSocket m_socket;
+ QMap<int, QTuioCursor> m_activeCursors;
+ QVector<QTuioCursor> m_deadCursors;
+ QTransform m_transform;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTUIOHANDLER_P_H
diff --git a/src/plugins/generic/tuiotouch/tuiotouch.json b/src/plugins/generic/tuiotouch/tuiotouch.json
new file mode 100644
index 0000000000..bdbbcd203a
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/tuiotouch.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "TuioTouch" ]
+}
diff --git a/src/plugins/generic/tuiotouch/tuiotouch.pro b/src/plugins/generic/tuiotouch/tuiotouch.pro
new file mode 100644
index 0000000000..5e53403f5b
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/tuiotouch.pro
@@ -0,0 +1,26 @@
+TARGET = qtuiotouchplugin
+
+PLUGIN_TYPE = generic
+PLUGIN_EXTENDS = -
+PLUGIN_CLASS_NAME = QTuioTouchPlugin
+load(qt_plugin)
+
+QT += \
+ core-private \
+ gui-private \
+ network
+
+SOURCES += \
+ main.cpp \
+ qoscbundle.cpp \
+ qoscmessage.cpp \
+ qtuiohandler.cpp
+
+HEADERS += \
+ qoscbundle_p.h \
+ qoscmessage_p.h \
+ qtuiohandler_p.h \
+ qtuiocursor_p.h
+
+OTHER_FILES += \
+ tuiotouch.json
diff --git a/src/plugins/imageformats/gif/main.h b/src/plugins/imageformats/gif/main.h
index 733fad95cd..ac91fb79f6 100644
--- a/src/plugins/imageformats/gif/main.h
+++ b/src/plugins/imageformats/gif/main.h
@@ -51,8 +51,8 @@ public:
QGifPlugin();
~QGifPlugin();
- Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
- QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
+ Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
+ QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/ico/main.h b/src/plugins/imageformats/ico/main.h
index 30534cc681..dadceb4445 100644
--- a/src/plugins/imageformats/ico/main.h
+++ b/src/plugins/imageformats/ico/main.h
@@ -48,8 +48,8 @@ class QICOPlugin : public QImageIOPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ico.json")
public:
- Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
- QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
+ Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
+ QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h
index a470e12b5e..dbec0d3ce8 100644
--- a/src/plugins/imageformats/ico/qicohandler.h
+++ b/src/plugins/imageformats/ico/qicohandler.h
@@ -44,20 +44,20 @@ public:
QtIcoHandler(QIODevice *device);
virtual ~QtIcoHandler();
- bool canRead() const;
- bool read(QImage *image);
- bool write(const QImage &image);
+ bool canRead() const Q_DECL_OVERRIDE;
+ bool read(QImage *image) Q_DECL_OVERRIDE;
+ bool write(const QImage &image) Q_DECL_OVERRIDE;
- QByteArray name() const;
+ QByteArray name() const Q_DECL_OVERRIDE;
- int imageCount() const;
- bool jumpToImage(int imageNumber);
- bool jumpToNextImage();
+ int imageCount() const Q_DECL_OVERRIDE;
+ bool jumpToImage(int imageNumber) Q_DECL_OVERRIDE;
+ bool jumpToNextImage() Q_DECL_OVERRIDE;
static bool canRead(QIODevice *device);
- bool supportsOption(ImageOption option) const;
- QVariant option(ImageOption option) const;
+ bool supportsOption(ImageOption option) const Q_DECL_OVERRIDE;
+ QVariant option(ImageOption option) const Q_DECL_OVERRIDE;
private:
int m_currentIconIndex;
diff --git a/src/plugins/imageformats/jpeg/main.h b/src/plugins/imageformats/jpeg/main.h
index 2226241747..a6d9e95371 100644
--- a/src/plugins/imageformats/jpeg/main.h
+++ b/src/plugins/imageformats/jpeg/main.h
@@ -47,8 +47,8 @@ class QJpegPlugin : public QImageIOPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jpeg.json")
public:
- Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
- QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
+ Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
+ QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforminputcontexts/compose/main.cpp b/src/plugins/platforminputcontexts/compose/main.cpp
index ee0a147dd4..2fdc3b37ef 100644
--- a/src/plugins/platforminputcontexts/compose/main.cpp
+++ b/src/plugins/platforminputcontexts/compose/main.cpp
@@ -45,7 +45,7 @@ class QComposePlatformInputContextPlugin : public QPlatformInputContextPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "compose.json")
public:
- QComposeInputContext *create(const QString &, const QStringList &);
+ QComposeInputContext *create(const QString &, const QStringList &) Q_DECL_OVERRIDE;
};
QComposeInputContext *QComposePlatformInputContextPlugin::create(const QString &system, const QStringList &paramList)
diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h
index 897b164b3b..d2e80bebc2 100644
--- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h
@@ -52,11 +52,11 @@ public:
QComposeInputContext();
~QComposeInputContext();
- bool isValid() const;
- void setFocusObject(QObject *object);
- void reset();
- void update(Qt::InputMethodQueries);
- bool filterEvent(const QEvent *event);
+ bool isValid() const Q_DECL_OVERRIDE;
+ void setFocusObject(QObject *object) Q_DECL_OVERRIDE;
+ void reset() Q_DECL_OVERRIDE;
+ void update(Qt::InputMethodQueries) Q_DECL_OVERRIDE;
+ bool filterEvent(const QEvent *event) Q_DECL_OVERRIDE;
protected:
void clearComposeBuffer();
diff --git a/src/plugins/platforminputcontexts/ibus/main.cpp b/src/plugins/platforminputcontexts/ibus/main.cpp
index 8460b62a4f..7b62e2ea94 100644
--- a/src/plugins/platforminputcontexts/ibus/main.cpp
+++ b/src/plugins/platforminputcontexts/ibus/main.cpp
@@ -45,7 +45,7 @@ class QIbusPlatformInputContextPlugin : public QPlatformInputContextPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "ibus.json")
public:
- QIBusPlatformInputContext *create(const QString&, const QStringList&);
+ QIBusPlatformInputContext *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QIBusPlatformInputContext *QIbusPlatformInputContextPlugin::create(const QString& system, const QStringList& paramList)
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
index dda24aca08..8ed69eb980 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
@@ -47,13 +47,13 @@ public:
QIBusPlatformInputContext();
~QIBusPlatformInputContext();
- bool isValid() const;
- void setFocusObject(QObject *object);
+ bool isValid() const Q_DECL_OVERRIDE;
+ void setFocusObject(QObject *object) Q_DECL_OVERRIDE;
- void invokeAction(QInputMethod::Action a, int x);
- void reset();
- void commit();
- void update(Qt::InputMethodQueries);
+ void invokeAction(QInputMethod::Action a, int x) Q_DECL_OVERRIDE;
+ void reset() Q_DECL_OVERRIDE;
+ void commit() Q_DECL_OVERRIDE;
+ void update(Qt::InputMethodQueries) Q_DECL_OVERRIDE;
Q_INVOKABLE bool x11FilterEvent(uint keyval, uint keycode, uint state, bool press);
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 3a80f9437a..59125ac0d2 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -155,7 +155,7 @@ namespace QtAndroidInput
static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
{
//### TODO: add proper API for Qt 5.2
- static bool rightMouseFromLongPress = qgetenv("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS").toInt();
+ static bool rightMouseFromLongPress = qEnvironmentVariableIntValue("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS");
if (!rightMouseFromLongPress)
return;
m_ignoreMouseEvents = true;
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 1c157c79c3..18d3ebb456 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -410,7 +410,7 @@ namespace QtAndroid
bool blockEventLoopsWhenSuspended()
{
- static bool block = qgetenv("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED").toInt();
+ static bool block = qEnvironmentVariableIntValue("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED");
return block;
}
@@ -648,6 +648,11 @@ static void onActivityResult(JNIEnv */*env*/, jclass /*cls*/,
QtAndroidPrivate::handleActivityResult(requestCode, resultCode, data);
}
+static void onNewIntent(JNIEnv *env, jclass /*cls*/, jobject data)
+{
+ QtAndroidPrivate::handleNewIntent(env, data);
+}
+
static JNINativeMethod methods[] = {
{"startQtAndroidPlugin", "()Z", (void *)startQtAndroidPlugin},
{"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication},
@@ -658,7 +663,8 @@ static JNINativeMethod methods[] = {
{"updateWindow", "()V", (void *)updateWindow},
{"updateApplicationState", "(I)V", (void *)updateApplicationState},
{"handleOrientationChanged", "(II)V", (void *)handleOrientationChanged},
- {"onActivityResult", "(IILandroid/content/Intent;)V", (void *)onActivityResult}
+ {"onActivityResult", "(IILandroid/content/Intent;)V", (void *)onActivityResult},
+ {"onNewIntent", "(Landroid/content/Intent;)V", (void *)onNewIntent}
};
#define FIND_AND_CHECK_CLASS(CLASS_NAME) \
diff --git a/src/plugins/platforms/android/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp
index 23182c6e57..36c349f6b4 100644
--- a/src/plugins/platforms/android/androidjnimenu.cpp
+++ b/src/plugins/platforms/android/androidjnimenu.cpp
@@ -199,7 +199,7 @@ namespace QtAndroidMenu
env->DeleteLocalRef(env->CallObjectMethod(menuItem, setEnabledMenuItemMethodID, enabled));
if (!icon.isNull()) { // isNull() only checks the d pointer, not the actual image data.
- int sz = qMax(36, qgetenv("QT_ANDROID_APP_ICON_SIZE").toInt());
+ int sz = qMax(36, qEnvironmentVariableIntValue("QT_ANDROID_APP_ICON_SIZE"));
QImage img = icon.pixmap(QSize(sz,sz),
enabled
? QIcon::Normal
diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
index 06303cdd10..6ff4c50c40 100644
--- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
+++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
@@ -133,9 +133,7 @@ public:
virtual bool open(QIODevice::OpenMode openMode)
{
- if (m_assetFile)
- return openMode & QIODevice::ReadOnly;
- return false;
+ return m_assetFile != 0 && (openMode & QIODevice::WriteOnly) == 0;
}
virtual bool close()
@@ -254,7 +252,7 @@ private:
AndroidAssetsFileEngineHandler::AndroidAssetsFileEngineHandler()
- : m_assetsCache(std::max(5, qgetenv("QT_ANDROID_MAX_ASSETS_CACHE_SIZE").toInt()))
+ : m_assetsCache(std::max(5, qEnvironmentVariableIntValue("QT_ANDROID_MAX_ASSETS_CACHE_SIZE")))
, m_hasPrepopulatedCache(false)
, m_hasTriedPrepopulatingCache(false)
{
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index 092ade2e4a..41139941c8 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -85,7 +85,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen():QObject(),QPlatformScreen()
m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight);
// Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16
// is way much faster than 32
- if (qgetenv("QT_ANDROID_RASTER_IMAGE_DEPTH").toInt() == 16) {
+ if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) {
m_format = QImage::Format_RGB16;
m_depth = 16;
} else {
@@ -131,6 +131,7 @@ void QAndroidPlatformScreen::addWindow(QAndroidPlatformWindow *window)
if (window->parent() && window->isRaster())
return;
+ Q_ASSERT(!m_windowStack.contains(window));
m_windowStack.prepend(window);
if (window->isRaster()) {
m_rasterSurfaces.ref();
@@ -147,7 +148,10 @@ void QAndroidPlatformScreen::removeWindow(QAndroidPlatformWindow *window)
if (window->parent() && window->isRaster())
return;
+
+ Q_ASSERT(m_windowStack.contains(window));
m_windowStack.removeOne(window);
+ Q_ASSERT(!m_windowStack.contains(window));
if (window->isRaster()) {
m_rasterSurfaces.deref();
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index 35eb282994..f1ddcefef6 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -450,7 +450,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
case StyleNames:
- if (qgetenv("QT_USE_ANDROID_NATIVE_STYLE").toInt()
+ if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE")
&& m_androidStyleData) {
return QStringList("android");
}
@@ -458,7 +458,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
case MouseDoubleClickDistance:
{
- int minimumDistance = qgetenv("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE").toInt();
+ int minimumDistance = qEnvironmentVariableIntValue("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE");
int ret = minimumDistance;
QAndroidPlatformIntegration *platformIntegration
@@ -502,7 +502,7 @@ QString QAndroidPlatformTheme::standardButtonText(int button) const
bool QAndroidPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
{
if (type == MessageDialog)
- return qgetenv("QT_USE_ANDROID_NATIVE_DIALOGS").toInt() == 1;
+ return qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_DIALOGS") == 1;
return false;
}
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp
index 03cb186a81..1207d7c90b 100644
--- a/src/plugins/platforms/android/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp
@@ -82,15 +82,15 @@ void QAndroidPlatformWindow::setVisible(bool visible)
setGeometry(platformScreen()->availableGeometry());
}
- QRect availableGeometry = screen()->availableGeometry();
- if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
- QPlatformWindow::setVisible(visible);
-
if (visible)
platformScreen()->addWindow(this);
else
platformScreen()->removeWindow(this);
+ QRect availableGeometry = screen()->availableGeometry();
+ if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QPlatformWindow::setVisible(visible);
+
// The Android Activity is activated before Qt is initialized, causing the application state to
// never be set to 'active'. We explicitly set this state when the first window becomes visible.
if (visible)
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 72bd09625a..180cb23669 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -337,7 +337,7 @@ QCocoaIntegration::~QCocoaIntegration()
// Delete screens in reverse order to avoid crash in case of multiple screens
while (!mScreens.isEmpty()) {
- delete mScreens.takeLast();
+ destroyScreen(mScreens.takeLast());
}
clearToolbars();
@@ -397,7 +397,7 @@ void QCocoaIntegration::updateScreens()
// Now the leftovers in remainingScreens are no longer current, so we can delete them.
foreach (QCocoaScreen* screen, remainingScreens) {
mScreens.removeOne(screen);
- delete screen;
+ destroyScreen(screen);
}
// All screens in mScreens are siblings, because we ignored the mirrors.
foreach (QCocoaScreen* screen, mScreens)
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
index c527c478ff..c426cacc35 100755
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
@@ -57,7 +57,7 @@ public:
virtual void updateToolTip(const QString &toolTip);
virtual void updateMenu(QPlatformMenu *menu);
virtual QRect geometry() const;
- virtual void showMessage(const QString &msg, const QString &title,
+ virtual void showMessage(const QString &title, const QString &msg,
const QIcon& icon, MessageIcon iconType, int secs);
virtual bool isSystemTrayAvailable() const;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 6656212457..aa07c5a55b 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -804,7 +804,7 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
NSInteger styleMask = NSBorderlessWindowMask;
if (flags & Qt::FramelessWindowHint)
- return styleMask;
+ return styleMask | NSResizableWindowMask;
if ((type & Qt::Popup) == Qt::Popup) {
if (!windowIsPopupType(type))
styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
@@ -1506,7 +1506,10 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
if ((m_synchedWindowState & Qt::WindowMinimized) != (newState & Qt::WindowMinimized)) {
if (newState & Qt::WindowMinimized) {
- [m_nsWindow performMiniaturize : m_nsWindow];
+ if (m_nsWindow.styleMask & NSMiniaturizableWindowMask)
+ [m_nsWindow performMiniaturize : m_nsWindow];
+ else
+ [m_nsWindow miniaturize : m_nsWindow];
} else {
[m_nsWindow deminiaturize : m_nsWindow];
}
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index fa71ab4086..59297bdffe 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -74,6 +74,8 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
NSString *m_inputSource;
QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper;
bool m_resendKeyEvent;
+ bool m_scrolling;
+ bool m_exposedOnMoveToWindow;
}
- (id)init;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 5d3befa25b..fb7b615ee1 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -160,6 +160,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_inputSource = 0;
m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self];
m_resendKeyEvent = false;
+ m_scrolling = false;
if (!touchDevice) {
touchDevice = new QTouchDevice;
@@ -271,10 +272,13 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
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
- && [self.window.className isEqualToString:@"NSCarbonMenuWindow"])
+ if ((!_q_NSWindowDidChangeOcclusionStateNotification
+ && [self.window.className isEqualToString:@"NSCarbonMenuWindow"])) {
+ m_exposedOnMoveToWindow = true;
m_platformWindow->exposeWindow();
- } else {
+ }
+ } else if (m_exposedOnMoveToWindow) {
+ m_exposedOnMoveToWindow = false;
m_platformWindow->obscureWindow();
}
}
@@ -415,8 +419,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
&& [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
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wobjc-method-access"
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_CLANG("-Wobjc-method-access")
enum { NSWindowOcclusionStateVisible = 1UL << 1 };
#endif
if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible) {
@@ -431,7 +435,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_platformWindow->obscureWindow();
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
-#pragma clang diagnostic pop
+QT_WARNING_POP
#endif
} else if (notificationName == NSWindowDidChangeScreenNotification) {
if (m_window) {
@@ -1265,12 +1269,10 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
{
if (m_window->flags() & Qt::WindowTransparentForInput)
return [super scrollWheel:theEvent];
- const EventRef carbonEvent = (EventRef)[theEvent eventRef];
- const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
- const bool scrollEvent = carbonEventKind == kEventMouseScroll;
QPoint angleDelta;
- if (scrollEvent) {
+ Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
+ if ([theEvent hasPreciseScrollingDeltas]) {
// The mouse device contains pixel scroll wheel support (Mighty Mouse, Trackpad).
// Since deviceDelta is delivered as pixels rather than degrees, we need to
// convert from pixels to degrees in a sensible manner.
@@ -1279,8 +1281,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const int pixelsToDegrees = 2; // 8 * 1/4
angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
+ source = Qt::MouseEventSynthesizedBySystem;
} else {
- // carbonEventKind == kEventMouseWheelMoved
// Remove acceleration, and use either -120 or 120 as delta:
angleDelta.setX(qBound(-120, int([theEvent deltaX] * 10000), 120));
angleDelta.setY(qBound(-120, int([theEvent deltaY] * 10000), 120));
@@ -1321,19 +1323,23 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
#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)
+ if (phase == NSEventPhaseMayBegin) {
+ m_scrolling = true;
ph = Qt::ScrollBegin;
- } else
+ }
+ }
#endif
- if (phase == NSEventPhaseBegan) {
- // On 10.7, MayBegin will not happen, so Began is the actual beginning.
+ if (phase == NSEventPhaseBegan) {
+ // If MayBegin did not happen, Began is the actual beginning.
+ if (!m_scrolling)
ph = Qt::ScrollBegin;
- }
- if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
+ m_scrolling = true;
+ } else if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
ph = Qt::ScrollEnd;
+ m_scrolling = false;
}
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source);
}
#endif //QT_NO_WHEELEVENT
@@ -1419,7 +1425,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if (m_sendKeyEvent && m_composingText.isEmpty())
QWindowSystemInterface::handleExtendedKeyEvent(focusWindow, timestamp, QEvent::Type(eventType), keyCode, modifiers,
- nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat]);
+ nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat], 1, false);
m_sendKeyEvent = false;
m_resendKeyEvent = false;
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index a86bb0ee04..8c70f70edd 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -923,7 +923,11 @@ public:
static const char keyC[] = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes";
const QString familyName = QString::fromWCharArray(lf.lfFaceName);
const QString nameSubstitute = QSettings(QLatin1String(keyC), QSettings::NativeFormat).value(familyName, familyName).toString();
- memcpy(lf.lfFaceName, nameSubstitute.utf16(), sizeof(wchar_t) * qMin(nameSubstitute.length() + 1, LF_FACESIZE));
+ if (nameSubstitute != familyName) {
+ const int nameSubstituteLength = qMin(nameSubstitute.length(), LF_FACESIZE - 1);
+ memcpy(lf.lfFaceName, nameSubstitute.utf16(), nameSubstituteLength * sizeof(wchar_t));
+ lf.lfFaceName[nameSubstituteLength] = 0;
+ }
ComPtr<IDWriteFont> dwriteFont;
HRESULT hr = QWindowsDirect2DContext::instance()->dwriteGdiInterop()->CreateFontFromLOGFONT(&lf, &dwriteFont);
diff --git a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro
new file mode 100644
index 0000000000..d8ce385636
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+contains(QT_CONFIG, egl_x11): SUBDIRS += eglfs_x11
+contains(QT_CONFIG, kms): SUBDIRS += eglfs_kms
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.json b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.json
new file mode 100644
index 0000000000..70fec1cacf
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "eglfs_kms" ]
+}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
new file mode 100644
index 0000000000..f79653127e
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
@@ -0,0 +1,32 @@
+TARGET = qeglfs-kms-integration
+
+PLUGIN_CLASS_NAME=QEglFSKmsIntegrationPlugin
+PLUGIN_TYPE=egldeviceintegrations
+
+load(qt_plugin)
+
+QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+
+INCLUDEPATH += $$PWD/../..
+
+# Avoid X11 header collision
+DEFINES += MESA_EGL_NO_X11_HEADERS
+
+CONFIG += link_pkgconfig
+PKGCONFIG += libdrm gbm
+
+CONFIG += egl
+QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
+
+SOURCES += $$PWD/qeglfskmsmain.cpp \
+ $$PWD/qeglfskmsintegration.cpp \
+ $$PWD/qeglfskmsdevice.cpp \
+ $$PWD/qeglfskmsscreen.cpp \
+ $$PWD/qeglfskmscursor.cpp
+
+HEADERS += $$PWD/qeglfskmsintegration.h \
+ $$PWD/qeglfskmsdevice.h \
+ $$PWD/qeglfskmsscreen.h \
+ $$PWD/qeglfskmscursor.h
+
+OTHER_FILES += $$PWD/eglfs_kms.json
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp
new file mode 100644
index 0000000000..e337e832e2
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfskmscursor.h"
+#include "qeglfskmsscreen.h"
+#include "qeglfskmsdevice.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtCore/QLoggingCategory>
+#include <QtGui/QPainter>
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+#ifndef DRM_CAP_CURSOR_WIDTH
+#define DRM_CAP_CURSOR_WIDTH 0x8
+#endif
+
+#ifndef DRM_CAP_CURSOR_HEIGHT
+#define DRM_CAP_CURSOR_HEIGHT 0x9
+#endif
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
+
+QEglFSKmsCursor::QEglFSKmsCursor(QEglFSKmsScreen *screen)
+ : m_screen(screen)
+ , m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below
+ , m_bo(Q_NULLPTR)
+ , m_cursorImage(0, 0, 0, 0, 0, 0)
+ , m_visible(true)
+{
+ uint64_t width, height;
+ if ((drmGetCap(m_screen->device()->fd(), DRM_CAP_CURSOR_WIDTH, &width) == 0)
+ && (drmGetCap(m_screen->device()->fd(), DRM_CAP_CURSOR_HEIGHT, &height) == 0)) {
+ m_cursorSize.setWidth(width);
+ m_cursorSize.setHeight(height);
+ }
+
+ m_bo = gbm_bo_create(m_screen->device()->device(), m_cursorSize.width(), m_cursorSize.height(),
+ GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
+ if (!m_bo) {
+ qWarning("Could not create buffer for cursor!");
+ } else {
+ initCursorAtlas();
+ }
+
+#ifndef QT_NO_CURSOR
+ QCursor cursor(Qt::ArrowCursor);
+ changeCursor(&cursor, 0);
+#endif
+ setPos(QPoint(0, 0));
+}
+
+QEglFSKmsCursor::~QEglFSKmsCursor()
+{
+ drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0, 0);
+ drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0);
+
+ gbm_bo_destroy(m_bo);
+ m_bo = Q_NULLPTR;
+}
+
+void QEglFSKmsCursor::pointerEvent(const QMouseEvent &event)
+{
+ setPos(event.screenPos().toPoint());
+}
+
+#ifndef QT_NO_CURSOR
+void QEglFSKmsCursor::changeCursor(QCursor *windowCursor, QWindow *window)
+{
+ Q_UNUSED(window);
+
+ if (!m_visible)
+ return;
+
+ const Qt::CursorShape newShape = windowCursor ? windowCursor->shape() : Qt::ArrowCursor;
+ if (newShape == Qt::BitmapCursor) {
+ m_cursorImage.set(windowCursor->pixmap().toImage(),
+ windowCursor->hotSpot().x(),
+ windowCursor->hotSpot().y());
+ } else {
+ // Standard cursor, look up in atlas
+ const int width = m_cursorAtlas.cursorWidth;
+ const int height = m_cursorAtlas.cursorHeight;
+ const qreal ws = (qreal)m_cursorAtlas.cursorWidth / m_cursorAtlas.width;
+ const qreal hs = (qreal)m_cursorAtlas.cursorHeight / m_cursorAtlas.height;
+
+ QRect textureRect(ws * (newShape % m_cursorAtlas.cursorsPerRow) * m_cursorAtlas.width,
+ hs * (newShape / m_cursorAtlas.cursorsPerRow) * m_cursorAtlas.height,
+ width,
+ height);
+ QPoint hotSpot = m_cursorAtlas.hotSpots[newShape];
+ m_cursorImage.set(m_cursorAtlas.image.copy(textureRect),
+ hotSpot.x(),
+ hotSpot.y());
+ }
+
+ if (m_cursorImage.image()->width() > m_cursorSize.width() || m_cursorImage.image()->height() > m_cursorSize.height())
+ qWarning("Cursor larger than %dx%d, cursor will be clipped.", m_cursorSize.width(), m_cursorSize.height());
+
+ QImage cursorImage(m_cursorSize, QImage::Format_ARGB32);
+ cursorImage.fill(Qt::transparent);
+
+ QPainter painter;
+ painter.begin(&cursorImage);
+ painter.drawImage(0, 0, *m_cursorImage.image());
+ painter.end();
+
+ gbm_bo_write(m_bo, cursorImage.constBits(), cursorImage.byteCount());
+
+ uint32_t handle = gbm_bo_get_handle(m_bo).u32;
+ int status = drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, handle,
+ m_cursorSize.width(), m_cursorSize.height());
+ if (status != 0)
+ qWarning("Could not set cursor: %d", status);
+}
+#endif // QT_NO_CURSOR
+
+QPoint QEglFSKmsCursor::pos() const
+{
+ return m_pos;
+}
+
+void QEglFSKmsCursor::setPos(const QPoint &pos)
+{
+ QPoint adjustedPos = pos - m_cursorImage.hotspot();
+ int ret = drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, adjustedPos.x(), adjustedPos.y());
+ if (ret == 0) {
+ m_pos = pos;
+ } else {
+ qWarning("Failed to move cursor: %d", ret);
+ }
+}
+
+void QEglFSKmsCursor::initCursorAtlas()
+{
+ static QByteArray json = qgetenv("QT_QPA_EGLFS_CURSOR");
+ if (json.isEmpty())
+ json = ":/cursor.json";
+
+ qCDebug(qLcEglfsKmsDebug) << "Initializing cursor atlas from" << json;
+
+ QFile file(QString::fromUtf8(json));
+ if (!file.open(QFile::ReadOnly)) {
+ drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0, 0);
+ drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0);
+ m_visible = false;
+ return;
+ }
+
+ QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
+ QJsonObject object = doc.object();
+
+ QString atlas = object.value(QLatin1String("image")).toString();
+ Q_ASSERT(!atlas.isEmpty());
+
+ const int cursorsPerRow = object.value(QLatin1String("cursorsPerRow")).toDouble();
+ Q_ASSERT(cursorsPerRow);
+ m_cursorAtlas.cursorsPerRow = cursorsPerRow;
+
+ const QJsonArray hotSpots = object.value(QLatin1String("hotSpots")).toArray();
+ Q_ASSERT(hotSpots.count() == Qt::LastCursor + 1);
+ for (int i = 0; i < hotSpots.count(); i++) {
+ QPoint hotSpot(hotSpots[i].toArray()[0].toDouble(), hotSpots[i].toArray()[1].toDouble());
+ m_cursorAtlas.hotSpots << hotSpot;
+ }
+
+ QImage image = QImage(atlas).convertToFormat(QImage::Format_ARGB32);
+ m_cursorAtlas.cursorWidth = image.width() / m_cursorAtlas.cursorsPerRow;
+ m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow) / cursorsPerRow);
+ m_cursorAtlas.width = image.width();
+ m_cursorAtlas.height = image.height();
+ m_cursorAtlas.image = image;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h
new file mode 100644
index 0000000000..4b07000c35
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSKMSCURSOR_H
+#define QEGLFSKMSCURSOR_H
+
+#include <qpa/qplatformcursor.h>
+#include <QtCore/QList>
+#include <QtGui/QImage>
+
+#include <gbm.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSKmsScreen;
+
+class QEglFSKmsCursor : public QPlatformCursor
+{
+ Q_OBJECT
+
+public:
+ QEglFSKmsCursor(QEglFSKmsScreen *screen);
+ ~QEglFSKmsCursor();
+
+ // input methods
+ void pointerEvent(const QMouseEvent & event) Q_DECL_OVERRIDE;
+#ifndef QT_NO_CURSOR
+ void changeCursor(QCursor * windowCursor, QWindow * window) Q_DECL_OVERRIDE;
+#endif
+ QPoint pos() const Q_DECL_OVERRIDE;
+ void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
+
+private:
+ void initCursorAtlas();
+
+ QEglFSKmsScreen *m_screen;
+ QSize m_cursorSize;
+ gbm_bo *m_bo;
+ QPoint m_pos;
+ QPlatformCursorImage m_cursorImage;
+ bool m_visible;
+
+ // cursor atlas information
+ struct CursorAtlas {
+ CursorAtlas() : cursorsPerRow(0), cursorWidth(0), cursorHeight(0) { }
+ int cursorsPerRow;
+ int width, height; // width and height of the atlas
+ int cursorWidth, cursorHeight; // width and height of cursors inside the atlas
+ QList<QPoint> hotSpots;
+ QImage image;
+ } m_cursorAtlas;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
new file mode 100644
index 0000000000..d8f0f01aff
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
@@ -0,0 +1,408 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfskmsdevice.h"
+#include "qeglfskmsscreen.h"
+
+#include "qeglfsintegration.h"
+
+#include <QtCore/QLoggingCategory>
+#include <QtCore/private/qcore_unix_p.h>
+#include <QtGui/private/qguiapplication_p.h>
+
+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
+
+enum OutputConfiguration {
+ OutputConfigOff,
+ OutputConfigPreferred,
+ OutputConfigCurrent,
+ OutputConfigMode,
+ OutputConfigModeline
+};
+
+int QEglFSKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector)
+{
+ for (int i = 0; i < connector->count_encoders; i++) {
+ drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoders[i]);
+ if (!encoder) {
+ qWarning("Failed to get encoder");
+ continue;
+ }
+
+ quint32 possibleCrtcs = encoder->possible_crtcs;
+ drmModeFreeEncoder(encoder);
+
+ for (int j = 0; j < resources->count_crtcs; j++) {
+ bool isPossible = possibleCrtcs & (1 << j);
+ bool isAvailable = !(m_crtc_allocator & 1 << resources->crtcs[j]);
+
+ if (isPossible && isAvailable)
+ return j;
+ }
+ }
+
+ return -1;
+}
+
+static const char * const connector_type_names[] = {
+ "None",
+ "VGA",
+ "DVI",
+ "DVI",
+ "DVI",
+ "Composite",
+ "TV",
+ "LVDS",
+ "CTV",
+ "DIN",
+ "DP",
+ "HDMI",
+ "HDMI",
+ "TV",
+ "eDP",
+};
+
+static QString nameForConnector(const drmModeConnectorPtr connector)
+{
+ QString connectorName = "UNKNOWN";
+
+ if (connector->connector_type < ARRAY_LENGTH(connector_type_names))
+ connectorName = connector_type_names[connector->connector_type];
+
+ connectorName += QString::number(connector->connector_type_id);
+
+ return connectorName;
+}
+
+static bool parseModeline(const QString &s, drmModeModeInfoPtr mode)
+{
+ char hsync[16];
+ char vsync[16];
+ float fclock;
+
+ mode->type = DRM_MODE_TYPE_USERDEF;
+ mode->hskew = 0;
+ mode->vscan = 0;
+ mode->vrefresh = 0;
+ mode->flags = 0;
+
+ if (sscanf(qPrintable(s), "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s",
+ &fclock,
+ &mode->hdisplay,
+ &mode->hsync_start,
+ &mode->hsync_end,
+ &mode->htotal,
+ &mode->vdisplay,
+ &mode->vsync_start,
+ &mode->vsync_end,
+ &mode->vtotal, hsync, vsync) != 11)
+ return false;
+
+ mode->clock = fclock * 1000;
+
+ if (strcmp(hsync, "+hsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_PHSYNC;
+ else if (strcmp(hsync, "-hsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_NHSYNC;
+ else
+ return false;
+
+ if (strcmp(vsync, "+vsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_PVSYNC;
+ else if (strcmp(vsync, "-vsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_NVSYNC;
+ else
+ return false;
+
+ return true;
+}
+
+QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos)
+{
+ const QString connectorName = nameForConnector(connector);
+
+ const int crtc = crtcForConnector(resources, connector);
+ if (crtc < 0) {
+ qWarning() << "No usable crtc/encoder pair for connector" << connectorName;
+ return Q_NULLPTR;
+ }
+
+ OutputConfiguration configuration;
+ QSize configurationSize;
+ drmModeModeInfo configurationModeline;
+
+ const QString mode = m_integration->outputSettings().value(connectorName).value("mode", "preferred").toString().toLower();
+ if (mode == "off") {
+ configuration = OutputConfigOff;
+ } else if (mode == "preferred") {
+ configuration = OutputConfigPreferred;
+ } else if (mode == "current") {
+ configuration = OutputConfigCurrent;
+ } else if (sscanf(qPrintable(mode), "%dx%d", &configurationSize.rwidth(), &configurationSize.rheight()) == 2) {
+ configuration = OutputConfigMode;
+ } else if (parseModeline(mode, &configurationModeline)) {
+ configuration = OutputConfigModeline;
+ } else {
+ qWarning("Invalid mode \"%s\" for output %s", qPrintable(mode), qPrintable(connectorName));
+ configuration = OutputConfigPreferred;
+ }
+
+ const uint32_t crtc_id = resources->crtcs[crtc];
+
+ if (configuration == OutputConfigOff) {
+ qCDebug(qLcEglfsKmsDebug) << "Turning off output" << connectorName;
+ drmModeSetCrtc(m_dri_fd, crtc_id, 0, 0, 0, 0, 0, Q_NULLPTR);
+ return Q_NULLPTR;
+ }
+
+ // Get the current mode on the current crtc
+ drmModeModeInfo crtc_mode;
+ memset(&crtc_mode, 0, sizeof crtc_mode);
+ if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) {
+ drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id);
+ drmModeFreeEncoder(encoder);
+
+ if (!crtc)
+ return Q_NULLPTR;
+
+ if (crtc->mode_valid)
+ crtc_mode = crtc->mode;
+
+ drmModeFreeCrtc(crtc);
+ }
+
+ QList<drmModeModeInfo> modes;
+ qCDebug(qLcEglfsKmsDebug) << connectorName << "mode count:" << connector->count_modes;
+ for (int i = 0; i < connector->count_modes; i++) {
+ const drmModeModeInfo &mode = connector->modes[i];
+ qCDebug(qLcEglfsKmsDebug) << "mode" << i << mode.hdisplay << "x" << mode.vdisplay
+ << "@" << mode.vrefresh << "hz";
+ modes << connector->modes[i];
+ }
+
+ int preferred = -1;
+ int current = -1;
+ int configured = -1;
+ int best = -1;
+
+ for (int i = modes.size() - 1; i >= 0; i--) {
+ const drmModeModeInfo &m = modes.at(i);
+
+ if (configuration == OutputConfigMode &&
+ m.hdisplay == configurationSize.width() &&
+ m.vdisplay == configurationSize.height()) {
+ configured = i;
+ }
+
+ if (!memcmp(&crtc_mode, &m, sizeof m))
+ current = i;
+
+ if (m.type & DRM_MODE_TYPE_PREFERRED)
+ preferred = i;
+
+ best = i;
+ }
+
+ if (configuration == OutputConfigModeline) {
+ modes << configurationModeline;
+ configured = modes.size() - 1;
+ }
+
+ if (current < 0 && crtc_mode.clock != 0) {
+ modes << crtc_mode;
+ current = mode.size() - 1;
+ }
+
+ if (configuration == OutputConfigCurrent)
+ configured = current;
+
+ int selected_mode = -1;
+
+ if (configured >= 0)
+ selected_mode = configured;
+ else if (preferred >= 0)
+ selected_mode = preferred;
+ else if (current >= 0)
+ selected_mode = current;
+ else if (best >= 0)
+ selected_mode = best;
+
+ if (selected_mode < 0) {
+ qWarning() << "No modes available for output" << connectorName;
+ return Q_NULLPTR;
+ } else {
+ int width = modes[selected_mode].hdisplay;
+ int height = modes[selected_mode].vdisplay;
+ int refresh = modes[selected_mode].vrefresh;
+ qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
+ << "@" << refresh << "hz for output" << connectorName;
+ }
+
+ QEglFSKmsOutput output = {
+ connectorName,
+ connector->connector_id,
+ crtc_id,
+ QSizeF(connector->mmWidth, connector->mmHeight),
+ selected_mode,
+ false,
+ drmModeGetCrtc(m_dri_fd, crtc_id),
+ modes
+ };
+
+ m_crtc_allocator |= (1 << output.crtc_id);
+ m_connector_allocator |= (1 << output.connector_id);
+
+ return new QEglFSKmsScreen(m_integration, this, output, pos);
+}
+
+void QEglFSKmsDevice::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ Q_UNUSED(fd);
+ Q_UNUSED(sequence);
+ Q_UNUSED(tv_sec);
+ Q_UNUSED(tv_usec);
+
+ QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(user_data);
+ screen->flipFinished();
+}
+
+QEglFSKmsDevice::QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QString &path)
+ : m_integration(integration)
+ , m_path(path)
+ , m_dri_fd(-1)
+ , m_gbm_device(Q_NULLPTR)
+ , m_crtc_allocator(0)
+ , m_connector_allocator(0)
+{
+}
+
+bool QEglFSKmsDevice::open()
+{
+ Q_ASSERT(m_dri_fd == -1);
+ Q_ASSERT(m_gbm_device == Q_NULLPTR);
+
+ qCDebug(qLcEglfsKmsDebug) << "Opening device" << m_path;
+ m_dri_fd = qt_safe_open(m_path.toLocal8Bit().constData(), O_RDWR | O_CLOEXEC);
+ if (m_dri_fd == -1) {
+ qErrnoWarning("Could not open DRM device %s", qPrintable(m_path));
+ return false;
+ }
+
+ qCDebug(qLcEglfsKmsDebug) << "Creating GBM device for file descriptor" << m_dri_fd
+ << "obtained from" << m_path;
+ m_gbm_device = gbm_create_device(m_dri_fd);
+ if (!m_gbm_device) {
+ qErrnoWarning("Could not create GBM device");
+ qt_safe_close(m_dri_fd);
+ m_dri_fd = -1;
+ return false;
+ }
+
+ return true;
+}
+
+void QEglFSKmsDevice::close()
+{
+ if (m_gbm_device) {
+ gbm_device_destroy(m_gbm_device);
+ m_gbm_device = Q_NULLPTR;
+ }
+
+ if (m_dri_fd != -1) {
+ qt_safe_close(m_dri_fd);
+ m_dri_fd = -1;
+ }
+}
+
+void QEglFSKmsDevice::createScreens()
+{
+ drmModeResPtr resources = drmModeGetResources(m_dri_fd);
+ if (!resources) {
+ qWarning("drmModeGetResources failed");
+ return;
+ }
+
+ QPoint pos(0, 0);
+ QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
+
+ 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();
+ }
+
+ drmModeFreeConnector(connector);
+ }
+
+ drmModeFreeResources(resources);
+}
+
+gbm_device *QEglFSKmsDevice::device() const
+{
+ return m_gbm_device;
+}
+
+int QEglFSKmsDevice::fd() const
+{
+ return m_dri_fd;
+}
+
+void QEglFSKmsDevice::handleDrmEvent()
+{
+ drmEventContext drmEvent = {
+ DRM_EVENT_CONTEXT_VERSION,
+ Q_NULLPTR, // vblank handler
+ pageFlipHandler // page flip handler
+ };
+
+ drmHandleEvent(m_dri_fd, &drmEvent);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h
new file mode 100644
index 0000000000..ebe6f62f5b
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSKMSDEVICE_H
+#define QEGLFSKMSDEVICE_H
+
+#include "qeglfskmsintegration.h"
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include <gbm.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSKmsScreen;
+
+class QEglFSKmsDevice
+{
+public:
+ QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QString &path);
+
+ bool open();
+ void close();
+
+ void createScreens();
+
+ gbm_device *device() const;
+ int fd() const;
+
+ void handleDrmEvent();
+
+private:
+ Q_DISABLE_COPY(QEglFSKmsDevice)
+
+ QEglFSKmsIntegration *m_integration;
+ QString m_path;
+ int m_dri_fd;
+ gbm_device *m_gbm_device;
+
+ quint32 m_crtc_allocator;
+ quint32 m_connector_allocator;
+
+ int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
+ QEglFSKmsScreen *screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos);
+
+ static void pageFlipHandler(int fd,
+ unsigned int sequence,
+ unsigned int tv_sec,
+ unsigned int tv_usec,
+ void *user_data);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
new file mode 100644
index 0000000000..f5aba0742a
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfskmsintegration.h"
+#include "qeglfskmsdevice.h"
+#include "qeglfskmsscreen.h"
+#include "qeglfskmscursor.h"
+
+#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
+#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <QtCore/QLoggingCategory>
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtGui/qpa/qplatformwindow.h>
+#include <QtGui/qpa/qplatformcursor.h>
+#include <QtGui/QScreen>
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include <gbm.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcEglfsKmsDebug, "qt.qpa.eglfs.kms")
+
+QMutex QEglFSKmsScreen::m_waitForFlipMutex;
+
+QEglFSKmsIntegration::QEglFSKmsIntegration()
+ : m_device(Q_NULLPTR)
+ , m_hwCursor(true)
+ , m_pbuffers(false)
+{}
+
+void QEglFSKmsIntegration::platformInit()
+{
+ loadConfig();
+
+ if (!m_devicePath.isEmpty()) {
+ qCDebug(qLcEglfsKmsDebug) << "Using DRM device" << m_devicePath << "specified in config file";
+ } else {
+
+ QDeviceDiscovery *d = QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask);
+ QStringList devices = d->scanConnectedDevices();
+ qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices;
+ d->deleteLater();
+
+ if (devices.isEmpty())
+ qFatal("Could not find DRM device!");
+
+ m_devicePath = devices.first();
+ qCDebug(qLcEglfsKmsDebug) << "Using" << m_devicePath;
+ }
+
+ m_device = new QEglFSKmsDevice(this, m_devicePath);
+ if (!m_device->open())
+ qFatal("Could not open device %s - aborting!", qPrintable(m_devicePath));
+}
+
+void QEglFSKmsIntegration::platformDestroy()
+{
+ m_device->close();
+ delete m_device;
+ m_device = Q_NULLPTR;
+}
+
+EGLNativeDisplayType QEglFSKmsIntegration::platformDisplay() const
+{
+ Q_ASSERT(m_device);
+ return reinterpret_cast<EGLNativeDisplayType>(m_device->device());
+}
+
+bool QEglFSKmsIntegration::usesDefaultScreen()
+{
+ return false;
+}
+
+void QEglFSKmsIntegration::screenInit()
+{
+ m_device->createScreens();
+}
+
+QSurfaceFormat QEglFSKmsIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
+{
+ QSurfaceFormat format(inputFormat);
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
+ format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
+ format.setRedBufferSize(8);
+ format.setGreenBufferSize(8);
+ format.setBlueBufferSize(8);
+ return format;
+}
+
+EGLNativeWindowType QEglFSKmsIntegration::createNativeWindow(QPlatformWindow *platformWindow,
+ const QSize &size,
+ const QSurfaceFormat &format)
+{
+ Q_UNUSED(size);
+ Q_UNUSED(format);
+
+ QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(platformWindow->screen());
+ if (screen->surface()) {
+ qWarning("Only single window per screen supported!");
+ return 0;
+ }
+
+ return reinterpret_cast<EGLNativeWindowType>(screen->createSurface());
+}
+
+EGLNativeWindowType QEglFSKmsIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)
+{
+ Q_UNUSED(format);
+ Q_ASSERT(m_device);
+
+ qCDebug(qLcEglfsKmsDebug) << "Creating native off screen window";
+ gbm_surface *surface = gbm_surface_create(m_device->device(),
+ 1, 1,
+ GBM_FORMAT_XRGB8888,
+ GBM_BO_USE_RENDERING);
+
+ return reinterpret_cast<EGLNativeWindowType>(surface);
+}
+
+void QEglFSKmsIntegration::destroyNativeWindow(EGLNativeWindowType window)
+{
+ gbm_surface *surface = reinterpret_cast<gbm_surface *>(window);
+ gbm_surface_destroy(surface);
+}
+
+bool QEglFSKmsIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case QPlatformIntegration::ThreadedPixmaps:
+ case QPlatformIntegration::OpenGL:
+ case QPlatformIntegration::ThreadedOpenGL:
+ return true;
+ default:
+ return false;
+ }
+}
+
+QPlatformCursor *QEglFSKmsIntegration::createCursor(QPlatformScreen *screen) const
+{
+ if (m_hwCursor)
+ return Q_NULLPTR;
+ else
+ return new QEGLPlatformCursor(screen);
+}
+
+void QEglFSKmsIntegration::waitForVSync(QPlatformSurface *surface) const
+{
+ QWindow *window = static_cast<QWindow *>(surface->surface());
+ QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(window->screen()->handle());
+
+ screen->waitForFlip();
+}
+
+void QEglFSKmsIntegration::presentBuffer(QPlatformSurface *surface)
+{
+ QWindow *window = static_cast<QWindow *>(surface->surface());
+ QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(window->screen()->handle());
+
+ screen->flip();
+}
+
+bool QEglFSKmsIntegration::supportsPBuffers() const
+{
+ return m_pbuffers;
+}
+
+bool QEglFSKmsIntegration::hwCursor() const
+{
+ return m_hwCursor;
+}
+
+QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const
+{
+ return m_outputSettings;
+}
+
+void QEglFSKmsIntegration::loadConfig()
+{
+ static QByteArray json = qgetenv("QT_QPA_EGLFS_KMS_CONFIG");
+ if (json.isEmpty())
+ return;
+
+ qCDebug(qLcEglfsKmsDebug) << "Loading KMS setup from" << json;
+
+ QFile file(QString::fromUtf8(json));
+ if (!file.open(QFile::ReadOnly)) {
+ qCDebug(qLcEglfsKmsDebug) << "Could not open config file"
+ << json << "for reading";
+ return;
+ }
+
+ QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
+ if (!doc.isObject()) {
+ qCDebug(qLcEglfsKmsDebug) << "Invalid config file" << json
+ << "- no top-level JSON object";
+ return;
+ }
+
+ QJsonObject object = doc.object();
+
+ m_hwCursor = object.value("hwcursor").toBool(m_hwCursor);
+ m_pbuffers = object.value("pbuffers").toBool(m_pbuffers);
+ m_devicePath = object.value("device").toString();
+
+ QJsonArray outputs = object.value("outputs").toArray();
+ for (int i = 0; i < outputs.size(); i++) {
+ QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap();
+
+ if (outputSettings.contains("name")) {
+ QString name = outputSettings.value("name").toString();
+
+ if (m_outputSettings.contains(name)) {
+ qCDebug(qLcEglfsKmsDebug) << "Output" << name << "configured multiple times!";
+ }
+
+ m_outputSettings.insert(name, outputSettings);
+ }
+ }
+
+ qCDebug(qLcEglfsKmsDebug) << "Configuration:\n"
+ << "\thwcursor:" << m_hwCursor << "\n"
+ << "\tpbuffers:" << m_pbuffers << "\n"
+ << "\toutputs:" << m_outputSettings;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
new file mode 100644
index 0000000000..434f337176
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSKMSINTEGRATION_H
+#define QEGLFSKMSINTEGRATION_H
+
+#include "qeglfsdeviceintegration.h"
+#include <QtCore/QMap>
+#include <QtCore/QVariant>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSKmsDevice;
+
+class QEglFSKmsIntegration : public QEGLDeviceIntegration
+{
+public:
+ QEglFSKmsIntegration();
+
+ void platformInit() Q_DECL_OVERRIDE;
+ void platformDestroy() Q_DECL_OVERRIDE;
+ EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE;
+ bool usesDefaultScreen() Q_DECL_OVERRIDE;
+ void screenInit() Q_DECL_OVERRIDE;
+ QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const Q_DECL_OVERRIDE;
+ EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
+ const QSize &size,
+ const QSurfaceFormat &format) Q_DECL_OVERRIDE;
+ EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format) Q_DECL_OVERRIDE;
+ void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
+ QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE;
+ void waitForVSync(QPlatformSurface *surface) const Q_DECL_OVERRIDE;
+ void presentBuffer(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ bool supportsPBuffers() const Q_DECL_OVERRIDE;
+
+ bool hwCursor() const;
+ QMap<QString, QVariantMap> outputSettings() const;
+
+private:
+ void loadConfig();
+
+ QEglFSKmsDevice *m_device;
+ bool m_hwCursor;
+ bool m_pbuffers;
+ QString m_devicePath;
+ QMap<QString, QVariantMap> m_outputSettings;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsmain.cpp
new file mode 100644
index 0000000000..8d75ff797e
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsmain.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the qmake spec 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsdeviceintegration.h"
+#include "qeglfskmsintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSKmsIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms.json")
+
+public:
+ QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsIntegration; }
+};
+
+QT_END_NAMESPACE
+
+#include "qeglfskmsmain.moc"
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
new file mode 100644
index 0000000000..0a4d5fe2bc
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfskmsscreen.h"
+#include "qeglfskmsdevice.h"
+#include "qeglfskmscursor.h"
+
+#include <QtCore/QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
+
+void QEglFSKmsScreen::bufferDestroyedHandler(gbm_bo *bo, void *data)
+{
+ FrameBuffer *fb = static_cast<FrameBuffer *>(data);
+
+ if (fb->fb) {
+ gbm_device *device = gbm_bo_get_device(bo);
+ drmModeRmFB(gbm_device_get_fd(device), fb->fb);
+ }
+
+ delete fb;
+}
+
+QEglFSKmsScreen::FrameBuffer *QEglFSKmsScreen::framebufferForBufferObject(gbm_bo *bo)
+{
+ {
+ FrameBuffer *fb = static_cast<FrameBuffer *>(gbm_bo_get_user_data(bo));
+ if (fb)
+ return fb;
+ }
+
+ uint32_t width = gbm_bo_get_width(bo);
+ uint32_t height = gbm_bo_get_height(bo);
+ uint32_t stride = gbm_bo_get_stride(bo);
+ uint32_t handle = gbm_bo_get_handle(bo).u32;
+
+ QScopedPointer<FrameBuffer> fb(new FrameBuffer);
+
+ int ret = drmModeAddFB(m_device->fd(), width, height, 24, 32,
+ stride, handle, &fb->fb);
+
+ if (ret) {
+ qWarning("Failed to create KMS FB!");
+ return Q_NULLPTR;
+ }
+
+ gbm_bo_set_user_data(bo, fb.data(), bufferDestroyedHandler);
+ return fb.take();
+}
+
+QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
+ QEglFSKmsDevice *device,
+ QEglFSKmsOutput output,
+ QPoint position)
+ : QEglFSScreen(eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(device->device())))
+ , m_integration(integration)
+ , m_device(device)
+ , m_gbm_surface(Q_NULLPTR)
+ , m_gbm_bo_current(Q_NULLPTR)
+ , m_gbm_bo_next(Q_NULLPTR)
+ , m_output(output)
+ , m_pos(position)
+ , m_cursor(Q_NULLPTR)
+{
+}
+
+QEglFSKmsScreen::~QEglFSKmsScreen()
+{
+ restoreMode();
+}
+
+QRect QEglFSKmsScreen::geometry() const
+{
+ const int mode = m_output.mode;
+ return QRect(m_pos.x(), m_pos.y(),
+ m_output.modes[mode].hdisplay,
+ m_output.modes[mode].vdisplay);
+}
+
+int QEglFSKmsScreen::depth() const
+{
+ return 32;
+}
+
+QImage::Format QEglFSKmsScreen::format() const
+{
+ return QImage::Format_RGB32;
+}
+
+QSizeF QEglFSKmsScreen::physicalSize() const
+{
+ return m_output.physical_size;
+}
+
+QDpi QEglFSKmsScreen::logicalDpi() const
+{
+ QSizeF ps = physicalSize();
+ QSize s = geometry().size();
+
+ if (ps.isValid() && s.isValid())
+ return QDpi(25.4 * s.width() / ps.width(),
+ 25.4 * s.height() / ps.height());
+ else
+ return QDpi(100, 100);
+}
+
+Qt::ScreenOrientation QEglFSKmsScreen::nativeOrientation() const
+{
+ return Qt::PrimaryOrientation;
+}
+
+Qt::ScreenOrientation QEglFSKmsScreen::orientation() const
+{
+ return Qt::PrimaryOrientation;
+}
+
+QString QEglFSKmsScreen::name() const
+{
+ return m_output.name;
+}
+
+QPlatformCursor *QEglFSKmsScreen::cursor() const
+{
+ if (m_integration->hwCursor()) {
+ if (m_cursor.isNull()) {
+ QEglFSKmsScreen *that = const_cast<QEglFSKmsScreen *>(this);
+ that->m_cursor.reset(new QEglFSKmsCursor(that));
+ }
+
+ return m_cursor.data();
+ } else {
+ return QEglFSScreen::cursor();
+ }
+}
+
+gbm_surface *QEglFSKmsScreen::createSurface()
+{
+ if (!m_gbm_surface) {
+ qCDebug(qLcEglfsKmsDebug) << "Creating window for screen" << name();
+ m_gbm_surface = gbm_surface_create(m_device->device(),
+ geometry().width(),
+ geometry().height(),
+ GBM_FORMAT_XRGB8888,
+ GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+ }
+ return m_gbm_surface;
+}
+
+void QEglFSKmsScreen::destroySurface()
+{
+ if (m_gbm_bo_current) {
+ gbm_bo_destroy(m_gbm_bo_current);
+ m_gbm_bo_current = Q_NULLPTR;
+ }
+
+ if (m_gbm_bo_next) {
+ gbm_bo_destroy(m_gbm_bo_next);
+ m_gbm_bo_next = Q_NULLPTR;
+ }
+
+ if (m_gbm_surface) {
+ gbm_surface_destroy(m_gbm_surface);
+ m_gbm_surface = Q_NULLPTR;
+ }
+}
+
+void QEglFSKmsScreen::waitForFlip()
+{
+ // Don't lock the mutex unless we actually need to
+ if (!m_gbm_bo_next)
+ return;
+
+ QMutexLocker lock(&m_waitForFlipMutex);
+ while (m_gbm_bo_next)
+ m_device->handleDrmEvent();
+}
+
+void QEglFSKmsScreen::flip()
+{
+ if (!m_gbm_surface) {
+ qWarning("Cannot sync before platform init!");
+ return;
+ }
+
+ m_gbm_bo_next = gbm_surface_lock_front_buffer(m_gbm_surface);
+ if (!m_gbm_bo_next) {
+ qWarning("Could not lock GBM surface front buffer!");
+ return;
+ }
+
+ FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next);
+
+ if (!m_output.mode_set) {
+ int ret = drmModeSetCrtc(m_device->fd(),
+ m_output.crtc_id,
+ fb->fb,
+ 0, 0,
+ &m_output.connector_id, 1,
+ &m_output.modes[m_output.mode]);
+
+ if (ret)
+ qErrnoWarning("Could not set DRM mode!");
+ else
+ m_output.mode_set = true;
+ }
+
+ int ret = drmModePageFlip(m_device->fd(),
+ m_output.crtc_id,
+ fb->fb,
+ DRM_MODE_PAGE_FLIP_EVENT,
+ this);
+ if (ret) {
+ qErrnoWarning("Could not queue DRM page flip!");
+ gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
+ m_gbm_bo_next = Q_NULLPTR;
+ }
+}
+
+void QEglFSKmsScreen::flipFinished()
+{
+ if (m_gbm_bo_current)
+ gbm_surface_release_buffer(m_gbm_surface,
+ m_gbm_bo_current);
+
+ m_gbm_bo_current = m_gbm_bo_next;
+ m_gbm_bo_next = Q_NULLPTR;
+}
+
+void QEglFSKmsScreen::restoreMode()
+{
+ if (m_output.mode_set && m_output.saved_crtc) {
+ drmModeSetCrtc(m_device->fd(),
+ m_output.saved_crtc->crtc_id,
+ m_output.saved_crtc->buffer_id,
+ 0, 0,
+ &m_output.connector_id, 1,
+ &m_output.saved_crtc->mode);
+
+ drmModeFreeCrtc(m_output.saved_crtc);
+ m_output.saved_crtc = Q_NULLPTR;
+
+ m_output.mode_set = false;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
new file mode 100644
index 0000000000..e4d5ee9e0a
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSKMSSCREEN_H
+#define QEGLFSKMSSCREEN_H
+
+#include "qeglfskmsintegration.h"
+#include "qeglfsscreen.h"
+#include <QtCore/QList>
+#include <QtCore/QMutex>
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include <gbm.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSKmsDevice;
+class QEglFSKmsCursor;
+
+struct QEglFSKmsOutput
+{
+ QString name;
+ uint32_t connector_id;
+ uint32_t crtc_id;
+ QSizeF physical_size;
+ int mode; // index of selected mode in list below
+ bool mode_set;
+ drmModeCrtcPtr saved_crtc;
+ QList<drmModeModeInfo> modes;
+};
+
+class QEglFSKmsScreen : public QEglFSScreen
+{
+public:
+ QEglFSKmsScreen(QEglFSKmsIntegration *integration,
+ QEglFSKmsDevice *device,
+ QEglFSKmsOutput output,
+ QPoint position);
+ ~QEglFSKmsScreen();
+
+ QRect geometry() const Q_DECL_OVERRIDE;
+ int depth() const Q_DECL_OVERRIDE;
+ QImage::Format format() const Q_DECL_OVERRIDE;
+
+ QSizeF physicalSize() const Q_DECL_OVERRIDE;
+ QDpi logicalDpi() const Q_DECL_OVERRIDE;
+ Qt::ScreenOrientation nativeOrientation() const Q_DECL_OVERRIDE;
+ Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE;
+
+ QString name() const Q_DECL_OVERRIDE;
+
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
+
+ QEglFSKmsDevice *device() const { return m_device; }
+
+ gbm_surface *surface() const { return m_gbm_surface; }
+ gbm_surface *createSurface();
+ void destroySurface();
+
+ void waitForFlip();
+ void flip();
+ void flipFinished();
+
+ QEglFSKmsOutput &output() { return m_output; }
+ void restoreMode();
+
+private:
+ QEglFSKmsIntegration *m_integration;
+ QEglFSKmsDevice *m_device;
+ gbm_surface *m_gbm_surface;
+
+ gbm_bo *m_gbm_bo_current;
+ gbm_bo *m_gbm_bo_next;
+
+ QEglFSKmsOutput m_output;
+ QPoint m_pos;
+ QScopedPointer<QEglFSKmsCursor> m_cursor;
+
+ struct FrameBuffer {
+ FrameBuffer() : fb(0) {}
+ uint32_t fb;
+ };
+ static void bufferDestroyedHandler(gbm_bo *bo, void *data);
+ FrameBuffer *framebufferForBufferObject(gbm_bo *bo);
+
+ static QMutex m_waitForFlipMutex;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.json b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.json
new file mode 100644
index 0000000000..846252789a
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "eglfs_x11" ]
+}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
new file mode 100644
index 0000000000..a1d08248ff
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
@@ -0,0 +1,24 @@
+TARGET = qeglfs-x11-integration
+
+PLUGIN_CLASS_NAME=QEglFSX11IntegrationPlugin
+PLUGIN_TYPE=egldeviceintegrations
+
+load(qt_plugin)
+
+QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+
+# Avoid X11 header collision
+DEFINES += MESA_EGL_NO_X11_HEADERS
+
+INCLUDEPATH += $$PWD/../..
+
+CONFIG += egl
+LIBS += -lX11 -lX11-xcb -lxcb
+QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
+
+SOURCES += $$PWD/qeglfsx11main.cpp \
+ $$PWD/qeglfsx11integration.cpp
+
+HEADERS += $$PWD/qeglfsx11integration.h
+
+OTHER_FILES += $$PWD/eglfs_x11.json
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
index b16857297c..e41c007df9 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the qmake spec of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,75 +31,28 @@
**
****************************************************************************/
-#include "qeglfshooks.h"
-
-#include <qpa/qwindowsysteminterface.h>
-#include <qpa/qplatformwindow.h>
+#include "qeglfsx11integration.h"
#include <QThread>
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
-#include <xcb/xcb.h>
-QT_BEGIN_NAMESPACE
+/* Make no mistake: This is not a replacement for the xcb platform plugin.
+ This here is barely an extremely useful tool for developing eglfs itself because
+ it allows to do so without any requirements for devices or drivers. */
-class QEglFSX11Hooks;
+QT_BEGIN_NAMESPACE
class EventReader : public QThread
{
public:
- EventReader(QEglFSX11Hooks *hooks)
- : m_hooks(hooks) { }
+ EventReader(QEglFSX11Integration *integration)
+ : m_integration(integration) { }
void run();
private:
- QEglFSX11Hooks *m_hooks;
-};
-
-namespace Atoms {
- enum {
- _NET_WM_NAME = 0,
- UTF8_STRING,
- WM_PROTOCOLS,
- WM_DELETE_WINDOW,
- _NET_WM_STATE,
- _NET_WM_STATE_FULLSCREEN,
-
- N_ATOMS
- };
-}
-
-class QEglFSX11Hooks : public QEglFSHooks
-{
-public:
- QEglFSX11Hooks() : m_connection(0), m_window(0), m_eventReader(0) {}
-
- virtual void platformInit();
- virtual void platformDestroy();
- virtual EGLNativeDisplayType platformDisplay() const;
- virtual QSize screenSize() const;
- virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window,
- const QSize &size,
- const QSurfaceFormat &format);
- virtual void destroyNativeWindow(EGLNativeWindowType window);
- virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
-
- xcb_connection_t *connection() { return m_connection; }
- const xcb_atom_t *atoms() const { return m_atoms; }
- QPlatformWindow *platformWindow() { return m_platformWindow; }
-
-private:
- void sendConnectionEvent(xcb_atom_t a);
-
- Display *m_display;
- xcb_connection_t *m_connection;
- xcb_atom_t m_atoms[Atoms::N_ATOMS];
- xcb_window_t m_window;
- EventReader *m_eventReader;
- xcb_window_t m_connectionEventListener;
- QPlatformWindow *m_platformWindow;
- mutable QSize m_screenSize;
+ QEglFSX11Integration *m_integration;
};
QAtomicInt running;
@@ -156,7 +109,7 @@ void EventReader::run()
Qt::MouseButtons buttons;
xcb_generic_event_t *event;
- while (running.load() && (event = xcb_wait_for_event(m_hooks->connection()))) {
+ while (running.load() && (event = xcb_wait_for_event(m_integration->connection()))) {
uint response_type = event->response_type & ~0x80;
switch (response_type) {
case XCB_BUTTON_PRESS: {
@@ -183,11 +136,11 @@ void EventReader::run()
}
case XCB_CLIENT_MESSAGE: {
xcb_client_message_event_t *client = (xcb_client_message_event_t *) event;
- const xcb_atom_t *atoms = m_hooks->atoms();
+ const xcb_atom_t *atoms = m_integration->atoms();
if (client->format == 32
&& client->type == atoms[Atoms::WM_PROTOCOLS]
&& client->data.data32[0] == atoms[Atoms::WM_DELETE_WINDOW]) {
- QWindow *window = m_hooks->platformWindow() ? m_hooks->platformWindow()->window() : 0;
+ QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : 0;
if (window)
QWindowSystemInterface::handleCloseEvent(window);
}
@@ -199,7 +152,7 @@ void EventReader::run()
}
}
-void QEglFSX11Hooks::sendConnectionEvent(xcb_atom_t a)
+void QEglFSX11Integration::sendConnectionEvent(xcb_atom_t a)
{
xcb_client_message_event_t event;
memset(&event, 0, sizeof(event));
@@ -214,14 +167,16 @@ void QEglFSX11Hooks::sendConnectionEvent(xcb_atom_t a)
xcb_flush(m_connection);
}
-void QEglFSX11Hooks::platformInit()
+#define DISPLAY ((Display *) m_display)
+
+void QEglFSX11Integration::platformInit()
{
m_display = XOpenDisplay(0);
if (!m_display)
qFatal("Could not open display");
- XSetEventQueueOwner(m_display, XCBOwnsEventQueue);
- m_connection = XGetXCBConnection(m_display);
+ XSetEventQueueOwner(DISPLAY, XCBOwnsEventQueue);
+ m_connection = XGetXCBConnection(DISPLAY);
running.ref();
@@ -237,7 +192,7 @@ void QEglFSX11Hooks::platformInit()
m_eventReader->start();
}
-void QEglFSX11Hooks::platformDestroy()
+void QEglFSX11Integration::platformDestroy()
{
running.deref();
@@ -247,31 +202,32 @@ void QEglFSX11Hooks::platformDestroy()
delete m_eventReader;
m_eventReader = 0;
- XCloseDisplay(m_display);
+ XCloseDisplay(DISPLAY);
m_display = 0;
m_connection = 0;
}
-EGLNativeDisplayType QEglFSX11Hooks::platformDisplay() const
+EGLNativeDisplayType QEglFSX11Integration::platformDisplay() const
{
- return m_display;
+ return DISPLAY;
}
-QSize QEglFSX11Hooks::screenSize() const
+QSize QEglFSX11Integration::screenSize() const
{
if (m_screenSize.isEmpty()) {
QList<QByteArray> env = qgetenv("EGLFS_X11_SIZE").split('x');
if (env.length() == 2) {
m_screenSize = QSize(env.at(0).toInt(), env.at(1).toInt());
} else {
- m_screenSize = QSize(640, 480);
- qDebug("EGLFS_X11_SIZE not set, falling back to 640x480");
+ XWindowAttributes a;
+ if (XGetWindowAttributes(DISPLAY, DefaultRootWindow(DISPLAY), &a))
+ m_screenSize = QSize(a.width, a.height);
}
}
return m_screenSize;
}
-EGLNativeWindowType QEglFSX11Hooks::createNativeWindow(QPlatformWindow *platformWindow,
+EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *platformWindow,
const QSize &size,
const QSurfaceFormat &format)
{
@@ -286,8 +242,6 @@ EGLNativeWindowType QEglFSX11Hooks::createNativeWindow(QPlatformWindow *platform
XCB_WINDOW_CLASS_INPUT_OUTPUT, it.data->root_visual,
0, 0);
- xcb_map_window(m_connection, m_window);
-
xcb_intern_atom_cookie_t cookies[Atoms::N_ATOMS];
static const char *atomNames[Atoms::N_ATOMS] = {
"_NET_WM_NAME",
@@ -313,30 +267,26 @@ EGLNativeWindowType QEglFSX11Hooks::createNativeWindow(QPlatformWindow *platform
xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window,
m_atoms[Atoms::WM_PROTOCOLS], XCB_ATOM_ATOM, 32, 1, &m_atoms[Atoms::WM_DELETE_WINDOW]);
- if (qgetenv("EGLFS_X11_FULLSCREEN").toInt()) {
- // Go fullscreen. The QScreen and QWindow size is controlled by EGLFS_X11_SIZE regardless,
- // this is just the native window.
- xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window,
- m_atoms[Atoms::_NET_WM_STATE], XCB_ATOM_ATOM, 32, 1, &m_atoms[Atoms::_NET_WM_STATE_FULLSCREEN]);
- }
+ // Go fullscreen.
+ xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window,
+ m_atoms[Atoms::_NET_WM_STATE], XCB_ATOM_ATOM, 32, 1, &m_atoms[Atoms::_NET_WM_STATE_FULLSCREEN]);
+
+ xcb_map_window(m_connection, m_window);
xcb_flush(m_connection);
return m_window;
}
-void QEglFSX11Hooks::destroyNativeWindow(EGLNativeWindowType window)
+void QEglFSX11Integration::destroyNativeWindow(EGLNativeWindowType window)
{
xcb_destroy_window(m_connection, window);
}
-bool QEglFSX11Hooks::hasCapability(QPlatformIntegration::Capability cap) const
+bool QEglFSX11Integration::hasCapability(QPlatformIntegration::Capability cap) const
{
Q_UNUSED(cap);
return false;
}
-static QEglFSX11Hooks eglFSX11Hooks;
-QEglFSHooks *platformHooks = &eglFSX11Hooks;
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
new file mode 100644
index 0000000000..78db504f3b
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSX11INTEGRATION_H
+#define QEGLFSX11INTEGRATION_H
+
+#include "qeglfsdeviceintegration.h"
+
+#include <qpa/qwindowsysteminterface.h>
+#include <qpa/qplatformwindow.h>
+
+#include <xcb/xcb.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Atoms {
+ enum {
+ _NET_WM_NAME = 0,
+ UTF8_STRING,
+ WM_PROTOCOLS,
+ WM_DELETE_WINDOW,
+ _NET_WM_STATE,
+ _NET_WM_STATE_FULLSCREEN,
+
+ N_ATOMS
+ };
+}
+
+class EventReader;
+
+class QEglFSX11Integration : public QEGLDeviceIntegration
+{
+public:
+ QEglFSX11Integration() : m_connection(0), m_window(0), m_eventReader(0) {}
+
+ void platformInit() Q_DECL_OVERRIDE;
+ void platformDestroy() Q_DECL_OVERRIDE;
+ EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE;
+ QSize screenSize() const Q_DECL_OVERRIDE;
+ EGLNativeWindowType createNativeWindow(QPlatformWindow *window,
+ const QSize &size,
+ const QSurfaceFormat &format) Q_DECL_OVERRIDE;
+ void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
+
+ xcb_connection_t *connection() { return m_connection; }
+ const xcb_atom_t *atoms() const { return m_atoms; }
+ QPlatformWindow *platformWindow() { return m_platformWindow; }
+
+private:
+ void sendConnectionEvent(xcb_atom_t a);
+
+ void *m_display;
+ xcb_connection_t *m_connection;
+ xcb_atom_t m_atoms[Atoms::N_ATOMS];
+ xcb_window_t m_window;
+ EventReader *m_eventReader;
+ xcb_window_t m_connectionEventListener;
+ QPlatformWindow *m_platformWindow;
+ mutable QSize m_screenSize;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
new file mode 100644
index 0000000000..2eee03f595
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the qmake spec 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsdeviceintegration.h"
+#include "qeglfsx11integration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSX11IntegrationPlugin : public QEGLDeviceIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_x11.json")
+
+public:
+ QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSX11Integration; }
+};
+
+QT_END_NAMESPACE
+
+#include "qeglfsx11main.moc"
diff --git a/src/plugins/platforms/eglfs/eglfs-plugin.pro b/src/plugins/platforms/eglfs/eglfs-plugin.pro
new file mode 100644
index 0000000000..0f493fdc01
--- /dev/null
+++ b/src/plugins/platforms/eglfs/eglfs-plugin.pro
@@ -0,0 +1,12 @@
+TARGET = qeglfs
+
+PLUGIN_TYPE = platforms
+PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin
+!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
+load(qt_plugin)
+
+QT += platformsupport-private eglfs_device_lib-private
+
+SOURCES += $$PWD/qeglfsmain.cpp
+
+OTHER_FILES += $$PWD/eglfs.json
diff --git a/src/plugins/platforms/eglfs/eglfs.pri b/src/plugins/platforms/eglfs/eglfs.pri
deleted file mode 100644
index 6f463ba7d9..0000000000
--- a/src/plugins/platforms/eglfs/eglfs.pri
+++ /dev/null
@@ -1,44 +0,0 @@
-QT += core-private gui-private platformsupport-private
-
-# Avoid X11 header collision
-DEFINES += MESA_EGL_NO_X11_HEADERS
-
-# Uncomment these to enable the X hooks, allowing to test the platform
-# plugin in a regular X11 environment (as long as EGL is available).
-# EGLFS_PLATFORM_HOOKS_SOURCES += qeglfshooks_x11.cpp
-# LIBS += -lX11 -lX11-xcb -lxcb
-
-# Uncomment these to enable the KMS hooks.
-# EGLFS_PLATFORM_HOOKS_SOURCES += qeglfshooks_kms.cpp
-# CONFIG += link_pkgconfig
-# PKGCONFIG += libdrm gbm
-
-SOURCES += $$PWD/qeglfsintegration.cpp \
- $$PWD/qeglfswindow.cpp \
- $$PWD/qeglfsscreen.cpp \
- $$PWD/qeglfshooks_stub.cpp \
- $$PWD/qeglfscontext.cpp
-
-HEADERS += $$PWD/qeglfsintegration.h \
- $$PWD/qeglfswindow.h \
- $$PWD/qeglfsscreen.h \
- $$PWD/qeglfshooks.h \
- $$PWD/qeglfscontext.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
-}
-
-CONFIG += egl qpa/genericunixfontdatabase
-
-RESOURCES += $$PWD/cursor.qrc
-
-OTHER_FILES += \
- $$PWD/eglfs.json
diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro
index 3ebe05b35e..03c96ca1d9 100644
--- a/src/plugins/platforms/eglfs/eglfs.pro
+++ b/src/plugins/platforms/eglfs/eglfs.pro
@@ -1,10 +1,6 @@
-TARGET = qeglfs
+TEMPLATE = subdirs
+CONFIG += ordered
-PLUGIN_TYPE = platforms
-PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin
-!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
-load(qt_plugin)
-
-SOURCES += $$PWD/main.cpp
-
-include(eglfs.pri)
+SUBDIRS += eglfs_device_lib.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
new file mode 100644
index 0000000000..d8ce421a69
--- /dev/null
+++ b/src/plugins/platforms/eglfs/eglfs_device_lib.pro
@@ -0,0 +1,59 @@
+# 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
+
+MODULE_INCLUDES = \
+ \$\$QT_MODULE_INCLUDE_BASE \
+ \$\$QT_MODULE_INCLUDE_BASE/QtQGui
+MODULE_PRIVATE_INCLUDES = \
+ \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION \
+ \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION/QtGui
+
+load(qt_module)
+
+QT += core-private gui-private platformsupport-private
+LIBS += $$QMAKE_LIBS_DYNLOAD
+
+# Avoid X11 header collision
+DEFINES += MESA_EGL_NO_X11_HEADERS
+
+DEFINES += QT_BUILD_EGL_DEVICE_LIB
+
+SOURCES += $$PWD/qeglfsintegration.cpp \
+ $$PWD/qeglfswindow.cpp \
+ $$PWD/qeglfsscreen.cpp \
+ $$PWD/qeglfshooks.cpp \
+ $$PWD/qeglfscontext.cpp \
+ $$PWD/qeglfsoffscreenwindow.cpp \
+ $$PWD/qeglfsdeviceintegration.cpp
+
+HEADERS += $$PWD/qeglfsintegration.h \
+ $$PWD/qeglfswindow.h \
+ $$PWD/qeglfsscreen.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
+
+RESOURCES += $$PWD/cursor.qrc
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp
index 6470280e2c..4bda09653f 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp
@@ -46,7 +46,8 @@ QT_BEGIN_NAMESPACE
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
EGLConfig *config, const QVariant &nativeHandle)
- : QEGLPlatformContext(format, share, display, config, nativeHandle)
+ : QEGLPlatformContext(format, share, display, config, nativeHandle),
+ m_tempWindow(0)
{
}
@@ -58,17 +59,45 @@ EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface
return static_cast<QEGLPbuffer *>(surface)->pbuffer();
}
+EGLSurface QEglFSContext::createTemporaryOffscreenSurface()
+{
+ if (qt_egl_device_integration()->supportsPBuffers())
+ return QEGLPlatformContext::createTemporaryOffscreenSurface();
+
+ if (!m_tempWindow) {
+ m_tempWindow = qt_egl_device_integration()->createNativeOffscreenWindow(format());
+ if (!m_tempWindow) {
+ qWarning("QEglFSContext: Failed to create temporary native window");
+ return EGL_NO_SURFACE;
+ }
+ }
+ EGLConfig config = q_configFromGLFormat(eglDisplay(), format());
+ return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0);
+}
+
+void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
+{
+ if (qt_egl_device_integration()->supportsPBuffers()) {
+ QEGLPlatformContext::destroyTemporaryOffscreenSurface(surface);
+ } else {
+ eglDestroySurface(eglDisplay(), surface);
+ qt_egl_device_integration()->destroyNativeWindow(m_tempWindow);
+ m_tempWindow = 0;
+ }
+}
+
void QEglFSContext::swapBuffers(QPlatformSurface *surface)
{
// draw the cursor
if (surface->surface()->surfaceClass() == QSurface::Window) {
QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
- if (QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(window->screen()->cursor()))
+ if (QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(window->screen()->cursor()))
cursor->paintOnScreen();
}
- QEglFSHooks::hooks()->waitForVSync();
+ qt_egl_device_integration()->waitForVSync(surface);
QEGLPlatformContext::swapBuffers(surface);
+ qt_egl_device_integration()->presentBuffer(surface);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h
index fcdad5ed22..245f690822 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.h
+++ b/src/plugins/platforms/eglfs/qeglfscontext.h
@@ -36,16 +36,22 @@
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#include <QtCore/QVariant>
+#include "qeglfsglobal.h"
QT_BEGIN_NAMESPACE
-class QEglFSContext : public QEGLPlatformContext
+class Q_EGLFS_EXPORT QEglFSContext : public QEGLPlatformContext
{
public:
QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
EGLConfig *config, const QVariant &nativeHandle);
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ EGLSurface createTemporaryOffscreenSurface() Q_DECL_OVERRIDE;
+ void destroyTemporaryOffscreenSurface(EGLSurface surface) Q_DECL_OVERRIDE;
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+
+private:
+ EGLNativeWindowType m_tempWindow;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
new file mode 100644
index 0000000000..69a5f67ea9
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsdeviceintegration.h"
+#include "qeglfsintegration.h"
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
+#include <QGuiApplication>
+#include <private/qguiapplication_p.h>
+#include <QScreen>
+#include <QDir>
+#include <QRegularExpression>
+#include <QLoggingCategory>
+
+#if defined(Q_OS_LINUX)
+#include <fcntl.h>
+#include <unistd.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+#endif
+
+#include <private/qfactoryloader_p.h>
+#include <private/qcore_unix_p.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration")
+
+#ifndef QT_NO_LIBRARY
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+
+static inline QEGLDeviceIntegration *loadIntegration(QFactoryLoader *loader, const QString &key)
+{
+ const int index = loader->indexOf(key);
+ if (index != -1) {
+ QObject *plugin = loader->instance(index);
+ if (QEGLDeviceIntegrationPlugin *factory = qobject_cast<QEGLDeviceIntegrationPlugin *>(plugin)) {
+ if (QEGLDeviceIntegration *result = factory->create())
+ return result;
+ }
+ }
+ return Q_NULLPTR;
+}
+
+#endif // QT_NO_LIBRARY
+
+QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList list;
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ list = directLoader()->keyMap().values();
+ if (!list.isEmpty()) {
+ const QString postFix = QStringLiteral(" (from ")
+ + QDir::toNativeSeparators(pluginPath)
+ + QLatin1Char(')');
+ const QStringList::iterator end = list.end();
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
+ (*it).append(postFix);
+ }
+ }
+ list.append(loader()->keyMap().values());
+ qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys:" << list;
+ return list;
+#else
+ return QStringList();
+#endif
+}
+
+QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)
+{
+ QEGLDeviceIntegration *integration = Q_NULLPTR;
+#ifndef QT_NO_LIBRARY
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ integration = loadIntegration(directLoader(), key);
+ }
+ if (!integration)
+ integration = loadIntegration(loader(), key);
+ if (integration)
+ qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
+ else
+ qCWarning(qLcEglDevDebug) << "Failed to load EGL device integration" << key;
+#endif
+ return integration;
+}
+
+static int framebuffer = -1;
+
+QByteArray QEGLDeviceIntegration::fbDeviceName() const
+{
+ QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB");
+ if (fbDev.isEmpty())
+ fbDev = QByteArrayLiteral("/dev/fb0");
+
+ return fbDev;
+}
+
+int QEGLDeviceIntegration::framebufferIndex() const
+{
+ int fbIndex = 0;
+#ifndef QT_NO_REGULAREXPRESSION
+ QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
+ QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName()));
+ if (match.hasMatch())
+ fbIndex = match.captured(1).toInt();
+#endif
+ return fbIndex;
+}
+
+void QEGLDeviceIntegration::platformInit()
+{
+ QByteArray fbDev = fbDeviceName();
+
+ framebuffer = qt_safe_open(fbDev, O_RDONLY);
+
+ if (framebuffer == -1) {
+ qWarning("EGLFS: Failed to open %s", fbDev.constData());
+ qFatal("EGLFS: Can't continue without a display");
+ }
+}
+
+void QEGLDeviceIntegration::platformDestroy()
+{
+ if (framebuffer != -1)
+ close(framebuffer);
+}
+
+EGLNativeDisplayType QEGLDeviceIntegration::platformDisplay() const
+{
+ return EGL_DEFAULT_DISPLAY;
+}
+
+bool QEGLDeviceIntegration::usesDefaultScreen()
+{
+ return true;
+}
+
+void QEGLDeviceIntegration::screenInit()
+{
+ // Nothing to do here. Called only when usesDefaultScreen is false.
+}
+
+void QEGLDeviceIntegration::screenDestroy()
+{
+ QGuiApplication *app = qGuiApp;
+ QEglFSIntegration *platformIntegration = static_cast<QEglFSIntegration *>(
+ QGuiApplicationPrivate::platformIntegration());
+ while (!app->screens().isEmpty())
+ platformIntegration->removeScreen(app->screens().last()->handle());
+}
+
+QSizeF QEGLDeviceIntegration::physicalScreenSize() const
+{
+ return q_physicalScreenSizeFromFb(framebuffer, screenSize());
+}
+
+QSize QEGLDeviceIntegration::screenSize() const
+{
+ return q_screenSizeFromFb(framebuffer);
+}
+
+QDpi QEGLDeviceIntegration::logicalDpi() const
+{
+ QSizeF ps = physicalScreenSize();
+ QSize s = screenSize();
+
+ return QDpi(25.4 * s.width() / ps.width(),
+ 25.4 * s.height() / ps.height());
+}
+
+Qt::ScreenOrientation QEGLDeviceIntegration::nativeOrientation() const
+{
+ return Qt::PrimaryOrientation;
+}
+
+Qt::ScreenOrientation QEGLDeviceIntegration::orientation() const
+{
+ return Qt::PrimaryOrientation;
+}
+
+int QEGLDeviceIntegration::screenDepth() const
+{
+ return q_screenDepthFromFb(framebuffer);
+}
+
+QImage::Format QEGLDeviceIntegration::screenFormat() const
+{
+ return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
+}
+
+QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
+{
+ QSurfaceFormat format = inputFormat;
+
+ static const bool force888 = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCE888");
+ if (force888) {
+ format.setRedBufferSize(8);
+ format.setGreenBufferSize(8);
+ format.setBlueBufferSize(8);
+ }
+
+ return format;
+}
+
+bool QEGLDeviceIntegration::filterConfig(EGLDisplay, EGLConfig) const
+{
+ return true;
+}
+
+EGLNativeWindowType QEGLDeviceIntegration::createNativeWindow(QPlatformWindow *platformWindow,
+ const QSize &size,
+ const QSurfaceFormat &format)
+{
+ Q_UNUSED(platformWindow);
+ Q_UNUSED(size);
+ Q_UNUSED(format);
+ return 0;
+}
+
+EGLNativeWindowType QEGLDeviceIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)
+{
+ Q_UNUSED(format);
+ return 0;
+}
+
+void QEGLDeviceIntegration::destroyNativeWindow(EGLNativeWindowType window)
+{
+ Q_UNUSED(window);
+}
+
+bool QEGLDeviceIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ Q_UNUSED(cap);
+ return false;
+}
+
+QPlatformCursor *QEGLDeviceIntegration::createCursor(QPlatformScreen *screen) const
+{
+ return new QEGLPlatformCursor(screen);
+}
+
+void QEGLDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
+{
+ Q_UNUSED(surface);
+
+#if defined(FBIO_WAITFORVSYNC)
+ static const bool forceSync = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCEVSYNC");
+ if (forceSync && framebuffer != -1) {
+ int arg = 0;
+ if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1)
+ qWarning("Could not wait for vsync.");
+ }
+#endif
+}
+
+void QEGLDeviceIntegration::presentBuffer(QPlatformSurface *surface)
+{
+ Q_UNUSED(surface);
+}
+
+bool QEGLDeviceIntegration::supportsPBuffers() const
+{
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
new file mode 100644
index 0000000000..42abc23c31
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSDEVICEINTEGRATION_H
+#define 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 <qpa/qplatformintegration.h>
+#include <qpa/qplatformscreen.h>
+#include <QtCore/QString>
+#include <QtGui/QSurfaceFormat>
+#include <QtGui/QImage>
+#include <EGL/egl.h>
+#include "qeglfsglobal.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformSurface;
+
+#define QEGLDeviceIntegrationFactoryInterface_iid "org.qt-project.qt.qpa.egl.QEGLDeviceIntegrationFactoryInterface.5.5"
+
+class Q_EGLFS_EXPORT QEGLDeviceIntegration
+{
+public:
+ virtual ~QEGLDeviceIntegration() { }
+
+ virtual void platformInit();
+ virtual void platformDestroy();
+ virtual EGLNativeDisplayType platformDisplay() const;
+ virtual bool usesDefaultScreen();
+ virtual void screenInit();
+ virtual void screenDestroy();
+ virtual QSizeF physicalScreenSize() const;
+ virtual QSize screenSize() const;
+ virtual QDpi logicalDpi() const;
+ virtual Qt::ScreenOrientation nativeOrientation() const;
+ virtual Qt::ScreenOrientation orientation() const;
+ virtual int screenDepth() const;
+ virtual QImage::Format screenFormat() const;
+ virtual QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const;
+ virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
+ const QSize &size,
+ const QSurfaceFormat &format);
+ virtual EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format);
+ virtual void destroyNativeWindow(EGLNativeWindowType window);
+ virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
+ virtual QPlatformCursor *createCursor(QPlatformScreen *screen) const;
+ virtual bool filterConfig(EGLDisplay display, EGLConfig config) const;
+ virtual void waitForVSync(QPlatformSurface *surface) const;
+ virtual void presentBuffer(QPlatformSurface *surface);
+ virtual QByteArray fbDeviceName() const;
+ virtual int framebufferIndex() const;
+ virtual bool supportsPBuffers() const;
+};
+
+class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject
+{
+ Q_OBJECT
+
+public:
+ virtual QEGLDeviceIntegration *create() = 0;
+};
+
+class Q_EGLFS_EXPORT QEGLDeviceIntegrationFactory
+{
+public:
+ static QStringList keys(const QString &pluginPath = QString());
+ static QEGLDeviceIntegration *create(const QString &name, const QString &platformPluginPath = QString());
+};
+
+QT_END_NAMESPACE
+
+#endif // QEGLDEVICEINTEGRATION_H
diff --git a/src/plugins/platforms/eglfs/qeglfsglobal.h b/src/plugins/platforms/eglfs/qeglfsglobal.h
new file mode 100644
index 0000000000..db9a76f899
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsglobal.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSGLOBAL_H
+#define QEGLFSGLOBAL_H
+
+#include <qglobal.h>
+
+#ifdef QT_BUILD_EGL_DEVICE_LIB
+#define Q_EGLFS_EXPORT Q_DECL_EXPORT
+#else
+#define Q_EGLFS_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.cpp b/src/plugins/platforms/eglfs/qeglfshooks.cpp
new file mode 100644
index 0000000000..2f12c61f99
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfshooks.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the qmake spec 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfshooks.h"
+#include <QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug)
+
+#ifdef EGLFS_PLATFORM_HOOKS
+
+QEGLDeviceIntegration *qt_egl_device_integration()
+{
+ extern QEglFSHooks *platformHooks;
+ return platformHooks;
+}
+
+#else
+
+class DeviceIntegration
+{
+public:
+ DeviceIntegration();
+ ~DeviceIntegration() { delete m_integration; }
+ QEGLDeviceIntegration *integration() { return m_integration; }
+private:
+ QEGLDeviceIntegration *m_integration;
+};
+
+Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
+
+DeviceIntegration::DeviceIntegration()
+{
+ QStringList pluginKeys = QEGLDeviceIntegrationFactory::keys();
+ if (!pluginKeys.isEmpty()) {
+ // Some built-in logic: Prioritize either X11 or KMS/DRM.
+ if (qEnvironmentVariableIsSet("DISPLAY")) {
+ const QString x11key = QStringLiteral("eglfs_x11");
+ if (pluginKeys.contains(x11key)) {
+ pluginKeys.removeOne(x11key);
+ pluginKeys.prepend(x11key);
+ }
+ } else {
+ const QString kmskey = QStringLiteral("eglfs_kms");
+ if (pluginKeys.contains(kmskey)) {
+ pluginKeys.removeOne(kmskey);
+ pluginKeys.prepend(kmskey);
+ }
+ }
+
+ QByteArray requested;
+
+ // The environment variable can override everything.
+ if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_INTEGRATION")) {
+ requested = qgetenv("QT_QPA_EGLFS_INTEGRATION");
+ } else {
+ // Device-specific makespecs may define a preferred plugin.
+#ifdef EGLFS_PREFERRED_PLUGIN
+#define DEFAULT_PLUGIN EGLFS_PREFERRED_PLUGIN
+#define STR(s) #s
+#define STRQ(s) STR(s)
+ requested = STRQ(DEFAULT_PLUGIN);
+#endif
+ }
+
+ // Treat "none" as special. There has to be a way to indicate
+ // that plugins must be ignored when the device is known to be
+ // functional with the default, non-specialized integration.
+ if (requested != QByteArrayLiteral("none")) {
+ if (!requested.isEmpty()) {
+ QString reqStr = QString::fromLocal8Bit(requested);
+ pluginKeys.removeOne(reqStr);
+ pluginKeys.prepend(reqStr);
+ }
+ qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys (sorted):" << pluginKeys;
+ while (!m_integration && !pluginKeys.isEmpty()) {
+ QString key = pluginKeys.takeFirst();
+ qCDebug(qLcEglDevDebug) << "Trying to load device EGL integration" << key;
+ m_integration = QEGLDeviceIntegrationFactory::create(key);
+ }
+ }
+ }
+
+ if (!m_integration) {
+ // 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;
+ }
+}
+
+QEGLDeviceIntegration *qt_egl_device_integration()
+{
+ return deviceIntegration()->integration();
+}
+
+#endif // EGLFS_PLATFORM_HOOKS
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h
index c51af17a56..1fcfc5bd08 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.h
+++ b/src/plugins/platforms/eglfs/qeglfshooks.h
@@ -34,56 +34,17 @@
#ifndef QEGLFSHOOKS_H
#define QEGLFSHOOKS_H
-#include <qpa/qplatformintegration.h>
-#include <qpa/qplatformscreen.h>
-#include <QtGui/QSurfaceFormat>
-#include <QtGui/QImage>
-#include <EGL/egl.h>
+#include "qeglfsdeviceintegration.h"
+#include "qeglfsglobal.h"
QT_BEGIN_NAMESPACE
-class QEGLPlatformCursor;
-class QEglFSScreen;
-
-class QEglFSHooks
+class QEglFSHooks : public QEGLDeviceIntegration
{
-public:
- virtual ~QEglFSHooks() {}
- virtual void platformInit();
- virtual void platformDestroy();
- virtual EGLNativeDisplayType platformDisplay() const;
- virtual QSizeF physicalScreenSize() const;
- virtual QSize screenSize() const;
- virtual QDpi logicalDpi() const;
- virtual Qt::ScreenOrientation nativeOrientation() const;
- virtual Qt::ScreenOrientation orientation() const;
- virtual int screenDepth() const;
- virtual QImage::Format screenFormat() const;
- virtual QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const;
- virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
- const QSize &size,
- const QSurfaceFormat &format);
- virtual void destroyNativeWindow(EGLNativeWindowType window);
- virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
- virtual QEGLPlatformCursor *createCursor(QPlatformScreen *screen) const;
- virtual bool filterConfig(EGLDisplay display, EGLConfig config) const;
- virtual void waitForVSync() const;
-
- virtual QByteArray fbDeviceName() const;
- virtual int framebufferIndex() const;
-
- static QEglFSHooks *hooks()
- {
-#ifdef EGLFS_PLATFORM_HOOKS
- extern QEglFSHooks *platformHooks;
- return platformHooks;
-#else
- extern QEglFSHooks stubHooks;
- return &stubHooks;
-#endif
- }
};
+Q_EGLFS_EXPORT QEGLDeviceIntegration *qt_egl_device_integration();
+
QT_END_NAMESPACE
#endif // QEGLFSHOOKS_H
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp b/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp
deleted file mode 100644
index 9e5d624d87..0000000000
--- a/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the qmake spec 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 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 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglfshooks.h"
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
-#include <QtCore/private/qcore_unix_p.h>
-#include <QtCore/QScopedPointer>
-#include <QtGui/qpa/qplatformwindow.h>
-
-#include <xf86drm.h>
-#include <xf86drmMode.h>
-#include <gbm.h>
-
-QT_USE_NAMESPACE
-
-class QEglKmsHooks : public QEglFSHooks
-{
-public:
- QEglKmsHooks();
-
- void platformInit() Q_DECL_OVERRIDE;
- void platformDestroy() Q_DECL_OVERRIDE;
- EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE;
- QSizeF physicalScreenSize() const Q_DECL_OVERRIDE;
- QSize screenSize() const Q_DECL_OVERRIDE;
- int screenDepth() const Q_DECL_OVERRIDE;
- QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const Q_DECL_OVERRIDE;
- EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
- const QSize &size,
- const QSurfaceFormat &format) Q_DECL_OVERRIDE;
- void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
- bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
- void waitForVSync() const Q_DECL_OVERRIDE;
-
- void waitForVSyncImpl();
- bool setup_kms();
-
- struct FrameBuffer {
- FrameBuffer() : fb(0) {}
- uint32_t fb;
- };
- FrameBuffer *framebufferForBufferObject(gbm_bo *bo);
-
-private:
- // device bits
- QByteArray m_device;
- int m_dri_fd;
- gbm_device *m_gbm_device;
-
- // KMS bits
- drmModeConnector *m_drm_connector;
- drmModeEncoder *m_drm_encoder;
- drmModeModeInfo m_drm_mode;
- quint32 m_drm_crtc;
-
- // Drawing bits
- gbm_surface *m_gbm_surface;
-};
-
-static QEglKmsHooks kms_hooks;
-QEglFSHooks *platformHooks = &kms_hooks;
-
-QEglKmsHooks::QEglKmsHooks()
- : m_dri_fd(-1)
- , m_gbm_device(Q_NULLPTR)
- , m_drm_connector(Q_NULLPTR)
- , m_drm_encoder(Q_NULLPTR)
- , m_drm_crtc(0)
- , m_gbm_surface(Q_NULLPTR)
-{
-
-}
-
-void QEglKmsHooks::platformInit()
-{
- QDeviceDiscovery *d = QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask);
- QStringList devices = d->scanConnectedDevices();
- d->deleteLater();
-
- if (devices.isEmpty())
- qFatal("Could not find DRM device!");
-
- m_device = devices.first().toLocal8Bit();
- m_dri_fd = qt_safe_open(m_device.constData(), O_RDWR | O_CLOEXEC);
- if (m_dri_fd == -1) {
- qErrnoWarning("Could not open DRM device %s", m_device.constData());
- qFatal("DRM device required, aborting.");
- }
-
- if (!setup_kms())
- qFatal("Could not set up KMS on device %s!", m_device.constData());
-
- m_gbm_device = gbm_create_device(m_dri_fd);
- if (!m_gbm_device)
- qFatal("Could not initialize gbm on device %s!", m_device.constData());
-}
-
-void QEglKmsHooks::platformDestroy()
-{
- gbm_device_destroy(m_gbm_device);
- m_gbm_device = Q_NULLPTR;
-
- if (qt_safe_close(m_dri_fd) == -1)
- qErrnoWarning("Could not close DRM device %s", m_device.constData());
-
- m_dri_fd = -1;
-}
-
-EGLNativeDisplayType QEglKmsHooks::platformDisplay() const
-{
- return static_cast<EGLNativeDisplayType>(m_gbm_device);
-}
-
-QSizeF QEglKmsHooks::physicalScreenSize() const
-{
- return QSizeF(m_drm_connector->mmWidth,
- m_drm_connector->mmHeight);
-}
-
-QSize QEglKmsHooks::screenSize() const
-{
- return QSize(m_drm_mode.hdisplay,
- m_drm_mode.vdisplay);
-}
-
-int QEglKmsHooks::screenDepth() const
-{
- return 32;
-}
-
-QSurfaceFormat QEglKmsHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
-{
- QSurfaceFormat format(inputFormat);
- format.setRenderableType(QSurfaceFormat::OpenGLES);
- format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
- format.setRedBufferSize(8);
- format.setGreenBufferSize(8);
- format.setBlueBufferSize(8);
- return format;
-}
-
-EGLNativeWindowType QEglKmsHooks::createNativeWindow(QPlatformWindow *platformWindow,
- const QSize &size,
- const QSurfaceFormat &format)
-{
- Q_UNUSED(platformWindow);
- Q_UNUSED(size);
- Q_UNUSED(format);
-
- if (m_gbm_surface) {
- qWarning("Only single window apps supported!");
- return 0;
- }
-
- m_gbm_surface = gbm_surface_create(m_gbm_device,
- screenSize().width(),
- screenSize().height(),
- GBM_FORMAT_XRGB8888,
- GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
- if (!m_gbm_surface)
- qFatal("Could not initialize GBM surface");
-
- return reinterpret_cast<EGLNativeWindowType>(m_gbm_surface);
-}
-
-void QEglKmsHooks::destroyNativeWindow(EGLNativeWindowType window)
-{
- gbm_surface *surface = reinterpret_cast<gbm_surface *>(window);
- if (surface == m_gbm_surface)
- m_gbm_surface = Q_NULLPTR;
- gbm_surface_destroy(surface);
-}
-
-bool QEglKmsHooks::hasCapability(QPlatformIntegration::Capability cap) const
-{
- switch (cap) {
- case QPlatformIntegration::ThreadedPixmaps:
- case QPlatformIntegration::OpenGL:
- case QPlatformIntegration::ThreadedOpenGL:
- case QPlatformIntegration::BufferQueueingOpenGL:
- return true;
- default:
- return false;
- }
-}
-
-static void gbm_bo_destroyed_callback(gbm_bo *bo, void *data)
-{
- QEglKmsHooks::FrameBuffer *fb = static_cast<QEglKmsHooks::FrameBuffer *>(data);
-
- if (fb->fb) {
- gbm_device *device = gbm_bo_get_device(bo);
- drmModeRmFB(gbm_device_get_fd(device), fb->fb);
- }
-
- delete fb;
-}
-
-QEglKmsHooks::FrameBuffer *QEglKmsHooks::framebufferForBufferObject(gbm_bo *bo)
-{
- {
- FrameBuffer *fb = static_cast<FrameBuffer *>(gbm_bo_get_user_data(bo));
- if (fb)
- return fb;
- }
-
- uint32_t width = gbm_bo_get_width(bo);
- uint32_t height = gbm_bo_get_height(bo);
- uint32_t stride = gbm_bo_get_stride(bo);
- uint32_t handle = gbm_bo_get_handle(bo).u32;
-
- QScopedPointer<FrameBuffer> fb(new FrameBuffer);
-
- int ret = drmModeAddFB(m_dri_fd, width, height, 24, 32,
- stride, handle, &fb->fb);
-
- if (ret) {
- qWarning("Failed to create KMS FB!");
- return Q_NULLPTR;
- }
-
- gbm_bo_set_user_data(bo, fb.data(), gbm_bo_destroyed_callback);
- return fb.take();
-}
-
-static void page_flip_handler(int fd,
- unsigned int sequence,
- unsigned int tv_sec,
- unsigned int tv_usec,
- void *user_data)
-{
- Q_UNUSED(fd);
- Q_UNUSED(sequence);
- Q_UNUSED(tv_sec);
- Q_UNUSED(tv_usec);
-
- // We are no longer flipping
- *static_cast<bool *>(user_data) = false;
-}
-
-void QEglKmsHooks::waitForVSync() const
-{
- const_cast<QEglKmsHooks*>(this)->waitForVSyncImpl();
-}
-
-void QEglKmsHooks::waitForVSyncImpl()
-{
- if (!m_gbm_surface) {
- qWarning("Cannot sync before platform init!");
- return;
- }
-
- if (!gbm_surface_has_free_buffers(m_gbm_surface)) {
- qWarning("Out of free GBM buffers!");
- return;
- }
-
- gbm_bo *front_buffer = gbm_surface_lock_front_buffer(m_gbm_surface);
- if (!front_buffer) {
- qWarning("Could not lock GBM surface front buffer!");
- return;
- }
-
- QEglKmsHooks::FrameBuffer *fb = framebufferForBufferObject(front_buffer);
-
- int ret = drmModeSetCrtc(m_dri_fd,
- m_drm_crtc,
- fb->fb,
- 0, 0,
- &m_drm_connector->connector_id, 1,
- &m_drm_mode);
- if (ret) {
- qErrnoWarning("Could not set DRM mode!");
- return;
- }
-
- bool flipping = true;
- ret = drmModePageFlip(m_dri_fd,
- m_drm_encoder->crtc_id,
- fb->fb,
- DRM_MODE_PAGE_FLIP_EVENT,
- &flipping);
- if (ret) {
- qErrnoWarning("Could not queue DRM page flip!");
- return;
- }
-
- drmEventContext drmEvent = {
- DRM_EVENT_CONTEXT_VERSION,
- Q_NULLPTR, // vblank handler
- page_flip_handler // page flip handler
- };
-
- fd_set fds;
- FD_ZERO(&fds);
- FD_SET(m_dri_fd, &fds);
-
- time_t start, cur;
- time(&start);
-
- while (flipping && (time(&cur) < start + 1)) {
- timespec v;
- memset(&v, 0, sizeof(v));
- v.tv_sec = start + 1 - cur;
-
- ret = qt_safe_select(m_dri_fd + 1, &fds, Q_NULLPTR, Q_NULLPTR, &v);
-
- if (ret == 0) {
- // timeout
- break;
- } else if (ret == -1) {
- qErrnoWarning("Error while selecting on DRM fd");
- break;
- } else if (drmHandleEvent(m_dri_fd, &drmEvent)) {
- qWarning("Could not handle DRM event!");
- }
- }
-
- gbm_surface_release_buffer(m_gbm_surface, front_buffer);
-}
-
-bool QEglKmsHooks::setup_kms()
-{
- drmModeRes *resources;
- drmModeConnector *connector;
- drmModeEncoder *encoder;
- quint32 crtc = 0;
- int i;
-
- resources = drmModeGetResources(m_dri_fd);
- if (!resources) {
- qWarning("drmModeGetResources failed");
- return false;
- }
-
- for (i = 0; i < resources->count_connectors; i++) {
- connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]);
- if (connector == NULL)
- continue;
-
- if (connector->connection == DRM_MODE_CONNECTED &&
- connector->count_modes > 0) {
- break;
- }
-
- drmModeFreeConnector(connector);
- }
-
- if (i == resources->count_connectors) {
- qWarning("No currently active connector found.");
- return false;
- }
-
- for (i = 0; i < resources->count_encoders; i++) {
- encoder = drmModeGetEncoder(m_dri_fd, resources->encoders[i]);
-
- if (encoder == NULL)
- continue;
-
- if (encoder->encoder_id == connector->encoder_id)
- break;
-
- drmModeFreeEncoder(encoder);
- }
-
- for (int j = 0; j < resources->count_crtcs; j++) {
- if ((encoder->possible_crtcs & (1 << j))) {
- crtc = resources->crtcs[j];
- break;
- }
- }
-
- if (crtc == 0)
- qFatal("No suitable CRTC available");
-
- m_drm_connector = connector;
- m_drm_encoder = encoder;
- m_drm_mode = connector->modes[0];
- m_drm_crtc = crtc;
-
- drmModeFreeResources(resources);
-
- return true;
-}
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
deleted file mode 100644
index 120c603125..0000000000
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the qmake spec 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtCore/QRegularExpression>
-#include "qeglfshooks.h"
-
-#if defined(Q_OS_LINUX)
-#include <fcntl.h>
-#include <unistd.h>
-#include <linux/fb.h>
-#include <sys/ioctl.h>
-#endif
-
-#include <private/qcore_unix_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// file descriptor for the frame buffer
-// this is a global static to keep the QEglFSHooks interface as clean as possible
-static int framebuffer = -1;
-
-QByteArray QEglFSHooks::fbDeviceName() const
-{
- QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB");
- if (fbDev.isEmpty())
- fbDev = QByteArrayLiteral("/dev/fb0");
-
- return fbDev;
-}
-
-int QEglFSHooks::framebufferIndex() const
-{
- int fbIndex = 0;
-#ifndef QT_NO_REGULAREXPRESSION
- QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
- QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName());
- if (match.hasMatch())
- fbIndex = match.captured(1).toInt();
-
-#endif
- return fbIndex;
-}
-
-void QEglFSHooks::platformInit()
-{
- QByteArray fbDev = fbDeviceName();
-
- framebuffer = qt_safe_open(fbDev, O_RDONLY);
-
- if (framebuffer == -1) {
- qWarning("EGLFS: Failed to open %s", qPrintable(fbDev));
- qFatal("EGLFS: Can't continue without a display");
- }
-}
-
-void QEglFSHooks::platformDestroy()
-{
- if (framebuffer != -1)
- close(framebuffer);
-}
-
-EGLNativeDisplayType QEglFSHooks::platformDisplay() const
-{
- return EGL_DEFAULT_DISPLAY;
-}
-
-QSizeF QEglFSHooks::physicalScreenSize() const
-{
- return q_physicalScreenSizeFromFb(framebuffer, screenSize());
-}
-
-QSize QEglFSHooks::screenSize() const
-{
- return q_screenSizeFromFb(framebuffer);
-}
-
-QDpi QEglFSHooks::logicalDpi() const
-{
- QSizeF ps = physicalScreenSize();
- QSize s = screenSize();
-
- return QDpi(25.4 * s.width() / ps.width(),
- 25.4 * s.height() / ps.height());
-}
-
-Qt::ScreenOrientation QEglFSHooks::nativeOrientation() const
-{
- return Qt::PrimaryOrientation;
-}
-
-Qt::ScreenOrientation QEglFSHooks::orientation() const
-{
- return Qt::PrimaryOrientation;
-}
-
-int QEglFSHooks::screenDepth() const
-{
- return q_screenDepthFromFb(framebuffer);
-}
-
-QImage::Format QEglFSHooks::screenFormat() const
-{
- return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
-}
-
-QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
-{
- QSurfaceFormat format = inputFormat;
-
- static const bool force888 = qgetenv("QT_QPA_EGLFS_FORCE888").toInt();
- if (force888) {
- format.setRedBufferSize(8);
- format.setGreenBufferSize(8);
- format.setBlueBufferSize(8);
- }
-
- return format;
-}
-
-bool QEglFSHooks::filterConfig(EGLDisplay, EGLConfig) const
-{
- return true;
-}
-
-EGLNativeWindowType QEglFSHooks::createNativeWindow(QPlatformWindow *platformWindow,
- const QSize &size,
- const QSurfaceFormat &format)
-{
- Q_UNUSED(platformWindow);
- Q_UNUSED(size);
- Q_UNUSED(format);
- return 0;
-}
-
-void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window)
-{
- Q_UNUSED(window);
-}
-
-bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const
-{
- Q_UNUSED(cap);
- return false;
-}
-
-QEGLPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const
-{
- return new QEGLPlatformCursor(screen);
-}
-
-void QEglFSHooks::waitForVSync() const
-{
-#if defined(FBIO_WAITFORVSYNC)
- static const bool forceSync = qgetenv("QT_QPA_EGLFS_FORCEVSYNC").toInt();
- if (forceSync && framebuffer != -1) {
- int arg = 0;
- if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1)
- qWarning("Could not wait for vsync.");
- }
-#endif
-}
-
-#ifndef EGLFS_PLATFORM_HOOKS
-QEglFSHooks stubHooks;
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index fbdd1d4c4d..a13a334433 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -45,6 +45,7 @@
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include "qeglfscontext.h"
+#include "qeglfsoffscreenwindow.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
@@ -62,43 +63,55 @@ QT_BEGIN_NAMESPACE
QEglFSIntegration::QEglFSIntegration()
{
- mDisableInputHandlers = qgetenv("QT_QPA_EGLFS_DISABLE_INPUT").toInt();
+ mDisableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT");
initResources();
}
-QEglFSIntegration::~QEglFSIntegration()
-{
- QEglFSHooks::hooks()->platformDestroy();
-}
-
bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
// We assume that devices will have more and not less capabilities
- if (QEglFSHooks::hooks() && QEglFSHooks::hooks()->hasCapability(cap))
+ if (qt_egl_device_integration()->hasCapability(cap))
return true;
return QEGLPlatformIntegration::hasCapability(cap);
}
+void QEglFSIntegration::addScreen(QPlatformScreen *screen)
+{
+ screenAdded(screen);
+}
+
+void QEglFSIntegration::removeScreen(QPlatformScreen *screen)
+{
+ destroyScreen(screen);
+}
+
void QEglFSIntegration::initialize()
{
- QEglFSHooks::hooks()->platformInit();
+ qt_egl_device_integration()->platformInit();
QEGLPlatformIntegration::initialize();
if (!mDisableInputHandlers)
createInputHandlers();
+
+ if (qt_egl_device_integration()->usesDefaultScreen())
+ addScreen(new QEglFSScreen(display()));
+ else
+ qt_egl_device_integration()->screenInit();
}
-EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
+void QEglFSIntegration::destroy()
{
- return QEglFSHooks::hooks()->platformDisplay();
+ qt_egl_device_integration()->screenDestroy();
+ QEGLPlatformIntegration::destroy();
+ qt_egl_device_integration()->platformDestroy();
}
-QEGLPlatformScreen *QEglFSIntegration::createScreen() const
+EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
{
- return new QEglFSScreen(display());
+ return qt_egl_device_integration()->platformDisplay();
}
QEGLPlatformWindow *QEglFSIntegration::createWindow(QWindow *window) const
@@ -112,12 +125,12 @@ QEGLPlatformContext *QEglFSIntegration::createContext(const QSurfaceFormat &form
QVariant *nativeHandle) const
{
QEglFSContext *ctx;
- QSurfaceFormat adjustedFormat = QEglFSHooks::hooks()->surfaceFormatFor(format);
+ QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(format);
if (!nativeHandle || nativeHandle->isNull()) {
EGLConfig config = QEglFSIntegration::chooseConfig(display, adjustedFormat);
- ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant());
+ ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant());
} else {
- ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle);
+ ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle);
}
*nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), display));
return ctx;
@@ -127,41 +140,28 @@ QPlatformOffscreenSurface *QEglFSIntegration::createOffscreenSurface(EGLDisplay
const QSurfaceFormat &format,
QOffscreenSurface *surface) const
{
- return new QEGLPbuffer(display, QEglFSHooks::hooks()->surfaceFormatFor(format), surface);
-}
+ QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(format);
+ if (qt_egl_device_integration()->supportsPBuffers())
+ return new QEGLPbuffer(display, fmt, surface);
+ else
+ return new QEglFSOffscreenWindow(display, fmt, surface);
-QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
-{
- switch (hint)
- {
- case QPlatformIntegration::ShowIsFullScreen:
- return screen()->compositingWindow() == 0;
- default:
- return QPlatformIntegration::styleHint(hint);
- }
+ // Never return null. Multiple QWindows are not supported by this plugin.
}
EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
{
class Chooser : public QEglConfigChooser {
public:
- Chooser(EGLDisplay display, QEglFSHooks *hooks)
- : QEglConfigChooser(display)
- , m_hooks(hooks)
- {
- }
-
- protected:
- bool filterConfig(EGLConfig config) const
- {
- return m_hooks->filterConfig(display(), config) && QEglConfigChooser::filterConfig(config);
+ Chooser(EGLDisplay display)
+ : QEglConfigChooser(display) { }
+ bool filterConfig(EGLConfig config) const Q_DECL_OVERRIDE {
+ return qt_egl_device_integration()->filterConfig(display(), config)
+ && QEglConfigChooser::filterConfig(config);
}
-
- private:
- QEglFSHooks *m_hooks;
};
- Chooser chooser(display, QEglFSHooks::hooks());
+ Chooser chooser(display);
chooser.setSurfaceFormat(format);
return chooser.chooseConfig();
}
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
index d612a270f2..2074d80e56 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -37,24 +37,26 @@
#include <QtPlatformSupport/private/qeglplatformintegration_p.h>
#include <qpa/qplatformscreen.h>
#include <EGL/egl.h>
+#include "qeglfsglobal.h"
QT_BEGIN_NAMESPACE
-class QEglFSIntegration : public QEGLPlatformIntegration
+class Q_EGLFS_EXPORT QEglFSIntegration : public QEGLPlatformIntegration
{
public:
QEglFSIntegration();
- ~QEglFSIntegration();
+
+ void addScreen(QPlatformScreen *screen);
+ void removeScreen(QPlatformScreen *screen);
void initialize() Q_DECL_OVERRIDE;
+ void destroy() Q_DECL_OVERRIDE;
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
- QVariant styleHint(QPlatformIntegration::StyleHint hint) const Q_DECL_OVERRIDE;
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
protected:
- QEGLPlatformScreen *createScreen() const Q_DECL_OVERRIDE;
QEGLPlatformWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
QEGLPlatformContext *createContext(const QSurfaceFormat &format,
QPlatformOpenGLContext *shareContext,
diff --git a/src/plugins/platforms/eglfs/main.cpp b/src/plugins/platforms/eglfs/qeglfsmain.cpp
index be91fbf3c3..2c5e79534d 100644
--- a/src/plugins/platforms/eglfs/main.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsmain.cpp
@@ -41,7 +41,7 @@ class QEglFSIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "eglfs.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&);
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QPlatformIntegration* QEglFSIntegrationPlugin::create(const QString& system, const QStringList& paramList)
@@ -55,4 +55,4 @@ QPlatformIntegration* QEglFSIntegrationPlugin::create(const QString& system, con
QT_END_NAMESPACE
-#include "main.moc"
+#include "qeglfsmain.moc"
diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
new file mode 100644
index 0000000000..7bf53ef351
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsoffscreenwindow.h"
+#include "qeglfshooks.h"
+#include <QtGui/QOffscreenSurface>
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ In some cases pbuffers are not available. Triggering QtGui's built-in
+ fallback for a hidden QWindow is not suitable for eglfs since this would be
+ treated as an attempt to create multiple top-level, native windows.
+
+ Therefore this class is provided as an alternative to QEGLPbuffer.
+
+ This class requires the hooks to implement createNativeOffscreenWindow().
+*/
+
+QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface)
+ : QPlatformOffscreenSurface(offscreenSurface)
+ , m_format(format)
+ , m_display(display)
+ , m_surface(EGL_NO_SURFACE)
+ , m_window(0)
+{
+ m_window = qt_egl_device_integration()->createNativeOffscreenWindow(format);
+ if (!m_window) {
+ qWarning("QEglFSOffscreenWindow: Failed to create native window");
+ return;
+ }
+ EGLConfig config = q_configFromGLFormat(m_display, m_format);
+ m_surface = eglCreateWindowSurface(m_display, config, m_window, 0);
+ if (m_surface != EGL_NO_SURFACE)
+ m_format = q_glFormatFromConfig(m_display, config);
+}
+
+QEglFSOffscreenWindow::~QEglFSOffscreenWindow()
+{
+ if (m_surface != EGL_NO_SURFACE)
+ eglDestroySurface(m_display, m_surface);
+ if (m_window)
+ qt_egl_device_integration()->destroyNativeWindow(m_window);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
new file mode 100644
index 0000000000..128ff56968
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSOFFSCREENWINDOW_H
+#define QEGLFSOFFSCREENWINDOW_H
+
+#include <EGL/egl.h>
+#include <qpa/qplatformoffscreensurface.h>
+#include "qeglfsglobal.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_EGLFS_EXPORT QEglFSOffscreenWindow : public QPlatformOffscreenSurface
+{
+public:
+ QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface);
+ ~QEglFSOffscreenWindow();
+
+ QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; }
+ bool isValid() const Q_DECL_OVERRIDE { return m_surface != EGL_NO_SURFACE; }
+
+private:
+ QSurfaceFormat m_format;
+ EGLDisplay m_display;
+ EGLSurface m_surface;
+ EGLNativeWindowType m_window;
+};
+
+QT_END_NAMESPACE
+
+#endif // QEGLFSOFFSCREENWINDOW_H
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
index bc93fe28e7..cb726a016b 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
#include <QtCore/qtextstream.h>
-#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
+#include <QtGui/qpa/qplatformcursor.h>
#include "qeglfsscreen.h"
#include "qeglfswindow.h"
@@ -43,11 +43,9 @@ QT_BEGIN_NAMESPACE
QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
: QEGLPlatformScreen(dpy),
m_surface(EGL_NO_SURFACE),
- m_cursor(0),
- m_rootWindow(0),
- m_rootContext(0)
+ m_cursor(0)
{
- m_cursor = QEglFSHooks::hooks()->createCursor(this);
+ m_cursor = qt_egl_device_integration()->createCursor(this);
}
QEglFSScreen::~QEglFSScreen()
@@ -57,37 +55,37 @@ QEglFSScreen::~QEglFSScreen()
QRect QEglFSScreen::geometry() const
{
- return QRect(QPoint(0, 0), QEglFSHooks::hooks()->screenSize());
+ return QRect(QPoint(0, 0), qt_egl_device_integration()->screenSize());
}
int QEglFSScreen::depth() const
{
- return QEglFSHooks::hooks()->screenDepth();
+ return qt_egl_device_integration()->screenDepth();
}
QImage::Format QEglFSScreen::format() const
{
- return QEglFSHooks::hooks()->screenFormat();
+ return qt_egl_device_integration()->screenFormat();
}
QSizeF QEglFSScreen::physicalSize() const
{
- return QEglFSHooks::hooks()->physicalScreenSize();
+ return qt_egl_device_integration()->physicalScreenSize();
}
QDpi QEglFSScreen::logicalDpi() const
{
- return QEglFSHooks::hooks()->logicalDpi();
+ return qt_egl_device_integration()->logicalDpi();
}
Qt::ScreenOrientation QEglFSScreen::nativeOrientation() const
{
- return QEglFSHooks::hooks()->nativeOrientation();
+ return qt_egl_device_integration()->nativeOrientation();
}
Qt::ScreenOrientation QEglFSScreen::orientation() const
{
- return QEglFSHooks::hooks()->orientation();
+ return qt_egl_device_integration()->orientation();
}
QPlatformCursor *QEglFSScreen::cursor() const
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
index 132646d7a6..59f55d33fb 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -34,19 +34,16 @@
#ifndef QEGLFSSCREEN_H
#define QEGLFSSCREEN_H
+#include "qeglfsglobal.h"
#include <QtPlatformSupport/private/qeglplatformscreen_p.h>
-
-#include <QtCore/QTextStream>
-
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
-class QEGLPlatformCursor;
class QEglFSWindow;
class QOpenGLContext;
-class QEglFSScreen : public QEGLPlatformScreen
+class Q_EGLFS_EXPORT QEglFSScreen : public QEGLPlatformScreen
{
public:
QEglFSScreen(EGLDisplay display);
@@ -65,12 +62,6 @@ public:
EGLSurface primarySurface() const { return m_surface; }
- QEGLPlatformWindow *compositingWindow() Q_DECL_OVERRIDE { return m_rootWindow; }
- QOpenGLContext *compositingContext() Q_DECL_OVERRIDE { return m_rootContext; }
-
- void setRootWindow(QEGLPlatformWindow *window) { m_rootWindow = window; }
- void setRootContext(QOpenGLContext *context) { m_rootContext = context; }
-
protected:
void setPrimarySurface(EGLSurface surface);
@@ -78,9 +69,7 @@ private:
friend class QEglFSWindow;
EGLSurface m_surface;
- QEGLPlatformCursor *m_cursor;
- QEGLPlatformWindow *m_rootWindow;
- QOpenGLContext *m_rootContext;
+ QPlatformCursor *m_cursor;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index 39a3ef94e9..8a61bcf30d 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -75,9 +75,10 @@ void QEglFSWindow::create()
// raster windows will not have their own native window, surface and context. Instead,
// they will be composited onto the root window's surface.
QEglFSScreen *screen = this->screen();
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
if (screen->primarySurface() != EGL_NO_SURFACE) {
- if (isRaster() && screen->compositingWindow()) {
- m_format = screen->compositingWindow()->format();
+ if (isRaster() && compositor->targetWindow()) {
+ m_format = compositor->targetWindow()->format();
return;
}
@@ -95,7 +96,7 @@ void QEglFSWindow::create()
QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size()));
EGLDisplay display = static_cast<QEglFSScreen *>(screen)->display();
- QSurfaceFormat platformFormat = QEglFSHooks::hooks()->surfaceFormatFor(window()->requestedFormat());
+ QSurfaceFormat platformFormat = qt_egl_device_integration()->surfaceFormatFor(window()->requestedFormat());
m_config = QEglFSIntegration::chooseConfig(display, platformFormat);
m_format = q_glFormatFromConfig(display, m_config, platformFormat);
@@ -109,8 +110,7 @@ void QEglFSWindow::create()
context->setScreen(window()->screen());
if (!context->create())
qFatal("EGLFS: Failed to create compositing context");
- screen->setRootContext(context);
- screen->setRootWindow(this);
+ compositor->setTarget(context, window());
}
}
@@ -118,7 +118,7 @@ void QEglFSWindow::destroy()
{
QEglFSScreen *screen = this->screen();
if (m_flags.testFlag(HasNativeWindow)) {
- QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->cursor());
+ QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(screen->cursor());
if (cursor)
cursor->resetResources();
@@ -129,7 +129,7 @@ void QEglFSWindow::destroy()
}
m_flags = 0;
- screen->removeWindow(this);
+ QOpenGLCompositor::instance()->removeWindow(this);
}
// The virtual functions resetSurface and invalidateSurface may get overridden
@@ -143,14 +143,15 @@ void QEglFSWindow::invalidateSurface()
eglDestroySurface(display, m_surface);
m_surface = EGL_NO_SURFACE;
}
- QEglFSHooks::hooks()->destroyNativeWindow(m_window);
+ qt_egl_device_integration()->destroyNativeWindow(m_window);
m_window = 0;
}
void QEglFSWindow::resetSurface()
{
- EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display();
- m_window = QEglFSHooks::hooks()->createNativeWindow(this, QEglFSHooks::hooks()->screenSize(), m_format);
+ QEglFSScreen *nativeScreen = static_cast<QEglFSScreen *>(screen());
+ EGLDisplay display = nativeScreen->display();
+ m_window = qt_egl_device_integration()->createNativeWindow(this, nativeScreen->geometry().size(), m_format);
m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
if (m_surface == EGL_NO_SURFACE) {
EGLint error = eglGetError();
@@ -161,17 +162,18 @@ void QEglFSWindow::resetSurface()
void QEglFSWindow::setVisible(bool visible)
{
- QList<QEGLPlatformWindow *> windows = screen()->windows();
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ QList<QOpenGLCompositorWindow *> windows = compositor->windows();
QWindow *wnd = window();
if (wnd->type() != Qt::Desktop) {
if (visible) {
- screen()->addWindow(this);
+ compositor->addWindow(this);
} else {
- screen()->removeWindow(this);
- windows = screen()->windows();
+ compositor->removeWindow(this);
+ windows = compositor->windows();
if (windows.size())
- windows.last()->requestActivateWindow();
+ windows.last()->sourceWindow()->requestActivate();
}
}
@@ -211,7 +213,7 @@ QRect QEglFSWindow::geometry() const
void QEglFSWindow::requestActivateWindow()
{
if (window()->type() != Qt::Desktop)
- screen()->moveToTop(this);
+ QOpenGLCompositor::instance()->moveToTop(this);
QWindow *wnd = window();
QWindowSystemInterface::handleWindowActivated(wnd);
@@ -222,20 +224,21 @@ void QEglFSWindow::raise()
{
QWindow *wnd = window();
if (wnd->type() != Qt::Desktop) {
- screen()->moveToTop(this);
+ QOpenGLCompositor::instance()->moveToTop(this);
QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size()));
}
}
void QEglFSWindow::lower()
{
- QList<QEGLPlatformWindow *> windows = screen()->windows();
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ QList<QOpenGLCompositorWindow *> windows = compositor->windows();
if (window()->type() != Qt::Desktop && windows.count() > 1) {
int idx = windows.indexOf(this);
if (idx > 0) {
- screen()->changeWindowIndex(this, idx - 1);
- QWindowSystemInterface::handleExposeEvent(windows.last()->window(),
- QRect(QPoint(0, 0), windows.last()->geometry().size()));
+ compositor->changeWindowIndex(this, idx - 1);
+ QWindowSystemInterface::handleExposeEvent(windows.last()->sourceWindow(),
+ QRect(QPoint(0, 0), windows.last()->sourceWindow()->geometry().size()));
}
}
}
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index 5dfa35197f..a3e3722b5a 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -36,12 +36,12 @@
#include "qeglfsintegration.h"
#include "qeglfsscreen.h"
-
+#include "qeglfsglobal.h"
#include <QtPlatformSupport/private/qeglplatformwindow_p.h>
QT_BEGIN_NAMESPACE
-class QEglFSWindow : public QEGLPlatformWindow
+class Q_EGLFS_EXPORT QEglFSWindow : public QEGLPlatformWindow
{
public:
QEglFSWindow(QWindow *w);
@@ -70,7 +70,7 @@ public:
bool hasNativeWindow() const { return m_flags.testFlag(HasNativeWindow); }
- virtual void invalidateSurface();
+ virtual void invalidateSurface() Q_DECL_OVERRIDE;
virtual void resetSurface();
protected:
diff --git a/src/plugins/platforms/ios/qiosbackingstore.h b/src/plugins/platforms/ios/qiosbackingstore.h
index eff7455247..555dfa2a5d 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.h
+++ b/src/plugins/platforms/ios/qiosbackingstore.h
@@ -38,6 +38,8 @@
QT_BEGIN_NAMESPACE
+class QOpenGLPaintDevice;
+
class QIOSBackingStore : public QPlatformBackingStore
{
public:
@@ -53,7 +55,7 @@ public:
private:
QOpenGLContext *m_context;
- QPaintDevice *m_device;
+ QOpenGLPaintDevice *m_device;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm
index 5ea5fbd8d1..7f622cf7c1 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.mm
+++ b/src/plugins/platforms/ios/qiosbackingstore.mm
@@ -73,19 +73,17 @@ QIOSBackingStore::~QIOSBackingStore()
void QIOSBackingStore::beginPaint(const QRegion &)
{
m_context->makeCurrent(window());
-
- QIOSWindow *iosWindow = static_cast<QIOSWindow *>(window()->handle());
- static_cast<QOpenGLPaintDevice *>(paintDevice())->setSize(window()->size() * iosWindow->devicePixelRatio());
}
QPaintDevice *QIOSBackingStore::paintDevice()
{
- if (!m_device) {
- QIOSWindow *iosWindow = static_cast<QIOSWindow *>(window()->handle());
- QOpenGLPaintDevice *openGLDevice = new QOpenGLPaintDevice(window()->size() * iosWindow->devicePixelRatio());
- openGLDevice->setDevicePixelRatio(iosWindow->devicePixelRatio());
- m_device = openGLDevice;
- }
+ if (!m_device)
+ m_device = new QOpenGLPaintDevice;
+
+ // Keep paint device size and device pixel ratio in sync with window
+ qreal devicePixelRatio = window()->devicePixelRatio();
+ m_device->setSize(window()->size() * devicePixelRatio);
+ m_device->setDevicePixelRatio(devicePixelRatio);
return m_device;
}
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index 3ecd0ca61f..be55a9e027 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -95,7 +95,7 @@ Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientat
break;
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationFaceDown:
- // FIXME: Use cached device orientation, or fall back to interface orientation
+ qWarning() << "Falling back to Qt::PortraitOrientation for UIDeviceOrientationFaceUp/UIDeviceOrientationFaceDown";
qtOrientation = Qt::PortraitOrientation;
break;
default:
diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h
index 85338b1c4d..d3474597e1 100644
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -76,7 +76,9 @@ public:
QTouchDevice *touchDevice();
QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE;
+ // Called from Objective-C class QIOSScreenTracker, which can't be friended
void addScreen(QPlatformScreen *screen) { screenAdded(screen); }
+ void destroyScreen(QPlatformScreen *screen) { QPlatformIntegration::destroyScreen(screen); }
static QIOSIntegration *instance();
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 461f160892..ff4b753cc1 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -120,7 +120,7 @@ QIOSIntegration::~QIOSIntegration()
m_inputContext = 0;
foreach (QScreen *screen, QGuiApplication::screens())
- delete screen->handle();
+ destroyScreen(screen->handle());
delete m_platformServices;
m_platformServices = 0;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 712bf0098b..830b42a3f1 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -92,7 +92,8 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
QIOSScreen *screen = qtPlatformScreenFor([notification object]);
Q_ASSERT_X(screen, Q_FUNC_INFO, "Screen disconnected that we didn't know about");
- delete screen;
+ QIOSIntegration *integration = QIOSIntegration::instance();
+ integration->destroyScreen(screen);
}
+ (void)screenModeChanged:(NSNotification*)notification
@@ -142,18 +143,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
- (void) orientationChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
-
- UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
- switch (deviceOrientation) {
- case UIDeviceOrientationFaceUp:
- case UIDeviceOrientationFaceDown:
- // We ignore these events, as iOS will send events with the 'regular'
- // orientations alongside these two orientations.
- return;
- default:
- Qt::ScreenOrientation screenOrientation = toQtScreenOrientation(deviceOrientation);
- QWindowSystemInterface::handleScreenOrientationChange(m_screen->screen(), screenOrientation);
- }
+ m_screen->updateProperties();
}
@end
@@ -218,12 +208,6 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
// Create a window and associated view-controller that we can use
m_uiWindow = [[UIWindow alloc] initWithFrame:[m_uiScreen bounds]];
m_uiWindow.rootViewController = [[[QIOSViewController alloc] initWithQIOSScreen:this] autorelease];
-
- // FIXME: Only do once windows are added to the screen, and for any screen
- if (screen == [UIScreen mainScreen]) {
- m_uiWindow.screen = m_uiScreen;
- m_uiWindow.hidden = NO;
- }
}
updateProperties();
@@ -240,33 +224,59 @@ void QIOSScreen::updateProperties()
QRect previousGeometry = m_geometry;
QRect previousAvailableGeometry = m_availableGeometry;
- UIView *rootView = m_uiWindow.rootViewController.view;
+ m_geometry = fromCGRect(m_uiScreen.bounds).toRect();
+ m_availableGeometry = fromCGRect(m_uiScreen.applicationFrame).toRect();
+
+ if (m_uiScreen == [UIScreen mainScreen]) {
+ Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
- m_geometry = fromCGRect([rootView convertRect:m_uiScreen.bounds fromView:m_uiWindow]).toRect();
- m_availableGeometry = fromCGRect([rootView convertRect:m_uiScreen.applicationFrame fromView:m_uiWindow]).toRect();
+ if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) {
+ // On iOS < 8.0 the UIScreen geometry is always in portait, and the system applies
+ // the screen rotation to the root view-controller's view instead of directly to the
+ // screen, like iOS 8 and above does.
+ m_geometry = mapBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry);
+ m_availableGeometry = transformBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry).mapRect(m_availableGeometry);
+ }
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 && ![m_uiWindow.rootViewController shouldAutorotate]) {
- // Setting the statusbar orientation (content orientation) on iOS8+ will result in the UIScreen
- // updating its geometry and available geometry, which in the case of content orientation is not
- // what we want. We want to reflect the screen geometry based on the locked orientation, and
- // adjust the available geometry based on the repositioned status bar for the current status
- // bar orientation.
+ QIOSViewController *qtViewController = [m_uiWindow.rootViewController isKindOfClass:[QIOSViewController class]] ?
+ static_cast<QIOSViewController *>(m_uiWindow.rootViewController) : nil;
- Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(rootView.qtViewController.lockedOrientation));
- Qt::ScreenOrientation contenOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
+ if (qtViewController.lockedOrientation) {
+ // Setting the statusbar orientation (content orientation) on will affect the screen geometry,
+ // which is not what we want. We want to reflect the screen geometry based on the locked orientation,
+ // and adjust the available geometry based on the repositioned status bar for the current status
+ // bar orientation.
- QTransform transform = screen()->transformBetween(lockedOrientation, contenOrientation, m_geometry).inverted();
+ Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(qtViewController.lockedOrientation));
+ QTransform transform = transformBetween(lockedOrientation, statusBarOrientation, m_geometry).inverted();
- m_geometry = transform.mapRect(m_geometry);
- m_availableGeometry = transform.mapRect(m_availableGeometry);
+ m_geometry = transform.mapRect(m_geometry);
+ m_availableGeometry = transform.mapRect(m_availableGeometry);
+ }
}
- if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) {
+ if (m_geometry != previousGeometry) {
const qreal millimetersPerInch = 25.4;
m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch;
+ }
+ // At construction time, we don't yet have an associated QScreen, but we still want
+ // to compute the properties above so they are ready for when the QScreen attaches.
+ // Also, at destruction time the QScreen has already been torn down, so notifying
+ // Qt about changes to the screen will cause asserts in the event delivery system.
+ if (!screen())
+ return;
+
+ if (screen()->orientation() != orientation())
+ QWindowSystemInterface::handleScreenOrientationChange(screen(), orientation());
+
+ // Note: The screen orientation change and the geometry changes are not atomic, so when
+ // the former is emitted, the latter has not been reported and reflected in the QScreen
+ // API yet. But conceptually it makes sense that the orientation update happens first,
+ // and the geometry updates caused by auto-rotation happen after that.
+
+ if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry)
QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_availableGeometry);
- }
}
QRect QIOSScreen::geometry() const
@@ -320,7 +330,30 @@ Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
Qt::ScreenOrientation QIOSScreen::orientation() const
{
- return toQtScreenOrientation([UIDevice currentDevice].orientation);
+ // Auxiliary screens are always the same orientation as their primary orientation
+ if (m_uiScreen != [UIScreen mainScreen])
+ return Qt::PrimaryOrientation;
+
+ UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
+
+ // At startup, iOS will report an unknown orientation for the device, even
+ // if we've asked it to begin generating device orientation notifications.
+ // In this case we fall back to the status bar orientation, which reflects
+ // the orientation the application was started up in (which may not match
+ // the physical orientation of the device, but typically does unless the
+ // application has been locked to a subset of the available orientations).
+ if (deviceOrientation == UIDeviceOrientationUnknown)
+ deviceOrientation = UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation);
+
+ // If the device reports face up or face down orientations, we can't map
+ // them to Qt orientations, so we pretend we're in the same orientation
+ // as before.
+ if (deviceOrientation == UIDeviceOrientationFaceUp || deviceOrientation == UIDeviceOrientationFaceDown) {
+ Q_ASSERT(screen());
+ return screen()->orientation();
+ }
+
+ return toQtScreenOrientation(deviceOrientation);
}
void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
@@ -330,6 +363,7 @@ void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
m_orientationListener = 0;
} else if (!m_orientationListener) {
m_orientationListener = [[QIOSOrientationListener alloc] initWithQIOSScreen:this];
+ updateProperties();
}
}
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h
index df7ce0ff4a..9df983a665 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.h
+++ b/src/plugins/platforms/ios/qiosviewcontroller.h
@@ -43,7 +43,6 @@ class QIOSScreen;
@property (nonatomic, assign) UIInterfaceOrientation lockedOrientation;
// UIViewController
-@property (nonatomic, assign) BOOL shouldAutorotate;
@property (nonatomic, assign) BOOL prefersStatusBarHidden;
@property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation;
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 01bc84ae68..1e1ac4ba18 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -56,11 +56,55 @@
// -------------------------------------------------------------------------
+@interface QIOSViewController () {
+ @public
+ QPointer<QIOSScreen> m_screen;
+ BOOL m_updatingProperties;
+ QMetaObject::Connection m_focusWindowChangeConnection;
+}
+@property (nonatomic, assign) BOOL changingOrientation;
+@end
+
+// -------------------------------------------------------------------------
+
@interface QIOSDesktopManagerView : UIView
@end
@implementation QIOSDesktopManagerView
+- (void)didAddSubview:(UIView *)subview
+{
+ Q_UNUSED(subview);
+
+ 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.
+ UIWindow *uiWindow = screen->uiWindow();
+
+ if (uiWindow.hidden) {
+ // Associate UIWindow to screen and show it the first time a QWindow
+ // is mapped to the screen. For external screens this means disabling
+ // mirroring mode and presenting alternate content on the screen.
+ uiWindow.screen = screen->uiScreen();
+ uiWindow.hidden = NO;
+ }
+}
+
+- (void)willRemoveSubview:(UIView *)subview
+{
+ Q_UNUSED(subview);
+
+ Q_ASSERT(self.window);
+ UIWindow *uiWindow = self.window;
+
+ if (uiWindow.screen != [UIScreen mainScreen] && self.subviews.count == 1) {
+ // Removing the last view of an external screen, go back to mirror mode
+ uiWindow.screen = nil;
+ uiWindow.hidden = YES;
+ }
+}
+
- (void)layoutSubviews
{
for (int i = int(self.subviews.count) - 1; i >= 0; --i) {
@@ -75,7 +119,11 @@
- (void)layoutView:(QUIView *)view
{
QWindow *window = view.qwindow;
- Q_ASSERT(window->handle());
+
+ // Return early if the QIOSWindow is still constructing, as we'll
+ // take care of setting the correct window state in the constructor.
+ if (!window->handle())
+ return;
// Re-apply window states to update geometry
if (window->windowState() & (Qt::WindowFullScreen | Qt::WindowMaximized))
@@ -121,13 +169,6 @@
// -------------------------------------------------------------------------
-@interface QIOSViewController () {
- QIOSScreen *m_screen;
- BOOL m_updatingProperties;
-}
-@property (nonatomic, assign) BOOL changingOrientation;
-@end
-
@implementation QIOSViewController
- (id)initWithQIOSScreen:(QIOSScreen *)screen
@@ -155,14 +196,14 @@
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
#endif
+ self.lockedOrientation = UIInterfaceOrientationUnknown;
self.changingOrientation = NO;
- self.shouldAutorotate = [super shouldAutorotate];
// Status bar may be initially hidden at startup through Info.plist
self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false);
self.preferredStatusBarUpdateAnimation = UIStatusBarAnimationNone;
- QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() {
+ m_focusWindowChangeConnection = QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() {
[self updateProperties];
});
}
@@ -170,6 +211,12 @@
return self;
}
+- (void)dealloc
+{
+ QObject::disconnect(m_focusWindowChangeConnection);
+ [super dealloc];
+}
+
- (void)loadView
{
self.view = [[[QIOSDesktopManagerView alloc] init] autorelease];
@@ -197,6 +244,11 @@
// -------------------------------------------------------------------------
+-(BOOL)shouldAutorotate
+{
+ return m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
+}
+
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)
-(NSUInteger)supportedInterfaceOrientations
{
@@ -282,7 +334,8 @@
if (!QCoreApplication::instance())
return;
- m_screen->updateProperties();
+ if (m_screen)
+ m_screen->updateProperties();
}
// -------------------------------------------------------------------------
@@ -292,6 +345,14 @@
if (!isQtApplication())
return;
+ if (!m_screen || !m_screen->screen())
+ return;
+
+ // For now we only care about the main screen, as both the statusbar
+ // visibility and orientation is only appropriate for the main screen.
+ if (m_screen->uiScreen() != [UIScreen mainScreen])
+ return;
+
// Prevent recursion caused by updating the status bar appearance (position
// or visibility), which in turn may cause a layout of our subviews, and
// a reset of window-states, which themselves affect the view controller
@@ -347,16 +408,12 @@
// so we keep the status bar in sync with content orientation. This will ensure
// that the task bar (and associated gestures) are also rotated accordingly.
- if (self.shouldAutorotate) {
+ if (!self.lockedOrientation) {
// We are moving from Qt::PrimaryOrientation to an explicit orientation,
// so we need to store the current statusbar orientation, as we need it
// later when mapping screen coordinates for QScreen and for returning
// to Qt::PrimaryOrientation.
self.lockedOrientation = uiApplication.statusBarOrientation;
-
- // Calling setStatusBarOrientation only has an effect when auto-rotation is
- // disabled, which makes sense when there's an explicit content orientation.
- self.shouldAutorotate = NO;
}
[uiApplication setStatusBarOrientation:
@@ -368,16 +425,15 @@
// that auto-rotation should be enabled. But we may be coming out of
// a state of locked orientation, which needs some cleanup before we
// can enable auto-rotation again.
- if (!self.shouldAutorotate) {
+ if (self.lockedOrientation) {
// First we need to restore the statusbar to what it was at the
// time of locking the orientation, otherwise iOS will be very
// confused when it starts doing auto-rotation again.
- [uiApplication setStatusBarOrientation:
- UIInterfaceOrientation(self.lockedOrientation)
+ [uiApplication setStatusBarOrientation:self.lockedOrientation
animated:kAnimateContentOrientationChanges];
// Then we can re-enable auto-rotation
- self.shouldAutorotate = YES;
+ self.lockedOrientation = UIInterfaceOrientationUnknown;
// And finally let iOS rotate the root view to match the device orientation
[UIViewController attemptRotationToDeviceOrientation];
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 6c4614408d..0b09e73a7d 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -250,17 +250,10 @@ void QIOSWindow::setWindowState(Qt::WindowState state)
void QIOSWindow::setParent(const QPlatformWindow *parentWindow)
{
- if (parentWindow) {
- UIView *parentView = reinterpret_cast<UIView *>(parentWindow->winId());
- [parentView addSubview:m_view];
- } else if (isQtApplication()) {
- for (UIWindow *uiWindow in [[UIApplication sharedApplication] windows]) {
- if (uiWindow.screen == static_cast<QIOSScreen *>(screen())->uiScreen()) {
- [uiWindow.rootViewController.view addSubview:m_view];
- break;
- }
- }
- }
+ UIView *parentView = parentWindow ? reinterpret_cast<UIView *>(parentWindow->winId())
+ : isQtApplication() ? static_cast<QIOSScreen *>(screen())->uiWindow().rootViewController.view : 0;
+
+ [parentView addSubview:m_view];
}
void QIOSWindow::requestActivateWindow()
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm
index 63b6827ad3..3dff271d00 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -193,4 +193,33 @@
action->doAction(QAccessibleActionInterface::decreaseAction());
}
+- (BOOL) accessibilityScroll : (UIAccessibilityScrollDirection) direction
+{
+ QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
+ QAccessibleActionInterface *action = iface->actionInterface();
+ if (!action)
+ return NO;
+ switch (direction) {
+ case UIAccessibilityScrollDirectionRight:
+ action->doAction(QAccessibleActionInterface::scrollRightAction());
+ return YES;
+ case UIAccessibilityScrollDirectionLeft:
+ action->doAction(QAccessibleActionInterface::scrollLeftAction());
+ return YES;
+ case UIAccessibilityScrollDirectionUp:
+ action->doAction(QAccessibleActionInterface::scrollUpAction());
+ return YES;
+ case UIAccessibilityScrollDirectionDown:
+ action->doAction(QAccessibleActionInterface::scrollDownAction());
+ return YES;
+ case UIAccessibilityScrollDirectionNext:
+ action->doAction(QAccessibleActionInterface::nextPageAction());
+ return YES;
+ case UIAccessibilityScrollDirectionPrevious:
+ action->doAction(QAccessibleActionInterface::previousPageAction());
+ return YES;
+ }
+ return NO;
+}
+
@end
diff --git a/src/plugins/platforms/kms/main.cpp b/src/plugins/platforms/kms/main.cpp
index 39ca77bd56..9e9e2c7344 100644
--- a/src/plugins/platforms/kms/main.cpp
+++ b/src/plugins/platforms/kms/main.cpp
@@ -41,7 +41,7 @@ class QKmsIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "kms.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&);
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QPlatformIntegration *QKmsIntegrationPlugin::create(const QString& system, const QStringList& paramList)
diff --git a/src/plugins/platforms/kms/qkmsbackingstore.h b/src/plugins/platforms/kms/qkmsbackingstore.h
index 56d57313e8..a8f2dddd03 100644
--- a/src/plugins/platforms/kms/qkmsbackingstore.h
+++ b/src/plugins/platforms/kms/qkmsbackingstore.h
@@ -49,12 +49,12 @@ public:
QKmsBackingStore(QWindow *window);
~QKmsBackingStore();
- QPaintDevice *paintDevice();
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
- void beginPaint(const QRegion &);
+ void beginPaint(const QRegion &) Q_DECL_OVERRIDE;
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size, const QRegion &staticContents);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
QImage toImage() const Q_DECL_OVERRIDE { return m_image; }
diff --git a/src/plugins/platforms/kms/qkmscontext.h b/src/plugins/platforms/kms/qkmscontext.h
index b388dba7d5..fabe3c2524 100644
--- a/src/plugins/platforms/kms/qkmscontext.h
+++ b/src/plugins/platforms/kms/qkmscontext.h
@@ -48,14 +48,14 @@ class QKmsContext : public QPlatformOpenGLContext
public:
QKmsContext(QOpenGLContext *context, QKmsDevice *device);
- bool makeCurrent(QPlatformSurface *surface);
- void doneCurrent();
- void swapBuffers(QPlatformSurface *surface);
- void (*getProcAddress(const QByteArray &procName)) ();
+ bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void doneCurrent() Q_DECL_OVERRIDE;
+ void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void (*getProcAddress(const QByteArray &procName)) () Q_DECL_OVERRIDE;
- bool isValid() const;
+ bool isValid() const Q_DECL_OVERRIDE;
- QSurfaceFormat format() const;
+ QSurfaceFormat format() const Q_DECL_OVERRIDE;
EGLContext eglContext() const;
diff --git a/src/plugins/platforms/kms/qkmscursor.h b/src/plugins/platforms/kms/qkmscursor.h
index 3eef4e599c..35d9814224 100644
--- a/src/plugins/platforms/kms/qkmscursor.h
+++ b/src/plugins/platforms/kms/qkmscursor.h
@@ -49,8 +49,8 @@ public:
QKmsCursor(QKmsScreen *screen);
~QKmsCursor();
- void pointerEvent(const QMouseEvent &event);
- void changeCursor(QCursor *windowCursor, QWindow *window);
+ void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
+ void changeCursor(QCursor *windowCursor, QWindow *window) Q_DECL_OVERRIDE;
private:
QKmsScreen *m_screen;
diff --git a/src/plugins/platforms/kms/qkmsintegration.cpp b/src/plugins/platforms/kms/qkmsintegration.cpp
index d94d7d9aaa..5ad58ba54f 100644
--- a/src/plugins/platforms/kms/qkmsintegration.cpp
+++ b/src/plugins/platforms/kms/qkmsintegration.cpp
@@ -74,7 +74,7 @@ QKmsIntegration::~QKmsIntegration()
delete device;
}
foreach (QPlatformScreen *screen, m_screens) {
- delete screen;
+ destroyScreen(screen);
}
delete m_fontDatabase;
delete m_vtHandler;
diff --git a/src/plugins/platforms/kms/qkmsnativeinterface.cpp b/src/plugins/platforms/kms/qkmsnativeinterface.cpp
index 3ed1643fdb..c133b48086 100644
--- a/src/plugins/platforms/kms/qkmsnativeinterface.cpp
+++ b/src/plugins/platforms/kms/qkmsnativeinterface.cpp
@@ -52,6 +52,21 @@ public:
Q_GLOBAL_STATIC(QKmsResourceMap, qKmsResourceMap)
+void *QKmsNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+ ResourceType resource = qKmsResourceMap()->value(lowerCaseResource);
+ void *result = 0;
+ switch (resource) {
+ case EglDisplay:
+ result = eglDisplay();
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+
+}
void *QKmsNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();
@@ -79,7 +94,14 @@ QPlatformNativeInterface::NativeResourceForContextFunction QKmsNativeInterface::
return 0;
}
-
+void *QKmsNativeInterface::eglDisplay()
+{
+ //QKmsIntegration *integration = static_cast<QKmsIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QKmsScreen *screen = static_cast<QKmsScreen *>(QGuiApplication::primaryScreen()->handle());
+ if (!screen || !screen->device())
+ return 0;
+ return screen->device()->eglDisplay();
+}
void *QKmsNativeInterface::eglDisplayForWindow(QWindow *window)
{
diff --git a/src/plugins/platforms/kms/qkmsnativeinterface.h b/src/plugins/platforms/kms/qkmsnativeinterface.h
index b9ef914045..402c8b7f6f 100644
--- a/src/plugins/platforms/kms/qkmsnativeinterface.h
+++ b/src/plugins/platforms/kms/qkmsnativeinterface.h
@@ -46,10 +46,12 @@ public:
EglContext
};
- void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
+ void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
+ void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) Q_DECL_OVERRIDE;
- NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource);
+ NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
+ void *eglDisplay();
void *eglDisplayForWindow(QWindow *window);
void *eglContextForWindow(QWindow *window);
static void *eglContextForContext(QOpenGLContext *context);
diff --git a/src/plugins/platforms/kms/qkmsscreen.cpp b/src/plugins/platforms/kms/qkmsscreen.cpp
index ddcdd10928..84c1eba448 100644
--- a/src/plugins/platforms/kms/qkmsscreen.cpp
+++ b/src/plugins/platforms/kms/qkmsscreen.cpp
@@ -216,7 +216,7 @@ void QKmsScreen::performPageFlip()
// Initialize cursor
- static int hideCursor = qgetenv("QT_QPA_KMS_HIDECURSOR").toInt();
+ static int hideCursor = qEnvironmentVariableIntValue("QT_QPA_KMS_HIDECURSOR");
if (!hideCursor) {
QCursor cursor(Qt::ArrowCursor);
m_cursor->changeCursor(&cursor, 0);
diff --git a/src/plugins/platforms/kms/qkmsscreen.h b/src/plugins/platforms/kms/qkmsscreen.h
index 552541503c..8557e12a03 100644
--- a/src/plugins/platforms/kms/qkmsscreen.h
+++ b/src/plugins/platforms/kms/qkmsscreen.h
@@ -67,11 +67,11 @@ public:
QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector);
~QKmsScreen();
- QRect geometry() const;
- int depth() const;
- QImage::Format format() const;
- QSizeF physicalSize() const;
- QPlatformCursor *cursor() const;
+ QRect geometry() const Q_DECL_OVERRIDE;
+ int depth() const Q_DECL_OVERRIDE;
+ QImage::Format format() const Q_DECL_OVERRIDE;
+ QSizeF physicalSize() const Q_DECL_OVERRIDE;
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
quint32 crtcId() const { return m_crtcId; }
QKmsDevice *device() const;
diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp
index 14cd3611d9..1fcf3fa0a8 100644
--- a/src/plugins/platforms/linuxfb/main.cpp
+++ b/src/plugins/platforms/linuxfb/main.cpp
@@ -41,7 +41,7 @@ class QLinuxFbIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "linuxfb.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&);
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QPlatformIntegration* QLinuxFbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
index cb870847f2..6785464cea 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
@@ -46,6 +46,16 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatforminputcontextfactory_p.h>
+#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
+#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
+#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
+#include <QtPlatformSupport/private/qevdevtouch_p.h>
+#endif
+
+#if !defined(QT_NO_TSLIB) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
+#include <QtPlatformSupport/private/qtslib_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
QLinuxFbIntegration::QLinuxFbIntegration(const QStringList &paramList)
@@ -57,7 +67,7 @@ QLinuxFbIntegration::QLinuxFbIntegration(const QStringList &paramList)
QLinuxFbIntegration::~QLinuxFbIntegration()
{
- delete m_primaryScreen;
+ destroyScreen(m_primaryScreen);
}
void QLinuxFbIntegration::initialize()
@@ -70,6 +80,9 @@ void QLinuxFbIntegration::initialize()
m_inputContext = QPlatformInputContextFactory::create();
m_vtHandler.reset(new QFbVtHandler);
+
+ if (!qEnvironmentVariableIntValue("QT_QPA_FB_DISABLE_INPUT"))
+ createInputHandlers();
}
bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@@ -113,4 +126,19 @@ QPlatformServices *QLinuxFbIntegration::services() const
return m_services.data();
}
+void QLinuxFbIntegration::createInputHandlers()
+{
+#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
+ new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this);
+ new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
+#ifndef QT_NO_TSLIB
+ const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
+ if (useTslib)
+ new QTsLibMouseHandler(QLatin1String("TsLib"), QString());
+ else
+#endif // QT_NO_TSLIB
+ new QEvdevTouchScreenHandlerThread(QString(), this);
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
index cabd943921..3e7e1c57f4 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
@@ -35,6 +35,7 @@
#define QLINUXFBINTEGRATION_H
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
@@ -42,7 +43,7 @@ class QAbstractEventDispatcher;
class QLinuxFbScreen;
class QFbVtHandler;
-class QLinuxFbIntegration : public QPlatformIntegration
+class QLinuxFbIntegration : public QPlatformIntegration, public QPlatformNativeInterface
{
public:
QLinuxFbIntegration(const QStringList &paramList);
@@ -63,6 +64,8 @@ public:
QList<QPlatformScreen *> screens() const;
private:
+ void createInputHandlers();
+
QLinuxFbScreen *m_primaryScreen;
QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> m_fontDb;
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index a66c9fa252..592ce90b16 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -55,10 +55,6 @@
#include <linux/fb.h>
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
-#endif
-
QT_BEGIN_NAMESPACE
static int openFramebufferDevice(const QString &dev)
@@ -393,22 +389,7 @@ bool QLinuxFbScreen::initialize()
QFbScreen::initializeCompositor();
mFbScreenImage = QImage(mMmap.data, geometry.width(), geometry.height(), mBytesPerLine, mFormat);
- QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
-#if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)
- bool hideCursor = false;
-#else
- bool hideCursor = true; // default to true to prevent the cursor showing up with the subclass on Android
-#endif
- if (hideCursorVal.isEmpty()) {
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
- QScopedPointer<QDeviceDiscovery> dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse));
- hideCursor = dis->scanConnectedDevices().isEmpty();
-#endif
- } else {
- hideCursor = hideCursorVal.toInt() != 0;
- }
- if (!hideCursor)
- mCursor = new QFbCursor(this);
+ mCursor = new QFbCursor(this);
mTtyFd = openTtyDevice(ttyDevice);
if (mTtyFd == -1)
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
index 1997d46ad1..32b8c3f4ab 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
@@ -51,7 +51,7 @@ public:
bool initialize();
public slots:
- QRegion doRedraw();
+ QRegion doRedraw() Q_DECL_OVERRIDE;
private:
QStringList mArgs;
diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp
index 191de630b2..d4db29016d 100644
--- a/src/plugins/platforms/minimal/main.cpp
+++ b/src/plugins/platforms/minimal/main.cpp
@@ -42,7 +42,7 @@ class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "minimal.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&);
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system, const QStringList& paramList)
diff --git a/src/plugins/platforms/minimal/qminimalbackingstore.h b/src/plugins/platforms/minimal/qminimalbackingstore.h
index d356153b62..e373d99783 100644
--- a/src/plugins/platforms/minimal/qminimalbackingstore.h
+++ b/src/plugins/platforms/minimal/qminimalbackingstore.h
@@ -46,9 +46,9 @@ public:
QMinimalBackingStore(QWindow *window);
~QMinimalBackingStore();
- QPaintDevice *paintDevice();
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size, const QRegion &staticContents);
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
private:
QImage mImage;
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
index 252f842df4..8a2bf79116 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.cpp
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -66,7 +66,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList &parameters)
, m_options(parseOptions(parameters))
{
if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable)
- && qgetenv(debugBackingStoreEnvironmentVariable).toInt() > 0) {
+ && qEnvironmentVariableIntValue(debugBackingStoreEnvironmentVariable) > 0) {
m_options |= DebugBackingStore | EnableFonts;
}
@@ -99,7 +99,7 @@ bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) co
class DummyFontDatabase : public QPlatformFontDatabase
{
public:
- virtual void populateFontDatabase() {}
+ virtual void populateFontDatabase() Q_DECL_OVERRIDE {}
};
QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h
index d9392df510..d1ab02c0dc 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.h
+++ b/src/plugins/platforms/minimal/qminimalintegration.h
@@ -45,9 +45,9 @@ public:
QMinimalScreen()
: mDepth(32), mFormat(QImage::Format_ARGB32_Premultiplied) {}
- QRect geometry() const { return mGeometry; }
- int depth() const { return mDepth; }
- QImage::Format format() const { return mFormat; }
+ QRect geometry() const Q_DECL_OVERRIDE { return mGeometry; }
+ int depth() const Q_DECL_OVERRIDE { return mDepth; }
+ QImage::Format format() const Q_DECL_OVERRIDE { return mFormat; }
public:
QRect mGeometry;
@@ -67,12 +67,12 @@ public:
explicit QMinimalIntegration(const QStringList &parameters);
~QMinimalIntegration();
- bool hasCapability(QPlatformIntegration::Capability cap) const;
- QPlatformFontDatabase *fontDatabase() const;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
+ QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
- QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
- QAbstractEventDispatcher *createEventDispatcher() const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
unsigned options() const { return m_options; }
diff --git a/src/plugins/platforms/minimalegl/main.cpp b/src/plugins/platforms/minimalegl/main.cpp
index de130ae2ff..f66c8008d0 100644
--- a/src/plugins/platforms/minimalegl/main.cpp
+++ b/src/plugins/platforms/minimalegl/main.cpp
@@ -41,7 +41,7 @@ class QMinimalEglIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "minimalegl.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&);
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QPlatformIntegration* QMinimalEglIntegrationPlugin::create(const QString& system, const QStringList& paramList)
diff --git a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h
index 617ab9a1b9..483c5fc789 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h
+++ b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h
@@ -47,13 +47,13 @@ public:
QMinimalEglBackingStore(QWindow *window);
~QMinimalEglBackingStore();
- QPaintDevice *paintDevice();
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
- void beginPaint(const QRegion &);
- void endPaint();
+ void beginPaint(const QRegion &) Q_DECL_OVERRIDE;
+ void endPaint() Q_DECL_OVERRIDE;
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size, const QRegion &staticContents);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
private:
QOpenGLContext *m_context;
diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
index 0b12e62cc1..3fbed1ec26 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
+++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
@@ -60,7 +60,7 @@ QMinimalEglIntegration::QMinimalEglIntegration()
QMinimalEglIntegration::~QMinimalEglIntegration()
{
- delete mScreen;
+ destroyScreen(mScreen);
}
bool QMinimalEglIntegration::hasCapability(QPlatformIntegration::Capability cap) const
diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.h b/src/plugins/platforms/minimalegl/qminimaleglintegration.h
index 5c42184926..452185bcdb 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglintegration.h
+++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.h
@@ -47,17 +47,17 @@ public:
QMinimalEglIntegration();
~QMinimalEglIntegration();
- bool hasCapability(QPlatformIntegration::Capability cap) const;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
- QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
- QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
- QPlatformFontDatabase *fontDatabase() const;
+ QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
- QAbstractEventDispatcher *createEventDispatcher() const;
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
- QVariant styleHint(QPlatformIntegration::StyleHint hint) const;
+ QVariant styleHint(QPlatformIntegration::StyleHint hint) const Q_DECL_OVERRIDE;
private:
QPlatformFontDatabase *mFontDb;
diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
index a0ebffa806..af99a8c664 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
+++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
@@ -54,7 +54,7 @@ public:
{
}
- EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE
{
QMinimalEglWindow *window = static_cast<QMinimalEglWindow *>(surface);
QMinimalEglScreen *screen = static_cast<QMinimalEglScreen *>(window->screen());
diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.h b/src/plugins/platforms/minimalegl/qminimaleglscreen.h
index 9e5dc90971..e70d52f1aa 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglscreen.h
+++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.h
@@ -50,9 +50,9 @@ public:
QMinimalEglScreen(EGLNativeDisplayType display);
~QMinimalEglScreen();
- QRect geometry() const;
- int depth() const;
- QImage::Format format() const;
+ QRect geometry() const Q_DECL_OVERRIDE;
+ int depth() const Q_DECL_OVERRIDE;
+ QImage::Format format() const Q_DECL_OVERRIDE;
QPlatformOpenGLContext *platformContext() const;
diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.h b/src/plugins/platforms/minimalegl/qminimaleglwindow.h
index 5c3006663f..536cae6f46 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglwindow.h
+++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.h
@@ -46,8 +46,8 @@ class QMinimalEglWindow : public QPlatformWindow
public:
QMinimalEglWindow(QWindow *w);
- void setGeometry(const QRect &);
- WId winId() const;
+ void setGeometry(const QRect &) Q_DECL_OVERRIDE;
+ WId winId() const Q_DECL_OVERRIDE;
private:
WId m_winid;
diff --git a/src/plugins/platforms/offscreen/main.cpp b/src/plugins/platforms/offscreen/main.cpp
index 98b8e2ba95..102b349b7a 100644
--- a/src/plugins/platforms/offscreen/main.cpp
+++ b/src/plugins/platforms/offscreen/main.cpp
@@ -42,7 +42,7 @@ class QOffscreenIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "offscreen.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&);
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
QPlatformIntegration *QOffscreenIntegrationPlugin::create(const QString& system, const QStringList& paramList)
diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
index 50c9a85fcf..5acb245be0 100644
--- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
@@ -49,8 +49,8 @@ class QOffscreenCursor : public QPlatformCursor
public:
QOffscreenCursor() : m_pos(10, 10) {}
- QPoint pos() const { return m_pos; }
- void setPos(const QPoint &pos)
+ QPoint pos() const Q_DECL_OVERRIDE { return m_pos; }
+ void setPos(const QPoint &pos) Q_DECL_OVERRIDE
{
m_pos = pos;
QWindowList wl = QGuiApplication::topLevelWindows();
@@ -76,7 +76,7 @@ public:
QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0;
}
- void changeCursor(QCursor *windowCursor, QWindow *window)
+ void changeCursor(QCursor *windowCursor, QWindow *window) Q_DECL_OVERRIDE
{
Q_UNUSED(windowCursor);
Q_UNUSED(window);
diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.h b/src/plugins/platforms/offscreen/qoffscreencommon.h
index 88615d2da4..394d20bce5 100644
--- a/src/plugins/platforms/offscreen/qoffscreencommon.h
+++ b/src/plugins/platforms/offscreen/qoffscreencommon.h
@@ -51,12 +51,12 @@ class QOffscreenScreen : public QPlatformScreen
public:
QOffscreenScreen();
- QRect geometry() const { return m_geometry; }
- int depth() const { return 32; }
- QImage::Format format() const { return QImage::Format_RGB32; }
- QPlatformCursor *cursor() const { return m_cursor.data(); }
+ QRect geometry() const Q_DECL_OVERRIDE { return m_geometry; }
+ int depth() const Q_DECL_OVERRIDE { return 32; }
+ QImage::Format format() const Q_DECL_OVERRIDE { return QImage::Format_RGB32; }
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE { return m_cursor.data(); }
- QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
static QPlatformWindow *windowContainingCursor;
@@ -69,8 +69,8 @@ public:
class QOffscreenDrag : public QPlatformDrag
{
public:
- QMimeData *platformDropData() { return 0; }
- Qt::DropAction drag(QDrag *) { return Qt::IgnoreAction; }
+ QMimeData *platformDropData() Q_DECL_OVERRIDE { return 0; }
+ Qt::DropAction drag(QDrag *) Q_DECL_OVERRIDE { return Qt::IgnoreAction; }
};
#endif
@@ -80,10 +80,10 @@ public:
QOffscreenBackingStore(QWindow *window);
~QOffscreenBackingStore();
- QPaintDevice *paintDevice();
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size, const QRegion &staticContents);
- bool scroll(const QRegion &area, int dx, int dy);
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
+ bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE;
QPixmap grabWindow(WId window, const QRect &rect) const;
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h
index 714c5eb081..4572269d27 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.h
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h
@@ -48,17 +48,17 @@ public:
QOffscreenIntegration();
~QOffscreenIntegration();
- bool hasCapability(QPlatformIntegration::Capability cap) const;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
- QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
#ifndef QT_NO_DRAGANDDROP
- QPlatformDrag *drag() const;
+ QPlatformDrag *drag() const Q_DECL_OVERRIDE;
#endif
- QPlatformServices *services() const;
+ QPlatformServices *services() const Q_DECL_OVERRIDE;
- QPlatformFontDatabase *fontDatabase() const;
- QAbstractEventDispatcher *createEventDispatcher() const;
+ QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
static QOffscreenIntegration *createOffscreenIntegration();
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h
index c50e812777..59e62c3c20 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h
@@ -49,9 +49,9 @@ class QOffscreenX11Info;
class QOffscreenX11Integration : public QOffscreenIntegration
{
public:
- bool hasCapability(QPlatformIntegration::Capability cap) const;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
- QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
private:
mutable QScopedPointer<QOffscreenX11Connection> m_connection;
@@ -82,14 +82,14 @@ public:
QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGLContext *context);
~QOffscreenX11GLXContext();
- bool makeCurrent(QPlatformSurface *surface);
- void doneCurrent();
- void swapBuffers(QPlatformSurface *surface);
- void (*getProcAddress(const QByteArray &procName)) ();
+ bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void doneCurrent() Q_DECL_OVERRIDE;
+ void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void (*getProcAddress(const QByteArray &procName)) () Q_DECL_OVERRIDE;
- QSurfaceFormat format() const;
- bool isSharing() const;
- bool isValid() const;
+ QSurfaceFormat format() const Q_DECL_OVERRIDE;
+ bool isSharing() const Q_DECL_OVERRIDE;
+ bool isValid() const Q_DECL_OVERRIDE;
private:
QScopedPointer<QOffscreenX11GLXContextData> d;
diff --git a/src/plugins/platforms/offscreen/qoffscreenwindow.h b/src/plugins/platforms/offscreen/qoffscreenwindow.h
index d168d28ee8..e50a5a08ff 100644
--- a/src/plugins/platforms/offscreen/qoffscreenwindow.h
+++ b/src/plugins/platforms/offscreen/qoffscreenwindow.h
@@ -47,15 +47,15 @@ public:
QOffscreenWindow(QWindow *window);
~QOffscreenWindow();
- void setGeometry(const QRect &rect);
- void setWindowState(Qt::WindowState state);
+ void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
+ void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE;
- QMargins frameMargins() const;
+ QMargins frameMargins() const Q_DECL_OVERRIDE;
- void setVisible(bool visible);
- void requestActivateWindow();
+ void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void requestActivateWindow() Q_DECL_OVERRIDE;
- WId winId() const;
+ WId winId() const Q_DECL_OVERRIDE;
static QOffscreenWindow *windowForWinId(WId id);
diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
index 1e29fcc9b1..26bdd14327 100644
--- a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
+++ b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
@@ -133,3 +133,8 @@ void QOpenWFDIntegration::addScreen(QOpenWFDScreen *screen)
{
screenAdded(screen);
}
+
+void QOpenWFDIntegration::destroyScreen(QOpenWFDScreen *screen)
+{
+ QPlatformIntegration::destroyScreen(screen);
+}
diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.h b/src/plugins/platforms/openwfd/qopenwfdintegration.h
index 6c086b73be..9243205caa 100644
--- a/src/plugins/platforms/openwfd/qopenwfdintegration.h
+++ b/src/plugins/platforms/openwfd/qopenwfdintegration.h
@@ -63,6 +63,7 @@ public:
QPlatformPrinterSupport *printerSupport() const;
void addScreen(QOpenWFDScreen *screen);
+ void destroyScreen(QOpenWFDScreen *screen);
private:
QList<QPlatformScreen *> mScreens;
QList<QOpenWFDDevice *>mDevices;
diff --git a/src/plugins/platforms/openwfd/qopenwfdport.cpp b/src/plugins/platforms/openwfd/qopenwfdport.cpp
index 0bdc6b2d4b..b643644800 100644
--- a/src/plugins/platforms/openwfd/qopenwfdport.cpp
+++ b/src/plugins/platforms/openwfd/qopenwfdport.cpp
@@ -140,7 +140,7 @@ void QOpenWFDPort::detach()
mAttached = false;
mOn = false;
- delete mScreen;
+ mDevice->integration()->destroyScreen(mScreen);
wfdDestroyPipeline(mDevice->handle(),mPipeline);
mPipelineId = WFD_INVALID_PIPELINE_ID;
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index 69f6f308b5..4e1b7e3026 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -35,8 +35,4 @@ contains(QT_CONFIG, directfb) {
SUBDIRS += directfb
}
-contains(QT_CONFIG, kms):contains(QT_CONFIG, opengl) {
- SUBDIRS += kms
-}
-
contains(QT_CONFIG, linuxfb): SUBDIRS += linuxfb
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp
index 09736304e1..7133d01e87 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.cpp
+++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp
@@ -164,7 +164,7 @@ EGLenum QQnxGLContext::checkEGLError(const char *msg)
return error;
}
-void QQnxGLContext::initialize()
+void QQnxGLContext::initializeContext()
{
qGLContextDebug() << Q_FUNC_INFO;
@@ -182,7 +182,7 @@ void QQnxGLContext::initialize()
}
}
-void QQnxGLContext::shutdown()
+void QQnxGLContext::shutdownContext()
{
qGLContextDebug() << Q_FUNC_INFO;
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h
index 090c7ed49d..a91a89901f 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.h
+++ b/src/plugins/platforms/qnx/qqnxglcontext.h
@@ -53,8 +53,8 @@ public:
static EGLenum checkEGLError(const char *msg);
- static void initialize();
- static void shutdown();
+ static void initializeContext();
+ static void shutdownContext();
void requestSurfaceChange();
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 34b79b61da..dba4ba67a8 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -182,7 +182,7 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
#if !defined(QT_NO_OPENGL)
// Initialize global OpenGL resources
- QQnxGLContext::initialize();
+ QQnxGLContext::initializeContext();
#endif
// Create/start event thread
@@ -306,7 +306,7 @@ QQnxIntegration::~QQnxIntegration()
#if !defined(QT_NO_OPENGL)
// Cleanup global OpenGL resources
- QQnxGLContext::shutdown();
+ QQnxGLContext::shutdownContext();
#endif
#if defined(QQNX_PPS)
@@ -554,7 +554,7 @@ void QQnxIntegration::removeDisplay(QQnxScreen *screen)
Q_CHECK_PTR(screen);
Q_ASSERT(m_screens.contains(screen));
m_screens.removeAll(screen);
- screen->deleteLater();
+ destroyScreen(screen);
}
void QQnxIntegration::destroyDisplays()
diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp
index d42babb8ab..d4407842f5 100644
--- a/src/plugins/platforms/qnx/qqnxscreen.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreen.cpp
@@ -305,7 +305,7 @@ static int defaultDepth()
if (defaultDepth == 0) {
// check if display depth was specified in environment variable;
// use default value if no valid value found
- defaultDepth = qgetenv("QQNX_DISPLAY_DEPTH").toInt();
+ defaultDepth = qEnvironmentVariableIntValue("QQNX_DISPLAY_DEPTH");
if (defaultDepth != 16 && defaultDepth != 32)
defaultDepth = 32;
}
@@ -680,7 +680,7 @@ void QQnxScreen::adjustOrientation()
return;
bool ok = false;
- const int rotation = qgetenv("ORIENTATION").toInt(&ok);
+ const int rotation = qEnvironmentVariableIntValue("ORIENTATION", &ok);
if (ok)
setRotation(rotation);
@@ -859,7 +859,7 @@ void QQnxScreen::setRootWindow(QQnxWindow *window)
{
// Optionally disable the screen power save
bool ok = false;
- const int disablePowerSave = qgetenv("QQNX_DISABLE_POWER_SAVE").toInt(&ok);
+ const int disablePowerSave = qEnvironmentVariableIntValue("QQNX_DISABLE_POWER_SAVE", &ok);
if (ok && disablePowerSave) {
const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
int result = screen_set_window_property_iv(window->nativeHandle(), SCREEN_PROPERTY_IDLE_MODE, &mode);
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
index 7f60be0d50..3d6a6ced6e 100644
--- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp
+++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
@@ -121,7 +121,7 @@ AccessibleRelation::AccessibleRelation(const QList<QAccessibleInterface *> &targ
HRESULT STDMETHODCALLTYPE AccessibleRelation::QueryInterface(REFIID id, LPVOID *iface)
{
*iface = 0;
- if (id == IID_IUnknown)
+ if (id == IID_IUnknown || id == IID_IAccessibleRelation)
*iface = (IUnknown*)this;
if (*iface) {
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h
index 351bf2555c..f7f5e022c3 100644
--- a/src/plugins/platforms/windows/accessible/iaccessible2.h
+++ b/src/plugins/platforms/windows/accessible/iaccessible2.h
@@ -39,24 +39,7 @@
#include "qwindowsmsaaaccessible.h"
#include "comutils.h"
-#include "Accessible2.h"
-#include "AccessibleAction.h"
-#include "AccessibleApplication.h"
-#include "AccessibleComponent.h"
-#include "AccessibleEditableText.h"
-#include "AccessibleHyperlink.h"
-#include "AccessibleHypertext.h"
-#include "AccessibleImage.h"
-#include "AccessibleRelation.h"
-#include "AccessibleTable.h"
-#include "AccessibleTable2.h"
-#include "AccessibleTableCell.h"
-#include "AccessibleText.h"
-#include "AccessibleValue.h"
-
-#include "AccessibleEventID.h"
-#include "AccessibleRole.h"
-#include "AccessibleStates.h"
+#include "ia2_api_all.h"
#include <servprov.h>
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
index a78d821b1d..c522cf281e 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
@@ -42,7 +42,7 @@
#include <QtGui/qaccessible.h>
#ifndef Q_CC_MINGW
# include <oleacc.h>
-# include "Accessible2.h" // IAccessible2 inherits from IAccessible
+# include "ia2_api_all.h" // IAccessible2 inherits from IAccessible
#else
// MinGW
# include <basetyps.h>
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index f1f472b3e2..3a0c3b9fe9 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1580,14 +1580,14 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog()
QWindowsNativeFileDialogBase *result = QWindowsNativeFileDialogBase::create(options()->acceptMode(), m_data);
if (!result)
return 0;
- QObject::connect(result, SIGNAL(accepted()), this, SIGNAL(accept()));
- QObject::connect(result, SIGNAL(rejected()), this, SIGNAL(reject()));
- QObject::connect(result, SIGNAL(directoryEntered(QUrl)),
- this, SIGNAL(directoryEntered(QUrl)));
- QObject::connect(result, SIGNAL(currentChanged(QUrl)),
- this, SIGNAL(currentChanged(QUrl)));
- QObject::connect(result, SIGNAL(filterSelected(QString)),
- this, SIGNAL(filterSelected(QString)));
+ QObject::connect(result, &QWindowsNativeDialogBase::accepted, this, &QPlatformDialogHelper::accept);
+ QObject::connect(result, &QWindowsNativeDialogBase::rejected, this, &QPlatformDialogHelper::reject);
+ QObject::connect(result, &QWindowsNativeFileDialogBase::directoryEntered,
+ this, &QPlatformFileDialogHelper::directoryEntered);
+ QObject::connect(result, &QWindowsNativeFileDialogBase::currentChanged,
+ this, &QPlatformFileDialogHelper::currentChanged);
+ QObject::connect(result, &QWindowsNativeFileDialogBase::filterSelected,
+ this, &QPlatformFileDialogHelper::filterSelected);
// Apply settings.
const QSharedPointer<QFileDialogOptions> &opts = options();
@@ -1961,8 +1961,8 @@ QWindowsNativeDialogBase *QWindowsXpFileDialogHelper::createNativeDialog()
{
m_data.fromOptions(options());
if (QWindowsXpNativeFileDialog *result = QWindowsXpNativeFileDialog::create(options(), m_data)) {
- QObject::connect(result, SIGNAL(accepted()), this, SIGNAL(accept()));
- QObject::connect(result, SIGNAL(rejected()), this, SIGNAL(reject()));
+ QObject::connect(result, &QWindowsNativeDialogBase::accepted, this, &QPlatformDialogHelper::accept);
+ QObject::connect(result, &QWindowsNativeDialogBase::rejected, this, &QPlatformDialogHelper::reject);
return result;
}
return 0;
@@ -2117,8 +2117,8 @@ QWindowsNativeDialogBase *QWindowsColorDialogHelper::createNativeDialog()
{
QWindowsNativeColorDialog *nativeDialog = new QWindowsNativeColorDialog(m_currentColor);
nativeDialog->setWindowTitle(options()->windowTitle());
- connect(nativeDialog, SIGNAL(accepted()), this, SIGNAL(accept()));
- connect(nativeDialog, SIGNAL(rejected()), this, SIGNAL(reject()));
+ connect(nativeDialog, &QWindowsNativeDialogBase::accepted, this, &QPlatformDialogHelper::accept);
+ connect(nativeDialog, &QWindowsNativeDialogBase::rejected, this, &QPlatformDialogHelper::reject);
return nativeDialog;
}
#endif // USE_NATIVE_COLOR_DIALOG
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index f52c5b733c..b71497b176 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -597,7 +597,17 @@ bool QWindowsEGLContext::makeCurrent(QPlatformSurface *surface)
QWindowsEGLStaticContext::libEGL.eglSwapInterval(m_staticContext->display(), m_swapInterval);
}
} else {
- qWarning("QWindowsEGLContext::makeCurrent: eglError: %x, this: %p \n", QWindowsEGLStaticContext::libEGL.eglGetError(), this);
+ int err = QWindowsEGLStaticContext::libEGL.eglGetError();
+ // EGL_CONTEXT_LOST (loss of the D3D device) is not necessarily fatal.
+ // Qt Quick is able to recover for example.
+ if (err == EGL_CONTEXT_LOST) {
+ m_eglContext = EGL_NO_CONTEXT;
+ qCDebug(lcQpaGl) << "Got EGL context lost in makeCurrent() for context" << this;
+ // Drop the surface. Will recreate on the next makeCurrent.
+ window->invalidateSurface();
+ } else {
+ qWarning("QWindowsEGLContext::makeCurrent: eglError: %x, this: %p \n", err, this);
+ }
}
return ok;
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 9c26a227b8..91bc4c64a5 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -618,20 +618,6 @@ QDebug operator<<(QDebug d, const QFontDef &def)
return d;
}
-// convert 0 ~ 1000 integer to QFont::Weight
-static inline QFont::Weight weightFromInteger(long weight)
-{
- if (weight < 400)
- return QFont::Light;
- if (weight < 600)
- return QFont::Normal;
- if (weight < 700)
- return QFont::DemiBold;
- if (weight < 800)
- return QFont::Bold;
- return QFont::Black;
-}
-
static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet)
{
switch (charSet) {
@@ -808,7 +794,7 @@ QString getEnglishName(const QString &familyName)
HDC hdc = GetDC( 0 );
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
- memcpy(lf.lfFaceName, familyName.utf16(), qMin(LF_FACESIZE, familyName.length()) * sizeof(wchar_t));
+ memcpy(lf.lfFaceName, familyName.utf16(), qMin(familyName.length(), LF_FACESIZE - 1) * sizeof(wchar_t));
lf.lfCharSet = DEFAULT_CHARSET;
HFONT hfont = CreateFontIndirect(&lf);
@@ -865,7 +851,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_OUTPUT
@@ -1078,15 +1064,15 @@ QFontEngineMulti *QWindowsFontDatabase::fontEngineMulti(QFontEngine *fontEngine,
if (script == QChar::Script_Common)
return new QWindowsMultiFontEngine(fontEngine, script);
// ### as long as fallbacksForFamily() does not take script parameter into account,
- // prefer QFontEngineMultiBasicImpl's loadEngine() implementation for complex scripts
+ // prefer QFontEngineMulti's loadEngine() implementation for complex scripts
return QPlatformFontDatabase::fontEngineMulti(fontEngine, script);
}
QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, void *handle)
{
- QFontEngine *fe = QWindowsFontDatabase::createEngine(fontDef, 0,
+ QFontEngine *fe = QWindowsFontDatabase::createEngine(fontDef,
QWindowsContext::instance()->defaultDPI(),
- false, sharedFontData());
+ sharedFontData());
qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef << fe << handle;
return fe;
}
@@ -1134,9 +1120,9 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
request.styleStrategy = QFont::PreferMatch;
request.hintingPreference = hintingPreference;
- fontEngine = QWindowsFontDatabase::createEngine(request, 0,
+ fontEngine = QWindowsFontDatabase::createEngine(request,
QWindowsContext::instance()->defaultDPI(),
- false, sharedFontData());
+ sharedFontData());
if (fontEngine) {
if (request.family != fontEngine->fontDef.family) {
@@ -1238,7 +1224,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
else
fontEngine->fontDef.style = QFont::StyleNormal;
- fontEngine->fontDef.weight = weightFromInteger(qFromBigEndian<quint16>(os2Table->weightClass));
+ fontEngine->fontDef.weight = QPlatformFontDatabase::weightFromInteger(qFromBigEndian<quint16>(os2Table->weightClass));
}
}
@@ -1349,7 +1335,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
HDC hdc = GetDC(0);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
- memcpy(lf.lfFaceName, familyName.utf16(), sizeof(wchar_t) * qMin(LF_FACESIZE, familyName.size()));
+ 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);
@@ -1574,6 +1560,10 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request)
lf.lfPitchAndFamily = DEFAULT_PITCH | hint;
QString fam = request.family;
+ if (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");
@@ -1585,7 +1575,7 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request)
if (fam == QLatin1String("Courier") && !(request.styleStrategy & QFont::PreferBitmap))
fam = QStringLiteral("Courier New");
- memcpy(lf.lfFaceName, fam.utf16(), sizeof(wchar_t) * qMin(fam.length() + 1, 32)); // 32 = Windows hard-coded
+ memcpy(lf.lfFaceName, fam.utf16(), fam.size() * sizeof(wchar_t));
return lf;
}
@@ -1668,17 +1658,12 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFon
QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
- HDC fontHdc, int dpi, bool rawMode,
+ int dpi,
const QSharedPointer<QWindowsFontEngineData> &data)
{
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
- const bool useDevice = (request.styleStrategy & QFont::PreferDevice) && fontHdc;
-
- const HDC hdc = useDevice ? fontHdc : data->hdc;
-
- bool stockFont = false;
bool preferClearTypeAA = false;
HFONT hfont = 0;
@@ -1691,32 +1676,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
bool useDirectWrite = false;
#endif
- if (rawMode) { // will choose a stock font
- int f = SYSTEM_FONT;
- const QString fam = request.family.toLower();
- if (fam == QLatin1String("default") || fam == QLatin1String("system"))
- f = SYSTEM_FONT;
-#ifndef Q_OS_WINCE
- else if (fam == QLatin1String("system_fixed"))
- f = SYSTEM_FIXED_FONT;
- else if (fam == QLatin1String("ansi_fixed"))
- f = ANSI_FIXED_FONT;
- else if (fam == QLatin1String("ansi_var"))
- f = ANSI_VAR_FONT;
- else if (fam == QLatin1String("device_default"))
- f = DEVICE_DEFAULT_FONT;
- else if (fam == QLatin1String("oem_fixed"))
- f = OEM_FIXED_FONT;
-#endif
- else if (fam.at(0) == QLatin1Char('#'))
- f = fam.right(fam.length()-1).toInt();
- hfont = (HFONT)GetStockObject(f);
- if (!hfont) {
- qErrnoWarning("%s: GetStockObject failed", __FUNCTION__);
- hfont = QWindowsFontDatabase::systemFont();
- }
- stockFont = true;
- } else {
+ {
lf = fontDefToLOGFONT(request);
preferClearTypeAA = lf.lfQuality == CLEARTYPE_QUALITY;
@@ -1724,17 +1684,16 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
if (!hfont)
qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__);
- stockFont = (hfont == 0);
bool ttf = false;
int avWidth = 0;
BOOL res;
- HGDIOBJ oldObj = SelectObject(hdc, hfont);
+ HGDIOBJ oldObj = SelectObject(data->hdc, hfont);
TEXTMETRIC tm;
- res = GetTextMetrics(hdc, &tm);
+ res = GetTextMetrics(data->hdc, &tm);
avWidth = tm.tmAveCharWidth;
ttf = tm.tmPitchAndFamily & TMPF_TRUETYPE;
- SelectObject(hdc, oldObj);
+ SelectObject(data->hdc, oldObj);
if (!useDirectWrite) {
if (hfont && (!ttf || request.stretch != 100)) {
@@ -1748,15 +1707,11 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
}
#ifndef Q_OS_WINCE
- if (hfont == 0) {
+ if (hfont == 0)
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
- stockFont = true;
- }
#else
- if (hfont == 0) {
+ if (hfont == 0)
hfont = (HFONT)GetStockObject(SYSTEM_FONT);
- stockFont = true;
- }
#endif
}
@@ -1766,9 +1721,13 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
// turns out okay)
useDirectWrite = false;
if (initDirectWrite(data.data())) {
- const QString nameSubstitute = QWindowsFontEngineDirectWrite::fontNameSubstitute(QString::fromWCharArray(lf.lfFaceName));
- memcpy(lf.lfFaceName, nameSubstitute.utf16(),
- sizeof(wchar_t) * qMin(nameSubstitute.length() + 1, LF_FACESIZE));
+ 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;
+ }
HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(
&lf,
@@ -1786,10 +1745,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
QFontEngine *fe = 0;
if (!useDirectWrite) {
- QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, stockFont, lf, data);
+ QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, lf, data);
if (preferClearTypeAA)
few->glyphFormat = QFontEngine::Format_A32;
- few->initFontInfo(request, fontHdc, dpi);
+ few->initFontInfo(request, dpi);
fe = few;
}
@@ -1839,7 +1798,7 @@ QFont QWindowsFontDatabase::LOGFONT_to_QFont(const LOGFONT& logFont, int vertica
QFont qFont(QString::fromWCharArray(logFont.lfFaceName));
qFont.setItalic(logFont.lfItalic);
if (logFont.lfWeight != FW_DONTCARE)
- qFont.setWeight(weightFromInteger(logFont.lfWeight));
+ qFont.setWeight(QPlatformFontDatabase::weightFromInteger(logFont.lfWeight));
const qreal logFontHeight = qAbs(logFont.lfHeight);
qFont.setPointSizeF(logFontHeight * 72.0 / qreal(verticalDPI_In));
qFont.setUnderline(logFont.lfUnderline);
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h
index 8a682e6bec..eb6273b835 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.h
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h
@@ -87,7 +87,7 @@ public:
static QFont systemDefaultFont();
static QFontEngine *createEngine(const QFontDef &request,
- HDC fontHdc, int dpi, bool rawMode,
+ int dpi,
const QSharedPointer<QWindowsFontEngineData> &data);
static HFONT systemFont();
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
index 0fc5e0dc0c..c3bfd9825f 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
@@ -47,25 +47,12 @@
#include <wchar.h>
#ifdef Q_OS_WINCE
+#include <QtCore/QFile>
#include <QtEndian>
#endif
QT_BEGIN_NAMESPACE
-// convert 0 ~ 1000 integer to QFont::Weight
-static inline QFont::Weight weightFromInteger(long weight)
-{
- if (weight < 400)
- return QFont::Light;
- if (weight < 600)
- return QFont::Normal;
- if (weight < 700)
- return QFont::DemiBold;
- if (weight < 800)
- return QFont::Bold;
- return QFont::Black;
-}
-
static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet)
{
switch (charSet) {
@@ -114,6 +101,127 @@ static FontFile * createFontFile(const QString &fileName, int index)
extern bool localizedName(const QString &name);
extern QString getEnglishName(const QString &familyName);
+#ifdef 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;
+
+static QString fontNameFromTTFile(const QString &filename)
+{
+ QFile f(filename);
+ QString retVal;
+ qint64 bytesRead;
+ qint64 bytesToRead;
+
+ if (f.open(QIODevice::ReadOnly)) {
+ 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;
+}
+#endif // Q_OS_WINCE
+
static bool addFontToDatabase(const QString &familyName, uchar charSet,
const TEXTMETRIC *textmetric,
const FONTSIGNATURE *signature,
@@ -139,7 +247,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_OUTPUT
@@ -259,7 +367,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
while (it.hasNext()) {
const QString fontFile = it.next();
- const QString fontName = QBasicFontDatabase::fontNameFromTTFile(fontFile);
+ const QString fontName = fontNameFromTTFile(fontFile);
if (fontName.isEmpty())
continue;
fontCache.insert(fontName, fontFile);
@@ -406,11 +514,14 @@ void QWindowsFontDatabaseFT::populate(const QString &family)
__FUNCTION__, qPrintable(family));
return;
}
+
wmemcpy(lf.lfFaceName, reinterpret_cast<const wchar_t*>(family.utf16()),
family.size() + 1);
lf.lfPitchAndFamily = 0;
+
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont,
(LPARAM)&m_families, 0);
+
ReleaseDC(0, dummy);
}
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index e45ff5d744..912c7a598d 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -239,7 +239,7 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
while (it.hasNext()) {
const uint uc = it.next();
if (
-#ifdef Q_WS_WINCE
+#ifdef Q_DEAD_CODE_FROM_QT4_WINCE
tm.tmFirstChar > 60000 ||
#endif
uc >= first && uc <= last)
@@ -264,14 +264,13 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
*/
QWindowsFontEngine::QWindowsFontEngine(const QString &name,
- HFONT _hfont, bool stockFontIn, LOGFONT lf,
+ HFONT _hfont, LOGFONT lf,
const QSharedPointer<QWindowsFontEngineData> &fontEngineData)
: QFontEngine(Win),
m_fontEngineData(fontEngineData),
_name(name),
hfont(_hfont),
m_logfont(lf),
- stockFont(stockFontIn),
ttf(0),
hasOutline(0),
lw(0),
@@ -325,10 +324,8 @@ QWindowsFontEngine::~QWindowsFontEngine()
// make sure we aren't by accident still selected
SelectObject(m_fontEngineData->hdc, (HFONT)GetStockObject(SYSTEM_FONT));
- if (!stockFont) {
- if (!DeleteObject(hfont))
- qErrnoWarning("%s: QFontEngineWin: failed to delete non-stock font... failed", __FUNCTION__);
- }
+ if (!DeleteObject(hfont))
+ qErrnoWarning("%s: QFontEngineWin: failed to delete font...", __FUNCTION__);
qCDebug(lcQpaFonts) << __FUNCTION__ << _name;
if (!uniqueFamilyName.isEmpty()) {
@@ -1182,19 +1179,13 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
return QImage();
}
- QImage indexed(mask->width(), mask->height(), QImage::Format_Indexed8);
+ QImage alphaMap(mask->width(), mask->height(), QImage::Format_Alpha8);
- // ### This part is kinda pointless, but we'll crash later if we don't because some
- // code paths expects there to be colortables for index8-bit...
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
// 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 = indexed.scanLine(y);
+ uchar *dest = alphaMap.scanLine(y);
if (mask->image().format() == QImage::Format_RGB16) {
const qint16 *src = (qint16 *) ((const QImage &) mask->image()).scanLine(y);
for (int x=0; x<mask->width(); ++x)
@@ -1216,7 +1207,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
DeleteObject(font);
}
- return indexed;
+ return alphaMap;
}
#define SPI_GETFONTSMOOTHINGCONTRAST 0x200C
@@ -1265,9 +1256,9 @@ QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
request.pixelSize = pixelSize;
QFontEngine *fontEngine =
- QWindowsFontDatabase::createEngine(request, 0,
+ QWindowsFontDatabase::createEngine(request,
QWindowsContext::instance()->defaultDPI(),
- false, m_fontEngineData);
+ m_fontEngineData);
if (fontEngine) {
fontEngine->fontDef.family = actualFontName;
if (!uniqueFamilyName.isEmpty()) {
@@ -1280,11 +1271,10 @@ QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
}
void QWindowsFontEngine::initFontInfo(const QFontDef &request,
- HDC fontHdc,
int dpi)
{
fontDef = request; // most settings are equal
- HDC dc = ((request.styleStrategy & QFont::PreferDevice) && fontHdc) ? fontHdc : m_fontEngineData->hdc;
+ HDC dc = m_fontEngineData->hdc;
SelectObject(dc, hfont);
wchar_t n[64];
GetTextFace(dc, 64, n);
@@ -1309,17 +1299,13 @@ void QWindowsFontEngine::initFontInfo(const QFontDef &request,
Will probably be superseded by a common Free Type font engine in Qt 5.X.
*/
QWindowsMultiFontEngine::QWindowsMultiFontEngine(QFontEngine *fe, int script)
- : QFontEngineMultiBasicImpl(fe, script)
+ : QFontEngineMulti(fe, script)
{
}
-void QWindowsMultiFontEngine::loadEngine(int at)
+QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
{
- ensureFallbackFamiliesQueried();
- Q_ASSERT(at < engines.size());
- Q_ASSERT(engines.at(at) == 0);
-
- QFontEngine *fontEngine = engines.at(0);
+ QFontEngine *fontEngine = engine(0);
QSharedPointer<QWindowsFontEngineData> data;
LOGFONT lf;
@@ -1339,36 +1325,36 @@ void QWindowsMultiFontEngine::loadEngine(int at)
}
const QString fam = fallbackFamilyAt(at - 1);
- memcpy(lf.lfFaceName, fam.utf16(), sizeof(wchar_t) * qMin(fam.length() + 1, 32)); // 32 = Windows hard-coded
+ 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(QString::fromWCharArray(lf.lfFaceName));
- memcpy(lf.lfFaceName, nameSubstitute.utf16(),
- sizeof(wchar_t) * qMin(nameSubstitute.length() + 1, LF_FACESIZE));
+ 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 = fontDef;
- fedw->fontDef.family = fam;
- fedw->ref.ref();
- engines[at] = fedw;
-
- qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam;
- return;
+ return fedw;
} else {
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
}
-
}
}
#endif
@@ -1376,19 +1362,10 @@ void QWindowsMultiFontEngine::loadEngine(int at)
// Get here if original font is not DirectWrite or DirectWrite creation failed for some
// reason
HFONT hfont = CreateFontIndirect(&lf);
-
- bool stockFont = false;
- if (hfont == 0) {
+ if (hfont == 0)
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
- stockFont = true;
- }
- engines[at] = new QWindowsFontEngine(fam, hfont, stockFont, lf, data);
- engines[at]->ref.ref();
- engines[at]->fontDef = fontDef;
- engines[at]->fontDef.family = fam;
- qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam;
- // TODO: increase cost in QFontCache for the font engine loaded here
+ return new QWindowsFontEngine(fam, hfont, lf, data);
}
bool QWindowsFontEngine::supportsTransformation(const QTransform &transform) const
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h
index 02bc4008d1..5b412eba78 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.h
+++ b/src/plugins/platforms/windows/qwindowsfontengine.h
@@ -63,12 +63,12 @@ class QWindowsFontEngine : public QFontEngine
friend class QWindowsMultiFontEngine;
public:
- QWindowsFontEngine(const QString &name, HFONT, bool, LOGFONT,
+ QWindowsFontEngine(const QString &name, HFONT hfont, LOGFONT lf,
const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
~QWindowsFontEngine();
void initFontInfo(const QFontDef &request,
- HDC fontHdc, int dpi);
+ int dpi);
QFixed lineThickness() const Q_DECL_OVERRIDE;
Properties properties() const Q_DECL_OVERRIDE;
@@ -139,7 +139,6 @@ private:
QString uniqueFamilyName;
const HFONT hfont;
const LOGFONT m_logfont;
- uint stockFont : 1;
uint ttf : 1;
uint hasOutline : 1;
uint hasUnreliableOutline : 1;
@@ -163,13 +162,12 @@ private:
mutable int designAdvancesSize;
};
-
-class QWindowsMultiFontEngine : public QFontEngineMultiBasicImpl
+class QWindowsMultiFontEngine : public QFontEngineMulti
{
public:
explicit QWindowsMultiFontEngine(QFontEngine *fe, int script);
- void loadEngine(int at);
+ QFontEngine *loadEngine(int at) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index ed512f78ca..5c241b1fc8 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -485,15 +485,11 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub
{
QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform());
- QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
+ QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
for (int y=0; y<im.height(); ++y) {
uint *src = (uint*) im.scanLine(y);
- uchar *dst = indexed.scanLine(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;
@@ -501,7 +497,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub
}
}
- return indexed;
+ return alphaMap;
}
bool QWindowsFontEngineDirectWrite::supportsSubPixelPositions() const
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 3348241d37..e71b101125 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -135,6 +135,10 @@
#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
#endif
+// Common GL and WGL constants
+#define RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define LOSE_CONTEXT_ON_RESET_ARB 0x8252
+
QT_BEGIN_NAMESPACE
QWindowsOpengl32DLL QOpenGLStaticContext::opengl32;
@@ -747,6 +751,12 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext,
break;
}
}
+
+ if (format.testOption(QSurfaceFormat::ResetNotification)) {
+ attributes[attribIndex++] = RESET_NOTIFICATION_STRATEGY_ARB;
+ attributes[attribIndex++] = LOSE_CONTEXT_ON_RESET_ARB;
+ }
+
qCDebug(lcQpaGl) << __FUNCTION__ << "Creating context version"
<< majorVersion << '.' << minorVersion << attribIndex / 2 << "attributes";
@@ -859,6 +869,10 @@ QWindowsOpenGLContextFormat QWindowsOpenGLContextFormat::current()
result.options |= QSurfaceFormat::DeprecatedFunctions;
if (value & GL_CONTEXT_FLAG_DEBUG_BIT)
result.options |= QSurfaceFormat::DebugContext;
+ value = 0;
+ QOpenGLStaticContext::opengl32.glGetIntegerv(RESET_NOTIFICATION_STRATEGY_ARB, &value);
+ if (value == LOSE_CONTEXT_ON_RESET_ARB)
+ result.options |= QSurfaceFormat::ResetNotification;
if (result.version < 0x0302)
return result;
// v3.2 onwards: Profiles
@@ -1032,7 +1046,9 @@ QWindowsGLContext::QWindowsGLContext(QOpenGLStaticContext *staticContext,
m_pixelFormat(0),
m_extensionsUsed(false),
m_swapInterval(-1),
- m_ownsContext(true)
+ m_ownsContext(true),
+ m_getGraphicsResetStatus(0),
+ m_lost(false)
{
if (!m_staticContext) // Something went very wrong. Stop here, isValid() will return false.
return;
@@ -1212,6 +1228,28 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval)
if (m_staticContext->wglGetSwapInternalExt && obtainedSwapInterval)
*obtainedSwapInterval = m_staticContext->wglGetSwapInternalExt();
+ bool hasRobustness = false;
+ if (m_obtainedFormat.majorVersion() < 3) {
+ const char *exts = (const char *) QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS);
+ hasRobustness = exts && strstr(exts, "GL_ARB_robustness");
+ } else {
+ typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint);
+ glGetStringi_t glGetStringi = (glGetStringi_t) QOpenGLStaticContext::opengl32.wglGetProcAddress("glGetStringi");
+ if (glGetStringi) {
+ GLint n = 0;
+ QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n);
+ for (GLint i = 0; i < n; ++i) {
+ const char *p = (const char *) glGetStringi(GL_EXTENSIONS, i);
+ if (p && !strcmp(p, "GL_ARB_robustness")) {
+ hasRobustness = true;
+ break;
+ }
+ }
+ }
+ }
+ if (hasRobustness)
+ m_getGraphicsResetStatus = (GLenum (APIENTRY *)()) QOpenGLStaticContext::opengl32.wglGetProcAddress("glGetGraphicsResetStatusARB");
+
QOpenGLStaticContext::opengl32.wglMakeCurrent(prevSurface, prevContext);
return true;
}
@@ -1297,7 +1335,16 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface)
}
m_windowContexts.append(newContext);
+ m_lost = false;
bool success = QOpenGLStaticContext::opengl32.wglMakeCurrent(newContext.hdc, newContext.renderingContext);
+ if (!success) {
+ if (m_getGraphicsResetStatus && m_getGraphicsResetStatus()) {
+ m_lost = true;
+ qCDebug(lcQpaGl) << "makeCurrent(): context loss detected" << this;
+ // Drop the surface. Will recreate on the next makeCurrent.
+ window->invalidateSurface();
+ }
+ }
// Set the swap interval
if (m_staticContext->wglSwapInternalExt) {
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h
index 5f845f245e..27b0b2e191 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.h
+++ b/src/plugins/platforms/windows/qwindowsglcontext.h
@@ -232,7 +232,7 @@ public:
explicit QWindowsGLContext(QOpenGLStaticContext *staticContext, QOpenGLContext *context);
~QWindowsGLContext();
bool isSharing() const Q_DECL_OVERRIDE { return m_context->shareHandle(); }
- bool isValid() const Q_DECL_OVERRIDE { return m_renderingContext; }
+ bool isValid() const Q_DECL_OVERRIDE { return m_renderingContext && !m_lost; }
QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_obtainedFormat; }
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
@@ -262,6 +262,8 @@ private:
bool m_extensionsUsed;
int m_swapInterval;
bool m_ownsContext;
+ GLenum (APIENTRY * m_getGraphicsResetStatus)();
+ bool m_lost;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index ad63a57d3e..32074fd9b1 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -156,8 +156,8 @@ QWindowsInputContext::QWindowsInputContext() :
m_WM_MSIME_MOUSE(RegisterWindowMessage(L"MSIMEMouseOperation")),
m_endCompositionRecursionGuard(false)
{
- connect(QGuiApplication::inputMethod(), SIGNAL(cursorRectangleChanged()),
- this, SLOT(cursorRectChanged()));
+ connect(QGuiApplication::inputMethod(), &QInputMethod::cursorRectangleChanged,
+ this, &QWindowsInputContext::cursorRectChanged);
}
QWindowsInputContext::~QWindowsInputContext()
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index d1617eaa3c..7fb37bc1f1 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -94,6 +94,7 @@ public:
static QWindowsIntegration *instance();
inline void emitScreenAdded(QPlatformScreen *s) { screenAdded(s); }
+ inline void emitDestroyScreen(QPlatformScreen *s) { destroyScreen(s); }
unsigned options() const;
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index d781cdbe9c..2022c0e07a 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -42,6 +42,36 @@
#include <private/qguiapplication_p.h>
#include <QtGui/QKeyEvent>
+#if defined(WM_APPCOMMAND)
+# ifndef FAPPCOMMAND_MOUSE
+# define FAPPCOMMAND_MOUSE 0x8000
+# endif
+# ifndef FAPPCOMMAND_KEY
+# define FAPPCOMMAND_KEY 0
+# endif
+# ifndef FAPPCOMMAND_OEM
+# define FAPPCOMMAND_OEM 0x1000
+# endif
+# ifndef FAPPCOMMAND_MASK
+# define FAPPCOMMAND_MASK 0xF000
+# endif
+# ifndef GET_APPCOMMAND_LPARAM
+# define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
+# endif
+# ifndef GET_DEVICE_LPARAM
+# define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
+# endif
+# ifndef GET_MOUSEORKEY_LPARAM
+# define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
+# endif
+# ifndef GET_FLAGS_LPARAM
+# define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
+# endif
+# ifndef GET_KEYSTATE_LPARAM
+# define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
+# endif
+#endif
+
QT_BEGIN_NAMESPACE
/*!
@@ -1192,6 +1222,8 @@ Qt::KeyboardModifiers QWindowsKeyMapper::queryKeyboardModifiers()
modifiers |= Qt::ControlModifier;
if (GetKeyState(VK_MENU) < 0)
modifiers |= Qt::AltModifier;
+ if (GetKeyState(VK_LWIN) < 0 || GetKeyState(VK_RWIN) < 0)
+ modifiers |= Qt::MetaModifier;
return modifiers;
}
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index bc8e9347dc..42f4e66d6c 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -343,10 +343,11 @@ static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
return true;
}
-static QByteArray getData(int cf, IDataObject *pDataObj)
+static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1)
{
QByteArray data;
FORMATETC formatetc = setCf(cf);
+ formatetc.lindex = lindex;
STGMEDIUM s;
if (pDataObj->GetData(&formatetc, &s) == S_OK) {
DWORD * val = (DWORD*)GlobalLock(s.hGlobal);
@@ -791,7 +792,6 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
{
if (mimeType == QLatin1String("text/uri-list")) {
if (canGetData(CF_HDROP, pDataObj)) {
- QByteArray texturi;
QList<QVariant> urls;
QByteArray data = getData(CF_HDROP, pDataObj);
@@ -1340,21 +1340,34 @@ static bool isCustomMimeType(const QString &mimeType)
return mimeType.startsWith(QLatin1String(x_qt_windows_mime), Qt::CaseInsensitive);
}
-static QString customMimeType(const QString &mimeType)
+static QString customMimeType(const QString &mimeType, int *lindex = 0)
{
int len = sizeof(x_qt_windows_mime) - 1;
- int n = mimeType.lastIndexOf(QLatin1Char('\"'))-len;
- return mimeType.mid(len, n);
+ int n = mimeType.lastIndexOf(QLatin1Char('\"')) - len;
+ QString ret = mimeType.mid(len, n);
+
+ const int beginPos = mimeType.indexOf(QLatin1String(";index="));
+ if (beginPos > -1) {
+ const int endPos = mimeType.indexOf(QLatin1Char(';'), beginPos + 1);
+ const int indexStartPos = beginPos + 7;
+ if (lindex)
+ *lindex = mimeType.midRef(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt();
+ } else {
+ if (lindex)
+ *lindex = -1;
+ }
+ return ret;
}
bool QLastResortMimes::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
{
if (isCustomMimeType(mimeType)) {
+ // MSDN documentation for QueryGetData says only -1 is supported, so ignore lindex here.
QString clipFormat = customMimeType(mimeType);
int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
return canGetData(cf, pDataObj);
} else if (formats.keys(mimeType).isEmpty()) {
- // if it is not in there then register it an see if we can get it
+ // if it is not in there then register it and see if we can get it
int cf = QWindowsMime::registerMimeType(mimeType);
return canGetData(cf, pDataObj);
} else {
@@ -1370,9 +1383,10 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p
if (canConvertToMime(mimeType, pDataObj)) {
QByteArray data;
if (isCustomMimeType(mimeType)) {
- QString clipFormat = customMimeType(mimeType);
+ int lindex;
+ QString clipFormat = customMimeType(mimeType, &lindex);
int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
- data = getData(cf, pDataObj);
+ data = getData(cf, pDataObj, lindex);
} else if (formats.keys(mimeType).isEmpty()) {
int cf = QWindowsMime::registerMimeType(mimeType);
data = getData(cf, pDataObj);
@@ -1452,6 +1466,7 @@ QWindowsMime * QWindowsMimeConverter::converterToMime(const QString &mimeType, I
QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) const
{
+ qCDebug(lcQpaMime) << "QWindowsMime::allMimesForFormats()";
ensureInitialized();
QStringList formats;
LPENUMFORMATETC FAR fmtenum;
@@ -1461,10 +1476,9 @@ QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) con
FORMATETC fmtetc;
while (S_OK == fmtenum->Next(1, &fmtetc, 0)) {
#if defined(QMIME_DEBUG)
- qDebug("QWindowsMime::allMimesForFormats()");
wchar_t buf[256] = {0};
GetClipboardFormatName(fmtetc.cfFormat, buf, 255);
- qDebug("CF = %d : %s", fmtetc.cfFormat, QString::fromWCharArray(buf));
+ qDebug("CF = %d : %s", fmtetc.cfFormat, qPrintable(QString::fromWCharArray(buf)));
#endif
for (int i= m_mimes.size() - 1; i >= 0; --i) {
QString format = m_mimes.at(i)->mimeForFormat(fmtetc);
@@ -1478,7 +1492,7 @@ QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) con
}
fmtenum->Release();
}
- qCDebug(lcQpaMime) << __FUNCTION__ << pDataObj << formats;
+ qCDebug(lcQpaMime) << pDataObj << formats;
return formats;
}
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 12ecc53f92..b2f853f3e6 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -217,6 +217,13 @@ int QWindowsNativeInterface::registerMimeType(const QString &mimeType)
return QWindowsMime::registerMimeType(mimeType);
}
+QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &function) const
+{
+ if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
+ return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
+ return Q_NULLPTR;
+}
+
QVariant QWindowsNativeInterface::gpu() const
{
return GpuDescription::detect().toVariant();
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index 349ed28b1d..5c9e15fa35 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -88,6 +88,8 @@ public:
QVariant windowProperty(QPlatformWindow *window, const QString &name) const Q_DECL_OVERRIDE;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const Q_DECL_OVERRIDE;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) Q_DECL_OVERRIDE;
+
+ QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index ae8020a53e..2566f70436 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -462,7 +462,7 @@ void QWindowsScreenManager::removeScreen(int index)
if (movedWindowCount)
QWindowSystemInterface::flushWindowSystemEvents();
}
- delete m_screens.takeAt(index);
+ QWindowsIntegration::instance()->emitDestroyScreen(m_screens.takeAt(index));
}
/*!
@@ -497,6 +497,13 @@ bool QWindowsScreenManager::handleScreenChanges()
return true;
}
+void QWindowsScreenManager::clearScreens()
+{
+ // Delete screens in reverse order to avoid crash in case of multiple screens
+ while (!m_screens.isEmpty())
+ QWindowsIntegration::instance()->emitDestroyScreen(m_screens.takeLast());
+}
+
const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const
{
foreach (QWindowsScreen *scr, m_screens) {
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 28256f3000..ab0fecd970 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -127,11 +127,7 @@ public:
QWindowsScreenManager();
- inline void clearScreens() {
- // Delete screens in reverse order to avoid crash in case of multiple screens
- while (!m_screens.isEmpty())
- delete m_screens.takeLast();
- }
+ void clearScreens();
bool handleScreenChanges();
bool handleDisplayChange(WPARAM wParam, LPARAM lParam);
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 0216b40e3e..d9c5c97672 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -935,16 +935,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
#endif // QT_NO_OPENGL
updateDropSite();
-#ifndef Q_OS_WINCE
- if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
- && aWindow->type() != Qt::ForeignWindow) {
- if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0)) {
- setFlag(TouchRegistered);
- } else {
- qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(aWindow->objectName()));
- }
- }
-#endif // !Q_OS_WINCE
+ registerTouchWindow();
setWindowState(aWindow->windowState());
const qreal opacity = qt_window_private(aWindow)->opacity;
if (!qFuzzyCompare(opacity, qreal(1.0)))
@@ -2356,6 +2347,35 @@ void *QWindowsWindow::surface(void *nativeConfig)
#endif
}
+void QWindowsWindow::invalidateSurface()
+{
+ if (m_surface) {
+ if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
+ staticOpenGLContext->destroyWindowSurface(m_surface);
+ m_surface = 0;
+ }
+}
+
+void QWindowsWindow::setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes)
+{
+ if (!window->handle())
+ return;
+ static_cast<QWindowsWindow *>(window->handle())->registerTouchWindow(touchTypes);
+}
+
+void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes)
+{
+#ifndef Q_OS_WINCE
+ if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
+ && window()->type() != Qt::ForeignWindow) {
+ if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, (ULONG)touchTypes))
+ setFlag(TouchRegistered);
+ else
+ qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
+ }
+#endif // !Q_OS_WINCE
+}
+
void QWindowsWindow::aboutToMakeCurrent()
{
#ifndef QT_NO_OPENGL
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 6d6d473ccd..674f0ab00d 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -43,6 +43,7 @@
#include "qwindowsopenglcontext.h"
#include <qpa/qplatformwindow.h>
+#include <QtPlatformHeaders/qwindowswindowfunctions.h>
QT_BEGIN_NAMESPACE
@@ -251,6 +252,7 @@ public:
void setWindowIcon(const QIcon &icon);
void *surface(void *nativeConfig);
+ void invalidateSurface() Q_DECL_OVERRIDE;
void aboutToMakeCurrent();
#ifndef Q_OS_WINCE
@@ -260,6 +262,9 @@ public:
void stopAlertWindow();
#endif
+ static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes);
+ void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
+
private:
inline void show_sys() const;
inline void hide_sys() const;
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
index a41e5f8f38..41bd2e108d 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
@@ -80,6 +80,11 @@ QFont QWinRTFontDatabase::defaultFont() const
return QFont(QStringLiteral("Segoe UI"));
}
+bool QWinRTFontDatabase::fontsAlwaysScalable() const
+{
+ return true;
+}
+
void QWinRTFontDatabase::populateFontDatabase()
{
ComPtr<IDWriteFactory1> factory;
@@ -204,31 +209,7 @@ void QWinRTFontDatabase::populateFamily(const QString &familyName)
}
}
- QFont::Weight weight;
- switch (font->GetWeight()) {
- case DWRITE_FONT_WEIGHT_THIN:
- case DWRITE_FONT_WEIGHT_EXTRA_LIGHT:
- case DWRITE_FONT_WEIGHT_LIGHT:
- case DWRITE_FONT_WEIGHT_SEMI_LIGHT:
- weight = QFont::Light;
- break;
- default:
- case DWRITE_FONT_WEIGHT_NORMAL:
- case DWRITE_FONT_WEIGHT_MEDIUM:
- weight = QFont::Normal;
- break;
- case DWRITE_FONT_WEIGHT_DEMI_BOLD:
- weight = QFont::DemiBold;
- break;
- case DWRITE_FONT_WEIGHT_BOLD:
- case DWRITE_FONT_WEIGHT_EXTRA_BOLD:
- weight = QFont::Bold;
- break;
- case DWRITE_FONT_WEIGHT_BLACK:
- case DWRITE_FONT_WEIGHT_EXTRA_BLACK:
- weight = QFont::Black;
- break;
- }
+ QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(font->GetWeight());
QFont::Style style;
switch (font->GetStyle()) {
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.h b/src/plugins/platforms/winrt/qwinrtfontdatabase.h
index f0c4714911..cf8ed3b06a 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.h
+++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.h
@@ -53,9 +53,10 @@ class QWinRTFontDatabase : public QBasicFontDatabase
{
public:
QString fontDir() const;
- QFont defaultFont() const Q_DECL_OVERRIDE;
#ifdef QT_WINRT_USE_DWRITE
~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;
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
index f64b47960a..339a658c3e 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.cpp
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -170,7 +170,7 @@ QWinRTTheme::QWinRTTheme()
bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const
{
static bool useNativeDialogs = qEnvironmentVariableIsSet("QT_USE_WINRT_NATIVE_DIALOGS")
- ? qgetenv("QT_USE_WINRT_NATIVE_DIALOGS").toInt() : true;
+ ? qEnvironmentVariableIntValue("QT_USE_WINRT_NATIVE_DIALOGS") : true;
if (type == FileDialog || type == MessageDialog)
return useNativeDialogs;
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri
new file mode 100644
index 0000000000..56bc126652
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri
@@ -0,0 +1,13 @@
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/qxcbglintegration.h \
+ $$PWD/qxcbglintegrationfactory.h \
+ $$PWD/qxcbglintegrationplugin.h \
+ $$PWD/qxcbnativeinterfacehandler.h
+
+SOURCES += \
+ $$PWD/qxcbglintegrationfactory.cpp \
+ $$PWD/qxcbglintegration.cpp \
+ $$PWD/qxcbnativeinterfacehandler.cpp
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
new file mode 100644
index 0000000000..29fddeabd4
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
@@ -0,0 +1,9 @@
+TEMPLATE = subdirs
+
+contains(QT_CONFIG, egl):contains(QT_CONFIG, egl_x11) {
+ SUBDIRS += xcb_egl
+}
+
+contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, 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
new file mode 100644
index 0000000000..8c60268e0d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri
@@ -0,0 +1,38 @@
+QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
+
+INCLUDEPATH += $$PWD
+INCLUDEPATH += $$PWD/../
+
+# needed by Xcursor ...
+contains(QT_CONFIG, xcb-xlib) {
+ DEFINES += XCB_USE_XLIB
+ contains(QT_CONFIG, 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) {
+ 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) {
+ DEFINES += XCB_USE_RENDER
+ XCB_DIR = ../../../3rdparty/xcb
+ INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
+ LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
+} 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
+}
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp
new file mode 100644
index 0000000000..d864ee1198
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(QT_XCB_GLINTEGRATION, "qt.xcb.glintegration")
+
+QXcbGlIntegration::QXcbGlIntegration()
+{
+}
+QXcbGlIntegration::~QXcbGlIntegration()
+{
+}
+
+bool QXcbGlIntegration::handleXcbEvent(xcb_generic_event_t *event, uint responseType)
+{
+ Q_UNUSED(event);
+ Q_UNUSED(responseType);
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
new file mode 100644
index 0000000000..947ef15162
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLINTEGRATION_H
+
+#include "qxcbexport.h"
+#include "qxcbwindow.h"
+
+#include <QtCore/QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformOffscreenSurface;
+class QOffscreenSurface;
+class QXcbNativeInterfaceHandler;
+
+Q_XCB_EXPORT Q_DECLARE_LOGGING_CATEGORY(QT_XCB_GLINTEGRATION)
+
+class Q_XCB_EXPORT QXcbGlIntegration
+{
+public:
+ QXcbGlIntegration();
+ virtual ~QXcbGlIntegration();
+ virtual bool initialize(QXcbConnection *connection) = 0;
+
+ virtual bool supportsThreadedOpenGL() const { return false; }
+ virtual bool handleXcbEvent(xcb_generic_event_t *event, uint responseType);
+
+ virtual QXcbWindow *createWindow(QWindow *window) const = 0;
+ virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const = 0;
+ virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const = 0;
+
+ virtual QXcbNativeInterfaceHandler *nativeInterfaceHandler() const { return Q_NULLPTR; }
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
new file mode 100644
index 0000000000..c4546b990a
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationfactory.h"
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbglintegrationplugin.h"
+#include "private/qfactoryloader_p.h"
+#include "qguiapplication.h"
+#include "qdir.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QXcbGlIntegrationFactoryInterface_iid, QLatin1String("/xcbglintegrations"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QXcbGlIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+
+static inline QXcbGlIntegration *loadIntegration(QFactoryLoader *loader, const QString &key)
+{
+ const int index = loader->indexOf(key);
+ if (index != -1) {
+ if (QXcbGlIntegrationPlugin *factory = qobject_cast<QXcbGlIntegrationPlugin *>(loader->instance(index)))
+ if (QXcbGlIntegration *result = factory->create())
+ return result;
+ }
+ return Q_NULLPTR;
+}
+#endif // !QT_NO_LIBRARY
+
+QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList list;
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ list = directLoader()->keyMap().values();
+ if (!list.isEmpty()) {
+ const QString postFix = QStringLiteral(" (from ")
+ + QDir::toNativeSeparators(pluginPath)
+ + QLatin1Char(')');
+ const QStringList::iterator end = list.end();
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
+ (*it).append(postFix);
+ }
+ }
+ list.append(loader()->keyMap().values());
+ return list;
+#else
+ return QStringList();
+#endif
+}
+
+QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ // Try loading the plugin from platformPluginPath first:
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ if (QXcbGlIntegration *ret = loadIntegration(directLoader(), platform))
+ return ret;
+ }
+ if (QXcbGlIntegration *ret = loadIntegration(loader(), platform))
+ return ret;
+#endif
+ return Q_NULLPTR;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h
new file mode 100644
index 0000000000..d1fb91dee8
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLINTEGRATIONFACTORY_H
+#define QXCBGLINTEGRATIONFACTORY_H
+
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlIntegration;
+
+class QXcbGlIntegrationFactory
+{
+public:
+ static QStringList keys(const QString &pluginPath = QString());
+ static QXcbGlIntegration *create(const QString &name, const QString &platformPluginPath = QString());
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLINTEGRATIONFACTORY_H
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
new file mode 100644
index 0000000000..ef630a4fbe
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLINTEGRATIONPLUGIN_H
+#define QXCBGLINTEGRATIONPLUGIN_H
+
+#include "qxcbexport.h"
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+#define QXcbGlIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5"
+
+class QXcbGlIntegration;
+
+class Q_XCB_EXPORT QXcbGlIntegrationPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QXcbGlIntegrationPlugin(QObject *parent = 0)
+ : QObject(parent)
+ { }
+
+ virtual QXcbGlIntegration *create() = 0;
+};
+QT_END_NAMESPACE
+
+#endif //QXCBGLINTEGRATIONPLUGIN_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..b060c8649d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbnativeinterfacehandler.h"
+
+#include "qxcbnativeinterface.h"
+
+QT_BEGIN_NAMESPACE
+
+QXcbNativeInterfaceHandler::QXcbNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+ : m_native_interface(nativeInterface)
+{
+ m_native_interface->addHandler(this);
+}
+QXcbNativeInterfaceHandler::~QXcbNativeInterfaceHandler()
+{
+ m_native_interface->removeHandler(this);
+}
+
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForIntegration(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForScreen(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForBackingStore(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QFunctionPointer QXcbNativeInterfaceHandler::platformFunction(const QByteArray &function) const
+{
+ Q_UNUSED(function);
+ return Q_NULLPTR;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h
new file mode 100644
index 0000000000..3c239c443d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBNATIVEINTERFACEHANDLER_H
+#define QXCBNATIVEINTERFACEHANDLER_H
+
+#include <QtCore/QByteArray>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+
+#include "qxcbexport.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbNativeInterface;
+class Q_XCB_EXPORT QXcbNativeInterfaceHandler
+{
+public:
+ QXcbNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+ virtual ~QXcbNativeInterfaceHandler();
+
+ virtual QPlatformNativeInterface::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) const;
+
+ virtual QFunctionPointer platformFunction(const QByteArray &function) const;
+protected:
+ QXcbNativeInterface *m_native_interface;
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
new file mode 100644
index 0000000000..0dce728019
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLCONTEXT_H
+#define QXCBEGLCONTEXT_H
+
+#include "qxcbeglwindow.h"
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtPlatformHeaders/QEGLNativeContext>
+
+QT_BEGIN_NAMESPACE
+
+//####todo remove the noops (looks like their where there in the initial commit)
+class QXcbEglContext : public QEGLPlatformContext
+{
+public:
+ QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share,
+ EGLDisplay display, QXcbConnection *c, const QVariant &nativeHandle)
+ : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle)
+ , m_connection(c)
+ {
+ Q_XCB_NOOP(m_connection);
+ }
+
+ void swapBuffers(QPlatformSurface *surface)
+ {
+ Q_XCB_NOOP(m_connection);
+ QEGLPlatformContext::swapBuffers(surface);
+ Q_XCB_NOOP(m_connection);
+ }
+
+ bool makeCurrent(QPlatformSurface *surface)
+ {
+ Q_XCB_NOOP(m_connection);
+ bool ret = QEGLPlatformContext::makeCurrent(surface);
+ Q_XCB_NOOP(m_connection);
+ return ret;
+ }
+
+ void doneCurrent()
+ {
+ Q_XCB_NOOP(m_connection);
+ QEGLPlatformContext::doneCurrent();
+ Q_XCB_NOOP(m_connection);
+ }
+
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ {
+ if (surface->surface()->surfaceClass() == QSurface::Window)
+ return static_cast<QXcbEglWindow *>(surface)->eglSurface();
+ else
+ return static_cast<QEGLPbuffer *>(surface)->pbuffer();
+ }
+
+ QVariant nativeHandle() const {
+ return QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(eglContext(), eglDisplay()));
+ }
+
+private:
+ QXcbConnection *m_connection;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLCONTEXT_H
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
new file mode 100644
index 0000000000..bcde872423
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBINCLUDE_H
+#define QXCBINCLUDE_H
+
+#include <QtGui/QPalette>
+#include <QtCore/QTextStream>
+#include <QtGui/private/qmath_p.h>
+#include <QtGui/private/qcssparser_p.h>
+#include <QtGui/private/qtextengine_p.h>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+#endif //QXCBINCLUDE_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
new file mode 100644
index 0000000000..75b35f4fb8
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglintegration.h"
+
+#include "qxcbeglcontext.h"
+
+#include <QtGui/QOffscreenSurface>
+
+#include "qxcbeglnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+QXcbEglIntegration::QXcbEglIntegration()
+ : m_connection(Q_NULLPTR)
+ , m_egl_display(EGL_NO_DISPLAY)
+{
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration created";
+}
+
+QXcbEglIntegration::~QXcbEglIntegration()
+{
+ if (m_egl_display != EGL_NO_DISPLAY)
+ eglTerminate(m_egl_display);
+}
+
+bool QXcbEglIntegration::initialize(QXcbConnection *connection)
+{
+ m_connection = connection;
+
+#ifdef USE_XCB_XLIB
+ Display *dpy = (Display *)m_connection->xlib_display();
+#else
+ EGLNativeDisplayType dpy = EGL_DEFAULT_DISPLAY;
+#endif
+ m_egl_display = eglGetDisplay(dpy);
+
+ EGLint major, minor;
+ bool success = eglInitialize(m_egl_display, &major, &minor);
+ if (!success) {
+ m_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration retrying with display" << m_egl_display;
+ success = eglInitialize(m_egl_display, &major, &minor);
+ }
+
+ m_native_interface_handler.reset(new QXcbEglNativeInterfaceHandler(connection->nativeInterface()));
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration successfully initialized";
+ return success;
+}
+
+QXcbWindow *QXcbEglIntegration::createWindow(QWindow *window) const
+{
+ return new QXcbEglWindow(window, const_cast<QXcbEglIntegration *>(this));
+}
+
+QPlatformOpenGLContext *QXcbEglIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+ QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+ QXcbEglContext *platformContext = new QXcbEglContext(context->format(),
+ context->shareHandle(),
+ eglDisplay(),
+ screen->connection(),
+ context->nativeHandle());
+ context->setNativeHandle(platformContext->nativeHandle());
+ return platformContext;
+}
+
+QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ return new QEGLPbuffer(eglDisplay(), surface->requestedFormat(), surface);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h
new file mode 100644
index 0000000000..2a49cd0ca9
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLINTEGRATION_H
+#define QXCBEGLINTEGRATION_H
+
+#include "qxcbglintegration.h"
+
+#include "qxcbeglwindow.h"
+
+#include <QtGui/QOpenGLContext>
+#include <QtGui/qpa/qplatformscreen.h>
+#include <QtGui/QScreen>
+
+#include "qxcbscreen.h"
+
+#include "qxcbeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglNativeInterfaceHandler;
+
+class QXcbEglIntegration : public QXcbGlIntegration
+{
+public:
+ QXcbEglIntegration();
+ ~QXcbEglIntegration();
+
+ bool initialize(QXcbConnection *connection) Q_DECL_OVERRIDE;
+
+ QXcbWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
+
+ bool supportsThreadedOpenGL() const Q_DECL_OVERRIDE { return true; }
+
+ EGLDisplay eglDisplay() const { return m_egl_display; }
+ void *xlib_display() const { return m_connection->xlib_display(); }
+private:
+ QXcbConnection *m_connection;
+ EGLDisplay m_egl_display;
+
+ QScopedPointer<QXcbEglNativeInterfaceHandler> m_native_interface_handler;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp
new file mode 100644
index 0000000000..9feb8f31ca
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbeglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglIntegrationPlugin : public QXcbGlIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QXcbGlIntegrationFactoryInterface_iid FILE "xcb_egl.json")
+public:
+ QXcbGlIntegration *create()
+ {
+ return new QXcbEglIntegration();
+ }
+
+};
+
+QT_END_NAMESPACE
+
+#include "qxcbeglmain.moc"
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..9d06502158
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglnativeinterfacehandler.h"
+
+#include <QtGui/private/qguiapplication_p.h>
+#include "qxcbeglwindow.h"
+#include "qxcbintegration.h"
+#include "qxcbeglintegration.h"
+#include "qxcbeglcontext.h"
+
+QT_BEGIN_NAMESPACE
+
+static int resourceType(const QByteArray &key)
+{
+ static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
+ QByteArrayLiteral("egldisplay"),
+ QByteArrayLiteral("eglcontext"),
+ QByteArrayLiteral("eglconfig")
+ };
+ for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+ if (key == names[i])
+ return i;
+ }
+
+ if (key == QByteArrayLiteral("get_egl_context"))
+ return QXcbEglNativeInterfaceHandler::EglContext;
+
+ return sizeof(names) / sizeof(names[0]);
+}
+
+QXcbEglNativeInterfaceHandler::QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+ : QXcbNativeInterfaceHandler(nativeInterface)
+{
+}
+
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForIntegration(const QByteArray &resource) const{
+ switch (resourceType(resource)) {
+ case EglDisplay:
+ return eglDisplay;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case EglContext:
+ return eglContextForContext;
+ case EglConfig:
+ return eglConfigForContext;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case EglDisplay:
+ return eglDisplayForWindow;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbEglNativeInterfaceHandler::eglDisplay()
+{
+ QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->defaultConnection()->glIntegration());
+ return eglIntegration->eglDisplay();
+}
+
+void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
+{
+ Q_ASSERT(window);
+ if (window->supportsOpenGL() && window->handle() == Q_NULLPTR)
+ return eglDisplay();
+ else if (window->supportsOpenGL())
+ return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
+ return Q_NULLPTR;
+}
+
+void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ Q_ASSERT(context->handle());
+ return static_cast<QXcbEglContext *>(context->handle())->eglContext();
+}
+
+void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ Q_ASSERT(context->handle());
+ return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h
new file mode 100644
index 0000000000..7734bcd048
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLNATIVEINTERFACEHANDLER_H
+#define QXCBEGLNATIVEINTERFACEHANDLER_H
+
+#include "qxcbnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglNativeInterfaceHandler : public QXcbNativeInterfaceHandler
+{
+public:
+ enum ResourceType {
+ EglDisplay,
+ EglContext,
+ EglConfig
+ };
+
+ QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+
+ QPlatformNativeInterface::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const Q_DECL_OVERRIDE;
+ QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE;
+ QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const Q_DECL_OVERRIDE;
+private:
+ static void *eglDisplay();
+ static void *eglDisplayForWindow(QWindow *window);
+ static void *eglContextForContext(QOpenGLContext *context);
+ static void *eglConfigForContext(QOpenGLContext *context);
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBEGLNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
new file mode 100644
index 0000000000..61dd8d5069
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglwindow.h"
+
+#include "qxcbeglintegration.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QXcbEglWindow::QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration)
+ : QXcbWindow(window)
+ , m_glIntegration(glIntegration)
+ , m_config(Q_NULLPTR)
+ , m_surface(EGL_NO_SURFACE)
+{
+}
+
+QXcbEglWindow::~QXcbEglWindow()
+{
+ eglDestroySurface(m_glIntegration->eglDisplay(), m_surface);
+}
+
+void QXcbEglWindow::resolveFormat()
+{
+ m_config = q_configFromGLFormat(m_glIntegration->eglDisplay(), window()->requestedFormat(), true);
+ m_format = q_glFormatFromConfig(m_glIntegration->eglDisplay(), m_config, m_format);
+}
+
+void *QXcbEglWindow::createVisual()
+{
+ Display *xdpy = static_cast<Display *>(m_glIntegration->xlib_display());
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(xdpy, m_glIntegration->eglDisplay(), m_config);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(xdpy, VisualIDMask, &visualInfoTemplate, &matchingCount);
+ return visualInfo;
+}
+
+void QXcbEglWindow::create()
+{
+ QXcbWindow::create();
+
+ m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, 0);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h
new file mode 100644
index 0000000000..7d1a4c8e37
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLWINDOW_H
+#define QXCBEGLWINDOW_H
+
+#include "qxcbwindow.h"
+
+#include "qxcbeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglIntegration;
+
+class QXcbEglWindow : public QXcbWindow
+{
+public:
+ QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration);
+ ~QXcbEglWindow();
+
+ EGLSurface eglSurface() const { return m_surface; }
+
+ QXcbEglIntegration *glIntegration() const { return m_glIntegration; }
+
+protected:
+ void create() Q_DECL_OVERRIDE;
+ void resolveFormat() Q_DECL_OVERRIDE;
+ void *createVisual() Q_DECL_OVERRIDE;
+
+private:
+ QXcbEglIntegration *m_glIntegration;
+ EGLConfig m_config;
+ EGLSurface m_surface;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLWINDOW_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json
new file mode 100644
index 0000000000..6d6785691d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "xcb_egl" ]
+}
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
new file mode 100644
index 0000000000..082c22821a
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
@@ -0,0 +1,27 @@
+TARGET = qxcb-egl-integration
+
+PLUGIN_CLASS_NAME = QXcbEglIntegrationPlugin
+PLUGIN_TYPE = xcbglintegrations
+
+load(qt_plugin)
+
+include(../gl_integrations_plugin_base.pri)
+
+CONFIG += egl
+
+DEFINES += SUPPORT_X11
+#should be removed from sources
+DEFINES += XCB_USE_EGL XCB_USE_XLIB
+
+
+HEADERS += \
+ qxcbeglcontext.h \
+ qxcbeglintegration.h \
+ qxcbeglwindow.h \
+ qxcbeglnativeinterfacehandler.h
+
+SOURCES += \
+ qxcbeglintegration.cpp \
+ qxcbeglwindow.cpp \
+ qxcbeglmain.cpp \
+ qxcbeglnativeinterfacehandler.cpp
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index c0be836bce..c0be836bce 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
index 5777980093..73a17d69b4 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
@@ -54,14 +54,14 @@ public:
const QVariant &nativeHandle);
~QGLXContext();
- bool makeCurrent(QPlatformSurface *surface);
- void doneCurrent();
- void swapBuffers(QPlatformSurface *surface);
- void (*getProcAddress(const QByteArray &procName)) ();
+ bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void doneCurrent() Q_DECL_OVERRIDE;
+ void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void (*getProcAddress(const QByteArray &procName)) () Q_DECL_OVERRIDE;
- QSurfaceFormat format() const;
- bool isSharing() const;
- bool isValid() const;
+ QSurfaceFormat format() const Q_DECL_OVERRIDE;
+ bool isSharing() const Q_DECL_OVERRIDE;
+ bool isValid() const Q_DECL_OVERRIDE;
GLXContext glxContext() const { return m_context; }
GLXFBConfig glxConfig() const { return m_config; }
@@ -94,8 +94,8 @@ public:
explicit QGLXPbuffer(QOffscreenSurface *offscreenSurface);
~QGLXPbuffer();
- QSurfaceFormat format() const { return m_format; }
- bool isValid() const { return m_pbuffer != 0; }
+ QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; }
+ bool isValid() const Q_DECL_OVERRIDE { return m_pbuffer != 0; }
GLXPbuffer pbuffer() const { return m_pbuffer; }
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
new file mode 100644
index 0000000000..c8ea2053e3
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
@@ -0,0 +1,223 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglxintegration.h"
+
+#if defined(XCB_HAS_XCB_GLX)
+#include <xcb/glx.h>
+#endif
+
+#include "qxcbnativeinterface.h"
+#include "qxcbglxwindow.h"
+#include "qxcbscreen.h"
+#include "qglxintegration.h"
+
+#include <QtGui/QOpenGLContext>
+
+#include "qxcbglxnativeinterfacehandler.h"
+
+#include <X11/Xlibint.h>
+
+QT_BEGIN_NAMESPACE
+
+#if defined(XCB_HAS_XCB_GLX) && XCB_GLX_MAJOR_VERSION == 1 && XCB_GLX_MINOR_VERSION < 4
+
+#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
+
+typedef struct xcb_glx_buffer_swap_complete_event_t {
+ uint8_t response_type;
+ uint8_t pad0;
+ uint16_t sequence;
+ uint16_t event_type;
+ uint8_t pad1[2];
+ xcb_glx_drawable_t drawable;
+ uint32_t ust_hi;
+ uint32_t ust_lo;
+ uint32_t msc_hi;
+ uint32_t msc_lo;
+ uint32_t sbc;
+} xcb_glx_buffer_swap_complete_event_t;
+#endif
+
+#if defined(XCB_USE_XLIB) && defined(XCB_USE_GLX)
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable; /* drawable on which event was requested in event mask */
+ int event_type;
+ int64_t ust;
+ int64_t msc;
+ int64_t sbc;
+} QGLXBufferSwapComplete;
+#endif
+
+QXcbGlxIntegration::QXcbGlxIntegration()
+ : m_connection(Q_NULLPTR)
+ , m_glx_first_event(0)
+{
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb GLX gl-integration created";
+}
+
+QXcbGlxIntegration::~QXcbGlxIntegration()
+{
+}
+
+bool QXcbGlxIntegration::initialize(QXcbConnection *connection)
+{
+ m_connection = connection;
+#ifdef XCB_HAS_XCB_GLX
+
+ const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection->xcb_connection(), &xcb_glx_id);
+ if (!reply || !reply->present)
+ return false;
+
+ m_glx_first_event = reply->first_event;
+
+ xcb_generic_error_t *error = 0;
+ xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(m_connection->xcb_connection(),
+ XCB_GLX_MAJOR_VERSION,
+ XCB_GLX_MINOR_VERSION);
+ xcb_glx_query_version_reply_t *xglx_query = xcb_glx_query_version_reply(m_connection->xcb_connection(),
+ xglx_query_cookie, &error);
+ if (!xglx_query || error) {
+ qCWarning(QT_XCB_GLINTEGRATION) << "QXcbConnection: Failed to initialize GLX";
+ free(error);
+ return false;
+ }
+ free(xglx_query);
+#endif
+
+ m_native_interface_handler.reset(new QXcbGlxNativeInterfaceHandler(connection->nativeInterface()));
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb GLX gl-integration successfully initialized";
+ return true;
+}
+
+bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint responseType)
+{
+ bool handled = false;
+ // Check if a custom XEvent constructor was registered in xlib for this event type, and call it discarding the constructed XEvent if any.
+ // XESetWireToEvent might be used by libraries to intercept messages from the X server e.g. the OpenGL lib waiting for DRI2 events.
+ Display *xdisplay = static_cast<Display *>(m_connection->xlib_display());
+ XLockDisplay(xdisplay);
+ bool locked = true;
+ Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, 0);
+ if (proc) {
+ XESetWireToEvent(xdisplay, responseType, proc);
+ XEvent dummy;
+ event->sequence = LastKnownRequestProcessed(xdisplay);
+ if (proc(xdisplay, &dummy, (xEvent*)event)) {
+#ifdef XCB_HAS_XCB_GLX
+ // DRI2 clients don't receive GLXBufferSwapComplete events on the wire.
+ // Instead the GLX event is synthesized from the DRI2BufferSwapComplete event
+ // by DRI2WireToEvent(). For an application to be able to see the event
+ // we have to convert it to an xcb_glx_buffer_swap_complete_event_t and
+ // pass it to the native event filter.
+ const uint swap_complete = m_glx_first_event + XCB_GLX_BUFFER_SWAP_COMPLETE;
+ QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
+ if (dispatcher && uint(dummy.type) == swap_complete && responseType != swap_complete) {
+ QGLXBufferSwapComplete *xev = reinterpret_cast<QGLXBufferSwapComplete *>(&dummy);
+ xcb_glx_buffer_swap_complete_event_t ev;
+ memset(&ev, 0, sizeof(xcb_glx_buffer_swap_complete_event_t));
+ ev.response_type = xev->type;
+ ev.sequence = xev->serial;
+ ev.event_type = xev->event_type;
+ ev.drawable = xev->drawable;
+ ev.ust_hi = xev->ust >> 32;
+ ev.ust_lo = xev->ust & 0xffffffff;
+ ev.msc_hi = xev->msc >> 32;
+ ev.msc_lo = xev->msc & 0xffffffff;
+ ev.sbc = xev->sbc & 0xffffffff;
+ // Unlock the display before calling the native event filter
+ XUnlockDisplay(xdisplay);
+ locked = false;
+ QByteArray genericEventFilterType = m_connection->nativeInterface()->genericEventFilterType();
+ long result = 0;
+ handled = dispatcher->filterNativeEvent(genericEventFilterType, &ev, &result);
+ }
+#endif
+ }
+ }
+ if (locked)
+ XUnlockDisplay(xdisplay);
+ return handled;
+}
+
+QXcbWindow *QXcbGlxIntegration::createWindow(QWindow *window) const
+{
+ return new QXcbGlxWindow(window);
+}
+
+QPlatformOpenGLContext *QXcbGlxIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+ QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+ QGLXContext *platformContext = new QGLXContext(screen, context->format(),
+ context->shareHandle(), context->nativeHandle());
+ context->setNativeHandle(platformContext->nativeHandle());
+ return platformContext;
+}
+
+QPlatformOffscreenSurface *QXcbGlxIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ static bool vendorChecked = false;
+ static bool glxPbufferUsable = true;
+ if (!vendorChecked) {
+ vendorChecked = true;
+ const char *glxvendor = glXGetClientString(glXGetCurrentDisplay(), GLX_VENDOR);
+ if (glxvendor && !strcmp(glxvendor, "ATI"))
+ glxPbufferUsable = false;
+ }
+ if (glxPbufferUsable)
+ return new QGLXPbuffer(surface);
+ else
+ return 0; // trigger fallback to hidden QWindow
+
+}
+
+bool QXcbGlxIntegration::supportsThreadedOpenGL() const
+{
+ return QGLXContext::supportsThreading();
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h
new file mode 100644
index 0000000000..2869fc20a4
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLXINTEGRATION_H
+#define QXCBGLXINTEGRATION_H
+
+#include "qxcbglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbNativeInterfaceHandler;
+
+class QXcbGlxIntegration : public QXcbGlIntegration
+{
+public:
+ QXcbGlxIntegration();
+ ~QXcbGlxIntegration();
+
+ bool initialize(QXcbConnection *connection) Q_DECL_OVERRIDE;
+ bool handleXcbEvent(xcb_generic_event_t *event, uint responseType) Q_DECL_OVERRIDE;
+
+ QXcbWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
+
+ virtual bool supportsThreadedOpenGL() const Q_DECL_OVERRIDE;
+
+private:
+ QXcbConnection *m_connection;
+ uint32_t m_glx_first_event;
+
+ QScopedPointer<QXcbNativeInterfaceHandler> m_native_interface_handler;
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLXINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp
new file mode 100644
index 0000000000..93bb76f92f
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbglxintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlxIntegrationPlugin : public QXcbGlIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QXcbGlIntegrationFactoryInterface_iid FILE "xcb_glx.json")
+public:
+ QXcbGlIntegration *create()
+ {
+ return new QXcbGlxIntegration();
+ }
+
+};
+
+QT_END_NAMESPACE
+
+#include "qxcbglxmain.moc"
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..6cdd4101e0
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglxnativeinterfacehandler.h"
+
+#include "qglxintegration.h"
+#include <QtGui/QOpenGLContext>
+QT_BEGIN_NAMESPACE
+
+static int resourceType(const QByteArray &key)
+{
+ static const QByteArray names[] = { // match QXcbGlxNativeInterfaceHandler::ResourceType
+ QByteArrayLiteral("glxconfig"),
+ QByteArrayLiteral("glxcontext"),
+ };
+ for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+ if (key == names[i])
+ return i;
+ }
+
+ return sizeof(names) / sizeof(names[0]);
+}
+
+QXcbGlxNativeInterfaceHandler::QXcbGlxNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+ : QXcbNativeInterfaceHandler(nativeInterface)
+{
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbGlxNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case GLXConfig:
+ return glxConfigForContext;
+ case GLXContext:
+ return glxContextForContext;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbGlxNativeInterfaceHandler::glxContextForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
+ return glxPlatformContext->glxContext();
+}
+
+void *QXcbGlxNativeInterfaceHandler::glxConfigForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
+ return glxPlatformContext->glxConfig();
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h
new file mode 100644
index 0000000000..e9df28ea39
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLXNATIVEINTERFACEHANDLER_H
+#define QXCBGLXNATIVEINTERFACEHANDLER_H
+
+#include "qxcbnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlxNativeInterfaceHandler : public QXcbNativeInterfaceHandler
+{
+public:
+ enum ResourceType {
+ GLXConfig,
+ GLXContext,
+ };
+
+ QXcbGlxNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+ QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE;
+
+private:
+ static void *glxContextForContext(QOpenGLContext *context);
+ static void *glxConfigForContext(QOpenGLContext *context);
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLXNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
new file mode 100644
index 0000000000..8d5bfb13d3
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglxwindow.h"
+
+#include "qxcbscreen.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QXcbGlxWindow::QXcbGlxWindow(QWindow *window)
+ : QXcbWindow(window)
+{
+}
+
+QXcbGlxWindow::~QXcbGlxWindow()
+{
+}
+
+void QXcbGlxWindow::resolveFormat()
+{
+ m_format = window()->requestedFormat(); //qglx_findVisualInfo sets the resovled format
+}
+
+void *QXcbGlxWindow::createVisual()
+{
+ QXcbScreen *scr = xcbScreen();
+ if (!scr)
+ return Q_NULLPTR;
+ return qglx_findVisualInfo(DISPLAY_FROM_XCB(scr), scr->screenNumber(), &m_format);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h
new file mode 100644
index 0000000000..bb7cd7bef2
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLXWINDOW_H
+#define QXCBGLXWINDOW_H
+
+#include "qxcbglxintegration.h"
+#include "qxcbwindow.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlxWindow : public QXcbWindow
+{
+public:
+ QXcbGlxWindow(QWindow *window);
+ ~QXcbGlxWindow();
+
+protected:
+ void resolveFormat() Q_DECL_OVERRIDE;
+ void *createVisual() Q_DECL_OVERRIDE;
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLXWINDOW_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json
new file mode 100644
index 0000000000..1e2641ae7c
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "xcb_glx" ]
+}
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
new file mode 100644
index 0000000000..57cd81ec3b
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
@@ -0,0 +1,31 @@
+TARGET = qxcb-glx-integration
+
+PLUGIN_CLASS_NAME = QXcbGlxIntegrationPlugin
+PLUGIN_TYPE = xcbglintegrations
+
+load(qt_plugin)
+
+include(../gl_integrations_plugin_base.pri)
+
+#should be removed from the sources
+DEFINES += XCB_USE_GLX XCB_USE_XLIB
+
+LIBS += -lxcb
+
+contains(QT_CONFIG, xcb-glx) {
+ DEFINES += XCB_HAS_XCB_GLX
+ LIBS += -lxcb-glx
+}
+
+HEADERS += \
+ qxcbglxintegration.h \
+ qxcbglxwindow.h \
+ qglxintegration.h \
+ qxcbglxnativeinterfacehandler.h
+
+SOURCES += \
+ qxcbglxmain.cpp \
+ qxcbglxintegration.cpp \
+ qxcbglxwindow.cpp \
+ qglxintegration.cpp \
+ qxcbglxnativeinterfacehandler.cpp
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index f4382c7b50..bbde948090 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -49,6 +49,7 @@
#include <qdebug.h>
#include <qpainter.h>
#include <qscreen.h>
+#include <qpa/qplatformgraphicsbuffer.h>
#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,8 @@ public:
~QXcbShmImage() { destroy(); }
QImage *image() { return &m_qimage; }
+ QPlatformGraphicsBuffer *graphicsBuffer() { return m_graphics_buffer; }
+
QSize size() const { return m_qimage.size(); }
void put(xcb_window_t window, const QPoint &dst, const QRect &source);
@@ -73,6 +76,7 @@ private:
xcb_image_t *m_xcb_image;
QImage m_qimage;
+ QPlatformGraphicsBuffer *m_graphics_buffer;
xcb_gcontext_t m_gc;
xcb_window_t m_gc_window;
@@ -80,8 +84,39 @@ private:
QRegion m_dirty;
};
+class QXcbShmGraphicsBuffer : public QPlatformGraphicsBuffer
+{
+public:
+ QXcbShmGraphicsBuffer(QImage *image)
+ : QPlatformGraphicsBuffer(image->size(), QImage::toPixelFormat(image->format()))
+ , m_access_lock(QPlatformGraphicsBuffer::None)
+ , m_image(image)
+ { }
+
+ bool doLock(AccessTypes access, const QRect &rect) Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(rect);
+ if (access & ~(QPlatformGraphicsBuffer::SWReadAccess | QPlatformGraphicsBuffer::SWWriteAccess))
+ return false;
+
+ m_access_lock |= access;
+ return true;
+ }
+ void doUnlock() Q_DECL_OVERRIDE { m_access_lock = None; }
+
+ const uchar *data() const Q_DECL_OVERRIDE { return m_image->bits(); }
+ uchar *data() Q_DECL_OVERRIDE { return m_image->bits(); }
+ int bytesPerLine() const Q_DECL_OVERRIDE { return m_image->bytesPerLine(); }
+
+ Origin origin() const Q_DECL_OVERRIDE { return QPlatformGraphicsBuffer::OriginTopLeft; }
+private:
+ AccessTypes m_access_lock;
+ QImage *m_image;
+};
+
QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QImage::Format format)
: QXcbObject(screen->connection())
+ , m_graphics_buffer(Q_NULLPTR)
, m_gc(0)
, m_gc_window(0)
{
@@ -137,6 +172,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
}
m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
+ m_graphics_buffer = new QXcbShmGraphicsBuffer(&m_qimage);
}
void QXcbShmImage::destroy()
@@ -158,6 +194,8 @@ void QXcbShmImage::destroy()
if (m_gc)
Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc));
+ delete m_graphics_buffer;
+ m_graphics_buffer = Q_NULLPTR;
}
void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source)
@@ -287,10 +325,17 @@ void QXcbBackingStore::beginPaint(const QRegion &region)
}
}
+#ifndef QT_NO_OPENGL
QImage QXcbBackingStore::toImage() const
{
return m_image && m_image->image() ? *m_image->image() : QImage();
}
+#endif
+
+QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const
+{
+ return m_image ? m_image->graphicsBuffer() : Q_NULLPTR;
+}
void QXcbBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h
index 38fb5a7ae4..aa2c953983 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.h
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.h
@@ -50,18 +50,21 @@ public:
QXcbBackingStore(QWindow *widget);
~QXcbBackingStore();
- QPaintDevice *paintDevice();
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
#ifndef QT_NO_OPENGL
void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, QOpenGLContext *context,
- bool translucentBackground);
+ bool translucentBackground) Q_DECL_OVERRIDE;
+ QImage toImage() const Q_DECL_OVERRIDE;
#endif
- QImage toImage() const;
- void resize(const QSize &size, const QRegion &staticContents);
- bool scroll(const QRegion &area, int dx, int dy);
- void beginPaint(const QRegion &);
+ QPlatformGraphicsBuffer *graphicsBuffer() const Q_DECL_OVERRIDE;
+
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
+ bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE;
+
+ void beginPaint(const QRegion &) Q_DECL_OVERRIDE;
private:
QXcbShmImage *m_image;
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index f56a29d985..1c798a96bb 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -84,7 +84,7 @@ public:
}
protected:
- QStringList formats_sys() const
+ QStringList formats_sys() const Q_DECL_OVERRIDE
{
if (isEmpty())
return QStringList();
@@ -114,13 +114,13 @@ protected:
return formatList;
}
- bool hasFormat_sys(const QString &format) const
+ bool hasFormat_sys(const QString &format) const Q_DECL_OVERRIDE
{
QStringList list = formats();
return list.contains(format);
}
- QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const Q_DECL_OVERRIDE
{
if (fmt.isEmpty() || isEmpty())
return QByteArray();
@@ -232,7 +232,7 @@ public:
}
protected:
- void timerEvent(QTimerEvent *ev)
+ void timerEvent(QTimerEvent *ev) Q_DECL_OVERRIDE
{
if (ev->timerId() == abort_timer) {
// this can happen when the X client we are sending data
@@ -276,7 +276,7 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME;
- m_screen = connection()->primaryScreen();
+ QXcbScreen *platformScreen = screen();
int x = 0, y = 0, w = 3, h = 3;
@@ -284,11 +284,11 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
m_owner, // window id
- m_screen->screen()->root, // parent window id
+ platformScreen->screen()->root, // parent window id
x, y, w, h,
0, // border width
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
- m_screen->screen()->root_visual, // visual
+ platformScreen->screen()->root_visual, // visual
0, // value mask
0)); // value list
#ifndef QT_NO_DEBUG
@@ -462,9 +462,16 @@ bool QXcbClipboard::ownsMode(QClipboard::Mode mode) const
return m_timestamp[mode] != XCB_CURRENT_TIME;
}
+QXcbScreen *QXcbClipboard::screen() const
+{
+ return connection()->primaryScreen();
+}
+
xcb_window_t QXcbClipboard::requestor() const
{
- if (!m_requestor) {
+ QXcbScreen *platformScreen = screen();
+
+ if (!m_requestor && platformScreen) {
const int x = 0, y = 0, w = 3, h = 3;
QXcbClipboard *that = const_cast<QXcbClipboard *>(this);
@@ -472,11 +479,11 @@ xcb_window_t QXcbClipboard::requestor() const
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
window, // window id
- m_screen->screen()->root, // parent window id
+ platformScreen->screen()->root, // parent window id
x, y, w, h,
0, // border width
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
- m_screen->screen()->root_visual, // visual
+ platformScreen->screen()->root_visual, // visual
0, // value mask
0)); // value list
#ifndef QT_NO_DEBUG
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h
index e76d502691..a12464928c 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.h
+++ b/src/plugins/platforms/xcb/qxcbclipboard.h
@@ -53,13 +53,13 @@ public:
QXcbClipboard(QXcbConnection *connection);
~QXcbClipboard();
- QMimeData *mimeData(QClipboard::Mode mode);
- void setMimeData(QMimeData *data, QClipboard::Mode mode);
+ QMimeData *mimeData(QClipboard::Mode mode) Q_DECL_OVERRIDE;
+ void setMimeData(QMimeData *data, QClipboard::Mode mode) Q_DECL_OVERRIDE;
- bool supportsMode(QClipboard::Mode mode) const;
- bool ownsMode(QClipboard::Mode mode) const;
+ bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE;
+ bool ownsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE;
- QXcbScreen *screen() const { return m_screen; }
+ QXcbScreen *screen() const;
xcb_window_t requestor() const;
void setRequestor(xcb_window_t window);
@@ -91,8 +91,6 @@ private:
xcb_atom_t atomForMode(QClipboard::Mode mode) const;
QClipboard::Mode modeForAtom(xcb_atom_t atom) const;
- QXcbScreen *m_screen;
-
// Selection and Clipboard
QXcbClipboardMime *m_xClipboard[2];
QMimeData *m_clientClipboard[2];
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 5510c3b1b4..48cf366d28 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -44,6 +44,8 @@
#include "qxcbnativeinterface.h"
#include "qxcbintegration.h"
#include "qxcbsystemtraytracker.h"
+#include "qxcbglintegrationfactory.h"
+#include "qxcbglintegration.h"
#include <QSocketNotifier>
#include <QAbstractEventDispatcher>
@@ -74,14 +76,6 @@
#include <xcb/render.h>
#endif
-#if defined(XCB_HAS_XCB_GLX)
-#include <xcb/glx.h>
-#endif
-
-#ifdef XCB_USE_EGL //don't pull in eglext prototypes
-#include <EGL/egl.h>
-#endif
-
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input")
@@ -121,39 +115,6 @@ static int ioErrorHandler(Display *dpy)
}
#endif
-#if defined(XCB_HAS_XCB_GLX) && XCB_GLX_MAJOR_VERSION == 1 && XCB_GLX_MINOR_VERSION < 4
-
-#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
-
-typedef struct xcb_glx_buffer_swap_complete_event_t {
- uint8_t response_type;
- uint8_t pad0;
- uint16_t sequence;
- uint16_t event_type;
- uint8_t pad1[2];
- xcb_glx_drawable_t drawable;
- uint32_t ust_hi;
- uint32_t ust_lo;
- uint32_t msc_hi;
- uint32_t msc_lo;
- uint32_t sbc;
-} xcb_glx_buffer_swap_complete_event_t;
-#endif
-
-#if defined(XCB_USE_XLIB) && defined(XCB_USE_GLX)
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Drawable drawable; /* drawable on which event was requested in event mask */
- int event_type;
- int64_t ust;
- int64_t msc;
- int64_t sbc;
-} QGLXBufferSwapComplete;
-#endif
-
QXcbScreen* QXcbConnection::findOrCreateScreen(QList<QXcbScreen *>& newScreens,
int screenNumber, xcb_screen_t* xcbScreen, xcb_randr_get_output_info_reply_t *output)
{
@@ -166,7 +127,7 @@ QXcbScreen* QXcbConnection::findOrCreateScreen(QList<QXcbScreen *>& newScreens,
int dotPos = displayName.lastIndexOf('.');
if (dotPos != -1)
displayName.truncate(dotPos);
- name = displayName + QLatin1Char('.') + QString::number(screenNumber);
+ name = QString::fromLocal8Bit(displayName) + QLatin1Char('.') + QString::number(screenNumber);
}
foreach (QXcbScreen* scr, m_screens)
if (scr->name() == name && scr->root() == xcbScreen->root)
@@ -279,11 +240,12 @@ void QXcbConnection::updateScreens()
++xcbScreenNumber;
} // for each xcb screen
+ QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
// Now activeScreens is the complete set of screens which are active at this time.
// Delete any existing screens which are not in activeScreens
for (int i = m_screens.count() - 1; i >= 0; --i) {
if (!activeScreens.contains(m_screens[i])) {
- delete m_screens[i];
+ integration->destroyScreen(m_screens.at(i));
m_screens.removeAt(i);
}
}
@@ -300,7 +262,7 @@ void QXcbConnection::updateScreens()
// Now that they are in the right order, emit the added signals for new screens only
foreach (QXcbScreen* screen, m_screens)
if (newScreens.contains(screen))
- ((QXcbIntegration*)QGuiApplicationPrivate::platformIntegration())->screenAdded(screen);
+ integration->screenAdded(screen);
}
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, const char *displayName)
@@ -309,11 +271,12 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_primaryScreenNumber(0)
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface)
+#ifdef XCB_USE_XLIB
+ , m_xlib_display(0)
+#endif
, xfixes_first_event(0)
, xrandr_first_event(0)
, xkb_first_event(0)
- , glx_first_event(0)
- , has_glx_extension(false)
, has_shape_extension(false)
, has_randr_extension(false)
, has_input_shape(false)
@@ -322,14 +285,10 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_buttons(0)
, m_focusWindow(0)
, m_systemTrayTracker(0)
+ , m_glIntegration(Q_NULLPTR)
{
-#ifdef XCB_USE_EGL
- EGLNativeDisplayType dpy = EGL_DEFAULT_DISPLAY;
-#elif defined(XCB_USE_XLIB)
- Display *dpy;
-#endif
#ifdef XCB_USE_XLIB
- dpy = XOpenDisplay(m_displayName.constData());
+ Display *dpy = XOpenDisplay(m_displayName.constData());
if (dpy) {
m_primaryScreenNumber = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy);
@@ -345,12 +304,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_connection || xcb_connection_has_error(m_connection))
qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData());
-#ifdef XCB_USE_EGL
- EGLDisplay eglDisplay = eglGetDisplay(dpy);
- m_egl_display = eglDisplay;
- EGLint major, minor;
- m_has_egl = eglInitialize(eglDisplay, &major, &minor);
-#endif //XCB_USE_EGL
m_reader = new QXcbEventReader(this);
m_reader->start();
@@ -363,9 +316,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
#ifdef XCB_USE_RENDER
&xcb_render_id,
#endif
-#ifdef XCB_HAS_XCB_GLX
- &xcb_glx_id,
-#endif
0
};
@@ -382,7 +332,9 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeXRandr();
updateScreens();
- initializeGLX();
+ if (m_screens.isEmpty())
+ qFatal("QXcbConnection: no screens available");
+
initializeXFixes();
initializeXRender();
m_xi2Enabled = false;
@@ -405,6 +357,27 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_startupId.isNull())
qunsetenv("DESKTOP_STARTUP_ID");
+
+ QStringList glIntegrationNames;
+ glIntegrationNames << QStringLiteral("xcb_glx") << QStringLiteral("xcb_egl");
+ QString glIntegrationName = QString::fromLocal8Bit(qgetenv("QT_XCB_GL_INTEGRATION"));
+ if (glIntegrationName.size()) {
+ glIntegrationNames.removeAll(glIntegrationName);
+ glIntegrationNames.prepend(glIntegrationName);
+ }
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Choosing xcb gl-integration based on following priority\n" << glIntegrationNames;
+ for (int i = 0; i < glIntegrationNames.size() && !m_glIntegration; i++) {
+ m_glIntegration = QXcbGlIntegrationFactory::create(glIntegrationNames.at(i));
+ if (m_glIntegration && !m_glIntegration->initialize(this)) {
+ qCDebug(QT_XCB_GLINTEGRATION) << "Failed to initialize xcb gl-integration" << glIntegrationNames.at(i);
+ delete m_glIntegration;
+ m_glIntegration = Q_NULLPTR;
+ }
+ }
+ if (!m_glIntegration)
+ qCDebug(QT_XCB_GLINTEGRATION) << "Failed to create xcb gl-integration";
+
sync();
if (qEnvironmentVariableIsEmpty("QT_IM_MODULE"))
@@ -431,14 +404,12 @@ QXcbConnection::~QXcbConnection()
delete m_reader;
+ QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
// Delete screens in reverse order to avoid crash in case of multiple screens
while (!m_screens.isEmpty())
- delete m_screens.takeLast();
+ integration->destroyScreen(m_screens.takeLast());
-#ifdef XCB_USE_EGL
- if (m_has_egl)
- eglTerminate(m_egl_display);
-#endif //XCB_USE_EGL
+ delete m_glIntegration;
#ifdef XCB_USE_XLIB
XCloseDisplay((Display *)m_xlib_display);
@@ -990,51 +961,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
}
}
-#ifdef XCB_USE_XLIB
- if (!handled) {
- // Check if a custom XEvent constructor was registered in xlib for this event type, and call it discarding the constructed XEvent if any.
- // XESetWireToEvent might be used by libraries to intercept messages from the X server e.g. the OpenGL lib waiting for DRI2 events.
- Display *xdisplay = (Display *)m_xlib_display;
- XLockDisplay(xdisplay);
- bool locked = true;
- Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, response_type, 0);
- if (proc) {
- XESetWireToEvent(xdisplay, response_type, proc);
- XEvent dummy;
- event->sequence = LastKnownRequestProcessed(m_xlib_display);
- if (proc(xdisplay, &dummy, (xEvent*)event)) {
-#if defined(XCB_USE_GLX) && defined(XCB_HAS_XCB_GLX)
- // DRI2 clients don't receive GLXBufferSwapComplete events on the wire.
- // Instead the GLX event is synthesized from the DRI2BufferSwapComplete event
- // by DRI2WireToEvent(). For an application to be able to see the event
- // we have to convert it to an xcb_glx_buffer_swap_complete_event_t and
- // pass it to the native event filter.
- const uint swap_complete = glx_first_event + XCB_GLX_BUFFER_SWAP_COMPLETE;
- if (dispatcher && has_glx_extension && uint(dummy.type) == swap_complete && response_type != swap_complete) {
- QGLXBufferSwapComplete *xev = reinterpret_cast<QGLXBufferSwapComplete *>(&dummy);
- xcb_glx_buffer_swap_complete_event_t ev;
- memset(&ev, 0, sizeof(xcb_glx_buffer_swap_complete_event_t));
- ev.response_type = xev->type;
- ev.sequence = xev->serial;
- ev.event_type = xev->event_type;
- ev.drawable = xev->drawable;
- ev.ust_hi = xev->ust >> 32;
- ev.ust_lo = xev->ust & 0xffffffff;
- ev.msc_hi = xev->msc >> 32;
- ev.msc_lo = xev->msc & 0xffffffff;
- ev.sbc = xev->sbc & 0xffffffff;
- // Unlock the display before calling the native event filter
- XUnlockDisplay(xdisplay);
- locked = false;
- handled = dispatcher->filterNativeEvent(m_nativeInterface->genericEventFilterType(), &ev, &result);
- }
-#endif
- }
- }
- if (locked)
- XUnlockDisplay(xdisplay);
- }
-#endif
+ if (!handled)
+ handled = m_glIntegration->handleXcbEvent(event, response_type);
if (handled)
printXcbEvent("Handled XCB event", event);
@@ -1232,6 +1160,13 @@ xcb_window_t QXcbConnection::rootWindow()
return primaryScreen()->root();
}
+#ifdef XCB_USE_XLIB
+void *QXcbConnection::xlib_display() const
+{
+ return m_xlib_display;
+}
+#endif
+
void QXcbConnection::processXcbEvents()
{
int connection_error = xcb_connection_has_error(xcb_connection());
@@ -1674,34 +1609,6 @@ void QXcbConnection::initializeXRender()
#endif
}
-void QXcbConnection::initializeGLX()
-{
-#ifdef XCB_HAS_XCB_GLX
- const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_glx_id);
- if (!reply || !reply->present)
- return;
-
- has_glx_extension = true;
- glx_first_event = reply->first_event;
-
- xcb_generic_error_t *error = 0;
- xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(m_connection,
- XCB_GLX_MAJOR_VERSION,
- XCB_GLX_MINOR_VERSION);
- xcb_glx_query_version_reply_t *xglx_query = xcb_glx_query_version_reply(m_connection,
- xglx_query_cookie, &error);
- if (!xglx_query || error) {
- qWarning("QXcbConnection: Failed to initialize GLX");
- free(error);
- has_glx_extension = false;
- }
- free(xglx_query);
-#else
- // no way to check, assume GLX is present
- has_glx_extension = true;
-#endif
-}
-
void QXcbConnection::initializeXRandr()
{
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_randr_id);
@@ -1811,13 +1718,6 @@ void QXcbConnection::initializeXKB()
#endif
}
-#if defined(XCB_USE_EGL)
-bool QXcbConnection::hasEgl() const
-{
- return m_has_egl;
-}
-#endif // defined(XCB_USE_EGL)
-
#if defined(XCB_USE_XINPUT2)
static int xi2ValuatorOffset(unsigned char *maskPtr, int maskLen, int number)
{
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 7286b6b89b..18fc8113e1 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -36,6 +36,7 @@
#include <xcb/xcb.h>
+#include "qxcbexport.h"
#include <QHash>
#include <QList>
#include <QMutex>
@@ -85,6 +86,7 @@ class QXcbClipboard;
class QXcbWMSupport;
class QXcbNativeInterface;
class QXcbSystemTrayTracker;
+class QXcbGlIntegration;
namespace QXcbAtom {
enum Atom {
@@ -295,7 +297,7 @@ class QXcbEventReader : public QThread
public:
QXcbEventReader(QXcbConnection *connection);
- void run();
+ void run() Q_DECL_OVERRIDE;
QXcbEventArray *lock();
void unlock();
@@ -360,7 +362,7 @@ private:
};
class QAbstractEventDispatcher;
-class QXcbConnection : public QObject
+class Q_XCB_EXPORT QXcbConnection : public QObject
{
Q_OBJECT
public:
@@ -395,15 +397,9 @@ public:
QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); }
xcb_window_t rootWindow();
#ifdef XCB_USE_XLIB
- void *xlib_display() const { return m_xlib_display; }
+ void *xlib_display() const;
#endif
-#ifdef XCB_USE_EGL
- bool hasEgl() const;
-#endif
-#if defined(XCB_USE_EGL)
- void *egl_display() const { return m_egl_display; }
-#endif
#if defined(XCB_USE_XINPUT2)
void xi2Select(xcb_window_t window);
#endif
@@ -437,7 +433,6 @@ public:
inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; }
- bool hasGLX() const { return has_glx_extension; }
bool hasXFixes() const { return xfixes_first_event > 0; }
bool hasXShape() const { return has_shape_extension; }
bool hasXRandr() const { return has_randr_extension; }
@@ -446,6 +441,7 @@ public:
bool hasXKB() const { return has_xkb; }
bool supportsThreadedRendering() const { return m_reader->isRunning(); }
+ bool threadedEventHandling() const { return m_reader->isRunning(); }
xcb_timestamp_t getTimestamp();
@@ -472,6 +468,8 @@ public:
QXcbEventReader *eventReader() const { return m_reader; }
bool canGrab() const { return m_canGrabServer; }
+
+ QXcbGlIntegration *glIntegration() const { return m_glIntegration; }
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
@@ -484,7 +482,6 @@ private slots:
private:
void initializeAllAtoms();
void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0);
- void initializeGLX();
void initializeXFixes();
void initializeXRender();
void initializeXRandr();
@@ -580,10 +577,6 @@ private:
QHash<int, QWindowSystemInterface::TouchPoint> m_touchPoints;
QHash<int, XInput2TouchDeviceData*> m_touchDevices;
#endif
-#if defined(XCB_USE_EGL)
- void *m_egl_display;
- bool m_has_egl;
-#endif
#ifdef Q_XCB_DEBUG
struct CallInfo {
int sequence;
@@ -604,9 +597,7 @@ private:
uint32_t xfixes_first_event;
uint32_t xrandr_first_event;
uint32_t xkb_first_event;
- uint32_t glx_first_event;
- bool has_glx_extension;
bool has_shape_extension;
bool has_randr_extension;
bool has_input_shape;
@@ -619,6 +610,7 @@ private:
QByteArray m_startupId;
QXcbSystemTrayTracker *m_systemTrayTracker;
+ QXcbGlIntegration *m_glIntegration;
friend class QXcbEventReader;
};
@@ -668,11 +660,6 @@ cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection,
#define Q_XCB_NOOP(c)
#endif
-
-#if defined(XCB_USE_EGL)
-#define EGL_DISPLAY_FROM_XCB(object) ((EGLDisplay)(object->connection()->egl_display()))
-#endif
-
QT_END_NAMESPACE
#endif
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 90d323ed34..8a9e7a55c0 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -355,8 +355,11 @@ void QXcbConnection::xi2Select(xcb_window_t window)
XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
{
- XInput2TouchDeviceData *dev = m_touchDevices[id];
- if (!dev) {
+ XInput2TouchDeviceData *dev = Q_NULLPTR;
+ QHash<int, XInput2TouchDeviceData*>::const_iterator devIt = m_touchDevices.find(id);
+ if ( devIt != m_touchDevices.end() ) {
+ dev = devIt.value();
+ } else {
int nrDevices = 0;
QTouchDevice::Capabilities caps = 0;
dev = new XInput2TouchDeviceData;
@@ -420,7 +423,7 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
}
if (type >= QTouchDevice::TouchScreen && type <= QTouchDevice::TouchPad) {
dev->qtTouchDevice = new QTouchDevice;
- dev->qtTouchDevice->setName(dev->xiDeviceInfo->name);
+ dev->qtTouchDevice->setName(QString::fromUtf8(dev->xiDeviceInfo->name));
dev->qtTouchDevice->setType((QTouchDevice::DeviceType)type);
dev->qtTouchDevice->setCapabilities(caps);
dev->qtTouchDevice->setMaximumTouchPoints(maxTouchPoints);
@@ -428,7 +431,6 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
QWindowSystemInterface::registerTouchDevice(dev->qtTouchDevice);
m_touchDevices[id] = dev;
} else {
- m_touchDevices.remove(id);
XIFreeDeviceInfo(dev->xiDeviceInfo);
delete dev;
dev = 0;
diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h
index 8ed23154ed..8f03f01747 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.h
+++ b/src/plugins/platforms/xcb/qxcbcursor.h
@@ -70,10 +70,10 @@ public:
QXcbCursor(QXcbConnection *conn, QXcbScreen *screen);
~QXcbCursor();
#ifndef QT_NO_CURSOR
- void changeCursor(QCursor *cursor, QWindow *widget);
+ void changeCursor(QCursor *cursor, QWindow *widget) Q_DECL_OVERRIDE;
#endif
- QPoint pos() const;
- void setPos(const QPoint &pos);
+ QPoint pos() const Q_DECL_OVERRIDE;
+ void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
static void queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0);
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index ec0399ed5f..9944f54780 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -117,9 +117,9 @@ public:
~QXcbDropData();
protected:
- bool hasFormat_sys(const QString &mimeType) const;
- QStringList formats_sys() const;
- QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
+ bool hasFormat_sys(const QString &mimeType) const Q_DECL_OVERRIDE;
+ QStringList formats_sys() const Q_DECL_OVERRIDE;
+ QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const Q_DECL_OVERRIDE;
QVariant xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const;
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h
index 63a344a098..b5188fd41c 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.h
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -68,7 +68,7 @@ public:
QXcbDrag(QXcbConnection *c);
~QXcbDrag();
- virtual QMimeData *platformDropData();
+ virtual QMimeData *platformDropData() Q_DECL_OVERRIDE;
void startDrag() Q_DECL_OVERRIDE;
void cancel() Q_DECL_OVERRIDE;
@@ -92,7 +92,7 @@ public:
xcb_timestamp_t targetTime() { return target_time; }
protected:
- void timerEvent(QTimerEvent* e);
+ void timerEvent(QTimerEvent* e) Q_DECL_OVERRIDE;
private:
friend class QXcbDropData;
diff --git a/src/plugins/platforms/xcb/qxcbeglsurface.h b/src/plugins/platforms/xcb/qxcbexport.h
index b03a029094..caf5124133 100644
--- a/src/plugins/platforms/xcb/qxcbeglsurface.h
+++ b/src/plugins/platforms/xcb/qxcbexport.h
@@ -31,34 +31,19 @@
**
****************************************************************************/
-#ifndef QXCBEGLSURFACE_H
-#define QXCBEGLSURFACE_H
+#ifndef QXCBEXPORT_H
+#define QXCBEXPORT_H
-#include <EGL/egl.h>
+#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
-class QXcbEGLSurface
-{
-public:
- QXcbEGLSurface(EGLDisplay display, EGLSurface surface)
- : m_display(display)
- , m_surface(surface)
- {
- }
-
- ~QXcbEGLSurface()
- {
- eglDestroySurface(m_display, m_surface);
- }
-
- EGLSurface surface() const { return m_surface; }
-
-private:
- EGLDisplay m_display;
- EGLSurface m_surface;
-};
+# if defined(QT_BUILD_XCB_PLUGIN)
+# define Q_XCB_EXPORT Q_DECL_EXPORT
+# else
+# define Q_XCB_EXPORT Q_DECL_IMPORT
+# endif
QT_END_NAMESPACE
+#endif //QXCBEXPORT_H
-#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index f0c4a7f691..352d3255e4 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -41,6 +41,7 @@
#include "qxcbnativeinterface.h"
#include "qxcbclipboard.h"
#include "qxcbdrag.h"
+#include "qxcbglintegration.h"
#ifndef QT_NO_SESSIONMANAGER
#include "qxcbsessionmanager.h"
@@ -69,15 +70,6 @@
#include <private/qgenericunixthemes_p.h>
#include <qpa/qplatforminputcontext.h>
-#if defined(XCB_USE_GLX)
-#include "qglxintegration.h"
-#elif defined(XCB_USE_EGL)
-#include "qxcbeglsurface.h"
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
-#include <QtPlatformHeaders/QEGLNativeContext>
-#endif
-
#include <QtGui/QOpenGLContext>
#include <QtGui/QScreen>
#include <QtGui/QOffscreenSurface>
@@ -177,7 +169,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
#ifdef Q_XCB_DEBUG
qDebug() << "QXcbIntegration: Connecting to additional display: " << parameters.at(i) << parameters.at(i+1);
#endif
- QString display = parameters.at(i) + ':' + parameters.at(i+1);
+ QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1);
m_connections << new QXcbConnection(m_nativeInterface.data(), display.toLatin1().constData());
}
@@ -191,82 +183,32 @@ QXcbIntegration::~QXcbIntegration()
QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
{
- return new QXcbWindow(window);
-}
-
-#if defined(XCB_USE_EGL)
-class QEGLXcbPlatformContext : public QEGLPlatformContext
-{
-public:
- QEGLXcbPlatformContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share,
- EGLDisplay display, QXcbConnection *c, const QVariant &nativeHandle)
- : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle)
- , m_connection(c)
- {
- Q_XCB_NOOP(m_connection);
- }
-
- void swapBuffers(QPlatformSurface *surface)
- {
- Q_XCB_NOOP(m_connection);
- QEGLPlatformContext::swapBuffers(surface);
- Q_XCB_NOOP(m_connection);
- }
-
- bool makeCurrent(QPlatformSurface *surface)
- {
- Q_XCB_NOOP(m_connection);
- bool ret = QEGLPlatformContext::makeCurrent(surface);
- Q_XCB_NOOP(m_connection);
- return ret;
- }
-
- void doneCurrent()
- {
- Q_XCB_NOOP(m_connection);
- QEGLPlatformContext::doneCurrent();
- Q_XCB_NOOP(m_connection);
- }
-
- EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
- {
- if (surface->surface()->surfaceClass() == QSurface::Window)
- return static_cast<QXcbWindow *>(surface)->eglSurface()->surface();
- else
- return static_cast<QEGLPbuffer *>(surface)->pbuffer();
- }
-
- QVariant nativeHandle() const {
- return QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(eglContext(), eglDisplay()));
+ if (window->type() != Qt::Desktop) {
+ QXcbScreen *screen = static_cast<QXcbScreen *>(window->screen()->handle());
+ QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
+ if (glIntegration) {
+ QXcbWindow *xcbWindow = glIntegration->createWindow(window);
+ xcbWindow->create();
+ return xcbWindow;
+ }
}
-private:
- QXcbConnection *m_connection;
-};
-#endif
+ Q_ASSERT(window->type() == Qt::Desktop || !window->supportsOpenGL());
+ QXcbWindow *xcbWindow = new QXcbWindow(window);
+ xcbWindow->create();
+ return xcbWindow;
+}
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
-#if defined(XCB_USE_GLX)
- QGLXContext *platformContext = new QGLXContext(screen, context->format(),
- context->shareHandle(), context->nativeHandle());
- context->setNativeHandle(platformContext->nativeHandle());
- return platformContext;
-#elif defined(XCB_USE_EGL)
- QEGLXcbPlatformContext *platformContext = new QEGLXcbPlatformContext(context->format(),
- context->shareHandle(),
- screen->connection()->egl_display(),
- screen->connection(),
- context->nativeHandle());
- context->setNativeHandle(platformContext->nativeHandle());
- return platformContext;
-#else
- Q_UNUSED(screen);
- qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
- return 0;
-#endif
+ QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
+ if (!glIntegration) {
+ qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+ return Q_NULLPTR;
+ }
+ return glIntegration->createPlatformOpenGLContext(context);
}
#endif
@@ -277,45 +219,23 @@ QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *wind
QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
{
-#if defined(XCB_USE_GLX)
- static bool vendorChecked = false;
- static bool glxPbufferUsable = true;
- if (!vendorChecked) {
- vendorChecked = true;
- const char *glxvendor = glXGetClientString(glXGetCurrentDisplay(), GLX_VENDOR);
- if (glxvendor && !strcmp(glxvendor, "ATI"))
- glxPbufferUsable = false;
- }
- if (glxPbufferUsable)
- return new QGLXPbuffer(surface);
- else
- return 0; // trigger fallback to hidden QWindow
-#elif defined(XCB_USE_EGL)
QXcbScreen *screen = static_cast<QXcbScreen *>(surface->screen()->handle());
- return new QEGLPbuffer(screen->connection()->egl_display(), surface->requestedFormat(), surface);
-#else
- Q_UNUSED(surface);
- qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled");
- return 0;
-#endif
+ QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
+ if (!glIntegration) {
+ qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled");
+ return Q_NULLPTR;
+ }
+ return glIntegration->createPlatformOffscreenSurface(surface);
}
bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
-#if defined(XCB_USE_GLX)
- case OpenGL: return m_connections.at(0)->hasGLX();
-#elif defined(XCB_USE_EGL)
- case OpenGL: return true;
-#else
- case OpenGL: return false;
-#endif
-#if defined(XCB_USE_GLX)
- case ThreadedOpenGL: return m_connections.at(0)->supportsThreadedRendering() && QGLXContext::supportsThreading();
-#else
- case ThreadedOpenGL: return m_connections.at(0)->supportsThreadedRendering();
-#endif
+ case OpenGL: return m_connections.first()->glIntegration();
+ case ThreadedOpenGL: return m_connections.at(0)->threadedEventHandling()
+ && m_connections.at(0)->glIntegration()
+ && m_connections.at(0)->glIntegration()->supportsThreadedOpenGL();
case WindowMasks: return true;
case MultipleWindows: return true;
case ForeignWindows: return true;
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index db6ad541ea..150e3d57cb 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -37,6 +37,8 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
+#include "qxcbexport.h"
+
QT_BEGIN_NAMESPACE
class QXcbConnection;
@@ -44,51 +46,51 @@ class QAbstractEventDispatcher;
class QXcbNativeInterface;
class QXcbScreen;
-class QXcbIntegration : public QPlatformIntegration
+class Q_XCB_EXPORT QXcbIntegration : public QPlatformIntegration
{
public:
QXcbIntegration(const QStringList &parameters, int &argc, char **argv);
~QXcbIntegration();
- QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
#ifndef QT_NO_OPENGL
- QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
#endif
- QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
- QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
- bool hasCapability(Capability cap) const;
- QAbstractEventDispatcher *createEventDispatcher() const;
- void initialize();
+ bool hasCapability(Capability cap) const Q_DECL_OVERRIDE;
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
+ void initialize() Q_DECL_OVERRIDE;
void moveToScreen(QWindow *window, int screen);
- QPlatformFontDatabase *fontDatabase() const;
+ QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
- QPlatformNativeInterface *nativeInterface()const;
+ QPlatformNativeInterface *nativeInterface()const Q_DECL_OVERRIDE;
#ifndef QT_NO_CLIPBOARD
- QPlatformClipboard *clipboard() const;
+ QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE;
#endif
#ifndef QT_NO_DRAGANDDROP
- QPlatformDrag *drag() const;
+ QPlatformDrag *drag() const Q_DECL_OVERRIDE;
#endif
- QPlatformInputContext *inputContext() const;
+ QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE;
#ifndef QT_NO_ACCESSIBILITY
- QPlatformAccessibility *accessibility() const;
+ QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE;
#endif
- QPlatformServices *services() const;
+ QPlatformServices *services() const Q_DECL_OVERRIDE;
- Qt::KeyboardModifiers queryKeyboardModifiers() const;
- QList<int> possibleKeys(const QKeyEvent *e) const;
+ Qt::KeyboardModifiers queryKeyboardModifiers() const Q_DECL_OVERRIDE;
+ QList<int> possibleKeys(const QKeyEvent *e) const Q_DECL_OVERRIDE;
- QStringList themeNames() const;
- QPlatformTheme *createPlatformTheme(const QString &name) const;
- QVariant styleHint(StyleHint hint) const;
+ QStringList themeNames() const Q_DECL_OVERRIDE;
+ QPlatformTheme *createPlatformTheme(const QString &name) const Q_DECL_OVERRIDE;
+ QVariant styleHint(StyleHint hint) const Q_DECL_OVERRIDE;
QXcbConnection *defaultConnection() const { return m_connections.first(); }
@@ -98,7 +100,7 @@ public:
QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE;
#endif
- void sync();
+ void sync() Q_DECL_OVERRIDE;
private:
QList<QXcbConnection *> m_connections;
diff --git a/src/plugins/platforms/xcb/qxcbmain.cpp b/src/plugins/platforms/xcb/qxcbmain.cpp
index 80de5ba6f1..921c71711e 100644
--- a/src/plugins/platforms/xcb/qxcbmain.cpp
+++ b/src/plugins/platforms/xcb/qxcbmain.cpp
@@ -41,7 +41,7 @@ class QXcbIntegrationPlugin : public QPlatformIntegrationPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "xcb.json")
public:
- QPlatformIntegration *create(const QString&, const QStringList&, int &, char **);
+ QPlatformIntegration *create(const QString&, const QStringList&, int &, char **) Q_DECL_OVERRIDE;
};
QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& parameters, int &argc, char **argv)
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 31dedd40a2..915287d93e 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -46,13 +46,8 @@
#include <QtGui/qopenglcontext.h>
#include <QtGui/qscreen.h>
-#if defined(XCB_USE_EGL)
-#include "QtPlatformSupport/private/qeglplatformcontext_p.h"
-#elif defined (XCB_USE_GLX)
-#include "qglxintegration.h"
-#endif
-
#include <QtPlatformHeaders/qxcbwindowfunctions.h>
+#include "QtPlatformSupport/private/qdbusmenuconnection_p.h"
#ifdef XCB_USE_XLIB
# include <X11/Xlib.h>
@@ -62,18 +57,17 @@
#include <algorithm>
+#include "qxcbnativeinterfacehandler.h"
+
QT_BEGIN_NAMESPACE
// return QXcbNativeInterface::ResourceType for the key.
static int resourceType(const QByteArray &key)
{
static const QByteArray names[] = { // match QXcbNativeInterface::ResourceType
- QByteArrayLiteral("display"), QByteArrayLiteral("egldisplay"),
+ QByteArrayLiteral("display"),
QByteArrayLiteral("connection"), QByteArrayLiteral("screen"),
- QByteArrayLiteral("eglcontext"),
- QByteArrayLiteral("eglconfig"),
- QByteArrayLiteral("glxconfig"),
- QByteArrayLiteral("glxcontext"), QByteArrayLiteral("apptime"),
+ QByteArrayLiteral("apptime"),
QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"),
QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"),
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
@@ -83,16 +77,14 @@ static int resourceType(const QByteArray &key)
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
- if (result == end)
- result = std::find(names, end, key.toLower());
return int(result - names);
}
QXcbNativeInterface::QXcbNativeInterface() :
m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")),
m_sysTraySelectionAtom(XCB_ATOM_NONE),
- m_systrayVisualId(XCB_NONE)
-
+ m_systrayVisualId(XCB_NONE),
+ m_dbusTrayConnection(Q_NULLPTR)
{
}
@@ -209,10 +201,26 @@ void QXcbNativeInterface::clearRegion(const QWindow *qwindow, const QRect& rect)
}
}
+void QXcbNativeInterface::setParentRelativeBackPixmap(const QWindow *qwindow)
+{
+ if (const QPlatformWindow *platformWindow = qwindow->handle()) {
+ const QXcbWindow *qxwindow = static_cast<const QXcbWindow *>(platformWindow);
+ xcb_connection_t *xcb_conn = qxwindow->xcb_connection();
+
+ const quint32 mask = XCB_CW_BACK_PIXMAP;
+ const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE };
+ Q_XCB_CALL(xcb_change_window_attributes(xcb_conn, qxwindow->xcb_window(), mask, values));
+ }
+}
+
void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString)
{
- void *result = 0;
- switch (resourceType(resourceString)) {
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForIntegration(lowerCaseResource);
+ if (result)
+ return result;
+
+ switch (resourceType(lowerCaseResource)) {
case StartupId:
result = startupId();
break;
@@ -222,6 +230,9 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
case RootWindow:
result = rootWindow();
break;
+ case Display:
+ result = display();
+ break;
default:
break;
}
@@ -231,32 +242,25 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
{
- void *result = 0;
- switch (resourceType(resourceString)) {
- case EglContext:
- result = eglContextForContext(context);
- break;
- case EglConfig:
- result = eglConfigForContext(context);
- break;
- case GLXConfig:
- result = glxConfigForContext(context);
- break;
- case GLXContext:
- result = glxContextForContext(context);
- break;
- default:
- break;
- }
-
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForContext(lowerCaseResource, context);
return result;
}
-void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
+void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceString, QScreen *screen)
{
- void *result = 0;
+ if (!screen) {
+ qWarning() << "nativeResourceForScreen: null screen";
+ return Q_NULLPTR;
+ }
+
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForScreen(lowerCaseResource, screen);
+ if (result)
+ return result;
+
const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
- switch (resourceType(resource)) {
+ switch (resourceType(lowerCaseResource)) {
case Display:
#ifdef XCB_USE_XLIB
result = xcbScreen->connection()->xlib_display();
@@ -295,14 +299,15 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
- void *result = 0;
- switch (resourceType(resourceString)) {
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForWindow(lowerCaseResource, window);
+ if (result)
+ return result;
+
+ switch (resourceType(lowerCaseResource)) {
case Display:
result = displayForWindow(window);
break;
- case EglDisplay:
- result = eglDisplayForWindow(window);
- break;
case Connection:
result = connectionForWindow(window);
break;
@@ -316,17 +321,42 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr
return result;
}
+void *QXcbNativeInterface::nativeResourceForBackingStore(const QByteArray &resourceString, QBackingStore *backingStore)
+{
+ const QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForBackingStore(lowerCaseResource,backingStore);
+ return result;
+}
+
+
QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
{
- QByteArray lowerCaseResource = resource.toLower();
+ const QByteArray lowerCaseResource = resource.toLower();
+ QPlatformNativeInterface::NativeResourceForIntegrationFunction func = handlerNativeResourceFunctionForIntegration(lowerCaseResource);
+ if (func)
+ return func;
+
if (lowerCaseResource == "setstartupid")
return NativeResourceForIntegrationFunction(setStartupId);
return 0;
}
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ QPlatformNativeInterface::NativeResourceForContextFunction func = handlerNativeResourceFunctionForContext(lowerCaseResource);
+ if (func)
+ return func;
+ return Q_NULLPTR;
+}
+
QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource)
{
const QByteArray lowerCaseResource = resource.toLower();
+ NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(lowerCaseResource);
+ if (func)
+ return func;
+
if (lowerCaseResource == "setapptime")
return NativeResourceForScreenFunction(setAppTime);
else if (lowerCaseResource == "setappusertime")
@@ -334,8 +364,28 @@ QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::n
return 0;
}
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ NativeResourceForWindowFunction func = handlerNativeResourceFunctionForWindow(lowerCaseResource);
+ return func;
+}
+
+QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::nativeResourceFunctionForBackingStore(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource);
+ return func;
+}
+
QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &function) const
{
+ const QByteArray lowerCaseFunction = function.toLower();
+ QFunctionPointer func = handlerPlatformFunction(lowerCaseFunction);
+ if (func)
+ return func;
+
+ //case sensitive
if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) {
return QFunctionPointer(QXcbWindow::setWmWindowTypeStatic);
}
@@ -384,6 +434,17 @@ void *QXcbNativeInterface::rootWindow()
return 0;
}
+void *QXcbNativeInterface::display()
+{
+#ifdef XCB_USE_XLIB
+ QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbConnection *defaultConnection = integration->defaultConnection();
+ return defaultConnection->xlib_display();
+#else
+ return 0;
+#endif
+}
+
void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time)
{
static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time);
@@ -403,15 +464,6 @@ void QXcbNativeInterface::setStartupId(const char *data)
defaultConnection->setStartupId(startupId);
}
-QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource)
-{
- QByteArray lowerCaseResource = resource.toLower();
- if (lowerCaseResource == "get_egl_context") {
- return eglContextForContext;
- }
- return 0;
-}
-
QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QXcbScreen *screen;
@@ -434,17 +486,6 @@ void *QXcbNativeInterface::displayForWindow(QWindow *window)
#endif
}
-void *QXcbNativeInterface::eglDisplayForWindow(QWindow *window)
-{
-#if defined(XCB_USE_EGL)
- QXcbScreen *screen = qPlatformScreenForWindow(window);
- return screen->connection()->egl_display();
-#else
- Q_UNUSED(window)
- return 0;
-#endif
-}
-
void *QXcbNativeInterface::connectionForWindow(QWindow *window)
{
QXcbScreen *screen = qPlatformScreenForWindow(window);
@@ -457,54 +498,121 @@ void *QXcbNativeInterface::screenForWindow(QWindow *window)
return screen->screen();
}
-void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context)
+void QXcbNativeInterface::addHandler(QXcbNativeInterfaceHandler *handler)
{
- Q_ASSERT(context);
-#if defined(XCB_USE_EGL)
- QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
- return eglPlatformContext->eglContext();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ m_handlers.removeAll(handler);
+ m_handlers.prepend(handler);
}
-void * QXcbNativeInterface::eglConfigForContext(QOpenGLContext *context)
+void QXcbNativeInterface::removeHandler(QXcbNativeInterfaceHandler *handler)
{
- Q_ASSERT(context);
-#if defined(XCB_USE_EGL)
- QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
- return eglPlatformContext->eglConfig();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ m_handlers.removeAll(handler);
}
-void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context)
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const
{
- Q_ASSERT(context);
-#if defined(XCB_USE_GLX)
- QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
- return glxPlatformContext->glxContext();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForIntegrationFunction result = handler->nativeResourceFunctionForIntegration(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::handlerNativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForContextFunction result = handler->nativeResourceFunctionForContext(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
}
-void *QXcbNativeInterface::glxConfigForContext(QOpenGLContext *context)
+QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::handlerNativeResourceFunctionForScreen(const QByteArray &resource) const
{
- Q_ASSERT(context);
-#if defined(XCB_USE_GLX)
- QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
- return glxPlatformContext->glxConfig();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForScreenFunction result = handler->nativeResourceFunctionForScreen(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::handlerNativeResourceFunctionForWindow(const QByteArray &resource) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForWindowFunction result = handler->nativeResourceFunctionForWindow(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForBackingStoreFunction result = handler->nativeResourceFunctionForBackingStore(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+
+QFunctionPointer QXcbNativeInterface::handlerPlatformFunction(const QByteArray &function) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ QFunctionPointer func = handler->platformFunction(function);
+ if (func)
+ return func;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForIntegration(const QByteArray &resource) const
+{
+ NativeResourceForIntegrationFunction func = handlerNativeResourceFunctionForIntegration(resource);
+ if (func)
+ return func();
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const
+{
+ NativeResourceForContextFunction func = handlerNativeResourceFunctionForContext(resource);
+ if (func)
+ return func(context);
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const
+{
+ NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(resource);
+ if (func)
+ return func(screen);
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const
+{
+ NativeResourceForWindowFunction func = handlerNativeResourceFunctionForWindow(resource);
+ if (func)
+ return func(window);
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const
+{
+ NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource);
+ if (func)
+ return func(backingStore);
+ return Q_NULLPTR;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index 330dd008c4..df3efb037c 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -39,25 +39,24 @@
#include <QtCore/QRect>
+#include "qxcbexport.h"
+
QT_BEGIN_NAMESPACE
class QWidget;
class QXcbScreen;
class QXcbConnection;
+class QXcbNativeInterfaceHandler;
+class QDBusMenuConnection;
-class QXcbNativeInterface : public QPlatformNativeInterface
+class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
public:
enum ResourceType {
Display,
- EglDisplay,
Connection,
Screen,
- EglContext,
- EglConfig,
- GLXConfig,
- GLXContext,
AppTime,
AppUserTime,
ScreenHintStyle,
@@ -77,17 +76,19 @@ public:
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) Q_DECL_OVERRIDE;
void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE;
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) Q_DECL_OVERRIDE;
+ void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) Q_DECL_OVERRIDE;
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) Q_DECL_OVERRIDE;
+ NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) Q_DECL_OVERRIDE;
+ NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) Q_DECL_OVERRIDE;
QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; }
void *displayForWindow(QWindow *window);
- void *eglDisplayForWindow(QWindow *window);
void *connectionForWindow(QWindow *window);
void *screenForWindow(QWindow *window);
void *appTime(const QXcbScreen *screen);
@@ -96,21 +97,21 @@ public:
void *startupId();
void *x11Screen();
void *rootWindow();
+ void *display();
static void setStartupId(const char *);
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
- static void *eglContextForContext(QOpenGLContext *context);
- static void *eglConfigForContext(QOpenGLContext *context);
- static void *glxContextForContext(QOpenGLContext *context);
- static void *glxConfigForContext(QOpenGLContext *context);
Q_INVOKABLE void beep();
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
Q_INVOKABLE void clearRegion(const QWindow *qwindow, const QRect& rect);
+ Q_INVOKABLE void setParentRelativeBackPixmap(const QWindow *window);
Q_INVOKABLE bool systrayVisualHasAlphaChannel();
Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window);
Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window);
+ void addHandler(QXcbNativeInterfaceHandler *handler);
+ void removeHandler(QXcbNativeInterfaceHandler *handler);
signals:
void systemTrayWindowChanged(QScreen *screen);
@@ -121,8 +122,22 @@ private:
xcb_atom_t m_sysTraySelectionAtom;
xcb_visualid_t m_systrayVisualId;
+ QDBusMenuConnection *m_dbusTrayConnection;
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
+
+ QList<QXcbNativeInterfaceHandler *> m_handlers;
+ NativeResourceForIntegrationFunction handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const;
+ NativeResourceForContextFunction handlerNativeResourceFunctionForContext(const QByteArray &resource) const;
+ NativeResourceForScreenFunction handlerNativeResourceFunctionForScreen(const QByteArray &resource) const;
+ NativeResourceForWindowFunction handlerNativeResourceFunctionForWindow(const QByteArray &resource) const;
+ NativeResourceForBackingStoreFunction handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const;
+ QFunctionPointer handlerPlatformFunction(const QByteArray &function) const;
+ void *handlerNativeResourceForIntegration(const QByteArray &resource) const;
+ void *handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const;
+ void *handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const;
+ void *handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const;
+ void *handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 7136455754..b5eed4f4fe 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -337,7 +337,7 @@ QDpi QXcbScreen::logicalDpi() const
qreal QXcbScreen::devicePixelRatio() const
{
- static int override_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt();
+ static int override_dpr = qEnvironmentVariableIntValue("QT_DEVICE_PIXEL_RATIO");
static bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto";
if (override_dpr > 0)
return override_dpr;
@@ -417,6 +417,13 @@ void QXcbScreen::handleScreenChange(xcb_randr_screen_change_notify_event_t *chan
QDpi ldpi = logicalDpi();
QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QPlatformScreen::screen(), ldpi.first, ldpi.second);
+
+ // Windows which had null screens have already had expose events by now.
+ // They need to be told the screen is back, it's OK to render.
+ foreach (QWindow *window, QGuiApplication::topLevelWindows()) {
+ QXcbWindow *xcbWin = static_cast<QXcbWindow*>(window->handle());
+ xcbWin->maybeSetScreen(this);
+ }
}
void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp)
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index e9ab2edaa0..652d64c105 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -41,6 +41,7 @@
#include <xcb/randr.h>
#include "qxcbobject.h"
+#include "qxcbscreen.h"
#include <private/qfontengine_p.h>
@@ -50,29 +51,29 @@ class QXcbConnection;
class QXcbCursor;
class QXcbXSettings;
-class QXcbScreen : public QXcbObject, public QPlatformScreen
+class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen
{
public:
QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen,
xcb_randr_get_output_info_reply_t *output, QString outputName, int number);
~QXcbScreen();
- QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
- QWindow *topLevelAt(const QPoint &point) const;
+ QWindow *topLevelAt(const QPoint &point) const Q_DECL_OVERRIDE;
- QRect geometry() const { return m_geometry; }
+ QRect geometry() const Q_DECL_OVERRIDE { return m_geometry; }
QRect nativeGeometry() const { return m_nativeGeometry; }
- QRect availableGeometry() const {return m_availableGeometry;}
- int depth() const { return m_screen->root_depth; }
- QImage::Format format() const;
- QSizeF physicalSize() const { return m_sizeMillimeters; }
- QDpi logicalDpi() const;
- qreal devicePixelRatio() const;
- QPlatformCursor *cursor() const;
- qreal refreshRate() const { return m_refreshRate; }
- Qt::ScreenOrientation orientation() const { return m_orientation; }
- QList<QPlatformScreen *> virtualSiblings() const { return m_siblings; }
+ QRect availableGeometry() const Q_DECL_OVERRIDE {return m_availableGeometry;}
+ int depth() const Q_DECL_OVERRIDE { return m_screen->root_depth; }
+ QImage::Format format() const Q_DECL_OVERRIDE;
+ QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_sizeMillimeters; }
+ QDpi logicalDpi() const Q_DECL_OVERRIDE;
+ qreal devicePixelRatio() const Q_DECL_OVERRIDE;
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
+ qreal refreshRate() const Q_DECL_OVERRIDE { return m_refreshRate; }
+ Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_orientation; }
+ QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; }
void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; }
int screenNumber() const { return m_number; }
@@ -89,7 +90,7 @@ public:
const xcb_visualtype_t *visualForId(xcb_visualid_t) const;
quint8 depthOfVisual(xcb_visualid_t) const;
- QString name() const { return m_outputName; }
+ QString name() const Q_DECL_OVERRIDE { return m_outputName; }
void handleScreenChange(xcb_randr_screen_change_notify_event_t *change_event);
void updateGeometry(xcb_timestamp_t timestamp);
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
index 2e297c4ae5..2f364d3e55 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
@@ -55,7 +55,7 @@ public:
void notifyManagerClientMessageEvent(const xcb_client_message_event_t *);
- void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *);
+ void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *) Q_DECL_OVERRIDE;
signals:
void systemTrayWindowChanged(QScreen *screen);
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 96c5663d83..a945b4cc18 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -97,15 +97,6 @@
#include <X11/extensions/XInput2.h>
#endif
-#if defined(XCB_USE_GLX)
-#include "qglxintegration.h"
-#include <QtPlatformSupport/private/qglxconvenience_p.h>
-#elif defined(XCB_USE_EGL)
-#include "qxcbeglsurface.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
-#endif
-
#define XCOORD_MAX 16383
enum {
defaultWindowWidth = 160,
@@ -238,21 +229,11 @@ QXcbWindow::QXcbWindow(QWindow *window)
, m_alertState(false)
, m_netWmUserTimeWindow(XCB_NONE)
, m_dirtyFrameMargins(false)
-#if defined(XCB_USE_EGL)
- , m_eglSurface(0)
-#endif
, m_lastWindowStateEvent(-1)
, m_syncState(NoSyncNeeded)
, m_pendingSyncRequest(0)
{
- m_screen = static_cast<QXcbScreen *>(window->screen()->handle());
-
- setConnection(m_screen->connection());
-
- if (window->type() != Qt::ForeignWindow)
- create();
- else
- m_window = window->winId();
+ setConnection(xcbScreen()->connection());
}
#ifdef Q_COMPILER_CLASS_ENUM
@@ -278,6 +259,11 @@ enum {
void QXcbWindow::create()
{
+ if (window()->type() == Qt::ForeignWindow) {
+ m_window = window()->winId();
+ return;
+ }
+
destroy();
m_deferredExpose = false;
@@ -286,11 +272,13 @@ void QXcbWindow::create()
Qt::WindowType type = window()->type();
+ QXcbScreen *platformScreen = xcbScreen();
+
if (type == Qt::Desktop) {
- m_window = m_screen->root();
- m_depth = m_screen->screen()->root_depth;
- m_visualId = m_screen->screen()->root_visual;
- const xcb_visualtype_t *visual = m_screen->visualForId(m_visualId);
+ m_window = platformScreen->root();
+ m_depth = platformScreen->screen()->root_depth;
+ m_visualId = platformScreen->screen()->root_visual;
+ const xcb_visualtype_t *visual = platformScreen->visualForId(m_visualId);
m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask);
connection()->addWindowEventListener(m_window, this);
return;
@@ -331,7 +319,7 @@ void QXcbWindow::create()
rect.setHeight(defaultWindowHeight);
}
- xcb_window_t xcb_parent_id = m_screen->root();
+ xcb_window_t xcb_parent_id = platformScreen->root();
if (parent()) {
xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();
m_embedded = parent()->window()->type() == Qt::ForeignWindow;
@@ -341,27 +329,12 @@ void QXcbWindow::create()
window()->setFormat(parentFormat);
}
}
- m_format = window()->requestedFormat();
-#if (defined(XCB_USE_GLX) || defined(XCB_USE_EGL)) && defined(XCB_USE_XLIB)
+ resolveFormat();
+
+#ifdef XCB_USE_XLIB
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
-#if defined(XCB_USE_GLX)
- XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), &m_format);
-#elif defined(XCB_USE_EGL)
- EGLDisplay eglDisplay = connection()->egl_display();
- EGLConfig eglConfig = q_configFromGLFormat(eglDisplay, m_format, true);
- m_format = q_glFormatFromConfig(eglDisplay, eglConfig, m_format);
-
- VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig);
-
- XVisualInfo visualInfoTemplate;
- memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
- visualInfoTemplate.visualid = id;
-
- XVisualInfo *visualInfo;
- int matchingCount = 0;
- visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
-#endif //XCB_USE_GLX
+ XVisualInfo *visualInfo = static_cast<XVisualInfo *>(createVisual());
if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface)
qFatal("Could not initialize OpenGL");
@@ -369,14 +342,15 @@ void QXcbWindow::create()
qWarning("Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.");
window()->setSurfaceType(QSurface::RasterSurface);
}
+
if (visualInfo) {
m_depth = visualInfo->depth;
m_imageFormat = imageFormatForVisual(visualInfo->depth, visualInfo->red_mask, visualInfo->blue_mask);
Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone);
XSetWindowAttributes a;
- a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber());
- a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber());
+ a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), platformScreen->screenNumber());
+ a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), platformScreen->screenNumber());
a.colormap = cmap;
m_visualId = visualInfo->visualid;
@@ -390,19 +364,19 @@ void QXcbWindow::create()
XFree(visualInfo);
}
}
+#endif
if (!m_window)
-#endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
{
m_window = xcb_generate_id(xcb_connection());
- m_visualId = m_screen->screen()->root_visual;
- m_depth = m_screen->screen()->root_depth;
+ m_visualId = platformScreen->screen()->root_visual;
+ m_depth = platformScreen->screen()->root_depth;
uint32_t mask = 0;
uint32_t values[3];
if (m_format.alphaBufferSize() == 8) {
- xcb_depth_iterator_t depthIter = xcb_screen_allowed_depths_iterator(m_screen->screen());
+ xcb_depth_iterator_t depthIter = xcb_screen_allowed_depths_iterator(platformScreen->screen());
while (depthIter.rem) {
if (depthIter.data->depth == 32) {
xcb_visualtype_iterator_t visualIter = xcb_depth_visuals_iterator(depthIter.data);
@@ -413,8 +387,8 @@ void QXcbWindow::create()
xcb_create_colormap(xcb_connection(), XCB_COLORMAP_ALLOC_NONE, colormap,
xcb_parent_id, m_visualId);
mask |= XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP;
- values[0] = m_screen->screen()->white_pixel;
- values[1] = m_screen->screen()->black_pixel;
+ values[0] = platformScreen->screen()->white_pixel;
+ values[1] = platformScreen->screen()->black_pixel;
values[2] = colormap;
break;
}
@@ -423,7 +397,7 @@ void QXcbWindow::create()
}
}
- const xcb_visualtype_t *visual = m_screen->visualForId(m_visualId);
+ const xcb_visualtype_t *visual = platformScreen->visualForId(m_visualId);
m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask);
Q_XCB_CALL(xcb_create_window(xcb_connection(),
@@ -453,12 +427,10 @@ void QXcbWindow::create()
properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS);
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING);
- m_usingSyncProtocol = m_screen->syncRequestSupported();
-#if !defined(XCB_USE_GLX)
- // synced resize only implemented on GLX
- if (window()->supportsOpenGL())
+ if (platformScreen->syncRequestSupported())
+ m_usingSyncProtocol = supportsSyncProtocol();
+ else
m_usingSyncProtocol = false;
-#endif
if (m_usingSyncProtocol)
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);
@@ -512,7 +484,7 @@ void QXcbWindow::create()
xcb_set_wm_hints(xcb_connection(), m_window, &hints);
- xcb_window_t leader = m_screen->clientLeader();
+ xcb_window_t leader = platformScreen->clientLeader();
Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32,
1, &leader));
@@ -538,7 +510,7 @@ void QXcbWindow::create()
#ifdef XCB_USE_XLIB
// force sync to read outstanding requests - see QTBUG-29106
- XSync(DISPLAY_FROM_XCB(m_screen), false);
+ XSync(DISPLAY_FROM_XCB(platformScreen), false);
#endif
#ifndef QT_NO_DRAGANDDROP
@@ -580,15 +552,18 @@ void QXcbWindow::destroy()
}
m_mapped = false;
-#if defined(XCB_USE_EGL)
- delete m_eglSurface;
- m_eglSurface = 0;
-#endif
-
if (m_pendingSyncRequest)
m_pendingSyncRequest->invalidate();
}
+void QXcbWindow::maybeSetScreen(QXcbScreen *screen)
+{
+ if (!window()->screen() && screen->geometry().contains(geometry().topLeft() * int(devicePixelRatio()))) {
+ QWindowSystemInterface::handleWindowScreenChanged(window(), static_cast<QPlatformScreen *>(screen)->screen());
+ QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(0, 0), window()->size())));
+ }
+}
+
void QXcbWindow::setGeometry(const QRect &rect)
{
QPlatformWindow::setGeometry(rect);
@@ -732,7 +707,7 @@ void QXcbWindow::show()
// Default to client leader if there is no transient parent, else modal dialogs can
// be hidden by their parents.
if (!transientXcbParent)
- transientXcbParent = static_cast<QXcbScreen *>(screen())->clientLeader();
+ transientXcbParent = xcbScreen()->clientLeader();
if (transientXcbParent) { // ICCCM 4.1.2.6
Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
@@ -763,7 +738,7 @@ void QXcbWindow::show()
if (QGuiApplication::modalWindow() == window())
requestActivateWindow();
- m_screen->windowShown(this);
+ xcbScreen()->windowShown(this);
connection()->sync();
}
@@ -773,13 +748,15 @@ void QXcbWindow::hide()
Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window));
// send synthetic UnmapNotify event according to icccm 4.1.4
- xcb_unmap_notify_event_t event;
- event.response_type = XCB_UNMAP_NOTIFY;
- event.event = m_screen->root();
- event.window = m_window;
- event.from_configure = false;
- Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_screen->root(),
- XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
+ if (xcbScreen()) {
+ xcb_unmap_notify_event_t event;
+ event.response_type = XCB_UNMAP_NOTIFY;
+ event.event = xcbScreen()->root();
+ event.window = m_window;
+ event.from_configure = false;
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, xcbScreen()->root(),
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
+ }
xcb_flush(xcb_connection());
@@ -1098,7 +1075,7 @@ void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two)
event.data.data32[3] = 0;
event.data.data32[4] = 0;
- Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
}
void QXcbWindow::setWindowState(Qt::WindowState state)
@@ -1139,7 +1116,7 @@ void QXcbWindow::setWindowState(Qt::WindowState state)
event.data.data32[3] = 0;
event.data.data32[4] = 0;
- Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
}
break;
case Qt::WindowMaximized:
@@ -1382,7 +1359,7 @@ void QXcbWindow::setParent(const QPlatformWindow *parent)
xcb_parent_id = qXcbParent->xcb_window();
m_embedded = qXcbParent->window()->type() == Qt::ForeignWindow;
} else {
- xcb_parent_id = m_screen->root();
+ xcb_parent_id = xcbScreen()->root();
m_embedded = false;
}
Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), xcb_parent_id, topLeft.x(), topLeft.y()));
@@ -1550,7 +1527,7 @@ void QXcbWindow::requestActivateWindow()
event.data.data32[3] = 0;
event.data.data32[4] = 0;
- Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
} else {
Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time()));
}
@@ -1560,25 +1537,9 @@ void QXcbWindow::requestActivateWindow()
QSurfaceFormat QXcbWindow::format() const
{
- // ### return actual format
return m_format;
}
-#if defined(XCB_USE_EGL)
-QXcbEGLSurface *QXcbWindow::eglSurface() const
-{
- if (!m_eglSurface) {
- EGLDisplay display = connection()->egl_display();
- EGLConfig config = q_configFromGLFormat(display, window()->requestedFormat(), true);
- EGLSurface surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)m_window, 0);
-
- m_eglSurface = new QXcbEGLSurface(display, surface);
- }
-
- return m_eglSurface;
-}
-#endif
-
void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes)
{
if (window->handle())
@@ -1787,15 +1748,15 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
relayFocusToModalWindow();
return;
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) {
- if (event->window == m_screen->root())
+ if (event->window == xcbScreen()->root())
return;
xcb_client_message_event_t reply = *event;
reply.response_type = XCB_CLIENT_MESSAGE;
- reply.window = m_screen->root();
+ reply.window = xcbScreen()->root();
- xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply);
+ xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply);
xcb_flush(xcb_connection());
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_SYNC_REQUEST)) {
connection()->setTime(event->data.data32[1]);
@@ -1846,7 +1807,9 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
QPlatformScreen *QXcbWindow::screenForNativeGeometry(const QRect &newGeometry) const
{
QXcbScreen *currentScreen = static_cast<QXcbScreen*>(screen());
- if (!parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) {
+ if (!currentScreen && QGuiApplication::primaryScreen())
+ currentScreen = static_cast<QXcbScreen*>(QGuiApplication::primaryScreen()->handle());
+ if (currentScreen && !parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) {
Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) {
if (static_cast<QXcbScreen*>(screen)->nativeGeometry().intersects(newGeometry))
return screen;
@@ -1859,10 +1822,10 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
{
bool fromSendEvent = (event->response_type & 0x80);
QPoint pos(event->x, event->y);
- if (!parent() && !fromSendEvent) {
+ if (!parent() && !fromSendEvent && xcbScreen()) {
// Do not trust the position, query it instead.
xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(),
- m_screen->root(), 0, 0);
+ xcbScreen()->root(), 0, 0);
xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL);
if (reply) {
pos.setX(reply->dst_x);
@@ -1877,11 +1840,10 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
QPlatformWindow::setGeometry(rect);
QWindowSystemInterface::handleGeometryChange(window(), rect);
-
QPlatformScreen *newScreen = screenForNativeGeometry(nativeRect);
- if (newScreen != m_screen) {
- m_screen = static_cast<QXcbScreen*>(newScreen);
- QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
+ if (newScreen != screen()) {
+ if (newScreen)
+ QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
int newDpr = devicePixelRatio();
if (newDpr != dpr) {
QRect newRect = mapGeometryFromNative(nativeRect, newDpr);
@@ -1924,7 +1886,7 @@ QPoint QXcbWindow::mapToGlobal(const QPoint &pos) const
const int dpr = int(devicePixelRatio());
QPoint ret;
xcb_translate_coordinates_cookie_t cookie =
- xcb_translate_coordinates(xcb_connection(), xcb_window(), m_screen->root(),
+ xcb_translate_coordinates(xcb_connection(), xcb_window(), xcbScreen()->root(),
pos.x() * dpr, pos.y() * dpr);
xcb_translate_coordinates_reply_t *reply =
xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL);
@@ -1945,7 +1907,7 @@ QPoint QXcbWindow::mapFromGlobal(const QPoint &pos) const
const int dpr = int(devicePixelRatio());
QPoint ret;
xcb_translate_coordinates_cookie_t cookie =
- xcb_translate_coordinates(xcb_connection(), m_screen->root(), xcb_window(),
+ xcb_translate_coordinates(xcb_connection(), xcbScreen()->root(), xcb_window(),
pos.x() *dpr, pos.y() * dpr);
xcb_translate_coordinates_reply_t *reply =
xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL);
@@ -2169,8 +2131,8 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
m_windowState = newState;
}
return;
- } else if (event->atom == atom(QXcbAtom::_NET_WORKAREA) && event->window == m_screen->root()) {
- m_screen->updateGeometry(event->time);
+ } else if (event->atom == atom(QXcbAtom::_NET_WORKAREA) && xcbScreen() && event->window == xcbScreen()->root()) {
+ xcbScreen()->updateGeometry(event->time);
}
}
@@ -2299,7 +2261,7 @@ bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner)
xev.data.data32[3] = XCB_BUTTON_INDEX_1;
xev.data.data32[4] = 0;
xcb_ungrab_pointer(connection()->xcb_connection(), XCB_CURRENT_TIME);
- xcb_send_event(connection()->xcb_connection(), false, m_screen->root(),
+ xcb_send_event(connection()->xcb_connection(), false, xcbScreen()->root(),
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
(const char *)&xev);
return true;
@@ -2344,7 +2306,7 @@ void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event)
break;
case XEMBED_EMBEDDED_NOTIFY:
Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window));
- m_screen->windowShown(this);
+ xcbScreen()->windowShown(this);
break;
case XEMBED_FOCUS_IN:
Qt::FocusReason reason;
@@ -2438,13 +2400,18 @@ void QXcbWindow::postSyncWindowRequest()
if (!m_pendingSyncRequest) {
QXcbSyncWindowRequest *e = new QXcbSyncWindowRequest(this);
m_pendingSyncRequest = e;
- QCoreApplication::postEvent(m_screen->connection(), e);
+ QCoreApplication::postEvent(xcbScreen()->connection(), e);
}
}
qreal QXcbWindow::devicePixelRatio() const
{
- return m_screen ? m_screen->devicePixelRatio() : 1.0;
+ return xcbScreen() ? xcbScreen()->devicePixelRatio() : 1.0;
+}
+
+QXcbScreen *QXcbWindow::xcbScreen() const
+{
+ return static_cast<QXcbScreen *>(screen());
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 254421e57d..981f4e7496 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -48,11 +48,10 @@
QT_BEGIN_NAMESPACE
class QXcbScreen;
-class QXcbEGLSurface;
class QXcbSyncWindowRequest;
class QIcon;
-class QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
+class Q_XCB_EXPORT QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
{
public:
enum NetWmState {
@@ -71,45 +70,45 @@ public:
QXcbWindow(QWindow *window);
~QXcbWindow();
- void setGeometry(const QRect &rect);
+ void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
- QMargins frameMargins() const;
+ QMargins frameMargins() const Q_DECL_OVERRIDE;
- void setVisible(bool visible);
- void setWindowFlags(Qt::WindowFlags flags);
- void setWindowState(Qt::WindowState state);
- WId winId() const;
- void setParent(const QPlatformWindow *window);
+ void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
+ void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE;
+ WId winId() const Q_DECL_OVERRIDE;
+ void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
- bool isExposed() const;
- bool isEmbedded(const QPlatformWindow *parentWindow) const;
- QPoint mapToGlobal(const QPoint &pos) const;
- QPoint mapFromGlobal(const QPoint &pos) const;
+ bool isExposed() const Q_DECL_OVERRIDE;
+ bool isEmbedded(const QPlatformWindow *parentWindow) const Q_DECL_OVERRIDE;
+ QPoint mapToGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
+ QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
- void setWindowTitle(const QString &title);
- void setWindowIcon(const QIcon &icon);
- void raise();
- void lower();
- void propagateSizeHints();
+ void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
+ void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE;
+ void raise() Q_DECL_OVERRIDE;
+ void lower() Q_DECL_OVERRIDE;
+ void propagateSizeHints() Q_DECL_OVERRIDE;
- void requestActivateWindow();
+ void requestActivateWindow() Q_DECL_OVERRIDE;
- bool setKeyboardGrabEnabled(bool grab);
- bool setMouseGrabEnabled(bool grab);
+ bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE;
+ bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE;
void setCursor(xcb_cursor_t cursor);
- QSurfaceFormat format() const;
+ QSurfaceFormat format() const Q_DECL_OVERRIDE;
- void windowEvent(QEvent *event);
+ void windowEvent(QEvent *event) Q_DECL_OVERRIDE;
- bool startSystemResize(const QPoint &pos, Qt::Corner corner);
+ bool startSystemResize(const QPoint &pos, Qt::Corner corner) Q_DECL_OVERRIDE;
- void setOpacity(qreal level);
- void setMask(const QRegion &region);
+ void setOpacity(qreal level) Q_DECL_OVERRIDE;
+ void setMask(const QRegion &region) Q_DECL_OVERRIDE;
- void setAlertState(bool enabled);
- bool isAlertState() const { return m_alertState; }
+ void setAlertState(bool enabled) Q_DECL_OVERRIDE;
+ bool isAlertState() const Q_DECL_OVERRIDE { return m_alertState; }
xcb_window_t xcb_window() const { return m_window; }
uint depth() const { return m_depth; }
@@ -138,10 +137,6 @@ public:
void updateNetWmUserTime(xcb_timestamp_t timestamp);
-#if defined(XCB_USE_EGL)
- QXcbEGLSurface *eglSurface() const;
-#endif
-
static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
@@ -152,14 +147,23 @@ public:
void postSyncWindowRequest();
void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
- qreal devicePixelRatio() const;
+ qreal devicePixelRatio() const Q_DECL_OVERRIDE;
+ QXcbScreen *xcbScreen() const;
+
+ virtual void create();
+ virtual void destroy();
+ void maybeSetScreen(QXcbScreen *screen);
QPlatformScreen *screenForNativeGeometry(const QRect &newGeometry) const;
public Q_SLOTS:
void updateSyncRequestCounter();
-private:
+protected:
+ virtual void resolveFormat() { m_format = window()->requestedFormat(); }
+ virtual void *createVisual() { return Q_NULLPTR; }
+ virtual bool supportsSyncProtocol() { return !window()->supportsOpenGL(); }
+
void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
NetWmStates netWmStates();
void setNetWmStates(NetWmStates);
@@ -178,9 +182,6 @@ private:
quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
void handleXEmbedMessage(const xcb_client_message_event_t *event);
- void create();
- void destroy();
-
void show();
void hide();
@@ -188,8 +189,6 @@ private:
void doFocusIn();
void doFocusOut();
- QXcbScreen *m_screen;
-
xcb_window_t m_window;
uint m_depth;
@@ -217,10 +216,6 @@ private:
mutable bool m_dirtyFrameMargins;
mutable QMargins m_frameMargins;
-#if defined(XCB_USE_EGL)
- mutable QXcbEGLSurface *m_eglSurface;
-#endif
-
QRegion m_exposeRegion;
xcb_visualid_t m_visualId;
diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro
index 129076c916..09ab1ad77a 100644
--- a/src/plugins/platforms/xcb/xcb-plugin.pro
+++ b/src/plugins/platforms/xcb/xcb-plugin.pro
@@ -5,117 +5,9 @@ PLUGIN_CLASS_NAME = QXcbIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
load(qt_plugin)
-QT += core-private gui-private platformsupport-private
+QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
SOURCES = \
- qxcbclipboard.cpp \
- qxcbconnection.cpp \
- qxcbintegration.cpp \
- qxcbkeyboard.cpp \
- qxcbmime.cpp \
- qxcbdrag.cpp \
- qxcbscreen.cpp \
- qxcbwindow.cpp \
- qxcbbackingstore.cpp \
- qxcbwmsupport.cpp \
- qxcbmain.cpp \
- qxcbnativeinterface.cpp \
- qxcbcursor.cpp \
- qxcbimage.cpp \
- qxcbxsettings.cpp \
- qxcbsystemtraytracker.cpp
-
-HEADERS = \
- qxcbclipboard.h \
- qxcbconnection.h \
- qxcbintegration.h \
- qxcbkeyboard.h \
- qxcbdrag.h \
- qxcbmime.h \
- qxcbobject.h \
- qxcbscreen.h \
- qxcbwindow.h \
- qxcbbackingstore.h \
- qxcbwmsupport.h \
- qxcbnativeinterface.h \
- qxcbcursor.h \
- qxcbimage.h \
- qxcbxsettings.h \
- qxcbsystemtraytracker.h
-
-LIBS += $$QMAKE_LIBS_DYNLOAD
-
-# needed by GLX, Xcursor ...
-contains(QT_CONFIG, xcb-xlib) {
- DEFINES += XCB_USE_XLIB
- LIBS += -lX11 -lX11-xcb
-
- contains(QT_CONFIG, xinput2) {
- DEFINES += XCB_USE_XINPUT2
- SOURCES += qxcbconnection_xi2.cpp
- LIBS += -lXi
- }
-}
-
-# 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) {
- DEFINES += XCB_USE_SM
- LIBS += -lSM -lICE
- SOURCES += qxcbsessionmanager.cpp
- HEADERS += qxcbsessionmanager.h
-}
-
-contains(QT_CONFIG, opengl) {
- contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, opengles2) {
- DEFINES += XCB_USE_GLX
- HEADERS += qglxintegration.h
- SOURCES += qglxintegration.cpp
- LIBS += $$QMAKE_LIBS_DYNLOAD
- contains(QT_CONFIG, xcb-glx) {
- DEFINES += XCB_HAS_XCB_GLX
- LIBS += -lxcb-glx
- }
- } else:contains(QT_CONFIG, egl):contains(QT_CONFIG, egl_x11) {
- DEFINES += XCB_USE_EGL
- CONFIG += egl
- HEADERS += qxcbeglsurface.h
-
- # EGL on MeeGo 1.2 Harmattan needs this macro to map EGLNativeDisplayType
- # and other types to the correct X11 types
- DEFINES += SUPPORT_X11
- }
-}
-
-DEFINES += $$QMAKE_DEFINES_XCB
-LIBS += $$QMAKE_LIBS_XCB
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
-QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
-
-CONFIG += qpa/genericunixfontdatabase
-
+ qxcbmain.cpp
OTHER_FILES += xcb.json README
-contains(QT_CONFIG, xcb-qt) {
- DEFINES += XCB_USE_RENDER
- XCB_DIR = ../../../3rdparty/xcb
- INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
- LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
-} 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
-}
-
-# libxkbcommon
-contains(QT_CONFIG, xkbcommon-qt): {
- QT_CONFIG += use-xkbcommon-x11support
- include(../../../3rdparty/xkbcommon.pri)
-} else {
- LIBS += $$QMAKE_LIBS_XKBCOMMON
- QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
-}
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index dab0d8cb14..5915a59c0b 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -2,4 +2,7 @@ TEMPLATE = subdirs
CONFIG += ordered
contains(QT_CONFIG, xcb-qt):SUBDIRS+=xcb-static
+
+SUBDIRS += xcb_qpa_lib.pro
SUBDIRS += xcb-plugin.pro
+SUBDIRS += gl_integrations
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
new file mode 100644
index 0000000000..fd704dd904
--- /dev/null
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -0,0 +1,111 @@
+TARGET = QtXcbQpa
+CONFIG += no_module_headers internal_module
+
+MODULE_INCLUDES = \
+ \$\$QT_MODULE_INCLUDE_BASE \
+ \$\$QT_MODULE_INCLUDE_BASE/QtQGui
+MODULE_PRIVATE_INCLUDES = \
+ \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION \
+ \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION/QtGui
+
+load(qt_module)
+
+QT += core-private gui-private platformsupport-private
+
+SOURCES = \
+ qxcbclipboard.cpp \
+ qxcbconnection.cpp \
+ qxcbintegration.cpp \
+ qxcbkeyboard.cpp \
+ qxcbmime.cpp \
+ qxcbdrag.cpp \
+ qxcbscreen.cpp \
+ qxcbwindow.cpp \
+ qxcbbackingstore.cpp \
+ qxcbwmsupport.cpp \
+ qxcbnativeinterface.cpp \
+ qxcbcursor.cpp \
+ qxcbimage.cpp \
+ qxcbxsettings.cpp \
+ qxcbsystemtraytracker.cpp
+
+HEADERS = \
+ qxcbclipboard.h \
+ qxcbconnection.h \
+ qxcbintegration.h \
+ qxcbkeyboard.h \
+ qxcbdrag.h \
+ qxcbmime.h \
+ qxcbobject.h \
+ qxcbscreen.h \
+ qxcbwindow.h \
+ qxcbbackingstore.h \
+ qxcbwmsupport.h \
+ qxcbnativeinterface.h \
+ qxcbcursor.h \
+ qxcbimage.h \
+ qxcbxsettings.h \
+ qxcbsystemtraytracker.h
+
+LIBS += $$QMAKE_LIBS_DYNLOAD
+
+DEFINES += QT_BUILD_XCB_PLUGIN
+# needed by Xcursor ...
+contains(QT_CONFIG, xcb-xlib) {
+ DEFINES += XCB_USE_XLIB
+ LIBS += -lX11 -lX11-xcb
+
+ contains(QT_CONFIG, xinput2) {
+ DEFINES += XCB_USE_XINPUT2
+ SOURCES += qxcbconnection_xi2.cpp
+ LIBS += -lXi
+ }
+}
+
+# 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) {
+ DEFINES += XCB_USE_SM
+ LIBS += -lSM -lICE
+ 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) {
+ DEFINES += XCB_USE_RENDER
+ XCB_DIR = ../../../3rdparty/xcb
+ INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
+ LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
+} 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
+}
+
+# libxkbcommon
+contains(QT_CONFIG, xkbcommon-qt) {
+ QT_CONFIG += use-xkbcommon-x11support
+ include(../../../3rdparty/xkbcommon.pri)
+} else {
+ LIBS += $$QMAKE_LIBS_XKBCOMMON
+ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
+}
+
diff --git a/src/plugins/platformthemes/gtk2/main.cpp b/src/plugins/platformthemes/gtk2/main.cpp
index 860a1f8b3f..f14621da69 100644
--- a/src/plugins/platformthemes/gtk2/main.cpp
+++ b/src/plugins/platformthemes/gtk2/main.cpp
@@ -42,7 +42,7 @@ class QGtk2ThemePlugin : public QPlatformThemePlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "gtk2.json")
public:
- QPlatformTheme *create(const QString &key, const QStringList &params);
+ QPlatformTheme *create(const QString &key, const QStringList &params) Q_DECL_OVERRIDE;
};
QPlatformTheme *QGtk2ThemePlugin::create(const QString &key, const QStringList &params)
diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp
index d7e73c873d..0c7ff1a717 100644
--- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp
@@ -40,6 +40,7 @@
#include <qfont.h>
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformfontdatabase.h>
#undef signals
#include <gtk/gtk.h>
@@ -511,14 +512,22 @@ static QString qt_fontToString(const QFont &font)
int weight = font.weight();
if (weight >= QFont::Black)
pango_font_description_set_weight(desc, PANGO_WEIGHT_HEAVY);
+ else if (weight >= QFont::ExtraBold)
+ pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRABOLD);
else if (weight >= QFont::Bold)
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
else if (weight >= QFont::DemiBold)
pango_font_description_set_weight(desc, PANGO_WEIGHT_SEMIBOLD);
+ else if (weight >= QFont::Medium)
+ pango_font_description_set_weight(desc, PANGO_WEIGHT_MEDIUM);
else if (weight >= QFont::Normal)
pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
- else
+ else if (weight >= QFont::Light)
pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT);
+ else if (weight >= QFont::ExtraLight)
+ pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRALIGHT);
+ else
+ pango_font_description_set_weight(desc, PANGO_WEIGHT_THIN);
int style = font.style();
if (style == QFont::StyleItalic)
@@ -545,17 +554,8 @@ static QFont qt_fontFromString(const QString &name)
if (!family.isEmpty())
font.setFamily(family);
- int weight = pango_font_description_get_weight(desc);
- if (weight >= PANGO_WEIGHT_HEAVY)
- font.setWeight(QFont::Black);
- else if (weight >= PANGO_WEIGHT_BOLD)
- font.setWeight(QFont::Bold);
- else if (weight >= PANGO_WEIGHT_SEMIBOLD)
- font.setWeight(QFont::DemiBold);
- else if (weight >= PANGO_WEIGHT_NORMAL)
- font.setWeight(QFont::Normal);
- else
- font.setWeight(QFont::Light);
+ const int weight = pango_font_description_get_weight(desc);
+ font.setWeight(QPlatformFontDatabase::weightFromInteger(weight));
PangoStyle style = pango_font_description_get_style(desc);
if (style == PANGO_STYLE_ITALIC)
diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h
index 9789c6750f..9ae562b1db 100644
--- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h
+++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h
@@ -52,12 +52,12 @@ public:
QGtk2ColorDialogHelper();
~QGtk2ColorDialogHelper();
- bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent);
- void exec();
- void hide();
+ bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE;
+ void exec() Q_DECL_OVERRIDE;
+ void hide() Q_DECL_OVERRIDE;
- void setCurrentColor(const QColor &color);
- QColor currentColor() const;
+ void setCurrentColor(const QColor &color) Q_DECL_OVERRIDE;
+ QColor currentColor() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void onAccepted();
@@ -77,18 +77,18 @@ public:
QGtk2FileDialogHelper();
~QGtk2FileDialogHelper();
- bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent);
- void exec();
- void hide();
+ bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE;
+ void exec() Q_DECL_OVERRIDE;
+ void hide() Q_DECL_OVERRIDE;
- bool defaultNameFilterDisables() const;
+ bool defaultNameFilterDisables() const Q_DECL_OVERRIDE;
void setDirectory(const QUrl &directory) Q_DECL_OVERRIDE;
QUrl directory() const Q_DECL_OVERRIDE;
void selectFile(const QUrl &filename) Q_DECL_OVERRIDE;
QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE;
- void setFilter();
- void selectNameFilter(const QString &filter);
- QString selectedNameFilter() const;
+ void setFilter() Q_DECL_OVERRIDE;
+ void selectNameFilter(const QString &filter) Q_DECL_OVERRIDE;
+ QString selectedNameFilter() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void onAccepted();
@@ -114,12 +114,12 @@ public:
QGtk2FontDialogHelper();
~QGtk2FontDialogHelper();
- bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent);
- void exec();
- void hide();
+ bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE;
+ void exec() Q_DECL_OVERRIDE;
+ void hide() Q_DECL_OVERRIDE;
- void setCurrentFont(const QFont &font);
- QFont currentFont() const;
+ void setCurrentFont(const QFont &font) Q_DECL_OVERRIDE;
+ QFont currentFont() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void onAccepted();
diff --git a/src/plugins/platformthemes/gtk2/qgtk2theme.h b/src/plugins/platformthemes/gtk2/qgtk2theme.h
index 304d7789f5..fd8e90fe5c 100644
--- a/src/plugins/platformthemes/gtk2/qgtk2theme.h
+++ b/src/plugins/platformthemes/gtk2/qgtk2theme.h
@@ -46,8 +46,8 @@ public:
virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
virtual QString gtkFontName() const Q_DECL_OVERRIDE;
- bool usePlatformNativeDialog(DialogType type) const;
- QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
+ bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE;
+ QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE;
static const char *name;
};
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index d1cbff59c1..587063b100 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -3,5 +3,6 @@ TEMPLATE = subdirs
SUBDIRS *= sqldrivers
!winrt:qtHaveModule(network): SUBDIRS += bearer
qtHaveModule(gui): SUBDIRS *= imageformats platforms platforminputcontexts platformthemes generic
+qtHaveModule(widgets): SUBDIRS *= styles
!winrt:!wince*:qtHaveModule(widgets):SUBDIRS += printsupport
diff --git a/src/plugins/printsupport/cups/main.cpp b/src/plugins/printsupport/cups/main.cpp
index 5a7b9d7440..d404b3e1c6 100644
--- a/src/plugins/printsupport/cups/main.cpp
+++ b/src/plugins/printsupport/cups/main.cpp
@@ -48,7 +48,7 @@ class QCupsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
public:
QStringList keys() const;
- QPlatformPrinterSupport *create(const QString &);
+ QPlatformPrinterSupport *create(const QString &) Q_DECL_OVERRIDE;
};
QStringList QCupsPrinterSupportPlugin::keys() const
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index d7cd18f1d1..b24b2393ef 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -46,8 +46,6 @@
#include <QtGui/qpagelayout.h>
#include <cups/cups.h>
-#include <limits.h>
-#include <math.h>
#include "private/qcore_unix_p.h" // overrides QT_OPEN
diff --git a/src/plugins/printsupport/cups/qcupsprintengine_p.h b/src/plugins/printsupport/cups/qcupsprintengine_p.h
index a083b1840a..e11db972aa 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine_p.h
+++ b/src/plugins/printsupport/cups/qcupsprintengine_p.h
@@ -68,8 +68,8 @@ public:
virtual ~QCupsPrintEngine();
// reimplementations QPdfPrintEngine
- void setProperty(PrintEnginePropertyKey key, const QVariant &value);
- QVariant property(PrintEnginePropertyKey key) const;
+ void setProperty(PrintEnginePropertyKey key, const QVariant &value) Q_DECL_OVERRIDE;
+ QVariant property(PrintEnginePropertyKey key) const Q_DECL_OVERRIDE;
// end reimplementations QPdfPrintEngine
private:
@@ -83,8 +83,8 @@ public:
QCupsPrintEnginePrivate(QPrinter::PrinterMode m);
~QCupsPrintEnginePrivate();
- bool openPrintDevice();
- void closePrintDevice();
+ bool openPrintDevice() Q_DECL_OVERRIDE;
+ void closePrintDevice() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QCupsPrintEnginePrivate)
diff --git a/src/plugins/sqldrivers/mysql/main.cpp b/src/plugins/sqldrivers/mysql/main.cpp
index 9448db59b1..2bc6e45a38 100644
--- a/src/plugins/sqldrivers/mysql/main.cpp
+++ b/src/plugins/sqldrivers/mysql/main.cpp
@@ -45,7 +45,7 @@ class QMYSQLDriverPlugin : public QSqlDriverPlugin
public:
QMYSQLDriverPlugin();
- QSqlDriver* create(const QString &);
+ QSqlDriver* create(const QString &) Q_DECL_OVERRIDE;
};
QMYSQLDriverPlugin::QMYSQLDriverPlugin()
diff --git a/src/plugins/sqldrivers/psql/main.cpp b/src/plugins/sqldrivers/psql/main.cpp
index 49217e8f1e..3bbb0a3a4e 100644
--- a/src/plugins/sqldrivers/psql/main.cpp
+++ b/src/plugins/sqldrivers/psql/main.cpp
@@ -45,7 +45,7 @@ class QPSQLDriverPlugin : public QSqlDriverPlugin
public:
QPSQLDriverPlugin();
- QSqlDriver* create(const QString &);
+ QSqlDriver* create(const QString &) Q_DECL_OVERRIDE;
};
QPSQLDriverPlugin::QPSQLDriverPlugin()
diff --git a/src/plugins/sqldrivers/sqlite/smain.cpp b/src/plugins/sqldrivers/sqlite/smain.cpp
index 3b0ca5aaba..2d040ff5d6 100644
--- a/src/plugins/sqldrivers/sqlite/smain.cpp
+++ b/src/plugins/sqldrivers/sqlite/smain.cpp
@@ -45,7 +45,7 @@ class QSQLiteDriverPlugin : public QSqlDriverPlugin
public:
QSQLiteDriverPlugin();
- QSqlDriver* create(const QString &);
+ QSqlDriver* create(const QString &) Q_DECL_OVERRIDE;
};
QSQLiteDriverPlugin::QSQLiteDriverPlugin()
diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro
index 60b30d70c0..cc6d02cbe8 100644
--- a/src/plugins/sqldrivers/sqlite/sqlite.pro
+++ b/src/plugins/sqldrivers/sqlite/sqlite.pro
@@ -4,7 +4,5 @@ SOURCES = smain.cpp
OTHER_FILES += sqlite.json
include(../../../sql/drivers/sqlite/qsql_sqlite.pri)
-wince*: DEFINES += HAVE_LOCALTIME_S=0
-
PLUGIN_CLASS_NAME = QSQLiteDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/plugins/styles/bb10style/bb10lightstyle.qrc b/src/plugins/styles/bb10style/bb10lightstyle.qrc
new file mode 100644
index 0000000000..0777e009bb
--- /dev/null
+++ b/src/plugins/styles/bb10style/bb10lightstyle.qrc
@@ -0,0 +1,54 @@
+<RCC>
+ <qresource prefix="/">
+ <file>light/button/core_button_disabled.png</file>
+ <file>light/button/core_button_inactive.png</file>
+ <file>light/button/core_button_pressed.png</file>
+ <file>light/checkbox/core_checkbox_checked.png</file>
+ <file>light/checkbox/core_checkbox_disabled.png</file>
+ <file>light/checkbox/core_checkbox_disabledchecked.png</file>
+ <file>light/checkbox/core_checkbox_enabled.png</file>
+ <file>light/checkbox/core_checkbox_pressed.png</file>
+ <file>light/checkbox/core_checkbox_pressedchecked.png</file>
+ <file>light/radiobutton/core_radiobutton_checked.png</file>
+ <file>light/radiobutton/core_radiobutton_disabled.png</file>
+ <file>light/radiobutton/core_radiobutton_disabledchecked.png</file>
+ <file>light/radiobutton/core_radiobutton_enabled.png</file>
+ <file>light/radiobutton/core_radiobutton_pressed.png</file>
+ <file>light/slider/core_slider_active.png</file>
+ <file>light/slider/core_slider_disabled.png</file>
+ <file>light/slider/core_slider_handle.png</file>
+ <file>light/slider/core_slider_handle_disabled.png</file>
+ <file>light/slider/core_slider_handle_pressed.png</file>
+ <file>light/slider/core_slider_inactive.png</file>
+ <file>light/slider/core_slider_vactive.png</file>
+ <file>light/slider/core_slider_vdisabled.png</file>
+ <file>light/slider/core_slider_vinactive.png</file>
+ <file>light/slider/core_slider_black.png</file>
+ <file>light/slider/core_slider_enabled.png</file>
+ <file>light/slider/core_slider_vblack.png</file>
+ <file>light/slider/core_slider_venabled.png</file>
+ <file>light/button/core_button_active.png</file>
+ <file>light/lineedit/core_textinput_bg.png</file>
+ <file>light/lineedit/core_textinput_bg_disabled.png</file>
+ <file>light/lineedit/core_textinput_bg_focused.png</file>
+ <file>light/progressbar/core_progressindicator_bg.png</file>
+ <file>light/progressbar/core_progressindicator_complete.png</file>
+ <file>light/progressbar/core_progressindicator_fill.png</file>
+ <file>light/progressbar/core_progressindicator_vbg.png</file>
+ <file>light/progressbar/core_progressindicator_vcomplete.png</file>
+ <file>light/progressbar/core_progressindicator_vfill.png</file>
+ <file>light/combobox/core_dropdown_button.png</file>
+ <file>light/combobox/core_dropdown_button_arrowdown.png</file>
+ <file>light/combobox/core_dropdown_button_arrowdown_pressed.png</file>
+ <file>light/combobox/core_dropdown_button_arrowup.png</file>
+ <file>light/combobox/core_dropdown_button_disabled.png</file>
+ <file>light/combobox/core_dropdown_button_pressed.png</file>
+ <file>light/combobox/core_dropdown_checkmark.png</file>
+ <file>light/combobox/core_dropdown_divider.png</file>
+ <file>light/combobox/core_dropdown_menu.png</file>
+ <file>light/combobox/core_dropdown_menuup.png</file>
+ <file>light/combobox/core_listitem_active.png</file>
+ <file>light/listitem/core_listitem_active.png</file>
+ <file>light/listitem/core_listitem_divider.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/styles/bb10style/bb10style.pro b/src/plugins/styles/bb10style/bb10style.pro
new file mode 100644
index 0000000000..ad35df6de7
--- /dev/null
+++ b/src/plugins/styles/bb10style/bb10style.pro
@@ -0,0 +1,28 @@
+TARGET = bb10styleplugin
+
+PLUGIN_TYPE = styles
+PLUGIN_CLASS_NAME = BlackBerry10StylePlugin
+load(qt_plugin)
+
+INCLUDEPATH += $$PWD
+
+QT += widgets
+
+HEADERS += \
+ qpixmapstyle.h \
+ qbb10brightstyle.h \
+ qbb10darkstyle.h \
+ qbb10styleplugin.h
+
+SOURCES += \
+ qpixmapstyle.cpp \
+ qbb10brightstyle.cpp \
+ qbb10darkstyle.cpp \
+ qbb10styleplugin.cpp
+
+RESOURCES += \
+ qbb10brightstyle.qrc \
+ qbb10darkstyle.qrc
+
+OTHER_FILES += qbb10styleplugin.json
+
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_disabled.png b/src/plugins/styles/bb10style/bright/button/core_button_disabled.png
new file mode 100644
index 0000000000..578a2383b8
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/button/core_button_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png b/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png
new file mode 100644
index 0000000000..7cd998af46
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png b/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png
new file mode 100644
index 0000000000..ff0850f616
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
new file mode 100755
index 0000000000..7769f15e44
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
new file mode 100755
index 0000000000..59b5bfa7c2
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png
new file mode 100644
index 0000000000..c59f60633c
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png
new file mode 100644
index 0000000000..49d9cfdf94
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png
new file mode 100644
index 0000000000..35751553e1
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png
new file mode 100644
index 0000000000..2a0c56b503
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
new file mode 100755
index 0000000000..f1c2ee3bed
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png
new file mode 100644
index 0000000000..d58df47cbf
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png
new file mode 100644
index 0000000000..1aa844309f
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png
new file mode 100644
index 0000000000..9ac049fb3d
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png
new file mode 100644
index 0000000000..d11af56b71
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png
new file mode 100644
index 0000000000..d10779d8d7
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png
new file mode 100644
index 0000000000..f9e1c9465b
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png
new file mode 100644
index 0000000000..27a321e387
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png
new file mode 100644
index 0000000000..a8270aed56
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png
new file mode 100644
index 0000000000..0198293ad6
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png
new file mode 100644
index 0000000000..47e7b2d4b6
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png
new file mode 100644
index 0000000000..2bde84e71d
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png b/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png
new file mode 100644
index 0000000000..4935d13c05
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
new file mode 100755
index 0000000000..07b8ea21bf
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png
new file mode 100644
index 0000000000..ab1083e9fa
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
new file mode 100755
index 0000000000..55f8aee066
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
new file mode 100755
index 0000000000..34daccc27e
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
new file mode 100755
index 0000000000..7a1e22321d
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
new file mode 100755
index 0000000000..3ff930dea7
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png
new file mode 100644
index 0000000000..87974668ff
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png
new file mode 100644
index 0000000000..8ff257dad3
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png
new file mode 100644
index 0000000000..66cf8cac8f
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png
new file mode 100644
index 0000000000..f18e0abafb
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png
new file mode 100644
index 0000000000..94e388a7aa
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png
new file mode 100644
index 0000000000..5dc5e52d88
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png
new file mode 100644
index 0000000000..077aa79c65
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png
new file mode 100644
index 0000000000..439499040a
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
new file mode 100755
index 0000000000..cb4c6a8136
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
new file mode 100755
index 0000000000..88fd1344d2
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
new file mode 100755
index 0000000000..79154e0568
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png
new file mode 100644
index 0000000000..169a4e1656
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_active.png b/src/plugins/styles/bb10style/bright/slider/core_slider_active.png
new file mode 100644
index 0000000000..c23c0ebc26
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png b/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png
new file mode 100644
index 0000000000..6b7224d702
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png
new file mode 100644
index 0000000000..9de7567e68
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png
new file mode 100644
index 0000000000..ad5c35076c
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png
new file mode 100644
index 0000000000..076e272794
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png
new file mode 100644
index 0000000000..5989fcaaeb
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
new file mode 100755
index 0000000000..8cb79118b9
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png b/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png
new file mode 100644
index 0000000000..8836534923
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png
new file mode 100644
index 0000000000..03062326f2
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png
new file mode 100644
index 0000000000..b0d94d7127
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png
new file mode 100644
index 0000000000..ce99b1a3ac
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png
new file mode 100644
index 0000000000..910b6627d4
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png
new file mode 100644
index 0000000000..18a9819af8
--- /dev/null
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_disabled.png b/src/plugins/styles/bb10style/dark/button/core_button_disabled.png
new file mode 100644
index 0000000000..79245dbf11
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/button/core_button_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png b/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png
new file mode 100644
index 0000000000..5eb86b70f3
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png b/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png
new file mode 100644
index 0000000000..7b1a6ce40b
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
new file mode 100755
index 0000000000..97842e1ac4
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
new file mode 100755
index 0000000000..c149b64a26
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png
new file mode 100644
index 0000000000..5a8af33094
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png
new file mode 100644
index 0000000000..74a24522fa
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png
new file mode 100644
index 0000000000..1e953221b6
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png
new file mode 100644
index 0000000000..5e51e7f39b
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
new file mode 100755
index 0000000000..507a77b3ea
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png
new file mode 100644
index 0000000000..7fa85428a0
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png
new file mode 100644
index 0000000000..a68d93acb5
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png
new file mode 100644
index 0000000000..4c1d085360
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png
new file mode 100644
index 0000000000..1ee578e07c
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png
new file mode 100644
index 0000000000..3239ef4bd6
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png
new file mode 100644
index 0000000000..af6793b87c
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png
new file mode 100644
index 0000000000..df6d402554
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png
new file mode 100644
index 0000000000..578c80aa5f
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png
new file mode 100644
index 0000000000..43b1025d36
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png
new file mode 100644
index 0000000000..1f52362050
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png
new file mode 100644
index 0000000000..62c7a2e558
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png b/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png
new file mode 100644
index 0000000000..1df4a7aad9
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
new file mode 100755
index 0000000000..07b8ea21bf
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png
new file mode 100644
index 0000000000..6bcaf91f87
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
new file mode 100755
index 0000000000..9b115897e8
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
new file mode 100755
index 0000000000..52aa4e4aa2
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
new file mode 100755
index 0000000000..39e3a8a4f5
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
new file mode 100755
index 0000000000..95fcafb437
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png
new file mode 100644
index 0000000000..e849c8f179
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png
new file mode 100644
index 0000000000..e8fd3b0173
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png
new file mode 100644
index 0000000000..1433f3ec33
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png
new file mode 100644
index 0000000000..d750e4671c
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png
new file mode 100644
index 0000000000..2c3c0a5e6c
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png
new file mode 100644
index 0000000000..1721586ac5
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png
new file mode 100644
index 0000000000..e646c9174b
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png
new file mode 100644
index 0000000000..93b3118e8d
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
new file mode 100755
index 0000000000..fd61937d65
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
new file mode 100755
index 0000000000..58a1a57b4c
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
new file mode 100755
index 0000000000..384f60758a
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png
new file mode 100644
index 0000000000..2542f2acaf
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_active.png b/src/plugins/styles/bb10style/dark/slider/core_slider_active.png
new file mode 100644
index 0000000000..6bdb413ced
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png b/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png
new file mode 100644
index 0000000000..eea5b3d78e
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png
new file mode 100644
index 0000000000..6a233315e4
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png
new file mode 100644
index 0000000000..2b297e5ca2
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png
new file mode 100644
index 0000000000..fbd37e5584
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png
new file mode 100644
index 0000000000..49cb6a42a7
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
new file mode 100755
index 0000000000..803c374015
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png b/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png
new file mode 100644
index 0000000000..08a1aecb6c
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png
new file mode 100644
index 0000000000..c8e467d9e6
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png
new file mode 100644
index 0000000000..ff160cbb1d
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png
new file mode 100644
index 0000000000..27d348122b
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png
new file mode 100644
index 0000000000..ff8a74a19f
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png
new file mode 100644
index 0000000000..b2b19a5460
--- /dev/null
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/qbb10brightstyle.cpp b/src/plugins/styles/bb10style/qbb10brightstyle.cpp
new file mode 100644
index 0000000000..8e6da406ea
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10brightstyle.cpp
@@ -0,0 +1,352 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbb10brightstyle.h"
+
+#include <QApplication>
+#include <QFont>
+#include <QStyleOption>
+#include <QProgressBar>
+#include <QComboBox>
+#include <QAbstractItemView>
+#include <QPainter>
+
+QT_BEGIN_NAMESPACE
+
+QBB10BrightStyle::QBB10BrightStyle() :
+ QPixmapStyle()
+{
+ addDescriptor(PB_Enabled,
+ QLatin1String("://bright/button/core_button_inactive.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_Checked,
+ QLatin1String("://bright/button/core_button_enabled_selected.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_Pressed,
+ QLatin1String("://bright/button/core_button_pressed.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_Disabled,
+ QLatin1String("://bright/button/core_button_disabled.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_PressedDisabled,
+ QLatin1String("://bright/button/core_button_disabled_selected.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+
+ addDescriptor(LE_Enabled,
+ QLatin1String("://bright/lineedit/core_textinput_bg.png"),
+ QMargins(8, 8, 8, 8));
+ addDescriptor(LE_Disabled,
+ QLatin1String("://bright/lineedit/core_textinput_bg_disabled.png"),
+ QMargins(8, 8, 8, 8));
+ addDescriptor(LE_Focused,
+ QLatin1String("://bright/lineedit/core_textinput_bg_highlight.png"),
+ QMargins(8, 8, 8, 8));
+
+ copyDescriptor(LE_Enabled, TE_Enabled);
+ copyDescriptor(LE_Disabled, TE_Disabled);
+ copyDescriptor(LE_Focused, TE_Focused);
+
+ addPixmap(CB_Enabled,
+ QLatin1String("://bright/checkbox/core_checkbox_enabled.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_Checked,
+ QLatin1String("://bright/checkbox/core_checkbox_checked.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_Pressed,
+ QLatin1String("://bright/checkbox/core_checkbox_pressed.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_PressedChecked,
+ QLatin1String("://bright/checkbox/core_checkbox_pressed_checked.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_Disabled,
+ QLatin1String("://bright/checkbox/core_checkbox_disabled.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_DisabledChecked,
+ QLatin1String("://bright/checkbox/core_checkbox_disabled_checked.png"),
+ QMargins(16, 16, 16, 16));
+
+ addPixmap(RB_Enabled,
+ QLatin1String("://bright/radiobutton/core_radiobutton_inactive.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_Checked,
+ QLatin1String("://bright/radiobutton/core_radiobutton_checked.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_Pressed,
+ QLatin1String("://bright/radiobutton/core_radiobutton_pressed.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_Disabled,
+ QLatin1String("://bright/radiobutton/core_radiobutton_disabled.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_DisabledChecked,
+ QLatin1String("://bright/radiobutton/core_radiobutton_disabled_checked.png"),
+ QMargins(16, 16, 16, 16));
+
+ addDescriptor(PB_HBackground,
+ QLatin1String("://bright/progressbar/core_progressindicator_bg.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_HContent,
+ QLatin1String("://bright/progressbar/core_progressindicator_fill.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_HComplete,
+ QLatin1String("://bright/progressbar/core_progressindicator_complete.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_VBackground,
+ QLatin1String("://bright/progressbar/core_progressindicator_vbg.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(PB_VContent,
+ QLatin1String("://bright/progressbar/core_progressindicator_vfill.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(PB_VComplete,
+ QLatin1String("://bright/progressbar/core_progressindicator_vcomplete.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+
+ addDescriptor(SG_HEnabled,
+ QLatin1String("://bright/slider/core_slider_enabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HDisabled,
+ QLatin1String("://bright/slider/core_slider_disabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HActiveEnabled,
+ QLatin1String("://bright/slider/core_slider_inactive.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HActivePressed,
+ QLatin1String("://bright/slider/core_slider_active.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HActiveDisabled,
+ QLatin1String("://bright/slider/core_slider_cache.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_VEnabled,
+ QLatin1String("://bright/slider/core_slider_venabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VDisabled,
+ QLatin1String("://bright/slider/core_slider_vdisabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VActiveEnabled,
+ QLatin1String("://bright/slider/core_slider_vinactive.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VActivePressed,
+ QLatin1String("://bright/slider/core_slider_vactive.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VActiveDisabled,
+ QLatin1String("://bright/slider/core_slider_vcache.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+
+ addPixmap(SH_HEnabled,
+ QLatin1String("://bright/slider/core_slider_handle.png"));
+ addPixmap(SH_HDisabled,
+ QLatin1String("://bright/slider/core_slider_handle_disabled.png"));
+ addPixmap(SH_HPressed,
+ QLatin1String("://bright/slider/core_slider_handle_pressed.png"));
+ addPixmap(SH_VEnabled,
+ QLatin1String("://bright/slider/core_slider_handle.png"));
+ addPixmap(SH_VDisabled,
+ QLatin1String("://bright/slider/core_slider_handle_disabled.png"));
+ addPixmap(SH_VPressed,
+ QLatin1String("://bright/slider/core_slider_handle_pressed.png"));
+
+ addDescriptor(DD_ButtonEnabled,
+ QLatin1String("://bright/combobox/core_dropdown_button.png"),
+ QMargins(14, 14, 14, 14),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(DD_ButtonDisabled,
+ QLatin1String("://bright/combobox/core_dropdown_button_disabled.png"),
+ QMargins(14, 14, 14, 14),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(DD_ButtonPressed,
+ QLatin1String("://bright/combobox/core_dropdown_button_pressed.png"),
+ QMargins(14, 14, 14, 14),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(DD_ItemSelected,
+ QLatin1String("://bright/combobox/core_listitem_active.png"));
+
+ addPixmap(DD_ArrowEnabled,
+ QLatin1String("://bright/combobox/core_dropdown_button_arrowdown.png"),
+ QMargins(35, 39, 35, 39));
+ copyPixmap(DD_ArrowEnabled, DD_ArrowDisabled);
+ addPixmap(DD_ArrowPressed,
+ QLatin1String("://bright/combobox/core_dropdown_button_arrowdown_pressed.png"),
+ QMargins(35, 39, 35, 39));
+ addPixmap(DD_ArrowOpen,
+ QLatin1String("://bright/combobox/core_dropdown_button_arrowup.png"),
+ QMargins(35, 39, 35, 39));
+ addDescriptor(DD_PopupDown,
+ QLatin1String("://bright/combobox/core_dropdown_menu.png"),
+ QMargins(12, 12, 12, 12),
+ QTileRules(Qt::StretchTile, Qt::StretchTile));
+ addDescriptor(DD_PopupUp,
+ QLatin1String("://bright/combobox/core_dropdown_menuup.png"),
+ QMargins(12, 12, 12, 12),
+ QTileRules(Qt::StretchTile, Qt::StretchTile));
+ addPixmap(DD_ItemSeparator,
+ QLatin1String("://bright/combobox/core_dropdown_divider.png"),
+ QMargins(5, 0, 5, 0));
+
+ addDescriptor(ID_Selected,
+ QLatin1String("://bright/listitem/core_listitem_active.png"));
+ addPixmap(ID_Separator,
+ QLatin1String("://bright/listitem/core_listitem_divider.png"));
+
+ addDescriptor(SB_Horizontal,
+ QLatin1String("://bright/scrollbar/core_scrollbar.png"),
+ QMargins(7, 8, 7, 8),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SB_Vertical,
+ QLatin1String("://bright/scrollbar/core_scrollbar_v.png"),
+ QMargins(8, 7, 8, 7),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+}
+
+QBB10BrightStyle::~QBB10BrightStyle()
+{
+}
+
+void QBB10BrightStyle::polish(QApplication *application)
+{
+ QPixmapStyle::polish(application);
+}
+
+void QBB10BrightStyle::polish(QWidget *widget)
+{
+ // Hide the text by default
+ if (QProgressBar *pb = qobject_cast<QProgressBar*>(widget))
+ pb->setTextVisible(false);
+
+ if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) {
+ QAbstractItemView *list = cb->view();
+ QPalette p = list->palette();
+ p.setBrush(QPalette::HighlightedText, p.brush(QPalette::Text));
+ list->setPalette(p);
+ }
+
+ if (qobject_cast<QAbstractItemView*>(widget)) {
+ QPalette p = widget->palette();
+ p.setBrush(QPalette::Disabled, QPalette::HighlightedText, p.brush(QPalette::Text));
+ widget->setPalette(p);
+ }
+
+ QPixmapStyle::polish(widget);
+}
+
+QPalette QBB10BrightStyle::standardPalette() const
+{
+ QPalette p;
+
+ QColor color = QColor(38, 38, 38);
+ p.setBrush(QPalette::ButtonText, color);
+ p.setBrush(QPalette::WindowText, color);
+ p.setBrush(QPalette::Text, color);
+
+ color.setAlpha(179);
+ p.setBrush(QPalette::Disabled, QPalette::ButtonText, color);
+ p.setBrush(QPalette::Disabled, QPalette::WindowText, color);
+ p.setBrush(QPalette::Disabled, QPalette::Text, color);
+
+ p.setColor(QPalette::Window, QColor(248, 248, 248));
+
+ p.setBrush(QPalette::Highlight, QColor(0, 168, 223));
+ p.setBrush(QPalette::HighlightedText, QColor(250, 250,250));
+
+ return p;
+}
+
+void QBB10BrightStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ switch (element) {
+ case CE_PushButtonLabel:
+ {
+ const bool on = option->state & State_On || option->state & State_Sunken;
+ const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option);
+ QStyleOptionButton newOpt = *button;
+ if (on)
+ newOpt.palette.setBrush(QPalette::ButtonText, QColor(250, 250, 250));
+ QPixmapStyle::drawControl(CE_PushButtonLabel, &newOpt, painter, widget);
+ break;
+ }
+ case CE_ProgressBarLabel:
+ // Don't draw the progress bar label
+ break;
+ default:
+ QPixmapStyle::drawControl(element, option, painter, widget);
+ }
+}
+
+void QBB10BrightStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ QPixmapStyle::drawPrimitive(element, option, painter, widget);
+
+ if (element == PE_PanelItemViewItem) {
+ // Draw the checkbox for current item
+ if (widget->property("_pixmap_combobox_list").toBool()
+ && option->state & QStyle::State_Selected) {
+ QPixmap pix(QLatin1String("://bright/combobox/core_dropdown_checkmark.png"));
+ QRect rect = option->rect;
+ const int margin = rect.height() / 2;
+ QPoint pos(rect.right() - margin - pix.width() / 2,
+ rect.top() + margin - pix.height() / 2);
+ painter->drawPixmap(pos, pix);
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/styles/bb10style/qbb10brightstyle.h b/src/plugins/styles/bb10style/qbb10brightstyle.h
new file mode 100644
index 0000000000..4a63b1dc48
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10brightstyle.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBB10BRIGHTSTYLE_H
+#define QBB10BRIGHTSTYLE_H
+
+#include "qpixmapstyle.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBB10BrightStyle : public QPixmapStyle
+{
+ Q_OBJECT
+
+public:
+ QBB10BrightStyle();
+ ~QBB10BrightStyle();
+
+ void polish(QApplication *application);
+ void polish(QWidget *widget);
+
+ QPalette standardPalette() const;
+
+ void drawControl(ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBB10BRIGHTSTYLE_H
diff --git a/src/plugins/styles/bb10style/qbb10brightstyle.qrc b/src/plugins/styles/bb10style/qbb10brightstyle.qrc
new file mode 100644
index 0000000000..2172536fa3
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10brightstyle.qrc
@@ -0,0 +1,57 @@
+<RCC>
+ <qresource prefix="/">
+ <file>bright/button/core_button_disabled.png</file>
+ <file>bright/button/core_button_disabled_selected.png</file>
+ <file>bright/button/core_button_inactive.png</file>
+ <file>bright/button/core_button_enabled_selected.png</file>
+ <file>bright/button/core_button_pressed.png</file>
+ <file>bright/checkbox/core_checkbox_checked.png</file>
+ <file>bright/checkbox/core_checkbox_disabled.png</file>
+ <file>bright/checkbox/core_checkbox_disabled_checked.png</file>
+ <file>bright/checkbox/core_checkbox_enabled.png</file>
+ <file>bright/checkbox/core_checkbox_pressed.png</file>
+ <file>bright/checkbox/core_checkbox_pressed_checked.png</file>
+ <file>bright/combobox/core_dropdown_button.png</file>
+ <file>bright/combobox/core_dropdown_button_arrowdown.png</file>
+ <file>bright/combobox/core_dropdown_button_arrowdown_pressed.png</file>
+ <file>bright/combobox/core_dropdown_button_arrowup.png</file>
+ <file>bright/combobox/core_dropdown_button_disabled.png</file>
+ <file>bright/combobox/core_dropdown_button_pressed.png</file>
+ <file>bright/combobox/core_dropdown_checkmark.png</file>
+ <file>bright/combobox/core_dropdown_divider.png</file>
+ <file>bright/combobox/core_dropdown_menu.png</file>
+ <file>bright/combobox/core_dropdown_menuup.png</file>
+ <file>bright/combobox/core_listitem_active.png</file>
+ <file>bright/lineedit/core_textinput_bg.png</file>
+ <file>bright/lineedit/core_textinput_bg_disabled.png</file>
+ <file>bright/lineedit/core_textinput_bg_highlight.png</file>
+ <file>bright/listitem/core_listitem_active.png</file>
+ <file>bright/listitem/core_listitem_divider.png</file>
+ <file>bright/progressbar/core_progressindicator_bg.png</file>
+ <file>bright/progressbar/core_progressindicator_complete.png</file>
+ <file>bright/progressbar/core_progressindicator_fill.png</file>
+ <file>bright/progressbar/core_progressindicator_vbg.png</file>
+ <file>bright/progressbar/core_progressindicator_vcomplete.png</file>
+ <file>bright/progressbar/core_progressindicator_vfill.png</file>
+ <file>bright/radiobutton/core_radiobutton_checked.png</file>
+ <file>bright/radiobutton/core_radiobutton_disabled.png</file>
+ <file>bright/radiobutton/core_radiobutton_disabled_checked.png</file>
+ <file>bright/radiobutton/core_radiobutton_inactive.png</file>
+ <file>bright/radiobutton/core_radiobutton_pressed.png</file>
+ <file>bright/scrollbar/core_scrollbar.png</file>
+ <file>bright/scrollbar/core_scrollbar_v.png</file>
+ <file>bright/slider/core_slider_active.png</file>
+ <file>bright/slider/core_slider_cache.png</file>
+ <file>bright/slider/core_slider_disabled.png</file>
+ <file>bright/slider/core_slider_enabled.png</file>
+ <file>bright/slider/core_slider_handle.png</file>
+ <file>bright/slider/core_slider_handle_disabled.png</file>
+ <file>bright/slider/core_slider_handle_pressed.png</file>
+ <file>bright/slider/core_slider_inactive.png</file>
+ <file>bright/slider/core_slider_vactive.png</file>
+ <file>bright/slider/core_slider_vcache.png</file>
+ <file>bright/slider/core_slider_vdisabled.png</file>
+ <file>bright/slider/core_slider_venabled.png</file>
+ <file>bright/slider/core_slider_vinactive.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/styles/bb10style/qbb10darkstyle.cpp b/src/plugins/styles/bb10style/qbb10darkstyle.cpp
new file mode 100644
index 0000000000..85bf4a7917
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10darkstyle.cpp
@@ -0,0 +1,357 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbb10darkstyle.h"
+
+#include <QApplication>
+#include <QFont>
+#include <QStyleOption>
+#include <QProgressBar>
+#include <QComboBox>
+#include <QAbstractItemView>
+#include <QPainter>
+#include <QLineEdit>
+#include <QTextEdit>
+
+QT_BEGIN_NAMESPACE
+
+QBB10DarkStyle::QBB10DarkStyle() :
+ QPixmapStyle()
+{
+ addDescriptor(PB_Enabled,
+ QLatin1String("://dark/button/core_button_inactive.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_Checked,
+ QLatin1String("://dark/button/core_button_enabled_selected.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_Pressed,
+ QLatin1String("://dark/button/core_button_pressed.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_Disabled,
+ QLatin1String("://dark/button/core_button_disabled.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_PressedDisabled,
+ QLatin1String("://dark/button/core_button_disabled_selected.png"),
+ QMargins(13, 13, 13, 13),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+
+ addDescriptor(LE_Enabled,
+ QLatin1String("://dark/lineedit/core_textinput_bg.png"),
+ QMargins(8, 8, 8, 8));
+ addDescriptor(LE_Disabled,
+ QLatin1String("://dark/lineedit/core_textinput_bg_disabled.png"),
+ QMargins(8, 8, 8, 8));
+ addDescriptor(LE_Focused,
+ QLatin1String("://dark/lineedit/core_textinput_bg_highlight.png"),
+ QMargins(8, 8, 8, 8));
+
+ copyDescriptor(LE_Enabled, TE_Enabled);
+ copyDescriptor(LE_Disabled, TE_Disabled);
+ copyDescriptor(LE_Focused, TE_Focused);
+
+ addPixmap(CB_Enabled,
+ QLatin1String("://dark/checkbox/core_checkbox_enabled.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_Checked,
+ QLatin1String("://dark/checkbox/core_checkbox_checked.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_Pressed,
+ QLatin1String("://dark/checkbox/core_checkbox_pressed.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_PressedChecked,
+ QLatin1String("://dark/checkbox/core_checkbox_pressed_checked.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_Disabled,
+ QLatin1String("://dark/checkbox/core_checkbox_disabled.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(CB_DisabledChecked,
+ QLatin1String("://dark/checkbox/core_checkbox_disabled_checked.png"),
+ QMargins(16, 16, 16, 16));
+
+ addPixmap(RB_Enabled,
+ QLatin1String("://dark/radiobutton/core_radiobutton_inactive.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_Checked,
+ QLatin1String("://dark/radiobutton/core_radiobutton_checked.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_Pressed,
+ QLatin1String("://dark/radiobutton/core_radiobutton_pressed.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_Disabled,
+ QLatin1String("://dark/radiobutton/core_radiobutton_disabled.png"),
+ QMargins(16, 16, 16, 16));
+ addPixmap(RB_DisabledChecked,
+ QLatin1String("://dark/radiobutton/core_radiobutton_disabled_checked.png"),
+ QMargins(16, 16, 16, 16));
+
+ addDescriptor(PB_HBackground,
+ QLatin1String("://dark/progressbar/core_progressindicator_bg.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_HContent,
+ QLatin1String("://dark/progressbar/core_progressindicator_fill.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_HComplete,
+ QLatin1String("://dark/progressbar/core_progressindicator_complete.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(PB_VBackground,
+ QLatin1String("://dark/progressbar/core_progressindicator_vbg.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(PB_VContent,
+ QLatin1String("://dark/progressbar/core_progressindicator_vfill.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(PB_VComplete,
+ QLatin1String("://dark/progressbar/core_progressindicator_vcomplete.png"),
+ QMargins(10, 10, 10, 10),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+
+ addDescriptor(SG_HEnabled,
+ QLatin1String("://dark/slider/core_slider_enabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HDisabled,
+ QLatin1String("://dark/slider/core_slider_disabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HActiveEnabled,
+ QLatin1String("://dark/slider/core_slider_inactive.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HActivePressed,
+ QLatin1String("://dark/slider/core_slider_active.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_HActiveDisabled,
+ QLatin1String("://dark/slider/core_slider_cache.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SG_VEnabled,
+ QLatin1String("://dark/slider/core_slider_venabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VDisabled,
+ QLatin1String("://dark/slider/core_slider_vdisabled.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VActiveEnabled,
+ QLatin1String("://dark/slider/core_slider_vinactive.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VActivePressed,
+ QLatin1String("://dark/slider/core_slider_vactive.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+ addDescriptor(SG_VActiveDisabled,
+ QLatin1String("://dark/slider/core_slider_vcache.png"),
+ QMargins(50, 50, 50, 50),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+
+ addPixmap(SH_HEnabled,
+ QLatin1String("://dark/slider/core_slider_handle.png"));
+ addPixmap(SH_HDisabled,
+ QLatin1String("://dark/slider/core_slider_handle_disabled.png"));
+ addPixmap(SH_HPressed,
+ QLatin1String("://dark/slider/core_slider_handle_pressed.png"));
+ addPixmap(SH_VEnabled,
+ QLatin1String("://dark/slider/core_slider_handle.png"));
+ addPixmap(SH_VDisabled,
+ QLatin1String("://dark/slider/core_slider_handle_disabled.png"));
+ addPixmap(SH_VPressed,
+ QLatin1String("://dark/slider/core_slider_handle_pressed.png"));
+
+ addDescriptor(DD_ButtonEnabled,
+ QLatin1String("://dark/combobox/core_dropdown_button.png"),
+ QMargins(14, 14, 14, 14),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(DD_ButtonDisabled,
+ QLatin1String("://dark/combobox/core_dropdown_button_disabled.png"),
+ QMargins(14, 14, 14, 14),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(DD_ButtonPressed,
+ QLatin1String("://dark/combobox/core_dropdown_button_pressed.png"),
+ QMargins(14, 14, 14, 14),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(DD_ItemSelected,
+ QLatin1String("://dark/combobox/core_listitem_active.png"));
+ addPixmap(DD_ArrowEnabled,
+ QLatin1String("://dark/combobox/core_dropdown_button_arrowdown.png"),
+ QMargins(35, 39, 35, 39));
+ copyPixmap(DD_ArrowEnabled, DD_ArrowDisabled);
+ addPixmap(DD_ArrowPressed,
+ QLatin1String("://dark/combobox/core_dropdown_button_arrowdown_pressed.png"),
+ QMargins(35, 39, 35, 39));
+ addPixmap(DD_ArrowOpen,
+ QLatin1String("://dark/combobox/core_dropdown_button_arrowup.png"),
+ QMargins(35, 39, 35, 39));
+ addDescriptor(DD_PopupDown,
+ QLatin1String("://dark/combobox/core_dropdown_menu.png"),
+ QMargins(12, 12, 12, 12), QTileRules(Qt::StretchTile, Qt::StretchTile));
+ addDescriptor(DD_PopupUp,
+ QLatin1String("://dark/combobox/core_dropdown_menuup.png"),
+ QMargins(12, 12, 12, 12), QTileRules(Qt::StretchTile, Qt::StretchTile));
+ addPixmap(DD_ItemSeparator,
+ QLatin1String("://dark/combobox/core_dropdown_divider.png"),
+ QMargins(5, 0, 5, 0));
+
+ addDescriptor(ID_Selected,
+ QLatin1String("://dark/listitem/core_listitem_active.png"));
+ addPixmap(ID_Separator,
+ QLatin1String("://dark/listitem/core_listitem_divider.png"));
+
+ addDescriptor(SB_Horizontal,
+ QLatin1String("://dark/scrollbar/core_scrollbar.png"),
+ QMargins(7, 8, 7, 8),
+ QTileRules(Qt::RepeatTile, Qt::StretchTile));
+ addDescriptor(SB_Vertical,
+ QLatin1String("://dark/scrollbar/core_scrollbar_v.png"),
+ QMargins(8, 7, 8, 7),
+ QTileRules(Qt::StretchTile, Qt::RepeatTile));
+}
+
+QBB10DarkStyle::~QBB10DarkStyle()
+{
+}
+
+void QBB10DarkStyle::polish(QApplication *application)
+{
+ QPixmapStyle::polish(application);
+}
+
+void QBB10DarkStyle::polish(QWidget *widget)
+{
+ // Hide the text by default
+ if (QProgressBar *pb = qobject_cast<QProgressBar*>(widget))
+ pb->setTextVisible(false);
+
+ if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) {
+ QAbstractItemView *list = cb->view();
+ QPalette p = list->palette();
+ p.setBrush(QPalette::HighlightedText, p.brush(QPalette::Text));
+ list->setPalette(p);
+ }
+
+ if (qobject_cast<QLineEdit*>(widget) || qobject_cast<QTextEdit*>(widget)) {
+ QPalette p = widget->palette();
+ p.setBrush(QPalette::Text, QColor(38, 38, 38));
+ widget->setPalette(p);
+ }
+
+ if (qobject_cast<QAbstractItemView*>(widget)) {
+ QPalette p = widget->palette();
+ p.setBrush(QPalette::Disabled, QPalette::HighlightedText, p.brush(QPalette::Text));
+ widget->setPalette(p);
+ }
+
+ QPixmapStyle::polish(widget);
+}
+
+QPalette QBB10DarkStyle::standardPalette() const
+{
+ QPalette p;
+
+ QColor color = QColor(250, 250, 250);
+ p.setBrush(QPalette::ButtonText, color);
+ p.setBrush(QPalette::WindowText, color);
+ p.setBrush(QPalette::Text, color);
+
+ color.setAlpha(179);
+ p.setBrush(QPalette::Disabled, QPalette::ButtonText, color);
+ p.setBrush(QPalette::Disabled, QPalette::WindowText, color);
+ p.setBrush(QPalette::Disabled, QPalette::Text, color);
+
+ p.setColor(QPalette::Window, QColor(18, 18, 18));
+
+ p.setBrush(QPalette::Highlight, QColor(0, 168, 223));
+ p.setBrush(QPalette::HighlightedText, QColor(250, 250,250));
+
+ return p;
+}
+
+void QBB10DarkStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ switch (element) {
+ case CE_PushButtonLabel:
+ {
+ const bool on = option->state & State_On || option->state & State_Sunken;
+ const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option);
+ QStyleOptionButton newOpt = *button;
+ if (on)
+ newOpt.palette.setBrush(QPalette::ButtonText, QColor(38, 38, 38));
+ QPixmapStyle::drawControl(CE_PushButtonLabel, &newOpt, painter, widget);
+ break;
+ }
+ case CE_ProgressBarLabel:
+ // Don't draw the progress bar label
+ break;
+ default:
+ QPixmapStyle::drawControl(element, option, painter, widget);
+ }
+}
+
+void QBB10DarkStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ QPixmapStyle::drawPrimitive(element, option, painter, widget);
+
+ if (element == PE_PanelItemViewItem) {
+ // Draw the checkbox for current item
+ if (widget->property("_pixmap_combobox_list").toBool()
+ && option->state & QStyle::State_Selected) {
+ QPixmap pix(QLatin1String("://dark/combobox/core_dropdown_checkmark.png"));
+ QRect rect = option->rect;
+ const int margin = rect.height() / 2;
+ QPoint pos(rect.right() - margin - pix.width() / 2,
+ rect.top() + margin - pix.height() / 2);
+ painter->drawPixmap(pos, pix);
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/styles/bb10style/qbb10darkstyle.h b/src/plugins/styles/bb10style/qbb10darkstyle.h
new file mode 100644
index 0000000000..1be7b0540c
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10darkstyle.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBB10DARKSTYLE_H
+#define QBB10DARKSTYLE_H
+
+#include "qpixmapstyle.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBB10DarkStyle : public QPixmapStyle
+{
+ Q_OBJECT
+
+public:
+ QBB10DarkStyle();
+ ~QBB10DarkStyle();
+
+ void polish(QApplication *application);
+ void polish(QWidget *widget);
+
+ QPalette standardPalette() const;
+
+ void drawControl(ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBB10DARKSTYLE_H
diff --git a/src/plugins/styles/bb10style/qbb10darkstyle.qrc b/src/plugins/styles/bb10style/qbb10darkstyle.qrc
new file mode 100644
index 0000000000..31a5236207
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10darkstyle.qrc
@@ -0,0 +1,57 @@
+<RCC>
+ <qresource prefix="/">
+ <file>dark/button/core_button_disabled.png</file>
+ <file>dark/button/core_button_disabled_selected.png</file>
+ <file>dark/button/core_button_inactive.png</file>
+ <file>dark/button/core_button_enabled_selected.png</file>
+ <file>dark/button/core_button_pressed.png</file>
+ <file>dark/checkbox/core_checkbox_checked.png</file>
+ <file>dark/checkbox/core_checkbox_disabled.png</file>
+ <file>dark/checkbox/core_checkbox_disabled_checked.png</file>
+ <file>dark/checkbox/core_checkbox_enabled.png</file>
+ <file>dark/checkbox/core_checkbox_pressed.png</file>
+ <file>dark/checkbox/core_checkbox_pressed_checked.png</file>
+ <file>dark/combobox/core_dropdown_button.png</file>
+ <file>dark/combobox/core_dropdown_button_arrowdown.png</file>
+ <file>dark/combobox/core_dropdown_button_arrowdown_pressed.png</file>
+ <file>dark/combobox/core_dropdown_button_arrowup.png</file>
+ <file>dark/combobox/core_dropdown_button_disabled.png</file>
+ <file>dark/combobox/core_dropdown_button_pressed.png</file>
+ <file>dark/combobox/core_dropdown_checkmark.png</file>
+ <file>dark/combobox/core_dropdown_divider.png</file>
+ <file>dark/combobox/core_dropdown_menu.png</file>
+ <file>dark/combobox/core_dropdown_menuup.png</file>
+ <file>dark/combobox/core_listitem_active.png</file>
+ <file>dark/lineedit/core_textinput_bg.png</file>
+ <file>dark/lineedit/core_textinput_bg_disabled.png</file>
+ <file>dark/lineedit/core_textinput_bg_highlight.png</file>
+ <file>dark/listitem/core_listitem_active.png</file>
+ <file>dark/listitem/core_listitem_divider.png</file>
+ <file>dark/progressbar/core_progressindicator_bg.png</file>
+ <file>dark/progressbar/core_progressindicator_complete.png</file>
+ <file>dark/progressbar/core_progressindicator_fill.png</file>
+ <file>dark/progressbar/core_progressindicator_vbg.png</file>
+ <file>dark/progressbar/core_progressindicator_vcomplete.png</file>
+ <file>dark/progressbar/core_progressindicator_vfill.png</file>
+ <file>dark/radiobutton/core_radiobutton_checked.png</file>
+ <file>dark/radiobutton/core_radiobutton_disabled.png</file>
+ <file>dark/radiobutton/core_radiobutton_disabled_checked.png</file>
+ <file>dark/radiobutton/core_radiobutton_inactive.png</file>
+ <file>dark/radiobutton/core_radiobutton_pressed.png</file>
+ <file>dark/scrollbar/core_scrollbar.png</file>
+ <file>dark/scrollbar/core_scrollbar_v.png</file>
+ <file>dark/slider/core_slider_active.png</file>
+ <file>dark/slider/core_slider_cache.png</file>
+ <file>dark/slider/core_slider_disabled.png</file>
+ <file>dark/slider/core_slider_enabled.png</file>
+ <file>dark/slider/core_slider_handle.png</file>
+ <file>dark/slider/core_slider_handle_disabled.png</file>
+ <file>dark/slider/core_slider_handle_pressed.png</file>
+ <file>dark/slider/core_slider_inactive.png</file>
+ <file>dark/slider/core_slider_vactive.png</file>
+ <file>dark/slider/core_slider_vcache.png</file>
+ <file>dark/slider/core_slider_vdisabled.png</file>
+ <file>dark/slider/core_slider_venabled.png</file>
+ <file>dark/slider/core_slider_vinactive.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/styles/bb10style/qbb10styleplugin.cpp b/src/plugins/styles/bb10style/qbb10styleplugin.cpp
new file mode 100644
index 0000000000..eba5e868a2
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10styleplugin.cpp
@@ -0,0 +1,74 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbb10styleplugin.h"
+#include "qbb10darkstyle.h"
+#include "qbb10brightstyle.h"
+
+QT_BEGIN_NAMESPACE
+
+QBB10StylePlugin::QBB10StylePlugin()
+{
+}
+
+QBB10StylePlugin::~QBB10StylePlugin()
+{
+}
+
+QStyle *QBB10StylePlugin::create(const QString &key)
+{
+ const QString keyLower(key.toLower());
+ if (keyLower == QLatin1String("bb10bright"))
+ return new QBB10BrightStyle;
+ else if (keyLower == QLatin1String("bb10dark"))
+ return new QBB10DarkStyle;
+
+ return 0;
+}
+
+QStringList QBB10StylePlugin::keys() const
+{
+ return QStringList() << QLatin1String("bb10bright") << QLatin1String("bb10dark");
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qbb10styleplugin.cpp"
diff --git a/src/plugins/styles/bb10style/qbb10styleplugin.h b/src/plugins/styles/bb10style/qbb10styleplugin.h
new file mode 100644
index 0000000000..2bc08d441c
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10styleplugin.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBB10STYLEPLUGIN_H
+#define QBB10STYLEPLUGIN_H
+
+#include <QStylePlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QBB10StylePlugin : public QStylePlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "qbb10styleplugin.json")
+
+public:
+ QBB10StylePlugin();
+ ~QBB10StylePlugin();
+
+ QStyle *create(const QString &key);
+ QStringList keys() const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBB10STYLEPLUGIN_H
diff --git a/src/plugins/styles/bb10style/qbb10styleplugin.json b/src/plugins/styles/bb10style/qbb10styleplugin.json
new file mode 100644
index 0000000000..8f79b706c3
--- /dev/null
+++ b/src/plugins/styles/bb10style/qbb10styleplugin.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "bb10bright", "bb10dark" ]
+}
diff --git a/src/plugins/styles/bb10style/qpixmapstyle.cpp b/src/plugins/styles/bb10style/qpixmapstyle.cpp
new file mode 100644
index 0000000000..539b892e65
--- /dev/null
+++ b/src/plugins/styles/bb10style/qpixmapstyle.cpp
@@ -0,0 +1,994 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpixmapstyle.h"
+
+#include <QDebug>
+#include <QTextEdit>
+#include <QStringBuilder>
+#include <QPainter>
+#include <QPixmapCache>
+#include <QStyleOption>
+#include <QString>
+#include <QProgressBar>
+#include <QSlider>
+#include <QEvent>
+#include <QComboBox>
+#include <QAbstractItemView>
+#include <QListView>
+#include <QTreeView>
+#include <QStyledItemDelegate>
+#include <QAbstractScrollArea>
+#include <QScrollBar>
+
+#include <qscroller.h>
+
+QT_BEGIN_NAMESPACE
+
+QPixmapStyle::QPixmapStyle() :
+ QCommonStyle()
+{
+}
+
+QPixmapStyle::~QPixmapStyle()
+{
+}
+
+void QPixmapStyle::polish(QApplication *application)
+{
+ QCommonStyle::polish(application);
+#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+ QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
+#endif
+}
+
+void QPixmapStyle::polish(QPalette &palette)
+{
+ palette = proxy()->standardPalette();
+}
+
+void QPixmapStyle::polish(QWidget *widget)
+{
+ // Don't fill the interior of the QTextEdit
+ if (qobject_cast<QTextEdit*>(widget)) {
+ QPalette p = widget->palette();
+ p.setBrush(QPalette::Base, Qt::NoBrush);
+ widget->setPalette(p);
+ }
+
+ if (QProgressBar *pb = qobject_cast<QProgressBar*>(widget)) {
+ // Center the text in the progress bar
+ pb->setAlignment(Qt::AlignCenter);
+ // Change the font size if needed, as it's used to compute the minimum size
+ QFont font = pb->font();
+ font.setPixelSize(m_descriptors.value(PB_HBackground).size.height()/2);
+ pb->setFont(font);
+ }
+
+ if (qobject_cast<QSlider*>(widget))
+ widget->installEventFilter(this);
+
+ if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) {
+ widget->installEventFilter(this);
+ // NOTE: This will break if the private API of QComboBox changes drastically
+ // Make sure the popup is created so we can change the frame style
+ QAbstractItemView *list = cb->view();
+ list->setProperty("_pixmap_combobox_list", true);
+ list->setItemDelegate(new QStyledItemDelegate(list));
+ QPalette p = list->palette();
+ p.setBrush(QPalette::Active, QPalette::Base, QBrush(Qt::transparent) );
+ p.setBrush(QPalette::Active, QPalette::AlternateBase, QBrush(Qt::transparent) );
+ p.setBrush(QPalette::Inactive, QPalette::Base, QBrush(Qt::transparent) );
+ p.setBrush(QPalette::Inactive, QPalette::AlternateBase, QBrush(Qt::transparent) );
+ p.setBrush(QPalette::Disabled, QPalette::Base, QBrush(Qt::transparent) );
+ p.setBrush(QPalette::Disabled, QPalette::AlternateBase, QBrush(Qt::transparent) );
+ list->setPalette(p);
+
+ QFrame *frame = qobject_cast<QFrame*>(list->parent());
+ if (frame) {
+ const Descriptor &desc = m_descriptors.value(DD_PopupDown);
+ const Pixmap &pix = m_pixmaps.value(DD_ItemSeparator);
+ frame->setContentsMargins(pix.margins.left(), desc.margins.top(),
+ pix.margins.right(), desc.margins.bottom());
+ frame->setAttribute(Qt::WA_TranslucentBackground);
+#ifdef Q_DEAD_CODE_FROM_QT4_WIN
+ // FramelessWindowHint is needed on windows to make
+ // WA_TranslucentBackground work properly
+ frame->setWindowFlags(widget->windowFlags() | Qt::FramelessWindowHint);
+#endif
+ }
+ }
+
+ if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0)
+ widget->installEventFilter(this);
+
+ if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) {
+ scrollArea->viewport()->setAutoFillBackground(false);
+ if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(scrollArea)) {
+ view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+ view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ }
+ QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture);
+ }
+
+ if (qobject_cast<QScrollBar*>(widget))
+ widget->setAttribute(Qt::WA_OpaquePaintEvent, false);
+
+ QCommonStyle::polish(widget);
+}
+
+void QPixmapStyle::unpolish(QWidget *widget)
+{
+ if (qobject_cast<QSlider*>(widget) ||
+ qobject_cast<QComboBox*>(widget)) {
+ widget->removeEventFilter(this);
+ }
+
+ if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0)
+ widget->removeEventFilter(this);
+
+ if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget))
+ QScroller::ungrabGesture(scrollArea->viewport());
+
+ QCommonStyle::unpolish(widget);
+}
+
+void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ switch (element) {
+ case PE_FrameFocusRect: //disable focus rectangle
+ break;
+ case PE_PanelButtonBevel:
+ case PE_PanelButtonCommand:
+ drawPushButton(option, painter, widget);
+ break;
+ case PE_PanelLineEdit:
+ case PE_FrameLineEdit:
+ drawLineEdit(option, painter, widget);
+ break;
+ case PE_Frame:
+ case PE_FrameDefaultButton:
+ if (qobject_cast<const QTextEdit*>(widget))
+ drawTextEdit(option, painter, widget);
+ break;
+ case PE_IndicatorCheckBox:
+ drawCheckBox(option, painter, widget);
+ break;
+ case PE_IndicatorRadioButton:
+ drawRadioButton(option, painter, widget);
+ break;
+ case PE_PanelItemViewItem:
+ if (qobject_cast<const QListView*>(widget))
+ drawPanelItemViewItem(option, painter, widget);
+ else
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
+ break;
+ default:
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
+ }
+}
+
+void QPixmapStyle::drawControl(ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ switch (element) {
+ case CE_ProgressBarGroove:
+ drawProgressBarBackground(option, painter, widget);
+ break;
+ case CE_ProgressBarLabel:
+ drawProgressBarLabel(option, painter, widget);
+ break;
+ case CE_ProgressBarContents:
+ drawProgressBarFill(option, painter, widget);
+ break;
+ case CE_ShapedFrame:
+ // NOTE: This will break if the private API of QComboBox changes drastically
+ if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) {
+ const Descriptor &desc = m_descriptors.value(DD_PopupDown);
+ const Pixmap &pix = m_pixmaps.value(DD_ItemSeparator);
+ QRect rect = option->rect;
+ rect.adjust(-pix.margins.left(), -desc.margins.top(),
+ pix.margins.right(), desc.margins.bottom());
+ bool up = widget->property("_pixmapstyle_combobox_up").toBool();
+ drawCachedPixmap(up ? DD_PopupUp : DD_PopupDown, rect, painter);
+ }
+ else {
+ QCommonStyle::drawControl(element, option, painter, widget);
+ }
+ break;
+ default:
+ QCommonStyle::drawControl(element, option, painter, widget);
+ }
+}
+
+void QPixmapStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ switch (cc) {
+ case CC_Slider:
+ drawSlider(option, painter, widget);
+ break;
+ case CC_ComboBox:
+ drawComboBox(option, painter, widget);
+ break;
+ case CC_ScrollBar:
+ drawScrollBar(option, painter, widget);
+ break;
+ default:
+ QCommonStyle::drawComplexControl(cc, option, painter, widget);
+ }
+}
+
+QSize QPixmapStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const
+{
+ switch (type) {
+ case CT_PushButton:
+ return pushButtonSizeFromContents(option, contentsSize, widget);
+ case CT_LineEdit:
+ return lineEditSizeFromContents(option, contentsSize, widget);
+ case CT_ProgressBar:
+ return progressBarSizeFromContents(option, contentsSize, widget);
+ case CT_Slider:
+ return sliderSizeFromContents(option, contentsSize, widget);
+ case CT_ComboBox:
+ return comboBoxSizeFromContents(option, contentsSize, widget);
+ case CT_ItemViewItem:
+ return itemViewSizeFromContents(option, contentsSize, widget);
+ default: ;
+ }
+
+ return QCommonStyle::sizeFromContents(type, option, contentsSize, widget);
+}
+
+QRect QPixmapStyle::subElementRect(SubElement element, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ switch (element) {
+ case SE_LineEditContents:
+ {
+ QRect rect = QCommonStyle::subElementRect(element, option, widget);
+ const Descriptor &desc = m_descriptors.value(LE_Enabled);
+ rect.adjust(desc.margins.left(), desc.margins.top(),
+ -desc.margins.right(), -desc.margins.bottom());
+ rect = visualRect(option->direction, option->rect, rect);
+ return rect;
+ }
+ default: ;
+ }
+
+ return QCommonStyle::subElementRect(element, option, widget);
+}
+
+QRect QPixmapStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option,
+ SubControl sc, const QWidget *widget) const
+{
+ switch (cc) {
+ case CC_ComboBox:
+ return comboBoxSubControlRect(option, sc, widget);
+ case CC_ScrollBar:
+ return scrollBarSubControlRect(option, sc, widget);
+ default: ;
+ }
+
+ return QCommonStyle::subControlRect(cc, option, sc, widget);
+}
+
+int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ switch (metric) {
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ return 0;
+ case PM_DefaultFrameWidth:
+ if (qobject_cast<const QTextEdit*>(widget)) {
+ const Descriptor &desc = m_descriptors.value(LE_Enabled);
+ return qMax(qMax(desc.margins.left(), desc.margins.right()),
+ qMax(desc.margins.top(), desc.margins.bottom()));
+ }
+ return 0;
+ case PM_IndicatorWidth:
+ return m_pixmaps.value(CB_Enabled).pixmap.width();
+ case PM_IndicatorHeight:
+ return m_pixmaps.value(CB_Enabled).pixmap.height();
+ case PM_CheckBoxLabelSpacing:
+ {
+ const Pixmap &pix = m_pixmaps.value(CB_Enabled);
+ return qMax(qMax(pix.margins.left(), pix.margins.right()),
+ qMax(pix.margins.top(), pix.margins.bottom()));
+ }
+ case PM_ExclusiveIndicatorWidth:
+ return m_pixmaps.value(RB_Enabled).pixmap.width();
+ case PM_ExclusiveIndicatorHeight:
+ return m_pixmaps.value(RB_Enabled).pixmap.height();
+ case PM_RadioButtonLabelSpacing:
+ {
+ const Pixmap &pix = m_pixmaps.value(RB_Enabled);
+ return qMax(qMax(pix.margins.left(), pix.margins.right()),
+ qMax(pix.margins.top(), pix.margins.bottom()));
+ }
+ case PM_SliderThickness:
+ if (const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider*>(option)) {
+ const Descriptor desc = m_descriptors.value(slider->orientation == Qt::Horizontal
+ ? SG_HEnabled : SG_VEnabled);
+ return slider->orientation == Qt::Horizontal
+ ? desc.size.height() : desc.size.width();
+ }
+ break;
+ case PM_SliderControlThickness:
+ if (const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider*>(option)) {
+ const Pixmap pix = m_pixmaps.value(slider->orientation == Qt::Horizontal
+ ? SH_HEnabled : SH_VEnabled);
+ return slider->orientation == Qt::Horizontal
+ ? pix.pixmap.height() : pix.pixmap.width();
+ }
+ break;
+ case PM_SliderLength:
+ if (const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider*>(option)) {
+ const Pixmap pix = m_pixmaps.value(slider->orientation == Qt::Horizontal
+ ? SH_HEnabled : SH_VEnabled);
+ return slider->orientation == Qt::Horizontal
+ ? pix.pixmap.width() : pix.pixmap.height();
+ }
+ break;
+ case PM_ScrollBarExtent:
+ if (const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider*>(option)) {
+ const Descriptor desc = m_descriptors.value(slider->orientation == Qt::Horizontal
+ ? SB_Horizontal : SB_Vertical);
+ return slider->orientation == Qt::Horizontal
+ ? desc.size.height() : desc.size.width();
+ }
+ break;
+ case PM_ScrollBarSliderMin:
+ return 0;
+ default: ;
+ }
+
+ return QCommonStyle::pixelMetric(metric, option, widget);
+}
+
+int QPixmapStyle::styleHint(StyleHint hint, const QStyleOption *option,
+ const QWidget *widget, QStyleHintReturn *returnData) const
+{
+ switch (hint) {
+ case SH_EtchDisabledText:
+ return false;
+ case SH_ComboBox_Popup:
+ return false;
+ default: ;
+ }
+
+ return QCommonStyle::styleHint(hint, option, widget, returnData);
+}
+
+QStyle::SubControl QPixmapStyle::hitTestComplexControl(QStyle::ComplexControl control,
+ const QStyleOptionComplex *option,
+ const QPoint &pos,
+ const QWidget *widget) const
+{
+ const SubControl sc = QCommonStyle::hitTestComplexControl(control, option, pos, widget);
+ if (control == CC_ScrollBar) {
+ if (sc == SC_ScrollBarAddLine)
+ return SC_ScrollBarAddPage;
+ else if (sc == SC_ScrollBarSubLine)
+ return SC_ScrollBarSubPage;
+ }
+
+ return sc;
+}
+
+bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event)
+{
+ if (QSlider *slider = qobject_cast<QSlider*>(watched)) {
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ slider->update();
+ break;
+ default: ;
+ }
+ }
+
+ if (QComboBox *comboBox = qobject_cast<QComboBox*>(watched)) {
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ event->ignore();
+ comboBox->setProperty("_pixmapstyle_combobox_pressed", true);
+ comboBox->repaint();
+ return true;
+ case QEvent::MouseButtonRelease:
+ comboBox->setProperty("_pixmapstyle_combobox_pressed", false);
+ comboBox->repaint();
+ if ( comboBox->view() ) {
+ if ( comboBox->view()->isVisible() || (!comboBox->isEnabled()))
+ comboBox->hidePopup();
+ else
+ comboBox->showPopup();
+ }
+ break;
+ default: ;
+ }
+ }
+
+ if (qstrcmp(watched->metaObject()->className(),"QComboBoxPrivateContainer") == 0) {
+ if (event->type() == QEvent::Show) {
+ QWidget *widget = qobject_cast<QWidget*>(watched);
+ int yPopup = widget->geometry().top();
+ int yCombo = widget->parentWidget()->mapToGlobal(QPoint(0, 0)).y();
+ QRect geom = widget->geometry();
+ const Descriptor &desc = m_descriptors.value(DD_ButtonEnabled);
+ const bool up = yPopup < yCombo;
+ geom.moveTop(geom.top() + (up ? desc.margins.top() : -desc.margins.bottom()));
+ widget->setGeometry(geom);
+ widget->setProperty("_pixmapstyle_combobox_up", up);
+ widget->parentWidget()->setProperty("_pixmapstyle_combobox_up", up);
+ }
+ }
+
+ return QCommonStyle::eventFilter(watched, event);
+}
+
+void QPixmapStyle::addDescriptor(QPixmapStyle::ControlDescriptor control, const QString &fileName,
+ QMargins margins, QTileRules tileRules)
+{
+ Descriptor desc;
+
+ QImage image(fileName);
+ if (image.isNull())
+ return;
+
+ desc.fileName = fileName;
+ desc.margins = margins;
+ desc.tileRules = tileRules;
+ desc.size = image.size();
+
+ m_descriptors[control] = desc;
+}
+
+void QPixmapStyle::copyDescriptor(QPixmapStyle::ControlDescriptor source,
+ QPixmapStyle::ControlDescriptor dest)
+{
+ m_descriptors[dest] = m_descriptors.value(source);
+}
+
+void QPixmapStyle::drawCachedPixmap(QPixmapStyle::ControlDescriptor control, const QRect &rect,
+ QPainter *p) const
+{
+ if (!m_descriptors.contains(control))
+ return;
+ const Descriptor &desc = m_descriptors.value(control);
+ const QPixmap pix = getCachedPixmap(control, desc, rect.size());
+ Q_ASSERT(!pix.isNull());
+ p->drawPixmap(rect, pix);
+}
+
+void QPixmapStyle::addPixmap(ControlPixmap control, const QString &fileName,
+ QMargins margins)
+{
+ Pixmap pix;
+
+ QPixmap image(fileName);
+ if (image.isNull())
+ return;
+
+ pix.pixmap = image;
+ pix.margins = margins;
+
+ m_pixmaps[control] = pix;
+}
+
+void QPixmapStyle::copyPixmap(QPixmapStyle::ControlPixmap source, QPixmapStyle::ControlPixmap dest)
+{
+ m_pixmaps[dest] = m_pixmaps.value(source);
+}
+
+void QPixmapStyle::drawPushButton(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ const bool checked = option->state & State_On;
+ const bool pressed = option->state & State_Sunken;
+ const bool enabled = option->state & State_Enabled;
+
+ ControlDescriptor control = PB_Enabled;
+ if (enabled)
+ control = pressed ? PB_Pressed : (checked ? PB_Checked : PB_Enabled);
+ else
+ control = checked ? PB_PressedDisabled : PB_Disabled;
+ drawCachedPixmap(control, option->rect, painter);
+}
+
+void QPixmapStyle::drawLineEdit(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ // Don't draw for the line edit inside a combobox
+ if (widget && qobject_cast<const QComboBox*>(widget->parentWidget()))
+ return;
+
+ const bool enabled = option->state & State_Enabled;
+ const bool focused = option->state & State_HasFocus;
+ ControlDescriptor control = enabled ? (focused ? LE_Focused : LE_Enabled) : LE_Disabled;
+ drawCachedPixmap(control, option->rect, painter);
+}
+
+void QPixmapStyle::drawTextEdit(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ const bool enabled = option->state & State_Enabled;
+ const bool focused = option->state & State_HasFocus;
+ ControlDescriptor control = enabled ? (focused ? TE_Focused : TE_Enabled) : TE_Disabled;
+ drawCachedPixmap(control, option->rect, painter);
+}
+
+void QPixmapStyle::drawCheckBox(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option);
+
+ const bool down = button->state & State_Sunken;
+ const bool enabled = button->state & State_Enabled;
+ const bool on = button->state & State_On;
+
+ ControlPixmap control;
+ if (enabled)
+ control = on ? (down ? CB_PressedChecked : CB_Checked) : (down ? CB_Pressed : CB_Enabled);
+ else
+ control = on ? CB_DisabledChecked : CB_Disabled;
+ painter->drawPixmap(button->rect, m_pixmaps.value(control).pixmap);
+}
+
+void QPixmapStyle::drawRadioButton(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option);
+
+ const bool down = button->state & State_Sunken;
+ const bool enabled = button->state & State_Enabled;
+ const bool on = button->state & State_On;
+
+ ControlPixmap control;
+ if (enabled)
+ control = on ? RB_Checked : (down ? RB_Pressed : RB_Enabled);
+ else
+ control = on ? RB_DisabledChecked : RB_Disabled;
+ painter->drawPixmap(button->rect, m_pixmaps.value(control).pixmap);
+}
+
+void QPixmapStyle::drawPanelItemViewItem(const QStyleOption *option, QPainter *painter,
+ const QWidget *widget) const
+{
+ ControlPixmap cp = ID_Separator;
+ ControlDescriptor cd = ID_Selected;
+
+ if (widget && widget->property("_pixmap_combobox_list").toBool()) {
+ cp = DD_ItemSeparator;
+ cd = DD_ItemSelected;
+ }
+
+ QPixmap pix = m_pixmaps.value(cp).pixmap;
+ QRect rect = option->rect;
+ rect.setBottom(rect.top() + pix.height()-1);
+ painter->drawPixmap(rect, pix);
+ if (option->state & QStyle::State_Selected) {
+ rect = option->rect;
+ rect.setTop(rect.top() + pix.height());
+ drawCachedPixmap(cd, rect, painter);
+ }
+}
+
+void QPixmapStyle::drawProgressBarBackground(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ bool vertical = false;
+ if (const QStyleOptionProgressBarV2 *pb2 =
+ qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
+ vertical = (pb2->orientation == Qt::Vertical);
+ }
+ drawCachedPixmap(vertical ? PB_VBackground : PB_HBackground, option->rect, painter);
+}
+
+void QPixmapStyle::drawProgressBarLabel(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ if (const QStyleOptionProgressBar *pb =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ bool vertical = false;
+ if (const QStyleOptionProgressBarV2 *pb2 =
+ qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
+ vertical = (pb2->orientation == Qt::Vertical);
+ }
+ if (!vertical) {
+ QPalette::ColorRole textRole = QPalette::ButtonText;
+ proxy()->drawItemText(painter, pb->rect,
+ Qt::AlignCenter | Qt::TextSingleLine, pb->palette,
+ pb->state & State_Enabled, pb->text, textRole);
+ }
+ }
+}
+
+void QPixmapStyle::drawProgressBarFill(const QStyleOption *option,
+ QPainter *painter, const QWidget *) const
+{
+ const QStyleOptionProgressBar *pbar =
+ qstyleoption_cast<const QStyleOptionProgressBar*>(option);
+ bool vertical = false;
+ bool flip = pbar->direction == Qt::RightToLeft;
+ if (const QStyleOptionProgressBarV2 *pb2 =
+ qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
+ vertical = (pb2->orientation == Qt::Vertical);
+ flip = flip ^ pb2->invertedAppearance;
+ }
+
+ if (pbar->progress == pbar->maximum) {
+ drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter);
+
+ } else {
+ if (pbar->progress == 0)
+ return;
+ const int maximum = pbar->maximum;
+ const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum;
+ const int progress = pbar->progress*ratio;
+
+ QRect optRect = option->rect;
+ if (vertical) {
+ if (flip)
+ optRect.setBottom(optRect.top()+progress-1);
+ else
+ optRect.setTop(optRect.bottom()-progress+1);
+ } else {
+ if (flip)
+ optRect.setLeft(optRect.right()-progress+1);
+ else
+ optRect.setRight(optRect.left()+progress-1);
+ }
+
+ drawCachedPixmap(vertical ? PB_VContent : PB_HContent, optRect, painter);
+ }
+}
+
+void QPixmapStyle::drawSlider(const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option);
+ if (!slider)
+ return;
+
+ const bool enabled = option->state & State_Enabled;
+ const bool pressed = option->state & State_Sunken;
+ const Qt::Orientation orient = slider->orientation;
+
+ const QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
+ if (option->subControls & SC_SliderGroove) {
+ QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
+ if (groove.isValid()) {
+ // Draw the background
+ ControlDescriptor control;
+ if (orient == Qt::Horizontal)
+ control = enabled ? SG_HEnabled : SG_HDisabled;
+ else
+ control = enabled ? SG_VEnabled : SG_VDisabled;
+ drawCachedPixmap(control, groove, painter);
+
+ // Draw the active part
+ if (orient == Qt::Horizontal) {
+ control = enabled ? (pressed ? SG_HActivePressed : SG_HActiveEnabled )
+ : SG_HActiveDisabled;
+ } else {
+ control = enabled ? (pressed ? SG_VActivePressed : SG_VActiveEnabled )
+ : SG_VActiveDisabled;
+ }
+ const Descriptor &desc = m_descriptors.value(control);
+ const QPixmap pix = getCachedPixmap(control, desc, groove.size());
+ if (!pix.isNull()) {
+ groove.setRight(orient == Qt::Horizontal
+ ? handle.center().x() : handle.center().y());
+ painter->drawPixmap(groove, pix, groove);
+ }
+ }
+ }
+ if (option->subControls & SC_SliderHandle) {
+ if (handle.isValid()) {
+ ControlPixmap pix;
+ if (orient == Qt::Horizontal)
+ pix = enabled ? (pressed ? SH_HPressed : SH_HEnabled) : SH_HDisabled;
+ else
+ pix = enabled ? (pressed ? SH_VPressed : SH_VEnabled) : SH_VDisabled;
+ painter->drawPixmap(handle, m_pixmaps.value(pix).pixmap);
+ }
+ }
+}
+
+void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ const bool enabled = option->state & State_Enabled;
+ const bool pressed = widget->property("_pixmapstyle_combobox_pressed").toBool();
+ const bool opened = option->state & State_On;
+
+ ControlDescriptor control =
+ enabled ? (pressed ? DD_ButtonPressed : DD_ButtonEnabled) : DD_ButtonDisabled;
+ drawCachedPixmap(control, option->rect, painter);
+
+ ControlPixmap cp = enabled ? (opened ? DD_ArrowOpen
+ : (pressed ? DD_ArrowPressed : DD_ArrowEnabled))
+ : DD_ArrowDisabled;
+ Pixmap pix = m_pixmaps.value(cp);
+ QRect rect = comboBoxSubControlRect(option, SC_ComboBoxArrow, widget);
+ painter->drawPixmap(rect, pix.pixmap);
+}
+
+void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ if (const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider*>(option)) {
+ // Do not draw the scrollbar
+ if (slider->minimum == slider->maximum)
+ return;
+
+ QRect rect = scrollBarSubControlRect(option, SC_ScrollBarSlider, widget);
+ ControlDescriptor control = slider->orientation == Qt::Horizontal
+ ? SB_Horizontal : SB_Vertical;
+ drawCachedPixmap(control, rect, painter);
+ }
+}
+
+QSize QPixmapStyle::pushButtonSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ const Descriptor &desc = m_descriptors.value(PB_Enabled);
+ const int bm = proxy()->pixelMetric(PM_ButtonMargin, option, widget);
+
+ int w = contentsSize.width();
+ int h = contentsSize.height();
+ w += desc.margins.left() + desc.margins.right() + bm;
+ h += desc.margins.top() + desc.margins.bottom() + bm;
+
+ return computeSize(desc, w, h);
+}
+
+QSize QPixmapStyle::lineEditSizeFromContents(const QStyleOption *,
+ const QSize &contentsSize, const QWidget *) const
+{
+ const Descriptor &desc = m_descriptors.value(LE_Enabled);
+ const int border = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth);
+
+ int w = contentsSize.width() + border + desc.margins.left() + desc.margins.right();
+ int h = contentsSize.height() + border + desc.margins.top() + desc.margins.bottom();
+
+ return computeSize(desc, w, h);
+}
+
+QSize QPixmapStyle::progressBarSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ bool vertical = false;
+ if (const QStyleOptionProgressBarV2 *pb2 =
+ qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
+ vertical = (pb2->orientation == Qt::Vertical);
+ }
+ QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget);
+ if (vertical) {
+ const Descriptor desc = m_descriptors.value(PB_VBackground);
+ return QSize(desc.size.height(), result.height());
+ } else {
+ const Descriptor desc = m_descriptors.value(PB_HBackground);
+ return QSize(result.width(), desc.size.height());
+ }
+}
+
+QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option);
+ if (!slider)
+ return QSize();
+
+ QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget);
+
+ const Descriptor desc = m_descriptors.value(slider->orientation == Qt::Horizontal
+ ? SG_HEnabled : SG_VEnabled);
+
+ if (slider->orientation == Qt::Horizontal)
+ return QSize(result.width(), desc.size.height());
+ else
+ return QSize(desc.size.width(), result.height());
+}
+
+QSize QPixmapStyle::comboBoxSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ const Descriptor &desc = m_descriptors.value(DD_ButtonEnabled);
+
+ QSize result = QCommonStyle::sizeFromContents(CT_ComboBox, option, contentsSize, widget);
+ return computeSize(desc, result.width(), result.height());
+}
+
+QSize QPixmapStyle::itemViewSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ QSize size = QCommonStyle::sizeFromContents(CT_ItemViewItem, option, contentsSize, widget);
+
+ ControlPixmap cp = ID_Separator;
+ ControlDescriptor cd = ID_Selected;
+ if (widget && widget->property("_pixmap_combobox_list").toBool()) {
+ cp = DD_ItemSeparator;
+ cd = DD_ItemSelected;
+ }
+
+ const Descriptor &desc = m_descriptors.value(cd);
+ const Pixmap &pix = m_pixmaps.value(cp);
+ size.setHeight(qMax(size.height(),
+ desc.size.height() + pix.pixmap.height()));
+ return size;
+}
+
+QRect QPixmapStyle::comboBoxSubControlRect(const QStyleOptionComplex *option,
+ QStyle::SubControl sc, const QWidget *) const
+{
+ QRect r = option->rect; // Default size
+ const Pixmap &pix = m_pixmaps.value(DD_ArrowEnabled);
+ const Descriptor &desc = m_descriptors.value(DD_ButtonEnabled);
+
+ switch (sc) {
+ case SC_ComboBoxArrow:
+ r.setRect(r.right() - pix.margins.right() - pix.pixmap.width(),
+ r.top() + pix.margins.top(),
+ pix.pixmap.width(), pix.pixmap.height());
+ break;
+ case SC_ComboBoxEditField:
+ r.adjust(desc.margins.left(), desc.margins.right(),
+ -desc.margins.right(), -desc.margins.bottom());
+ r.setRight(r.right() - pix.margins.right() - pix.margins.left() - pix.pixmap.width());
+ break;
+ default:
+ break;
+ }
+
+ r = visualRect(option->direction, option->rect, r);
+ return r;
+}
+
+QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option,
+ QStyle::SubControl sc, const QWidget *) const
+{
+ if (const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider*>(option)) {
+ int length = (slider->orientation == Qt::Horizontal)
+ ? slider->rect.width() : slider->rect.height();
+ int page = length * slider->pageStep
+ / (slider->maximum - slider->minimum + slider->pageStep);
+ int pos = length * slider->sliderValue
+ / (slider->maximum - slider->minimum + slider->pageStep);
+ pos = qMin(pos+page, length) - page;
+
+ QRect rect = slider->rect;
+
+ if (slider->orientation == Qt::Horizontal) {
+ switch (sc) {
+ case SC_ScrollBarAddPage:
+ rect.setLeft(pos+page);
+ return rect;
+ case SC_ScrollBarSubPage:
+ rect.setRight(pos);
+ return rect;
+ case SC_ScrollBarGroove:
+ return rect;
+ case SC_ScrollBarSlider:
+ rect.setLeft(pos);
+ rect.setRight(pos+page);
+ return rect;
+ default: ;
+ }
+ } else {
+ switch (sc) {
+ case SC_ScrollBarAddPage:
+ rect.setTop(pos+page);
+ return rect;
+ case SC_ScrollBarSubPage:
+ rect.setBottom(pos);
+ return rect;
+ case SC_ScrollBarGroove:
+ return rect;
+ case SC_ScrollBarSlider:
+ rect.setTop(pos);
+ rect.setBottom(pos+page);
+ return rect;
+ default: ;
+ }
+ }
+ }
+ return QRect();
+}
+
+static QPixmap scale(int w, int h, const QPixmap &pixmap, const QPixmapStyle::Descriptor &desc)
+{
+ QPixmap result(w, h);
+ {
+ const QColor transparent(0, 0, 0, 0);
+ result.fill( transparent );
+ QPainter p( &result );
+ const QMargins margins = desc.margins;
+ qDrawBorderPixmap(&p, result.rect(), margins, pixmap,
+ pixmap.rect(), margins, desc.tileRules);
+ }
+ return result;
+}
+
+QPixmap QPixmapStyle::getCachedPixmap(ControlDescriptor control, const Descriptor &desc,
+ const QSize &size) const
+{
+ const QString sizeString = QString::number(size.width()) % QLatin1Char('*')
+ % QString::number(size.height());
+ const QString key = QLatin1String(metaObject()->className()) % QString::number(control)
+ % QLatin1Char('@') % sizeString;
+
+ QPixmap result;
+
+ if (!QPixmapCache::find( key, &result)) {
+ QPixmap source(desc.fileName);
+ result = scale(size.width(), size.height(), source, desc);
+ QPixmapCache::insert(key, result);
+ }
+ return result;
+}
+
+QSize QPixmapStyle::computeSize(const QPixmapStyle::Descriptor &desc, int width, int height) const
+{
+ if (desc.tileRules.horizontal != Qt::RepeatTile)
+ width = qMax(width, desc.size.width());
+ if (desc.tileRules.vertical != Qt::RepeatTile)
+ height = qMax(height, desc.size.height());
+ return QSize(width, height);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/styles/bb10style/qpixmapstyle.h b/src/plugins/styles/bb10style/qpixmapstyle.h
new file mode 100644
index 0000000000..d4a223aab8
--- /dev/null
+++ b/src/plugins/styles/bb10style/qpixmapstyle.h
@@ -0,0 +1,236 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPIXMAPSTYLE_H
+#define QPIXMAPSTYLE_H
+
+#include <QCommonStyle>
+#include <QString>
+#include <QPixmap>
+#include <QMargins>
+#include <QTileRules>
+#include <QHash>
+#include <QPainter>
+
+QT_BEGIN_NAMESPACE
+
+class QPixmapStyle : public QCommonStyle
+{
+ Q_OBJECT
+
+public:
+ struct Descriptor {
+ QString fileName;
+ QSize size;
+ QMargins margins;
+ QTileRules tileRules;
+ };
+
+ enum ControlDescriptor {
+ BG_Background=0,
+ LE_Enabled, // QLineEdit
+ LE_Disabled,
+ LE_Focused,
+ PB_Enabled, // QPushButton
+ PB_Pressed,
+ PB_PressedDisabled,
+ PB_Checked,
+ PB_Disabled,
+ TE_Enabled, // QTextEdit
+ TE_Disabled,
+ TE_Focused,
+ PB_HBackground, // Horizontal QProgressBar
+ PB_HContent,
+ PB_HComplete,
+ PB_VBackground, // Vertical QProgressBar
+ PB_VContent,
+ PB_VComplete,
+ SG_HEnabled, // Horizontal QSlider groove
+ SG_HDisabled,
+ SG_HActiveEnabled,
+ SG_HActivePressed,
+ SG_HActiveDisabled,
+ SG_VEnabled, // Vertical QSlider groove
+ SG_VDisabled,
+ SG_VActiveEnabled,
+ SG_VActivePressed,
+ SG_VActiveDisabled,
+ DD_ButtonEnabled, // QComboBox (DropDown)
+ DD_ButtonDisabled,
+ DD_ButtonPressed,
+ DD_PopupDown,
+ DD_PopupUp,
+ DD_ItemSelected,
+ ID_Selected, // QStyledItemDelegate
+ SB_Horizontal, // QScrollBar
+ SB_Vertical
+ };
+
+ struct Pixmap {
+ QPixmap pixmap;
+ QMargins margins;
+ };
+ enum ControlPixmap {
+ CB_Enabled, // QCheckBox
+ CB_Checked,
+ CB_Pressed,
+ CB_PressedChecked,
+ CB_Disabled,
+ CB_DisabledChecked,
+ RB_Enabled, // QRadioButton
+ RB_Checked,
+ RB_Pressed,
+ RB_Disabled,
+ RB_DisabledChecked,
+ SH_HEnabled, // Horizontal QSlider handle
+ SH_HDisabled,
+ SH_HPressed,
+ SH_VEnabled, // Vertical QSlider handle
+ SH_VDisabled,
+ SH_VPressed,
+ DD_ArrowEnabled, // QComboBox (DropDown) arrow
+ DD_ArrowDisabled,
+ DD_ArrowPressed,
+ DD_ArrowOpen,
+ DD_ItemSeparator,
+ ID_Separator // QStyledItemDelegate separator
+ };
+
+public:
+ QPixmapStyle();
+ ~QPixmapStyle();
+
+ void polish(QApplication *application);
+ void polish(QPalette &palette);
+ void polish(QWidget *widget);
+ void unpolish(QWidget *widget);
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget=0) const;
+
+ QSize sizeFromContents(ContentsType type, const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget = 0) const;
+ QRect subElementRect(SubElement element, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option,
+ SubControl sc, const QWidget *widget = 0) const;
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+ int styleHint(StyleHint hint, const QStyleOption *option,
+ const QWidget *widget, QStyleHintReturn *returnData) const;
+ SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
+ const QPoint &pos, const QWidget *widget) const;
+
+ bool eventFilter(QObject *watched, QEvent *event);
+
+protected:
+ void addDescriptor(ControlDescriptor control, const QString &fileName,
+ QMargins margins = QMargins(),
+ QTileRules tileRules = QTileRules(Qt::RepeatTile, Qt::RepeatTile));
+ void copyDescriptor(ControlDescriptor source, ControlDescriptor dest);
+ void drawCachedPixmap(ControlDescriptor control, const QRect &rect, QPainter *p) const;
+
+ void addPixmap(ControlPixmap control, const QString &fileName,
+ QMargins margins = QMargins());
+ void copyPixmap(ControlPixmap source, ControlPixmap dest);
+
+ void drawPushButton(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawLineEdit(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawTextEdit(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawCheckBox(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawRadioButton(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawPanelItemViewItem(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawProgressBarBackground(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawProgressBarLabel(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawProgressBarFill(const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawSlider(const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawComboBox(const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawScrollBar(const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const;
+
+ QSize pushButtonSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const;
+ QSize lineEditSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const;
+ QSize progressBarSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const;
+ QSize sliderSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const;
+ QSize comboBoxSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const;
+ QSize itemViewSizeFromContents(const QStyleOption *option,
+ const QSize &contentsSize, const QWidget *widget) const;
+
+ QRect comboBoxSubControlRect(const QStyleOptionComplex *option,
+ SubControl sc, const QWidget *widget) const;
+ QRect scrollBarSubControlRect(const QStyleOptionComplex *option,
+ SubControl sc, const QWidget *widget) const;
+
+private:
+ QPixmap getCachedPixmap(ControlDescriptor control,
+ const Descriptor &desc, const QSize &size) const;
+
+ QSize computeSize(const Descriptor &desc, int width, int height) const;
+
+private:
+ QHash<ControlDescriptor, Descriptor> m_descriptors;
+ QHash<ControlPixmap, Pixmap> m_pixmaps;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPIXMAPSTYLE_H
diff --git a/src/plugins/styles/styles.pro b/src/plugins/styles/styles.pro
new file mode 100644
index 0000000000..88b3f90e0c
--- /dev/null
+++ b/src/plugins/styles/styles.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+blackberry:SUBDIRS += bb10style