summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.h6
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.cpp2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.h2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.h4
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.h4
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.h4
-rw-r--r--src/plugins/accessible/widgets/widgets.pro2
-rw-r--r--src/plugins/decorations/decorations.pro4
-rw-r--r--src/plugins/decorations/default/default.pro10
-rw-r--r--src/plugins/decorations/default/main.cpp76
-rw-r--r--src/plugins/decorations/styled/main.cpp77
-rw-r--r--src/plugins/decorations/styled/styled.pro13
-rw-r--r--src/plugins/decorations/windows/main.cpp76
-rw-r--r--src/plugins/decorations/windows/windows.pro10
-rw-r--r--src/plugins/gfxdrivers/ahi/ahi.pro14
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp598
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahi_qws.h84
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp74
-rw-r--r--src/plugins/gfxdrivers/directfb/directfb.pro15
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp436
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp294
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.h75
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp221
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h108
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp1430
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h123
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp588
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h105
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp1819
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h303
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp78
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp506
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h129
-rw-r--r--src/plugins/gfxdrivers/eglnullws/README48
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullws.pro18
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp181
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h69
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp66
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h47
-rw-r--r--src/plugins/gfxdrivers/gfxdrivers.pro10
-rw-r--r--src/plugins/gfxdrivers/linuxfb/linuxfb.pro14
-rw-r--r--src/plugins/gfxdrivers/linuxfb/main.cpp79
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro26
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c830
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h169
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h132
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c402
-rw-r--r--src/plugins/gfxdrivers/powervr/README66
-rw-r--r--src/plugins/gfxdrivers/powervr/powervr.pri2
-rw-r--r--src/plugins/gfxdrivers/powervr/powervr.pro3
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp351
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h99
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro27
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp74
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp273
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h85
-rw-r--r--src/plugins/gfxdrivers/qvfb/main.cpp82
-rw-r--r--src/plugins/gfxdrivers/qvfb/qvfb.pro19
-rw-r--r--src/plugins/gfxdrivers/transformed/main.cpp84
-rw-r--r--src/plugins/gfxdrivers/transformed/transformed.pro13
-rw-r--r--src/plugins/gfxdrivers/vnc/main.cpp86
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_p.h524
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp2338
-rw-r--r--src/plugins/gfxdrivers/vnc/vnc.pro16
-rw-r--r--src/plugins/graphicssystems/graphicssystems.pro15
-rw-r--r--src/plugins/graphicssystems/meego/dithering.cpp266
-rw-r--r--src/plugins/graphicssystems/meego/meego.pro13
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.cpp213
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.h125
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp534
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h127
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp58
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h54
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp323
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h78
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp224
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.h74
-rw-r--r--src/plugins/graphicssystems/opengl/opengl.pro13
-rw-r--r--src/plugins/graphicssystems/openvg/main.cpp71
-rw-r--r--src/plugins/graphicssystems/openvg/openvg.pro14
-rw-r--r--src/plugins/graphicssystems/shivavg/README8
-rw-r--r--src/plugins/graphicssystems/shivavg/main.cpp71
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavg.pro12
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp62
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp358
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h76
-rw-r--r--src/plugins/graphicssystems/trace/main.cpp69
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp153
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h71
-rw-r--r--src/plugins/graphicssystems/trace/trace.pro13
-rw-r--r--src/plugins/inputmethods/imsw-multi/imsw-multi.pro13
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontext.cpp212
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h117
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.cpp111
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h85
-rw-r--r--src/plugins/inputmethods/inputmethods.pro3
-rw-r--r--src/plugins/kbddrivers/kbddrivers.pro2
-rw-r--r--src/plugins/kbddrivers/linuxinput/linuxinput.pro14
-rw-r--r--src/plugins/kbddrivers/linuxinput/main.cpp77
-rw-r--r--src/plugins/mousedrivers/linuxtp/linuxtp.pro14
-rw-r--r--src/plugins/mousedrivers/linuxtp/main.cpp76
-rw-r--r--src/plugins/mousedrivers/mousedrivers.pro5
-rw-r--r--src/plugins/mousedrivers/pc/main.cpp81
-rw-r--r--src/plugins/mousedrivers/pc/pc.pro14
-rw-r--r--src/plugins/mousedrivers/tslib/main.cpp77
-rw-r--r--src/plugins/mousedrivers/tslib/tslib.pro16
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro28
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h (renamed from src/plugins/platforms/cocoa/qcocoawindowsurface.h)18
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm (renamed from src/plugins/platforms/cocoa/qcocoawindowsurface.mm)27
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h231
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm1133
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm112
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h42
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm90
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h9
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm37
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h (renamed from src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h)16
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm (renamed from src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp)31
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h25
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm259
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h11
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm230
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h21
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm10
-rw-r--r--src/plugins/platforms/directfb/directfb.pro2
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.cpp9
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.h2
-rw-r--r--src/plugins/platforms/eglconvenience/eglconvenience.pri7
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.cpp324
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h60
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp157
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.h71
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp184
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.h53
-rw-r--r--src/plugins/platforms/eglconvenience/xlibeglintegration.pri7
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pro2
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h2
-rw-r--r--src/plugins/platforms/externalplugin.pri29
-rw-r--r--src/plugins/platforms/fb_base/fb_base.cpp507
-rw-r--r--src/plugins/platforms/fb_base/fb_base.h210
-rw-r--r--src/plugins/platforms/fb_base/fb_base.pri2
-rw-r--r--src/plugins/platforms/fb_base/fb_base.pro23
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/basicunix.pri88
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp328
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h67
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri12
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp601
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h56
-rw-r--r--src/plugins/platforms/fontdatabases/genericunix/genericunix.pri10
-rw-r--r--src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h53
-rw-r--r--src/plugins/platforms/glxconvenience/glxconvenience.pri15
-rw-r--r--src/plugins/platforms/glxconvenience/qglxconvenience.cpp257
-rw-r--r--src/plugins/platforms/glxconvenience/qglxconvenience.h56
-rw-r--r--src/plugins/platforms/linuxfb/linuxfb.pro2
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp6
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.h2
-rw-r--r--src/plugins/platforms/minimal/minimal.pro6
-rw-r--r--src/plugins/platforms/minimal/qminimalbackingstore.cpp (renamed from src/plugins/platforms/minimal/qminimalwindowsurface.cpp)29
-rw-r--r--src/plugins/platforms/minimal/qminimalbackingstore.h (renamed from src/plugins/platforms/minimal/qminimalwindowsurface.h)18
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp28
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h5
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.cpp2
-rw-r--r--src/plugins/platforms/platforms.pro4
-rw-r--r--src/plugins/platforms/qvfb/qvfb.pro1
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.cpp6
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.h2
-rw-r--r--src/plugins/platforms/uikit/uikit.pro4
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp4
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.h3
-rw-r--r--src/plugins/platforms/vnc/qvncserver.cpp2
-rw-r--r--src/plugins/platforms/vnc/vnc.pro2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/gl_integration.pri13
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h8
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp184
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp (renamed from src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp)86
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h (renamed from src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h)33
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp (renamed from src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp)44
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h (renamed from src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h)42
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp (renamed from src/plugins/graphicssystems/opengl/main.cpp)87
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h (renamed from src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h)35
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri10
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp16
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h3
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp9
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h6
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp101
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h27
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp9
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h5
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp65
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h18
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp20
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h11
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp80
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h22
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp70
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h28
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp123
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h30
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp9
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h7
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp100
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h22
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp110
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h33
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp23
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h5
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp95
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h24
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h4
-rw-r--r--src/plugins/platforms/wayland/main.cpp7
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.cpp2
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp6
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp10
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h4
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp12
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp66
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h12
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.cpp16
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.h6
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.cpp4
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp (renamed from src/plugins/platforms/wayland/qwaylandshmsurface.cpp)30
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmbackingstore.h (renamed from src/plugins/platforms/wayland/qwaylandshmsurface.h)18
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.cpp10
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.h4
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp12
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h2
-rw-r--r--src/plugins/platforms/wayland/wayland.pro25
-rw-r--r--src/plugins/platforms/xcb/README2
-rw-r--r--src/plugins/platforms/xcb/qdri2context.cpp4
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp52
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h22
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp (renamed from src/plugins/platforms/xcb/qxcbwindowsurface.cpp)76
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.h (renamed from src/plugins/platforms/xcb/qxcbwindowsurface.h)16
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp848
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.h108
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp389
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h76
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp546
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.h (renamed from src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h)39
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp1330
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h158
-rw-r--r--src/plugins/platforms/xcb/qxcbeglsurface.h (renamed from src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h)30
-rw-r--r--src/plugins/platforms/xcb/qxcbimage.cpp266
-rw-r--r--src/plugins/platforms/xcb/qxcbimage.h (renamed from src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h)56
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp220
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h18
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp213
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h13
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp288
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.h68
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp92
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h18
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp95
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp937
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h61
-rw-r--r--src/plugins/platforms/xcb/qxcbwmsupport.cpp136
-rw-r--r--src/plugins/platforms/xcb/qxcbwmsupport.h (renamed from src/plugins/platforms/cocoa/qcocoaeventloopintegration.h)34
-rw-r--r--src/plugins/platforms/xcb/xcb.pro63
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.cpp8
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.h1
-rw-r--r--src/plugins/platforms/xlib/xlib.pro18
-rw-r--r--src/plugins/plugins.pro3
275 files changed, 8821 insertions, 22562 deletions
diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h
index c6453f19c4..3c01445091 100644
--- a/src/plugins/accessible/widgets/complexwidgets.h
+++ b/src/plugins/accessible/widgets/complexwidgets.h
@@ -43,9 +43,9 @@
#define COMPLEXWIDGETS_H
#include <QtCore/qpointer.h>
-#include <QtGui/qaccessiblewidget.h>
-#include <QtGui/qabstractitemview.h>
-#include <QtGui/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
+#include <QtWidgets/qabstractitemview.h>
+#include <QtWidgets/qaccessible2.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
index 1454c7c80b..8e72910b45 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
@@ -43,7 +43,7 @@
#include <qmenu.h>
#include <qmenubar.h>
-#include <QtGui/QAction>
+#include <QtWidgets/QAction>
#include <qstyle.h>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.h b/src/plugins/accessible/widgets/qaccessiblemenu.h
index 680594d667..1ee6d5436f 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.h
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.h
@@ -42,7 +42,7 @@
#ifndef QACCESSIBLEMENU_H
#define QACCESSIBLEMENU_H
-#include <QtGui/qaccessiblewidget.h>
+#include <QtWidgets/qaccessiblewidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index 34f5be912f..b14ee88bc8 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -65,7 +65,7 @@
#include <QMainWindow>
#include <QAbstractButton>
#include <private/qdockwidget_p.h>
-#include <QtGui/QFocusFrame>
+#include <QFocusFrame>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h
index 242f8c1610..942012896b 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.h
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h
@@ -42,8 +42,8 @@
#ifndef QACCESSIBLEWIDGETS_H
#define QACCESSIBLEWIDGETS_H
-#include <QtGui/qaccessible2.h>
-#include <QtGui/qaccessiblewidget.h>
+#include <QtWidgets/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h
index 0f21a5a119..529a331c94 100644
--- a/src/plugins/accessible/widgets/rangecontrols.h
+++ b/src/plugins/accessible/widgets/rangecontrols.h
@@ -42,8 +42,8 @@
#ifndef RANGECONTROLS_H
#define RANGECONTROLS_H
-#include <QtGui/qaccessiblewidget.h>
-#include <QtGui/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
+#include <QtWidgets/qaccessible2.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h
index d5144caebd..7cc14410cf 100644
--- a/src/plugins/accessible/widgets/simplewidgets.h
+++ b/src/plugins/accessible/widgets/simplewidgets.h
@@ -43,8 +43,8 @@
#define SIMPLEWIDGETS_H
#include <QtCore/qcoreapplication.h>
-#include <QtGui/qaccessible2.h>
-#include <QtGui/qaccessiblewidget.h>
+#include <QtWidgets/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/widgets.pro b/src/plugins/accessible/widgets/widgets.pro
index 00d99f94e7..6dd7e5022b 100644
--- a/src/plugins/accessible/widgets/widgets.pro
+++ b/src/plugins/accessible/widgets/widgets.pro
@@ -2,7 +2,7 @@ TARGET = qtaccessiblewidgets
load(qt_plugin)
include (../qaccessiblebase.pri)
-QT += core-private gui-private
+QT += core-private gui-private widgets-private
DESTDIR = $$QT.gui.plugins/accessible
QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)"
diff --git a/src/plugins/decorations/decorations.pro b/src/plugins/decorations/decorations.pro
deleted file mode 100644
index 3d6912e77c..0000000000
--- a/src/plugins/decorations/decorations.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-contains(decoration-plugins, default) :SUBDIRS += default
-contains(decoration-plugins, styled) :SUBDIRS += styled
-contains(decoration-plugins, windows) :SUBDIRS += windows
diff --git a/src/plugins/decorations/default/default.pro b/src/plugins/decorations/default/default.pro
deleted file mode 100644
index c323d10930..0000000000
--- a/src/plugins/decorations/default/default.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = qdecorationdefault
-load(qt_plugin)
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationdefault_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qdecorationdefault_qws.cpp
-
-DESTDIR = $$QT.gui.plugins/decorations
-target.path += $$[QT_INSTALL_PLUGINS]/decorations
-INSTALLS += target
diff --git a/src/plugins/decorations/default/main.cpp b/src/plugins/decorations/default/main.cpp
deleted file mode 100644
index b93b6f8b0e..0000000000
--- a/src/plugins/decorations/default/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdecorationplugin_qws.h>
-#include <qdecorationdefault_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class DecorationDefault : public QDecorationPlugin
-{
-public:
- DecorationDefault();
-
- QStringList keys() const;
- QDecoration *create(const QString&);
-};
-
-DecorationDefault::DecorationDefault()
- : QDecorationPlugin()
-{
-}
-
-QStringList DecorationDefault::keys() const
-{
- return (QStringList() << QLatin1String("Default"));
-}
-
-QDecoration* DecorationDefault::create(const QString& s)
-{
- if (s.toLower() == QLatin1String("default"))
- return new QDecorationDefault();
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(qdecorationdefault, DecorationDefault)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/decorations/styled/main.cpp b/src/plugins/decorations/styled/main.cpp
deleted file mode 100644
index 69c339843a..0000000000
--- a/src/plugins/decorations/styled/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdecorationplugin_qws.h>
-#include <qdecorationstyled_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class DecorationStyled : public QDecorationPlugin
-{
-public:
- DecorationStyled();
-
- QStringList keys() const;
- QDecoration *create(const QString&);
-};
-
-DecorationStyled::DecorationStyled() : QDecorationPlugin()
-{
-}
-
-QStringList DecorationStyled::keys() const
-{
- return (QStringList() << QLatin1String("Styled"));
-}
-
-QDecoration* DecorationStyled::create(const QString& s)
-{
- if (s.toLower() != QLatin1String("styled"))
- return 0;
-
- qDebug("creatign styled decoration");
-
- return new QDecorationStyled;
-}
-
-Q_EXPORT_PLUGIN2(qdecorationstyled, DecorationStyled)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/decorations/styled/styled.pro b/src/plugins/decorations/styled/styled.pro
deleted file mode 100644
index c5329aea29..0000000000
--- a/src/plugins/decorations/styled/styled.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qdecorationstyled
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/decorations
-target.path += $$[QT_INSTALL_PLUGINS]/decorations
-INSTALLS += target
-
-DEFINES += QT_QWS_DECORATION_STYLED
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationstyled_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qdecorationstyled_qws.cpp
-
diff --git a/src/plugins/decorations/windows/main.cpp b/src/plugins/decorations/windows/main.cpp
deleted file mode 100644
index 8ee8a156e8..0000000000
--- a/src/plugins/decorations/windows/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdecorationplugin_qws.h>
-#include <qdecorationwindows_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class DecorationWindows : public QDecorationPlugin
-{
-public:
- DecorationWindows();
-
- QStringList keys() const;
- QDecoration *create(const QString&);
-};
-
-DecorationWindows::DecorationWindows()
- : QDecorationPlugin()
-{
-}
-
-QStringList DecorationWindows::keys() const
-{
- return (QStringList() << QLatin1String("Windows"));
-}
-
-QDecoration* DecorationWindows::create(const QString& s)
-{
- if (s.toLower() == QLatin1String("windows"))
- return new QDecorationWindows();
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(qdecorationwindows, DecorationWindows)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/decorations/windows/windows.pro b/src/plugins/decorations/windows/windows.pro
deleted file mode 100644
index f27adb908b..0000000000
--- a/src/plugins/decorations/windows/windows.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = qdecorationwindows
-load(qt_plugin)
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationwindows_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qdecorationwindows_qws.cpp
-
-DESTDIR = $$QT.gui.plugins/decorations
-target.path += $$[QT_INSTALL_PLUGINS]/decorations
-INSTALLS += target
diff --git a/src/plugins/gfxdrivers/ahi/ahi.pro b/src/plugins/gfxdrivers/ahi/ahi.pro
deleted file mode 100644
index fd078421f9..0000000000
--- a/src/plugins/gfxdrivers/ahi/ahi.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qahiscreen
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-HEADERS = qscreenahi_qws.h
-
-SOURCES = qscreenahi_qws.cpp \
- qscreenahiplugin.cpp
-
-LIBS += -lahi
diff --git a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp b/src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp
deleted file mode 100644
index 320aff9811..0000000000
--- a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp
+++ /dev/null
@@ -1,598 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenahi_qws.h"
-
-#ifndef QT_NO_QWS_AHI
-
-#include <QtGui/qcolor.h>
-#include <QtGui/qapplication.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qvarlengtharray.h>
-#include <private/qwssignalhandler_p.h>
-
-#include <ahi.h>
-
-//#define QAHISCREEN_DEBUG
-
-static int depthForPixelFormat(const AhiPixelFormat_t format)
-{
- switch (format) {
- case AhiPix1bpp:
- return 1;
- case AhiPix2bpp:
- return 2;
- case AhiPix4bpp:
- return 4;
- case AhiPix8bpp_332RGB:
- case AhiPix8bpp:
- return 8;
- case AhiPix16bpp_444RGB:
- return 12;
- case AhiPix16bpp_555RGB:
- return 15;
- case AhiPix16bpp_565RGB:
- return 16;
- case AhiPix32bpp_8888ARGB:
- case AhiPix32bpp_8888BGRA:
- return 32;
- default:
- return 0;
- }
-}
-
-static AhiPixelFormat_t pixelFormatForImageFormat(const QImage::Format format)
-{
- switch (format) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- return AhiPix1bpp;
- case QImage::Format_Indexed8:
- return AhiPix8bpp;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- return AhiPix32bpp_8888ARGB;
- case QImage::Format_RGB16:
- return AhiPix16bpp_565RGB;
- case QImage::Format_RGB555:
- return AhiPix16bpp_555RGB;
- case QImage::Format_ARGB4444_Premultiplied:
- case QImage::Format_RGB444:
- return AhiPix16bpp_444RGB;
- default:
- return AhiPixelFormatMax;
- }
-}
-
-class QAhiScreenCursor : public QScreenCursor
-{
-public:
- QAhiScreenCursor(QScreen *screen, AhiDevCtx_t context);
-
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
- void show();
- void hide();
-
-private:
- QScreen *screen;
- AhiDevCtx_t context;
-};
-
-QAhiScreenCursor::QAhiScreenCursor(QScreen *s, AhiDevCtx_t c)
- : QScreenCursor(), screen(s), context(c)
-{
- hwaccel = true;
- supportsAlpha = true;
-
- if (enable)
- show();
- else
- hide();
-}
-
-void QAhiScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- if (image.isNull()) {
- QScreenCursor::set(image, hotx, hoty);
- return;
- }
-
- if (image.format() != QImage::Format_MonoLSB) {
- set(image.convertToFormat(QImage::Format_MonoLSB), hotx, hoty);
- return;
- }
-
- AhiPixelFormat_t pixFmt = pixelFormatForImageFormat(image.format());
-
- if (pixFmt >= AhiPixelFormatMax) { // generic fallback
- QImage::Format toFormat = screen->pixelFormat();
- if (toFormat == QImage::Format_Invalid)
- toFormat = QImage::Format_ARGB32;
- set(image.convertToFormat(toFormat), hotx, hoty);
- return;
- }
-
- AhiPoint_t hotSpot = { hotx, hoty };
- AhiSize_t bitmapSize = { image.width(), image.height() };
- AhiBitmap_t bitmap = { bitmapSize, (void*)(image.bits()),
- image.bytesPerLine(), pixFmt };
-
- AhiSts_t status;
- status = AhiDispCursorSet(context, AhiCursor1, &bitmap, &hotSpot,
- image.serialNumber(), 0);
- if (status != AhiStsOk)
- qWarning("QAhiScreenCursor::set(): AhiDispCursorSet failed: %x",
- status);
-
- QScreenCursor::set(image, hotx, hoty);
-}
-
-void QAhiScreenCursor::move(int x, int y)
-{
- AhiPoint_t pos = { x, y };
- AhiSts_t status = AhiDispCursorPos(context, AhiCursor1, &pos, 0);
- if (status != AhiStsOk)
- qWarning("QAhiScreenCursor::move(): error setting mouse position: %x",
- status);
- QScreenCursor::move(x, y);
-}
-
-void QAhiScreenCursor::show()
-{
- AhiSts_t status;
- status = AhiDispCursorState(context, AhiCursor1, AhiCursorStateOn, 0);
- if (status != AhiStsOk)
- qWarning("QAhiScreenCursor::show(): error setting state: %x", status);
- QScreenCursor::show();
-}
-
-void QAhiScreenCursor::hide()
-{
- AhiDispCursorState(context, AhiCursor1, AhiCursorStateOff, 0);
- QScreenCursor::hide();
-}
-
-class QAhiScreenPrivate : public QObject
-{
-public:
- QAhiScreenPrivate();
- ~QAhiScreenPrivate();
-
- bool setMode(AhiDispMode_t mode);
-
- AhiDevCtx_t context;
- AhiSurf_t surface;
- QAhiScreenCursor *cursor;
-};
-
-QT_BEGIN_NAMESPACE
-
-QAhiScreenPrivate::QAhiScreenPrivate()
- : context(0), surface(0), cursor(0)
-{
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-}
-
-QAhiScreenPrivate::~QAhiScreenPrivate()
-{
- delete cursor;
-
- if (surface) {
- AhiSurfFree(context, surface);
- surface = 0;
- }
- if (context) {
- AhiDevClose(context);
- context = 0;
- }
- AhiTerm();
-}
-
-bool QAhiScreenPrivate::setMode(AhiDispMode_t mode)
-{
- AhiSts_t status;
-
- status = AhiDispModeSet(context, &mode, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreenPrivate::setMode(): AhiDispModeSet failed: %x",
- status);
- return false;
- }
-
- if (surface) {
- AhiSurfFree(context, surface);
- surface = 0;
- }
- status = AhiSurfAlloc(context, &surface, &mode.size, mode.pixFmt,
- AHIFLAG_SURFFIXED);
- if (status != AhiStsOk) {
- qCritical("QAhiScreenPrivate::setMode(): AhisurfAlloc failed: %x",
- status);
- return false;
- }
-
- status = AhiDispSurfSet(context, surface, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreenPrivate::setMode(): AhiDispSurfSet failed: %x",
- status);
- return false;
- }
-
- return true;
-}
-
-QAhiScreen::QAhiScreen(int displayId)
- : QScreen(displayId), d_ptr(new QAhiScreenPrivate)
-{
-}
-
-QAhiScreen::~QAhiScreen()
-{
- delete d_ptr;
-}
-
-bool QAhiScreen::configure()
-{
- AhiSurfInfo_t surfaceInfo;
- AhiSts_t status;
-
- status = AhiSurfInfo(d_ptr->context, d_ptr->surface, &surfaceInfo);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::configure(): AhiSurfInfo failed: %x", status);
- return false;
- }
-
- QScreen::data = 0;
- QScreen::w = QScreen::dw = surfaceInfo.size.cx;
- QScreen::h = QScreen::dh = surfaceInfo.size.cy;
- QScreen::lstep = surfaceInfo.stride;
- QScreen::size = surfaceInfo.sizeInBytes;
-
- switch (surfaceInfo.pixFmt) {
- case AhiPix1bpp:
- setPixelFormat(QImage::Format_Mono);
- QScreen::d = 1;
- break;
- case AhiPix4bpp:
- QScreen::d = 4;
- break;
- case AhiPix8bpp_332RGB:
- case AhiPix8bpp:
- QScreen::d = 8;
- break;
- case AhiPix16bpp_444RGB:
- setPixelFormat(QImage::Format_RGB444);
- QScreen::d = 12;
- break;
- case AhiPix16bpp_555RGB:
- setPixelFormat(QImage::Format_RGB555);
- QScreen::d = 15;
- break;
- case AhiPix16bpp_565RGB:
- setPixelFormat(QImage::Format_RGB16);
- QScreen::d = 16;
- break;
- case AhiPix2bpp:
- QScreen::d = 2;
- break;
- case AhiPix32bpp_8888ARGB:
- setPixelFormat(QImage::Format_ARGB32);
- // fallthrough
- case AhiPix32bpp_8888BGRA:
- QScreen::d = 32;
- break;
- default:
- qCritical("QAhiScreen::configure(): Unknown pixel format: %x",
- surfaceInfo.pixFmt);
- return false;
- }
-
- const int dpi = 72;
- QScreen::physWidth = qRound(QScreen::dw * 25.4 / dpi);
- QScreen::physHeight = qRound(QScreen::dh * 25.4 / dpi);
-
- return true;
-}
-
-bool QAhiScreen::connect(const QString &displaySpec)
-{
- Q_UNUSED(displaySpec);
-
- AhiSts_t status;
-
- status = AhiInit(0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiInit failed: %x", status);
- return false;
- }
-
- AhiDev_t device;
- AhiDevInfo_t info;
-
- status = AhiDevEnum(&device, &info, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDevEnum failed: %x", status);
- return false;
- }
-#ifdef QAHISCREEN_DEBUG
- {
- int displayNo = 0;
- AhiDevInfo_t dispInfo = info;
- qDebug("AHI supported devices:");
- do {
- qDebug(" %2i: %s, sw version: %s (rev %u)\n"
- " chip: 0x%x (rev %u), mem: %i (%i/%i), bus: 0x%x",
- displayNo, dispInfo.name,
- dispInfo.swVersion, uint(dispInfo.swRevision),
- uint(dispInfo.chipId), uint(dispInfo.revisionId),
- uint(dispInfo.totalMemory),
- uint(dispInfo.internalMemSize),
- uint(dispInfo.externalMemSize),
- uint(dispInfo.cpuBusInterfaceMode));
- status = AhiDevEnum(&device, &info, ++displayNo);
- } while (status == AhiStsOk);
- }
-#endif
-
- status = AhiDevOpen(&d_ptr->context, device, "qscreenahi",
- AHIFLAG_USERLEVEL);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDevOpen failed: %x", status);
- return false;
- }
-
- AhiDispMode_t mode;
-
- status = AhiDispModeEnum(d_ptr->context, &mode, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDispModeEnum failed: %x", status);
- return false;
- }
-
-#ifdef QAHISCREEN_DEBUG
- {
- int modeNo = 0;
- AhiDispMode_t modeInfo = mode;
- qDebug("AHI supported modes:");
- do {
- qDebug(" %2i: %ux%u, fmt: %i, %u Hz, rot: %i, mirror: %i",
- modeNo, uint(modeInfo.size.cx), uint(modeInfo.size.cy),
- modeInfo.pixFmt, uint(modeInfo.frequency),
- modeInfo.rotation, modeInfo.mirror);
- status = AhiDispModeEnum(d_ptr->context, &modeInfo, ++modeNo);
- } while (status == AhiStsOk);
- }
-#endif
-
- if (QApplication::type() == QApplication::GuiServer) {
- if (!d_ptr->setMode(mode))
- return false;
- } else {
- status = AhiDispSurfGet(d_ptr->context, &d_ptr->surface);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDispSurfGet failed: %x",
- status);
- return false;
- }
-
- status = AhiDispModeGet(d_ptr->context, &mode);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::context(): AhiDispModeGet failed: %x",
- status);
- return false;
- }
- }
-
- return configure();
-}
-
-void QAhiScreen::disconnect()
-{
- AhiSurfFree(d_ptr->context, d_ptr->surface);
- d_ptr->surface = 0;
- AhiDevClose(d_ptr->context);
- d_ptr->context = 0;
- AhiTerm();
-}
-
-bool QAhiScreen::initDevice()
-{
- QScreenCursor::initSoftwareCursor();
-
- AhiSts_t status = AhiDispState(d_ptr->context, AhiDispStateOn, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDispState failed: %x", status);
- return false;
- }
-
- return true;
-}
-
-void QAhiScreen::shutdownDevice()
-{
- AhiDispState(d_ptr->context, AhiDispStateOff, 0);
-}
-
-void QAhiScreen::setMode(int width, int height, int depth)
-{
- int modeNo = 0;
- AhiDispMode_t mode;
- AhiSts_t status = AhiStsOk;
-
- while (status == AhiStsOk) {
- status = AhiDispModeEnum(d_ptr->context, &mode, modeNo);
- if (mode.size.cx == uint(width) &&
- mode.size.cy == uint(height) &&
- depthForPixelFormat(mode.pixFmt) == depth)
- {
- d_ptr->setMode(mode);
- configure();
- return;
- }
- }
-}
-
-void QAhiScreen::blit(const QImage &image, const QPoint &topLeft,
- const QRegion &reg)
-{
- AhiPixelFormat_t pixFmt = pixelFormatForImageFormat(image.format());
-
- if (pixFmt >= AhiPixelFormatMax) { // generic fallback
- QImage::Format toFormat = pixelFormat();
- if (toFormat == QImage::Format_Invalid)
- toFormat = QImage::Format_ARGB32;
- blit(image.convertToFormat(toFormat), topLeft, reg);
- return;
- }
-
- AhiSts_t status;
-
- status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::blit(): AhiDrawSurfDstSet failed: %x", status);
- return;
- }
-
- const QVector<QRect> rects = (reg & region()).rects();
- const int numRects = rects.size();
- QVarLengthArray<AhiPoint_t, 8> src(numRects);
- QVarLengthArray<AhiRect_t, 8> dest(numRects);
-
- for (int i = 0; i < numRects; ++i) {
- const QRect rect = rects.at(i);
-
- src[i].x = rect.x() - topLeft.x();
- src[i].y = rect.y() - topLeft.y();
- dest[i].left = rect.left();
- dest[i].top = rect.top();
- dest[i].right = rect.x() + rect.width();
- dest[i].bottom = rect.y() + rect.height();
- }
-
- AhiSize_t bitmapSize = { image.width(), image.height() };
- AhiBitmap_t bitmap = { bitmapSize, (void*)(image.bits()),
- image.bytesPerLine(), pixFmt };
-
- status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPSRCCOPY));
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::blit(): AhiDrawRopSet failed: %x", status);
- return;
- }
-
- for (int i = 0; i < numRects; ++i) {
- status = AhiDrawBitmapBlt(d_ptr->context, &dest[i], &src[i],
- &bitmap, 0, 0);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::blit(): AhiDrawBitmapBlt failed: %x",
- status);
- break;
- }
- }
-}
-
-void QAhiScreen::solidFill(const QColor &color, const QRegion &reg)
-{
- AhiSts_t status = AhiStsOk;
-
- switch (pixelFormat()) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB32:
- case QImage::Format_RGB32:
- status = AhiDrawBrushFgColorSet(d_ptr->context, color.rgba());
- break;
- case QImage::Format_RGB16:
- status = AhiDrawBrushFgColorSet(d_ptr->context, qt_convRgbTo16(color.rgb()));
- break;
- default:
- qFatal("QAhiScreen::solidFill(): Not implemented for pixel format %d",
- int(pixelFormat()));
- break;
- }
-
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawBrushFgColorSet failed: %x",
- status);
- return;
- }
-
- status = AhiDrawBrushSet(d_ptr->context, 0, 0, 0, AHIFLAG_BRUSHSOLID);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawBrushSet failed: %x",
- status);
- return;
- }
-
- status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPPATCOPY));
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawRopSet failed: %x", status);
- return;
- }
-
- status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawSurfDst failed: %x", status);
- return;
- }
-
- const QVector<QRect> rects = (reg & region()).rects();
- QVarLengthArray<AhiRect_t> ahiRects(rects.size());
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect rect = rects.at(i);
- ahiRects[i].left = rect.left();
- ahiRects[i].top = rect.top();
- ahiRects[i].right = rect.x() + rect.width();
- ahiRects[i].bottom = rect.y() + rect.height();
- }
-
- status = AhiDrawBitBltMulti(d_ptr->context, ahiRects.data(),
- 0, ahiRects.size());
- if (status != AhiStsOk)
- qWarning("QAhiScreen::solidFill(): AhiDrawBitBlt failed: %x", status);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_AHI
diff --git a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.h b/src/plugins/gfxdrivers/ahi/qscreenahi_qws.h
deleted file mode 100644
index a00cf77abf..0000000000
--- a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QAHISCREEN_H
-#define QAHISCREEN_H
-
-#include <QtGui/qscreenlinuxfb_qws.h>
-
-#ifndef QT_NO_QWS_AHI
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAhiScreenPrivate;
-
-class QAhiScreen : public QScreen
-{
-public:
- QAhiScreen(int displayId);
- ~QAhiScreen();
-
- bool connect(const QString &displaySpec);
- void disconnect();
- bool initDevice();
- void shutdownDevice();
- void setMode(int width, int height, int depth);
-
- void blit(const QImage &image, const QPoint &topLeft,
- const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
-
-private:
- bool configure();
-
- QAhiScreenPrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_AHI
-#endif // QAHISCREEN_H
diff --git a/src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp b/src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp
deleted file mode 100644
index 8cbc0447e5..0000000000
--- a/src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenahi_qws.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class QAhiScreenPlugin : public QScreenDriverPlugin
-{
-public:
- QAhiScreenPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-QAhiScreenPlugin::QAhiScreenPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList QAhiScreenPlugin::keys() const
-{
- return (QStringList() << "ahi");
-}
-
-QScreen* QAhiScreenPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() != "ahi")
- return 0;
-
- return new QAhiScreen(displayId);
-}
-
-Q_EXPORT_PLUGIN2(qahiscreen, QAhiScreenPlugin)
diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro
deleted file mode 100644
index 6fb2a0f9aa..0000000000
--- a/src/plugins/gfxdrivers/directfb/directfb.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TARGET = qdirectfbscreen
-load(qt_plugin)
-include($$QT_SOURCE_TREE/src/gui/embedded/directfb.pri)
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-SOURCES += qdirectfbscreenplugin.cpp
-
-QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB
-LIBS += $$QT_LIBS_DIRECTFB
-DEFINES += $$QT_DEFINES_DIRECTFB
-contains(gfx-plugins, directfb):DEFINES += QT_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
deleted file mode 100644
index 9ec3f71c7c..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbkeyboard.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbscreen.h"
-#include <qobject.h>
-#include <qsocketnotifier.h>
-#include <qhash.h>
-
-#include <directfb.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-class KeyMap : public QHash<DFBInputDeviceKeySymbol, Qt::Key>
-{
-public:
- KeyMap();
-};
-
-Q_GLOBAL_STATIC(KeyMap, keymap);
-
-class QDirectFBKeyboardHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *handler);
- ~QDirectFBKeyboardHandlerPrivate();
-
- void suspend();
- void resume();
-
-private:
- QDirectFBKeyboardHandler *handler;
- IDirectFBEventBuffer *eventBuffer;
- QSocketNotifier *keyboardNotifier;
- DFBEvent event;
- int bytesRead;
- int lastUnicode, lastKeycode;
- Qt::KeyboardModifiers lastModifiers;
-private Q_SLOTS:
- void readKeyboardData();
-};
-
-QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *h)
- : handler(h), eventBuffer(0), keyboardNotifier(0), bytesRead(0),
- lastUnicode(0), lastKeycode(0), lastModifiers(0)
-{
- Q_ASSERT(qt_screen);
-
- IDirectFB *fb = QDirectFBScreen::instance()->dfb();
- if (!fb) {
- qCritical("QDirectFBKeyboardHandler: DirectFB not initialized");
- return;
- }
-
- DFBResult result;
- result = fb->CreateInputEventBuffer(fb, DICAPS_KEYS, DFB_TRUE,
- &eventBuffer);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBKeyboardHandler: "
- "Unable to create input event buffer", result);
- return;
- }
-
- int fd;
- result = eventBuffer->CreateFileDescriptor(eventBuffer, &fd);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBKeyboardHandler: "
- "Unable to create file descriptor", result);
- return;
- }
-
- int flags = ::fcntl(fd, F_GETFL, 0);
- ::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
- memset(&event, 0, sizeof(event));
-
- keyboardNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(keyboardNotifier, SIGNAL(activated(int)),
- this, SLOT(readKeyboardData()));
- resume();
-}
-
-void QDirectFBKeyboardHandlerPrivate::suspend()
-{
- keyboardNotifier->setEnabled(false);
-}
-
-void QDirectFBKeyboardHandlerPrivate::resume()
-{
- eventBuffer->Reset(eventBuffer);
- keyboardNotifier->setEnabled(true);
-}
-
-QDirectFBKeyboardHandlerPrivate::~QDirectFBKeyboardHandlerPrivate()
-{
- if (eventBuffer)
- eventBuffer->Release(eventBuffer);
-}
-
-void QDirectFBKeyboardHandlerPrivate::readKeyboardData()
-{
- if(!qt_screen)
- return;
-
- for (;;) {
- // GetEvent returns DFB_UNSUPPORTED after CreateFileDescriptor().
- // This seems stupid and I really hope it's a bug which will be fixed.
-
- // DFBResult ret = eventBuffer->GetEvent(eventBuffer, &event);
-
- char *buf = reinterpret_cast<char*>(&event);
- int ret = ::read(keyboardNotifier->socket(),
- buf + bytesRead, sizeof(DFBEvent) - bytesRead);
- if (ret == -1) {
- if (errno != EAGAIN)
- qWarning("QDirectFBKeyboardHandlerPrivate::readKeyboardData(): %s",
- strerror(errno));
- return;
- }
-
- Q_ASSERT(ret >= 0);
- bytesRead += ret;
- if (bytesRead < int(sizeof(DFBEvent)))
- break;
- bytesRead = 0;
-
- Q_ASSERT(event.clazz == DFEC_INPUT);
-
- const DFBInputEvent input = event.input;
-
- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
-
- // Not implemented:
- // if (input.modifiers & DIMM_SUPER)
- // if (input.modifiers & DIMM_HYPER)
-
- if (!(input.flags & DIEF_KEYSYMBOL) ||
- !(input.flags & DIEF_KEYID) ||
- !(input.type & (DIET_KEYPRESS|DIET_KEYRELEASE)))
- {
- static bool first = true;
- if (first) {
- qWarning("QDirectFBKeyboardHandler - Getting unexpected non-keyboard related events");
- first = false;
- }
- break;
- }
-
- if (input.flags & DIEF_MODIFIERS) {
- if (input.modifiers & DIMM_SHIFT)
- modifiers |= Qt::ShiftModifier;
- if (input.modifiers & DIMM_CONTROL)
- modifiers |= Qt::ControlModifier;
- if (input.modifiers & DIMM_ALT)
- modifiers |= Qt::AltModifier;
- if (input.modifiers & DIMM_ALTGR)
- modifiers |= Qt::AltModifier;
- if (input.modifiers & DIMM_META)
- modifiers |= Qt::MetaModifier;
- }
-
-
- const bool press = input.type & DIET_KEYPRESS;
- DFBInputDeviceKeySymbol symbol = input.key_symbol;
- int unicode = -1;
- int keycode = 0;
-
- keycode = keymap()->value(symbol);
- if (DFB_KEY_TYPE(symbol) == DIKT_UNICODE)
- unicode = symbol;
-
- if (unicode != -1 || keycode != 0) {
- bool autoRepeat = false;
- if (press) {
- if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) {
- autoRepeat = true;
- } else {
- lastUnicode = unicode;
- lastKeycode = keycode;
- lastModifiers = modifiers;
- }
- } else {
- lastUnicode = lastKeycode = -1;
- lastModifiers = 0;
- }
- if (autoRepeat) {
- handler->processKeyEvent(unicode, keycode,
- modifiers, false, autoRepeat);
-
- }
-
- handler->processKeyEvent(unicode, keycode,
- modifiers, press, autoRepeat);
- }
- }
-}
-
-QDirectFBKeyboardHandler::QDirectFBKeyboardHandler(const QString &device)
- : QWSKeyboardHandler()
-{
- Q_UNUSED(device);
- d = new QDirectFBKeyboardHandlerPrivate(this);
-}
-
-QDirectFBKeyboardHandler::~QDirectFBKeyboardHandler()
-{
- delete d;
-}
-
-KeyMap::KeyMap()
-{
- insert(DIKS_BACKSPACE , Qt::Key_Backspace);
- insert(DIKS_TAB , Qt::Key_Tab);
- insert(DIKS_RETURN , Qt::Key_Return);
- insert(DIKS_ESCAPE , Qt::Key_Escape);
- insert(DIKS_DELETE , Qt::Key_Delete);
-
- insert(DIKS_CURSOR_LEFT , Qt::Key_Left);
- insert(DIKS_CURSOR_RIGHT , Qt::Key_Right);
- insert(DIKS_CURSOR_UP , Qt::Key_Up);
- insert(DIKS_CURSOR_DOWN , Qt::Key_Down);
- insert(DIKS_INSERT , Qt::Key_Insert);
- insert(DIKS_HOME , Qt::Key_Home);
- insert(DIKS_END , Qt::Key_End);
- insert(DIKS_PAGE_UP , Qt::Key_PageUp);
- insert(DIKS_PAGE_DOWN , Qt::Key_PageDown);
- insert(DIKS_PRINT , Qt::Key_Print);
- insert(DIKS_PAUSE , Qt::Key_Pause);
- insert(DIKS_SELECT , Qt::Key_Select);
- insert(DIKS_GOTO , Qt::Key_OpenUrl);
- insert(DIKS_CLEAR , Qt::Key_Clear);
- insert(DIKS_MENU , Qt::Key_Menu);
- insert(DIKS_HELP , Qt::Key_Help);
-
- insert(DIKS_INTERNET , Qt::Key_HomePage);
- insert(DIKS_MAIL , Qt::Key_LaunchMail);
- insert(DIKS_FAVORITES , Qt::Key_Favorites);
-
- insert(DIKS_BACK , Qt::Key_Back);
- insert(DIKS_FORWARD , Qt::Key_Forward);
- insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp);
- insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown);
- insert(DIKS_MUTE , Qt::Key_VolumeMute);
- insert(DIKS_PLAYPAUSE , Qt::Key_Pause);
- insert(DIKS_PLAY , Qt::Key_MediaPlay);
- insert(DIKS_STOP , Qt::Key_MediaStop);
- insert(DIKS_RECORD , Qt::Key_MediaRecord);
- insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious);
- insert(DIKS_NEXT , Qt::Key_MediaNext);
-
- insert(DIKS_F1 , Qt::Key_F1);
- insert(DIKS_F2 , Qt::Key_F2);
- insert(DIKS_F3 , Qt::Key_F3);
- insert(DIKS_F4 , Qt::Key_F4);
- insert(DIKS_F5 , Qt::Key_F5);
- insert(DIKS_F6 , Qt::Key_F6);
- insert(DIKS_F7 , Qt::Key_F7);
- insert(DIKS_F8 , Qt::Key_F8);
- insert(DIKS_F9 , Qt::Key_F9);
- insert(DIKS_F10 , Qt::Key_F10);
- insert(DIKS_F11 , Qt::Key_F11);
- insert(DIKS_F12 , Qt::Key_F12);
-
- insert(DIKS_SHIFT , Qt::Key_Shift);
- insert(DIKS_CONTROL , Qt::Key_Control);
- insert(DIKS_ALT , Qt::Key_Alt);
- insert(DIKS_ALTGR , Qt::Key_AltGr);
-
- insert(DIKS_META , Qt::Key_Meta);
- insert(DIKS_SUPER , Qt::Key_Super_L); // ???
- insert(DIKS_HYPER , Qt::Key_Hyper_L); // ???
-
- insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock);
- insert(DIKS_NUM_LOCK , Qt::Key_NumLock);
- insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock);
-
- insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot);
- insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering);
- insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute);
- insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve);
- insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron);
- insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla);
- insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex);
- insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis);
- insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute);
- insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave);
- insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota);
- insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron);
- insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek);
- insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound);
- insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde);
- insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound);
- insert(DIKS_SPACE , Qt::Key_Space);
- insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam);
- insert(DIKS_QUOTATION , Qt::Key_QuoteDbl);
- insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign);
- insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar);
- insert(DIKS_PERCENT_SIGN , Qt::Key_Percent);
- insert(DIKS_AMPERSAND , Qt::Key_Ampersand);
- insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe);
- insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft);
- insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight);
- insert(DIKS_ASTERISK , Qt::Key_Asterisk);
- insert(DIKS_PLUS_SIGN , Qt::Key_Plus);
- insert(DIKS_COMMA , Qt::Key_Comma);
- insert(DIKS_MINUS_SIGN , Qt::Key_Minus);
- insert(DIKS_PERIOD , Qt::Key_Period);
- insert(DIKS_SLASH , Qt::Key_Slash);
- insert(DIKS_0 , Qt::Key_0);
- insert(DIKS_1 , Qt::Key_1);
- insert(DIKS_2 , Qt::Key_2);
- insert(DIKS_3 , Qt::Key_3);
- insert(DIKS_4 , Qt::Key_4);
- insert(DIKS_5 , Qt::Key_5);
- insert(DIKS_6 , Qt::Key_6);
- insert(DIKS_7 , Qt::Key_7);
- insert(DIKS_8 , Qt::Key_8);
- insert(DIKS_9 , Qt::Key_9);
- insert(DIKS_COLON , Qt::Key_Colon);
- insert(DIKS_SEMICOLON , Qt::Key_Semicolon);
- insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less);
- insert(DIKS_EQUALS_SIGN , Qt::Key_Equal);
- insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater);
- insert(DIKS_QUESTION_MARK , Qt::Key_Question);
- insert(DIKS_AT , Qt::Key_At);
- insert(DIKS_CAPITAL_A , Qt::Key_A);
- insert(DIKS_CAPITAL_B , Qt::Key_B);
- insert(DIKS_CAPITAL_C , Qt::Key_C);
- insert(DIKS_CAPITAL_D , Qt::Key_D);
- insert(DIKS_CAPITAL_E , Qt::Key_E);
- insert(DIKS_CAPITAL_F , Qt::Key_F);
- insert(DIKS_CAPITAL_G , Qt::Key_G);
- insert(DIKS_CAPITAL_H , Qt::Key_H);
- insert(DIKS_CAPITAL_I , Qt::Key_I);
- insert(DIKS_CAPITAL_J , Qt::Key_J);
- insert(DIKS_CAPITAL_K , Qt::Key_K);
- insert(DIKS_CAPITAL_L , Qt::Key_L);
- insert(DIKS_CAPITAL_M , Qt::Key_M);
- insert(DIKS_CAPITAL_N , Qt::Key_N);
- insert(DIKS_CAPITAL_O , Qt::Key_O);
- insert(DIKS_CAPITAL_P , Qt::Key_P);
- insert(DIKS_CAPITAL_Q , Qt::Key_Q);
- insert(DIKS_CAPITAL_R , Qt::Key_R);
- insert(DIKS_CAPITAL_S , Qt::Key_S);
- insert(DIKS_CAPITAL_T , Qt::Key_T);
- insert(DIKS_CAPITAL_U , Qt::Key_U);
- insert(DIKS_CAPITAL_V , Qt::Key_V);
- insert(DIKS_CAPITAL_W , Qt::Key_W);
- insert(DIKS_CAPITAL_X , Qt::Key_X);
- insert(DIKS_CAPITAL_Y , Qt::Key_Y);
- insert(DIKS_CAPITAL_Z , Qt::Key_Z);
- insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft);
- insert(DIKS_BACKSLASH , Qt::Key_Backslash);
- insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight);
- insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum);
- insert(DIKS_UNDERSCORE , Qt::Key_Underscore);
- insert(DIKS_SMALL_A , Qt::Key_A);
- insert(DIKS_SMALL_B , Qt::Key_B);
- insert(DIKS_SMALL_C , Qt::Key_C);
- insert(DIKS_SMALL_D , Qt::Key_D);
- insert(DIKS_SMALL_E , Qt::Key_E);
- insert(DIKS_SMALL_F , Qt::Key_F);
- insert(DIKS_SMALL_G , Qt::Key_G);
- insert(DIKS_SMALL_H , Qt::Key_H);
- insert(DIKS_SMALL_I , Qt::Key_I);
- insert(DIKS_SMALL_J , Qt::Key_J);
- insert(DIKS_SMALL_K , Qt::Key_K);
- insert(DIKS_SMALL_L , Qt::Key_L);
- insert(DIKS_SMALL_M , Qt::Key_M);
- insert(DIKS_SMALL_N , Qt::Key_N);
- insert(DIKS_SMALL_O , Qt::Key_O);
- insert(DIKS_SMALL_P , Qt::Key_P);
- insert(DIKS_SMALL_Q , Qt::Key_Q);
- insert(DIKS_SMALL_R , Qt::Key_R);
- insert(DIKS_SMALL_S , Qt::Key_S);
- insert(DIKS_SMALL_T , Qt::Key_T);
- insert(DIKS_SMALL_U , Qt::Key_U);
- insert(DIKS_SMALL_V , Qt::Key_V);
- insert(DIKS_SMALL_W , Qt::Key_W);
- insert(DIKS_SMALL_X , Qt::Key_X);
- insert(DIKS_SMALL_Y , Qt::Key_Y);
- insert(DIKS_SMALL_Z , Qt::Key_Z);
- insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft);
- insert(DIKS_VERTICAL_BAR , Qt::Key_Bar);
- insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight);
- insert(DIKS_TILDE , Qt::Key_AsciiTilde);
-}
-
-QT_END_NAMESPACE
-#include "qdirectfbkeyboard.moc"
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
deleted file mode 100644
index f5f03e72eb..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbmouse.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbscreen.h"
-#include <qsocketnotifier.h>
-
-#include <directfb.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDirectFBMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler *h);
- ~QDirectFBMouseHandlerPrivate();
-
- void setEnabled(bool on);
-private:
- QDirectFBMouseHandler *handler;
- IDirectFBEventBuffer *eventBuffer;
-#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer *layer;
-#endif
- QSocketNotifier *mouseNotifier;
-
- QPoint prevPoint;
- Qt::MouseButtons prevbuttons;
-
- DFBEvent event;
- uint bytesRead;
-
-private Q_SLOTS:
- void readMouseData();
-};
-
-QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler *h)
- : handler(h), eventBuffer(0)
-{
- DFBResult result;
-
- QScreen *screen = QScreen::instance();
- if (!screen) {
- qCritical("QDirectFBMouseHandler: no screen instance found");
- return;
- }
-
- IDirectFB *fb = QDirectFBScreen::instance()->dfb();
- if (!fb) {
- qCritical("QDirectFBMouseHandler: DirectFB not initialized");
- return;
- }
-
-#ifndef QT_NO_DIRECTFB_LAYER
- layer = QDirectFBScreen::instance()->dfbDisplayLayer();
- if (!layer) {
- qCritical("QDirectFBMouseHandler: Unable to get primary display layer");
- return;
- }
-#endif
-
- DFBInputDeviceCapabilities caps;
- caps = DICAPS_BUTTONS | DICAPS_AXES;
- result = fb->CreateInputEventBuffer(fb, caps, DFB_TRUE, &eventBuffer);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBMouseHandler: "
- "Unable to create input event buffer", result);
- return;
- }
-
- int fd;
- result = eventBuffer->CreateFileDescriptor(eventBuffer, &fd);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBMouseHandler: "
- "Unable to create file descriptor", result);
- return;
- }
-
- int flags = fcntl(fd, F_GETFL, 0);
- fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
- // DirectFB seems to assume that the mouse always starts centered
- prevPoint = QPoint(screen->deviceWidth() / 2, screen->deviceHeight() / 2);
- prevbuttons = Qt::NoButton;
- memset(&event, 0, sizeof(event));
- bytesRead = 0;
-
- mouseNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
- setEnabled(true);
-}
-
-QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate()
-{
- if (eventBuffer)
- eventBuffer->Release(eventBuffer);
-}
-
-void QDirectFBMouseHandlerPrivate::setEnabled(bool on)
-{
- if (mouseNotifier->isEnabled() != on) {
-#ifndef QT_NO_DIRECTFB_LAYER
- DFBResult result;
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
- "Unable to set cooperative level", result);
- }
- result = layer->EnableCursor(layer, on ? 1 : 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
- "Unable to enable cursor", result);
- }
-
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
-
- layer->SetCooperativeLevel(layer, DLSCL_SHARED);
-#endif
- mouseNotifier->setEnabled(on);
- }
-}
-
-void QDirectFBMouseHandlerPrivate::readMouseData()
-{
- if (!QScreen::instance())
- return;
-
- for (;;) {
- // GetEvent returns DFB_UNSUPPORTED after CreateFileDescriptor().
- // This seems stupid and I really hope it's a bug which will be fixed.
-
- // DFBResult ret = eventBuffer->GetEvent(eventBuffer, &event);
-
- char *buf = reinterpret_cast<char*>(&event);
- int ret = ::read(mouseNotifier->socket(),
- buf + bytesRead, sizeof(DFBEvent) - bytesRead);
- if (ret == -1) {
- if (errno == EINTR)
- continue;
- if (errno == EAGAIN)
- return;
- qWarning("QDirectFBMouseHandlerPrivate::readMouseData(): %s",
- strerror(errno));
- return;
- }
-
- Q_ASSERT(ret >= 0);
- bytesRead += ret;
- if (bytesRead < sizeof(DFBEvent))
- break;
- bytesRead = 0;
-
- Q_ASSERT(event.clazz == DFEC_INPUT);
-
- const DFBInputEvent input = event.input;
- int x = prevPoint.x();
- int y = prevPoint.y();
- int wheel = 0;
-
- if (input.type == DIET_AXISMOTION) {
-#if defined(QT_NO_DIRECTFB_LAYER) || defined(QT_DIRECTFB_WINDOW_AS_CURSOR)
- if (input.flags & DIEF_AXISABS) {
- switch (input.axis) {
- case DIAI_X: x = input.axisabs; break;
- case DIAI_Y: y = input.axisabs; break;
- default:
- qWarning("QDirectFBMouseHandlerPrivate::readMouseData: "
- "unknown axis (absolute) %d", input.axis);
- break;
- }
- } else if (input.flags & DIEF_AXISREL) {
- switch (input.axis) {
- case DIAI_X: x += input.axisrel; break;
- case DIAI_Y: y += input.axisrel; break;
- case DIAI_Z: wheel = -120 * input.axisrel; break;
- default:
- qWarning("QDirectFBMouseHandlerPrivate::readMouseData: "
- "unknown axis (releative) %d", input.axis);
- }
- }
-#else
- if (input.axis == DIAI_X || input.axis == DIAI_Y) {
- DFBResult result = layer->GetCursorPosition(layer, &x, &y);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBMouseHandler::readMouseData",
- result);
- }
- } else if (input.axis == DIAI_Z) {
- Q_ASSERT(input.flags & DIEF_AXISREL);
- wheel = input.axisrel;
- wheel *= -120;
- }
-#endif
- }
-
- Qt::MouseButtons buttons = Qt::NoButton;
- if (input.flags & DIEF_BUTTONS) {
- if (input.buttons & DIBM_LEFT)
- buttons |= Qt::LeftButton;
- if (input.buttons & DIBM_MIDDLE)
- buttons |= Qt::MidButton;
- if (input.buttons & DIBM_RIGHT)
- buttons |= Qt::RightButton;
- }
-
- QPoint p = QPoint(x, y);
- handler->limitToScreen(p);
-
- if (p == prevPoint && wheel == 0 && buttons == prevbuttons)
- continue;
-
- prevPoint = p;
- prevbuttons = buttons;
-
- handler->mouseChanged(p, buttons, wheel);
- }
-}
-
-QDirectFBMouseHandler::QDirectFBMouseHandler(const QString &driver,
- const QString &device)
- : QWSMouseHandler(driver, device)
-{
- d = new QDirectFBMouseHandlerPrivate(this);
-}
-
-QDirectFBMouseHandler::~QDirectFBMouseHandler()
-{
- delete d;
-}
-
-void QDirectFBMouseHandler::suspend()
-{
- d->setEnabled(false);
-}
-
-void QDirectFBMouseHandler::resume()
-{
- d->setEnabled(true);
-}
-
-QT_END_NAMESPACE
-#include "qdirectfbmouse.moc"
-#endif // QT_NO_QWS_DIRECTFB
-
-
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
deleted file mode 100644
index 12004571cb..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBMOUSE_H
-#define QDIRECTFBMOUSE_H
-
-#include <qglobal.h>
-#include <QtGui/qmouse_qws.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBMouseHandlerPrivate;
-
-class QDirectFBMouseHandler : public QWSMouseHandler
-{
-public:
- explicit QDirectFBMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- ~QDirectFBMouseHandler();
-
- void suspend();
- void resume();
-protected:
- QDirectFBMouseHandlerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif // QT_NO_QWS_DIRECTFB
-#endif // QDIRECTFBMOUSE_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
deleted file mode 100644
index 90d0090790..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbscreen.h"
-#include "qdirectfbpaintdevice.h"
-#include "qdirectfbpaintengine.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_NAMESPACE
-
-QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr)
- : QCustomRasterPaintDevice(0), dfbSurface(0), screen(scr),
- bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), imageFormat(QImage::Format_Invalid)
-{
-#ifdef QT_DIRECTFB_SUBSURFACE
- subSurface = 0;
- syncPending = false;
-#endif
-}
-
-QDirectFBPaintDevice::~QDirectFBPaintDevice()
-{
- if (QDirectFBScreen::instance()) {
- unlockSurface();
-#ifdef QT_DIRECTFB_SUBSURFACE
- releaseSubSurface();
-#endif
- if (dfbSurface) {
- screen->releaseDFBSurface(dfbSurface);
- }
- }
- delete engine;
-}
-
-IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const
-{
- return dfbSurface;
-}
-
-bool QDirectFBPaintDevice::lockSurface(DFBSurfaceLockFlags lockFlags)
-{
- if (lockFlgs && (lockFlags & ~lockFlgs))
- unlockSurface();
- if (!mem) {
- Q_ASSERT(dfbSurface);
-#ifdef QT_DIRECTFB_SUBSURFACE
- if (!subSurface) {
- DFBResult result;
- subSurface = screen->getSubSurface(dfbSurface, QRect(), QDirectFBScreen::TrackSurface, &result);
- if (result != DFB_OK || !subSurface) {
- DirectFBError("Couldn't create sub surface", result);
- return false;
- }
- }
- IDirectFBSurface *surface = subSurface;
-#else
- IDirectFBSurface *surface = dfbSurface;
-#endif
- Q_ASSERT(surface);
- mem = QDirectFBScreen::lockSurface(surface, lockFlags, &bpl);
- lockFlgs = lockFlags;
- Q_ASSERT(mem);
- Q_ASSERT(bpl > 0);
- const QSize s = size();
- lockedImage = QImage(mem, s.width(), s.height(), bpl,
- QDirectFBScreen::getImageFormat(dfbSurface));
- return true;
- }
-#ifdef QT_DIRECTFB_SUBSURFACE
- if (syncPending) {
- syncPending = false;
- screen->waitIdle();
- }
-#endif
- return false;
-}
-
-void QDirectFBPaintDevice::unlockSurface()
-{
- if (QDirectFBScreen::instance() && lockFlgs) {
-#ifdef QT_DIRECTFB_SUBSURFACE
- IDirectFBSurface *surface = subSurface;
-#else
- IDirectFBSurface *surface = dfbSurface;
-#endif
- if (surface) {
- surface->Unlock(surface);
- lockFlgs = static_cast<DFBSurfaceLockFlags>(0);
- mem = 0;
- }
- }
-}
-
-void *QDirectFBPaintDevice::memory() const
-{
- return mem;
-}
-
-QImage::Format QDirectFBPaintDevice::format() const
-{
- return imageFormat;
-}
-
-int QDirectFBPaintDevice::bytesPerLine() const
-{
- Q_ASSERT(!mem || bpl != -1);
- return bpl;
-}
-
-QSize QDirectFBPaintDevice::size() const
-{
- int w, h;
- dfbSurface->GetSize(dfbSurface, &w, &h);
- return QSize(w, h);
-}
-
-int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- if (!dfbSurface)
- return 0;
-
- switch (metric) {
- case QPaintDevice::PdmWidth:
- case QPaintDevice::PdmHeight:
- return (metric == PdmWidth ? size().width() : size().height());
- case QPaintDevice::PdmWidthMM:
- return (size().width() * 1000) / dotsPerMeterX();
- case QPaintDevice::PdmHeightMM:
- return (size().height() * 1000) / dotsPerMeterY();
- case QPaintDevice::PdmPhysicalDpiX:
- case QPaintDevice::PdmDpiX:
- return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch
- case QPaintDevice::PdmPhysicalDpiY:
- case QPaintDevice::PdmDpiY:
- return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch
- case QPaintDevice::PdmDepth:
- return QDirectFBScreen::depth(imageFormat);
- case QPaintDevice::PdmNumColors: {
- if (!lockedImage.isNull())
- return lockedImage.colorCount();
-
- DFBResult result;
- IDirectFBPalette *palette = 0;
- unsigned int numColors = 0;
-
- result = dfbSurface->GetPalette(dfbSurface, &palette);
- if ((result != DFB_OK) || !palette)
- return 0;
-
- result = palette->GetSize(palette, &numColors);
- palette->Release(palette);
- if (result != DFB_OK)
- return 0;
-
- return numColors;
- }
- default:
- qCritical("QDirectFBPaintDevice::metric(): Unhandled metric!");
- return 0;
- }
-}
-
-QPaintEngine *QDirectFBPaintDevice::paintEngine() const
-{
- return engine;
-}
-
-#ifdef QT_DIRECTFB_SUBSURFACE
-void QDirectFBPaintDevice::releaseSubSurface()
-{
- Q_ASSERT(QDirectFBScreen::instance());
- if (subSurface) {
- unlockSurface();
- screen->releaseDFBSurface(subSurface);
- subSurface = 0;
- }
-}
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
deleted file mode 100644
index 975954a496..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBPAINTDEVICE_H
-#define QDIRECTFBPAINTDEVICE_H
-
-#include <private/qpaintengine_raster_p.h>
-#include "qdirectfbscreen.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Inherited by both window surface and pixmap
-class QDirectFBPaintEngine;
-class QDirectFBPaintDevice : public QCustomRasterPaintDevice
-{
-public:
- ~QDirectFBPaintDevice();
-
- virtual IDirectFBSurface *directFBSurface() const;
-
- bool lockSurface(DFBSurfaceLockFlags lockFlags);
- void unlockSurface();
-
- // Reimplemented from QCustomRasterPaintDevice:
- void *memory() const;
- QImage::Format format() const;
- int bytesPerLine() const;
- QSize size() const;
- int metric(QPaintDevice::PaintDeviceMetric metric) const;
- DFBSurfaceLockFlags lockFlags() const { return lockFlgs; }
- QPaintEngine *paintEngine() const;
-protected:
- QDirectFBPaintDevice(QDirectFBScreen *scr);
- inline int dotsPerMeterX() const
- {
- return (screen->deviceWidth() * 1000) / screen->physicalWidth();
- }
- inline int dotsPerMeterY() const
- {
- return (screen->deviceHeight() * 1000) / screen->physicalHeight();
- }
-
- IDirectFBSurface *dfbSurface;
-#ifdef QT_DIRECTFB_SUBSURFACE
- void releaseSubSurface();
- IDirectFBSurface *subSurface;
- friend class QDirectFBPaintEnginePrivate;
- bool syncPending;
-#endif
- QImage lockedImage;
- QDirectFBScreen *screen;
- int bpl;
- DFBSurfaceLockFlags lockFlgs;
- uchar *mem;
- QDirectFBPaintEngine *engine;
- QImage::Format imageFormat;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-#endif //QDIRECTFBPAINTDEVICE_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
deleted file mode 100644
index 18861cfac1..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ /dev/null
@@ -1,1430 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbpaintengine.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbwindowsurface.h"
-#include "qdirectfbscreen.h"
-#include "qdirectfbpixmap.h"
-#include <directfb.h>
-#include <qtransform.h>
-#include <qvarlengtharray.h>
-#include <qcache.h>
-#include <qmath.h>
-#include <private/qpixmapdata_p.h>
-#include <private/qpixmap_raster_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-class SurfaceCache;
-class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate
-{
-public:
- enum TransformationTypeFlags {
- Matrix_NegativeScale = 0x100,
- Matrix_RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject),
- Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported)
- };
-
- inline static uint getTransformationType(const QTransform &transform)
- {
- int ret = transform.type();
- if (qMin(transform.m11(), transform.m22()) < 0) {
- ret |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale;
- }
- return ret;
- }
-
- enum CompositionModeStatus {
- PorterDuff_None = 0x0,
- PorterDuff_Supported = 0x1,
- PorterDuff_PremultiplyColors = 0x2,
- PorterDuff_AlwaysBlend = 0x4
- };
-
- enum ClipType {
- ClipUnset,
- NoClip,
- RectClip,
- RegionClip,
- ComplexClip
- };
-
- QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p);
- ~QDirectFBPaintEnginePrivate();
-
- inline void setTransform(const QTransform &transforma);
- inline void setPen(const QPen &pen);
- inline void setCompositionMode(QPainter::CompositionMode mode);
- inline void setRenderHints(QPainter::RenderHints hints);
-
- inline void setDFBColor(const QColor &color);
-
- inline void lock();
- inline void unlock();
- static inline void unlock(QDirectFBPaintDevice *device);
-
- inline bool isSimpleBrush(const QBrush &brush) const;
-
- void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos, const QTransform &pixmapTransform);
- void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src);
-
- inline bool supportsStretchBlit() const;
-
- inline void updateClip();
- virtual void systemStateChanged();
-
- static IDirectFBSurface *getSurface(const QImage &img, bool *release);
-
-#ifdef QT_DIRECTFB_IMAGECACHE
- static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; }
-#endif
-
- enum BlitFlag {
- HasAlpha = 0x1,
- Premultiplied = 0x2
- };
- void prepareForBlit(uint blitFlags);
-
- IDirectFBSurface *surface;
-
- bool antialiased;
- bool simplePen;
-
- uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0
-
- SurfaceCache *surfaceCache;
- IDirectFB *fb;
- quint8 opacity;
-
- ClipType clipType;
- QDirectFBPaintDevice *dfbDevice;
- uint compositionModeStatus;
- bool isPremultiplied;
-
- bool inClip;
- QRect currentClip;
-
- QDirectFBPaintEngine *q;
-};
-
-class SurfaceCache
-{
-public:
- SurfaceCache() : surface(0), buffer(0), bufsize(0) {}
- ~SurfaceCache() { clear(); }
- IDirectFBSurface *getSurface(const uint *buf, int size);
- void clear();
-private:
- IDirectFBSurface *surface;
- uint *buffer;
- int bufsize;
-};
-
-
-#ifdef QT_DIRECTFB_IMAGECACHE
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <private/qimage_p.h>
-QT_END_INCLUDE_NAMESPACE
-struct CachedImage
-{
- IDirectFBSurface *surface;
- ~CachedImage()
- {
- if (surface && QDirectFBScreen::instance()) {
- QDirectFBScreen::instance()->releaseDFBSurface(surface);
- }
- }
-};
-static QCache<qint64, CachedImage> imageCache(4*1024*1024); // 4 MB
-#endif
-
-#define VOID_ARG() static_cast<bool>(false)
-enum PaintOperation {
- DRAW_RECTS = 0x0001, DRAW_LINES = 0x0002, DRAW_IMAGE = 0x0004,
- DRAW_PIXMAP = 0x0008, DRAW_TILED_PIXMAP = 0x0010, STROKE_PATH = 0x0020,
- DRAW_PATH = 0x0040, DRAW_POINTS = 0x0080, DRAW_ELLIPSE = 0x0100,
- DRAW_POLYGON = 0x0200, DRAW_TEXT = 0x0400, FILL_PATH = 0x0800,
- FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, DRAW_ROUNDED_RECT = 0x4000,
- DRAW_STATICTEXT = 0x8000, ALL = 0xffff
-};
-
-enum { RasterWarn = 1, RasterDisable = 2 };
-static inline uint rasterFallbacksMask(PaintOperation op)
-{
- uint ret = 0;
-#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
- if (op & QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)
- ret |= RasterWarn;
-#endif
-#ifdef QT_DIRECTFB_DISABLE_RASTERFALLBACKS
- if (op & QT_DIRECTFB_DISABLE_RASTERFALLBACKS)
- ret |= RasterDisable;
-#endif
- static int warningMask = -1;
- static int disableMask = -1;
- if (warningMask < 0) {
- struct {
- const char *name;
- PaintOperation operation;
- } const operations[] = {
- { "DRAW_RECTS", DRAW_RECTS },
- { "DRAW_LINES", DRAW_LINES },
- { "DRAW_IMAGE", DRAW_IMAGE },
- { "DRAW_PIXMAP", DRAW_PIXMAP },
- { "DRAW_TILED_PIXMAP", DRAW_TILED_PIXMAP },
- { "STROKE_PATH", STROKE_PATH },
- { "DRAW_PATH", DRAW_PATH },
- { "DRAW_POINTS", DRAW_POINTS },
- { "DRAW_ELLIPSE", DRAW_ELLIPSE },
- { "DRAW_POLYGON", DRAW_POLYGON },
- { "DRAW_TEXT", DRAW_TEXT },
- { "FILL_PATH", FILL_PATH },
- { "FILL_RECT", FILL_RECT },
- { "DRAW_COLORSPANS", DRAW_COLORSPANS },
- { "DRAW_ROUNDED_RECT", DRAW_ROUNDED_RECT },
- { "ALL", ALL },
- { 0, ALL }
- };
-
- QStringList warning = QString::fromLatin1(qgetenv("QT_DIRECTFB_WARN_ON_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'),
- QString::SkipEmptyParts);
- QStringList disable = QString::fromLatin1(qgetenv("QT_DIRECTFB_DISABLE_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'),
- QString::SkipEmptyParts);
- warningMask = 0;
- disableMask = 0;
- if (!warning.isEmpty() || !disable.isEmpty()) {
- for (int i=0; operations[i].name; ++i) {
- const QString name = QString::fromLatin1(operations[i].name);
- int idx = warning.indexOf(name);
- if (idx != -1) {
- warningMask |= operations[i].operation;
- warning.erase(warning.begin() + idx);
- }
- idx = disable.indexOf(name);
- if (idx != -1) {
- disableMask |= operations[i].operation;
- disable.erase(disable.begin() + idx);
- }
- }
- }
- if (!warning.isEmpty()) {
- qWarning("QDirectFBPaintEngine QT_DIRECTFB_WARN_ON_RASTERFALLBACKS Unknown operation(s): %s",
- qPrintable(warning.join(QLatin1String("|"))));
- }
- if (!disable.isEmpty()) {
- qWarning("QDirectFBPaintEngine QT_DIRECTFB_DISABLE_RASTERFALLBACKS Unknown operation(s): %s",
- qPrintable(disable.join(QLatin1String("|"))));
- }
- }
- if (op & warningMask)
- ret |= RasterWarn;
- if (op & disableMask)
- ret |= RasterDisable;
- return ret;
-}
-
-template <typename device, typename T1, typename T2, typename T3>
-static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
- uint transformationType, bool simplePen,
- uint clipType, uint compositionModeStatus,
- const char *nameOne, const T1 &one,
- const char *nameTwo, const T2 &two,
- const char *nameThree, const T3 &three);
-
-#define RASTERFALLBACK(op, one, two, three) \
- { \
- static const uint rasterFallbacks = rasterFallbacksMask(op); \
- switch (rasterFallbacks) { \
- case 0: break; \
- case RasterWarn: \
- rasterFallbackWarn("Falling back to raster engine for", \
- __FUNCTION__, \
- state()->painter->device(), \
- d_func()->transformationType, \
- d_func()->simplePen, \
- d_func()->clipType, \
- d_func()->compositionModeStatus, \
- #one, one, #two, two, #three, three); \
- break; \
- case RasterDisable|RasterWarn: \
- rasterFallbackWarn("Disabled raster engine operation", \
- __FUNCTION__, \
- state()->painter->device(), \
- d_func()->transformationType, \
- d_func()->simplePen, \
- d_func()->clipType, \
- d_func()->compositionModeStatus, \
- #one, one, #two, two, #three, three); \
- case RasterDisable: \
- return; \
- } \
- }
-
-template <class T>
-static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface);
-template <class T>
-static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface);
-template <class T>
-static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface);
-
-#define CLIPPED_PAINT(operation) { \
- d->unlock(); \
- DFBRegion clipRegion; \
- switch (d->clipType) { \
- case QDirectFBPaintEnginePrivate::NoClip: \
- case QDirectFBPaintEnginePrivate::RectClip: \
- operation; \
- break; \
- case QDirectFBPaintEnginePrivate::RegionClip: { \
- Q_ASSERT(d->clip()); \
- const QVector<QRect> cr = d->clip()->clipRegion.rects(); \
- const int size = cr.size(); \
- for (int i=0; i<size; ++i) { \
- d->currentClip = cr.at(i); \
- clipRegion.x1 = d->currentClip.x(); \
- clipRegion.y1 = d->currentClip.y(); \
- clipRegion.x2 = d->currentClip.right(); \
- clipRegion.y2 = d->currentClip.bottom(); \
- d->surface->SetClip(d->surface, &clipRegion); \
- operation; \
- } \
- d->updateClip(); \
- break; } \
- case QDirectFBPaintEnginePrivate::ComplexClip: \
- case QDirectFBPaintEnginePrivate::ClipUnset: \
- qFatal("CLIPPED_PAINT internal error %d", d->clipType); \
- break; \
- } \
- }
-
-
-QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device)
- : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device)
-{
-}
-
-QDirectFBPaintEngine::~QDirectFBPaintEngine()
-{
-}
-
-bool QDirectFBPaintEngine::begin(QPaintDevice *device)
-{
- Q_D(QDirectFBPaintEngine);
- if (device->devType() == QInternal::CustomRaster) {
- d->dfbDevice = static_cast<QDirectFBPaintDevice*>(device);
- } else if (device->devType() == QInternal::Pixmap) {
- QPixmapData *data = static_cast<QPixmap*>(device)->pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbPixmapData = static_cast<QDirectFBPixmapData*>(data);
- QDirectFBPaintEnginePrivate::unlock(dfbPixmapData);
- d->dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData);
- }
-
- if (d->dfbDevice)
- d->surface = d->dfbDevice->directFBSurface();
-
- if (!d->surface) {
- qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x",
- device->devType());
- }
- d->isPremultiplied = QDirectFBScreen::isPremultiplied(d->dfbDevice->format());
-
- d->prepare(d->dfbDevice);
- gccaps = AllFeatures;
- d->setCompositionMode(state()->composition_mode);
-
- return QRasterPaintEngine::begin(device);
-}
-
-bool QDirectFBPaintEngine::end()
-{
- Q_D(QDirectFBPaintEngine);
- d->unlock();
- d->dfbDevice = 0;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- d->surface->ReleaseSource(d->surface);
-#endif
- d->currentClip = QRect();
- d->surface->SetClip(d->surface, NULL);
- d->surface = 0;
- return QRasterPaintEngine::end();
-}
-
-void QDirectFBPaintEngine::clipEnabledChanged()
-{
- Q_D(QDirectFBPaintEngine);
- QRasterPaintEngine::clipEnabledChanged();
- d->updateClip();
-}
-
-void QDirectFBPaintEngine::penChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setPen(state()->pen);
-
- QRasterPaintEngine::penChanged();
-}
-
-void QDirectFBPaintEngine::opacityChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->opacity = quint8(state()->opacity * 255);
- QRasterPaintEngine::opacityChanged();
-}
-
-void QDirectFBPaintEngine::compositionModeChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setCompositionMode(state()->compositionMode());
- QRasterPaintEngine::compositionModeChanged();
-}
-
-void QDirectFBPaintEngine::renderHintsChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setRenderHints(state()->renderHints);
- QRasterPaintEngine::renderHintsChanged();
-}
-
-void QDirectFBPaintEngine::transformChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setTransform(state()->matrix);
- QRasterPaintEngine::transformChanged();
-}
-
-void QDirectFBPaintEngine::setState(QPainterState *state)
-{
- Q_D(QDirectFBPaintEngine);
- QRasterPaintEngine::setState(state);
- d->setPen(state->pen);
- d->opacity = quint8(state->opacity * 255);
- d->setCompositionMode(state->compositionMode());
- d->setTransform(state->transform());
- d->setRenderHints(state->renderHints);
- if (d->surface)
- d->updateClip();
-}
-
-void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
-{
- Q_D(QDirectFBPaintEngine);
- const bool wasInClip = d->inClip;
- d->inClip = true;
- QRasterPaintEngine::clip(path, op);
- if (!wasInClip) {
- d->inClip = false;
- d->updateClip();
- }
-}
-
-void QDirectFBPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
-{
- Q_D(QDirectFBPaintEngine);
- const bool wasInClip = d->inClip;
- d->inClip = true;
- QRasterPaintEngine::clip(region, op);
- if (!wasInClip) {
- d->inClip = false;
- d->updateClip();
- }
-}
-
-void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
-{
- Q_D(QDirectFBPaintEngine);
- const bool wasInClip = d->inClip;
- d->inClip = true;
- QRasterPaintEngine::clip(rect, op);
- if (!wasInClip) {
- d->inClip = false;
- d->updateClip();
- }
-}
-
-void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
-{
- Q_D(QDirectFBPaintEngine);
- const QPen &pen = state()->pen;
- const QBrush &brush = state()->brush;
- if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen)
- return;
-
- if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
- || !d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !d->isSimpleBrush(brush)
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- if (brush.style() != Qt::NoBrush) {
- d->setDFBColor(brush.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects<QRect>)(rects, rectCount, state()->matrix, d->surface));
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRect>)(rects, rectCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
-{
- Q_D(QDirectFBPaintEngine);
- const QPen &pen = state()->pen;
- const QBrush &brush = state()->brush;
- if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen)
- return;
-
- if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
- || !d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !d->isSimpleBrush(brush)
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- if (brush.style() != Qt::NoBrush) {
- d->setDFBColor(brush.color());
- CLIPPED_PAINT(fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface));
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRectF>)(rects, rectCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
-{
- Q_D(QDirectFBPaintEngine);
-
- const QPen &pen = state()->pen;
- if (!d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawLines(lines, lineCount);
- return;
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLine>)(lines, lineCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
-{
- Q_D(QDirectFBPaintEngine);
-
- const QPen &pen = state()->pen;
- if (!d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawLines(lines, lineCount);
- return;
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLineF>)(lines, lineCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
- const QRectF &sr,
- Qt::ImageConversionFlags flags)
-{
- Q_D(QDirectFBPaintEngine);
- Q_UNUSED(flags);
-
- /* This is hard to read. The way it works is like this:
-
- - If you do not have support for preallocated surfaces and do not use an
- image cache we always fall back to raster engine.
-
- - If it's rotated/sheared/mirrored (negative scale) or we can't
- clip it we fall back to raster engine.
-
- - If we don't cache the image, but we do have support for
- preallocated surfaces we fall back to the raster engine if the
- image is in a format DirectFB can't handle.
-
- - If we do cache the image but don't have support for preallocated
- images and the cost of caching the image (bytes used) is higher
- than the max image cache size we fall back to raster engine.
- */
-
-#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())
-#ifndef QT_DIRECTFB_IMAGECACHE
- || (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN)
-#elif defined QT_NO_DIRECTFB_PREALLOCATED
- || (QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost())
-#endif
- )
-#endif
- {
- RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr);
- d->lock();
- QRasterPaintEngine::drawImage(r, image, sr, flags);
- return;
- }
-#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- bool release;
- IDirectFBSurface *imgSurface = d->getSurface(image, &release);
- uint blitFlags = 0;
- if (image.hasAlphaChannel())
- blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha;
- if (QDirectFBScreen::isPremultiplied(image.format()))
- blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied;
- d->prepareForBlit(blitFlags);
- CLIPPED_PAINT(d->blit(r, imgSurface, sr));
- if (release) {
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- d->surface->ReleaseSource(d->surface);
-#endif
- imgSurface->Release(imgSurface);
- }
-#endif
-}
-
-void QDirectFBPaintEngine::drawImage(const QPointF &p, const QImage &img)
-{
- drawImage(QRectF(p, img.size()), img, img.rect());
-}
-
-void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
- const QRectF &sr)
-{
- Q_D(QDirectFBPaintEngine);
-
- if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
- RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
- d->lock();
- QRasterPaintEngine::drawPixmap(r, pixmap, sr);
- } else {
- QPixmapData *data = pixmap.pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
- if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())) {
- RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
- const QImage *img = dfbData->buffer();
- d->lock();
- QRasterPaintEngine::drawImage(r, *img, sr);
- } else {
- QDirectFBPaintEnginePrivate::unlock(dfbData);
- IDirectFBSurface *s = dfbData->directFBSurface();
- uint blitFlags = 0;
- if (pixmap.hasAlphaChannel())
- blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha;
- if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat()))
- blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied;
-
- d->prepareForBlit(blitFlags);
- CLIPPED_PAINT(d->blit(r, s, sr));
- }
- }
-}
-
-void QDirectFBPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm)
-{
- drawPixmap(QRectF(p, pm.size()), pm, pm.rect());
-}
-
-void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r,
- const QPixmap &pixmap,
- const QPointF &offset)
-{
- Q_D(QDirectFBPaintEngine);
- if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
- RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
- d->lock();
- QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset);
- } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || (!d->supportsStretchBlit() && state()->matrix.isScaling())) {
- RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
- QPixmapData *pixmapData = pixmap.pixmapData();
- Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(pixmapData);
- const QImage *img = dfbData->buffer();
- d->lock();
- QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType);
- data->fromImage(*img, Qt::AutoColor);
- const QPixmap pix(data);
- QRasterPaintEngine::drawTiledPixmap(r, pix, offset);
- } else {
- QTransform transform(state()->matrix);
- CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset, transform));
- }
-}
-
-
-void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
-{
- RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::stroke(path, pen);
-}
-
-void QDirectFBPaintEngine::drawPath(const QPainterPath &path)
-{
- RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPath(path);
-}
-
-void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount)
-{
- RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPoints(points, pointCount);
-}
-
-void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount)
-{
- RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPoints(points, pointCount);
-}
-
-void QDirectFBPaintEngine::drawEllipse(const QRectF &rect)
-{
- RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawEllipse(rect);
-}
-
-void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount,
- PolygonDrawMode mode)
-{
- RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPolygon(points, pointCount, mode);
-}
-
-void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount,
- PolygonDrawMode mode)
-{
- RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPolygon(points, pointCount, mode);
-}
-
-void QDirectFBPaintEngine::drawTextItem(const QPointF &p,
- const QTextItem &textItem)
-{
- RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawTextItem(p, textItem);
-}
-
-void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
-{
- if (brush.style() == Qt::NoBrush)
- return;
- RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::fill(path, brush);
-}
-
-void QDirectFBPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
-{
- RASTERFALLBACK(DRAW_ROUNDED_RECT, rect, xrad, yrad);
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawRoundedRect(rect, xrad, yrad, mode);
-}
-
-void QDirectFBPaintEngine::drawStaticTextItem(QStaticTextItem *item)
-{
- RASTERFALLBACK(DRAW_STATICTEXT, item, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawStaticTextItem(item);
-}
-
-void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
-{
- Q_D(QDirectFBPaintEngine);
- if (brush.style() == Qt::NoBrush)
- return;
- if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) {
- switch (brush.style()) {
- case Qt::SolidPattern: {
- const QColor color = brush.color();
- if (!color.isValid())
- return;
-
- if (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- break;
- }
- d->setDFBColor(color);
- const QRect r = state()->matrix.mapRect(rect).toRect();
- CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()));
- return; }
-
- case Qt::TexturePattern: {
- const QPointF &brushOrigin = state()->brushOrigin;
- const QTransform stateTransform = state()->matrix;
- QTransform transform(stateTransform);
- transform.translate(brushOrigin.x(), brushOrigin.y());
- transform = brush.transform() * transform;
- if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (QDirectFBPaintEnginePrivate::getTransformationType(transform) & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (!d->supportsStretchBlit() && transform.isScaling())) {
- break;
- }
-
- const QPixmap texture = brush.texture();
- if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass)
- break;
-
- CLIPPED_PAINT(d->drawTiledPixmap(stateTransform.mapRect(rect), texture, rect.topLeft() - brushOrigin, transform));
- return; }
- default:
- break;
- }
- }
- RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG());
- d->lock();
- QRasterPaintEngine::fillRect(rect, brush);
-}
-
-void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color)
-{
- if (!color.isValid())
- return;
- Q_D(QDirectFBPaintEngine);
- if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG());
- d->lock();
- QRasterPaintEngine::fillRect(rect, color);
- } else {
- d->setDFBColor(color);
- const QRect r = state()->matrix.mapRect(rect).toRect();
- CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()));
- }
-}
-
-void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length,
- uint const_alpha)
-{
- Q_D(QDirectFBPaintEngine);
- IDirectFBSurface *src = d->surfaceCache->getSurface(buffer, bufsize);
- // ### how does this play with setDFBColor
- src->SetColor(src, 0, 0, 0, const_alpha);
- const DFBRectangle rect = { 0, 0, length, 1 };
- d->surface->Blit(d->surface, src, &rect, x, y);
-}
-
-#ifdef QT_DIRECTFB_IMAGECACHE
-static void cachedImageCleanupHook(qint64 key)
-{
- delete imageCache.take(key);
-}
-void QDirectFBPaintEngine::initImageCache(int size)
-{
- Q_ASSERT(size >= 0);
- imageCache.setMaxCost(size);
- QImagePixmapCleanupHooks::instance()->addImageHook(cachedImageCleanupHook);
-}
-
-#endif // QT_DIRECTFB_IMAGECACHE
-
-// ---- QDirectFBPaintEnginePrivate ----
-
-
-QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p)
- : surface(0), antialiased(false), simplePen(false),
- transformationType(0), opacity(255),
- clipType(ClipUnset), dfbDevice(0),
- compositionModeStatus(0), isPremultiplied(false), inClip(false), q(p)
-{
- fb = QDirectFBScreen::instance()->dfb();
- surfaceCache = new SurfaceCache;
-}
-
-QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate()
-{
- delete surfaceCache;
-}
-
-bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const
-{
- return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased);
-}
-
-void QDirectFBPaintEnginePrivate::lock()
-{
- // We will potentially get a new pointer to the buffer after a
- // lock so we need to call the base implementation of prepare so
- // it updates its rasterBuffer to point to the new buffer address.
- Q_ASSERT(dfbDevice);
- if (dfbDevice->lockSurface(DSLF_READ|DSLF_WRITE)) {
- prepare(dfbDevice);
- }
-}
-
-void QDirectFBPaintEnginePrivate::unlock()
-{
- Q_ASSERT(dfbDevice);
-#ifdef QT_DIRECTFB_SUBSURFACE
- dfbDevice->syncPending = true;
-#else
- QDirectFBPaintEnginePrivate::unlock(dfbDevice);
-#endif
-}
-
-void QDirectFBPaintEnginePrivate::unlock(QDirectFBPaintDevice *device)
-{
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- Q_ASSERT(device);
- device->unlockSurface();
-#else
- Q_UNUSED(device);
-#endif
-}
-
-void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform)
-{
- transformationType = getTransformationType(transform);
- setPen(q->state()->pen);
-}
-
-void QDirectFBPaintEnginePrivate::setPen(const QPen &pen)
-{
- if (pen.style() == Qt::NoPen) {
- simplePen = true;
- } else if (pen.style() == Qt::SolidLine
- && !antialiased
- && pen.brush().style() == Qt::SolidPattern
- && pen.widthF() <= 1.0
- && (transformationType < QTransform::TxScale || pen.isCosmetic())) {
- simplePen = true;
- } else {
- simplePen = false;
- }
-}
-
-void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode)
-{
- if (!surface)
- return;
-
- static const bool forceRasterFallBack = qgetenv("QT_DIRECTFB_FORCE_RASTER").toInt() > 0;
- if (forceRasterFallBack) {
- compositionModeStatus = PorterDuff_None;
- return;
- }
-
- compositionModeStatus = PorterDuff_Supported|PorterDuff_PremultiplyColors|PorterDuff_AlwaysBlend;
- switch (mode) {
- case QPainter::CompositionMode_Clear:
- surface->SetPorterDuff(surface, DSPD_CLEAR);
- break;
- case QPainter::CompositionMode_Source:
- surface->SetPorterDuff(surface, DSPD_SRC);
- compositionModeStatus &= ~PorterDuff_AlwaysBlend;
- if (!isPremultiplied)
- compositionModeStatus &= ~PorterDuff_PremultiplyColors;
- break;
- case QPainter::CompositionMode_SourceOver:
- compositionModeStatus &= ~PorterDuff_AlwaysBlend;
- surface->SetPorterDuff(surface, DSPD_SRC_OVER);
- break;
- case QPainter::CompositionMode_DestinationOver:
- surface->SetPorterDuff(surface, DSPD_DST_OVER);
- break;
- case QPainter::CompositionMode_SourceIn:
- surface->SetPorterDuff(surface, DSPD_SRC_IN);
- if (!isPremultiplied)
- compositionModeStatus &= ~PorterDuff_PremultiplyColors;
- break;
- case QPainter::CompositionMode_DestinationIn:
- surface->SetPorterDuff(surface, DSPD_DST_IN);
- break;
- case QPainter::CompositionMode_SourceOut:
- surface->SetPorterDuff(surface, DSPD_SRC_OUT);
- break;
- case QPainter::CompositionMode_DestinationOut:
- surface->SetPorterDuff(surface, DSPD_DST_OUT);
- break;
- case QPainter::CompositionMode_Destination:
- surface->SetSrcBlendFunction(surface, DSBF_ZERO);
- surface->SetDstBlendFunction(surface, DSBF_ONE);
- break;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case QPainter::CompositionMode_SourceAtop:
- surface->SetPorterDuff(surface, DSPD_SRC_ATOP);
- break;
- case QPainter::CompositionMode_DestinationAtop:
- surface->SetPorterDuff(surface, DSPD_DST_ATOP);
- break;
- case QPainter::CompositionMode_Plus:
- surface->SetPorterDuff(surface, DSPD_ADD);
- break;
- case QPainter::CompositionMode_Xor:
- surface->SetPorterDuff(surface, DSPD_XOR);
- break;
-#endif
- default:
- compositionModeStatus = PorterDuff_None;
- break;
- }
-}
-
-void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
-{
- const bool old = antialiased;
- antialiased = bool(hints & QPainter::Antialiasing);
- if (old != antialiased) {
- setPen(q->state()->pen);
- }
-}
-
-void QDirectFBPaintEnginePrivate::prepareForBlit(uint flags)
-{
- DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX;
- if (flags & Premultiplied)
- blittingFlags |= DSBLIT_SRC_PREMULTIPLY;
- if (flags & HasAlpha)
- blittingFlags |= DSBLIT_BLEND_ALPHACHANNEL;
- if (opacity != 255) {
- blittingFlags |= DSBLIT_BLEND_COLORALPHA;
- surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
- }
-
- surface->SetBlittingFlags(surface, blittingFlags);
-}
-
-static inline uint ALPHA_MUL(uint x, uint a)
-{
- uint t = x * a;
- t = ((t + (t >> 8) + 0x80) >> 8) & 0xff;
- return t;
-}
-
-void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color)
-{
- Q_ASSERT(surface);
- Q_ASSERT(compositionModeStatus & PorterDuff_Supported);
- const quint8 alpha = (opacity == 255 ?
- color.alpha() : ALPHA_MUL(color.alpha(), opacity));
- QColor col;
- if (compositionModeStatus & PorterDuff_PremultiplyColors) {
- col = QColor(ALPHA_MUL(color.red(), alpha),
- ALPHA_MUL(color.green(), alpha),
- ALPHA_MUL(color.blue(), alpha),
- alpha);
- } else {
- col = QColor(color.red(), color.green(), color.blue(), alpha);
- }
- surface->SetColor(surface, col.red(), col.green(), col.blue(), col.alpha());
- surface->SetDrawingFlags(surface, alpha == 255 && !(compositionModeStatus & PorterDuff_AlwaysBlend) ? DSDRAW_NOFX : DSDRAW_BLEND);
-}
-
-IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release)
-{
-#ifdef QT_NO_DIRECTFB_IMAGECACHE
- *release = true;
- return QDirectFBScreen::instance()->createDFBSurface(img, img.format(), QDirectFBScreen::DontTrackSurface);
-#else
- const qint64 key = img.cacheKey();
- *release = false;
- if (imageCache.contains(key)) {
- return imageCache[key]->surface;
- }
-
- const int cost = cacheCost(img);
- const bool cache = cost <= imageCache.maxCost();
- QDirectFBScreen *screen = QDirectFBScreen::instance();
- const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img)
- ? screen->alphaPixmapFormat() : screen->pixelFormat());
-
- IDirectFBSurface *surface = screen->createDFBSurface(img, format,
- cache
- ? QDirectFBScreen::TrackSurface
- : QDirectFBScreen::DontTrackSurface);
- if (cache) {
- CachedImage *cachedImage = new CachedImage;
- const_cast<QImage&>(img).data_ptr()->is_cached = true;
- cachedImage->surface = surface;
- imageCache.insert(key, cachedImage, cost);
- } else {
- *release = true;
- }
- return surface;
-#endif
-}
-
-
-void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src)
-{
- const QRect sr = src.toRect();
- const QRect dr = q->state()->matrix.mapRect(dest).toRect();
- if (dr.isEmpty())
- return;
- const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() };
- DFBResult result;
-
- if (dr.size() == sr.size()) {
- result = surface->Blit(surface, s, &sRect, dr.x(), dr.y());
- } else {
- Q_ASSERT(supportsStretchBlit());
- const DFBRectangle dRect = { dr.x(), dr.y(), dr.width(), dr.height() };
- result = surface->StretchBlit(surface, s, &sRect, &dRect);
- }
- if (result != DFB_OK)
- DirectFBError("QDirectFBPaintEngine::drawPixmap()", result);
-}
-
-static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset)
-{
- qreal pos = rect_pos - offset;
- while (pos > rect_pos)
- pos -= pixmapSize;
- while (pos + pixmapSize < rect_pos)
- pos += pixmapSize;
- return pos;
-}
-
-void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap,
- const QPointF &off, const QTransform &pixmapTransform)
-{
- const QTransform &transform = q->state()->matrix;
- Q_ASSERT(!(getTransformationType(transform) & Matrix_BlitsUnsupported) &&
- !(getTransformationType(pixmapTransform) & Matrix_BlitsUnsupported));
- const QRect destinationRect = transform.mapRect(dest).toRect().normalized();
- QRect newClip = destinationRect;
- if (!currentClip.isEmpty())
- newClip &= currentClip;
-
- if (newClip.isNull())
- return;
-
- const DFBRegion clip = {
- newClip.x(),
- newClip.y(),
- newClip.right(),
- newClip.bottom()
- };
- surface->SetClip(surface, &clip);
-
- QPointF offset = pixmapTransform.inverted().map(off);
- Q_ASSERT(transform.type() <= QTransform::TxScale);
- QPixmapData *data = pixmap.pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
- IDirectFBSurface *sourceSurface = dfbData->directFBSurface();
- uint blitFlags = 0;
- if (dfbData->hasAlphaChannel())
- blitFlags |= HasAlpha;
- if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat()))
- blitFlags |= Premultiplied;
- prepareForBlit(blitFlags);
- QDirectFBPaintEnginePrivate::unlock(dfbData);
- const QSize pixmapSize = dfbData->size();
- if (transform.isScaling() || pixmapTransform.isScaling()) {
- Q_ASSERT(supportsStretchBlit());
- Q_ASSERT(qMin(transform.m11(), transform.m22()) >= 0);
- offset.rx() *= transform.m11();
- offset.ry() *= transform.m22();
-
- const QSizeF mappedSize(pixmapSize.width() * pixmapTransform.m11(), pixmapSize.height() * pixmapTransform.m22());
- qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y());
- const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x());
- while (y <= destinationRect.bottom()) {
- qreal x = startX;
- while (x <= destinationRect.right()) {
- const DFBRectangle destination = { qRound(x), qRound(y), mappedSize.width(), mappedSize.height() };
- surface->StretchBlit(surface, sourceSurface, 0, &destination);
- x += mappedSize.width();
- }
- y += mappedSize.height();
- }
- } else {
- qreal y = fixCoord(destinationRect.y(), pixmapSize.height(), offset.y());
- const qreal startX = fixCoord(destinationRect.x(), pixmapSize.width(), offset.x());
- int horizontal = qMax(1, destinationRect.width() / pixmapSize.width()) + 1;
- if (startX != destinationRect.x())
- ++horizontal;
- int vertical = qMax(1, destinationRect.height() / pixmapSize.height()) + 1;
- if (y != destinationRect.y())
- ++vertical;
-
- const int maxCount = (vertical * horizontal);
- QVarLengthArray<DFBRectangle, 16> sourceRects(maxCount);
- QVarLengthArray<DFBPoint, 16> points(maxCount);
-
- int i = 0;
- while (y <= destinationRect.bottom()) {
- Q_ASSERT(i < maxCount);
- qreal x = startX;
- while (x <= destinationRect.right()) {
- points[i].x = qRound(x);
- points[i].y = qRound(y);
- sourceRects[i].x = 0;
- sourceRects[i].y = 0;
- sourceRects[i].w = int(pixmapSize.width());
- sourceRects[i].h = int(pixmapSize.height());
- x += pixmapSize.width();
- ++i;
- }
- y += pixmapSize.height();
- }
- surface->BatchBlit(surface, sourceSurface, sourceRects.constData(), points.constData(), i);
- }
-
- if (currentClip.isEmpty()) {
- surface->SetClip(surface, 0);
- } else {
- const DFBRegion clip = {
- currentClip.x(),
- currentClip.y(),
- currentClip.right(),
- currentClip.bottom()
- };
- surface->SetClip(surface, &clip);
- }
-}
-
-void QDirectFBPaintEnginePrivate::updateClip()
-{
- Q_ASSERT(surface);
- currentClip = QRect();
- const QClipData *clipData = clip();
- if (!clipData || !clipData->enabled) {
- surface->SetClip(surface, NULL);
- clipType = NoClip;
- } else if (clipData->hasRectClip) {
- const DFBRegion r = {
- clipData->clipRect.x(),
- clipData->clipRect.y(),
- clipData->clipRect.right(),
- clipData->clipRect.bottom()
- };
- surface->SetClip(surface, &r);
- currentClip = clipData->clipRect.normalized();
- // ### is this guaranteed to always be normalized?
- clipType = RectClip;
- } else if (clipData->hasRegionClip) {
- clipType = RegionClip;
- } else {
- clipType = ComplexClip;
- }
-}
-
-bool QDirectFBPaintEnginePrivate::supportsStretchBlit() const
-{
-#ifdef QT_DIRECTFB_STRETCHBLIT
- return !(q->state()->renderHints & QPainter::SmoothPixmapTransform);
-#else
- return false;
-#endif
-}
-
-
-void QDirectFBPaintEnginePrivate::systemStateChanged()
-{
- QRasterPaintEnginePrivate::systemStateChanged();
- updateClip();
-}
-
-IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size)
-{
- if (buffer == buf && bufsize == size)
- return surface;
-
- clear();
-
- const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size);
- surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface, 0);
- if (!surface)
- qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface");
-
- buffer = const_cast<uint*>(buf);
- bufsize = size;
-
- return surface;
-}
-
-void SurfaceCache::clear()
-{
- if (surface && QDirectFBScreen::instance())
- QDirectFBScreen::instance()->releaseDFBSurface(surface);
- surface = 0;
- buffer = 0;
- bufsize = 0;
-}
-
-
-static inline QRect mapRect(const QTransform &transform, const QRect &rect) { return transform.mapRect(rect); }
-static inline QRect mapRect(const QTransform &transform, const QRectF &rect) { return transform.mapRect(rect).toRect(); }
-static inline QLine map(const QTransform &transform, const QLine &line) { return transform.map(line); }
-static inline QLine map(const QTransform &transform, const QLineF &line) { return transform.map(line).toLine(); }
-template <class T>
-static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface)
-{
- if (n == 1) {
- const QLine l = map(transform, lines[0]);
- surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2());
- } else {
- QVarLengthArray<DFBRegion, 32> lineArray(n);
- for (int i=0; i<n; ++i) {
- const QLine l = map(transform, lines[i]);
- lineArray[i].x1 = l.x1();
- lineArray[i].y1 = l.y1();
- lineArray[i].x2 = l.x2();
- lineArray[i].y2 = l.y2();
- }
- surface->DrawLines(surface, lineArray.constData(), n);
- }
-}
-
-template <class T>
-static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
-{
- if (n == 1) {
- const QRect r = mapRect(transform, rects[0]);
- surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height());
- } else {
- QVarLengthArray<DFBRectangle, 32> rectArray(n);
- for (int i=0; i<n; ++i) {
- const QRect r = mapRect(transform, rects[i]);
- rectArray[i].x = r.x();
- rectArray[i].y = r.y();
- rectArray[i].w = r.width();
- rectArray[i].h = r.height();
- }
- surface->FillRectangles(surface, rectArray.constData(), n);
- }
-}
-
-template <class T>
-static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
-{
- for (int i=0; i<n; ++i) {
- const QRect r = mapRect(transform, rects[i]);
- surface->DrawRectangle(surface, r.x(), r.y(), r.width(), r.height());
- }
-}
-
-template <typename T> inline const T *ptr(const T &t) { return &t; }
-template <> inline const bool* ptr<bool>(const bool &) { return 0; }
-template <typename device, typename T1, typename T2, typename T3>
-static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
- uint transformationType, bool simplePen,
- uint clipType, uint compositionModeStatus,
- const char *nameOne, const T1 &one,
- const char *nameTwo, const T2 &two,
- const char *nameThree, const T3 &three)
-{
- QString out;
- QDebug dbg(&out);
- dbg << msg << (QByteArray(func) + "()") << "painting on";
- if (dev->devType() == QInternal::Widget) {
- dbg << static_cast<const QWidget*>(dev);
- } else {
- dbg << dev << "of type" << dev->devType();
- }
-
- dbg << QString::fromLatin1("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0'))
- << "simplePen" << simplePen
- << "clipType" << clipType
- << "compositionModeStatus" << compositionModeStatus;
-
- const T1 *t1 = ptr(one);
- const T2 *t2 = ptr(two);
- const T3 *t3 = ptr(three);
-
- if (t1) {
- dbg << nameOne << *t1;
- if (t2) {
- dbg << nameTwo << *t2;
- if (t3) {
- dbg << nameThree << *t3;
- }
- }
- }
- qWarning("%s", qPrintable(out));
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
deleted file mode 100644
index a3217d0f32..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAINTENGINE_DIRECTFB_P_H
-#define QPAINTENGINE_DIRECTFB_P_H
-
-#include <QtGui/qpaintengine.h>
-#include <private/qpaintengine_raster_p.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBPaintEnginePrivate;
-
-class QDirectFBPaintEngine : public QRasterPaintEngine
-{
- Q_DECLARE_PRIVATE(QDirectFBPaintEngine)
-public:
- QDirectFBPaintEngine(QPaintDevice *device);
- virtual ~QDirectFBPaintEngine();
-
- virtual bool begin(QPaintDevice *device);
- virtual bool end();
-
- virtual void drawRects(const QRect *rects, int rectCount);
- virtual void drawRects(const QRectF *rects, int rectCount);
-
- virtual void fillRect(const QRectF &r, const QBrush &brush);
- virtual void fillRect(const QRectF &r, const QColor &color);
-
- virtual void drawLines(const QLine *line, int lineCount);
- virtual void drawLines(const QLineF *line, int lineCount);
-
- virtual void drawImage(const QPointF &p, const QImage &img);
- virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
- Qt::ImageConversionFlags falgs = Qt::AutoColor);
-
- virtual void drawPixmap(const QPointF &p, const QPixmap &pm);
- virtual void drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr);
- virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr);
-
- virtual void drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length, uint const_alpha);
-
- virtual void stroke(const QVectorPath &path, const QPen &pen);
- virtual void drawPath(const QPainterPath &path);
- virtual void drawPoints(const QPointF *points, int pointCount);
- virtual void drawPoints(const QPoint *points, int pointCount);
- virtual void drawEllipse(const QRectF &rect);
- virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
- virtual void drawTextItem(const QPointF &p, const QTextItem &textItem);
- virtual void fill(const QVectorPath &path, const QBrush &brush);
- virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
-
- virtual void clipEnabledChanged();
- virtual void penChanged();
- virtual void opacityChanged();
- virtual void compositionModeChanged();
- virtual void renderHintsChanged();
- virtual void transformChanged();
-
- virtual void setState(QPainterState *state);
-
- virtual void clip(const QVectorPath &path, Qt::ClipOperation op);
- virtual void clip(const QRegion &region, Qt::ClipOperation op);
- virtual void clip(const QRect &rect, Qt::ClipOperation op);
-
- virtual void drawStaticTextItem(QStaticTextItem *item);
-
- static void initImageCache(int size);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-
-#endif // QPAINTENGINE_DIRECTFB_P_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
deleted file mode 100644
index 5259a93698..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ /dev/null
@@ -1,588 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbpixmap.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbscreen.h"
-#include "qdirectfbpaintengine.h"
-
-#include <QtGui/qbitmap.h>
-#include <QtCore/qfile.h>
-#include <directfb.h>
-
-
-QT_BEGIN_NAMESPACE
-
-static int global_ser_no = 0;
-
-QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType)
- : QPixmapData(pixelType, DirectFBClass), QDirectFBPaintDevice(screen),
- alpha(false)
-{
- setSerialNumber(0);
-}
-
-QDirectFBPixmapData::~QDirectFBPixmapData()
-{
-}
-
-void QDirectFBPixmapData::resize(int width, int height)
-{
- if (width <= 0 || height <= 0) {
- invalidate();
- return;
- }
-
- imageFormat = screen->pixelFormat();
- dfbSurface = screen->createDFBSurface(QSize(width, height),
- imageFormat,
- QDirectFBScreen::TrackSurface);
- d = QDirectFBScreen::depth(imageFormat);
- alpha = false;
- if (!dfbSurface) {
- invalidate();
- qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface");
- return;
- }
-
- w = width;
- h = height;
- is_null = (w <= 0 || h <= 0);
- setSerialNumber(++global_ser_no);
-}
-
-#ifdef QT_DIRECTFB_OPAQUE_DETECTION
-// mostly duplicated from qimage.cpp (QImageData::checkForAlphaPixels)
-static bool checkForAlphaPixels(const QImage &img)
-{
- const uchar *bits = img.bits();
- const int bytes_per_line = img.bytesPerLine();
- const uchar *end_bits = bits + bytes_per_line;
- const int width = img.width();
- const int height = img.height();
- switch (img.format()) {
- case QImage::Format_Indexed8:
- return img.hasAlphaChannel();
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- for (int y=0; y<height; ++y) {
- for (int x=0; x<width; ++x) {
- if ((((uint *)bits)[x] & 0xff000000) != 0xff000000) {
- return true;
- }
- }
- bits += bytes_per_line;
- }
- break;
-
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- for (int y=0; y<height; ++y) {
- while (bits < end_bits) {
- if (bits[0] != 0) {
- return true;
- }
- bits += 3;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
- }
- break;
-
- case QImage::Format_ARGB6666_Premultiplied:
- for (int y=0; y<height; ++y) {
- while (bits < end_bits) {
- if ((bits[0] & 0xfc) != 0) {
- return true;
- }
- bits += 3;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
- }
- break;
-
- case QImage::Format_ARGB4444_Premultiplied:
- for (int y=0; y<height; ++y) {
- while (bits < end_bits) {
- if ((bits[0] & 0xf0) != 0) {
- return true;
- }
- bits += 2;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
- }
- break;
-
- default:
- break;
- }
-
- return false;
-}
-#endif // QT_DIRECTFB_OPAQUE_DETECTION
-
-bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img, Qt::ImageConversionFlags flags)
-{
- if (img.depth() == 1)
- return true;
-#ifdef QT_DIRECTFB_OPAQUE_DETECTION
- return ((flags & Qt::NoOpaqueDetection) ? img.hasAlphaChannel() : checkForAlphaPixels(img));
-#else
- Q_UNUSED(flags);
- return img.hasAlphaChannel();
-#endif
-}
-
-#ifdef QT_DIRECTFB_IMAGEPROVIDER
-bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- if (!QFile::exists(filename))
- return false;
- if (flags == Qt::AutoColor) {
- if (filename.startsWith(QLatin1Char(':'))) { // resource
- QFile file(filename);
- if (!file.open(QIODevice::ReadOnly))
- return false;
- const QByteArray data = file.readAll();
- file.close();
- return fromData(reinterpret_cast<const uchar*>(data.constData()), data.size(), format, flags);
- } else {
- DFBDataBufferDescription description;
- description.flags = DBDESC_FILE;
- const QByteArray fileNameData = filename.toLocal8Bit();
- description.file = fileNameData.constData();
- if (fromDataBufferDescription(description)) {
- return true;
- }
- // fall back to Qt
- }
- }
- return QPixmapData::fromFile(filename, format, flags);
-}
-
-bool QDirectFBPixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- if (flags == Qt::AutoColor) {
- DFBDataBufferDescription description;
- description.flags = DBDESC_MEMORY;
- description.memory.data = buffer;
- description.memory.length = len;
- if (fromDataBufferDescription(description))
- return true;
- // fall back to Qt
- }
- return QPixmapData::fromData(buffer, len, format, flags);
-}
-
-template <typename T> struct QDirectFBInterfaceCleanupHandler
-{
- static void cleanup(T *t) { if (t) t->Release(t); }
-};
-
-template <typename T>
-class QDirectFBPointer : public QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >
-{
-public:
- QDirectFBPointer(T *t = 0)
- : QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >(t)
- {}
-};
-
-bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescription &dataBufferDescription)
-{
- IDirectFB *dfb = screen->dfb();
- Q_ASSERT(dfb);
- DFBResult result = DFB_OK;
- IDirectFBDataBuffer *dataBufferPtr;
- if ((result = dfb->CreateDataBuffer(dfb, &dataBufferDescription, &dataBufferPtr)) != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromDataBufferDescription()", result);
- return false;
- }
- QDirectFBPointer<IDirectFBDataBuffer> dataBuffer(dataBufferPtr);
-
- IDirectFBImageProvider *providerPtr;
- if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK)
- return false;
-
- QDirectFBPointer<IDirectFBImageProvider> provider(providerPtr);
-
- DFBImageDescription imageDescription;
- result = provider->GetImageDescription(provider.data(), &imageDescription);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't get image description", result);
- return false;
- }
-
- if (imageDescription.caps & DICAPS_COLORKEY) {
- return false;
- }
-
- DFBSurfaceDescription surfaceDescription;
- if ((result = provider->GetSurfaceDescription(provider.data(), &surfaceDescription)) != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't get surface description", result);
- return false;
- }
-
- alpha = imageDescription.caps & DICAPS_ALPHACHANNEL;
- imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
-
- dfbSurface = screen->createDFBSurface(QSize(surfaceDescription.width, surfaceDescription.height),
- imageFormat, QDirectFBScreen::TrackSurface);
-
- result = provider->RenderTo(provider.data(), dfbSurface, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't render to surface", result);
- return false;
- }
-
- w = surfaceDescription.width;
- h = surfaceDescription.height;
- is_null = (w <= 0 || h <= 0);
- d = QDirectFBScreen::depth(imageFormat);
- setSerialNumber(++global_ser_no);
-
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- screen->setDirectFBImageProvider(providerPtr);
- provider.take();
-#endif
-
- return true;
-}
-
-#endif
-
-void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags)
-{
- alpha = QDirectFBPixmapData::hasAlphaChannel(img, flags);
- imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
-
- QImage image;
- if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) {
- image = img.convertToFormat(imageFormat, flags);
- flags = Qt::AutoColor;
- } else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) {
- image = img.convertToFormat(imageFormat, flags);
- } else if (img.format() != imageFormat) {
- image = img.convertToFormat(imageFormat, flags);
- } else {
- image = img;
- }
-
- dfbSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::NoPreallocated | QDirectFBScreen::TrackSurface);
- if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::fromImage()");
- invalidate();
- return;
- }
-
- w = image.width();
- h = image.height();
- is_null = (w <= 0 || h <= 0);
- d = QDirectFBScreen::depth(imageFormat);
- setSerialNumber(++global_ser_no);
-#ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION
- Q_UNUSED(flags);
-#endif
-}
-
-void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->classId() != DirectFBClass) {
- QPixmapData::copy(data, rect);
- return;
- }
-
- const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data);
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- if (otherData->lockFlags()) {
- const_cast<QDirectFBPixmapData*>(otherData)->unlockSurface();
- }
-#endif
- IDirectFBSurface *src = otherData->directFBSurface();
- alpha = data->hasAlphaChannel();
- imageFormat = (alpha
- ? QDirectFBScreen::instance()->alphaPixmapFormat()
- : QDirectFBScreen::instance()->pixelFormat());
-
-
- dfbSurface = screen->createDFBSurface(rect.size(), imageFormat,
- QDirectFBScreen::TrackSurface);
- if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::copy()");
- invalidate();
- return;
- }
-
- if (alpha) {
- dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
- } else {
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- }
- const DFBRectangle blitRect = { rect.x(), rect.y(),
- rect.width(), rect.height() };
- w = rect.width();
- h = rect.height();
- d = otherData->d;
- is_null = (w <= 0 || h <= 0);
- unlockSurface();
- DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0);
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- dfbSurface->ReleaseSource(dfbSurface);
-#endif
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::copy()", result);
- invalidate();
- return;
- }
-
- setSerialNumber(++global_ser_no);
-}
-
-static inline bool isOpaqueFormat(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_RGB32:
- case QImage::Format_RGB16:
- case QImage::Format_RGB666:
- case QImage::Format_RGB555:
- case QImage::Format_RGB888:
- case QImage::Format_RGB444:
- return true;
- default:
- break;
- }
- return false;
-}
-
-void QDirectFBPixmapData::fill(const QColor &color)
-{
- if (!serialNumber())
- return;
-
- Q_ASSERT(dfbSurface);
-
- alpha |= (color.alpha() < 255);
-
- if (alpha && isOpaqueFormat(imageFormat)) {
- QSize size;
- dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight());
- screen->releaseDFBSurface(dfbSurface);
- imageFormat = screen->alphaPixmapFormat();
- d = QDirectFBScreen::depth(imageFormat);
- dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface);
- setSerialNumber(++global_ser_no);
- if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::fill()");
- invalidate();
- return;
- }
- }
-
- dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), color.alpha());
-}
-
-QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
- Qt::TransformationMode mode) const
-{
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- if (lockFlags())
- that->unlockSurface();
-#endif
-
- if (!dfbSurface || transform.type() != QTransform::TxScale
- || mode != Qt::FastTransformation)
- {
- const QImage *image = that->buffer();
- Q_ASSERT(image);
- const QImage transformed = image->transformed(transform, mode);
- QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
- data->fromImage(transformed, Qt::AutoColor);
- return QPixmap(data);
- }
-
- const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
- if (size.isEmpty())
- return QPixmap();
-
- QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
- data->setSerialNumber(++global_ser_no);
- DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
- data->alpha = alpha;
- if (alpha) {
- flags = DSBLIT_BLEND_ALPHACHANNEL;
- }
- data->dfbSurface = screen->createDFBSurface(size,
- imageFormat,
- QDirectFBScreen::TrackSurface);
- if (flags & DSBLIT_BLEND_ALPHACHANNEL) {
- data->dfbSurface->Clear(data->dfbSurface, 0, 0, 0, 0);
- }
- data->dfbSurface->SetBlittingFlags(data->dfbSurface, flags);
-
- const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
- data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect);
- data->w = size.width();
- data->h = size.height();
- data->is_null = (data->w <= 0 || data->h <= 0);
-
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- data->dfbSurface->ReleaseSource(data->dfbSurface);
-#endif
- return QPixmap(data);
-}
-
-QImage QDirectFBPixmapData::toImage() const
-{
- if (!dfbSurface)
- return QImage();
-
-#if 0
- // In later versions of DirectFB one can set a flag to tell
- // DirectFB not to move the surface to videomemory. When that
- // happens we can use this (hopefully faster) codepath
-#ifndef QT_NO_DIRECTFB_PREALLOCATED
- QImage ret(w, h, QDirectFBScreen::getImageFormat(dfbSurface));
- if (IDirectFBSurface *imgSurface = screen->createDFBSurface(ret, QDirectFBScreen::DontTrackSurface)) {
- if (hasAlphaChannel()) {
- imgSurface->SetBlittingFlags(imgSurface, DSBLIT_BLEND_ALPHACHANNEL);
- imgSurface->Clear(imgSurface, 0, 0, 0, 0);
- } else {
- imgSurface->SetBlittingFlags(imgSurface, DSBLIT_NOFX);
- }
- imgSurface->Blit(imgSurface, dfbSurface, 0, 0, 0);
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- imgSurface->ReleaseSource(imgSurface);
-#endif
- imgSurface->Release(imgSurface);
- return ret;
- }
-#endif
-#endif
-
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
- const QImage *img = that->buffer();
- return img->copy();
-}
-
-/* This is QPixmapData::paintEngine(), not QPaintDevice::paintEngine() */
-
-QPaintEngine *QDirectFBPixmapData::paintEngine() const
-{
- if (!engine) {
- // QDirectFBPixmapData is also a QCustomRasterPaintDevice, so pass
- // that to the paint engine:
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
- that->engine = new QDirectFBPaintEngine(that);
- }
- return engine;
-}
-
-QImage *QDirectFBPixmapData::buffer()
-{
- if (!lockFlgs) {
- lockSurface(DSLF_READ|DSLF_WRITE);
- }
- Q_ASSERT(lockFlgs);
- Q_ASSERT(!lockedImage.isNull());
- return &lockedImage;
-}
-
-
-bool QDirectFBPixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- if (!dfbSurface) {
- return false;
- }
- unlockSurface();
- DFBResult result = dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::scroll", result);
- return false;
- }
- result = dfbSurface->SetPorterDuff(dfbSurface, DSPD_NONE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::scroll", result);
- return false;
- }
-
- const DFBRectangle source = { rect.x(), rect.y(), rect.width(), rect.height() };
- result = dfbSurface->Blit(dfbSurface, dfbSurface, &source, source.x + dx, source.y + dy);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::scroll", result);
- return false;
- }
-
- return true;
-}
-
-void QDirectFBPixmapData::invalidate()
-{
- if (dfbSurface) {
- screen->releaseDFBSurface(dfbSurface);
- dfbSurface = 0;
- }
- setSerialNumber(0);
- alpha = false;
- d = w = h = 0;
- is_null = true;
- imageFormat = QImage::Format_Invalid;
-}
-
-Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_pixmap(const QPixmap &pixmap)
-{
- const QPixmapData *data = pixmap.pixmapData();
- if (!data || data->classId() != QPixmapData::DirectFBClass)
- return 0;
- const QDirectFBPixmapData *dfbData = static_cast<const QDirectFBPixmapData*>(data);
- return dfbData->directFBSurface();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
deleted file mode 100644
index bc94b42638..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBPIXMAP_H
-#define QDIRECTFBPIXMAP_H
-
-#include <qglobal.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include <QtGui/private/qpixmapdata_p.h>
-#include <QtGui/private/qpaintengine_raster_p.h>
-#include "qdirectfbpaintdevice.h"
-#include <directfb.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBPaintEngine;
-
-class QDirectFBPixmapData : public QPixmapData, public QDirectFBPaintDevice
-{
-public:
- QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType);
- ~QDirectFBPixmapData();
-
- // Re-implemented from QPixmapData:
- virtual void resize(int width, int height);
- virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
-#ifdef QT_DIRECTFB_IMAGEPROVIDER
- virtual bool fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags);
- virtual bool fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags);
-#endif
- virtual void copy(const QPixmapData *data, const QRect &rect);
- virtual void fill(const QColor &color);
- virtual QPixmap transformed(const QTransform &matrix,
- Qt::TransformationMode mode) const;
- virtual QImage toImage() const;
- virtual QPaintEngine *paintEngine() const;
- virtual QImage *buffer();
- virtual bool scroll(int dx, int dy, const QRect &rect);
- // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice
- virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); }
-
- inline QImage::Format pixelFormat() const { return imageFormat; }
- inline bool hasAlphaChannel() const { return alpha; }
- static bool hasAlphaChannel(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor);
-private:
-#ifdef QT_DIRECTFB_IMAGEPROVIDER
- bool fromDataBufferDescription(const DFBDataBufferDescription &dataBuffer);
-#endif
- void invalidate();
- bool alpha;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-
-#endif // QDIRECTFBPIXMAP_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
deleted file mode 100644
index 7b1538bb49..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ /dev/null
@@ -1,1819 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbscreen.h"
-#include "qdirectfbwindowsurface.h"
-#include "qdirectfbpixmap.h"
-#include "qdirectfbmouse.h"
-#include "qdirectfbkeyboard.h"
-#include <QtGui/qwsdisplay_qws.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qwindowsystem_qws.h>
-#include <QtGui/private/qgraphicssystem_qws_p.h>
-#include <QtGui/private/qwssignalhandler_p.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qrect.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_NAMESPACE
-
-class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem
-{
- Q_OBJECT
-public:
- QDirectFBScreenPrivate(QDirectFBScreen *qptr);
- ~QDirectFBScreenPrivate();
-
- void setFlipFlags(const QStringList &args);
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
-public slots:
-#ifdef QT_DIRECTFB_WM
- void onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event);
-#endif
-public:
- IDirectFB *dfb;
- DFBSurfaceFlipFlags flipFlags;
- QDirectFBScreen::DirectFBFlags directFBFlags;
- QImage::Format alphaPixmapFormat;
- IDirectFBScreen *dfbScreen;
-#ifdef QT_NO_DIRECTFB_WM
- IDirectFBSurface *primarySurface;
- QColor backgroundColor;
-#endif
-#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer *dfbLayer;
-#endif
- QSet<IDirectFBSurface*> allocatedSurfaces;
-
-#ifndef QT_NO_DIRECTFB_MOUSE
- QDirectFBMouseHandler *mouse;
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- QDirectFBKeyboardHandler *keyboard;
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- IDirectFBImageProvider *imageProvider;
-#endif
- IDirectFBSurface *cursorSurface;
- qint64 cursorImageKey;
-
- QDirectFBScreen *q;
- static QDirectFBScreen *instance;
-};
-
-QDirectFBScreen *QDirectFBScreenPrivate::instance = 0;
-
-QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
- : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE),
- directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid),
- dfbScreen(0)
-#ifdef QT_NO_DIRECTFB_WM
- , primarySurface(0)
-#endif
-#ifndef QT_NO_DIRECTFB_LAYER
- , dfbLayer(0)
-#endif
-#ifndef QT_NO_DIRECTFB_MOUSE
- , mouse(0)
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- , keyboard(0)
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- , imageProvider(0)
-#endif
- , cursorSurface(0)
- , cursorImageKey(0)
- , q(qptr)
-{
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-#ifdef QT_DIRECTFB_WM
- connect(QWSServer::instance(), SIGNAL(windowEvent(QWSWindow*,QWSServer::WindowEvent)),
- this, SLOT(onWindowEvent(QWSWindow*,QWSServer::WindowEvent)));
-#endif
-}
-
-QDirectFBScreenPrivate::~QDirectFBScreenPrivate()
-{
-#ifndef QT_NO_DIRECTFB_MOUSE
- delete mouse;
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- delete keyboard;
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- if (imageProvider)
- imageProvider->Release(imageProvider);
-#endif
-
- for (QSet<IDirectFBSurface*>::const_iterator it = allocatedSurfaces.begin(); it != allocatedSurfaces.end(); ++it) {
- (*it)->Release(*it);
- }
-
-#ifdef QT_NO_DIRECTFB_WM
- if (primarySurface)
- primarySurface->Release(primarySurface);
-#endif
-
-#ifndef QT_NO_DIRECTFB_LAYER
- if (dfbLayer)
- dfbLayer->Release(dfbLayer);
-#endif
-
- if (dfbScreen)
- dfbScreen->Release(dfbScreen);
-
- if (dfb)
- dfb->Release(dfb);
-}
-
-IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options, DFBResult *resultPtr)
-{
- if (image.isNull()) // assert?
- return 0;
-
- if (QDirectFBScreen::getSurfacePixelFormat(format) == DSPF_UNKNOWN) {
- format = QDirectFBPixmapData::hasAlphaChannel(image) ? d_ptr->alphaPixmapFormat : pixelFormat();
- }
- if (image.format() != format) {
- return createDFBSurface(image.convertToFormat(format), format, options | NoPreallocated, resultPtr);
- }
-
- DFBSurfaceDescription description;
- memset(&description, 0, sizeof(DFBSurfaceDescription));
- description.width = image.width();
- description.height = image.height();
- description.flags = DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT;
- initSurfaceDescriptionPixelFormat(&description, format);
- bool doMemCopy = true;
-#ifdef QT_DIRECTFB_PREALLOCATED
- if (!(options & NoPreallocated)) {
- doMemCopy = false;
- description.flags |= DSDESC_PREALLOCATED;
- description.preallocated[0].data = const_cast<uchar*>(image.bits());
- description.preallocated[0].pitch = image.bytesPerLine();
- description.preallocated[1].data = 0;
- description.preallocated[1].pitch = 0;
- }
-#endif
- DFBResult result;
- IDirectFBSurface *surface = createDFBSurface(description, options, &result);
- if (resultPtr)
- *resultPtr = result;
- if (!surface) {
- DirectFBError("Couldn't create surface createDFBSurface(QImage, QImage::Format, SurfaceCreationOptions)", result);
- return 0;
- }
- if (doMemCopy) {
- int bplDFB;
- uchar *mem = QDirectFBScreen::lockSurface(surface, DSLF_WRITE, &bplDFB);
- if (mem) {
- const int height = image.height();
- const int bplQt = image.bytesPerLine();
- if (bplQt == bplDFB && bplQt == (image.width() * image.depth() / 8)) {
- memcpy(mem, image.bits(), image.byteCount());
- } else {
- for (int i=0; i<height; ++i) {
- memcpy(mem, image.scanLine(i), bplQt);
- mem += bplDFB;
- }
- }
- surface->Unlock(surface);
- }
- }
-#ifdef QT_DIRECTFB_PALETTE
- if (image.colorCount() != 0 && surface)
- QDirectFBScreen::setSurfaceColorTable(surface, image);
-#endif
- return surface;
-}
-
-IDirectFBSurface *QDirectFBScreen::copyDFBSurface(IDirectFBSurface *src,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result)
-{
- Q_ASSERT(src);
- QSize size;
- src->GetSize(src, &size.rwidth(), &size.rheight());
- IDirectFBSurface *surface = createDFBSurface(size, format, options, result);
- DFBSurfaceBlittingFlags flags = QDirectFBScreen::hasAlphaChannel(surface)
- ? DSBLIT_BLEND_ALPHACHANNEL
- : DSBLIT_NOFX;
- if (flags & DSBLIT_BLEND_ALPHACHANNEL)
- surface->Clear(surface, 0, 0, 0, 0);
-
- surface->SetBlittingFlags(surface, flags);
- surface->Blit(surface, src, 0, 0, 0);
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- surface->ReleaseSource(surface);
-#endif
- return surface;
-}
-
-IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result)
-{
- DFBSurfaceDescription desc;
- memset(&desc, 0, sizeof(DFBSurfaceDescription));
- desc.flags |= DSDESC_WIDTH|DSDESC_HEIGHT;
- if (!QDirectFBScreen::initSurfaceDescriptionPixelFormat(&desc, format))
- return 0;
- desc.width = size.width();
- desc.height = size.height();
- return createDFBSurface(desc, options, result);
-}
-
-IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options, DFBResult *resultPtr)
-{
- DFBResult tmp;
- DFBResult &result = (resultPtr ? *resultPtr : tmp);
- result = DFB_OK;
- IDirectFBSurface *newSurface = 0;
-
- if (!d_ptr->dfb) {
- qWarning("QDirectFBScreen::createDFBSurface() - not connected");
- return 0;
- }
-
- if (d_ptr->directFBFlags & VideoOnly
- && !(desc.flags & DSDESC_PREALLOCATED)
- && (!(desc.flags & DSDESC_CAPS) || !(desc.caps & DSCAPS_SYSTEMONLY))) {
- // Add the video only capability. This means the surface will be created in video ram
- if (!(desc.flags & DSDESC_CAPS)) {
- desc.caps = DSCAPS_VIDEOONLY;
- desc.flags |= DSDESC_CAPS;
- } else {
- desc.caps |= DSCAPS_VIDEOONLY;
- }
- result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface);
- if (result != DFB_OK
-#ifdef QT_NO_DEBUG
- && (desc.flags & DSDESC_CAPS) && (desc.caps & DSCAPS_PRIMARY)
-#endif
- ) {
- qWarning("QDirectFBScreen::createDFBSurface() Failed to create surface in video memory!\n"
- " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
- desc.flags, desc.caps, desc.width, desc.height,
- desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat),
- desc.preallocated[0].data, desc.preallocated[0].pitch,
- DirectFBErrorString(result));
- }
- desc.caps &= ~DSCAPS_VIDEOONLY;
- }
-
- if (d_ptr->directFBFlags & SystemOnly)
- desc.caps |= DSCAPS_SYSTEMONLY;
-
- if (!newSurface)
- result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface);
-
- if (result != DFB_OK) {
- qWarning("QDirectFBScreen::createDFBSurface() Failed!\n"
- " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
- desc.flags, desc.caps, desc.width, desc.height,
- desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat),
- desc.preallocated[0].data, desc.preallocated[0].pitch,
- DirectFBErrorString(result));
- return 0;
- }
-
- Q_ASSERT(newSurface);
-
- if (options & TrackSurface) {
- d_ptr->allocatedSurfaces.insert(newSurface);
- }
-
- return newSurface;
-}
-
-#ifdef QT_DIRECTFB_SUBSURFACE
-IDirectFBSurface *QDirectFBScreen::getSubSurface(IDirectFBSurface *surface,
- const QRect &rect,
- SurfaceCreationOptions options,
- DFBResult *resultPtr)
-{
- Q_ASSERT(!(options & NoPreallocated));
- Q_ASSERT(surface);
- DFBResult res;
- DFBResult &result = (resultPtr ? *resultPtr : res);
- IDirectFBSurface *subSurface = 0;
- if (rect.isNull()) {
- result = surface->GetSubSurface(surface, 0, &subSurface);
- } else {
- const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() };
- result = surface->GetSubSurface(surface, &subRect, &subSurface);
- }
- if (result != DFB_OK) {
- DirectFBError("Can't get sub surface", result);
- } else if (options & TrackSurface) {
- d_ptr->allocatedSurfaces.insert(subSurface);
- }
- return subSurface;
-}
-#endif
-
-
-void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface)
-{
- Q_ASSERT(QDirectFBScreen::instance());
- Q_ASSERT(surface);
- surface->Release(surface);
- if (!d_ptr->allocatedSurfaces.remove(surface))
- qWarning("QDirectFBScreen::releaseDFBSurface() - %p not in list", surface);
-
- //qDebug("Released surface at %p. New count = %d", surface, d_ptr->allocatedSurfaces.count());
-}
-
-QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const
-{
- return d_ptr->directFBFlags;
-}
-
-IDirectFB *QDirectFBScreen::dfb()
-{
- return d_ptr->dfb;
-}
-
-#ifdef QT_NO_DIRECTFB_WM
-IDirectFBSurface *QDirectFBScreen::primarySurface()
-{
- return d_ptr->primarySurface;
-}
-#endif
-
-#ifndef QT_NO_DIRECTFB_LAYER
-IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer()
-{
- return d_ptr->dfbLayer;
-}
-#endif
-
-DFBSurfacePixelFormat QDirectFBScreen::getSurfacePixelFormat(QImage::Format format)
-{
- switch (format) {
-#ifndef QT_NO_DIRECTFB_PALETTE
- case QImage::Format_Indexed8:
- return DSPF_LUT8;
-#endif
- case QImage::Format_RGB888:
- return DSPF_RGB24;
- case QImage::Format_ARGB4444_Premultiplied:
- return DSPF_ARGB4444;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case QImage::Format_RGB444:
- return DSPF_RGB444;
- case QImage::Format_RGB555:
- return DSPF_RGB555;
-#endif
- case QImage::Format_RGB16:
- return DSPF_RGB16;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case QImage::Format_ARGB6666_Premultiplied:
- return DSPF_ARGB6666;
- case QImage::Format_RGB666:
- return DSPF_RGB18;
-#endif
- case QImage::Format_RGB32:
- return DSPF_RGB32;
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB32:
- return DSPF_ARGB;
- default:
- return DSPF_UNKNOWN;
- };
-}
-
-QImage::Format QDirectFBScreen::getImageFormat(IDirectFBSurface *surface)
-{
- DFBSurfacePixelFormat format;
- surface->GetPixelFormat(surface, &format);
-
- switch (format) {
- case DSPF_LUT8:
- return QImage::Format_Indexed8;
- case DSPF_RGB24:
- return QImage::Format_RGB888;
- case DSPF_ARGB4444:
- return QImage::Format_ARGB4444_Premultiplied;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB444:
- return QImage::Format_RGB444;
- case DSPF_RGB555:
-#endif
- case DSPF_ARGB1555:
- return QImage::Format_RGB555;
- case DSPF_RGB16:
- return QImage::Format_RGB16;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case DSPF_ARGB6666:
- return QImage::Format_ARGB6666_Premultiplied;
- case DSPF_RGB18:
- return QImage::Format_RGB666;
-#endif
- case DSPF_RGB32:
- return QImage::Format_RGB32;
- case DSPF_ARGB: {
- DFBSurfaceCapabilities caps;
- const DFBResult result = surface->GetCapabilities(surface, &caps);
- Q_ASSERT(result == DFB_OK);
- Q_UNUSED(result);
- return (caps & DSCAPS_PREMULTIPLIED
- ? QImage::Format_ARGB32_Premultiplied
- : QImage::Format_ARGB32); }
- default:
- break;
- }
- return QImage::Format_Invalid;
-}
-
-DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer,
- int length)
-{
- DFBSurfaceDescription description;
- memset(&description, 0, sizeof(DFBSurfaceDescription));
-
- description.flags = DSDESC_CAPS|DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT|DSDESC_PREALLOCATED;
- description.caps = DSCAPS_PREMULTIPLIED;
- description.width = length;
- description.height = 1;
- description.pixelformat = DSPF_ARGB;
- description.preallocated[0].data = (void*)buffer;
- description.preallocated[0].pitch = length * sizeof(uint);
- description.preallocated[1].data = 0;
- description.preallocated[1].pitch = 0;
- return description;
-}
-
-#ifndef QT_NO_DIRECTFB_PALETTE
-void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface,
- const QImage &image)
-{
- if (!surface)
- return;
-
- const int numColors = image.colorCount();
- if (numColors == 0)
- return;
-
- QVarLengthArray<DFBColor, 256> colors(numColors);
- for (int i = 0; i < numColors; ++i) {
- QRgb c = image.color(i);
- colors[i].a = qAlpha(c);
- colors[i].r = qRed(c);
- colors[i].g = qGreen(c);
- colors[i].b = qBlue(c);
- }
-
- IDirectFBPalette *palette;
- DFBResult result;
- result = surface->GetPalette(surface, &palette);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::setSurfaceColorTable GetPalette",
- result);
- return;
- }
- result = palette->SetEntries(palette, colors.data(), numColors, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::setSurfaceColorTable SetEntries",
- result);
- }
- palette->Release(palette);
-}
-
-#endif // QT_NO_DIRECTFB_PALETTE
-
-#if defined QT_DIRECTFB_CURSOR
-class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor
-{
-public:
- QDirectFBScreenCursor();
- virtual void set(const QImage &image, int hotx, int hoty);
- virtual void move(int x, int y);
- virtual void show();
- virtual void hide();
-private:
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- ~QDirectFBScreenCursor();
- bool createWindow();
- IDirectFBWindow *window;
-#endif
- IDirectFBDisplayLayer *layer;
-};
-
-QDirectFBScreenCursor::QDirectFBScreenCursor()
-{
- IDirectFB *fb = QDirectFBScreen::instance()->dfb();
- if (!fb)
- qFatal("QDirectFBScreenCursor: DirectFB not initialized");
-
- layer = QDirectFBScreen::instance()->dfbDisplayLayer();
- Q_ASSERT(layer);
-
- enable = false;
- hwaccel = true;
- supportsAlpha = true;
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- window = 0;
- DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorOpacity(layer, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cursor opacity", result);
- }
-
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
-#endif
-}
-
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
-QDirectFBScreenCursor::~QDirectFBScreenCursor()
-{
- if (window) {
- window->Release(window);
- window = 0;
- }
-}
-
-bool QDirectFBScreenCursor::createWindow()
-{
- Q_ASSERT(!window);
- Q_ASSERT(!cursor.isNull());
- DFBWindowDescription description;
- memset(&description, 0, sizeof(DFBWindowDescription));
- description.flags = DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_CAPS|DWDESC_PIXELFORMAT|DWDESC_SURFACE_CAPS;
- description.width = cursor.width();
- description.height = cursor.height();
- description.posx = pos.x() - hotspot.x();
- description.posy = pos.y() - hotspot.y();
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- description.flags |= DWDESC_OPTIONS;
- description.options = DWOP_GHOST|DWOP_ALPHACHANNEL;
-#endif
- description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER;
- const QImage::Format format = QDirectFBScreen::instance()->alphaPixmapFormat();
- description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
- if (QDirectFBScreen::isPremultiplied(format))
- description.surface_caps = DSCAPS_PREMULTIPLIED;
-
- DFBResult result = layer->CreateWindow(layer, &description, &window);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to create window", result);
- return false;
- }
- result = window->SetOpacity(window, 255);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to set opacity ", result);
- return false;
- }
-
- result = window->SetStackingClass(window, DWSC_UPPER);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to set stacking class ", result);
- return false;
- }
-
- result = window->RaiseToTop(window);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to raise window ", result);
- return false;
- }
-
- return true;
-}
-#endif
-
-void QDirectFBScreenCursor::move(int x, int y)
-{
- pos = QPoint(x, y);
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- if (window) {
- const QPoint p = pos - hotspot;
- DFBResult result = window->MoveTo(window, p.x(), p.y());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::move: Unable to move window", result);
- }
- }
-#else
- layer->WarpCursor(layer, x, y);
-#endif
-}
-
-void QDirectFBScreenCursor::hide()
-{
- if (enable) {
- enable = false;
- DFBResult result;
-#ifndef QT_DIRECTFB_WINDOW_AS_CURSOR
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorOpacity(layer, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cursor opacity", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
-#else
- if (window) {
- result = window->SetOpacity(window, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set window opacity", result);
- }
- }
-#endif
- }
-}
-
-void QDirectFBScreenCursor::show()
-{
- if (!enable) {
- enable = true;
- DFBResult result;
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorOpacity(layer,
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- 0
-#else
- 255
-#endif
- );
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cursor shape", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- if (window) {
- DFBResult result = window->SetOpacity(window, 255);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set window opacity", result);
- }
- }
-#endif
- }
-}
-
-void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- QDirectFBScreen *screen = QDirectFBScreen::instance();
- if (!screen)
- return;
-
- if (image.isNull()) {
- cursor = QImage();
- hide();
- } else {
- cursor = image.convertToFormat(screen->alphaPixmapFormat());
- size = cursor.size();
- hotspot = QPoint(hotx, hoty);
- DFBResult result = DFB_OK;
- IDirectFBSurface *surface = screen->createDFBSurface(cursor, screen->alphaPixmapFormat(),
- QDirectFBScreen::DontTrackSurface, &result);
- if (!surface) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to create surface", result);
- return;
- }
-#ifndef QT_DIRECTFB_WINDOW_AS_CURSOR
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorShape(layer, surface, hotx, hoty);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cursor shape", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
-#else
- if (window || createWindow()) {
- QSize windowSize;
- result = window->GetSize(window, &windowSize.rwidth(), &windowSize.rheight());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: "
- "Unable to get window size", result);
- }
- result = window->Resize(window, size.width(), size.height());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to resize window", result);
- }
-
- IDirectFBSurface *windowSurface;
- result = window->GetSurface(window, &windowSurface);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to get window surface", result);
- } else {
- result = windowSurface->Clear(windowSurface, 0, 0, 0, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to clear surface", result);
- }
-
- result = windowSurface->Blit(windowSurface, surface, 0, 0, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to blit to surface", result);
- }
- }
- result = windowSurface->Flip(windowSurface, 0, DSFLIP_NONE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to flip window", result);
- }
-
- windowSurface->Release(windowSurface);
- }
-#endif
- surface->Release(surface);
- show();
- }
-
-}
-#endif // QT_DIRECTFB_CURSOR
-
-QDirectFBScreen::QDirectFBScreen(int display_id)
- : QScreen(display_id, DirectFBClass), d_ptr(new QDirectFBScreenPrivate(this))
-{
- QDirectFBScreenPrivate::instance = this;
-}
-
-QDirectFBScreen::~QDirectFBScreen()
-{
- if (QDirectFBScreenPrivate::instance == this)
- QDirectFBScreenPrivate::instance = 0;
- delete d_ptr;
-}
-
-QDirectFBScreen *QDirectFBScreen::instance()
-{
- return QDirectFBScreenPrivate::instance;
-}
-
-int QDirectFBScreen::depth(DFBSurfacePixelFormat format)
-{
- switch (format) {
- case DSPF_A1:
- return 1;
- case DSPF_A8:
- case DSPF_RGB332:
- case DSPF_LUT8:
- case DSPF_ALUT44:
- return 8;
- case DSPF_I420:
- case DSPF_YV12:
- case DSPF_NV12:
- case DSPF_NV21:
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB444:
-#endif
- return 12;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB555:
- return 15;
-#endif
- case DSPF_ARGB1555:
- case DSPF_RGB16:
- case DSPF_YUY2:
- case DSPF_UYVY:
- case DSPF_NV16:
- case DSPF_ARGB2554:
- case DSPF_ARGB4444:
- return 16;
- case DSPF_RGB24:
- return 24;
- case DSPF_RGB32:
- case DSPF_ARGB:
- case DSPF_AiRGB:
- return 32;
- case DSPF_UNKNOWN:
- default:
- return 0;
- };
- return 0;
-}
-
-int QDirectFBScreen::depth(QImage::Format format)
-{
- int depth = 0;
- switch(format) {
- case QImage::Format_Invalid:
- case QImage::NImageFormats:
- Q_ASSERT(false);
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- depth = 1;
- break;
- case QImage::Format_Indexed8:
- depth = 8;
- break;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- depth = 32;
- break;
- case QImage::Format_RGB555:
- case QImage::Format_RGB16:
- case QImage::Format_RGB444:
- case QImage::Format_ARGB4444_Premultiplied:
- depth = 16;
- break;
- case QImage::Format_RGB666:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_RGB888:
- depth = 24;
- break;
- }
- return depth;
-}
-
-void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args)
-{
- QRegExp flipRegexp(QLatin1String("^flip=([\\w,]*)$"));
- int index = args.indexOf(flipRegexp);
- if (index >= 0) {
- const QStringList flips = flipRegexp.cap(1).split(QLatin1Char(','),
- QString::SkipEmptyParts);
- flipFlags = DSFLIP_NONE;
- foreach(const QString &flip, flips) {
- if (flip == QLatin1String("wait"))
- flipFlags |= DSFLIP_WAIT;
- else if (flip == QLatin1String("blit"))
- flipFlags |= DSFLIP_BLIT;
- else if (flip == QLatin1String("onsync"))
- flipFlags |= DSFLIP_ONSYNC;
- else if (flip == QLatin1String("pipeline"))
- flipFlags |= DSFLIP_PIPELINE;
- else
- qWarning("QDirectFBScreen: Unknown flip argument: %s",
- qPrintable(flip));
- }
- } else {
- flipFlags = DSFLIP_BLIT|DSFLIP_ONSYNC;
- }
-}
-
-#ifdef QT_DIRECTFB_WM
-void QDirectFBScreenPrivate::onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event)
-{
- if (event == QWSServer::Raise) {
- QWSWindowSurface *windowSurface = window->windowSurface();
- if (windowSurface && windowSurface->key() == QLatin1String("directfb")) {
- static_cast<QDirectFBWindowSurface*>(windowSurface)->raise();
- }
- }
-}
-#endif
-
-QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const
-{
- if (type == QPixmapData::BitmapType)
- return QWSGraphicsSystem::createPixmapData(type);
-
- return new QDirectFBPixmapData(q, type);
-}
-
-#if (Q_DIRECTFB_VERSION >= 0x000923)
-#ifdef QT_NO_DEBUG
-struct FlagDescription;
-static const FlagDescription *accelerationDescriptions = 0;
-static const FlagDescription *blitDescriptions = 0;
-static const FlagDescription *drawDescriptions = 0;
-#else
-struct FlagDescription {
- const char *name;
- uint flag;
-};
-
-static const FlagDescription accelerationDescriptions[] = {
- { "DFXL_NONE", DFXL_NONE },
- { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE },
- { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE },
- { "DFXL_DRAWLINE", DFXL_DRAWLINE },
- { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE },
- { "DFXL_BLIT", DFXL_BLIT },
- { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT },
- { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES },
- { "DFXL_DRAWSTRING", DFXL_DRAWSTRING },
- { 0, 0 }
-};
-
-static const FlagDescription blitDescriptions[] = {
- { "DSBLIT_NOFX", DSBLIT_NOFX },
- { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL },
- { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA },
- { "DSBLIT_COLORIZE", DSBLIT_COLORIZE },
- { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY },
- { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY },
- { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY },
- { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY },
- { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY },
- { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE },
-#if (Q_DIRECTFB_VERSION >= 0x000923)
- { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR },
- { "DSBLIT_XOR", DSBLIT_XOR },
-#endif
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION },
-#endif
- { 0, 0 }
-};
-
-static const FlagDescription drawDescriptions[] = {
- { "DSDRAW_NOFX", DSDRAW_NOFX },
- { "DSDRAW_BLEND", DSDRAW_BLEND },
- { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY },
- { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY },
- { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY },
- { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY },
- { "DSDRAW_XOR", DSDRAW_XOR },
- { 0, 0 }
-};
-#endif
-
-static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags)
-{
-#ifdef QT_NO_DEBUG
- Q_UNUSED(mask);
- Q_UNUSED(flags);
- return QByteArray("");
-#else
- if (!mask)
- return flags[0].name;
-
- QStringList list;
- for (int i=1; flags[i].name; ++i) {
- if (mask & flags[i].flag) {
- list.append(QString::fromLatin1(flags[i].name));
- }
- }
- Q_ASSERT(!list.isEmpty());
- return (QLatin1Char(' ') + list.join(QLatin1String("|"))).toLatin1();
-#endif
-}
-static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface)
-{
- DFBResult result;
- DFBGraphicsDeviceDescription dev;
-
- result = fb->GetDeviceDescription(fb, &dev);
- if (result != DFB_OK) {
- DirectFBError("Error reading graphics device description", result);
- return;
- }
-
- DFBSurfacePixelFormat pixelFormat;
- primarySurface->GetPixelFormat(primarySurface, &pixelFormat);
-
- qDebug("Device: %s (%s), Driver: %s v%i.%i (%s) Pixelformat: %d (%d)\n"
- "acceleration: 0x%x%s\nblit: 0x%x%s\ndraw: 0x%0x%s\nvideo: %iKB\n",
- dev.name, dev.vendor, dev.driver.name, dev.driver.major,
- dev.driver.minor, dev.driver.vendor, DFB_PIXELFORMAT_INDEX(pixelFormat),
- QDirectFBScreen::getImageFormat(primarySurface), dev.acceleration_mask,
- flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(),
- dev.blitting_flags, flagDescriptions(dev.blitting_flags, blitDescriptions).constData(),
- dev.drawing_flags, flagDescriptions(dev.drawing_flags, drawDescriptions).constData(),
- (dev.video_memory >> 10));
-}
-#endif
-
-static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value)
-{
- Q_ASSERT(value);
- QRegExp rx(QString::fromLatin1("%1=?(\\d+)").arg(variable));
- rx.setCaseSensitivity(Qt::CaseInsensitive);
- if (arguments.indexOf(rx) != -1) {
- *value = rx.cap(1).toInt();
- return true;
- }
- return false;
-}
-
-static inline QColor colorFromName(const QString &name)
-{
- QRegExp rx(QLatin1String("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])"));
- rx.setCaseSensitivity(Qt::CaseInsensitive);
- if (rx.exactMatch(name)) {
- Q_ASSERT(rx.captureCount() == 4);
- int ints[4];
- int i;
- for (i=0; i<4; ++i) {
- bool ok;
- ints[i] = rx.cap(i + 1).toUInt(&ok, 16);
- if (!ok || ints[i] > 255)
- break;
- }
- if (i == 4)
- return QColor(ints[0], ints[1], ints[2], ints[3]);
- }
- return QColor(name);
-}
-
-bool QDirectFBScreen::connect(const QString &displaySpec)
-{
- DFBResult result = DFB_OK;
-
- { // pass command line arguments to DirectFB
- const QStringList args = QCoreApplication::arguments();
- int argc = args.size();
- char **argv = new char*[argc];
-
- for (int i = 0; i < argc; ++i)
- argv[i] = qstrdup(args.at(i).toLocal8Bit().constData());
-
- result = DirectFBInit(&argc, &argv);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen: error initializing DirectFB",
- result);
- }
- delete[] argv;
- }
-
- const QStringList displayArgs = displaySpec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
-
- d_ptr->setFlipFlags(displayArgs);
-
- result = DirectFBCreate(&d_ptr->dfb);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen: error creating DirectFB interface",
- result);
- return false;
- }
-
- if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive))
- d_ptr->directFBFlags |= VideoOnly;
-
- if (displayArgs.contains(QLatin1String("systemonly"), Qt::CaseInsensitive)) {
- if (d_ptr->directFBFlags & VideoOnly) {
- qWarning("QDirectFBScreen: error. videoonly and systemonly are mutually exclusive");
- } else {
- d_ptr->directFBFlags |= SystemOnly;
- }
- }
-
- if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) {
- d_ptr->directFBFlags |= BoundingRectFlip;
- } else if (displayArgs.contains(QLatin1String("nopartialflip"), Qt::CaseInsensitive)) {
- d_ptr->directFBFlags |= NoPartialFlip;
- }
-
-#ifdef QT_DIRECTFB_IMAGECACHE
- int imageCacheSize = 4 * 1024 * 1024; // 4 MB
- setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize);
- QDirectFBPaintEngine::initImageCache(imageCacheSize);
-#endif
-
-#ifndef QT_NO_DIRECTFB_WM
- if (displayArgs.contains(QLatin1String("fullscreen")))
-#endif
- d_ptr->dfb->SetCooperativeLevel(d_ptr->dfb, DFSCL_FULLSCREEN);
-
- const bool forcePremultiplied = displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive);
-
- DFBSurfaceDescription description;
- memset(&description, 0, sizeof(DFBSurfaceDescription));
- IDirectFBSurface *surface;
-
-#ifdef QT_NO_DIRECTFB_WM
- description.flags = DSDESC_CAPS;
- if (::setIntOption(displayArgs, QLatin1String("width"), &description.width))
- description.flags |= DSDESC_WIDTH;
- if (::setIntOption(displayArgs, QLatin1String("height"), &description.height))
- description.flags |= DSDESC_HEIGHT;
-
- description.caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE;
- struct {
- const char *name;
- const DFBSurfaceCapabilities cap;
- } const capabilities[] = {
- { "static_alloc", DSCAPS_STATIC_ALLOC },
- { "triplebuffer", DSCAPS_TRIPLE },
- { "interlaced", DSCAPS_INTERLACED },
- { "separated", DSCAPS_SEPARATED },
-// { "depthbuffer", DSCAPS_DEPTH }, // only makes sense with TextureTriangles which are not supported
- { 0, DSCAPS_NONE }
- };
- for (int i=0; capabilities[i].name; ++i) {
- if (displayArgs.contains(QString::fromLatin1(capabilities[i].name), Qt::CaseInsensitive))
- description.caps |= capabilities[i].cap;
- }
-
- if (forcePremultiplied) {
- description.caps |= DSCAPS_PREMULTIPLIED;
- }
-
- // We don't track the primary surface as it's released in disconnect
- d_ptr->primarySurface = createDFBSurface(description, DontTrackSurface, &result);
- if (!d_ptr->primarySurface) {
- DirectFBError("QDirectFBScreen: error creating primary surface",
- result);
- return false;
- }
-
- surface = d_ptr->primarySurface;
-#else
- description.flags = DSDESC_WIDTH|DSDESC_HEIGHT;
- description.width = description.height = 1;
- surface = createDFBSurface(description, DontTrackSurface, &result);
- if (!surface) {
- DirectFBError("QDirectFBScreen: error creating surface", result);
- return false;
- }
-#endif
- // Work out what format we're going to use for surfaces with an alpha channel
- QImage::Format pixelFormat = QDirectFBScreen::getImageFormat(surface);
- d_ptr->alphaPixmapFormat = pixelFormat;
-
- switch (pixelFormat) {
- case QImage::Format_RGB666:
- d_ptr->alphaPixmapFormat = QImage::Format_ARGB6666_Premultiplied;
- break;
- case QImage::Format_RGB444:
- d_ptr->alphaPixmapFormat = QImage::Format_ARGB4444_Premultiplied;
- break;
- case QImage::Format_RGB32:
- pixelFormat = d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied;
- // ### Format_RGB32 doesn't work so well with Qt. Force ARGB32 for windows/pixmaps
- break;
- case QImage::Format_Indexed8:
- qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the LUT8 pixelformat.");
- return false;
- case QImage::NImageFormats:
- case QImage::Format_Invalid:
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- case QImage::Format_RGB888:
- case QImage::Format_RGB16:
- case QImage::Format_RGB555:
- d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied;
- break;
- case QImage::Format_ARGB32:
- if (forcePremultiplied)
- d_ptr->alphaPixmapFormat = pixelFormat = QImage::Format_ARGB32_Premultiplied;
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- // works already
- break;
- }
- setPixelFormat(pixelFormat);
- QScreen::d = QDirectFBScreen::depth(pixelFormat);
- data = 0;
- lstep = 0;
- size = 0;
-
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect: "
- "Unable to get screen!", result);
- return false;
- }
- const QString qws_size = QString::fromLatin1(qgetenv("QWS_SIZE"));
- if (!qws_size.isEmpty()) {
- QRegExp rx(QLatin1String("(\\d+)x(\\d+)"));
- if (!rx.exactMatch(qws_size)) {
- qWarning("QDirectFBScreen::connect: Can't parse QWS_SIZE=\"%s\"", qPrintable(qws_size));
- } else {
- int *ints[2] = { &w, &h };
- for (int i=0; i<2; ++i) {
- *ints[i] = rx.cap(i + 1).toInt();
- if (*ints[i] <= 0) {
- qWarning("QDirectFBScreen::connect: %s is not a positive integer",
- qPrintable(rx.cap(i + 1)));
- w = h = 0;
- break;
- }
- }
- }
- }
-
- setIntOption(displayArgs, QLatin1String("width"), &w);
- setIntOption(displayArgs, QLatin1String("height"), &h);
-
-#ifndef QT_NO_DIRECTFB_LAYER
- int layerId = DLID_PRIMARY;
- setIntOption(displayArgs, QLatin1String("layerid"), &layerId);
-
- result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, static_cast<DFBDisplayLayerID>(layerId),
- &d_ptr->dfbLayer);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect: "
- "Unable to get display layer!", result);
- return false;
- }
- result = d_ptr->dfbLayer->GetScreen(d_ptr->dfbLayer, &d_ptr->dfbScreen);
-#else
- result = d_ptr->dfb->GetScreen(d_ptr->dfb, 0, &d_ptr->dfbScreen);
-#endif
-
- if (w <= 0 || h <= 0) {
-#ifdef QT_NO_DIRECTFB_WM
- result = d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h);
-#elif (Q_DIRECTFB_VERSION >= 0x010000)
- IDirectFBSurface *layerSurface;
- if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) == DFB_OK) {
- result = layerSurface->GetSize(layerSurface, &w, &h);
- layerSurface->Release(layerSurface);
- }
- if (w <= 0 || h <= 0) {
- result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h);
- }
-#else
- qWarning("QDirectFBScreen::connect: DirectFB versions prior to 1.0 do not offer a way\n"
- "query the size of the primary surface in windowed mode. You have to specify\n"
- "the size of the display using QWS_SIZE=[0-9]x[0-9] or\n"
- "QWS_DISPLAY=directfb:width=[0-9]:height=[0-9]");
- return false;
-#endif
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect: "
- "Unable to get screen size!", result);
- return false;
- }
- }
-
-
- dw = w;
- dh = h;
-
- Q_ASSERT(dw != 0 && dh != 0);
-
- physWidth = physHeight = -1;
- setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth);
- setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight);
- const int dpi = 72;
- if (physWidth < 0)
- physWidth = qRound(dw * 25.4 / dpi);
- if (physHeight < 0)
- physHeight = qRound(dh * 25.4 / dpi);
-
- setGraphicsSystem(d_ptr);
-
-#if (Q_DIRECTFB_VERSION >= 0x000923)
- if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive))
- printDirectFBInfo(d_ptr->dfb, surface);
-#endif
-#ifdef QT_DIRECTFB_WM
- surface->Release(surface);
- QColor backgroundColor;
-#else
- QColor &backgroundColor = d_ptr->backgroundColor;
-#endif
-
- QRegExp backgroundColorRegExp(QLatin1String("bgcolor=(.+)"));
- backgroundColorRegExp.setCaseSensitivity(Qt::CaseInsensitive);
- if (displayArgs.indexOf(backgroundColorRegExp) != -1) {
- backgroundColor = colorFromName(backgroundColorRegExp.cap(1));
- }
-#ifdef QT_NO_DIRECTFB_WM
- if (!backgroundColor.isValid())
- backgroundColor = Qt::green;
- d_ptr->primarySurface->Clear(d_ptr->primarySurface, backgroundColor.red(),
- backgroundColor.green(), backgroundColor.blue(),
- backgroundColor.alpha());
- d_ptr->primarySurface->Flip(d_ptr->primarySurface, 0, d_ptr->flipFlags);
-#else
- if (backgroundColor.isValid()) {
- DFBResult result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect "
- "Unable to set cooperative level", result);
- }
- result = d_ptr->dfbLayer->SetBackgroundColor(d_ptr->dfbLayer, backgroundColor.red(), backgroundColor.green(),
- backgroundColor.blue(), backgroundColor.alpha());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::connect: "
- "Unable to set background color", result);
- }
-
- result = d_ptr->dfbLayer->SetBackgroundMode(d_ptr->dfbLayer, DLBM_COLOR);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::connect: "
- "Unable to set background mode", result);
- }
-
- result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect "
- "Unable to set cooperative level", result);
- }
-
- }
-#endif
-
- return true;
-}
-
-void QDirectFBScreen::disconnect()
-{
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- if (d_ptr->imageProvider)
- d_ptr->imageProvider->Release(d_ptr->imageProvider);
-#endif
-#ifdef QT_NO_DIRECTFB_WM
- d_ptr->primarySurface->Release(d_ptr->primarySurface);
- d_ptr->primarySurface = 0;
-#endif
-
- foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces)
- surf->Release(surf);
- d_ptr->allocatedSurfaces.clear();
-
-#ifndef QT_NO_DIRECTFB_LAYER
- d_ptr->dfbLayer->Release(d_ptr->dfbLayer);
- d_ptr->dfbLayer = 0;
-#endif
-
- d_ptr->dfbScreen->Release(d_ptr->dfbScreen);
- d_ptr->dfbScreen = 0;
-
- d_ptr->dfb->Release(d_ptr->dfb);
- d_ptr->dfb = 0;
-}
-
-bool QDirectFBScreen::initDevice()
-{
-#ifndef QT_NO_DIRECTFB_MOUSE
- if (qgetenv("QWS_MOUSE_PROTO").isEmpty()) {
- QWSServer::instance()->setDefaultMouse("None");
- d_ptr->mouse = new QDirectFBMouseHandler;
- }
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- if (qgetenv("QWS_KEYBOARD").isEmpty()) {
- QWSServer::instance()->setDefaultKeyboard("None");
- d_ptr->keyboard = new QDirectFBKeyboardHandler(QString());
- }
-#endif
-
-#ifdef QT_DIRECTFB_CURSOR
- qt_screencursor = new QDirectFBScreenCursor;
-#elif !defined QT_NO_QWS_CURSOR
- QScreenCursor::initSoftwareCursor();
-#endif
- return true;
-}
-
-void QDirectFBScreen::shutdownDevice()
-{
-#ifndef QT_NO_DIRECTFB_MOUSE
- delete d_ptr->mouse;
- d_ptr->mouse = 0;
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- delete d_ptr->keyboard;
- d_ptr->keyboard = 0;
-#endif
-
-#ifndef QT_NO_QWS_CURSOR
- delete qt_screencursor;
- qt_screencursor = 0;
-#endif
-}
-
-void QDirectFBScreen::setMode(int width, int height, int depth)
-{
- d_ptr->dfb->SetVideoMode(d_ptr->dfb, width, height, depth);
-}
-
-void QDirectFBScreen::blank(bool on)
-{
- d_ptr->dfbScreen->SetPowerMode(d_ptr->dfbScreen,
- (on ? DSPM_ON : DSPM_SUSPEND));
-}
-
-QWSWindowSurface *QDirectFBScreen::createSurface(QWidget *widget) const
-{
-#ifdef QT_NO_DIRECTFB_WM
- if (QApplication::type() == QApplication::GuiServer) {
- return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this), widget);
- } else {
- return QScreen::createSurface(widget);
- }
-#else
- return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this), widget);
-#endif
-}
-
-QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("directfb")) {
- return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this));
- }
- return QScreen::createSurface(key);
-}
-
-#if defined QT_NO_DIRECTFB_WM
-struct PaintCommand {
- PaintCommand() : dfbSurface(0), windowOpacity(255), blittingFlags(DSBLIT_NOFX) {}
- IDirectFBSurface *dfbSurface;
- QImage image;
- QPoint windowPosition;
- QRegion source;
- quint8 windowOpacity;
- DFBSurfaceBlittingFlags blittingFlags;
-};
-
-static inline void initParameters(DFBRectangle &source, const QRect &sourceGlobal, const QPoint &pos)
-{
- source.x = sourceGlobal.x() - pos.x();
- source.y = sourceGlobal.y() - pos.y();
- source.w = sourceGlobal.width();
- source.h = sourceGlobal.height();
-}
-#endif
-
-void QDirectFBScreen::exposeRegion(QRegion r, int)
-{
- Q_UNUSED(r);
-#if defined QT_NO_DIRECTFB_WM
-
- r &= region();
- if (r.isEmpty()) {
- return;
- }
- r = r.boundingRect();
-
- IDirectFBSurface *primary = d_ptr->primarySurface;
- const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows();
- QVarLengthArray<PaintCommand, 4> commands(windows.size());
- QRegion region = r;
- int idx = 0;
- for (int i=0; i<windows.size(); ++i) {
- QWSWindowSurface *surface = windows.at(i)->windowSurface();
- if (!surface)
- continue;
-
- const QRect windowGeometry = surface->geometry();
- const QRegion intersection = region & windowGeometry;
- if (intersection.isEmpty()) {
- continue;
- }
-
- PaintCommand &cmd = commands[idx];
-
- if (surface->key() == QLatin1String("directfb")) {
- const QDirectFBWindowSurface *ws = static_cast<QDirectFBWindowSurface*>(surface);
- cmd.dfbSurface = ws->directFBSurface();
-
- if (!cmd.dfbSurface) {
- continue;
- }
- } else {
- cmd.image = surface->image();
- if (cmd.image.isNull()) {
- continue;
- }
- }
- ++idx;
-
- cmd.windowPosition = windowGeometry.topLeft();
- cmd.source = intersection;
- if (windows.at(i)->isOpaque()) {
- region -= intersection;
- if (region.isEmpty())
- break;
- } else {
- cmd.windowOpacity = windows.at(i)->opacity();
- cmd.blittingFlags = cmd.windowOpacity == 255
- ? DSBLIT_BLEND_ALPHACHANNEL
- : (DSBLIT_BLEND_ALPHACHANNEL|DSBLIT_BLEND_COLORALPHA);
- }
- }
-
- solidFill(d_ptr->backgroundColor, region);
-
- while (idx > 0) {
- const PaintCommand &cmd = commands[--idx];
- Q_ASSERT(cmd.dfbSurface || !cmd.image.isNull());
- IDirectFBSurface *surface;
- if (cmd.dfbSurface) {
- surface = cmd.dfbSurface;
- } else {
- Q_ASSERT(!cmd.image.isNull());
- DFBResult result;
- surface = createDFBSurface(cmd.image, cmd.image.format(), DontTrackSurface, &result);
- Q_ASSERT((result != DFB_OK) == !surface);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::exposeRegion: Can't create surface from image", result);
- continue;
- }
- }
-
- primary->SetBlittingFlags(primary, cmd.blittingFlags);
- if (cmd.blittingFlags & DSBLIT_BLEND_COLORALPHA) {
- primary->SetColor(primary, 0xff, 0xff, 0xff, cmd.windowOpacity);
- }
- const QRegion &region = cmd.source;
- const int rectCount = region.rectCount();
- DFBRectangle source;
- if (rectCount == 1) {
- ::initParameters(source, region.boundingRect(), cmd.windowPosition);
- primary->Blit(primary, surface, &source, cmd.windowPosition.x() + source.x, cmd.windowPosition.y() + source.y);
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i=0; i<rectCount; ++i) {
- ::initParameters(source, rects.at(i), cmd.windowPosition);
- primary->Blit(primary, surface, &source, cmd.windowPosition.x() + source.x, cmd.windowPosition.y() + source.y);
- }
- }
- if (surface != cmd.dfbSurface) {
- surface->Release(surface);
- }
- }
-
- primary->SetColor(primary, 0xff, 0xff, 0xff, 0xff);
-
-#if defined QT_NO_DIRECTFB_CURSOR and !defined QT_NO_QWS_CURSOR
- if (QScreenCursor *cursor = QScreenCursor::instance()) {
- const QRect cursorRectangle = cursor->boundingRect();
- if (cursor->isVisible() && !cursor->isAccelerated() && r.intersects(cursorRectangle)) {
- const QImage image = cursor->image();
- if (image.cacheKey() != d_ptr->cursorImageKey) {
- if (d_ptr->cursorSurface) {
- releaseDFBSurface(d_ptr->cursorSurface);
- }
- d_ptr->cursorSurface = createDFBSurface(image, image.format(), QDirectFBScreen::TrackSurface);
- d_ptr->cursorImageKey = image.cacheKey();
- }
-
- Q_ASSERT(d_ptr->cursorSurface);
- primary->SetBlittingFlags(primary, DSBLIT_BLEND_ALPHACHANNEL);
- primary->Blit(primary, d_ptr->cursorSurface, 0, cursorRectangle.x(), cursorRectangle.y());
- }
- }
-#endif
- flipSurface(primary, d_ptr->flipFlags, r, QPoint());
- primary->SetBlittingFlags(primary, DSBLIT_NOFX);
-#endif
-}
-
-void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
-{
-#ifdef QT_DIRECTFB_WM
- Q_UNUSED(color);
- Q_UNUSED(region);
-#else
- QDirectFBScreen::solidFill(d_ptr->primarySurface, color, region);
-#endif
-}
-
-static inline void clearRect(IDirectFBSurface *surface, const QColor &color, const QRect &rect)
-{
- Q_ASSERT(surface);
- const DFBRegion region = { rect.left(), rect.top(), rect.right(), rect.bottom() };
- // could just reinterpret_cast this to a DFBRegion
- surface->SetClip(surface, &region);
- surface->Clear(surface, color.red(), color.green(), color.blue(), color.alpha());
-}
-
-void QDirectFBScreen::solidFill(IDirectFBSurface *surface, const QColor &color, const QRegion &region)
-{
- if (region.isEmpty())
- return;
-
- const int n = region.rectCount();
- if (n == 1) {
- clearRect(surface, color, region.boundingRect());
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i=0; i<n; ++i) {
- clearRect(surface, color, rects.at(i));
- }
- }
- surface->SetClip(surface, 0);
-}
-
-QImage::Format QDirectFBScreen::alphaPixmapFormat() const
-{
- return d_ptr->alphaPixmapFormat;
-}
-
-bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description,
- QImage::Format format)
-{
- const DFBSurfacePixelFormat pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
- if (pixelformat == DSPF_UNKNOWN)
- return false;
- description->flags |= DSDESC_PIXELFORMAT;
- description->pixelformat = pixelformat;
- if (QDirectFBScreen::isPremultiplied(format)) {
- if (!(description->flags & DSDESC_CAPS)) {
- description->caps = DSCAPS_PREMULTIPLIED;
- description->flags |= DSDESC_CAPS;
- } else {
- description->caps |= DSCAPS_PREMULTIPLIED;
- }
- }
- return true;
-}
-
-uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl)
-{
- void *mem = 0;
- const DFBResult result = surface->Lock(surface, flags, &mem, bpl);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::lockSurface()", result);
- }
-
- return reinterpret_cast<uchar*>(mem);
-}
-
-static inline bool isFullUpdate(IDirectFBSurface *surface, const QRegion &region, const QPoint &offset)
-{
- if (offset == QPoint(0, 0) && region.rectCount() == 1) {
- QSize size;
- surface->GetSize(surface, &size.rwidth(), &size.rheight());
- if (region.boundingRect().size() == size)
- return true;
- }
- return false;
-}
-
-void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags,
- const QRegion &region, const QPoint &offset)
-{
- if (d_ptr->directFBFlags & NoPartialFlip
- || (!(flipFlags & DSFLIP_BLIT) && QT_PREPEND_NAMESPACE(isFullUpdate(surface, region, offset)))) {
- surface->Flip(surface, 0, flipFlags);
- } else {
- if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.rectCount() > 1) {
- const QVector<QRect> rects = region.rects();
- const DFBSurfaceFlipFlags nonWaitFlags = flipFlags & ~DSFLIP_WAIT;
- for (int i=0; i<rects.size(); ++i) {
- const QRect &r = rects.at(i);
- const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.right() + offset.x(),
- r.bottom() + offset.y() };
- surface->Flip(surface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags);
- }
- } else {
- const QRect r = region.boundingRect();
- const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.right() + offset.x(),
- r.bottom() + offset.y() };
- surface->Flip(surface, &dfbReg, flipFlags);
- }
- }
-}
-
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-void QDirectFBScreen::setDirectFBImageProvider(IDirectFBImageProvider *provider)
-{
- Q_ASSERT(provider);
- if (d_ptr->imageProvider)
- d_ptr->imageProvider->Release(d_ptr->imageProvider);
- d_ptr->imageProvider = provider;
-}
-#endif
-
-void QDirectFBScreen::waitIdle()
-{
- d_ptr->dfb->WaitIdle(d_ptr->dfb);
-}
-
-#ifdef QT_DIRECTFB_WM
-IDirectFBWindow *QDirectFBScreen::windowForWidget(const QWidget *widget) const
-{
- if (widget) {
- const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface());
- if (surface && surface->key() == QLatin1String("directfb")) {
- return static_cast<const QDirectFBWindowSurface*>(surface)->directFBWindow();
- }
- }
- return 0;
-}
-#endif
-
-IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRect *rect) const
-{
- Q_ASSERT(widget);
- if (!widget->isVisible() || widget->size().isNull())
- return 0;
-
- const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface());
- if (surface && surface->key() == QLatin1String("directfb")) {
- return static_cast<const QDirectFBWindowSurface*>(surface)->surfaceForWidget(widget, rect);
- }
- return 0;
-}
-
-#ifdef QT_DIRECTFB_SUBSURFACE
-IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, const QRect &area) const
-{
- Q_ASSERT(widget);
- QRect rect;
- IDirectFBSurface *surface = surfaceForWidget(widget, &rect);
- IDirectFBSurface *subSurface = 0;
- if (surface) {
- if (!area.isNull())
- rect &= area.translated(widget->mapTo(widget->window(), QPoint(0, 0)));
- if (!rect.isNull()) {
- const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() };
- const DFBResult result = surface->GetSubSurface(surface, &subRect, &subSurface);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::subSurface(): Can't get sub surface", result);
- }
- }
- }
- return subSurface;
-}
-#endif
-
-Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_widget(const QWidget *widget, QRect *rect)
-{
- return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->surfaceForWidget(widget, rect) : 0;
-}
-#ifdef QT_DIRECTFB_SUBSURFACE
-Q_GUI_EXPORT IDirectFBSurface *qt_directfb_subsurface_for_widget(const QWidget *widget, const QRect &area)
-{
- return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->subSurfaceForWidget(widget, area) : 0;
-}
-#endif
-#ifdef QT_DIRECTFB_WM
-Q_GUI_EXPORT IDirectFBWindow *qt_directfb_window_for_widget(const QWidget *widget)
-{
- return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->windowForWidget(widget) : 0;
-}
-
-#endif
-
-QT_END_NAMESPACE
-
-#include "qdirectfbscreen.moc"
-#endif // QT_NO_QWS_DIRECTFB
-
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
deleted file mode 100644
index afc153bab2..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBSCREEN_H
-#define QDIRECTFBSCREEN_H
-
-#include <qglobal.h>
-#ifndef QT_NO_QWS_DIRECTFB
-#include <QtGui/qscreen_qws.h>
-#include <directfb.h>
-#include <directfb_version.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined QT_DIRECTFB_SUBSURFACE && !defined QT_NO_DIRECTFB_SUBSURFACE
-#define QT_NO_DIRECTFB_SUBSURFACE
-#endif
-#if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER
-#define QT_DIRECTFB_LAYER
-#endif
-#if !defined QT_NO_DIRECTFB_WM && !defined QT_DIRECTFB_WM
-#define QT_DIRECTFB_WM
-#endif
-#if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE
-#define QT_NO_DIRECTFB_IMAGECACHE
-#endif
-#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER
-#define QT_DIRECTFB_IMAGEPROVIDER
-#endif
-#if !defined QT_NO_DIRECTFB_STRETCHBLIT && !defined QT_DIRECTFB_STRETCHBLIT
-#define QT_DIRECTFB_STRETCHBLIT
-#endif
-#if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-#define QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-#endif
-#if !defined QT_DIRECTFB_WINDOW_AS_CURSOR && !defined QT_NO_DIRECTFB_WINDOW_AS_CURSOR
-#define QT_NO_DIRECTFB_WINDOW_AS_CURSOR
-#endif
-#if !defined QT_DIRECTFB_PALETTE && !defined QT_NO_DIRECTFB_PALETTE
-#define QT_NO_DIRECTFB_PALETTE
-#endif
-#if !defined QT_NO_DIRECTFB_PREALLOCATED && !defined QT_DIRECTFB_PREALLOCATED
-#define QT_DIRECTFB_PREALLOCATED
-#endif
-#if !defined QT_NO_DIRECTFB_MOUSE && !defined QT_DIRECTFB_MOUSE
-#define QT_DIRECTFB_MOUSE
-#endif
-#if !defined QT_NO_DIRECTFB_KEYBOARD && !defined QT_DIRECTFB_KEYBOARD
-#define QT_DIRECTFB_KEYBOARD
-#endif
-#if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION
-#define QT_DIRECTFB_OPAQUE_DETECTION
-#endif
-#ifndef QT_NO_QWS_CURSOR
-#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR
-#define QT_DIRECTFB_CURSOR
-#elif defined QT_DIRECTFB_LAYER
-#define QT_DIRECTFB_CURSOR
-#endif
-#endif
-#ifndef QT_DIRECTFB_CURSOR
-#define QT_NO_DIRECTFB_CURSOR
-#endif
-#if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM
-#error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && defined QT_NO_DIRECTFB_IMAGEPROVIDER
-#error QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE requires QT_DIRECTFB_IMAGEPROVIDER to be defined
-#endif
-#if defined QT_DIRECTFB_WINDOW_AS_CURSOR && defined QT_NO_DIRECTFB_WM
-#error QT_DIRECTFB_WINDOW_AS_CURSOR requires QT_DIRECTFB_WM to be defined
-#endif
-
-#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERSION << 8) | DIRECTFB_MICRO_VERSION)
-
-#define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \
- static inline F operator~(F f) { return F(~int(f)); } \
- static inline F operator&(F left, F right) { return F(int(left) & int(right)); } \
- static inline F operator|(F left, F right) { return F(int(left) | int(right)); } \
- static inline F &operator|=(F &left, F right) { left = (left | right); return left; } \
- static inline F &operator&=(F &left, F right) { left = (left & right); return left; }
-
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBInputDeviceCapabilities);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowDescriptionFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowCapabilities);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowOptions);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDescriptionFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceCapabilities);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceLockFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceBlittingFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDrawingFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceFlipFlags);
-
-class QDirectFBScreenPrivate;
-class Q_GUI_EXPORT QDirectFBScreen : public QScreen
-{
-public:
- QDirectFBScreen(int display_id);
- ~QDirectFBScreen();
-
- enum DirectFBFlag {
- NoFlags = 0x00,
- VideoOnly = 0x01,
- SystemOnly = 0x02,
- BoundingRectFlip = 0x04,
- NoPartialFlip = 0x08
- };
-
- Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag);
-
- DirectFBFlags directFBFlags() const;
-
- bool connect(const QString &displaySpec);
- void disconnect();
- bool initDevice();
- void shutdownDevice();
-
- void exposeRegion(QRegion r, int changing);
- void solidFill(const QColor &color, const QRegion &region);
- static void solidFill(IDirectFBSurface *surface, const QColor &color, const QRegion &region);
-
- void setMode(int width, int height, int depth);
- void blank(bool on);
-
- QWSWindowSurface *createSurface(QWidget *widget) const;
- QWSWindowSurface *createSurface(const QString &key) const;
-
- static QDirectFBScreen *instance();
- void waitIdle();
- IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const;
-#ifdef QT_DIRECTFB_SUBSURFACE
- IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const;
-#endif
- IDirectFB *dfb();
-#ifdef QT_DIRECTFB_WM
- IDirectFBWindow *windowForWidget(const QWidget *widget) const;
-#else
- IDirectFBSurface *primarySurface();
-#endif
-#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer *dfbDisplayLayer();
-#endif
-
- // Track surface creation/release so we can release all on exit
- enum SurfaceCreationOption {
- DontTrackSurface = 0x1,
- TrackSurface = 0x2,
- NoPreallocated = 0x4
- };
- Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption);
- IDirectFBSurface *createDFBSurface(const QImage &image,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result = 0);
- IDirectFBSurface *createDFBSurface(const QSize &size,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result = 0);
- IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result = 0);
- IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc,
- SurfaceCreationOptions options,
- DFBResult *result);
-#ifdef QT_DIRECTFB_SUBSURFACE
- IDirectFBSurface *getSubSurface(IDirectFBSurface *surface,
- const QRect &rect,
- SurfaceCreationOptions options,
- DFBResult *result);
-#endif
-
- void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags,
- const QRegion &region, const QPoint &offset);
- void releaseDFBSurface(IDirectFBSurface *surface);
-
- using QScreen::depth;
- static int depth(DFBSurfacePixelFormat format);
- static int depth(QImage::Format format);
-
- static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format);
- static DFBSurfaceDescription getSurfaceDescription(const uint *buffer,
- int length);
- static QImage::Format getImageFormat(IDirectFBSurface *surface);
- static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format);
- static inline bool isPremultiplied(QImage::Format format);
- static inline bool hasAlphaChannel(DFBSurfacePixelFormat format);
- static inline bool hasAlphaChannel(IDirectFBSurface *surface);
- QImage::Format alphaPixmapFormat() const;
-
-#ifndef QT_NO_DIRECTFB_PALETTE
- static void setSurfaceColorTable(IDirectFBSurface *surface,
- const QImage &image);
-#endif
-
- static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0);
-#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- void setDirectFBImageProvider(IDirectFBImageProvider *provider);
-#endif
-private:
- QDirectFBScreenPrivate *d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions);
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags);
-
-inline bool QDirectFBScreen::isPremultiplied(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
- return true;
- default:
- break;
- }
- return false;
-}
-
-inline bool QDirectFBScreen::hasAlphaChannel(DFBSurfacePixelFormat format)
-{
- switch (format) {
- case DSPF_ARGB1555:
- case DSPF_ARGB:
- case DSPF_LUT8:
- case DSPF_AiRGB:
- case DSPF_A1:
- case DSPF_ARGB2554:
- case DSPF_ARGB4444:
-#if (Q_DIRECTFB_VERSION >= 0x000923)
- case DSPF_AYUV:
-#endif
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case DSPF_A4:
- case DSPF_ARGB1666:
- case DSPF_ARGB6666:
- case DSPF_LUT2:
-#endif
- return true;
- default:
- return false;
- }
-}
-
-inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface)
-{
- Q_ASSERT(surface);
- DFBSurfacePixelFormat format;
- surface->GetPixelFormat(surface, &format);
- return QDirectFBScreen::hasAlphaChannel(format);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-#endif // QDIRECTFBSCREEN_H
-
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
deleted file mode 100644
index 228e7b8dea..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbscreen.h"
-
-#include <QtGui/qscreendriverplugin_qws.h>
-#include <QtCore/qstringlist.h>
-#ifndef QT_NO_QWS_DIRECTFB
-
-class DirectFBScreenDriverPlugin : public QScreenDriverPlugin
-{
-public:
- DirectFBScreenDriverPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-DirectFBScreenDriverPlugin::DirectFBScreenDriverPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList DirectFBScreenDriverPlugin::keys() const
-{
- return (QStringList() << "directfb");
-}
-
-QScreen* DirectFBScreenDriverPlugin::create(const QString& driver,
- int displayId)
-{
- if (driver.toLower() != "directfb")
- return 0;
-
- return new QDirectFBScreen(displayId);
-}
-
-Q_EXPORT_PLUGIN2(qdirectfbscreen, DirectFBScreenDriverPlugin)
-
-#endif
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
deleted file mode 100644
index b8fc811e4d..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ /dev/null
@@ -1,506 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbwindowsurface.h"
-#include "qdirectfbscreen.h"
-#include "qdirectfbpaintengine.h"
-
-#include <private/qwidget_p.h>
-#include <qwidget.h>
-#include <qwindowsystem_qws.h>
-#include <qpaintdevice.h>
-#include <qvarlengtharray.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_NAMESPACE
-
-QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr)
- : QDirectFBPaintDevice(scr)
-#ifndef QT_NO_DIRECTFB_WM
- , dfbWindow(0)
-#endif
- , flipFlags(flip)
- , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
- , flushPending(false)
-{
-#ifdef QT_NO_DIRECTFB_WM
- mode = Offscreen;
-#endif
- setSurfaceFlags(Opaque | Buffered);
-#ifdef QT_DIRECTFB_TIMING
- frames = 0;
- timer.start();
-#endif
-}
-
-QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget)
- : QWSWindowSurface(widget), QDirectFBPaintDevice(scr)
-#ifndef QT_NO_DIRECTFB_WM
- , dfbWindow(0)
-#endif
- , flipFlags(flip)
- , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
- , flushPending(false)
-{
- SurfaceFlags flags = 0;
- if (!widget || widget->window()->windowOpacity() == 0xff)
- flags |= Opaque;
-#ifdef QT_NO_DIRECTFB_WM
- if (widget && widget->testAttribute(Qt::WA_PaintOnScreen)) {
- flags = RegionReserved;
- mode = Primary;
- } else {
- mode = Offscreen;
- flags = Buffered;
- }
-#endif
- setSurfaceFlags(flags);
-#ifdef QT_DIRECTFB_TIMING
- frames = 0;
- timer.start();
-#endif
-}
-
-QDirectFBWindowSurface::~QDirectFBWindowSurface()
-{
- releaseSurface();
- // these are not tracked by QDirectFBScreen so we don't want QDirectFBPaintDevice to release it
-}
-
-bool QDirectFBWindowSurface::isValid() const
-{
- return true;
-}
-
-#ifdef QT_DIRECTFB_WM
-void QDirectFBWindowSurface::raise()
-{
- if (IDirectFBWindow *window = directFBWindow()) {
- window->RaiseToTop(window);
- }
-}
-
-IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const
-{
- return dfbWindow;
-}
-
-void QDirectFBWindowSurface::createWindow(const QRect &rect)
-{
- IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
- if (!layer)
- qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");
-
- updateIsOpaque();
-
- DFBWindowDescription description;
- memset(&description, 0, sizeof(DFBWindowDescription));
-
- description.flags = DWDESC_CAPS|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT;
- description.caps = DWCAPS_NODECORATION;
- description.surface_caps = DSCAPS_NONE;
- imageFormat = screen->pixelFormat();
-
- if (!(surfaceFlags() & Opaque)) {
- imageFormat = screen->alphaPixmapFormat();
- description.caps |= DWCAPS_ALPHACHANNEL;
-#if (Q_DIRECTFB_VERSION >= 0x010200)
- description.flags |= DWDESC_OPTIONS;
- description.options |= DWOP_ALPHACHANNEL;
-#endif
- }
- description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(imageFormat);
- description.posx = rect.x();
- description.posy = rect.y();
- description.width = rect.width();
- description.height = rect.height();
-
- if (QDirectFBScreen::isPremultiplied(imageFormat))
- description.surface_caps = DSCAPS_PREMULTIPLIED;
-
- if (screen->directFBFlags() & QDirectFBScreen::VideoOnly)
- description.surface_caps |= DSCAPS_VIDEOONLY;
-
- DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow);
-
- if (result != DFB_OK)
- DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result);
-
- if (window()) {
- if (window()->windowFlags() & Qt::WindowStaysOnTopHint) {
- dfbWindow->SetStackingClass(dfbWindow, DWSC_UPPER);
- }
- DFBWindowID winid;
- result = dfbWindow->GetID(dfbWindow, &winid);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBWindowSurface::createWindow. Can't get ID", result);
- } else {
- window()->setProperty("_q_DirectFBWindowID", winid);
- }
- }
-
- Q_ASSERT(!dfbSurface);
- dfbWindow->GetSurface(dfbWindow, &dfbSurface);
-}
-
-static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect)
-{
- DFBResult result = DFB_OK;
- const bool isMove = old.isEmpty() || rect.topLeft() != old.topLeft();
- const bool isResize = rect.size() != old.size();
-
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- if (isResize && isMove) {
- result = dfbWindow->SetBounds(dfbWindow, rect.x(), rect.y(),
- rect.width(), rect.height());
- } else if (isResize) {
- result = dfbWindow->Resize(dfbWindow,
- rect.width(), rect.height());
- } else if (isMove) {
- result = dfbWindow->MoveTo(dfbWindow, rect.x(), rect.y());
- }
-#else
- if (isResize) {
- result = dfbWindow->Resize(dfbWindow,
- rect.width(), rect.height());
- }
- if (isMove) {
- result = dfbWindow->MoveTo(dfbWindow, rect.x(), rect.y());
- }
-#endif
- return result;
-}
-#endif // QT_NO_DIRECTFB_WM
-
-void QDirectFBWindowSurface::setGeometry(const QRect &rect)
-{
- const QRect oldRect = geometry();
- if (oldRect == rect)
- return;
-
- IDirectFBSurface *oldSurface = dfbSurface;
- const bool sizeChanged = oldRect.size() != rect.size();
- if (sizeChanged) {
- delete engine;
- engine = 0;
- releaseSurface();
- Q_ASSERT(!dfbSurface);
- }
-
- if (rect.isNull()) {
-#ifndef QT_NO_DIRECTFB_WM
- if (dfbWindow) {
- if (window())
- window()->setProperty("_q_DirectFBWindowID", QVariant());
-
- dfbWindow->Release(dfbWindow);
- dfbWindow = 0;
- }
-#endif
- Q_ASSERT(!dfbSurface);
-#ifdef QT_DIRECTFB_SUBSURFACE
- Q_ASSERT(!subSurface);
-#endif
- } else {
-#ifdef QT_DIRECTFB_WM
- if (!dfbWindow) {
- createWindow(rect);
- } else {
- setWindowGeometry(dfbWindow, oldRect, rect);
- Q_ASSERT(!sizeChanged || !dfbSurface);
- if (sizeChanged)
- dfbWindow->GetSurface(dfbWindow, &dfbSurface);
- }
-#else
- IDirectFBSurface *primarySurface = screen->primarySurface();
- DFBResult result = DFB_OK;
- if (mode == Primary) {
- Q_ASSERT(primarySurface);
- if (rect == screen->region().boundingRect()) {
- dfbSurface = primarySurface;
- } else {
- const DFBRectangle r = { rect.x(), rect.y(),
- rect.width(), rect.height() };
- result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
- }
- } else { // mode == Offscreen
- if (!dfbSurface) {
- dfbSurface = screen->createDFBSurface(rect.size(), surfaceFlags() & Opaque ? screen->pixelFormat() : screen->alphaPixmapFormat(),
- QDirectFBScreen::DontTrackSurface);
- }
- }
- if (result != DFB_OK)
- DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result);
-#endif
- }
- if (oldSurface != dfbSurface) {
- imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;
- }
-
- if (oldRect.size() != rect.size()) {
- QWSWindowSurface::setGeometry(rect);
- } else {
- QWindowSurface::setGeometry(rect);
- }
-}
-
-QByteArray QDirectFBWindowSurface::permanentState() const
-{
- QByteArray state(sizeof(SurfaceFlags) + sizeof(DFBWindowID), 0);
- char *ptr = state.data();
- SurfaceFlags flags = surfaceFlags();
- memcpy(ptr, &flags, sizeof(SurfaceFlags));
- ptr += sizeof(SurfaceFlags);
- DFBWindowID did = (DFBWindowID)(-1);
- if (dfbWindow)
- dfbWindow->GetID(dfbWindow, &did);
- memcpy(ptr, &did, sizeof(DFBWindowID));
- return state;
-}
-
-void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
-{
- const char *ptr = state.constData();
- IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
- SurfaceFlags flags;
- memcpy(&flags, ptr, sizeof(SurfaceFlags));
-
- setSurfaceFlags(flags);
- ptr += sizeof(SurfaceFlags);
- DFBWindowID id;
- memcpy(&id, ptr, sizeof(DFBWindowID));
- if (dfbSurface)
- dfbSurface->Release(dfbSurface);
- if (id != (DFBWindowID)-1) {
- IDirectFBWindow *dw;
- layer->GetWindow(layer, id, &dw);
- if (dw->GetSurface(dw, &dfbSurface) != DFB_OK)
- dfbSurface = 0;
- dw->Release(dw);
- }
- else {
- dfbSurface = 0;
- }
-}
-
-bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
-{
- if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.rectCount() != 1)
- return false;
- if (flushPending) {
- dfbSurface->Flip(dfbSurface, 0, DSFLIP_BLIT);
- } else {
- flushPending = true;
- }
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- const QRect r = region.boundingRect();
- const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() };
- dfbSurface->Blit(dfbSurface, dfbSurface, &rect, r.x() + dx, r.y() + dy);
- return true;
-}
-
-bool QDirectFBWindowSurface::move(const QPoint &moveBy)
-{
- setGeometry(geometry().translated(moveBy));
- return true;
-}
-
-void QDirectFBWindowSurface::setOpaque(bool opaque)
-{
- SurfaceFlags flags = surfaceFlags();
- if (opaque != (flags & Opaque)) {
- if (opaque) {
- flags |= Opaque;
- } else {
- flags &= ~Opaque;
- }
- setSurfaceFlags(flags);
- }
-}
-
-
-void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
- QWidget *win = window();
- if (!win)
- return;
-
-#if !defined(QT_NO_QWS_PROXYSCREEN) && !defined(QT_NO_GRAPHICSVIEW)
- QWExtra *extra = qt_widget_private(widget)->extraData();
- if (extra && extra->proxyWidget)
- return;
-#else
- Q_UNUSED(widget);
-#endif
-
- const quint8 windowOpacity = quint8(win->windowOpacity() * 0xff);
- const QRect windowGeometry = geometry();
-#ifdef QT_DIRECTFB_WM
- quint8 currentOpacity;
- Q_ASSERT(dfbWindow);
- dfbWindow->GetOpacity(dfbWindow, &currentOpacity);
- if (currentOpacity != windowOpacity) {
- dfbWindow->SetOpacity(dfbWindow, windowOpacity);
- }
-
- screen->flipSurface(dfbSurface, flipFlags, region, offset);
-#else
- setOpaque(windowOpacity == 0xff);
- if (mode == Offscreen) {
- screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0);
- } else {
- screen->flipSurface(dfbSurface, flipFlags, region, offset);
- }
-#endif
-
-#ifdef QT_DIRECTFB_TIMING
- enum { Secs = 3 };
- ++frames;
- if (timer.elapsed() >= Secs * 1000) {
- qDebug("%d fps", int(double(frames) / double(Secs)));
- frames = 0;
- timer.restart();
- }
-#endif
- flushPending = false;
-}
-
-void QDirectFBWindowSurface::beginPaint(const QRegion &region)
-{
- if (!engine) {
- engine = new QDirectFBPaintEngine(this);
- }
-
- if (dfbSurface) {
- const QWidget *win = window();
- if (win && win->testAttribute(Qt::WA_NoSystemBackground)) {
- QDirectFBScreen::solidFill(dfbSurface, Qt::transparent, region);
- }
- }
- flushPending = true;
-}
-
-void QDirectFBWindowSurface::endPaint(const QRegion &)
-{
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- unlockSurface();
-#endif
-}
-
-IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const
-{
- return dfbSurface;
-}
-
-
-IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const
-{
- Q_ASSERT(widget);
- if (!dfbSurface)
- return 0;
- QWidget *win = window();
- Q_ASSERT(win);
- if (rect) {
- if (win == widget) {
- *rect = widget->rect();
- } else {
- *rect = QRect(widget->mapTo(win, QPoint(0, 0)), widget->size());
- }
- }
-
- Q_ASSERT(win == widget || win->isAncestorOf(widget));
- return dfbSurface;
-}
-
-void QDirectFBWindowSurface::releaseSurface()
-{
- if (dfbSurface) {
-#ifdef QT_DIRECTFB_SUBSURFACE
- releaseSubSurface();
-#else
- unlockSurface();
-#endif
-#ifdef QT_NO_DIRECTFB_WM
- Q_ASSERT(screen->primarySurface());
- if (dfbSurface != screen->primarySurface())
-#endif
-
- dfbSurface->Release(dfbSurface);
- dfbSurface = 0;
- }
-}
-
-void QDirectFBWindowSurface::updateIsOpaque()
-{
- const QWidget *win = window();
- Q_ASSERT(win);
- if (win->testAttribute(Qt::WA_OpaquePaintEvent) || win->testAttribute(Qt::WA_PaintOnScreen)) {
- setOpaque(true);
- return;
- }
-
- if (qFuzzyCompare(static_cast<float>(win->windowOpacity()), 1.0f)) {
- const QPalette &pal = win->palette();
-
- if (win->autoFillBackground()) {
- const QBrush &autoFillBrush = pal.brush(win->backgroundRole());
- if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
- setOpaque(true);
- return;
- }
- }
-
- if (win->isWindow() && !win->testAttribute(Qt::WA_NoSystemBackground)) {
- const QBrush &windowBrush = win->palette().brush(QPalette::Window);
- if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
- setOpaque(true);
- return;
- }
- }
- }
- setOpaque(false);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
deleted file mode 100644
index df9baa1ff2..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECFBWINDOWSURFACE_H
-#define QDIRECFBWINDOWSURFACE_H
-
-#include "qdirectfbpaintengine.h"
-#include "qdirectfbpaintdevice.h"
-#include "qdirectfbscreen.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include <private/qpaintengine_raster_p.h>
-#include <private/qwindowsurface_qws_p.h>
-
-#ifdef QT_DIRECTFB_TIMING
-#include <qdatetime.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice
-{
-public:
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr);
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget);
- ~QDirectFBWindowSurface();
-
-#ifdef QT_DIRECTFB_WM
- void raise();
-#endif
- bool isValid() const;
-
- void setGeometry(const QRect &rect);
-
- QString key() const { return QLatin1String("directfb"); }
- QByteArray permanentState() const;
- void setPermanentState(const QByteArray &state);
-
- bool scroll(const QRegion &area, int dx, int dy);
-
- bool move(const QPoint &offset);
-
- QImage image() const { return QImage(); }
- QPaintDevice *paintDevice() { return this; }
-
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
- void beginPaint(const QRegion &);
- void endPaint(const QRegion &);
-
- IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const;
- IDirectFBSurface *directFBSurface() const;
-#ifdef QT_DIRECTFB_WM
- IDirectFBWindow *directFBWindow() const;
-#endif
-private:
- void updateIsOpaque();
- void setOpaque(bool opaque);
- void releaseSurface();
-
-#ifdef QT_DIRECTFB_WM
- void createWindow(const QRect &rect);
- IDirectFBWindow *dfbWindow;
-#else
- enum Mode {
- Primary,
- Offscreen
- } mode;
-#endif
-
- DFBSurfaceFlipFlags flipFlags;
- bool boundingRectFlip;
- bool flushPending;
-#ifdef QT_DIRECTFB_TIMING
- int frames;
- QTime timer;
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-
-#endif // QDIRECFBWINDOWSURFACE_H
diff --git a/src/plugins/gfxdrivers/eglnullws/README b/src/plugins/gfxdrivers/eglnullws/README
deleted file mode 100644
index 80b88c7e01..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/README
+++ /dev/null
@@ -1,48 +0,0 @@
-EGL NullWS QScreen Driver
-=========================
-
-If your application draws everything within a single full-screen QGLWidget then
-you may wish to use this QScreen plugin driver. This driver simply returns 0
-(as a EGLNativeWindowType value) when asked by the QtOpenGl module to create a
-native window. Some OpenGL ES implementations (including PowerVR) interpret this
-to mean that a full-screen OpenGL context is desired without any windowing
-support (NullWS).
-
-To tell a Qt/Embedded application to use this driver use the -display command
-line option or the QWS_DISPLAY environment variable. The following driver
-options are supported:
-
-size=WIDTHxHEIGHT Screen size reported by the driver
-format=FORMAT Screen format
-
-Run with '-display eglnullws:help' to get a full list of options (including a
-list of supported format strings).
-
-If you choose a screen format that is not supported by the hardware then the
-QtOpenGl module will write out a list of supported EGL configurations. Use
-one of the supported screen formats from this list.
-
-Using this driver with PowerVR hardware
----------------------------------------
-
-Using this plugin with PowerVR hardware should give a significant speedup
-compared to running with the Qt powervr driver (with a full-screen QGLWidget).
-This is because sacrificing the window system allows less work to be done in
-order to get graphics on the screen. Using this driver also avoids the memory
-fragmentation issues present in the powervr driver and avoids any direct
-dependencies on the deprecated PVR2D API from Imagination Technologies.
-
-To use this driver ensure you have /etc/powervr.ini with contents similar to
-this:
-
-[default]
-WindowSystem=libpvrPVR2D_FLIPWSEGL.so
-
-This driver will also function with libpvrPVR2D_FRONTWSEGL.so, but that draws
-straight into the framebuffer and will therefore cause flickering (it can be
-useful for performance testing though). The flip plugin uses triple buffering,
-so you will need to set the virtual vertical resolution of your framebuffer to
-be three times the physical vertical resolution of your screen. This can be
-done with 'fbset -vyres'. Failure to do this can cause system crashes. You
-should also ensure that the plugin you choose in powervr.ini is in your library
-path (it may just silently default to the flip plugin if not).
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro
deleted file mode 100644
index cb65c2b627..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TARGET = qeglnullws
-load(qt_plugin)
-
-CONFIG += warn_on
-QT += opengl
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-HEADERS = eglnullwsscreen.h \
- eglnullwsscreenplugin.h \
- eglnullwswindowsurface.h
-
-SOURCES = eglnullwsscreen.cpp \
- eglnullwsscreenplugin.cpp \
- eglnullwswindowsurface.cpp
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp
deleted file mode 100644
index e8c73cf31d..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "eglnullwsscreen.h"
-#include "eglnullwswindowsurface.h"
-#include "eglnullwsscreenplugin.h"
-
-#include <QHash>
-#include <QDebug>
-
-namespace
-{
- class EGLNullWSScreenSurfaceFunctions : public QGLScreenSurfaceFunctions
- {
- public:
- virtual bool createNativeWindow(QWidget *, EGLNativeWindowType *native)
- { *native = 0; return true; }
- };
-}
-
-EGLNullWSScreen::EGLNullWSScreen(int displayId) : QGLScreen(displayId) {}
-
-EGLNullWSScreen::~EGLNullWSScreen() {}
-
-bool EGLNullWSScreen::initDevice()
-{
- setSurfaceFunctions(new EGLNullWSScreenSurfaceFunctions);
- return true;
-}
-
-static const QHash<QString, QImage::Format> formatDictionary()
-{
- QHash<QString, QImage::Format> dictionary;
- dictionary["rgb32"] = QImage::Format_RGB32;
- dictionary["argb32"] = QImage::Format_ARGB32;
- dictionary["rgb16"] = QImage::Format_RGB16;
- dictionary["rgb666"] = QImage::Format_RGB666;
- dictionary["rgb555"] = QImage::Format_RGB555;
- dictionary["rgb888"] = QImage::Format_RGB888;
- dictionary["rgb444"] = QImage::Format_RGB444;
- return dictionary;
-}
-
-static int depthForFormat(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_RGB32: return 32;
- case QImage::Format_ARGB32: return 32;
- case QImage::Format_RGB16: return 16;
- case QImage::Format_RGB666: return 24;
- case QImage::Format_RGB555: return 16;
- case QImage::Format_RGB888: return 24;
- case QImage::Format_RGB444: return 16;
- default:
- Q_ASSERT_X(false, "EGLNullWSScreen", "Unknown format");
- return -1;
- }
-}
-
-static void printHelp(const QHash<QString, QImage::Format> &formatDictionary)
-{
- QByteArray formatsBuf;
- QTextStream(&formatsBuf) << QStringList(formatDictionary.keys()).join(", ");
- qWarning(
- "%s: Valid options are:\n"
- "size=WIDTHxHEIGHT Screen size reported by this driver\n"
- "format=FORMAT Screen format, where FORMAT is one of the following:\n"
- " %s\n",
- PluginName,
- formatsBuf.constData());
-}
-
-bool EGLNullWSScreen::connect(const QString &displaySpec)
-{
- const QStringList args = displaySpec.section(':', 1).split(':', QString::SkipEmptyParts);
- const QHash<QString, QImage::Format> formatDict = formatDictionary();
- Q_FOREACH(const QString arg, args) {
- const QString optionName = arg.section('=', 0, 0);
- const QString optionArg = arg.section('=', 1);
- if (optionName == QLatin1String("size")) {
- w = optionArg.section('x', 0, 0).toInt();
- h = optionArg.section('x', 1, 1).toInt();
- } else if (optionName == QLatin1String("format")) {
- if (formatDict.contains(optionArg))
- setPixelFormat(formatDict.value(optionArg));
- else
- printHelp(formatDict);
- } else {
- printHelp(formatDict);
- }
- }
-
- if (w == 0 || h == 0) {
- w = 640;
- h = 480;
- qWarning("%s: Using default screen size %dx%d", PluginName, w, h);
- }
- dw = w;
- dh = h;
-
- if (pixelFormat() == QImage::Format_Invalid) {
- qWarning("%s: Using default screen format argb32", PluginName);
- setPixelFormat(QImage::Format_ARGB32);
- }
- d = depthForFormat(pixelFormat());
-
- static const int Dpi = 120;
- static const qreal ScalingFactor = static_cast<qreal>(25.4) / Dpi;
- physWidth = qRound(dw * ScalingFactor);
- physHeight = qRound(dh * ScalingFactor);
-
- return true;
-}
-
-void EGLNullWSScreen::disconnect() {}
-
-void EGLNullWSScreen::shutdownDevice() {}
-
-void EGLNullWSScreen::setMode(int /*width*/, int /*height*/, int /*depth*/) {}
-
-void EGLNullWSScreen::blank(bool /*on*/) {}
-
-void EGLNullWSScreen::exposeRegion(QRegion /*r*/, int /*changing*/) {}
-
-QWSWindowSurface* EGLNullWSScreen::createSurface(QWidget *widget) const
-{
- if (qobject_cast<QGLWidget*>(widget)) {
- return new EGLNullWSWindowSurface(widget);
- } else {
- qWarning("%s: Creating non-GL surface", PluginName);
- return QScreen::createSurface(widget);
- }
-}
-
-QWSWindowSurface* EGLNullWSScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("eglnullws")) {
- return new EGLNullWSWindowSurface;
- } else {
- qWarning("%s: Creating non-GL surface", PluginName);
- return QScreen::createSurface(key);
- }
-}
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h
deleted file mode 100644
index 8295e5daaa..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef EGLNULLWSSCREEN
-#define EGLNULLWSSCREEN
-
-#include <QGLScreen>
-
-class EGLNullWSScreen : public QGLScreen
-{
-public:
- EGLNullWSScreen(int displayId);
- ~EGLNullWSScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
-
- void setMode(int width, int height, int depth);
- void blank(bool on);
-
- void exposeRegion(QRegion r, int changing);
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
- bool hasOpenGL() { return true; }
-};
-
-#endif // EGLNULLWSSCREEN
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp
deleted file mode 100644
index ebae53d8c4..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "eglnullwsscreenplugin.h"
-#include "eglnullwsscreen.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class EGLNullWSScreenPlugin : public QScreenDriverPlugin
-{
-public:
- virtual QStringList keys() const;
- virtual QScreen *create(const QString& driver, int displayId);
-};
-
-QStringList EGLNullWSScreenPlugin::keys() const
-{
- return QStringList() << QLatin1String(PluginName);
-}
-
-QScreen *EGLNullWSScreenPlugin::create(const QString& driver, int displayId)
-{
- return (driver.toLower() == QLatin1String(PluginName) ?
- new EGLNullWSScreen(displayId) : 0);
-}
-
-Q_EXPORT_PLUGIN2(qeglnullws, EGLNullWSScreenPlugin)
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h
deleted file mode 100644
index c0e5c2a524..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef EGLNULLWSSCREENPLUGIN_H
-#define EGLNULLWSSCREENPLUGIN_H
-
-const char *const PluginName = "eglnullws";
-
-#endif // EGLNULLWSSCREENPLUGIN_H
diff --git a/src/plugins/gfxdrivers/gfxdrivers.pro b/src/plugins/gfxdrivers/gfxdrivers.pro
deleted file mode 100644
index 1f38942a50..0000000000
--- a/src/plugins/gfxdrivers/gfxdrivers.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = subdirs
-contains(gfx-plugins, ahi) :SUBDIRS += ahi
-contains(gfx-plugins, directfb) :SUBDIRS += directfb
-contains(gfx-plugins, linuxfb) :SUBDIRS += linuxfb
-contains(gfx-plugins, qvfb) :SUBDIRS += qvfb
-contains(gfx-plugins, vnc) :SUBDIRS += vnc
-contains(gfx-plugins, transformed) :SUBDIRS += transformed
-contains(gfx-plugins, svgalib) :SUBDIRS += svgalib
-contains(gfx-plugins, powervr) :SUBDIRS += powervr
-contains(gfx-plugins, eglnullws) :SUBDIRS += eglnullws
diff --git a/src/plugins/gfxdrivers/linuxfb/linuxfb.pro b/src/plugins/gfxdrivers/linuxfb/linuxfb.pro
deleted file mode 100644
index 2bbe910e63..0000000000
--- a/src/plugins/gfxdrivers/linuxfb/linuxfb.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qscreenlinuxfb
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_LINUXFB
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qscreenlinuxfb_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreenlinuxfb_qws.cpp
diff --git a/src/plugins/gfxdrivers/linuxfb/main.cpp b/src/plugins/gfxdrivers/linuxfb/main.cpp
deleted file mode 100644
index 187237f042..0000000000
--- a/src/plugins/gfxdrivers/linuxfb/main.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreenlinuxfb_qws.h>
-#include <qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-class QScreenLinuxFbPlugin : public QScreenDriverPlugin
-{
-public:
- QScreenLinuxFbPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-QScreenLinuxFbPlugin::QScreenLinuxFbPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList QScreenLinuxFbPlugin::keys() const
-{
- QStringList list;
- list << QLatin1String("LinuxFb");
- return list;
-}
-
-QScreen* QScreenLinuxFbPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() == QLatin1String("linuxfb"))
- return new QLinuxFbScreen(displayId);
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(qscreenlinuxfb, QScreenLinuxFbPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro b/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro
deleted file mode 100644
index 595cf45301..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro
+++ /dev/null
@@ -1,26 +0,0 @@
-TEMPLATE = lib
-TARGET = pvrQWSWSEGL
-CONFIG += dll warn_on
-CONFIG -= qt
-
-HEADERS+=\
- pvrqwsdrawable.h \
- pvrqwsdrawable_p.h
-
-SOURCES+=\
- pvrqwsdrawable.c \
- pvrqwswsegl.c
-
-INCLUDEPATH += $$QMAKE_INCDIR_EGL
-
-for(p, QMAKE_LIBDIR_EGL) {
- exists($$p):LIBS += -L$$p
-}
-
-LIBS += -lpvr2d
-
-DESTDIR = $$QMAKE_LIBDIR_QT
-target.path = $$[QT_INSTALL_LIBS]
-INSTALLS += target
-
-include(../powervr.pri) \ No newline at end of file
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c
deleted file mode 100644
index c453279155..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c
+++ /dev/null
@@ -1,830 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvrqwsdrawable_p.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <linux/fb.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-PvrQwsDisplay pvrQwsDisplay;
-
-static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable);
-
-/* Initialize the /dev/fbN device for a specific screen */
-static int pvrQwsInitFbScreen(int screen)
-{
- struct fb_var_screeninfo var;
- struct fb_fix_screeninfo fix;
- unsigned long start;
- unsigned long length;
- int width, height, stride;
- PVR2DFORMAT format;
- void *mapped;
- int fd, bytesPerPixel;
- char name[64];
- PVR2DMEMINFO *memInfo;
- unsigned long pageAddresses[2];
-
- /* Bail out if already initialized, or the number is incorrect */
- if (screen < 0 || screen >= PVRQWS_MAX_SCREENS)
- return 0;
- if (pvrQwsDisplay.screens[screen].initialized)
- return 1;
-
- /* Open the framebuffer and fetch its properties */
- sprintf(name, "/dev/fb%d", screen);
- fd = open(name, O_RDWR, 0);
- if (fd < 0) {
- perror(name);
- return 0;
- }
- if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0) {
- perror("FBIOGET_VSCREENINFO");
- close(fd);
- return 0;
- }
- if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0) {
- perror("FBIOGET_FSCREENINFO");
- close(fd);
- return 0;
- }
- width = var.xres;
- height = var.yres;
- bytesPerPixel = var.bits_per_pixel / 8;
- stride = fix.line_length;
- format = PVR2D_1BPP;
- if (var.bits_per_pixel == 16) {
- if (var.red.length == 5 && var.green.length == 6 &&
- var.blue.length == 5 && var.red.offset == 11 &&
- var.green.offset == 5 && var.blue.offset == 0) {
- format = PVR2D_RGB565;
- }
- if (var.red.length == 4 && var.green.length == 4 &&
- var.blue.length == 4 && var.transp.length == 4 &&
- var.red.offset == 8 && var.green.offset == 4 &&
- var.blue.offset == 0 && var.transp.offset == 12) {
- format = PVR2D_ARGB4444;
- }
- } else if (var.bits_per_pixel == 32) {
- if (var.red.length == 8 && var.green.length == 8 &&
- var.blue.length == 8 && var.transp.length == 8 &&
- var.red.offset == 16 && var.green.offset == 8 &&
- var.blue.offset == 0 && var.transp.offset == 24) {
- format = PVR2D_ARGB8888;
- }
- }
- if (format == PVR2D_1BPP) {
- fprintf(stderr, "%s: could not find a suitable PVR2D pixel format\n", name);
- close(fd);
- return 0;
- }
- start = fix.smem_start;
- length = var.xres_virtual * var.yres_virtual * bytesPerPixel;
-
- if (screen == 0) {
- /* We use PVR2DGetFrameBuffer to map the first screen.
- On some chipsets it is more reliable than using PVR2DMemWrap */
- mapped = 0;
- memInfo = 0;
- } else {
- /* Other screens: map the framebuffer region into memory */
- mapped = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (!mapped || mapped == (void *)(-1)) {
- perror("mmap");
- close(fd);
- return 0;
- }
-
- /* Allocate a PVR2D memory region for the framebuffer */
- memInfo = 0;
- if (pvrQwsDisplay.context) {
- pageAddresses[0] = start & 0xFFFFF000;
- pageAddresses[1] = 0;
- if (PVR2DMemWrap
- (pvrQwsDisplay.context, mapped, PVR2D_WRAPFLAG_CONTIGUOUS,
- length, pageAddresses, &memInfo) != PVR2D_OK) {
- munmap(mapped, length);
- close(fd);
- return 0;
- }
- }
- }
-
- /* We don't need the file descriptor any more */
- close(fd);
-
- /* The framebuffer is ready, so initialize the PvrQwsScreenInfo */
- pvrQwsDisplay.screens[screen].screenRect.x = 0;
- pvrQwsDisplay.screens[screen].screenRect.y = 0;
- pvrQwsDisplay.screens[screen].screenRect.width = width;
- pvrQwsDisplay.screens[screen].screenRect.height = height;
- pvrQwsDisplay.screens[screen].screenStride = stride;
- pvrQwsDisplay.screens[screen].pixelFormat = format;
- pvrQwsDisplay.screens[screen].bytesPerPixel = bytesPerPixel;
- pvrQwsDisplay.screens[screen].screenDrawable = 0;
- if (mapped) {
- /* Don't set these fields if mapped is 0, because PVR2DGetFrameBuffer
- may have already been called and set them */
- pvrQwsDisplay.screens[screen].frameBuffer = memInfo;
- pvrQwsDisplay.screens[screen].mapped = mapped;
- }
- pvrQwsDisplay.screens[screen].mappedLength = length;
- pvrQwsDisplay.screens[screen].screenStart = start;
- pvrQwsDisplay.screens[screen].needsUnmap = (mapped != 0);
- pvrQwsDisplay.screens[screen].initialized = 1;
- return 1;
-}
-
-/* Called when a new drawable is added to ensure that we have a
- PVR2D context and framebuffer PVR2DMEMINFO blocks */
-static int pvrQwsAddDrawable(void)
-{
- int numDevs, screen;
- PVR2DDEVICEINFO *devs;
- unsigned long devId;
- unsigned long pageAddresses[2];
- PVR2DMEMINFO *memInfo;
- PVR2DDISPLAYINFO displayInfo;
-
- /* Bail out early if this is not the first drawable */
- if (pvrQwsDisplay.numDrawables > 0) {
- ++(pvrQwsDisplay.numDrawables);
- return 1;
- }
-
- /* Find the first PVR2D device in the system and open it */
- numDevs = PVR2DEnumerateDevices(0);
- if (numDevs <= 0)
- return 0;
- devs = (PVR2DDEVICEINFO *)malloc(sizeof(PVR2DDEVICEINFO) * numDevs);
- if (!devs)
- return 0;
- if (PVR2DEnumerateDevices(devs) != PVR2D_OK) {
- free(devs);
- return 0;
- }
- devId = devs[0].ulDevID;
- free(devs);
- if (PVR2DCreateDeviceContext(devId, &pvrQwsDisplay.context, 0) != PVR2D_OK)
- return 0;
- pvrQwsDisplay.numFlipBuffers = 0;
- pvrQwsDisplay.flipChain = 0;
- if (PVR2DGetDeviceInfo(pvrQwsDisplay.context, &displayInfo) == PVR2D_OK) {
- if (displayInfo.ulMaxFlipChains > 0 && displayInfo.ulMaxBuffersInChain > 0)
- pvrQwsDisplay.numFlipBuffers = displayInfo.ulMaxBuffersInChain;
- if (pvrQwsDisplay.numFlipBuffers > PVRQWS_MAX_FLIP_BUFFERS)
- pvrQwsDisplay.numFlipBuffers = PVRQWS_MAX_FLIP_BUFFERS;
- }
-
- /* Create the PVR2DMEMINFO blocks for the active framebuffers */
- for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
- if (screen != 0 && pvrQwsDisplay.screens[screen].mapped) {
- pageAddresses[0]
- = pvrQwsDisplay.screens[screen].screenStart & 0xFFFFF000;
- pageAddresses[1] = 0;
- if (PVR2DMemWrap
- (pvrQwsDisplay.context,
- pvrQwsDisplay.screens[screen].mapped,
- PVR2D_WRAPFLAG_CONTIGUOUS,
- pvrQwsDisplay.screens[screen].mappedLength,
- pageAddresses, &memInfo) != PVR2D_OK) {
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
- pvrQwsDisplay.context = 0;
- return 0;
- }
- pvrQwsDisplay.screens[screen].frameBuffer = memInfo;
- } else if (screen == 0) {
- if (PVR2DGetFrameBuffer
- (pvrQwsDisplay.context,
- PVR2D_FB_PRIMARY_SURFACE, &memInfo) != PVR2D_OK) {
- fprintf(stderr, "QWSWSEGL: could not get the primary framebuffer surface\n");
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
- pvrQwsDisplay.context = 0;
- return 0;
- }
- pvrQwsDisplay.screens[screen].frameBuffer = memInfo;
- pvrQwsDisplay.screens[screen].mapped = memInfo->pBase;
- }
- }
-
- /* Create a flip chain for the screen if supported by the hardware */
- pvrQwsDisplay.usePresentBlit = 0;
- if (pvrQwsDisplay.numFlipBuffers > 0) {
- long stride = 0;
- unsigned long flipId = 0;
- unsigned long numBuffers;
- if (PVR2DCreateFlipChain(pvrQwsDisplay.context, 0,
- //PVR2D_CREATE_FLIPCHAIN_SHARED |
- //PVR2D_CREATE_FLIPCHAIN_QUERY,
- pvrQwsDisplay.numFlipBuffers,
- pvrQwsDisplay.screens[0].screenRect.width,
- pvrQwsDisplay.screens[0].screenRect.height,
- pvrQwsDisplay.screens[0].pixelFormat,
- &stride, &flipId, &(pvrQwsDisplay.flipChain))
- == PVR2D_OK) {
- pvrQwsDisplay.screens[0].screenStride = stride;
- PVR2DGetFlipChainBuffers(pvrQwsDisplay.context,
- pvrQwsDisplay.flipChain,
- &numBuffers,
- pvrQwsDisplay.flipBuffers);
- } else {
- pvrQwsDisplay.flipChain = 0;
- pvrQwsDisplay.numFlipBuffers = 0;
- }
-
- /* PVR2DPresentBlt is a little more reliable than PVR2DBlt
- when flip chains are present, even if we cannot create a
- flip chain at the moment */
- pvrQwsDisplay.usePresentBlit = 1;
- }
-
- /* The context is ready to go */
- ++(pvrQwsDisplay.numDrawables);
- return 1;
-}
-
-/* Called when the last drawable is destroyed. The PVR2D context
- will be destroyed but the raw framebuffer memory will stay mapped */
-static void pvrQwsDestroyContext(void)
-{
- int screen;
- for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
- if (pvrQwsDisplay.screens[screen].frameBuffer) {
- PVR2DMemFree
- (pvrQwsDisplay.context,
- pvrQwsDisplay.screens[screen].frameBuffer);
- pvrQwsDisplay.screens[screen].frameBuffer = 0;
- }
- }
-
- if (pvrQwsDisplay.numFlipBuffers > 0)
- PVR2DDestroyFlipChain(pvrQwsDisplay.context, pvrQwsDisplay.flipChain);
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
- pvrQwsDisplay.context = 0;
- pvrQwsDisplay.flipChain = 0;
- pvrQwsDisplay.numFlipBuffers = 0;
- pvrQwsDisplay.usePresentBlit = 0;
-}
-
-int pvrQwsDisplayOpen(void)
-{
- int screen;
-
- /* If the display is already open, increase reference count and return */
- if (pvrQwsDisplay.refCount > 0) {
- ++(pvrQwsDisplay.refCount);
- return 1;
- }
-
- /* Open the framebuffer and map it directly */
- if (!pvrQwsInitFbScreen(0)) {
- --(pvrQwsDisplay.refCount);
- return 0;
- }
-
- /* Clear the other screens. We will create them if they are referenced */
- for (screen = 1; screen < PVRQWS_MAX_SCREENS; ++screen)
- memset(&(pvrQwsDisplay.screens[screen]), 0, sizeof(PvrQwsScreenInfo));
-
- /* The display is open and ready */
- ++(pvrQwsDisplay.refCount);
- return 1;
-}
-
-void pvrQwsDisplayClose(void)
-{
- int screen;
-
- if (pvrQwsDisplay.refCount == 0)
- return;
- if (--(pvrQwsDisplay.refCount) > 0)
- return;
-
- /* Prevent pvrQwsDestroyContext from being called for the time being */
- ++pvrQwsDisplay.numDrawables;
-
- /* Free the screens */
- for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
- PvrQwsScreenInfo *info = &(pvrQwsDisplay.screens[screen]);
- if (info->screenDrawable)
- pvrQwsDestroyDrawableForced(info->screenDrawable);
- if (info->frameBuffer)
- PVR2DMemFree(pvrQwsDisplay.context, info->frameBuffer);
- if (info->mapped && info->needsUnmap)
- munmap(info->mapped, info->mappedLength);
- }
-
- /* Now it is safe to destroy the PVR2D context */
- --pvrQwsDisplay.numDrawables;
- if (pvrQwsDisplay.context)
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
-
- memset(&pvrQwsDisplay, 0, sizeof(pvrQwsDisplay));
-}
-
-int pvrQwsDisplayIsOpen(void)
-{
- return (pvrQwsDisplay.refCount > 0);
-}
-
-/* Ensure that a specific screen has been initialized */
-static int pvrQwsEnsureScreen(int screen)
-{
- if (screen < 0 || screen >= PVRQWS_MAX_SCREENS)
- return 0;
- if (!screen)
- return 1;
- return pvrQwsInitFbScreen(screen);
-}
-
-PvrQwsDrawable *pvrQwsScreenWindow(int screen)
-{
- PvrQwsDrawable *drawable;
-
- if (!pvrQwsEnsureScreen(screen))
- return 0;
-
- drawable = pvrQwsDisplay.screens[screen].screenDrawable;
- if (drawable)
- return drawable;
-
- drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
- if (!drawable)
- return 0;
-
- drawable->type = PvrQwsScreen;
- drawable->screen = screen;
- drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
- drawable->rect = pvrQwsDisplay.screens[screen].screenRect;
- drawable->visibleRects[0] = drawable->rect;
- drawable->numVisibleRects = 1;
- drawable->isFullScreen = 1;
-
- if (!pvrQwsAddDrawable()) {
- free(drawable);
- return 0;
- }
-
- pvrQwsDisplay.screens[screen].screenDrawable = drawable;
-
- return drawable;
-}
-
-PvrQwsDrawable *pvrQwsCreateWindow(int screen, long winId, const PvrQwsRect *rect)
-{
- PvrQwsDrawable *drawable;
-
- if (!pvrQwsEnsureScreen(screen))
- return 0;
-
- drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
- if (!drawable)
- return 0;
-
- drawable->type = PvrQwsWindow;
- drawable->winId = winId;
- drawable->refCount = 1;
- drawable->screen = screen;
- drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
- drawable->rect = *rect;
-
- if (!pvrQwsAddDrawable()) {
- free(drawable);
- return 0;
- }
-
- drawable->nextWinId = pvrQwsDisplay.firstWinId;
- pvrQwsDisplay.firstWinId = drawable;
-
- return drawable;
-}
-
-PvrQwsDrawable *pvrQwsFetchWindow(long winId)
-{
- PvrQwsDrawable *drawable = pvrQwsDisplay.firstWinId;
- while (drawable != 0 && drawable->winId != winId)
- drawable = drawable->nextWinId;
-
- if (drawable)
- ++(drawable->refCount);
- return drawable;
-}
-
-int pvrQwsReleaseWindow(PvrQwsDrawable *drawable)
-{
- if (drawable->type == PvrQwsWindow)
- return (--(drawable->refCount) <= 0);
- else
- return 0;
-}
-
-PvrQwsDrawable *pvrQwsCreatePixmap(int width, int height, int screen)
-{
- PvrQwsDrawable *drawable;
-
- if (!pvrQwsEnsureScreen(screen))
- return 0;
-
- drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
- if (!drawable)
- return 0;
-
- drawable->type = PvrQwsPixmap;
- drawable->screen = screen;
- drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
- drawable->rect.x = 0;
- drawable->rect.y = 0;
- drawable->rect.width = width;
- drawable->rect.height = height;
-
- if (!pvrQwsAddDrawable()) {
- free(drawable);
- return 0;
- }
-
- return drawable;
-}
-
-static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable)
-{
- /* Remove the drawable from the display's winId list */
- PvrQwsDrawable *current = pvrQwsDisplay.firstWinId;
- PvrQwsDrawable *prev = 0;
- while (current != 0 && current != drawable) {
- prev = current;
- current = current->nextWinId;
- }
- if (current != 0) {
- if (prev)
- prev->nextWinId = current->nextWinId;
- else
- pvrQwsDisplay.firstWinId = current->nextWinId;
- }
-
- pvrQwsFreeBuffers(drawable);
- free(drawable);
-
- --pvrQwsDisplay.numDrawables;
- if (pvrQwsDisplay.numDrawables == 0)
- pvrQwsDestroyContext();
-}
-
-void pvrQwsDestroyDrawable(PvrQwsDrawable *drawable)
-{
- if (drawable && drawable->type != PvrQwsScreen)
- pvrQwsDestroyDrawableForced(drawable);
-}
-
-PvrQwsDrawableType pvrQwsGetDrawableType(PvrQwsDrawable *drawable)
-{
- return drawable->type;
-}
-
-void pvrQwsSetVisibleRegion
- (PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects)
-{
- int index, indexOut;
- PvrQwsRect *rect;
- PvrQwsRect *screenRect;
-
- /* Visible regions don't make sense for pixmaps */
- if (drawable->type == PvrQwsPixmap)
- return;
-
- /* Restrict the number of rectangles to prevent buffer overflow */
- if (numRects > PVRQWS_MAX_VISIBLE_RECTS)
- numRects = PVRQWS_MAX_VISIBLE_RECTS;
- if (numRects > 0)
- memcpy(drawable->visibleRects, rects, numRects * sizeof(PvrQwsRect));
-
- /* Convert the rectangles into screen-relative co-ordinates and
- then clamp them to the screen boundaries. If any of the
- clamped rectangles are empty, remove them from the list */
- screenRect = &(pvrQwsDisplay.screens[drawable->screen].screenRect);
- indexOut = 0;
- for (index = 0, rect = drawable->visibleRects; index < numRects; ++index, ++rect) {
- if (rect->x < 0) {
- rect->width += rect->x;
- rect->x = 0;
- if (rect->width < 0)
- rect->width = 0;
- } else if (rect->x >= screenRect->width) {
- rect->x = screenRect->width;
- rect->width = 0;
- }
- if ((rect->x + rect->width) > screenRect->width) {
- rect->width = screenRect->width - rect->x;
- }
- if (rect->y < 0) {
- rect->height += rect->y;
- rect->y = 0;
- if (rect->height < 0)
- rect->height = 0;
- } else if (rect->y >= screenRect->height) {
- rect->y = screenRect->height;
- rect->height = 0;
- }
- if ((rect->y + rect->height) > screenRect->height) {
- rect->height = screenRect->height - rect->y;
- }
- if (rect->width > 0 && rect->height > 0) {
- if (index != indexOut)
- drawable->visibleRects[indexOut] = *rect;
- ++indexOut;
- }
- }
- drawable->numVisibleRects = indexOut;
-}
-
-void pvrQwsClearVisibleRegion(PvrQwsDrawable *drawable)
-{
- if (drawable->type != PvrQwsPixmap)
- drawable->numVisibleRects = 0;
-}
-
-void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect)
-{
- /* We can only change the geometry of window drawables */
- if (drawable->type != PvrQwsWindow)
- return;
-
- /* If the position has changed, then clear the visible region */
- if (drawable->rect.x != rect->x || drawable->rect.y != rect->y) {
- drawable->rect.x = rect->x;
- drawable->rect.y = rect->y;
- drawable->numVisibleRects = 0;
- }
-
- /* If the size has changed, then clear the visible region and
- invalidate the drawable's buffers. Invalidating the buffers
- will force EGL to recreate the drawable, which will then
- allocate new buffers for the new size */
- if (drawable->rect.width != rect->width ||
- drawable->rect.height != rect->height) {
- drawable->rect.width = rect->width;
- drawable->rect.height = rect->height;
- drawable->numVisibleRects = 0;
- pvrQwsInvalidateBuffers(drawable);
- }
-}
-
-void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect)
-{
- *rect = drawable->rect;
-}
-
-void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
-{
- if (drawable->rotationAngle != angle) {
- drawable->rotationAngle = angle;
-
- /* Force the buffers to be recreated if the rotation angle changes */
- pvrQwsInvalidateBuffers(drawable);
- }
-}
-
-int pvrQwsGetStride(PvrQwsDrawable *drawable)
-{
- if (drawable->backBuffersValid)
- return drawable->strideBytes;
- else
- return 0;
-}
-
-PvrQwsPixelFormat pvrQwsGetPixelFormat(PvrQwsDrawable *drawable)
-{
- return (PvrQwsPixelFormat)(drawable->pixelFormat);
-}
-
-void *pvrQwsGetRenderBuffer(PvrQwsDrawable *drawable)
-{
- if (drawable->backBuffersValid)
- return drawable->backBuffers[drawable->currentBackBuffer]->pBase;
- else
- return 0;
-}
-
-int pvrQwsAllocBuffers(PvrQwsDrawable *drawable)
-{
- int index;
- int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
- if (drawable->type == PvrQwsPixmap)
- numBuffers = 1;
- if (drawable->backBuffers[0]) {
- if (drawable->backBuffersValid)
- return 1;
- if (!drawable->usingFlipBuffers) {
- for (index = 0; index < numBuffers; ++index)
- PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
- }
- }
- drawable->stridePixels = (drawable->rect.width + 31) & ~31;
- drawable->strideBytes =
- drawable->stridePixels *
- pvrQwsDisplay.screens[drawable->screen].bytesPerPixel;
- drawable->usingFlipBuffers =
- (pvrQwsDisplay.numFlipBuffers > 0 && drawable->isFullScreen);
- if (drawable->usingFlipBuffers) {
- if (numBuffers > (int)(pvrQwsDisplay.numFlipBuffers))
- numBuffers = pvrQwsDisplay.numFlipBuffers;
- for (index = 0; index < numBuffers; ++index)
- drawable->backBuffers[index] = pvrQwsDisplay.flipBuffers[index];
- } else {
- for (index = 0; index < numBuffers; ++index) {
- if (PVR2DMemAlloc(pvrQwsDisplay.context,
- drawable->strideBytes * drawable->rect.height,
- 128, 0,
- &(drawable->backBuffers[index])) != PVR2D_OK) {
- while (--index >= 0)
- PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
- memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
- drawable->backBuffersValid = 0;
- return 0;
- }
- }
- }
- for (index = numBuffers; index < PVRQWS_MAX_BACK_BUFFERS; ++index) {
- drawable->backBuffers[index] = drawable->backBuffers[0];
- }
- drawable->backBuffersValid = 1;
- drawable->currentBackBuffer = 0;
- return 1;
-}
-
-void pvrQwsFreeBuffers(PvrQwsDrawable *drawable)
-{
- int index;
- int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
- if (drawable->type == PvrQwsPixmap)
- numBuffers = 1;
- if (!drawable->usingFlipBuffers) {
- for (index = 0; index < numBuffers; ++index) {
- if (drawable->backBuffers[index])
- PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
- }
- }
- memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
- drawable->backBuffersValid = 0;
- drawable->usingFlipBuffers = 0;
-}
-
-void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable)
-{
- drawable->backBuffersValid = 0;
-}
-
-int pvrQwsGetBuffers
- (PvrQwsDrawable *drawable, PVR2DMEMINFO **source, PVR2DMEMINFO **render)
-{
- if (!drawable->backBuffersValid)
- return 0;
- *render = drawable->backBuffers[drawable->currentBackBuffer];
- *source = drawable->backBuffers
- [(drawable->currentBackBuffer + PVRQWS_MAX_BACK_BUFFERS - 1) %
- PVRQWS_MAX_BACK_BUFFERS];
- return 1;
-}
-
-int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly)
-{
- PVR2DMEMINFO *buffer;
- PvrQwsRect *rect;
- int index;
-
- /* Bail out if the back buffers have been invalidated */
- if (!drawable->backBuffersValid)
- return 0;
-
- /* If there is a swap function, then use that instead */
- if (drawable->swapFunction) {
- (*(drawable->swapFunction))(drawable, drawable->userData, repaintOnly);
- if (!repaintOnly) {
- drawable->currentBackBuffer
- = (drawable->currentBackBuffer + 1) % PVRQWS_MAX_BACK_BUFFERS;
- }
- return 1;
- }
-
- /* Iterate through the visible rectangles and blit them to the screen */
- if (!repaintOnly) {
- index = drawable->currentBackBuffer;
- } else {
- index = (drawable->currentBackBuffer + PVRQWS_MAX_BACK_BUFFERS - 1)
- % PVRQWS_MAX_BACK_BUFFERS;
- }
- buffer = drawable->backBuffers[index];
- rect = drawable->visibleRects;
- if (drawable->usingFlipBuffers) {
- PVR2DPresentFlip(pvrQwsDisplay.context, pvrQwsDisplay.flipChain, buffer, 0);
- } else if (pvrQwsDisplay.usePresentBlit && drawable->numVisibleRects > 0) {
- PVR2DRECT pvrRects[PVRQWS_MAX_VISIBLE_RECTS];
- for (index = 0; index < drawable->numVisibleRects; ++index, ++rect) {
- pvrRects[index].left = rect->x;
- pvrRects[index].top = rect->y;
- pvrRects[index].right = rect->x + rect->width;
- pvrRects[index].bottom = rect->y + rect->height;
- }
- for (index = 0; index < drawable->numVisibleRects; index += 4) {
- int numClip = drawable->numVisibleRects - index;
- if (numClip > 4) /* No more than 4 clip rects at a time */
- numClip = 4;
- PVR2DSetPresentBltProperties
- (pvrQwsDisplay.context,
- PVR2D_PRESENT_PROPERTY_SRCSTRIDE |
- PVR2D_PRESENT_PROPERTY_DSTSIZE |
- PVR2D_PRESENT_PROPERTY_DSTPOS |
- PVR2D_PRESENT_PROPERTY_CLIPRECTS,
- drawable->strideBytes,
- drawable->rect.width, drawable->rect.height,
- drawable->rect.x, drawable->rect.y,
- numClip, pvrRects + index, 0);
- PVR2DPresentBlt(pvrQwsDisplay.context, buffer, 0);
- }
- PVR2DQueryBlitsComplete(pvrQwsDisplay.context, buffer, 1);
- } else {
- /* TODO: use PVR2DBltClipped for faster transfers of clipped windows */
- PVR2DBLTINFO blit;
- for (index = 0; index < drawable->numVisibleRects; ++index, ++rect) {
- memset(&blit, 0, sizeof(blit));
-
- blit.CopyCode = PVR2DROPcopy;
- blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
-
- blit.pSrcMemInfo = buffer;
- blit.SrcStride = drawable->strideBytes;
- blit.SrcX = rect->x - drawable->rect.x;
- blit.SrcY = rect->y - drawable->rect.y;
- blit.SizeX = rect->width;
- blit.SizeY = rect->height;
- blit.SrcFormat = drawable->pixelFormat;
-
- blit.pDstMemInfo = pvrQwsDisplay.screens[drawable->screen].frameBuffer;
- blit.DstStride = pvrQwsDisplay.screens[drawable->screen].screenStride;
- blit.DstX = rect->x;
- blit.DstY = rect->y;
- blit.DSizeX = rect->width;
- blit.DSizeY = rect->height;
- blit.DstFormat = pvrQwsDisplay.screens[drawable->screen].pixelFormat;
-
- PVR2DBlt(pvrQwsDisplay.context, &blit);
- }
- }
-
- /* Swap the buffers */
- if (!repaintOnly) {
- drawable->currentBackBuffer
- = (drawable->currentBackBuffer + 1) % PVRQWS_MAX_BACK_BUFFERS;
- }
- return 1;
-}
-
-void pvrQwsSetSwapFunction
- (PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData)
-{
- drawable->swapFunction = func;
- drawable->userData = userData;
-}
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h
deleted file mode 100644
index 40119b0a41..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVRQWSDRAWABLE_H
-#define PVRQWSDRAWABLE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- int x, y, width, height;
-} PvrQwsRect;
-
-typedef enum
-{
- PvrQwsScreen,
- PvrQwsWindow,
- PvrQwsPixmap
-
-} PvrQwsDrawableType;
-
-typedef enum
-{
- PvrQws_1BPP = 0,
- PvrQws_RGB565,
- PvrQws_ARGB4444,
- PvrQws_RGB888,
- PvrQws_ARGB8888,
- PvrQws_VGAEMU
-
-} PvrQwsPixelFormat;
-
-typedef struct _PvrQwsDrawable PvrQwsDrawable;
-
-typedef void (*PvrQwsSwapFunction)
- (PvrQwsDrawable *drawable, void *userData, int repaintOnly);
-
-/* Open the display and prepare for window operations. The display
- can be opened multiple times and each time is reference counted.
- The display will be finally closed when the same number of
- calls to pvrQwsDisplayClose() have been encountered */
-int pvrQwsDisplayOpen(void);
-
-/* Close the display */
-void pvrQwsDisplayClose(void);
-
-/* Determine if the display is already open */
-int pvrQwsDisplayIsOpen(void);
-
-/* Create a window that represents a particular framebuffer screen.
- Initially the visible region will be the whole screen. If the screen
- window has already been created, then will return the same value */
-PvrQwsDrawable *pvrQwsScreenWindow(int screen);
-
-/* Create a top-level window on a particular framebuffer screen.
- Initially the window will not have a visible region */
-PvrQwsDrawable *pvrQwsCreateWindow(int screen, long winId, const PvrQwsRect *rect);
-
-/* Fetch an existing window for a window id and increase its refcount */
-PvrQwsDrawable *pvrQwsFetchWindow(long winId);
-
-/* Release the refcount on a window. Returns 1 if refcount is zero */
-int pvrQwsReleaseWindow(PvrQwsDrawable *drawable);
-
-/* Create an off-screen pixmap */
-PvrQwsDrawable *pvrQwsCreatePixmap(int width, int height, int screen);
-
-/* Destroy a previously-created drawable. Will not destroy screens. */
-void pvrQwsDestroyDrawable(PvrQwsDrawable *drawable);
-
-/* Get a drawable's type */
-PvrQwsDrawableType pvrQwsGetDrawableType(PvrQwsDrawable *drawable);
-
-/* Sets the visible region for a window or screen drawable. Pixels within
- the specified rectangles will be copied to the framebuffer when the window
- or screen is swapped. The rectangles should be in global co-ordinates */
-void pvrQwsSetVisibleRegion
- (PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects);
-
-/* Clear the visible region for a window or screen drawable,
- effectively removing it from the screen */
-void pvrQwsClearVisibleRegion(PvrQwsDrawable *drawable);
-
-/* Set the geometry for a drawable. This can only be used on windows */
-void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect);
-
-/* Get the current geometry for a drawable */
-void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect);
-
-/* Set the rotation angle in degrees */
-void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle);
-
-/* Get the line stride for a drawable. Returns zero if the buffers
- are not allocated or have been invalidated */
-int pvrQwsGetStride(PvrQwsDrawable *drawable);
-
-/* Get the pixel format for a drawable */
-PvrQwsPixelFormat pvrQwsGetPixelFormat(PvrQwsDrawable *drawable);
-
-/* Get a pointer to the beginning of a drawable's current render buffer.
- Returns null if the buffers are not allocated or have been invalidated */
-void *pvrQwsGetRenderBuffer(PvrQwsDrawable *drawable);
-
-/* Allocate the buffers associated with a drawable. We allocate one buffer
- for pixmaps, and several for windows and screens */
-int pvrQwsAllocBuffers(PvrQwsDrawable *drawable);
-
-/* Free the buffers associated with a drawable */
-void pvrQwsFreeBuffers(PvrQwsDrawable *drawable);
-
-/* Invalidate the buffers associated with a drawable. The buffers will
- still be allocated but the next attempt to swap the buffers will fail */
-void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable);
-
-/* Swap the back buffers for a window or screen and copy to the framebuffer */
-int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly);
-
-/* Set the swap function for a drawable. When pvrQwsSwapBuffers()
- is called on the drawable, the supplied function will be called
- instead of copying the drawable contents to the screen. This allows
- higher-level compositors to know when a drawable has changed.
- The swap function can be set to null to return to normal processing */
-void pvrQwsSetSwapFunction
- (PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h
deleted file mode 100644
index b20dc023d6..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVRQWSDRAWABLE_P_H
-#define PVRQWSDRAWABLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// reasons. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <pvr2d.h>
-#include "pvrqwsdrawable.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PVRQWS_MAX_VISIBLE_RECTS 32
-#define PVRQWS_MAX_SCREENS 1
-#define PVRQWS_MAX_BACK_BUFFERS 2
-#define PVRQWS_MAX_FLIP_BUFFERS 2
-
-typedef struct {
-
- PvrQwsRect screenRect;
- int screenStride;
- PVR2DFORMAT pixelFormat;
- int bytesPerPixel;
- PVR2DMEMINFO *frameBuffer;
- PvrQwsDrawable *screenDrawable;
- void *mapped;
- int mappedLength;
- unsigned long screenStart;
- int needsUnmap;
- int initialized;
-
-} PvrQwsScreenInfo;
-
-typedef struct {
-
- int refCount;
- PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS];
- PVR2DCONTEXTHANDLE context;
- int numDrawables;
- unsigned long numFlipBuffers;
- PVR2DFLIPCHAINHANDLE flipChain;
- PVR2DMEMINFO *flipBuffers[PVRQWS_MAX_FLIP_BUFFERS];
- int usePresentBlit;
- PvrQwsDrawable *firstWinId;
-
-} PvrQwsDisplay;
-
-extern PvrQwsDisplay pvrQwsDisplay;
-
-struct _PvrQwsDrawable
-{
- PvrQwsDrawableType type;
- long winId;
- int refCount;
- PvrQwsRect rect;
- int screen;
- PVR2DFORMAT pixelFormat;
- PvrQwsRect visibleRects[PVRQWS_MAX_VISIBLE_RECTS];
- int numVisibleRects;
- PVR2DMEMINFO *backBuffers[PVRQWS_MAX_BACK_BUFFERS];
- int currentBackBuffer;
- int backBuffersValid;
- int usingFlipBuffers;
- int isFullScreen;
- int strideBytes;
- int stridePixels;
- int rotationAngle;
- PvrQwsSwapFunction swapFunction;
- void *userData;
- PvrQwsDrawable *nextWinId;
-
-};
-
-/* Get the current source and render buffers for a drawable */
-int pvrQwsGetBuffers
- (PvrQwsDrawable *drawable, PVR2DMEMINFO **source, PVR2DMEMINFO **render);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c
deleted file mode 100644
index ce99e607f2..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <GLES/eglplatform.h>
-#include <wsegl.h>
-#include <pvr2d.h>
-#include <string.h>
-#include <sys/mman.h>
-#include "pvrqwsdrawable_p.h"
-
-#define WSEGL_UNUSED(x) (void)x;
-
-// If the PVR2D version is not specified, then assume MBX-style headers.
-// If the version is defined, then we assume that we have SGX-style headers.
-#if !defined(PVR2D_REV_MAJOR)
-#define WSEGL_CAP_WINDOWS_USE_HW_SYNC WSEGL_CAP_WINDOWS_USE_MBX_SYNC
-#define WSEGL_CAP_PIXMAPS_USE_HW_SYNC WSEGL_CAP_PIXMAPS_USE_MBX_SYNC
-#endif
-
-/* Capability information for the display */
-static WSEGLCaps const wseglDisplayCaps[] = {
- {WSEGL_CAP_WINDOWS_USE_HW_SYNC, 1},
- {WSEGL_CAP_PIXMAPS_USE_HW_SYNC, 1},
- {WSEGL_NO_CAPS, 0}
-};
-
-/* Configuration information for the display */
-static WSEGLConfig wseglDisplayConfigs[] = {
- {WSEGL_DRAWABLE_WINDOW, WSEGL_PIXELFORMAT_565, WSEGL_FALSE,
- 0, 0, 0, WSEGL_OPAQUE, 0},
- {WSEGL_DRAWABLE_PIXMAP, WSEGL_PIXELFORMAT_565, WSEGL_FALSE,
- 0, 0, 0, WSEGL_OPAQUE, 0},
- {WSEGL_NO_DRAWABLE, 0, 0, 0, 0, 0, 0, 0}
-};
-
-/* Determine if nativeDisplay is a valid display handle */
-static WSEGLError wseglIsDisplayValid(NativeDisplayType nativeDisplay)
-{
- /* We only have the default display in this system */
- if (nativeDisplay == WSEGL_DEFAULT_DISPLAY)
- return WSEGL_SUCCESS;
- else
- return WSEGL_BAD_NATIVE_DISPLAY;
-}
-
-/* Initialize a native display for use with WSEGL */
-static WSEGLError wseglInitializeDisplay
- (NativeDisplayType nativeDisplay, WSEGLDisplayHandle *display,
- const WSEGLCaps **caps, WSEGLConfig **configs)
-{
- WSEGLPixelFormat pixelFormat;
-
- /* Bail out if the native display is incorrect */
- if (nativeDisplay != WSEGL_DEFAULT_DISPLAY)
- return WSEGL_CANNOT_INITIALISE;
-
- /* Open the PVR/QWS display, which will initialize the framebuffer */
- if (!pvrQwsDisplayOpen())
- return WSEGL_CANNOT_INITIALISE;
-
- /* Convert the PVR2D pixel format into a WSEGL pixel format */
- switch (pvrQwsDisplay.screens[0].pixelFormat) {
- case PVR2D_RGB565:
- pixelFormat = WSEGL_PIXELFORMAT_565;
- break;
-
- case PVR2D_ARGB4444:
- pixelFormat = WSEGL_PIXELFORMAT_4444;
- break;
-
- case PVR2D_ARGB8888:
- pixelFormat = WSEGL_PIXELFORMAT_8888;
- break;
-
- default:
- pvrQwsDisplayClose();
- return WSEGL_CANNOT_INITIALISE;
- }
- wseglDisplayConfigs[0].ePixelFormat = pixelFormat;
- wseglDisplayConfigs[1].ePixelFormat = pixelFormat;
-
- /* The display has been initialized */
- *display = (WSEGLDisplayHandle)&pvrQwsDisplay;
- *caps = wseglDisplayCaps;
- *configs = wseglDisplayConfigs;
- return WSEGL_SUCCESS;
-}
-
-/* Close the WSEGL display */
-static WSEGLError wseglCloseDisplay(WSEGLDisplayHandle display)
-{
- if (display == (WSEGLDisplayHandle)&pvrQwsDisplay)
- pvrQwsDisplayClose();
- return WSEGL_SUCCESS;
-}
-
-static WSEGLRotationAngle wseglRotationValue(int degrees)
-{
- switch (degrees) {
- case 90: return WSEGL_ROTATE_90;
- case 180: return WSEGL_ROTATE_180;
- case 270: return WSEGL_ROTATE_270;
- default: return WSEGL_ROTATE_0;
- }
-}
-
-/* Create the WSEGL drawable version of a native window */
-static WSEGLError wseglCreateWindowDrawable
- (WSEGLDisplayHandle display, WSEGLConfig *config,
- WSEGLDrawableHandle *drawable, NativeWindowType nativeWindow,
- WSEGLRotationAngle *rotationAngle)
-{
- PvrQwsDrawable *draw;
-
- WSEGL_UNUSED(display);
- WSEGL_UNUSED(config);
-
- /* Check for special handles that indicate framebuffer screens */
- if (nativeWindow >= (NativeWindowType)0 &&
- nativeWindow < (NativeWindowType)PVRQWS_MAX_SCREENS) {
- PvrQwsDrawable *screen = pvrQwsScreenWindow((int)nativeWindow);
- if (!screen)
- return WSEGL_OUT_OF_MEMORY;
- *drawable = (WSEGLDrawableHandle)screen;
- if (!pvrQwsAllocBuffers(screen))
- return WSEGL_OUT_OF_MEMORY;
- *rotationAngle = wseglRotationValue(screen->rotationAngle);
- return WSEGL_SUCCESS;
- }
-
- /* The native window is the winId - fetch the underlying drawable */
- draw = pvrQwsFetchWindow((long)nativeWindow);
- if (!draw)
- return WSEGL_BAD_DRAWABLE;
-
- /* The drawable is ready to go */
- *drawable = (WSEGLDrawableHandle)draw;
- *rotationAngle = wseglRotationValue(draw->rotationAngle);
- if (!pvrQwsAllocBuffers(draw))
- return WSEGL_OUT_OF_MEMORY;
- return WSEGL_SUCCESS;
-}
-
-/* Create the WSEGL drawable version of a native pixmap */
-static WSEGLError wseglCreatePixmapDrawable
- (WSEGLDisplayHandle display, WSEGLConfig *config,
- WSEGLDrawableHandle *drawable, NativePixmapType nativePixmap,
- WSEGLRotationAngle *rotationAngle)
-{
- WSEGL_UNUSED(display);
- WSEGL_UNUSED(config);
- if (!nativePixmap)
- return WSEGL_BAD_NATIVE_PIXMAP;
- if (!pvrQwsAllocBuffers((PvrQwsDrawable *)nativePixmap))
- return WSEGL_OUT_OF_MEMORY;
- *drawable = (WSEGLDrawableHandle)nativePixmap;
- *rotationAngle = WSEGL_ROTATE_0;
- return WSEGL_SUCCESS;
-}
-
-/* Delete a specific drawable */
-static WSEGLError wseglDeleteDrawable(WSEGLDrawableHandle _drawable)
-{
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- if (!drawable || drawable->type == PvrQwsScreen)
- return WSEGL_SUCCESS;
- if (pvrQwsDisplay.numFlipBuffers == 0)
- pvrQwsFreeBuffers(drawable);
- if (pvrQwsReleaseWindow(drawable))
- pvrQwsDestroyDrawable(drawable);
- return WSEGL_SUCCESS;
-}
-
-/* Swap the contents of a drawable to the screen */
-static WSEGLError wseglSwapDrawable
- (WSEGLDrawableHandle _drawable, unsigned long data)
-{
- WSEGL_UNUSED(data);
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- if (drawable->type != PvrQwsPixmap && !pvrQwsSwapBuffers(drawable, 0))
- return WSEGL_BAD_DRAWABLE;
- else
- return WSEGL_SUCCESS;
-}
-
-/* Set the swap interval of a window drawable */
-static WSEGLError wseglSwapControlInterval
- (WSEGLDrawableHandle drawable, unsigned long interval)
-{
- WSEGL_UNUSED(drawable);
- if (pvrQwsDisplay.flipChain) {
- PVR2DSetPresentFlipProperties
- (pvrQwsDisplay.context, pvrQwsDisplay.flipChain,
- PVR2D_PRESENT_PROPERTY_INTERVAL, 0, 0, 0, NULL, interval);
- }
- return WSEGL_SUCCESS;
-}
-
-/* Flush native rendering requests on a drawable */
-static WSEGLError wseglWaitNative
- (WSEGLDrawableHandle drawable, unsigned long engine)
-{
- WSEGL_UNUSED(drawable);
- if (engine == WSEGL_DEFAULT_NATIVE_ENGINE)
- return WSEGL_SUCCESS;
- else
- return WSEGL_BAD_NATIVE_ENGINE;
-}
-
-/* Copy color data from a drawable to a native pixmap */
-static WSEGLError wseglCopyFromDrawable
- (WSEGLDrawableHandle _drawable, NativePixmapType nativePixmap)
-{
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- PvrQwsDrawable *pixmap = (PvrQwsDrawable *)nativePixmap;
- PVR2DBLTINFO blit;
-
- if (!drawable || !drawable->backBuffersValid)
- return WSEGL_BAD_NATIVE_WINDOW;
- if (!pixmap || !pixmap->backBuffersValid)
- return WSEGL_BAD_NATIVE_PIXMAP;
-
- memset(&blit, 0, sizeof(blit));
-
- blit.CopyCode = PVR2DROPcopy;
- blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
-
- blit.pSrcMemInfo = drawable->backBuffers[drawable->currentBackBuffer];
- blit.SrcStride = drawable->strideBytes;
- blit.SrcX = 0;
- blit.SrcY = 0;
- blit.SizeX = drawable->rect.width;
- blit.SizeY = drawable->rect.height;
- blit.SrcFormat = drawable->pixelFormat;
-
- blit.pDstMemInfo = pixmap->backBuffers[pixmap->currentBackBuffer];
- blit.DstStride = pixmap->strideBytes;
- blit.DstX = 0;
- blit.DstY = 0;
- blit.DSizeX = pixmap->rect.width;
- blit.DSizeY = pixmap->rect.height;
- blit.DstFormat = pixmap->pixelFormat;
-
- PVR2DBlt(pvrQwsDisplay.context, &blit);
- PVR2DQueryBlitsComplete
- (pvrQwsDisplay.context, pixmap->backBuffers[pixmap->currentBackBuffer], 1);
-
- return WSEGL_SUCCESS;
-}
-
-/* Copy color data from a PBuffer to a native pixmap */
-static WSEGLError wseglCopyFromPBuffer
- (void *address, unsigned long width, unsigned long height,
- unsigned long stride, WSEGLPixelFormat format,
- NativePixmapType nativePixmap)
-{
- PvrQwsDrawable *pixmap = (PvrQwsDrawable *)nativePixmap;
- PVR2DFORMAT pixelFormat;
-
- if (!pixmap)
- return WSEGL_BAD_NATIVE_PIXMAP;
-
- /* We can only copy under certain conditions */
- switch (format) {
- case WSEGL_PIXELFORMAT_565:
- pixelFormat = PVR2D_RGB565; break;
- case WSEGL_PIXELFORMAT_4444:
- pixelFormat = PVR2D_ARGB4444; break;
- case WSEGL_PIXELFORMAT_8888:
- pixelFormat = PVR2D_ARGB8888; break;
- default:
- return WSEGL_BAD_CONFIG;
- }
- if (width > (unsigned long)(pixmap->rect.width) ||
- height > (unsigned long)(pixmap->rect.height) ||
- pixelFormat != pixmap->pixelFormat) {
- return WSEGL_BAD_CONFIG;
- }
-
- /* We'd like to use PVR2DBlt to do this, but there is no easy way
- to map the virtual "address" into physical space to be able
- to use the hardware assist. Use memcpy to do the work instead.
- Note: PBuffer's are upside down, so we copy from the bottom up */
- char *srcaddr = (char *)address;
- char *dstaddr = (char *)(pixmap->backBuffers[pixmap->currentBackBuffer]->pBase);
- int dststride = pixmap->strideBytes;
- int srcwidth = ((int)width) * pvrQwsDisplay.screens[0].bytesPerPixel;
- srcaddr += height * stride;
- while (height > 0) {
- srcaddr -= (int)stride;
- memcpy(dstaddr, srcaddr, srcwidth);
- dstaddr += dststride;
- --height;
- }
- return WSEGL_SUCCESS;
-}
-
-/* Return the parameters of a drawable that are needed by the EGL layer */
-static WSEGLError wseglGetDrawableParameters
- (WSEGLDrawableHandle _drawable, WSEGLDrawableParams *sourceParams,
- WSEGLDrawableParams *renderParams)
-{
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- PVR2DMEMINFO *source, *render;
- WSEGLPixelFormat pixelFormat;
-
- if (!pvrQwsGetBuffers(drawable, &source, &render))
- return WSEGL_BAD_DRAWABLE;
-
- switch (drawable->pixelFormat) {
- case PVR2D_RGB565:
- default:
- pixelFormat = WSEGL_PIXELFORMAT_565;
- break;
-
- case PVR2D_ARGB4444:
- pixelFormat = WSEGL_PIXELFORMAT_4444;
- break;
-
- case PVR2D_ARGB8888:
- pixelFormat = WSEGL_PIXELFORMAT_8888;
- break;
- }
-
- sourceParams->ui32Width = drawable->rect.width;
- sourceParams->ui32Height = drawable->rect.height;
- sourceParams->ui32Stride = drawable->stridePixels;
- sourceParams->ePixelFormat = pixelFormat;
- sourceParams->pvLinearAddress = source->pBase;
- sourceParams->ui32HWAddress = source->ui32DevAddr;
- sourceParams->hPrivateData = source->hPrivateData;
-
- renderParams->ui32Width = drawable->rect.width;
- renderParams->ui32Height = drawable->rect.height;
- renderParams->ui32Stride = drawable->stridePixels;
- renderParams->ePixelFormat = pixelFormat;
- renderParams->pvLinearAddress = render->pBase;
- renderParams->ui32HWAddress = render->ui32DevAddr;
- renderParams->hPrivateData = render->hPrivateData;
-
- return WSEGL_SUCCESS;
-}
-
-static WSEGL_FunctionTable const wseglFunctions = {
- WSEGL_VERSION,
- wseglIsDisplayValid,
- wseglInitializeDisplay,
- wseglCloseDisplay,
- wseglCreateWindowDrawable,
- wseglCreatePixmapDrawable,
- wseglDeleteDrawable,
- wseglSwapDrawable,
- wseglSwapControlInterval,
- wseglWaitNative,
- wseglCopyFromDrawable,
- wseglCopyFromPBuffer,
- wseglGetDrawableParameters
-};
-
-/* Return the table of WSEGL functions to the EGL implementation */
-const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void)
-{
- return &wseglFunctions;
-}
diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README
deleted file mode 100644
index 513e7f5e9e..0000000000
--- a/src/plugins/gfxdrivers/powervr/README
+++ /dev/null
@@ -1,66 +0,0 @@
-PowerVR QScreen Driver
-======================
-
-This QScreen plugin driver allows the QtOpenGl module to integrate with PowerVR
-hardware from Imagination Technologies. Using this plugin, applications may use
-QGLWidget & QGLPixelBuffer with OpenGL ES. The integration with PowerVR drivers
-is built as two libraries: The actual QScreen plugin used by Qt (in the
-pvreglscreen directory) and a WSEGL plugin for the PowerVR drivers (in the
-QWSWSEGL directory).
-
-Qt/Embedded needs to be configured with the QT_QWS_CLIENTBLIT and
-QT_NO_QWS_CURSOR defines.
-
-The PowerVR drivers provide the WSEGL plugin API to allow window systems such as
-QWS to integrate correctly. In order to use the integration, the WSEGL plugin
-(libpvrQWSWSEGL.so, usually installed into the Qt library directory) must be in
-the LD library path. The PowerVR driver also needs to be told which WSEGL library
-to use. This is done by creating/modifying /etc/powervr.ini:
-
-[default]
-WindowSystem=libpvrQWSWSEGL.so
-
-Note: It is important that the /etc/powervr.ini file not contain ^M (Ctrl-M) DOS
-end of line markers at the end of its lines. If ^M markers are present, then the
-libpvrQWSWSEGL.so driver will not be loaded and the default null Linux driver
-will be loaded silently instead. Make sure that the end of line markers are
-strictly Unix-style markers.
-
-
-***************************************************************************
-* IMPORTANT: To build the QScreen plugin and the WSEGL library it depends *
-* on, the pvr2d.h, wsegl.h headers for your platform are required. You *
-* can find a copy of these headers in src/3rdparty/powervr for SGX based *
-* platforms like the TI OMAP3xxx. They probably will not work on MBX *
-* because of differences in the layout of certain PVR2D structures. *
-* You can tell Qt where to find the actual headers for your system by *
-* setting QMAKE_INCDIR_POWERVR in the mkspec. *
-***************************************************************************
-
-When you start a Qt/Embedded application, you should modify the QWS_DISPLAY
-environment variable to use the "powervr" driver instead of "LinuxFb". For
-example, if your original QWS_DISPLAY variable was:
-
- LinuxFb:mmWidth40:mmHeight54:0
-
-then it should be changed to:
-
- powervr:mmWidth40:mmHeight54:0
-
-To test the OpenGL ES integration, you can use the hellogl_es example and run it
-on the device with:
-
- hellogl_es -qws
-
-The driver also supports screen rotation if Qt is configured with the
--qt-gfx-transformed option and the QWS_DISPLAY variable is wrapped in a
-"Transformed" declaration:
-
- Transformed:powervr:mmWidth40:mmHeight54:Rot90:0
-
-Know Issues:
- * A QGLWidget may not have window decorations if it is a top-level window.
- * On some platforms, starting a QWS application after the system has been up
- for a long time may cause the driver to fail. This is due to fragmentation
- of main memory prevening older PowerVR drivers from allocating a contiguous
- region of phyical RAM for the GL surface.
diff --git a/src/plugins/gfxdrivers/powervr/powervr.pri b/src/plugins/gfxdrivers/powervr/powervr.pri
deleted file mode 100644
index 9df8c0ed5b..0000000000
--- a/src/plugins/gfxdrivers/powervr/powervr.pri
+++ /dev/null
@@ -1,2 +0,0 @@
-
-INCLUDEPATH += $$QMAKE_INCDIR_POWERVR
diff --git a/src/plugins/gfxdrivers/powervr/powervr.pro b/src/plugins/gfxdrivers/powervr/powervr.pro
deleted file mode 100644
index f31ad042d8..0000000000
--- a/src/plugins/gfxdrivers/powervr/powervr.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = QWSWSEGL pvreglscreen
-CONFIG += ordered
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
deleted file mode 100644
index 0171de6797..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvreglscreen.h"
-#include "pvreglwindowsurface.h"
-#include "pvrqwsdrawable_p.h"
-#include <QRegExp>
-#include <qwindowsystem_qws.h>
-#ifndef QT_NO_QWS_TRANSFORMED
-#include <qscreentransformed_qws.h>
-#endif
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/kd.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-//![0]
-PvrEglScreen::PvrEglScreen(int displayId)
- : QGLScreen(displayId)
-{
- setOptions(NativeWindows);
- setSupportsBlitInClients(true);
- setSurfaceFunctions(new PvrEglScreenSurfaceFunctions(this, displayId));
-//![0]
- fd = -1;
- ttyfd = -1;
- doGraphicsMode = true;
- oldKdMode = KD_TEXT;
- parent = 0;
-
- // Make sure that the EGL layer is initialized and the drivers loaded.
- EGLDisplay dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
- if (!eglInitialize(dpy, 0, 0))
- qWarning("Could not initialize EGL display - are the drivers loaded?");
-
- // Make sure that screen 0 is initialized.
- pvrQwsScreenWindow(0);
-}
-
-PvrEglScreen::~PvrEglScreen()
-{
- if (fd >= 0)
- ::close(fd);
-}
-
-bool PvrEglScreen::initDevice()
-{
- openTty();
- return true;
-}
-
-bool PvrEglScreen::connect(const QString &displaySpec)
-{
- if (!pvrQwsDisplayOpen())
- return false;
-
- // Initialize the QScreen properties.
- data = (uchar *)(pvrQwsDisplay.screens[0].mapped);
- w = pvrQwsDisplay.screens[0].screenRect.width;
- h = pvrQwsDisplay.screens[0].screenRect.height;
- lstep = pvrQwsDisplay.screens[0].screenStride;
- dw = w;
- dh = h;
- size = h * lstep;
- mapsize = size;
- switch (pvrQwsDisplay.screens[0].pixelFormat) {
- case PVR2D_RGB565:
- d = 16;
- setPixelFormat(QImage::Format_RGB16);
- break;
- case PVR2D_ARGB4444:
- d = 16;
- setPixelFormat(QImage::Format_ARGB4444_Premultiplied);
- break;
- case PVR2D_ARGB8888:
- d = 32;
- setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- default:
- pvrQwsDisplayClose();
- qWarning("PvrEglScreen::connect: unsupported pixel format %d", (int)(pvrQwsDisplay.screens[0].pixelFormat));
- return false;
- }
-
- // Handle display physical size spec.
- QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
- QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
- int dimIdxW = displayArgs.indexOf(mmWidthRx);
- QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
- int dimIdxH = displayArgs.indexOf(mmHeightRx);
- if (dimIdxW >= 0) {
- mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
- physWidth = mmWidthRx.cap(1).toInt();
- if (dimIdxH < 0)
- physHeight = dh*physWidth/dw;
- }
- if (dimIdxH >= 0) {
- mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
- physHeight = mmHeightRx.cap(1).toInt();
- if (dimIdxW < 0)
- physWidth = dw*physHeight/dh;
- }
- if (dimIdxW < 0 && dimIdxH < 0) {
- const int dpi = 72;
- physWidth = qRound(dw * 25.4 / dpi);
- physHeight = qRound(dh * 25.4 / dpi);
- }
-
- // Find the name of the tty device to use.
- QRegExp ttyRegExp(QLatin1String("tty=(.*)"));
- if (displayArgs.indexOf(ttyRegExp) != -1)
- ttyDevice = ttyRegExp.cap(1);
- if (displayArgs.contains(QLatin1String("nographicsmodeswitch")))
- doGraphicsMode = false;
-
- // The screen is ready.
- return true;
-}
-
-void PvrEglScreen::disconnect()
-{
- pvrQwsDisplayClose();
-}
-
-void PvrEglScreen::shutdownDevice()
-{
- closeTty();
-}
-
-void PvrEglScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion &region)
-{
- QGLScreen::blit(img, topLeft, region);
- sync();
-}
-
-void PvrEglScreen::solidFill(const QColor &color, const QRegion &region)
-{
- QGLScreen::solidFill(color, region);
- sync();
-}
-
-bool PvrEglScreen::chooseContext
- (QGLContext *context, const QGLContext *shareContext)
-{
- // We use PvrEglScreenSurfaceFunctions instead.
- Q_UNUSED(context);
- Q_UNUSED(shareContext);
- return false;
-}
-
-bool PvrEglScreen::hasOpenGL()
-{
- return true;
-}
-
-//![1]
-QWSWindowSurface* PvrEglScreen::createSurface(QWidget *widget) const
-{
- if (qobject_cast<QGLWidget*>(widget))
- return new PvrEglWindowSurface(widget, (PvrEglScreen *)this, displayId);
-
- return QScreen::createSurface(widget);
-}
-
-QWSWindowSurface* PvrEglScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("PvrEgl"))
- return new PvrEglWindowSurface();
-
- return QScreen::createSurface(key);
-}
-//![1]
-
-#ifndef QT_NO_QWS_TRANSFORMED
-
-static const QScreen *parentScreen
- (const QScreen *current, const QScreen *lookingFor)
-{
- if (!current)
- return 0;
- switch (current->classId()) {
- case QScreen::ProxyClass:
- case QScreen::TransformedClass: {
- const QScreen *child =
- static_cast<const QProxyScreen *>(current)->screen();
- if (child == lookingFor)
- return current;
- else
- return parentScreen(child, lookingFor);
- }
- // Not reached.
-
- case QScreen::MultiClass: {
- QList<QScreen *> screens = current->subScreens();
- foreach (QScreen *screen, screens) {
- if (screen == lookingFor)
- return current;
- const QScreen *parent = parentScreen(screen, lookingFor);
- if (parent)
- return parent;
- }
- }
- break;
-
- default: break;
- }
- return 0;
-}
-
-int PvrEglScreen::transformation() const
-{
- // We need to search for our parent screen, which is assumed to be
- // "Transformed". If it isn't, then there is no transformation.
- // There is no direct method to get the parent screen so we need
- // to search every screen until we find ourselves.
- if (!parent && qt_screen != this)
- parent = parentScreen(qt_screen, this);
- if (!parent)
- return 0;
- if (parent->classId() != QScreen::TransformedClass)
- return 0;
- return 90 * static_cast<const QTransformedScreen *>(parent)
- ->transformOrientation();
-}
-
-#else
-
-int PvrEglScreen::transformation() const
-{
- return 0;
-}
-
-#endif
-
-void PvrEglScreen::sync()
-{
- // Put code here to synchronize 2D and 3D operations if necessary.
-}
-
-void PvrEglScreen::openTty()
-{
- const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0};
-
- if (ttyDevice.isEmpty()) {
- for (const char * const *dev = devs; *dev; ++dev) {
- ttyfd = ::open(*dev, O_RDWR);
- if (ttyfd != -1)
- break;
- }
- } else {
- ttyfd = ::open(ttyDevice.toAscii().constData(), O_RDWR);
- }
-
- if (ttyfd == -1)
- return;
-
- ::fcntl(ttyfd, F_SETFD, FD_CLOEXEC);
-
- if (doGraphicsMode) {
- ioctl(ttyfd, KDGETMODE, &oldKdMode);
- if (oldKdMode != KD_GRAPHICS) {
- int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS);
- if (ret == -1)
- doGraphicsMode = false;
- }
- }
-
- // No blankin' screen, no blinkin' cursor!, no cursor!
- const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
- ::write(ttyfd, termctl, sizeof(termctl));
-}
-
-void PvrEglScreen::closeTty()
-{
- if (ttyfd == -1)
- return;
-
- if (doGraphicsMode)
- ioctl(ttyfd, KDSETMODE, oldKdMode);
-
- // Blankin' screen, blinkin' cursor!
- const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
- ::write(ttyfd, termctl, sizeof(termctl));
-
- ::close(ttyfd);
- ttyfd = -1;
-}
-
-//![2]
-bool PvrEglScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native)
-{
-//![2]
- QWSWindowSurface *surface =
- static_cast<QWSWindowSurface *>(widget->windowSurface());
- if (!surface) {
- // The widget does not have a surface yet, so give it one.
- surface = new PvrEglWindowSurface(widget, screen, displayId);
- widget->setWindowSurface(surface);
- } else if (surface->key() != QLatin1String("PvrEgl")) {
- // The application has attached a QGLContext to an ordinary QWidget.
- // Replace the widget's window surface with a new one that can do GL.
- QRect geometry = widget->frameGeometry();
- geometry.moveTo(widget->mapToGlobal(QPoint(0, 0)));
- surface = new PvrEglWindowSurface(widget, screen, displayId);
- surface->setGeometry(geometry);
- widget->setWindowSurface(surface);
- widget->setAttribute(Qt::WA_NoSystemBackground, true);
- }
- PvrEglWindowSurface *nsurface = static_cast<PvrEglWindowSurface*>(surface);
- *native = (EGLNativeWindowType)(nsurface->nativeDrawable());
- return true;
-}
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
deleted file mode 100644
index f1893e3e96..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVREGLSCREEN_H
-#define PVREGLSCREEN_H
-
-#include <QScreen>
-#include <QGLScreen>
-#include "pvrqwsdrawable.h"
-
-class PvrEglScreen;
-
-class PvrEglScreenSurfaceFunctions : public QGLScreenSurfaceFunctions
-{
-public:
- PvrEglScreenSurfaceFunctions(PvrEglScreen *s, int screenNum)
- : screen(s), displayId(screenNum) {}
-
- bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native);
-
-private:
- PvrEglScreen *screen;
- int displayId;
-};
-
-class PvrEglScreen : public QGLScreen
-{
-public:
- PvrEglScreen(int displayId);
- ~PvrEglScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
- void setMode(int, int, int) {}
-
- void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
-
- bool chooseContext(QGLContext *context, const QGLContext *shareContext);
- bool hasOpenGL();
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
- int transformation() const;
-
-private:
- void sync();
- void openTty();
- void closeTty();
-
- int fd;
- int ttyfd, oldKdMode;
- QString ttyDevice;
- bool doGraphicsMode;
- mutable const QScreen *parent;
-};
-
-#endif
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro
deleted file mode 100644
index 2b5212a6b3..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TEMPLATE = lib
-TARGET = qgfxpvregl
-CONFIG += qt plugin warn_on
-QT += opengl
-
-LIBS += -lpvrQWSWSEGL
-
-DEFINES += QT_QWS_CLIENTBLIT
-
-INCLUDEPATH += ../QWSWSEGL
-
-
-HEADERS = \
- pvreglscreen.h \
- pvreglwindowsurface.h
-
-SOURCES = \
- pvreglscreenplugin.cpp \
- pvreglscreen.cpp \
- pvreglwindowsurface.cpp
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-include(../powervr.pri) \ No newline at end of file
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp
deleted file mode 100644
index 943bf9473c..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvreglscreen.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class PvrEglScreenPlugin : public QScreenDriverPlugin
-{
-public:
- PvrEglScreenPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-PvrEglScreenPlugin::PvrEglScreenPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList PvrEglScreenPlugin::keys() const
-{
- return (QStringList() << "powervr");
-}
-
-QScreen* PvrEglScreenPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() != "powervr")
- return 0;
-
- return new PvrEglScreen(displayId);
-}
-
-Q_EXPORT_PLUGIN2(qgfxpvregl, PvrEglScreenPlugin)
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
deleted file mode 100644
index f23f5c1cc4..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvreglwindowsurface.h"
-#include "pvreglscreen.h"
-#include <QScreen>
-#include <QDebug>
-#include <QWSDisplay>
-
-PvrEglWindowSurface::PvrEglWindowSurface
- (QWidget *widget, PvrEglScreen *screen, int screenNum)
- : QWSGLWindowSurface(widget)
-{
- setSurfaceFlags(QWSWindowSurface::Opaque);
-
- this->widget = widget;
- this->screen = screen;
- this->pdevice = 0;
-
- QPoint pos = offset(widget);
- QSize size = widget->size();
-
- PvrQwsRect pvrRect;
- pvrRect.x = pos.x();
- pvrRect.y = pos.y();
- pvrRect.width = size.width();
- pvrRect.height = size.height();
- transformRects(&pvrRect, 1);
-
- // Try to recover a previous PvrQwsDrawable object for the widget
- // if there is one. This can happen when a PvrEglWindowSurface
- // is created for a widget, bound to a EGLSurface, and then destroyed.
- // When a new PvrEglWindowSurface is created for the widget, it will
- // pick up the previous PvrQwsDrawable if the EGLSurface has not been
- // destroyed in the meantime.
- drawable = pvrQwsFetchWindow((long)widget);
- if (drawable)
- pvrQwsSetGeometry(drawable, &pvrRect);
- else
- drawable = pvrQwsCreateWindow(screenNum, (long)widget, &pvrRect);
- pvrQwsSetRotation(drawable, screen->transformation());
-}
-
-PvrEglWindowSurface::PvrEglWindowSurface()
- : QWSGLWindowSurface()
-{
- setSurfaceFlags(QWSWindowSurface::Opaque);
- drawable = 0;
- widget = 0;
- screen = 0;
- pdevice = 0;
-}
-
-PvrEglWindowSurface::~PvrEglWindowSurface()
-{
- // Release the PvrQwsDrawable. If it is bound to an EGLSurface,
- // then it will stay around until a new PvrEglWindowSurface is
- // created for the widget. If it is not bound to an EGLSurface,
- // it will be destroyed immediately.
- if (drawable && pvrQwsReleaseWindow(drawable))
- pvrQwsDestroyDrawable(drawable);
-
- delete pdevice;
-}
-
-bool PvrEglWindowSurface::isValid() const
-{
- return (widget != 0);
-}
-
-void PvrEglWindowSurface::setGeometry(const QRect &rect)
-{
- if (drawable) {
- // XXX: adjust for the screen offset.
- PvrQwsRect pvrRect;
- pvrRect.x = rect.x();
- pvrRect.y = rect.y();
- pvrRect.width = rect.width();
- pvrRect.height = rect.height();
- transformRects(&pvrRect, 1);
- pvrQwsSetGeometry(drawable, &pvrRect);
- pvrQwsSetRotation(drawable, screen->transformation());
- }
- QWSGLWindowSurface::setGeometry(rect);
-}
-
-bool PvrEglWindowSurface::move(const QPoint &offset)
-{
- QRect rect = geometry().translated(offset);
- if (drawable) {
- PvrQwsRect pvrRect;
- pvrRect.x = rect.x();
- pvrRect.y = rect.y();
- pvrRect.width = rect.width();
- pvrRect.height = rect.height();
- transformRects(&pvrRect, 1);
- pvrQwsSetGeometry(drawable, &pvrRect);
- pvrQwsSetRotation(drawable, screen->transformation());
- }
- return QWSGLWindowSurface::move(offset);
-}
-
-QByteArray PvrEglWindowSurface::permanentState() const
-{
- // Nothing interesting to pass to the server just yet.
- return QByteArray();
-}
-
-void PvrEglWindowSurface::setPermanentState(const QByteArray &state)
-{
- Q_UNUSED(state);
-}
-
-void PvrEglWindowSurface::flush
- (QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- // The GL paint engine is responsible for the swapBuffers() call.
- // If we were to call the base class's implementation of flush()
- // then it would fetch the image() and manually blit it to the
- // screeen instead of using the fast PVR2D blit.
- Q_UNUSED(widget);
- Q_UNUSED(region);
- Q_UNUSED(offset);
-}
-
-QImage PvrEglWindowSurface::image() const
-{
- if (drawable) {
- PvrQwsRect pvrRect;
- pvrQwsGetGeometry(drawable, &pvrRect);
- void *data = pvrQwsGetRenderBuffer(drawable);
- if (data) {
- return QImage((uchar *)data, pvrRect.width, pvrRect.height,
- pvrQwsGetStride(drawable), screen->pixelFormat());
- }
- }
- return QImage(16, 16, screen->pixelFormat());
-}
-
-QPaintDevice *PvrEglWindowSurface::paintDevice()
-{
- return widget;
-}
-
-void PvrEglWindowSurface::setDirectRegion(const QRegion &r, int id)
-{
- QWSGLWindowSurface::setDirectRegion(r, id);
-
- if (!drawable)
- return;
-
- // Clip the region to the window boundaries in case the child
- // is partially outside the geometry of the parent.
- QWidget *window = widget->window();
- QRegion region = r;
- if (widget != window) {
- QRect rect = window->geometry();
- rect.moveTo(window->mapToGlobal(QPoint(0, 0)));
- region = region.intersect(rect);
- }
-
- if (region.isEmpty()) {
- pvrQwsClearVisibleRegion(drawable);
- } else if (region.rectCount() == 1) {
- QRect rect = region.boundingRect();
- PvrQwsRect pvrRect;
- pvrRect.x = rect.x();
- pvrRect.y = rect.y();
- pvrRect.width = rect.width();
- pvrRect.height = rect.height();
- transformRects(&pvrRect, 1);
- pvrQwsSetVisibleRegion(drawable, &pvrRect, 1);
- pvrQwsSetRotation(drawable, screen->transformation());
- if (!pvrQwsSwapBuffers(drawable, 1))
- screen->solidFill(QColor(0, 0, 0), region);
- } else {
- QVector<QRect> rects = region.rects();
- PvrQwsRect *pvrRects = new PvrQwsRect [rects.size()];
- for (int index = 0; index < rects.size(); ++index) {
- QRect rect = rects[index];
- pvrRects[index].x = rect.x();
- pvrRects[index].y = rect.y();
- pvrRects[index].width = rect.width();
- pvrRects[index].height = rect.height();
- }
- transformRects(pvrRects, rects.size());
- pvrQwsSetVisibleRegion(drawable, pvrRects, rects.size());
- pvrQwsSetRotation(drawable, screen->transformation());
- if (!pvrQwsSwapBuffers(drawable, 1))
- screen->solidFill(QColor(0, 0, 0), region);
- delete [] pvrRects;
- }
-}
-
-void PvrEglWindowSurface::transformRects(PvrQwsRect *rects, int count) const
-{
- switch (screen->transformation()) {
- case 0: break;
-
- case 90:
- {
- for (int index = 0; index < count; ++index) {
- int x = rects[index].y;
- int y = screen->height() - (rects[index].x + rects[index].width);
- rects[index].x = x;
- rects[index].y = y;
- qSwap(rects[index].width, rects[index].height);
- }
- }
- break;
-
- case 180:
- {
- for (int index = 0; index < count; ++index) {
- int x = screen->width() - (rects[index].x + rects[index].width);
- int y = screen->height() - (rects[index].y + rects[index].height);
- rects[index].x = x;
- rects[index].y = y;
- }
- }
- break;
-
- case 270:
- {
- for (int index = 0; index < count; ++index) {
- int x = screen->width() - (rects[index].y + rects[index].height);
- int y = rects[index].x;
- rects[index].x = x;
- rects[index].y = y;
- qSwap(rects[index].width, rects[index].height);
- }
- }
- break;
- }
-}
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
deleted file mode 100644
index 365fed9170..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVREGLWINDOWSURFACE_H
-#define PVREGLWINDOWSURFACE_H
-
-#include <private/qglwindowsurface_qws_p.h>
-#include "pvrqwsdrawable.h"
-
-class PvrEglScreen;
-
-class PvrEglWindowSurface : public QWSGLWindowSurface
-{
-public:
- PvrEglWindowSurface(QWidget *widget, PvrEglScreen *screen, int screenNum);
- PvrEglWindowSurface();
- ~PvrEglWindowSurface();
-
- QString key() const { return QLatin1String("PvrEgl"); }
-
- bool isValid() const;
-
- void setGeometry(const QRect &rect);
- bool move(const QPoint &offset);
-
- QByteArray permanentState() const;
- void setPermanentState(const QByteArray &state);
-
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
- QImage image() const;
- QPaintDevice *paintDevice();
-
- void setDirectRegion(const QRegion &region, int id);
-
- long nativeDrawable() const { return (long)widget; }
-
-private:
- QWidget *widget;
- PvrQwsDrawable *drawable;
- PvrEglScreen *screen;
- QPaintDevice *pdevice;
-
- void transformRects(PvrQwsRect *rects, int count) const;
-};
-
-#endif
diff --git a/src/plugins/gfxdrivers/qvfb/main.cpp b/src/plugins/gfxdrivers/qvfb/main.cpp
deleted file mode 100644
index 98661b61b9..0000000000
--- a/src/plugins/gfxdrivers/qvfb/main.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreenvfb_qws.h>
-#include <qstringlist.h>
-
-#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
-
-class ScreenVfbDriver : public QScreenDriverPlugin
-{
-public:
- ScreenVfbDriver();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-ScreenVfbDriver::ScreenVfbDriver()
-: QScreenDriverPlugin()
-{
-}
-
-QStringList ScreenVfbDriver::keys() const
-{
- QStringList list;
- list << "QVFb";
- return list;
-}
-
-QScreen* ScreenVfbDriver::create(const QString& driver, int displayId)
-{
- if (driver.toLower() == "qvfb")
- return new QVFbScreen(displayId);
-
- return 0;
-}
-
-Q_EXPORT_STATIC_PLUGIN(ScreenVfbDriver)
-Q_EXPORT_PLUGIN2(qscreenvfb, ScreenVfbDriver)
-
-QT_END_NAMESPACE
-#endif //QT_NO_LIBRARY
diff --git a/src/plugins/gfxdrivers/qvfb/qvfb.pro b/src/plugins/gfxdrivers/qvfb/qvfb.pro
deleted file mode 100644
index 99376be81c..0000000000
--- a/src/plugins/gfxdrivers/qvfb/qvfb.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-TARGET = qscreenvfb
-load(qt_plugin)
-
-DEFINES += QT_QWS_QVFB QT_QWS_MOUSE_QVFB QT_QWS_KBD_QVFB
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-HEADERS = \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.h \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.h \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
diff --git a/src/plugins/gfxdrivers/transformed/main.cpp b/src/plugins/gfxdrivers/transformed/main.cpp
deleted file mode 100644
index 612068e3a6..0000000000
--- a/src/plugins/gfxdrivers/transformed/main.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreentransformed_qws.h>
-#include <qstringlist.h>
-#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
-
-class GfxTransformedDriver : public QScreenDriverPlugin
-{
-public:
- GfxTransformedDriver();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-GfxTransformedDriver::GfxTransformedDriver()
-: QScreenDriverPlugin()
-{
-}
-
-QStringList GfxTransformedDriver::keys() const
-{
- QStringList list;
- list << "Transformed";
- return list;
-}
-
-QScreen* GfxTransformedDriver::create(const QString& driver, int displayId)
-{
-#ifndef QT_NO_QWS_TRANSFORMED
- if (driver.toLower() == "transformed")
- return new QTransformedScreen(displayId);
-#else //QT_NO_QWS_TRANSFORMED
- printf("QT buildt with QT_NO_QWS_TRANSFORMED. No screen driver returned\n");
-#endif //QT_NO_QWS_TRANSFORMED
- return 0;
-}
-
-Q_EXPORT_STATIC_PLUGIN(GfxTransformedDriver)
-Q_EXPORT_PLUGIN2(qgfxtransformed, GfxTransformedDriver)
-
-QT_END_NAMESPACE
-#endif //QT_NO_LIBRARY
diff --git a/src/plugins/gfxdrivers/transformed/transformed.pro b/src/plugins/gfxdrivers/transformed/transformed.pro
deleted file mode 100644
index f97713fc38..0000000000
--- a/src/plugins/gfxdrivers/transformed/transformed.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qgfxtransformed
-load(qt_plugin)
-
-DEFINES += QT_QWS_TRANSFORMED
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qscreentransformed_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreentransformed_qws.cpp
-
-target.path=$$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
diff --git a/src/plugins/gfxdrivers/vnc/main.cpp b/src/plugins/gfxdrivers/vnc/main.cpp
deleted file mode 100644
index 0a7ae592e0..0000000000
--- a/src/plugins/gfxdrivers/vnc/main.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreenvnc_qws.h>
-#include <qstringlist.h>
-
-#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
-
-class GfxVncDriver : public QScreenDriverPlugin
-{
-public:
- GfxVncDriver();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-GfxVncDriver::GfxVncDriver()
-: QScreenDriverPlugin()
-{
-}
-
-QStringList GfxVncDriver::keys() const
-{
- QStringList list;
- list << "VNC";
- return list;
-}
-
-QScreen* GfxVncDriver::create(const QString& driver, int displayId)
-{
-#ifndef QT_NO_QWS_VNC
- if (driver.toLower() == "vnc")
- return new QVNCScreen(displayId);
-#else //QT_NO_QWS_VNC
- printf("QT buildt with QT_NO_QWS_VNC. No screen driver returned\n");
-#endif //QT_NO_QWS_VNC
- return 0;
-}
-
-Q_EXPORT_STATIC_PLUGIN(GfxVncDriver)
-Q_EXPORT_PLUGIN2(qgfxvnc, GfxVncDriver)
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_LIBRARY
diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h b/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h
deleted file mode 100644
index e64393a8c9..0000000000
--- a/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h
+++ /dev/null
@@ -1,524 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENVNC_P_H
-#define QSCREENVNC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qscreenvnc_qws.h"
-
-#ifndef QT_NO_QWS_VNC
-
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qsharedmemory.h>
-#include <QtNetwork/qtcpsocket.h>
-#include <QtNetwork/qtcpserver.h>
-
-QT_BEGIN_NAMESPACE
-
-class QVNCServer;
-
-#ifndef QT_NO_QWS_CURSOR
-class QVNCCursor : public QProxyScreenCursor
-{
-public:
- QVNCCursor(QVNCScreen *s);
- ~QVNCCursor();
-
- void hide();
- void show();
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
-
-private:
- void setDirty(const QRect &r) const;
- QVNCScreen *screen;
-};
-
-class QVNCClientCursor : public QProxyScreenCursor
-{
-public:
- QVNCClientCursor(QVNCServer *s);
- ~QVNCClientCursor();
-
- void set(const QImage &image, int hotx, int hoty);
- void write() const;
-
-private:
- QVNCServer *server;
-};
-#endif // QT_NO_QWS_CURSOR
-
-#define MAP_TILE_SIZE 16
-#define MAP_WIDTH 1280 / MAP_TILE_SIZE
-#define MAP_HEIGHT 1024 / MAP_TILE_SIZE
-
-class QVNCDirtyMap
-{
-public:
- QVNCDirtyMap(QScreen *screen);
- virtual ~QVNCDirtyMap();
-
- void reset();
- bool dirty(int x, int y) const;
- virtual void setDirty(int x, int y, bool force = false) = 0;
- void setClean(int x, int y);
-
- int bytesPerPixel;
-
- int numDirty;
- int mapWidth;
- int mapHeight;
-
-protected:
- uchar *map;
- QScreen *screen;
- uchar *buffer;
- int bufferWidth;
- int bufferHeight;
- int bufferStride;
- int numTiles;
-};
-
-template <class T>
-class QVNCDirtyMapOptimized : public QVNCDirtyMap
-{
-public:
- QVNCDirtyMapOptimized(QScreen *screen) : QVNCDirtyMap(screen) {}
- ~QVNCDirtyMapOptimized() {}
-
- void setDirty(int x, int y, bool force = false);
-};
-
-class QRfbRect
-{
-public:
- QRfbRect() {}
- QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) {
- x = _x; y = _y; w = _w; h = _h;
- }
-
- void read(QTcpSocket *s);
- void write(QTcpSocket *s) const;
-
- quint16 x;
- quint16 y;
- quint16 w;
- quint16 h;
-};
-
-class QRfbPixelFormat
-{
-public:
- static int size() { return 16; }
-
- void read(QTcpSocket *s);
- void write(QTcpSocket *s);
-
- int bitsPerPixel;
- int depth;
- bool bigEndian;
- bool trueColor;
- int redBits;
- int greenBits;
- int blueBits;
- int redShift;
- int greenShift;
- int blueShift;
-};
-
-class QRfbServerInit
-{
-public:
- QRfbServerInit() { name = 0; }
- ~QRfbServerInit() { delete[] name; }
-
- int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); }
- void setName(const char *n);
-
- void read(QTcpSocket *s);
- void write(QTcpSocket *s);
-
- quint16 width;
- quint16 height;
- QRfbPixelFormat format;
- char *name;
-};
-
-class QRfbSetEncodings
-{
-public:
- bool read(QTcpSocket *s);
-
- quint16 count;
-};
-
-class QRfbFrameBufferUpdateRequest
-{
-public:
- bool read(QTcpSocket *s);
-
- char incremental;
- QRfbRect rect;
-};
-
-class QRfbKeyEvent
-{
-public:
- bool read(QTcpSocket *s);
-
- char down;
- int keycode;
- int unicode;
-};
-
-class QRfbPointerEvent
-{
-public:
- bool read(QTcpSocket *s);
-
- uint buttons;
- quint16 x;
- quint16 y;
-};
-
-class QRfbClientCutText
-{
-public:
- bool read(QTcpSocket *s);
-
- quint32 length;
-};
-
-class QVNCScreenPrivate : public QObject
-{
-public:
- QVNCScreenPrivate(QVNCScreen *parent);
- ~QVNCScreenPrivate();
-
- void setDirty(const QRect &rect, bool force = false);
- void configure();
-
- qreal dpiX;
- qreal dpiY;
- bool doOnScreenSurface;
- QVNCDirtyMap *dirty;
- int refreshRate;
- QVNCServer *vncServer;
-
-#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
- QSharedMemory shm;
-#endif
-
- QVNCScreen *q_ptr;
-
- bool noDisablePainting;
-};
-
-class QRfbEncoder
-{
-public:
- QRfbEncoder(QVNCServer *s) : server(s) {}
- virtual ~QRfbEncoder() {}
-
- virtual void write() = 0;
-
-protected:
- QVNCServer *server;
-};
-
-class QRfbRawEncoder : public QRfbEncoder
-{
-public:
- QRfbRawEncoder(QVNCServer *s) : QRfbEncoder(s) {}
-
- void write();
-
-private:
- QByteArray buffer;
-};
-
-template <class SRC> class QRfbHextileEncoder;
-
-template <class SRC>
-class QRfbSingleColorHextile
-{
-public:
- QRfbSingleColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
- bool read(const uchar *data, int width, int height, int stride);
- void write(QTcpSocket *socket) const;
-
-private:
- QRfbHextileEncoder<SRC> *encoder;
-};
-
-template <class SRC>
-class QRfbDualColorHextile
-{
-public:
- QRfbDualColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
- bool read(const uchar *data, int width, int height, int stride);
- void write(QTcpSocket *socket) const;
-
-private:
- struct Rect {
- quint8 xy;
- quint8 wh;
- } Q_PACKED rects[8 * 16];
-
- quint8 numRects;
- QRfbHextileEncoder<SRC> *encoder;
-
-private:
- inline int lastx() const { return rectx(numRects); }
- inline int lasty() const { return recty(numRects); }
- inline int rectx(int r) const { return rects[r].xy >> 4; }
- inline int recty(int r) const { return rects[r].xy & 0x0f; }
- inline int width(int r) const { return (rects[r].wh >> 4) + 1; }
- inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; }
-
- inline void setX(int r, int x) {
- rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
- }
- inline void setY(int r, int y) {
- rects[r].xy = (rects[r].xy & 0xf0) | y;
- }
- inline void setWidth(int r, int width) {
- rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
- }
- inline void setHeight(int r, int height) {
- rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
- }
-
- inline void setWidth(int width) { setWidth(numRects, width); }
- inline void setHeight(int height) { setHeight(numRects, height); }
- inline void setX(int x) { setX(numRects, x); }
- inline void setY(int y) { setY(numRects, y); }
- void next();
-};
-
-template <class SRC>
-class QRfbMultiColorHextile
-{
-public:
- QRfbMultiColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
- bool read(const uchar *data, int width, int height, int stride);
- void write(QTcpSocket *socket) const;
-
-private:
- inline quint8* rect(int r) {
- return rects.data() + r * (bpp + 2);
- }
- inline const quint8* rect(int r) const {
- return rects.constData() + r * (bpp + 2);
- }
- inline void setX(int r, int x) {
- quint8 *ptr = rect(r) + bpp;
- *ptr = (x << 4) | (*ptr & 0x0f);
- }
- inline void setY(int r, int y) {
- quint8 *ptr = rect(r) + bpp;
- *ptr = (*ptr & 0xf0) | y;
- }
- void setColor(SRC color);
- inline int rectx(int r) const {
- const quint8 *ptr = rect(r) + bpp;
- return *ptr >> 4;
- }
- inline int recty(int r) const {
- const quint8 *ptr = rect(r) + bpp;
- return *ptr & 0x0f;
- }
- inline void setWidth(int r, int width) {
- quint8 *ptr = rect(r) + bpp + 1;
- *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
- }
- inline void setHeight(int r, int height) {
- quint8 *ptr = rect(r) + bpp + 1;
- *ptr = (*ptr & 0xf0) | (height - 1);
- }
-
- bool beginRect();
- void endRect();
-
- static const int maxRectsSize = 16 * 16;
- QVarLengthArray<quint8, maxRectsSize> rects;
-
- quint8 bpp;
- quint8 numRects;
- QRfbHextileEncoder<SRC> *encoder;
-};
-
-template <class SRC>
-class QRfbHextileEncoder : public QRfbEncoder
-{
-public:
- QRfbHextileEncoder(QVNCServer *s);
- void write();
-
-private:
- enum SubEncoding {
- Raw = 1,
- BackgroundSpecified = 2,
- ForegroundSpecified = 4,
- AnySubrects = 8,
- SubrectsColoured = 16
- };
-
- QByteArray buffer;
- QRfbSingleColorHextile<SRC> singleColorHextile;
- QRfbDualColorHextile<SRC> dualColorHextile;
- QRfbMultiColorHextile<SRC> multiColorHextile;
-
- SRC bg;
- SRC fg;
- bool newBg;
- bool newFg;
-
- friend class QRfbSingleColorHextile<SRC>;
- friend class QRfbDualColorHextile<SRC>;
- friend class QRfbMultiColorHextile<SRC>;
-};
-
-class QVNCServer : public QObject
-{
- Q_OBJECT
-public:
- QVNCServer(QVNCScreen *screen);
- QVNCServer(QVNCScreen *screen, int id);
- ~QVNCServer();
-
- void setDirty();
- void setDirtyCursor() { dirtyCursor = true; setDirty(); }
- inline bool isConnected() const { return state == Connected; }
- inline void setRefreshRate(int rate) { refreshRate = rate; }
-
- enum ClientMsg { SetPixelFormat = 0,
- FixColourMapEntries = 1,
- SetEncodings = 2,
- FramebufferUpdateRequest = 3,
- KeyEvent = 4,
- PointerEvent = 5,
- ClientCutText = 6 };
-
- enum ServerMsg { FramebufferUpdate = 0,
- SetColourMapEntries = 1 };
-
- void convertPixels(char *dst, const char *src, int count) const;
-
- inline int clientBytesPerPixel() const {
- return pixelFormat.bitsPerPixel / 8;
- }
-
- inline QVNCScreen* screen() const { return qvnc_screen; }
- inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->d_ptr->dirty; }
- inline QTcpSocket* clientSocket() const { return client; }
- QImage screenImage() const;
- inline bool doPixelConversion() const { return needConversion; }
-#ifndef QT_NO_QWS_CURSOR
- inline bool hasClientCursor() const { return qvnc_cursor != 0; }
-#endif
-
-private:
- void setPixelFormat();
- void setEncodings();
- void frameBufferUpdateRequest();
- void pointerEvent();
- void keyEvent();
- void clientCutText();
- bool pixelConversionNeeded() const;
-
-private slots:
- void newConnection();
- void readClient();
- void checkUpdate();
- void discardClient();
-
-private:
- void init(uint port);
- enum ClientState { Unconnected, Protocol, Init, Connected };
- QTimer *timer;
- QTcpServer *serverSocket;
- QTcpSocket *client;
- ClientState state;
- quint8 msgType;
- bool handleMsg;
- QRfbPixelFormat pixelFormat;
- Qt::KeyboardModifiers keymod;
- int encodingsPending;
- int cutTextPending;
- uint supportCopyRect : 1;
- uint supportRRE : 1;
- uint supportCoRRE : 1;
- uint supportHextile : 1;
- uint supportZRLE : 1;
- uint supportCursor : 1;
- uint supportDesktopSize : 1;
- bool wantUpdate;
- bool sameEndian;
- bool needConversion;
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- bool swapBytes;
-#endif
- bool dirtyCursor;
- int refreshRate;
- QVNCScreen *qvnc_screen;
-#ifndef QT_NO_QWS_CURSOR
- QVNCClientCursor *qvnc_cursor;
-#endif
-
- QRfbEncoder *encoder;
-};
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_QWS_VNC
-#endif // QSCREENVNC_P_H
diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp
deleted file mode 100644
index 3ddedc63ea..0000000000
--- a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp
+++ /dev/null
@@ -1,2338 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenvnc_qws.h"
-
-#ifndef QT_NO_QWS_VNC
-
-#include "qscreenvnc_p.h"
-#include "qwindowsystem_qws.h"
-#include "qwsdisplay_qws.h"
-#include "qscreendriverfactory_qws.h"
-#include <QtCore/qtimer.h>
-#include <QtCore/qregexp.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/qpolygon.h>
-#include <QtGui/qpainter.h>
-#include <qdebug.h>
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qwssignalhandler_p.h>
-#include <private/qwidget_p.h>
-#include <private/qdrawhelper_p.h>
-
-#include <stdlib.h>
-
-QT_BEGIN_NAMESPACE
-
-//#define QT_QWS_VNC_DEBUG
-
-extern QString qws_qtePipeFilename();
-
-#ifndef QT_NO_QWS_CURSOR
-
-QVNCCursor::QVNCCursor(QVNCScreen *s)
- : screen(s)
-{
- if (qt_screencursor)
- setScreenCursor(qt_screencursor);
- else
- hwaccel = true;
-}
-
-QVNCCursor::~QVNCCursor()
-{
- if (screenCursor())
- qt_screencursor = screenCursor();
-}
-
-void QVNCCursor::setDirty(const QRect &r) const
-{
- screen->d_ptr->setDirty(r, true);
-}
-
-void QVNCCursor::hide()
-{
- QProxyScreenCursor::hide();
- if (enable)
- setDirty(boundingRect());
-}
-
-void QVNCCursor::show()
-{
- QProxyScreenCursor::show();
- if (enable)
- setDirty(boundingRect());
-}
-
-void QVNCCursor::set(const QImage &image, int hotx, int hoty)
-{
- QRegion dirty = boundingRect();
- QProxyScreenCursor::set(image, hotx, hoty);
- dirty |= boundingRect();
- if (enable && hwaccel && !screen->d_ptr->vncServer->hasClientCursor()) {
- const QVector<QRect> rects = dirty.rects();
- for (int i = 0; i < rects.size(); ++i)
- setDirty(rects.at(i));
- }
-}
-
-void QVNCCursor::move(int x, int y)
-{
- if (enable && hwaccel && !screen->d_ptr->vncServer->hasClientCursor()) {
- QRegion dirty = boundingRect();
- QProxyScreenCursor::move(x, y);
- dirty |= boundingRect();
- if (enable) {
- const QVector<QRect> rects = dirty.rects();
- for (int i = 0; i < rects.size(); ++i)
- setDirty(rects.at(i));
- }
- } else {
- QProxyScreenCursor::move(x, y);
- }
-}
-
-QVNCClientCursor::QVNCClientCursor(QVNCServer *s)
- : server(s)
-{
- setScreenCursor(qt_screencursor);
- Q_ASSERT(hwaccel);
- qt_screencursor = this; // hw: XXX
-
- set(image(), hotspot.x(), hotspot.y());
-}
-
-QVNCClientCursor::~QVNCClientCursor()
-{
- qt_screencursor = screenCursor();
-}
-
-void QVNCClientCursor::set(const QImage &image, int hotx, int hoty)
-{
- QScreenCursor::set(image, hotx, hoty);
- server->setDirtyCursor();
-}
-
-void QVNCClientCursor::write() const
-{
- QTcpSocket *socket = server->clientSocket();
-
- // FramebufferUpdate header
- {
- const quint16 tmp[6] = { htons(0),
- htons(1),
- htons(hotspot.x()), htons(hotspot.y()),
- htons(cursor.width()),
- htons(cursor.height()) };
- socket->write((char*)tmp, sizeof(tmp));
-
- const quint32 encoding = htonl(-239);
- socket->write((char*)(&encoding), sizeof(encoding));
- }
-
- if (cursor.isNull())
- return;
-
- // write pixels
- Q_ASSERT(cursor.hasAlphaChannel());
- const QImage img = cursor.convertToFormat(server->screen()->pixelFormat());
- const int n = server->clientBytesPerPixel() * img.width();
- char *buffer = new char[n];
- for (int i = 0; i < img.height(); ++i) {
- server->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
- socket->write(buffer, n);
- }
- delete[] buffer;
-
- // write mask
- const QImage bitmap = cursor.createAlphaMask().convertToFormat(QImage::Format_Mono);
- Q_ASSERT(bitmap.depth() == 1);
- Q_ASSERT(bitmap.size() == img.size());
- const int width = (bitmap.width() + 7) / 8;
- for (int i = 0; i < bitmap.height(); ++i)
- socket->write((const char*)bitmap.scanLine(i), width);
-}
-
-#endif // QT_NO_QWS_CURSOR
-
-QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent)
- : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25),
- vncServer(0), q_ptr(parent), noDisablePainting(false)
-{
-#ifdef QT_BUILD_INTERNAL
- noDisablePainting = (qgetenv("QT_VNC_NO_DISABLEPAINTING").toInt() > 0);
-#endif
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-}
-
-QVNCScreenPrivate::~QVNCScreenPrivate()
-{
-#if defined(QT_NO_QWS_MULTIPROCESS) || defined(QT_NO_SHAREDMEMORY)
- if (q_ptr->screen())
- return;
-
- delete[] q_ptr->data;
- q_ptr->data = 0;
-#else
- shm.detach();
-#endif
-}
-
-void QVNCScreenPrivate::configure()
-{
- if (q_ptr->screen())
- return;
-
- q_ptr->lstep = q_ptr->dw * ((q_ptr->d + 7) / 8);
- q_ptr->size = q_ptr->h * q_ptr->lstep;
- q_ptr->mapsize = q_ptr->size;
- q_ptr->physWidth = qRound(q_ptr->dw * qreal(25.4) / dpiX);
- q_ptr->physHeight = qRound(q_ptr->dh * qreal(25.4) / dpiY);
-
- switch (q_ptr->d) {
- case 1:
- q_ptr->setPixelFormat(QImage::Format_Mono); //### LSB???
- break;
- case 8:
- q_ptr->setPixelFormat(QImage::Format_Indexed8);
- break;
- case 12:
- q_ptr->setPixelFormat(QImage::Format_RGB444);
- break;
- case 15:
- q_ptr->setPixelFormat(QImage::Format_RGB555);
- break;
- case 16:
- q_ptr->setPixelFormat(QImage::Format_RGB16);
- break;
- case 18:
- q_ptr->setPixelFormat(QImage::Format_RGB666);
- break;
- case 24:
- q_ptr->setPixelFormat(QImage::Format_RGB888);
- break;
- case 32:
- q_ptr->setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- }
-
-#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
- if (q_ptr->size != shm.size()) {
- shm.detach();
- const QString key = qws_qtePipeFilename() +
- QString().sprintf("_vnc_%d_%d",
- q_ptr->displayId, q_ptr->size);
- shm.setKey(key);
- if (QApplication::type() == QApplication::GuiServer) {
- if (!shm.create(q_ptr->size)) {
- qWarning() << "QVNCScreen could not create shared memory:"
- << shm.errorString();
- if (!shm.attach()) {
- qWarning() << "QVNCScreen could not attach to shared memory:"
- << shm.errorString();
- }
- }
- } else if (!shm.attach()) {
- qWarning() << "QVNCScreen could not attach to shared memory:"
- << shm.errorString();
- }
- q_ptr->data = reinterpret_cast<uchar*>(shm.data());
- }
-#else
- if (q_ptr->data)
- delete[] q_ptr->data;
- q_ptr->data = new uchar[q_ptr->size];
-#endif
-}
-
-//===========================================================================
-
-static const struct {
- int keysym;
- int keycode;
-} keyMap[] = {
- { 0xff08, Qt::Key_Backspace },
- { 0xff09, Qt::Key_Tab },
- { 0xff0d, Qt::Key_Return },
- { 0xff1b, Qt::Key_Escape },
- { 0xff63, Qt::Key_Insert },
- { 0xffff, Qt::Key_Delete },
- { 0xff50, Qt::Key_Home },
- { 0xff57, Qt::Key_End },
- { 0xff55, Qt::Key_PageUp },
- { 0xff56, Qt::Key_PageDown },
- { 0xff51, Qt::Key_Left },
- { 0xff52, Qt::Key_Up },
- { 0xff53, Qt::Key_Right },
- { 0xff54, Qt::Key_Down },
- { 0xffbe, Qt::Key_F1 },
- { 0xffbf, Qt::Key_F2 },
- { 0xffc0, Qt::Key_F3 },
- { 0xffc1, Qt::Key_F4 },
- { 0xffc2, Qt::Key_F5 },
- { 0xffc3, Qt::Key_F6 },
- { 0xffc4, Qt::Key_F7 },
- { 0xffc5, Qt::Key_F8 },
- { 0xffc6, Qt::Key_F9 },
- { 0xffc7, Qt::Key_F10 },
- { 0xffc8, Qt::Key_F11 },
- { 0xffc9, Qt::Key_F12 },
- { 0xffe1, Qt::Key_Shift },
- { 0xffe2, Qt::Key_Shift },
- { 0xffe3, Qt::Key_Control },
- { 0xffe4, Qt::Key_Control },
- { 0xffe7, Qt::Key_Meta },
- { 0xffe8, Qt::Key_Meta },
- { 0xffe9, Qt::Key_Alt },
- { 0xffea, Qt::Key_Alt },
-
- { 0xffb0, Qt::Key_0 },
- { 0xffb1, Qt::Key_1 },
- { 0xffb2, Qt::Key_2 },
- { 0xffb3, Qt::Key_3 },
- { 0xffb4, Qt::Key_4 },
- { 0xffb5, Qt::Key_5 },
- { 0xffb6, Qt::Key_6 },
- { 0xffb7, Qt::Key_7 },
- { 0xffb8, Qt::Key_8 },
- { 0xffb9, Qt::Key_9 },
-
- { 0xff8d, Qt::Key_Return },
- { 0xffaa, Qt::Key_Asterisk },
- { 0xffab, Qt::Key_Plus },
- { 0xffad, Qt::Key_Minus },
- { 0xffae, Qt::Key_Period },
- { 0xffaf, Qt::Key_Slash },
-
- { 0xff95, Qt::Key_Home },
- { 0xff96, Qt::Key_Left },
- { 0xff97, Qt::Key_Up },
- { 0xff98, Qt::Key_Right },
- { 0xff99, Qt::Key_Down },
- { 0xff9a, Qt::Key_PageUp },
- { 0xff9b, Qt::Key_PageDown },
- { 0xff9c, Qt::Key_End },
- { 0xff9e, Qt::Key_Insert },
- { 0xff9f, Qt::Key_Delete },
-
- { 0, 0 }
-};
-
-void QRfbRect::read(QTcpSocket *s)
-{
- quint16 buf[4];
- s->read((char*)buf, 8);
- x = ntohs(buf[0]);
- y = ntohs(buf[1]);
- w = ntohs(buf[2]);
- h = ntohs(buf[3]);
-}
-
-void QRfbRect::write(QTcpSocket *s) const
-{
- quint16 buf[4];
- buf[0] = htons(x);
- buf[1] = htons(y);
- buf[2] = htons(w);
- buf[3] = htons(h);
- s->write((char*)buf, 8);
-}
-
-void QRfbPixelFormat::read(QTcpSocket *s)
-{
- char buf[16];
- s->read(buf, 16);
- bitsPerPixel = buf[0];
- depth = buf[1];
- bigEndian = buf[2];
- trueColor = buf[3];
-
- quint16 a = ntohs(*(quint16 *)(buf + 4));
- redBits = 0;
- while (a) { a >>= 1; redBits++; }
-
- a = ntohs(*(quint16 *)(buf + 6));
- greenBits = 0;
- while (a) { a >>= 1; greenBits++; }
-
- a = ntohs(*(quint16 *)(buf + 8));
- blueBits = 0;
- while (a) { a >>= 1; blueBits++; }
-
- redShift = buf[10];
- greenShift = buf[11];
- blueShift = buf[12];
-}
-
-void QRfbPixelFormat::write(QTcpSocket *s)
-{
- char buf[16];
- buf[0] = bitsPerPixel;
- buf[1] = depth;
- buf[2] = bigEndian;
- buf[3] = trueColor;
-
- quint16 a = 0;
- for (int i = 0; i < redBits; i++) a = (a << 1) | 1;
- *(quint16 *)(buf + 4) = htons(a);
-
- a = 0;
- for (int i = 0; i < greenBits; i++) a = (a << 1) | 1;
- *(quint16 *)(buf + 6) = htons(a);
-
- a = 0;
- for (int i = 0; i < blueBits; i++) a = (a << 1) | 1;
- *(quint16 *)(buf + 8) = htons(a);
-
- buf[10] = redShift;
- buf[11] = greenShift;
- buf[12] = blueShift;
- s->write(buf, 16);
-}
-
-
-void QRfbServerInit::setName(const char *n)
-{
- delete[] name;
- name = new char [strlen(n) + 1];
- strcpy(name, n);
-}
-
-void QRfbServerInit::read(QTcpSocket *s)
-{
- s->read((char *)&width, 2);
- width = ntohs(width);
- s->read((char *)&height, 2);
- height = ntohs(height);
- format.read(s);
-
- quint32 len;
- s->read((char *)&len, 4);
- len = ntohl(len);
-
- name = new char [len + 1];
- s->read(name, len);
- name[len] = '\0';
-}
-
-void QRfbServerInit::write(QTcpSocket *s)
-{
- quint16 t = htons(width);
- s->write((char *)&t, 2);
- t = htons(height);
- s->write((char *)&t, 2);
- format.write(s);
- quint32 len = strlen(name);
- len = htonl(len);
- s->write((char *)&len, 4);
- s->write(name, strlen(name));
-}
-
-bool QRfbSetEncodings::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 3)
- return false;
-
- char tmp;
- s->read(&tmp, 1); // padding
- s->read((char *)&count, 2);
- count = ntohs(count);
-
- return true;
-}
-
-bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 9)
- return false;
-
- s->read(&incremental, 1);
- rect.read(s);
-
- return true;
-}
-
-bool QRfbKeyEvent::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 7)
- return false;
-
- s->read(&down, 1);
- quint16 tmp;
- s->read((char *)&tmp, 2); // padding
-
- quint32 key;
- s->read((char *)&key, 4);
- key = ntohl(key);
-
- unicode = 0;
- keycode = 0;
- int i = 0;
- while (keyMap[i].keysym && !keycode) {
- if (keyMap[i].keysym == (int)key)
- keycode = keyMap[i].keycode;
- i++;
- }
-
- if (keycode >= ' ' && keycode <= '~')
- unicode = keycode;
-
- if (!keycode) {
- if (key <= 0xff) {
- unicode = key;
- if (key >= 'a' && key <= 'z')
- keycode = Qt::Key_A + key - 'a';
- else if (key >= ' ' && key <= '~')
- keycode = Qt::Key_Space + key - ' ';
- }
- }
-
- return true;
-}
-
-bool QRfbPointerEvent::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 5)
- return false;
-
- char buttonMask;
- s->read(&buttonMask, 1);
- buttons = 0;
- if (buttonMask & 1)
- buttons |= Qt::LeftButton;
- if (buttonMask & 2)
- buttons |= Qt::MidButton;
- if (buttonMask & 4)
- buttons |= Qt::RightButton;
-
- quint16 tmp;
- s->read((char *)&tmp, 2);
- x = ntohs(tmp);
- s->read((char *)&tmp, 2);
- y = ntohs(tmp);
-
- return true;
-}
-
-bool QRfbClientCutText::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 7)
- return false;
-
- char tmp[3];
- s->read(tmp, 3); // padding
- s->read((char *)&length, 4);
- length = ntohl(length);
-
- return true;
-}
-
-//===========================================================================
-
-QVNCServer::QVNCServer(QVNCScreen *screen)
- : qvnc_screen(screen)
-{
- init(5900);
-}
-
-QVNCServer::QVNCServer(QVNCScreen *screen, int id)
- : qvnc_screen(screen)
-{
- init(5900 + id);
-}
-
-void QVNCServer::init(uint port)
-{
- handleMsg = false;
- client = 0;
- encodingsPending = 0;
- cutTextPending = 0;
- keymod = 0;
- state = Unconnected;
- dirtyCursor = false;
-
- refreshRate = 25;
- timer = new QTimer(this);
- timer->setSingleShot(true);
- connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
-
- serverSocket = new QTcpServer(this);
- if (!serverSocket->listen(QHostAddress::Any, port))
- qDebug() << "QVNCServer could not connect:" << serverSocket->errorString();
- else
- qDebug("QVNCServer created on port %d", port);
-
- connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection()));
-
-#ifndef QT_NO_QWS_CURSOR
- qvnc_cursor = 0;
-#endif
- encoder = 0;
-}
-
-QVNCServer::~QVNCServer()
-{
- delete encoder;
- encoder = 0;
- delete client;
- client = 0;
-#ifndef QT_NO_QWS_CURSOR
- delete qvnc_cursor;
- qvnc_cursor = 0;
-#endif
-}
-
-void QVNCServer::setDirty()
-{
- if (state == Connected && !timer->isActive() &&
- ((dirtyMap()->numDirty > 0) || dirtyCursor)) {
- timer->start();
- }
-}
-
-void QVNCServer::newConnection()
-{
- if (client)
- delete client;
-
- client = serverSocket->nextPendingConnection();
- connect(client,SIGNAL(readyRead()),this,SLOT(readClient()));
- connect(client,SIGNAL(disconnected()),this,SLOT(discardClient()));
- handleMsg = false;
- encodingsPending = 0;
- cutTextPending = 0;
- supportHextile = false;
- wantUpdate = false;
-
- timer->start(1000 / refreshRate);
- dirtyMap()->reset();
-
- // send protocol version
- const char *proto = "RFB 003.003\n";
- client->write(proto, 12);
- state = Protocol;
-
- if (!qvnc_screen->screen() && !qvnc_screen->d_ptr->noDisablePainting)
- QWSServer::instance()->enablePainting(true);
-}
-
-void QVNCServer::readClient()
-{
- switch (state) {
- case Protocol:
- if (client->bytesAvailable() >= 12) {
- char proto[13];
- client->read(proto, 12);
- proto[12] = '\0';
- qDebug("Client protocol version %s", proto);
- // No authentication
- quint32 auth = htonl(1);
- client->write((char *) &auth, sizeof(auth));
- state = Init;
- }
- break;
-
- case Init:
- if (client->bytesAvailable() >= 1) {
- quint8 shared;
- client->read((char *) &shared, 1);
-
- // Server Init msg
- QRfbServerInit sim;
- QRfbPixelFormat &format = sim.format;
- switch (qvnc_screen->depth()) {
- case 32:
- format.bitsPerPixel = 32;
- format.depth = 32;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 8;
- format.greenBits = 8;
- format.blueBits = 8;
- format.redShift = 16;
- format.greenShift = 8;
- format.blueShift = 0;
- break;
-
- case 24:
- format.bitsPerPixel = 24;
- format.depth = 24;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 8;
- format.greenBits = 8;
- format.blueBits = 8;
- format.redShift = 16;
- format.greenShift = 8;
- format.blueShift = 0;
- break;
-
- case 18:
- format.bitsPerPixel = 24;
- format.depth = 18;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 6;
- format.greenBits = 6;
- format.blueBits = 6;
- format.redShift = 12;
- format.greenShift = 6;
- format.blueShift = 0;
- break;
-
- case 16:
- format.bitsPerPixel = 16;
- format.depth = 16;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 5;
- format.greenBits = 6;
- format.blueBits = 5;
- format.redShift = 11;
- format.greenShift = 5;
- format.blueShift = 0;
- break;
-
- case 15:
- format.bitsPerPixel = 16;
- format.depth = 15;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 5;
- format.greenBits = 5;
- format.blueBits = 5;
- format.redShift = 10;
- format.greenShift = 5;
- format.blueShift = 0;
- break;
-
- case 12:
- format.bitsPerPixel = 16;
- format.depth = 12;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 4;
- format.greenBits = 4;
- format.blueBits = 4;
- format.redShift = 8;
- format.greenShift = 4;
- format.blueShift = 0;
- break;
-
- case 8:
- case 4:
- format.bitsPerPixel = 8;
- format.depth = 8;
- format.bigEndian = 0;
- format.trueColor = false;
- format.redBits = 0;
- format.greenBits = 0;
- format.blueBits = 0;
- format.redShift = 0;
- format.greenShift = 0;
- format.blueShift = 0;
- break;
-
- default:
- qDebug("QVNC cannot drive depth %d", qvnc_screen->depth());
- discardClient();
- return;
- }
- sim.width = qvnc_screen->deviceWidth();
- sim.height = qvnc_screen->deviceHeight();
- sim.setName("Qt for Embedded Linux VNC Server");
- sim.write(client);
- state = Connected;
- }
- break;
-
- case Connected:
- do {
- if (!handleMsg) {
- client->read((char *)&msgType, 1);
- handleMsg = true;
- }
- if (handleMsg) {
- switch (msgType ) {
- case SetPixelFormat:
- setPixelFormat();
- break;
- case FixColourMapEntries:
- qDebug("Not supported: FixColourMapEntries");
- handleMsg = false;
- break;
- case SetEncodings:
- setEncodings();
- break;
- case FramebufferUpdateRequest:
- frameBufferUpdateRequest();
- break;
- case KeyEvent:
- keyEvent();
- break;
- case PointerEvent:
- pointerEvent();
- break;
- case ClientCutText:
- clientCutText();
- break;
- default:
- qDebug("Unknown message type: %d", (int)msgType);
- handleMsg = false;
- }
- }
- } while (!handleMsg && client->bytesAvailable());
- break;
- default:
- break;
- }
-}
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-bool QVNCScreen::swapBytes() const
-{
- if (depth() != 16)
- return false;
-
- if (screen())
- return screen()->frameBufferLittleEndian();
- return frameBufferLittleEndian();
-}
-#endif
-
-void QVNCServer::setPixelFormat()
-{
- if (client->bytesAvailable() >= 19) {
- char buf[3];
- client->read(buf, 3); // just padding
- pixelFormat.read(client);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("Want format: %d %d %d %d %d %d %d %d %d %d",
- int(pixelFormat.bitsPerPixel),
- int(pixelFormat.depth),
- int(pixelFormat.bigEndian),
- int(pixelFormat.trueColor),
- int(pixelFormat.redBits),
- int(pixelFormat.greenBits),
- int(pixelFormat.blueBits),
- int(pixelFormat.redShift),
- int(pixelFormat.greenShift),
- int(pixelFormat.blueShift));
-#endif
- if (!pixelFormat.trueColor) {
- qDebug("Can only handle true color clients");
- discardClient();
- }
- handleMsg = false;
- sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian;
- needConversion = pixelConversionNeeded();
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- swapBytes = qvnc_screen->swapBytes();
-#endif
- }
-}
-
-void QVNCServer::setEncodings()
-{
- QRfbSetEncodings enc;
-
- if (!encodingsPending && enc.read(client)) {
- encodingsPending = enc.count;
- if (!encodingsPending)
- handleMsg = false;
- }
-
- if (encoder) {
- delete encoder;
- encoder = 0;
- }
-
- enum Encodings {
- Raw = 0,
- CopyRect = 1,
- RRE = 2,
- CoRRE = 4,
- Hextile = 5,
- ZRLE = 16,
- Cursor = -239,
- DesktopSize = -223
- };
-
- if (encodingsPending && (unsigned)client->bytesAvailable() >=
- encodingsPending * sizeof(quint32)) {
- for (int i = 0; i < encodingsPending; ++i) {
- qint32 enc;
- client->read((char *)&enc, sizeof(qint32));
- enc = ntohl(enc);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: %d", enc);
-#endif
- switch (enc) {
- case Raw:
- if (!encoder) {
- encoder = new QRfbRawEncoder(this);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: using raw");
-#endif
- }
- break;
- case CopyRect:
- supportCopyRect = true;
- break;
- case RRE:
- supportRRE = true;
- break;
- case CoRRE:
- supportCoRRE = true;
- break;
- case Hextile:
- supportHextile = true;
- if (encoder)
- break;
- switch (qvnc_screen->depth()) {
-#ifdef QT_QWS_DEPTH_8
- case 8:
- encoder = new QRfbHextileEncoder<quint8>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_12
- case 12:
- encoder = new QRfbHextileEncoder<qrgb444>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15:
- encoder = new QRfbHextileEncoder<qrgb555>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_16
- case 16:
- encoder = new QRfbHextileEncoder<quint16>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_18
- case 18:
- encoder = new QRfbHextileEncoder<qrgb666>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24:
- encoder = new QRfbHextileEncoder<qrgb888>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_32
- case 32:
- encoder = new QRfbHextileEncoder<quint32>(this);
- break;
-#endif
- default:
- break;
- }
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: using hextile");
-#endif
- break;
- case ZRLE:
- supportZRLE = true;
- break;
- case Cursor:
- supportCursor = true;
-#ifndef QT_NO_QWS_CURSOR
- if (!qvnc_screen->screen() || qt_screencursor->isAccelerated()) {
- delete qvnc_cursor;
- qvnc_cursor = new QVNCClientCursor(this);
- }
-#endif
- break;
- case DesktopSize:
- supportDesktopSize = true;
- break;
- default:
- break;
- }
- }
- handleMsg = false;
- encodingsPending = 0;
- }
-
- if (!encoder) {
- encoder = new QRfbRawEncoder(this);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: fallback using raw");
-#endif
- }
-}
-
-void QVNCServer::frameBufferUpdateRequest()
-{
- QRfbFrameBufferUpdateRequest ev;
-
- if (ev.read(client)) {
- if (!ev.incremental) {
- QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h);
- r.translate(qvnc_screen->offset());
- qvnc_screen->d_ptr->setDirty(r, true);
- }
- wantUpdate = true;
- checkUpdate();
- handleMsg = false;
- }
-}
-
-void QVNCServer::pointerEvent()
-{
- QRfbPointerEvent ev;
- if (ev.read(client)) {
- const QPoint offset = qvnc_screen->offset();
- QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons);
- handleMsg = false;
- }
-}
-
-void QVNCServer::keyEvent()
-{
- QRfbKeyEvent ev;
-
- if (ev.read(client)) {
- if (ev.keycode == Qt::Key_Shift)
- keymod = ev.down ? keymod | Qt::ShiftModifier :
- keymod & ~Qt::ShiftModifier;
- else if (ev.keycode == Qt::Key_Control)
- keymod = ev.down ? keymod | Qt::ControlModifier :
- keymod & ~Qt::ControlModifier;
- else if (ev.keycode == Qt::Key_Alt)
- keymod = ev.down ? keymod | Qt::AltModifier :
- keymod & ~Qt::AltModifier;
- if (ev.unicode || ev.keycode)
- QWSServer::sendKeyEvent(ev.unicode, ev.keycode, keymod, ev.down, false);
- handleMsg = false;
- }
-}
-
-void QVNCServer::clientCutText()
-{
- QRfbClientCutText ev;
-
- if (cutTextPending == 0 && ev.read(client)) {
- cutTextPending = ev.length;
- if (!cutTextPending)
- handleMsg = false;
- }
-
- if (cutTextPending && client->bytesAvailable() >= cutTextPending) {
- char *text = new char [cutTextPending+1];
- client->read(text, cutTextPending);
- delete [] text;
- cutTextPending = 0;
- handleMsg = false;
- }
-}
-
-// stride in bytes
-template <class SRC>
-bool QRfbSingleColorHextile<SRC>::read(const uchar *data,
- int width, int height, int stride)
-{
- const int depth = encoder->server->screen()->depth();
- if (width % (depth / 8)) // hw: should rather fallback to simple loop
- return false;
-
- static int alwaysFalse = qgetenv("QT_VNC_NOCHECKFILL").toInt();
- if (alwaysFalse)
- return false;
-
- switch (depth) {
- case 4: {
- const quint8 *data8 = reinterpret_cast<const quint8*>(data);
- if ((data8[0] & 0xf) != (data8[0] >> 4))
- return false;
- width /= 2;
- } // fallthrough
- case 8: {
- const quint8 *data8 = reinterpret_cast<const quint8*>(data);
- if (data8[0] != data8[1])
- return false;
- width /= 2;
- } // fallthrough
- case 12:
- case 15:
- case 16: {
- const quint16 *data16 = reinterpret_cast<const quint16*>(data);
- if (data16[0] != data16[1])
- return false;
- width /= 2;
- } // fallthrough
- case 18:
- case 24:
- case 32: {
- const quint32 *data32 = reinterpret_cast<const quint32*>(data);
- const quint32 first = data32[0];
- const int linestep = (stride / sizeof(quint32)) - width;
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- if (*(data32++) != first)
- return false;
- }
- data32 += linestep;
- }
- break;
- }
- default:
- return false;
- }
-
- SRC color = reinterpret_cast<const SRC*>(data)[0];
- encoder->newBg |= (color != encoder->bg);
- encoder->bg = color;
- return true;
-}
-
-template <class SRC>
-void QRfbSingleColorHextile<SRC>::write(QTcpSocket *socket) const
-{
- if (true || encoder->newBg) {
- const int bpp = encoder->server->clientBytesPerPixel();
- const int padding = 3;
- QVarLengthArray<char> buffer(padding + 1 + bpp);
- buffer[padding] = 2; // BackgroundSpecified
- encoder->server->convertPixels(buffer.data() + padding + 1,
- reinterpret_cast<char*>(&encoder->bg),
- 1);
- socket->write(buffer.data() + padding, bpp + 1);
-// encoder->newBg = false;
- } else {
- char subenc = 0;
- socket->write(&subenc, 1);
- }
-}
-
-template <class SRC>
-bool QRfbDualColorHextile<SRC>::read(const uchar *data,
- int width, int height, int stride)
-{
- const SRC *ptr = reinterpret_cast<const SRC*>(data);
- const int linestep = (stride / sizeof(SRC)) - width;
-
- SRC c1;
- SRC c2 = 0;
- int n1 = 0;
- int n2 = 0;
- int x = 0;
- int y = 0;
-
- c1 = *ptr;
-
- // find second color
- while (y < height) {
- while (x < width) {
- if (*ptr == c1) {
- ++n1;
- } else {
- c2 = *ptr;
- goto found_second_color;
- }
- ++ptr;
- ++x;
- }
- x = 0;
- ptr += linestep;
- ++y;
- }
-
-found_second_color:
- // finish counting
- while (y < height) {
- while (x < width) {
- if (*ptr == c1) {
- ++n1;
- } else if (*ptr == c2) {
- ++n2;
- } else {
- return false;
- }
- ++ptr;
- ++x;
- }
- x = 0;
- ptr += linestep;
- ++y;
- }
-
- if (n2 > n1) {
- const quint32 tmpC = c1;
- c1 = c2;
- c2 = tmpC;
- }
-
- encoder->newBg |= (c1 != encoder->bg);
- encoder->newFg |= (c2 != encoder->fg);
-
- encoder->bg = c1;
- encoder->fg = c2;
-
- // create map
- bool inRect = false;
- numRects = 0;
- ptr = reinterpret_cast<const SRC*>(data);
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- if (inRect && *ptr == encoder->bg) {
- // rect finished
- setWidth(x - lastx());
- next();
- inRect = false;
- } else if (!inRect && *ptr == encoder->fg) {
- // rect start
- setX(x);
- setY(y);
- setHeight(1);
- inRect = true;
- }
- ++ptr;
- }
- if (inRect) {
- // finish rect
- setWidth(width - lastx());
- next();
- inRect = false;
- }
- ptr += linestep;
- }
-
- return true;
-}
-
-template <class SRC>
-void QRfbDualColorHextile<SRC>::write(QTcpSocket *socket) const
-{
- const int bpp = encoder->server->clientBytesPerPixel();
- const int padding = 3;
- QVarLengthArray<char> buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects));
- char &subenc = buffer[padding];
- int n = padding + sizeof(subenc);
-
- subenc = 0x8; // AnySubrects
-
- if (encoder->newBg) {
- subenc |= 0x2; // Background
- encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1);
- n += bpp;
-// encoder->newBg = false;
- }
-
- if (encoder->newFg) {
- subenc |= 0x4; // Foreground
- encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1);
- n += bpp;
-// encoder->newFg = false;
- }
- buffer[n] = numRects;
- n += sizeof(numRects);
-
- socket->write(buffer.data() + padding, n - padding);
- socket->write((char*)rects, numRects * sizeof(Rect));
-}
-
-template <class SRC>
-void QRfbDualColorHextile<SRC>::next()
-{
- for (int r = numRects - 1; r >= 0; --r) {
- if (recty(r) == lasty())
- continue;
- if (recty(r) < lasty() - 1) // only search previous scanline
- break;
- if (rectx(r) == lastx() && width(r) == width(numRects)) {
- ++rects[r].wh;
- return;
- }
- }
- ++numRects;
-}
-
-template <class SRC>
-inline void QRfbMultiColorHextile<SRC>::setColor(SRC color)
-{
- encoder->server->convertPixels(reinterpret_cast<char*>(rect(numRects)),
- (const char*)&color, 1);
-}
-
-template <class SRC>
-inline bool QRfbMultiColorHextile<SRC>::beginRect()
-{
- if ((rects.size() + bpp + 2) > maxRectsSize)
- return false;
- rects.resize(rects.size() + bpp + 2);
- return true;
-}
-
-template <class SRC>
-inline void QRfbMultiColorHextile<SRC>::endRect()
-{
- setHeight(numRects, 1);
- ++numRects;
-}
-
-template <class SRC>
-bool QRfbMultiColorHextile<SRC>::read(const uchar *data,
- int width, int height, int stride)
-{
- const SRC *ptr = reinterpret_cast<const SRC*>(data);
- const int linestep = (stride / sizeof(SRC)) - width;
-
- bpp = encoder->server->clientBytesPerPixel();
-
- if (encoder->newBg)
- encoder->bg = ptr[0];
-
- const SRC bg = encoder->bg;
- SRC color = bg;
- bool inRect = false;
-
- numRects = 0;
- rects.clear();
-
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- if (inRect && *ptr != color) { // end rect
- setWidth(numRects, x - rectx(numRects));
- endRect();
- inRect = false;
- }
-
- if (!inRect && *ptr != bg) { // begin rect
- if (!beginRect())
- return false;
- inRect = true;
- color = *ptr;
- setColor(color);
- setX(numRects, x);
- setY(numRects, y);
- }
- ++ptr;
- }
- if (inRect) { // end rect
- setWidth(numRects, width - rectx(numRects));
- endRect();
- inRect = false;
- }
- ptr += linestep;
- }
-
- return true;
-}
-
-template <class SRC>
-void QRfbMultiColorHextile<SRC>::write(QTcpSocket *socket) const
-{
- const int padding = 3;
- QVarLengthArray<quint8> buffer(bpp + padding + sizeof(quint8) + sizeof(numRects));
-
- quint8 &subenc = buffer[padding];
- int n = padding + sizeof(quint8);
-
- subenc = 8 | 16; // AnySubrects | SubrectsColoured
-
- if (encoder->newBg) {
- subenc |= 0x2; // Background
- encoder->server->convertPixels(reinterpret_cast<char*>(buffer.data() + n),
- reinterpret_cast<const char*>(&encoder->bg),
- 1);
- n += bpp;
-// encoder->newBg = false;
- }
-
- buffer[n] = numRects;
- n += sizeof(numRects);
-
- socket->write(reinterpret_cast<const char*>(buffer.data() + padding),
- n - padding);
- socket->write(reinterpret_cast<const char*>(rects.constData()),
- rects.size());
-}
-
-bool QVNCServer::pixelConversionNeeded() const
-{
- if (!sameEndian)
- return true;
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (qvnc_screen->swapBytes())
- return true;
-#endif
-
- const int screendepth = qvnc_screen->depth();
- if (screendepth != pixelFormat.bitsPerPixel)
- return true;
-
- switch (screendepth) {
- case 32:
- case 24:
- return false;
- case 18:
- return (pixelFormat.redBits == 6
- && pixelFormat.greenBits == 6
- && pixelFormat.blueBits == 6);
- case 16:
- return (pixelFormat.redBits == 5
- && pixelFormat.greenBits == 6
- && pixelFormat.blueBits == 5);
- case 15:
- return (pixelFormat.redBits == 5
- && pixelFormat.greenBits == 5
- && pixelFormat.blueBits == 5);
- case 12:
- return (pixelFormat.redBits == 4
- && pixelFormat.greenBits == 4
- && pixelFormat.blueBits == 4);
- }
- return true;
-}
-
-// count: number of pixels
-void QVNCServer::convertPixels(char *dst, const char *src, int count) const
-{
- const int screendepth = qvnc_screen->depth();
- const bool isBgr = qvnc_screen->pixelType() == QScreen::BGRPixel;
-
- // cutoffs
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (!swapBytes)
-#endif
- if (sameEndian) {
- if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs
-
- switch (screendepth) {
- case 32:
- memcpy(dst, src, count * sizeof(quint32));
- return;
- case 16:
- if (pixelFormat.redBits == 5
- && pixelFormat.greenBits == 6
- && pixelFormat.blueBits == 5)
- {
- memcpy(dst, src, count * sizeof(quint16));
- return;
- }
- }
- } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) {
-#if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned
- const quint32 *src32 = reinterpret_cast<const quint32*>(src);
- quint32 *dst32 = reinterpret_cast<quint32*>(dst);
- int count32 = count * sizeof(quint16) / sizeof(quint32);
- while (count32--) {
- const quint32 s = *src32++;
- quint32 result1;
- quint32 result2;
-
- // red
- result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8;
- result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8;
-
- // green
- result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11;
- result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5;
-
- // blue
- result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13;
- result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3;
-
- *dst32++ = result2;
- *dst32++ = result1;
- }
- if (count & 0x1) {
- const quint16 *src16 = reinterpret_cast<const quint16*>(src);
- *dst32 = qt_conv16ToRgb(src16[count - 1]);
- }
- return;
-#endif
- }
- }
-
- const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8;
-
-// nibble = 0;
-
- for (int i = 0; i < count; ++i) {
- int r, g, b;
-
- switch (screendepth) {
-#if 0
- case 4: {
- if (!nibble) {
- r = ((*src) & 0x0f) << 4;
- } else {
- r = (*src) & 0xf0;
- src++;
- }
- nibble = !nibble;
- g = b = r;
- break;
- }
-#endif
- case 8: {
- QRgb rgb = qvnc_screen->clut()[int(*src)];
- r = qRed(rgb);
- g = qGreen(rgb);
- b = qBlue(rgb);
- src++;
- break;
- }
-#ifdef QT_QWS_DEPTH_12
- case 12: {
- quint32 p = quint32(*reinterpret_cast<const qrgb444*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb444);
- break;
- }
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15: {
- quint32 p = quint32(*reinterpret_cast<const qrgb555*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb555);
- break;
- }
-#endif
- case 16: {
- quint16 p = *reinterpret_cast<const quint16*>(src);
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (swapBytes)
- p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
-#endif
- r = (p >> 11) & 0x1f;
- g = (p >> 5) & 0x3f;
- b = p & 0x1f;
- r <<= 3;
- g <<= 2;
- b <<= 3;
- src += sizeof(quint16);
- break;
- }
-#ifdef QT_QWS_DEPTH_18
- case 18: {
- quint32 p = quint32(*reinterpret_cast<const qrgb666*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb666);
- break;
- }
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24: {
- quint32 p = quint32(*reinterpret_cast<const qrgb888*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb888);
- break;
- }
-#endif
- case 32: {
- quint32 p = *reinterpret_cast<const quint32*>(src);
- r = (p >> 16) & 0xff;
- g = (p >> 8) & 0xff;
- b = p & 0xff;
- src += sizeof(quint32);
- break;
- }
- default: {
- r = g = b = 0;
- qDebug("QVNCServer: don't support %dbpp display", screendepth);
- return;
- }
- }
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (swapBytes ^ isBgr)
-#else
- if (isBgr)
-#endif
- qSwap(r, b);
-
- r >>= (8 - pixelFormat.redBits);
- g >>= (8 - pixelFormat.greenBits);
- b >>= (8 - pixelFormat.blueBits);
-
- int pixel = (r << pixelFormat.redShift) |
- (g << pixelFormat.greenShift) |
- (b << pixelFormat.blueShift);
-
- if (sameEndian || pixelFormat.bitsPerPixel == 8) {
- memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead?
- dst += bytesPerPixel;
- continue;
- }
-
-
- if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
- switch (pixelFormat.bitsPerPixel) {
- case 16:
- pixel = (((pixel & 0x0000ff00) << 8) |
- ((pixel & 0x000000ff) << 24));
- break;
- case 32:
- pixel = (((pixel & 0xff000000) >> 24) |
- ((pixel & 0x00ff0000) >> 8) |
- ((pixel & 0x0000ff00) << 8) |
- ((pixel & 0x000000ff) << 24));
- break;
- default:
- qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel);
- }
- } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian
- switch (pixelFormat.bitsPerPixel) {
- case 16:
- pixel = (((pixel & 0xff000000) >> 8) |
- ((pixel & 0x00ff0000) << 8));
- break;
- case 32:
- pixel = (((pixel & 0xff000000) >> 24) |
- ((pixel & 0x00ff0000) >> 8) |
- ((pixel & 0x0000ff00) << 8) |
- ((pixel & 0x000000ff) << 24));
- break;
- default:
- qDebug("Cannot handle %d bpp client",
- pixelFormat.bitsPerPixel);
- break;
- }
- }
- memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead?
- dst += bytesPerPixel;
- }
-}
-
-#ifndef QT_NO_QWS_CURSOR
-static void blendCursor(QImage &image, const QRect &imageRect)
-{
- const QRect cursorRect = qt_screencursor->boundingRect();
- const QRect intersection = (cursorRect & imageRect);
- const QRect destRect = intersection.translated(-imageRect.topLeft());
- const QRect srcRect = intersection.translated(-cursorRect.topLeft());
-
- QPainter painter(&image);
- painter.drawImage(destRect, qt_screencursor->image(), srcRect);
- painter.end();
-}
-#endif // QT_NO_QWS_CURSOR
-
-QVNCDirtyMap::QVNCDirtyMap(QScreen *s)
- : bytesPerPixel(0), numDirty(0), screen(s)
-{
- bytesPerPixel = (screen->depth() + 7) / 8;
- bufferWidth = screen->deviceWidth();
- bufferHeight = screen->deviceHeight();
- bufferStride = bufferWidth * bytesPerPixel;
- buffer = new uchar[bufferHeight * bufferStride];
-
- mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
- mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
- numTiles = mapWidth * mapHeight;
- map = new uchar[numTiles];
-}
-
-QVNCDirtyMap::~QVNCDirtyMap()
-{
- delete[] map;
- delete[] buffer;
-}
-
-void QVNCDirtyMap::reset()
-{
- memset(map, 1, numTiles);
- memset(buffer, 0, bufferHeight * bufferStride);
- numDirty = numTiles;
-}
-
-inline bool QVNCDirtyMap::dirty(int x, int y) const
-{
- return map[y * mapWidth + x];
-}
-
-inline void QVNCDirtyMap::setClean(int x, int y)
-{
- map[y * mapWidth + x] = 0;
- --numDirty;
-}
-
-template <class T>
-void QVNCDirtyMapOptimized<T>::setDirty(int tileX, int tileY, bool force)
-{
- static bool alwaysForce = qgetenv("QT_VNC_NO_COMPAREBUFFER").toInt();
- if (alwaysForce)
- force = true;
-
- bool changed = false;
-
- if (!force) {
- const int lstep = screen->linestep();
- const int startX = tileX * MAP_TILE_SIZE;
- const int startY = tileY * MAP_TILE_SIZE;
- const uchar *scrn = screen->base()
- + startY * lstep + startX * bytesPerPixel;
- uchar *old = buffer + startY * bufferStride + startX * sizeof(T);
-
- const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ?
- bufferHeight - startY : MAP_TILE_SIZE);
- const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ?
- bufferWidth - startX : MAP_TILE_SIZE);
- const bool doInlines = (tileWidth == MAP_TILE_SIZE);
-
- int y = tileHeight;
-
- if (doInlines) { // hw: memcmp/memcpy is inlined when using constants
- while (y) {
- if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) {
- changed = true;
- break;
- }
- scrn += lstep;
- old += bufferStride;
- --y;
- }
-
- while (y) {
- memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE);
- scrn += lstep;
- old += bufferStride;
- --y;
- }
- } else {
- while (y) {
- if (memcmp(old, scrn, sizeof(T) * tileWidth)) {
- changed = true;
- break;
- }
- scrn += lstep;
- old += bufferStride;
- --y;
- }
-
- while (y) {
- memcpy(old, scrn, sizeof(T) * tileWidth);
- scrn += lstep;
- old += bufferStride;
- --y;
- }
- }
- }
-
- const int mapIndex = tileY * mapWidth + tileX;
- if ((force || changed) && !map[mapIndex]) {
- map[mapIndex] = 1;
- ++numDirty;
- }
-}
-
-template <class SRC>
-QRfbHextileEncoder<SRC>::QRfbHextileEncoder(QVNCServer *s)
- : QRfbEncoder(s),
- singleColorHextile(this), dualColorHextile(this), multiColorHextile(this)
-{
-}
-
-/*
- \internal
- Send dirty rects using hextile encoding.
-*/
-template <class SRC>
-void QRfbHextileEncoder<SRC>::write()
-{
- QWSDisplay::grab(true);
-
- QVNCDirtyMap *map = server->dirtyMap();
- QTcpSocket *socket = server->clientSocket();
-
- const quint32 encoding = htonl(5); // hextile encoding
- const int bytesPerPixel = server->clientBytesPerPixel();
-
- {
- const char tmp[2] = { 0, 0 }; // msg type, padding
- socket->write(tmp, sizeof(tmp));
- }
- {
- const quint16 count = htons(map->numDirty);
- socket->write((char *)&count, sizeof(count));
- }
-
- if (map->numDirty <= 0) {
- QWSDisplay::ungrab();
- return;
- }
-
- newBg = true;
- newFg = true;
-
- const QImage screenImage = server->screenImage();
- QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE);
-
- for (int y = 0; y < map->mapHeight; ++y) {
- if (rect.y + MAP_TILE_SIZE > server->screen()->height())
- rect.h = server->screen()->height() - rect.y;
- rect.w = MAP_TILE_SIZE;
- for (int x = 0; x < map->mapWidth; ++x) {
- if (!map->dirty(x, y))
- continue;
- map->setClean(x, y);
-
- rect.x = x * MAP_TILE_SIZE;
- if (rect.x + MAP_TILE_SIZE > server->screen()->deviceWidth())
- rect.w = server->screen()->deviceWidth() - rect.x;
- rect.write(socket);
-
- socket->write((char *)&encoding, sizeof(encoding));
-
- const uchar *screendata = screenImage.scanLine(rect.y)
- + rect.x * screenImage.depth() / 8;
- int linestep = screenImage.bytesPerLine();
-
-#ifndef QT_NO_QWS_CURSOR
- // hardware cursors must be blended with the screen memory
- const bool doBlendCursor = qt_screencursor
- && !server->hasClientCursor()
- && qt_screencursor->isAccelerated();
- QImage tileImage;
- if (doBlendCursor) {
- const QRect tileRect(rect.x, rect.y, rect.w, rect.h);
- const QRect cursorRect = qt_screencursor->boundingRect()
- .translated(-server->screen()->offset());
- if (tileRect.intersects(cursorRect)) {
- tileImage = screenImage.copy(tileRect);
- blendCursor(tileImage,
- tileRect.translated(server->screen()->offset()));
- screendata = tileImage.bits();
- linestep = tileImage.bytesPerLine();
- }
- }
-#endif // QT_NO_QWS_CURSOR
-
- if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) {
- singleColorHextile.write(socket);
- } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) {
- dualColorHextile.write(socket);
- } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) {
- multiColorHextile.write(socket);
- } else if (server->doPixelConversion()) {
- const int bufferSize = rect.w * rect.h * bytesPerPixel + 1;
- const int padding = sizeof(quint32) - sizeof(char);
- buffer.resize(bufferSize + padding);
-
- buffer[padding] = 1; // Raw subencoding
-
- // convert pixels
- char *b = buffer.data() + padding + 1;
- const int bstep = rect.w * bytesPerPixel;
- for (int i = 0; i < rect.h; ++i) {
- server->convertPixels(b, (const char*)screendata, rect.w);
- screendata += linestep;
- b += bstep;
- }
- socket->write(buffer.constData() + padding, bufferSize);
- } else {
- quint8 subenc = 1; // Raw subencoding
- socket->write((char *)&subenc, 1);
-
- // send pixels
- for (int i = 0; i < rect.h; ++i) {
- socket->write((const char*)screendata,
- rect.w * bytesPerPixel);
- screendata += linestep;
- }
- }
- }
- if (socket->state() == QAbstractSocket::UnconnectedState)
- break;
- rect.y += MAP_TILE_SIZE;
- }
- socket->flush();
- Q_ASSERT(map->numDirty == 0);
-
- QWSDisplay::ungrab();
-}
-
-void QRfbRawEncoder::write()
-{
- QWSDisplay::grab(false);
-
- QVNCDirtyMap *map = server->dirtyMap();
- QTcpSocket *socket = server->clientSocket();
-
- const int bytesPerPixel = server->clientBytesPerPixel();
-
- // create a region from the dirty rects and send the region's merged rects.
- QRegion rgn;
- if (map) {
- for (int y = 0; y < map->mapHeight; ++y) {
- for (int x = 0; x < map->mapWidth; ++x) {
- if (!map->dirty(x, y))
- continue;
- rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE,
- MAP_TILE_SIZE, MAP_TILE_SIZE);
- map->setClean(x, y);
- }
- }
-
- rgn &= QRect(0, 0, server->screen()->deviceWidth(),
- server->screen()->deviceHeight());
- }
- const QVector<QRect> rects = rgn.rects();
-
- {
- const char tmp[2] = { 0, 0 }; // msg type, padding
- socket->write(tmp, sizeof(tmp));
- }
-
- {
- const quint16 count = htons(rects.size());
- socket->write((char *)&count, sizeof(count));
- }
-
- if (rects.size() <= 0) {
- QWSDisplay::ungrab();
- return;
- }
-
- const QImage screenImage = server->screenImage();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect tileRect = rects.at(i);
- const QRfbRect rect(tileRect.x(), tileRect.y(),
- tileRect.width(), tileRect.height());
- rect.write(socket);
-
- const quint32 encoding = htonl(0); // raw encoding
- socket->write((char *)&encoding, sizeof(encoding));
-
- int linestep = screenImage.bytesPerLine();
- const uchar *screendata = screenImage.scanLine(rect.y)
- + rect.x * screenImage.depth() / 8;
-
-#ifndef QT_NO_QWS_CURSOR
- // hardware cursors must be blended with the screen memory
- const bool doBlendCursor = qt_screencursor
- && !server->hasClientCursor()
- && qt_screencursor->isAccelerated();
- QImage tileImage;
- if (doBlendCursor) {
- const QRect cursorRect = qt_screencursor->boundingRect()
- .translated(-server->screen()->offset());
- if (tileRect.intersects(cursorRect)) {
- tileImage = screenImage.copy(tileRect);
- blendCursor(tileImage,
- tileRect.translated(server->screen()->offset()));
- screendata = tileImage.bits();
- linestep = tileImage.bytesPerLine();
- }
- }
-#endif // QT_NO_QWS_CURSOR
-
- if (server->doPixelConversion()) {
- const int bufferSize = rect.w * rect.h * bytesPerPixel;
- if (bufferSize > buffer.size())
- buffer.resize(bufferSize);
-
- // convert pixels
- char *b = buffer.data();
- const int bstep = rect.w * bytesPerPixel;
- for (int i = 0; i < rect.h; ++i) {
- server->convertPixels(b, (const char*)screendata, rect.w);
- screendata += linestep;
- b += bstep;
- }
- socket->write(buffer.constData(), bufferSize);
- } else {
- for (int i = 0; i < rect.h; ++i) {
- socket->write((const char*)screendata, rect.w * bytesPerPixel);
- screendata += linestep;
- }
- }
- if (socket->state() == QAbstractSocket::UnconnectedState)
- break;
- }
- socket->flush();
-
- QWSDisplay::ungrab();
-}
-
-inline QImage QVNCServer::screenImage() const
-{
- return QImage(qvnc_screen->base(), qvnc_screen->deviceWidth(),
- qvnc_screen->deviceHeight(), qvnc_screen->linestep(),
- qvnc_screen->pixelFormat());
-}
-
-void QVNCServer::checkUpdate()
-{
- if (!wantUpdate)
- return;
-
- if (dirtyCursor) {
-#ifndef QT_NO_QWS_CURSOR
- Q_ASSERT(qvnc_cursor);
- qvnc_cursor->write();
-#endif
- dirtyCursor = false;
- wantUpdate = false;
- return;
- }
-
- if (dirtyMap()->numDirty > 0) {
- if (encoder)
- encoder->write();
- wantUpdate = false;
- }
-}
-
-void QVNCServer::discardClient()
-{
- timer->stop();
- state = Unconnected;
- delete encoder;
- encoder = 0;
-#ifndef QT_NO_QWS_CURSOR
- delete qvnc_cursor;
- qvnc_cursor = 0;
-#endif
- if (!qvnc_screen->screen() && !qvnc_screen->d_ptr->noDisablePainting && QWSServer::instance())
- QWSServer::instance()->enablePainting(false);
-}
-
-
-//===========================================================================
-
-/*!
- \class QVNCScreen
- \internal
- \ingroup qws
-
- \brief The QVNCScreen class implements a screen driver for VNC
- servers.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
- Custom screen drivers can be added by subclassing the QScreen
- class, using the QScreenDriverFactory class to dynamically load
- the driver into the application.
-
- The VNC protocol allows you to view and interact with the
- computer's display from anywhere on the network. See the
- \l{The VNC Protocol and Qt for Embedded Linux}{VNC protocol}
- documentation for more details.
-
- The default implementation of QVNCScreen inherits QLinuxFbScreen,
- but any QScreen subclass, or QScreen itself, can serve as its base
- class. This is easily achieved by manipulating the \c
- VNCSCREEN_BASE definition in the header file.
-
- \sa QScreen, {Running Applications}
-*/
-
-/*!
- \fn QVNCScreen::QVNCScreen(int displayId)
-
- Constructs a QVNCScreen object. The \a displayId argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-QVNCScreen::QVNCScreen(int display_id)
- : QProxyScreen(display_id, VNCClass)
-{
- d_ptr = new QVNCScreenPrivate(this);
-}
-
-/*!
- Destroys this QVNCScreen object.
-*/
-QVNCScreen::~QVNCScreen()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-void QVNCScreen::setDirty(const QRect &rect)
-{
- d_ptr->setDirty(rect);
-}
-
-void QVNCScreenPrivate::setDirty(const QRect& rect, bool force)
-{
- if (rect.isEmpty())
- return;
-
- if (q_ptr->screen())
- q_ptr->screen()->setDirty(rect);
-
- if (!vncServer || !vncServer->isConnected())
- return;
-
- const QRect r = rect.translated(-q_ptr->offset());
- const int x1 = r.x() / MAP_TILE_SIZE;
- int y = r.y() / MAP_TILE_SIZE;
- for (; (y <= r.bottom() / MAP_TILE_SIZE) && y < dirty->mapHeight; y++)
- for (int x = x1; (x <= r.right() / MAP_TILE_SIZE) && x < dirty->mapWidth; x++)
- dirty->setDirty(x, y, force);
-
- vncServer->setDirty();
-}
-
-static int getDisplayId(const QString &spec)
-{
- QRegExp regexp(QLatin1String(":(\\d+)\\b"));
- if (regexp.lastIndexIn(spec) != -1) {
- const QString capture = regexp.cap(1);
- return capture.toInt();
- }
- return 0;
-}
-
-/*!
- \reimp
-*/
-bool QVNCScreen::connect(const QString &displaySpec)
-{
- QString dspec = displaySpec;
- if (dspec.startsWith(QLatin1String("vnc:"), Qt::CaseInsensitive))
- dspec = dspec.mid(QString::fromLatin1("vnc:").size());
- else if (dspec.compare(QLatin1String("vnc"), Qt::CaseInsensitive) == 0)
- dspec = QString();
-
- const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId);
- if (dspec.endsWith(displayIdSpec))
- dspec = dspec.left(dspec.size() - displayIdSpec.size());
-
- QStringList args = dspec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
- QRegExp refreshRegexp(QLatin1String("^refreshrate=(\\d+)$"));
- int index = args.indexOf(refreshRegexp);
- if (index >= 0) {
- d_ptr->refreshRate = refreshRegexp.cap(1).toInt();
- args.removeAt(index);
- dspec = args.join(QLatin1String(":"));
- }
-
- QString driver = dspec;
- int colon = driver.indexOf(QLatin1Char(':'));
- if (colon >= 0)
- driver.truncate(colon);
-
- if (QScreenDriverFactory::keys().contains(driver, Qt::CaseInsensitive)) {
- const int id = getDisplayId(dspec);
- QScreen *s = qt_get_screen(id, dspec.toLatin1().constData());
- if (s->pixelFormat() == QImage::Format_Indexed8
- || s->pixelFormat() == QImage::Format_Invalid && s->depth() == 8)
- qFatal("QVNCScreen: unsupported screen format");
- setScreen(s);
- } else { // create virtual screen
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- QScreen::setFrameBufferLittleEndian(false);
-#endif
-
- d = qgetenv("QWS_DEPTH").toInt();
- if (!d)
- d = 16;
-
- QByteArray str = qgetenv("QWS_SIZE");
- if(!str.isEmpty()) {
- sscanf(str.constData(), "%dx%d", &w, &h);
- dw = w;
- dh = h;
- } else {
- dw = w = 640;
- dh = h = 480;
- }
-
- const QStringList args = displaySpec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
-
- if (args.contains(QLatin1String("paintonscreen"), Qt::CaseInsensitive))
- d_ptr->doOnScreenSurface = true;
-
- QRegExp depthRegexp(QLatin1String("^depth=(\\d+)$"));
- if (args.indexOf(depthRegexp) != -1)
- d = depthRegexp.cap(1).toInt();
-
- QRegExp sizeRegexp(QLatin1String("^size=(\\d+)x(\\d+)$"));
- if (args.indexOf(sizeRegexp) != -1) {
- dw = w = sizeRegexp.cap(1).toInt();
- dh = h = sizeRegexp.cap(2).toInt();
- }
-
- // Handle display physical size spec.
- QRegExp mmWidthRegexp(QLatin1String("^mmWidth=?(\\d+)$"));
- if (args.indexOf(mmWidthRegexp) != -1) {
- const int mmWidth = mmWidthRegexp.cap(1).toInt();
- if (mmWidth > 0)
- d_ptr->dpiX = dw * 25.4 / mmWidth;
- }
- QRegExp mmHeightRegexp(QLatin1String("^mmHeight=?(\\d+)$"));
- if (args.indexOf(mmHeightRegexp) != -1) {
- const int mmHeight = mmHeightRegexp.cap(1).toInt();
- if (mmHeight > 0)
- d_ptr->dpiY = dh * 25.4 / mmHeight;
- }
- QRegExp dpiRegexp(QLatin1String("^dpi=(\\d+)(?:,(\\d+))?$"));
- if (args.indexOf(dpiRegexp) != -1) {
- const qreal dpiX = dpiRegexp.cap(1).toFloat();
- const qreal dpiY = dpiRegexp.cap(2).toFloat();
- if (dpiX > 0)
- d_ptr->dpiX = dpiX;
- d_ptr->dpiY = (dpiY > 0 ? dpiY : dpiX);
- }
-
- if (args.contains(QLatin1String("noDisablePainting")))
- d_ptr->noDisablePainting = true;
-
- QWSServer::setDefaultMouse("None");
- QWSServer::setDefaultKeyboard("None");
-
- d_ptr->configure();
- }
-
- // XXX
- qt_screen = this;
-
- return true;
-}
-
-/*!
- \reimp
-*/
-void QVNCScreen::disconnect()
-{
- QProxyScreen::disconnect();
-#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
- d_ptr->shm.detach();
-#endif
-}
-
-/*!
- \reimp
-*/
-bool QVNCScreen::initDevice()
-{
- if (!QProxyScreen::screen() && d == 4) {
- screencols = 16;
- int val = 0;
- for (int idx = 0; idx < 16; idx++, val += 17) {
- screenclut[idx] = qRgb(val, val, val);
- }
- }
- d_ptr->vncServer = new QVNCServer(this, displayId);
- d_ptr->vncServer->setRefreshRate(d_ptr->refreshRate);
-
- switch (depth()) {
-#ifdef QT_QWS_DEPTH_32
- case 32:
- d_ptr->dirty = new QVNCDirtyMapOptimized<quint32>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb888>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_18
- case 18:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb666>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_16
- case 16:
- d_ptr->dirty = new QVNCDirtyMapOptimized<quint16>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb555>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_12
- case 12:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb444>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_8
- case 8:
- d_ptr->dirty = new QVNCDirtyMapOptimized<quint8>(this);
- break;
-#endif
- default:
- qWarning("QVNCScreen::initDevice: No support for screen depth %d",
- depth());
- d_ptr->dirty = 0;
- return false;
- }
-
-
- const bool ok = QProxyScreen::initDevice();
-#ifndef QT_NO_QWS_CURSOR
- qt_screencursor = new QVNCCursor(this);
-#endif
- if (QProxyScreen::screen())
- return ok;
-
- // Disable painting if there is only 1 display and nothing is attached to the VNC server
- if (!d_ptr->noDisablePainting)
- QWSServer::instance()->enablePainting(false);
-
- return true;
-}
-
-/*!
- \reimp
-*/
-void QVNCScreen::shutdownDevice()
-{
- QProxyScreen::shutdownDevice();
- delete d_ptr->vncServer;
- delete d_ptr->dirty;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_VNC
diff --git a/src/plugins/gfxdrivers/vnc/vnc.pro b/src/plugins/gfxdrivers/vnc/vnc.pro
deleted file mode 100644
index 95e2ba7cf8..0000000000
--- a/src/plugins/gfxdrivers/vnc/vnc.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qgfxvnc
-load(qt_plugin)
-
-DEFINES += QT_QWS_VNC
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-HEADERS = \
- qscreenvnc_qws.h \
- qscreenvnc_p.h
-
-SOURCES = main.cpp \
- qscreenvnc_qws.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro
deleted file mode 100644
index 5c99291047..0000000000
--- a/src/plugins/graphicssystems/graphicssystems.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += trace
-!wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl
-contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) {
- SUBDIRS += openvg
-}
-
-contains(QT_CONFIG, shivavg) {
- # Only works under X11 at present
- !win32:!embedded:!mac:SUBDIRS += shivavg
-}
-
-!win32:!embedded:!mac:!symbian:CONFIG += x11
-
-x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += meego
diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp
deleted file mode 100644
index 6e4b61c754..0000000000
--- a/src/plugins/graphicssystems/meego/dithering.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// Implements two dithering methods:
-//
-// * convertRGBA32_to_RGB565
-//
-// This is implemented using Ordered Bayer Dithering. The code has been adapted
-// from QX11PixmapData::fromImage. This method was originally implemented using
-// Floyd-Steinberg dithering but was later changed to Ordered Dithering because
-// of the better quality of the results.
-//
-// * convertRGBA32_to_RGBA4444
-//
-// This is implemented using Floyd-Steinberg dithering.
-//
-// The alghorithm used here is not the fastest possible but it's prolly fast enough:
-// uses look-up tables, integer-only arthmetics and works in one pass on two lines
-// at a time. It's a high-quality dithering using 1/8 diffusion precission.
-// Each channel (RGBA) is diffused independently and alpha is dithered too.
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <QVarLengthArray>
-
-// Gets a component (red = 1, green = 2...) from a RGBA data structure.
-// data is unsigned char. stride is the number of bytes per line.
-#define GET_RGBA_COMPONENT(data, x, y, stride, c) (data[(y * stride) + (x << 2) + c])
-
-// Writes a new pixel with r, g, b to data in 565 16bit format. Data is a short.
-#define PUT_565(data, x, y, width, r, g, b) (data[(y * width) + x] = (r << 11) | (g << 5) | b)
-
-// Writes a new pixel with r, g, b, a to data in 4444 RGBA 16bit format. Data is a short.
-#define PUT_4444(data, x, y, width, r, g, b, a) (data[(y * width) + x] = (r << 12) | (g << 8) | (b << 4) | a)
-
-// Writes(ads) a new value to the diffusion accumulator. accumulator is a short.
-// x, y is a position in the accumulation buffer. y can be 0 or 1 -- we operate on two lines at time.
-#define ACCUMULATE(accumulator, x, y, width, v) if (x < width && x >= 0) accumulator[(y * width) + x] += v
-
-// Clamps a value to be in 0..255 range.
-#define CLAMP_256(v) if (v > 255) v = 255; if (v < 0) v = 0;
-
-// Converts incoming RGB32 (QImage::Format_RGB32) to RGB565. Returns the newly allocated data.
-unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride)
-{
- static bool thresholdMapInitialized = false;
- static int thresholdMap[16][16];
-
- if (!thresholdMapInitialized) {
- int i;
- int j;
- int n;
-
- thresholdMap[0][0] = 0;
- thresholdMap[1][0] = 2;
- thresholdMap[0][1] = 3;
- thresholdMap[1][1] = 1;
-
- for (n=2; n<16; n*=2) {
- for (i=0; i<n; i++) {
- for (j=0; j<n; j++) {
- thresholdMap[i][j] *= 4;
- thresholdMap[i+n][j] = thresholdMap[i][j] + 2;
- thresholdMap[i][j+n] = thresholdMap[i][j] + 3;
- thresholdMap[i+n][j+n] = thresholdMap[i][j] + 1;
- }
- }
- }
-
- thresholdMapInitialized = true;
- }
-
- // Output line stride. Aligned to 4 bytes.
- int alignedWidth = width;
- if (alignedWidth % 2 > 0)
- alignedWidth++;
-
- // Will store output
- unsigned short *out = (unsigned short *)malloc (alignedWidth * height * 2);
-
- int x;
- int y;
- int threshold;
-
- // For each line...
- for (y = 0; y < height; y++) {
-
- // For each column....
- for (x = 0; x < width; x++) {
-
- int r = GET_RGBA_COMPONENT(in, x, y, stride, 0);
- int g = GET_RGBA_COMPONENT(in, x, y, stride, 1);
- int b = GET_RGBA_COMPONENT(in, x, y, stride, 2);
-
- threshold = thresholdMap[x%16][y%16];
-
- if (r <= (255-(1<<3)) && ((r<<5) & 255) > threshold) r += (1<<3);
- if (g <= (255-(1<<2)) && ((g<<6) & 255) > threshold) g += (1<<2);
- if (b <= (255-(1<<3)) && ((b<<5) & 255) > threshold) b += (1<<3);
-
- // Write the newly produced pixel
- PUT_565(out, x, y, alignedWidth, ((b >> 3) & 0x1f), ((g >> 2) & 0x3f), ((r >> 3) & 0x1f));
- }
- }
-
- return out;
-}
-
-// Converts incoming RGBA32 (QImage::Format_ARGB32_Premultiplied) to RGB565. Returns the newly allocated data.
-// This function is similar (yet different) to the _565 variant but it makes sense to duplicate it here for simplicity.
-// The output has each scan line aligned to 4 bytes (as expected by GL by default).
-unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride)
-{
- // Output line stride. Aligned to 4 bytes.
- int alignedWidth = width;
- if (alignedWidth % 2 > 0)
- alignedWidth++;
-
- // Will store output
- unsigned short *out = (unsigned short *) malloc(alignedWidth * 2 * height);
-
- // Lookup tables for the 8bit => 4bit conversion
- unsigned char lookup_8bit_to_4bit[256];
- short lookup_8bit_to_4bit_diff[256];
-
- // Macros for the conversion using the lookup table.
- #define CONVERT_8BIT_TO_4BIT(v) (lookup_8bit_to_4bit[v])
- #define DIFF_8BIT_TO_4BIT(v) (lookup_8bit_to_4bit_diff[v])
-
- int i;
- int x, y, c; // Pixel we're processing. c is component number (0, 1, 2, 3 for r, b, b, a)
- short component[4]; // Stores the new components (r, g, b, a) for pixel produced during conversion
- short diff; // The difference between the converted value and the original one. To be accumulated.
- QVarLengthArray <short> accumulatorData(4 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines.
- short *accumulator[4]; // Helper for accessing the accumulator on a per-channel basis more easily.
- accumulator[0] = accumulatorData.data();
- accumulator[1] = accumulatorData.data() + width;
- accumulator[2] = accumulatorData.data() + (width * 2);
- accumulator[3] = accumulatorData.data() + (width * 3);
-
- // Produce the conversion lookup tables.
- for (i = 0; i < 256; i++) {
- lookup_8bit_to_4bit[i] = round(i / 16.0);
- // Before bitshifts: (i * 8) - (... * 16 * 8)
- lookup_8bit_to_4bit_diff[i] = (i << 3) - (lookup_8bit_to_4bit[i] << 7);
-
- if (lookup_8bit_to_4bit[i] > 15)
- lookup_8bit_to_4bit[i] = 15;
- }
-
- // Clear the accumulators
- memset(accumulator[0], 0, width * 4);
- memset(accumulator[1], 0, width * 4);
- memset(accumulator[2], 0, width * 4);
- memset(accumulator[3], 0, width * 4);
-
- // For each line...
- for (y = 0; y < height; y++) {
-
- // For each component (r, g, b, a)...
- memcpy(accumulator[0], accumulator[0] + width, width * 2);
- memset(accumulator[0] + width, 0, width * 2);
-
- memcpy(accumulator[1], accumulator[1] + width, width * 2);
- memset(accumulator[1] + width, 0, width * 2);
-
- memcpy(accumulator[2], accumulator[2] + width, width * 2);
- memset(accumulator[2] + width, 0, width * 2);
-
- memcpy(accumulator[3], accumulator[3] + width, width * 2);
- memset(accumulator[3] + width, 0, width * 2);
-
- // For each column....
- for (x = 0; x < width; x++) {
-
- // For each component (r, g, b, a)...
- for (c = 0; c < 4; c++) {
-
- // Get the 8bit value from the original image
- component[c] = GET_RGBA_COMPONENT(in, x, y, stride, c);
-
- // Add the diffusion for this pixel we stored in the accumulator.
- // >> 7 because the values in accumulator are stored * 128
- component[c] += accumulator[c][x] >> 7;
-
- // Make sure we're not over the boundaries.
- CLAMP_256(component[c]);
-
- // Store the difference from converting 8bit => 4bit and the orig pixel.
- // Convert 8bit => 4bit.
- diff = DIFF_8BIT_TO_4BIT(component[c]);
- component[c] = CONVERT_8BIT_TO_4BIT(component[c]);
-
- // Distribute the difference according to the matrix in the
- // accumulation bufffer.
- ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 7);
- ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 3);
- ACCUMULATE(accumulator[c], x, 1, width, diff * 5);
- ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 1);
- }
-
- // Write the newly produced pixel
- PUT_4444(out, x, y, alignedWidth, component[0], component[1], component[2], component[3]);
- }
- }
-
- return out;
-}
-
-unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride)
-{
- unsigned char *out = (unsigned char *) malloc(stride * height);
-
- // For each line...
- for (int y = 0; y < height; y++) {
- // For each column
- for (int x = 0; x < width; x++) {
- out[(stride * y) + (x * 4) + 0] = in[(stride * y) + (x * 4) + 2];
- out[(stride * y) + (x * 4) + 1] = in[(stride * y) + (x * 4) + 1];
- out[(stride * y) + (x * 4) + 2] = in[(stride * y) + (x * 4) + 0];
- out[(stride * y) + (x * 4) + 3] = in[(stride * y) + (x * 4) + 3];
- }
- }
-
- return out;
-}
diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro
deleted file mode 100644
index 6432825888..0000000000
--- a/src/plugins/graphicssystems/meego/meego.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qmeegographicssystem
-load(qt_plugin)
-
-QT += core-private gui-private opengl-private
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-HEADERS = qmeegographicssystem.h qmeegopixmapdata.h qmeegoextensions.h qmeegorasterpixmapdata.h qmeegolivepixmapdata.h
-SOURCES = qmeegographicssystem.cpp qmeegographicssystem.h qmeegographicssystemplugin.h qmeegographicssystemplugin.cpp qmeegopixmapdata.h qmeegopixmapdata.cpp qmeegoextensions.h qmeegoextensions.cpp qmeegorasterpixmapdata.h qmeegorasterpixmapdata.cpp qmeegolivepixmapdata.cpp qmeegolivepixmapdata.h dithering.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
deleted file mode 100644
index c1a8eb7028..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegoextensions.h"
-#include <private/qeglcontext_p.h>
-#include <private/qpixmapdata_gl_p.h>
-
-bool QMeeGoExtensions::initialized = false;
-bool QMeeGoExtensions::hasImageShared = false;
-bool QMeeGoExtensions::hasSurfaceScaling = false;
-bool QMeeGoExtensions::hasLockSurface = false;
-bool QMeeGoExtensions::hasFenceSync = false;
-
-/* Extension funcs */
-
-typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*);
-typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK);
-typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint);
-typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHRFunc)(EGLDisplay, EGLSurface, const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHRFunc)(EGLDisplay, EGLSurface);
-typedef EGLSyncKHR (EGLAPIENTRY *eglCreateSyncKHRFunc)(EGLDisplay, EGLenum, const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *eglDestroySyncKHRFunc)(EGLDisplay, EGLSyncKHR);
-typedef EGLint (EGLAPIENTRY *eglClientWaitSyncKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR);
-typedef EGLBoolean (EGLAPIENTRY *eglGetSyncAttribKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLint*);
-
-static eglQueryImageNOKFunc _eglQueryImageNOK = 0;
-static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0;
-static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0;
-static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0;
-static eglLockSurfaceKHRFunc _eglLockSurfaceKHR = 0;
-static eglUnlockSurfaceKHRFunc _eglUnlockSurfaceKHR = 0;
-static eglCreateSyncKHRFunc _eglCreateSyncKHR = 0;
-static eglDestroySyncKHRFunc _eglDestroySyncKHR = 0;
-static eglClientWaitSyncKHRFunc _eglClientWaitSyncKHR = 0;
-static eglGetSyncAttribKHRFunc _eglGetSyncAttribKHR = 0;
-
-/* Public */
-
-void QMeeGoExtensions::ensureInitialized()
-{
- if (!initialized)
- initialize();
-
- initialized = true;
-}
-
-EGLNativeSharedImageTypeNOK QMeeGoExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props)
-{
- if (!hasImageShared)
- qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
- return _eglCreateSharedImageNOK(dpy, image, props);
-}
-
-bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v)
-{
- if (!hasImageShared)
- qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
- return _eglQueryImageNOK(dpy, image, prop, v);
-}
-
-bool QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img)
-{
- if (!hasImageShared)
- qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
- return _eglDestroySharedImageNOK(dpy, img);
-}
-
-bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height)
-{
- if (!hasSurfaceScaling)
- qFatal("EGL_NOK_surface_scaling not found but trying to use capability!");
-
- return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height);
-}
-
-bool QMeeGoExtensions::eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
-{
- if (!hasLockSurface)
- qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
-
- return _eglLockSurfaceKHR(display, surface, attrib_list);
-}
-
-bool QMeeGoExtensions::eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
-{
- if (!hasLockSurface)
- qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
-
- return _eglUnlockSurfaceKHR(display, surface);
-}
-
-EGLSyncKHR QMeeGoExtensions::eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglCreateSyncKHR(dpy, type, attrib_list);
-}
-
-bool QMeeGoExtensions::eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglDestroySyncKHR(dpy, sync);
-}
-
-EGLint QMeeGoExtensions::eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglClientWaitSyncKHR(dpy, sync, flags, timeout);
-}
-
-EGLBoolean QMeeGoExtensions::eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglGetSyncAttribKHR(dpy, sync, attribute, value);
-}
-
-/* Private */
-
-void QMeeGoExtensions::initialize()
-{
- QGLContext *ctx = (QGLContext *) QGLContext::currentContext();
- qt_resolve_eglimage_gl_extensions(ctx);
-
- if (QEgl::hasExtension("EGL_NOK_image_shared")) {
- qDebug("MeegoGraphics: found EGL_NOK_image_shared");
- _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK");
- _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK");
- _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK");
- _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
- _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
-
- Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK);
- hasImageShared = true;
- }
-
- if (QEgl::hasExtension("EGL_NOK_surface_scaling")) {
- qDebug("MeegoGraphics: found EGL_NOK_surface_scaling");
- _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK");
-
- Q_ASSERT(_eglSetSurfaceScalingNOK);
- hasSurfaceScaling = true;
- }
-
- if (QEgl::hasExtension("EGL_KHR_lock_surface2")) {
- qDebug("MeegoGraphics: found EGL_KHR_lock_surface2");
- _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
- _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
-
- Q_ASSERT(_eglLockSurfaceKHR && _eglUnlockSurfaceKHR);
- hasLockSurface = true;
- }
-
- if (QEgl::hasExtension("EGL_KHR_fence_sync")) {
- qDebug("MeegoGraphics: found EGL_KHR_fence_sync");
- _eglCreateSyncKHR = (eglCreateSyncKHRFunc) eglGetProcAddress("eglCreateSyncKHR");
- _eglDestroySyncKHR = (eglDestroySyncKHRFunc) eglGetProcAddress("eglDestroySyncKHR");
- _eglClientWaitSyncKHR = (eglClientWaitSyncKHRFunc) eglGetProcAddress("eglClientWaitSyncKHR");
- _eglGetSyncAttribKHR = (eglGetSyncAttribKHRFunc) eglGetProcAddress("eglGetSyncAttribKHR");
-
- Q_ASSERT(_eglCreateSyncKHR && _eglDestroySyncKHR && _eglClientWaitSyncKHR && _eglGetSyncAttribKHR);
- hasFenceSync = true;
- }
-}
-
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h
deleted file mode 100644
index e4ceed3a31..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegoextensions.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MEXTENSIONS_H
-#define MEXTENSIONS_H
-
-#include <private/qgl_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qpixmapdata_gl_p.h>
-#include <EGL/egl.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-/* Extensions decls */
-
-#ifndef EGL_SHARED_IMAGE_NOK
-#define EGL_SHARED_IMAGE_NOK 0x30DA
-typedef void* EGLNativeSharedImageTypeNOK;
-#endif
-
-#ifndef EGL_GL_TEXTURE_2D_KHR
-#define EGL_GL_TEXTURE_2D_KHR 0x30B1
-#endif
-
-#ifndef EGL_FIXED_WIDTH_NOK
-#define EGL_FIXED_WIDTH_NOK 0x30DB
-#define EGL_FIXED_HEIGHT_NOK 0x30DC
-#endif
-
-#ifndef EGL_BITMAP_POINTER_KHR
-#define EGL_BITMAP_POINTER_KHR 0x30C6
-#define EGL_BITMAP_PITCH_KHR 0x30C7
-#endif
-
-#ifndef EGL_MAP_PRESERVE_PIXELS_KHR
-#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4
-#define EGL_LOCK_USAGE_HINT_KHR 0x30C5
-#define EGL_READ_SURFACE_BIT_KHR 0x0001
-#define EGL_WRITE_SURFACE_BIT_KHR 0x0002
-#endif
-
-#ifndef EGL_SYNC_FENCE_KHR
-#define EGL_SYNC_FENCE_KHR 0x30F9
-#define EGL_SYNC_TYPE_KHR 0x30F7
-#define EGL_SYNC_STATUS_KHR 0x30F1
-#define EGL_SYNC_CONDITION_KHR 0x30F8
-#define EGL_SIGNALED_KHR 0x30F2
-#define EGL_UNSIGNALED_KHR 0x30F3
-#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
-#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001
-#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
-#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
-#define EGL_CONDITION_SATISFIED_KHR 0x30F6
-#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
-typedef void* EGLSyncKHR;
-typedef khronos_utime_nanoseconds_t EGLTimeKHR;
-#endif
-
-/* Class */
-
-class QMeeGoExtensions
-{
-public:
- static void ensureInitialized();
-
- static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props);
- static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v);
- static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img);
- static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height);
- static bool eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
- static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface);
- static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
- static bool eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
- static EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
- static EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
-
-private:
- static void initialize();
-
- static bool initialized;
- static bool hasImageShared;
- static bool hasSurfaceScaling;
- static bool hasLockSurface;
- static bool hasFenceSync;
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
deleted file mode 100644
index ab403797df..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ /dev/null
@@ -1,534 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include <private/qpixmap_raster_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#include <private/qwindowsurface_raster_p.h>
-#include <private/qegl_p.h>
-#include <private/qglextensions_p.h>
-#include <private/qgl_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_runtime_p.h>
-#include <private/qimage_p.h>
-#include <private/qeglproperties_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qpixmap_x11_p.h>
-
-#include "qmeegopixmapdata.h"
-#include "qmeegolivepixmapdata.h"
-#include "qmeegographicssystem.h"
-#include "qmeegoextensions.h"
-
-#include <QTimer>
-
-bool QMeeGoGraphicsSystem::surfaceWasCreated = false;
-
-QHash <Qt::HANDLE, QPixmap*> QMeeGoGraphicsSystem::liveTexturePixmaps;
-
-QList<QMeeGoSwitchCallback> QMeeGoGraphicsSystem::switchCallbacks;
-
-QMeeGoGraphicsSystem::SwitchPolicy QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::AutomaticSwitch;
-
-QMeeGoGraphicsSystem::QMeeGoGraphicsSystem()
-{
- qDebug("Using the meego graphics system");
-}
-
-QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem()
-{
- qDebug("Meego graphics system destroyed");
- qt_destroy_gl_share_widget();
-}
-
-class QMeeGoGraphicsSystemSwitchHandler : public QObject
-{
- Q_OBJECT
-public:
- QMeeGoGraphicsSystemSwitchHandler();
-
- void addWidget(QWidget *widget);
- bool eventFilter(QObject *, QEvent *);
-
- void handleMapNotify();
-
-private slots:
- void removeWidget(QObject *object);
- void switchToRaster();
- void switchToMeeGo();
-
-private:
- int visibleWidgets() const;
-
-private:
- QList<QWidget *> m_widgets;
-};
-
-typedef bool(*QX11FilterFunction)(XEvent *event);
-Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func);
-
-static bool x11EventFilter(XEvent *event);
-
-QMeeGoGraphicsSystemSwitchHandler::QMeeGoGraphicsSystemSwitchHandler()
-{
- qt_installX11EventFilter(x11EventFilter);
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::addWidget(QWidget *widget)
-{
- if (widget != qt_gl_share_widget() && !m_widgets.contains(widget)) {
- widget->installEventFilter(this);
- connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(removeWidget(QObject *)));
- m_widgets << widget;
- }
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::handleMapNotify()
-{
- if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
- QTimer::singleShot(0, this, SLOT(switchToMeeGo()));
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::removeWidget(QObject *object)
-{
- m_widgets.removeOne(static_cast<QWidget *>(object));
- if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
- QTimer::singleShot(0, this, SLOT(switchToRaster()));
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::switchToRaster()
-{
- QMeeGoGraphicsSystem::switchToRaster();
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::switchToMeeGo()
-{
- QMeeGoGraphicsSystem::switchToMeeGo();
-}
-
-int QMeeGoGraphicsSystemSwitchHandler::visibleWidgets() const
-{
- int count = 0;
- for (int i = 0; i < m_widgets.size(); ++i)
- count += m_widgets.at(i)->isVisible() && !(m_widgets.at(i)->windowState() & Qt::WindowMinimized);
- return count;
-}
-
-bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::WindowStateChange
- && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
- {
- QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event);
- QWidget *widget = static_cast<QWidget *>(object);
-
- Qt::WindowStates current = widget->windowState();
- Qt::WindowStates old = change->oldState();
-
- // did minimized flag change?
- if ((current ^ old) & Qt::WindowMinimized) {
- if (current & Qt::WindowMinimized) {
- if (visibleWidgets() == 0)
- QMeeGoGraphicsSystem::switchToRaster();
- } else {
- if (visibleWidgets() > 0)
- QMeeGoGraphicsSystem::switchToMeeGo();
- }
- }
- }
-
- // resume processing of event
- return false;
-}
-
-Q_GLOBAL_STATIC(QMeeGoGraphicsSystemSwitchHandler, switch_handler)
-
-bool x11EventFilter(XEvent *event)
-{
- if (event->type == MapNotify)
- switch_handler()->handleMapNotify();
- return false;
-}
-
-QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- QGLWidget *shareWidget = qt_gl_share_widget();
-
- if (!shareWidget)
- return new QRasterWindowSurface(widget);
-
- QGLShareContextScope ctx(shareWidget->context());
-
- if (QApplicationPrivate::instance()->graphics_system_name == QLatin1String("runtime"))
- switch_handler()->addWidget(widget);
-
- QMeeGoGraphicsSystem::surfaceWasCreated = true;
- QWindowSurface *surface = new QGLWindowSurface(widget);
- return surface;
-}
-
-QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QRasterPixmapData(type);
-}
-
-QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData *origin)
-{
- // If the pixmap is a raster type...
- // and if the pixmap pointer matches our mapping...
- // create a shared image instead with the given handle.
-
- if (!origin->isNull() && origin->classId() == QPixmapData::RasterClass) {
- QRasterPixmapData *rasterClass = static_cast <QRasterPixmapData *> (origin);
- void *rawResource = static_cast <void *> (rasterClass->buffer()->data_ptr()->data);
-
- if (QMeeGoPixmapData::sharedImagesMap.contains(rawResource))
- return new QMeeGoPixmapData();
- }
-
- return new QRasterPixmapData(origin->pixelType());
-}
-
-QPixmapData* QMeeGoGraphicsSystem::wrapPixmapData(QPixmapData *pmd)
-{
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == "runtime") {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- QRuntimePixmapData *rt = new QRuntimePixmapData(rsystem, pmd->pixelType());;
- rt->m_data = pmd;
- rt->readBackInfo();
- rsystem->m_pixmapDatas << rt;
- return rt;
- } else
- return pmd;
-}
-
-void QMeeGoGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/)
-{
- if (QMeeGoGraphicsSystem::surfaceWasCreated) {
- qWarning("Trying to set surface fixed size but surface already created!");
- return;
- }
-
-#ifdef QT_WAS_PATCHED
- QEglProperties *properties = new QEglProperties();
- properties->setValue(EGL_FIXED_WIDTH_NOK, width);
- properties->setValue(EGL_FIXED_HEIGHT_NOK, height);
- QGLContextPrivate::setExtraWindowSurfaceCreationProps(properties);
-#endif
-}
-
-void QMeeGoGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height)
-{
- QMeeGoExtensions::ensureInitialized();
- QMeeGoExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height);
-}
-
-void QMeeGoGraphicsSystem::setTranslucent(bool translucent)
-{
- if (QMeeGoGraphicsSystem::surfaceWasCreated) {
- qWarning("Trying to set translucency but surface already created!");
- return;
- }
-
- QGLWindowSurface::surfaceFormat.setSampleBuffers(false);
- QGLWindowSurface::surfaceFormat.setSamples(0);
- QGLWindowSurface::surfaceFormat.setAlpha(translucent);
-}
-
-QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
-{
- if (softImage.format() != QImage::Format_ARGB32_Premultiplied &&
- softImage.format() != QImage::Format_RGB32) {
- qFatal("For egl shared images, the soft image has to be ARGB32_Premultiplied or RGB32");
- return NULL;
- }
-
- if (QMeeGoGraphicsSystem::meeGoRunning()) {
- QMeeGoPixmapData *pmd = new QMeeGoPixmapData;
- pmd->fromEGLSharedImage(handle, softImage);
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
- } else {
- QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType);
- pmd->fromImage(softImage, Qt::NoFormatConversion);
-
- // Make sure that the image was not converted in any way
- if (pmd->buffer()->data_ptr()->data !=
- const_cast<QImage &>(softImage).data_ptr()->data)
- qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail.");
-
- QMeeGoPixmapData::registerSharedImage(handle, softImage);
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
- }
-}
-
-void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap)
-{
- QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData();
-
- // Basic sanity check to make sure this is really a QMeeGoPixmapData...
- if (pmd->classId() != QPixmapData::OpenGLClass)
- qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!");
-
- pmd->updateFromSoftImage();
-}
-
-QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h)
-{
- QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType);
- pmd->resize(w, h);
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
-}
-
-bool QMeeGoGraphicsSystem::meeGoRunning()
-{
- return runningGraphicsSystemName() == "meego";
-}
-
-QPixmapData* QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format)
-{
- return new QMeeGoLivePixmapData(w, h, format);
-}
-
-QPixmapData* QMeeGoGraphicsSystem::pixmapDataFromLiveTextureHandle(Qt::HANDLE handle)
-{
- return new QMeeGoLivePixmapData(handle);
-}
-
-QImage* QMeeGoGraphicsSystem::lockLiveTexture(QPixmap* pixmap, void* fenceSync)
-{
- QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
- return pixmapData->lock(fenceSync);
-}
-
-bool QMeeGoGraphicsSystem::releaseLiveTexture(QPixmap *pixmap, QImage *image)
-{
- QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
- return pixmapData->release(image);
-}
-
-Qt::HANDLE QMeeGoGraphicsSystem::getLiveTextureHandle(QPixmap *pixmap)
-{
- QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
- return pixmapData->handle();
-}
-
-void* QMeeGoGraphicsSystem::createFenceSync()
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
- return QMeeGoExtensions::eglCreateSyncKHR(QEgl::display(), EGL_SYNC_FENCE_KHR, NULL);
-}
-
-void QMeeGoGraphicsSystem::destroyFenceSync(void *fenceSync)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
- QMeeGoExtensions::eglDestroySyncKHR(QEgl::display(), fenceSync);
-}
-
-QString QMeeGoGraphicsSystem::runningGraphicsSystemName()
-{
- if (!QApplicationPrivate::instance()) {
- qWarning("Querying graphics system but application not running yet!");
- return QString();
- }
-
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == QLatin1String("runtime")) {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- name = rsystem->graphicsSystemName();
- }
-
- return name;
-}
-
-void QMeeGoGraphicsSystem::switchToMeeGo()
-{
- if (switchPolicy == NoSwitch || meeGoRunning())
- return;
-
- if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
- qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system.");
- else {
- triggerSwitchCallbacks(0, "meego");
-
- QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
- app->setGraphicsSystem(QLatin1String("meego"));
-
- triggerSwitchCallbacks(1, "meego");
- }
-}
-
-void QMeeGoGraphicsSystem::switchToRaster()
-{
- if (switchPolicy == NoSwitch || runningGraphicsSystemName() == QLatin1String("raster"))
- return;
-
- if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
- qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system.");
- else {
- triggerSwitchCallbacks(0, "raster");
-
- QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
- app->setGraphicsSystem(QLatin1String("raster"));
-
- QMeeGoLivePixmapData::invalidateSurfaces();
-
- triggerSwitchCallbacks(1, "raster");
- }
-}
-
-void QMeeGoGraphicsSystem::registerSwitchCallback(QMeeGoSwitchCallback callback)
-{
- switchCallbacks << callback;
-}
-
-void QMeeGoGraphicsSystem::triggerSwitchCallbacks(int type, const char *name)
-{
- for (int i = 0; i < switchCallbacks.size(); ++i)
- switchCallbacks.at(i)(type, name);
-}
-
-/* C API */
-
-int qt_meego_image_to_egl_shared_image(const QImage &image)
-{
- return QMeeGoPixmapData::imageToEGLSharedImage(image);
-}
-
-QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage)
-{
- return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage);
-}
-
-QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h)
-{
- return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h);
-}
-
-bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle)
-{
- return QMeeGoPixmapData::destroyEGLSharedImage(handle);
-}
-
-void qt_meego_set_surface_fixed_size(int width, int height)
-{
- QMeeGoGraphicsSystem::setSurfaceFixedSize(width, height);
-}
-
-void qt_meego_set_surface_scaling(int x, int y, int width, int height)
-{
- QMeeGoGraphicsSystem::setSurfaceScaling(x, y, width, height);
-}
-
-void qt_meego_set_translucent(bool translucent)
-{
- QMeeGoGraphicsSystem::setTranslucent(translucent);
-}
-
-void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap)
-{
- QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap);
-}
-
-QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format)
-{
- return QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(w, h, format);
-}
-
-QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle)
-{
- return QMeeGoGraphicsSystem::pixmapDataFromLiveTextureHandle(handle);
-}
-
-QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync)
-{
- return QMeeGoGraphicsSystem::lockLiveTexture(pixmap, fenceSync);
-}
-
-bool qt_meego_live_texture_release(QPixmap *pixmap, QImage *image)
-{
- return QMeeGoGraphicsSystem::releaseLiveTexture(pixmap, image);
-}
-
-Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap)
-{
- return QMeeGoGraphicsSystem::getLiveTextureHandle(pixmap);
-}
-
-void* qt_meego_create_fence_sync(void)
-{
- return QMeeGoGraphicsSystem::createFenceSync();
-}
-
-void qt_meego_destroy_fence_sync(void* fs)
-{
- return QMeeGoGraphicsSystem::destroyFenceSync(fs);
-}
-
-void qt_meego_invalidate_live_surfaces(void)
-{
- return QMeeGoLivePixmapData::invalidateSurfaces();
-}
-
-void qt_meego_switch_to_raster(void)
-{
- QMeeGoGraphicsSystem::switchToRaster();
-}
-
-void qt_meego_switch_to_meego(void)
-{
- QMeeGoGraphicsSystem::switchToMeeGo();
-}
-
-void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback)
-{
- QMeeGoGraphicsSystem::registerSwitchCallback(callback);
-}
-
-void qt_meego_set_switch_policy(int policy)
-{
- QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::SwitchPolicy(policy);
-}
-
-#include "qmeegographicssystem.moc"
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
deleted file mode 100644
index 7299af56be..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MGRAPHICSSYSTEM_H
-#define MGRAPHICSSYSTEM_H
-
-#include <private/qgraphicssystem_p.h>
-#include <EGL/egl.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-extern "C" typedef void (*QMeeGoSwitchCallback)(int type, const char *name);
-
-class QMeeGoGraphicsSystem : public QGraphicsSystem
-{
-public:
- enum SwitchPolicy { AutomaticSwitch, ManualSwitch, NoSwitch };
-
- QMeeGoGraphicsSystem();
- ~QMeeGoGraphicsSystem();
-
- virtual QWindowSurface *createWindowSurface(QWidget *widget) const;
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const;
- virtual QPixmapData *createPixmapData(QPixmapData *origin);
-
- static QPixmapData *wrapPixmapData(QPixmapData *pmd);
- static void setSurfaceFixedSize(int width, int height);
- static void setSurfaceScaling(int x, int y, int width, int height);
- static void setTranslucent(bool translucent);
-
- static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
- static QPixmapData *pixmapDataFromEGLImage(Qt::HANDLE handle);
- static QPixmapData *pixmapDataWithGLTexture(int w, int h);
- static void updateEGLSharedImagePixmap(QPixmap *pixmap);
-
- static QPixmapData *pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format);
- static QPixmapData *pixmapDataFromLiveTextureHandle(Qt::HANDLE handle);
- static QImage *lockLiveTexture(QPixmap* pixmap, void* fenceSync);
- static bool releaseLiveTexture(QPixmap *pixmap, QImage *image);
- static Qt::HANDLE getLiveTextureHandle(QPixmap *pixmap);
-
- static void* createFenceSync();
- static void destroyFenceSync(void* fenceSync);
-
- static void switchToRaster();
- static void switchToMeeGo();
- static QString runningGraphicsSystemName();
-
- static void registerSwitchCallback(QMeeGoSwitchCallback callback);
-
- static SwitchPolicy switchPolicy;
-
-private:
- static bool meeGoRunning();
- static EGLSurface getSurfaceForLiveTexturePixmap(QPixmap *pixmap);
- static void destroySurfaceForLiveTexturePixmap(QPixmapData* pmd);
- static void triggerSwitchCallbacks(int type, const char *name);
-
- static bool surfaceWasCreated;
- static QHash<Qt::HANDLE, QPixmap*> liveTexturePixmaps;
- static QList<QMeeGoSwitchCallback> switchCallbacks;
-};
-
-/* C api */
-
-extern "C" {
- Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h);
- Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap);
- Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle);
- Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height);
- Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height);
- Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle);
- Q_DECL_EXPORT QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync);
- Q_DECL_EXPORT bool qt_meego_live_texture_release(QPixmap *pixmap, QImage *image);
- Q_DECL_EXPORT Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap);
- Q_DECL_EXPORT void* qt_meego_create_fence_sync(void);
- Q_DECL_EXPORT void qt_meego_destroy_fence_sync(void* fs);
- Q_DECL_EXPORT void qt_meego_invalidate_live_surfaces(void);
- Q_DECL_EXPORT void qt_meego_switch_to_raster(void);
- Q_DECL_EXPORT void qt_meego_switch_to_meego(void);
- Q_DECL_EXPORT void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback);
- Q_DECL_EXPORT void qt_meego_set_switch_policy(int policy);
-}
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp
deleted file mode 100644
index 493d14e962..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include "qmeegographicssystemplugin.h"
-#include "qmeegographicssystem.h"
-
-QStringList QMeeGoGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << "meego";
- return list;
-}
-
-QGraphicsSystem *QMeeGoGraphicsSystemPlugin::create(const QString&)
-{
- return new QMeeGoGraphicsSystem;
-}
-
-Q_EXPORT_PLUGIN2(meego, QMeeGoGraphicsSystemPlugin)
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h
deleted file mode 100644
index e38033a6cd..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MGRAPHICSSYSTEMPLUGIN_H
-#define MGRAPHICSSYSTEMPLUGIN_H
-
-#include <private/qgraphicssystemplugin_p.h>
-
-class QMeeGoGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- virtual QStringList keys() const;
- virtual QGraphicsSystem *create(const QString&);
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
deleted file mode 100644
index 40421bc8f0..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegolivepixmapdata.h"
-#include "qmeegorasterpixmapdata.h"
-#include <private/qimage_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_runtime_p.h>
-#include <private/qpixmap_x11_p.h>
-#include <stdio.h>
-
-static QMeeGoLivePixmapDataList all_live_pixmaps;
-
-static EGLint lock_attribs[] = {
- EGL_MAP_PRESERVE_PIXELS_KHR, EGL_TRUE,
- EGL_LOCK_USAGE_HINT_KHR, EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR,
- EGL_NONE
-};
-
-static EGLint preserved_attribs[] = {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
-};
-
-// as copied from qwindowsurface.cpp
-void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
-{
- // make sure we don't detach
- uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
-
- int lineskip = img.bytesPerLine();
- int depth = img.depth() >> 3;
-
- const QRect imageRect(0, 0, img.width(), img.height());
- const QRect r = rect & imageRect & imageRect.translated(-offset);
- const QPoint p = rect.topLeft() + offset;
-
- if (r.isEmpty())
- return;
-
- const uchar *src;
- uchar *dest;
-
- if (r.top() < p.y()) {
- src = mem + r.bottom() * lineskip + r.left() * depth;
- dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
- lineskip = -lineskip;
- } else {
- src = mem + r.top() * lineskip + r.left() * depth;
- dest = mem + p.y() * lineskip + p.x() * depth;
- }
-
- const int w = r.width();
- int h = r.height();
- const int bytes = w * depth;
-
- // overlapping segments?
- if (offset.y() == 0 && qAbs(offset.x()) < w) {
- do {
- ::memmove(dest, src, bytes);
- dest += lineskip;
- src += lineskip;
- } while (--h);
- } else {
- do {
- ::memcpy(dest, src, bytes);
- dest += lineskip;
- src += lineskip;
- } while (--h);
- }
-}
-
-/* Public */
-
-QMeeGoLivePixmapData::QMeeGoLivePixmapData(int w, int h, QImage::Format format) : QGLPixmapData(QPixmapData::PixmapType)
-{
- QImage image(w, h, format);
- QX11PixmapData *pmd = new QX11PixmapData(QPixmapData::PixmapType);
- pmd->fromImage(image, Qt::NoOpaqueDetection);
- backingX11Pixmap = new QPixmap(pmd);
-
- initializeThroughEGLImage();
-
- pos = all_live_pixmaps.insert(all_live_pixmaps.begin(), this);
-}
-
-QMeeGoLivePixmapData::QMeeGoLivePixmapData(Qt::HANDLE h) : QGLPixmapData(QPixmapData::PixmapType)
-{
- backingX11Pixmap = new QPixmap(QPixmap::fromX11Pixmap(h));
- initializeThroughEGLImage();
-
- pos = all_live_pixmaps.insert(all_live_pixmaps.begin(), this);
-}
-
-QMeeGoLivePixmapData::~QMeeGoLivePixmapData()
-{
- delete backingX11Pixmap;
- all_live_pixmaps.erase(pos);
-}
-
-void QMeeGoLivePixmapData::initializeThroughEGLImage()
-{
- if (texture()->id != 0)
- return;
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- EGLImageKHR eglImage = EGL_NO_IMAGE_KHR;
- GLuint newTextureId = 0;
-
- eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer) backingX11Pixmap->handle(), preserved_attribs);
-
- if (eglImage == EGL_NO_IMAGE_KHR) {
- qWarning("eglCreateImageKHR failed (live texture)!");
- return;
- }
-
- glGenTextures(1, &newTextureId);
- glBindTexture(GL_TEXTURE_2D, newTextureId);
-
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (EGLImageKHR) eglImage);
- if (glGetError() == GL_NO_ERROR) {
- resize(backingX11Pixmap->width(), backingX11Pixmap->height());
- texture()->id = newTextureId;
- texture()->options &= ~QGLContext::InvertedYBindOption;
- m_hasAlpha = backingX11Pixmap->hasAlphaChannel();
- } else {
- qWarning("Failed to create a texture from an egl image (live texture)!");
- glDeleteTextures(1, &newTextureId);
- }
-
- QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
-}
-
-QPixmapData *QMeeGoLivePixmapData::createCompatiblePixmapData() const
-{
- qWarning("Create compatible called on live pixmap! Expect fail soon...");
- return new QMeeGoRasterPixmapData(pixelType());
-}
-
-QImage* QMeeGoLivePixmapData::lock(EGLSyncKHR fenceSync)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- if (fenceSync) {
- QMeeGoExtensions::eglClientWaitSyncKHR(QEgl::display(),
- fenceSync,
- EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
- EGL_FOREVER_KHR);
- }
-
- void *data = 0;
- int pitch = 0;
- int surfaceWidth = 0;
- int surfaceHeight = 0;
- EGLSurface surface = 0;
- QImage::Format format;
- lockedImage = QImage();
-
- surface = getSurfaceForBackingPixmap();
- if (! QMeeGoExtensions::eglLockSurfaceKHR(QEgl::display(), surface, lock_attribs)) {
- qWarning("Failed to lock surface (live texture)!");
- return &lockedImage;
- }
-
- eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) &data);
- eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) &pitch);
- eglQuerySurface(QEgl::display(), surface, EGL_WIDTH, (EGLint*) &surfaceWidth);
- eglQuerySurface(QEgl::display(), surface, EGL_HEIGHT, (EGLint*) &surfaceHeight);
-
- // Ok, here we know we just support those two formats. Real solution would be:
- // query also the format.
- if (backingX11Pixmap->depth() > 16)
- format = QImage::Format_ARGB32_Premultiplied;
- else
- format = QImage::Format_RGB16;
-
- if (data == NULL || pitch == 0) {
- qWarning("Failed to query the live texture!");
- return &lockedImage;
- }
-
- if (width() != surfaceWidth || height() != surfaceHeight) {
- qWarning("Live texture dimensions don't match!");
- QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), surface);
- return &lockedImage;
- }
-
- lockedImage = QImage((uchar *) data, width(), height(), pitch, format);
- return &lockedImage;
-}
-
-bool QMeeGoLivePixmapData::release(QImage* /*img*/)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- if (QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), getSurfaceForBackingPixmap())) {
- lockedImage = QImage();
- return true;
- } else {
- lockedImage = QImage();
- return false;
- }
-}
-
-Qt::HANDLE QMeeGoLivePixmapData::handle()
-{
- return backingX11Pixmap->handle();
-}
-
-bool QMeeGoLivePixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- lock(NULL);
-
- if (!lockedImage.isNull())
- qt_scrollRectInImage(lockedImage, rect, QPoint(dx, dy));
-
- release(&lockedImage);
- return true;
-}
-
-EGLSurface QMeeGoLivePixmapData::getSurfaceForBackingPixmap()
-{
- initializeThroughEGLImage();
-
- // This code is a crative remix of the stuff that can be found in the
- // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(backingX11Pixmap->data_ptr().data());
- Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
- bool hasAlpha = pixmapData->hasAlphaChannel();
-
- if (pixmapData->gl_surface &&
- hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
- return pixmapData->gl_surface;
-
- // Check to see if the surface is still valid
- if (pixmapData->gl_surface &&
- hasAlpha != ((pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha) > 0)) {
- // Surface is invalid!
- destroySurfaceForPixmapData(pixmapData);
- }
-
- if (pixmapData->gl_surface == 0) {
- EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
- QEgl::OpenGL,
- hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
-
- pixmapData->gl_surface = (void*)QEgl::createSurface(backingX11Pixmap, config);
-
- if (hasAlpha)
- pixmapData->flags |= QX11PixmapData::GlSurfaceCreatedWithAlpha;
- else
- pixmapData->flags &= ~QX11PixmapData::GlSurfaceCreatedWithAlpha;
-
- if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
- return NULL;
- }
-
- return pixmapData->gl_surface;
-}
-
-void QMeeGoLivePixmapData::destroySurfaceForPixmapData(QPixmapData* pmd)
-{
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface) {
- eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
- pixmapData->gl_surface = 0;
- }
-}
-
-void QMeeGoLivePixmapData::invalidateSurfaces()
-{
- foreach (QMeeGoLivePixmapData *data, all_live_pixmaps) {
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(data->backingX11Pixmap->data_ptr().data());
- *data->texture() = QGLTexture();
- pixmapData->gl_surface = 0;
- }
-}
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h
deleted file mode 100644
index 73f75143e3..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MLIVEPIXMAPDATA_H
-#define MLIVEPIXMAPDATA_H
-
-#include <QLinkedList>
-#include <private/qpixmapdata_gl_p.h>
-#include "qmeegoextensions.h"
-
-class QMeeGoLivePixmapData;
-typedef QLinkedList<QMeeGoLivePixmapData *> QMeeGoLivePixmapDataList;
-
-class QMeeGoLivePixmapData : public QGLPixmapData
-{
-public:
- QMeeGoLivePixmapData(int w, int h, QImage::Format format);
- QMeeGoLivePixmapData(Qt::HANDLE h);
- ~QMeeGoLivePixmapData();
-
- QPixmapData *createCompatiblePixmapData() const;
- bool scroll(int dx, int dy, const QRect &rect);
-
- void initializeThroughEGLImage();
-
- QImage* lock(EGLSyncKHR fenceSync);
- bool release(QImage *img);
- Qt::HANDLE handle();
-
- EGLSurface getSurfaceForBackingPixmap();
- void destroySurfaceForPixmapData(QPixmapData* pmd);
-
- QPixmap *backingX11Pixmap;
- QImage lockedImage;
- QMeeGoLivePixmapDataList::Iterator pos;
-
- static void invalidateSurfaces();
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
deleted file mode 100644
index ec6c33fa07..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegopixmapdata.h"
-#include "qmeegoextensions.h"
-#include "qmeegorasterpixmapdata.h"
-#include <private/qimage_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_runtime_p.h>
-
-// from dithering.cpp
-extern unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride);
-extern unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride);
-extern unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride);
-
-static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
-
-QHash <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap;
-
-/* Public */
-
-QMeeGoPixmapData::QMeeGoPixmapData() : QGLPixmapData(QPixmapData::PixmapType)
-{
-}
-
-void QMeeGoPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha)
-{
- resize(w, h);
- texture()->id = textureId;
- m_hasAlpha = alpha;
- softImage = QImage();
-}
-
-QImage QMeeGoPixmapData::toImage() const
-{
- return softImage;
-}
-
-void QMeeGoPixmapData::fromImage(const QImage &image,
- Qt::ImageConversionFlags flags)
-{
- void *rawResource = static_cast <void *> (((QImage &) image).data_ptr()->data);
-
- if (sharedImagesMap.contains(rawResource)) {
- QMeeGoImageInfo *info = sharedImagesMap.value(rawResource);
- fromEGLSharedImage(info->handle, image);
- } else {
- // This should *never* happen since the graphics system should never
- // create a QMeeGoPixmapData for an origin that doesn't contain a raster
- // image we know about. But...
- qWarning("QMeeGoPixmapData::fromImage called on non-know resource. Falling back...");
- QGLPixmapData::fromImage(image, flags);
- }
-}
-
-void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si)
-{
- if (si.isNull())
- qFatal("Trying to build pixmap with an empty/null softimage!");
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
- QMeeGoExtensions::ensureInitialized();
-
- bool textureIsBound = false;
- GLuint newTextureId;
- GLint newWidth, newHeight;
-
- glGenTextures(1, &newTextureId);
- glBindTexture(GL_TEXTURE_2D, newTextureId);
-
- EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK,
- (EGLClientBuffer)handle, preserved_image_attribs);
-
- if (image != EGL_NO_IMAGE_KHR) {
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
- GLint err = glGetError();
- if (err == GL_NO_ERROR)
- textureIsBound = true;
-
- QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth);
- QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight);
-
- QEgl::eglDestroyImageKHR(QEgl::display(), image);
- }
-
- if (textureIsBound) {
- fromTexture(newTextureId, newWidth, newHeight,
- (si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels()));
- texture()->options &= ~QGLContext::InvertedYBindOption;
- softImage = si;
- QMeeGoPixmapData::registerSharedImage(handle, softImage);
- } else {
- qWarning("Failed to create a texture from a shared image!");
- glDeleteTextures(1, &newTextureId);
- }
-}
-
-Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
- QMeeGoExtensions::ensureInitialized();
-
- GLuint textureId;
-
- glGenTextures(1, &textureId);
- glBindTexture(GL_TEXTURE_2D, textureId);
- if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) {
- void *converted = convertBGRA32_to_RGBA32(image.bits(), image.width(), image.height(), image.bytesPerLine());
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, converted);
- free(converted);
- } else {
- void *converted = convertRGB32_to_RGB565(image.bits(), image.width(), image.height(), image.bytesPerLine());
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, converted);
- free(converted);
- }
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- glBindTexture(GL_TEXTURE_2D, textureId);
- EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(),
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer) textureId,
- preserved_image_attribs);
- glDeleteTextures(1, &textureId);
- if (eglimage) {
- EGLNativeSharedImageTypeNOK handle = QMeeGoExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL);
- QEgl::eglDestroyImageKHR(QEgl::display(), eglimage);
- return (Qt::HANDLE) handle;
- } else {
- qWarning("Failed to create shared image from pixmap/texture!");
- return 0;
- }
-}
-
-void QMeeGoPixmapData::updateFromSoftImage()
-{
- // FIXME That's broken with recent 16bit textures changes.
- m_dirty = true;
- m_source = softImage;
- ensureCreated();
-
- if (softImage.width() != w || softImage.height() != h)
- qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!");
-}
-
-bool QMeeGoPixmapData::destroyEGLSharedImage(Qt::HANDLE h)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- QMutableHashIterator <void*, QMeeGoImageInfo*> i(sharedImagesMap);
- while (i.hasNext()) {
- i.next();
- if (i.value()->handle == h)
- i.remove();
- }
-
- return QMeeGoExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h);
-}
-
-void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si)
-{
- void *raw = static_cast <void *> (((QImage) si).data_ptr()->data);
- QMeeGoImageInfo *info;
-
- if (! sharedImagesMap.contains(raw)) {
- info = new QMeeGoImageInfo;
- info->handle = handle;
- info->rawFormat = si.format();
- sharedImagesMap.insert(raw, info);
- } else {
- info = sharedImagesMap.value(raw);
- if (info->handle != handle || info->rawFormat != si.format())
- qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different");
- }
-}
-
-QPixmapData *QMeeGoPixmapData::createCompatiblePixmapData() const
-{
- return new QMeeGoRasterPixmapData(pixelType());
-}
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
deleted file mode 100644
index f1ff255b08..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MPIXMAPDATA_H
-#define MPIXMAPDATA_H
-
-#include <private/qpixmapdata_gl_p.h>
-
-struct QMeeGoImageInfo
-{
- Qt::HANDLE handle;
- QImage::Format rawFormat;
-};
-
-class QMeeGoPixmapData : public QGLPixmapData
-{
-public:
- QMeeGoPixmapData();
- void fromTexture(GLuint textureId, int w, int h, bool alpha);
- QPixmapData *createCompatiblePixmapData() const;
-
- virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
- virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags);
- virtual QImage toImage() const;
- virtual void updateFromSoftImage();
-
- QImage softImage;
-
- static QHash <void*, QMeeGoImageInfo*> sharedImagesMap;
-
- static Qt::HANDLE imageToEGLSharedImage(const QImage &image);
- static bool destroyEGLSharedImage(Qt::HANDLE h);
- static void registerSharedImage(Qt::HANDLE handle, const QImage &si);
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/opengl/opengl.pro b/src/plugins/graphicssystems/opengl/opengl.pro
deleted file mode 100644
index fd3542ecf0..0000000000
--- a/src/plugins/graphicssystems/opengl/opengl.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qglgraphicssystem
-load(qt_plugin)
-
-QT += core-private gui-private opengl-private
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-SOURCES = main.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-
-symbian: TARGET.UID3 = 0x2002131B
diff --git a/src/plugins/graphicssystems/openvg/main.cpp b/src/plugins/graphicssystems/openvg/main.cpp
deleted file mode 100644
index 0aa265e50b..0000000000
--- a/src/plugins/graphicssystems/openvg/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include "qgraphicssystem_vg_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList QVGGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << "OpenVG";
- return list;
-}
-
-QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == "openvg")
- return new QVGGraphicsSystem;
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/openvg/openvg.pro b/src/plugins/graphicssystems/openvg/openvg.pro
deleted file mode 100644
index 6a737790a2..0000000000
--- a/src/plugins/graphicssystems/openvg/openvg.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qvggraphicssystem
-load(qt_plugin)
-
-QT += openvg
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-SOURCES = main.cpp qgraphicssystem_vg.cpp
-HEADERS = qgraphicssystem_vg_p.h
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-
-symbian: TARGET.UID3 = 0x2001E62C
diff --git a/src/plugins/graphicssystems/shivavg/README b/src/plugins/graphicssystems/shivavg/README
deleted file mode 100644
index 15ee7101e8..0000000000
--- a/src/plugins/graphicssystems/shivavg/README
+++ /dev/null
@@ -1,8 +0,0 @@
-
-This graphics system uses ShivaVG (http://sourceforge.net/projects/shivavg)
-to perform OpenVG rendering on X11 systems. The graphics system name for
-the "-graphicssystem" command-line option is "ShivaVG".
-
-ShivaVG support is experimental, mostly to demonstrate how to integrate
-non-EGL OpenVG engines into the system. It will probably not produce
-good output.
diff --git a/src/plugins/graphicssystems/shivavg/main.cpp b/src/plugins/graphicssystems/shivavg/main.cpp
deleted file mode 100644
index 53bc782378..0000000000
--- a/src/plugins/graphicssystems/shivavg/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include "shivavggraphicssystem.h"
-
-QT_BEGIN_NAMESPACE
-
-class ShivaVGGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList ShivaVGGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << "ShivaVG";
- return list;
-}
-
-QGraphicsSystem* ShivaVGGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == "shivavg")
- return new ShivaVGGraphicsSystem;
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(shivavg, ShivaVGGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/shivavg/shivavg.pro b/src/plugins/graphicssystems/shivavg/shivavg.pro
deleted file mode 100644
index 1d934cd685..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavg.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TARGET = qshivavggraphicssystem
-load(qt_plugin)
-
-QT += openvg
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-SOURCES = main.cpp shivavggraphicssystem.cpp shivavgwindowsurface.cpp
-HEADERS = shivavggraphicssystem.h shivavgwindowsurface.h
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
diff --git a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp
deleted file mode 100644
index 48526538ab..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "shivavggraphicssystem.h"
-#include "shivavgwindowsurface.h"
-#include <QtGui/private/qpixmap_raster_p.h>
-
-QT_BEGIN_NAMESPACE
-
-ShivaVGGraphicsSystem::ShivaVGGraphicsSystem()
-{
-}
-
-QPixmapData *ShivaVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QRasterPixmapData(type);
-}
-
-QWindowSurface *ShivaVGGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return new ShivaVGWindowSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp
deleted file mode 100644
index 448532ae92..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#define GL_GLEXT_PROTOTYPES
-#include "shivavgwindowsurface.h"
-#include <QtOpenVG/private/qpaintengine_vg_p.h>
-#if defined(Q_WS_X11)
-#include "private/qt_x11_p.h"
-#include "qx11info_x11.h"
-#include <GL/glx.h>
-
-extern QX11Info *qt_x11Info(const QPaintDevice *pd);
-#endif
-
-// Define this to use framebuffer objects.
-//#define QVG_USE_FBO 1
-
-#include <vg/openvg.h>
-
-QT_BEGIN_NAMESPACE
-
-class QShivaContext
-{
-public:
- QShivaContext();
- ~QShivaContext();
-
- bool makeCurrent(ShivaVGWindowSurfacePrivate *surface);
- void doneCurrent();
-
- bool initialized;
- QSize currentSize;
- ShivaVGWindowSurfacePrivate *currentSurface;
-};
-
-Q_GLOBAL_STATIC(QShivaContext, shivaContext);
-
-class ShivaVGWindowSurfacePrivate
-{
-public:
- ShivaVGWindowSurfacePrivate()
- : isCurrent(false)
- , needsResize(true)
- , engine(0)
-#if defined(QVG_USE_FBO)
- , fbo(0)
- , texture(0)
-#endif
-#if defined(Q_WS_X11)
- , drawable(0)
- , context(0)
-#endif
- {
- }
- ~ShivaVGWindowSurfacePrivate();
-
- void ensureContext(QWidget *widget);
-
- QSize size;
- bool isCurrent;
- bool needsResize;
- QVGPaintEngine *engine;
-#if defined(QVG_USE_FBO)
- GLuint fbo;
- GLuint texture;
-#endif
-#if defined(Q_WS_X11)
- GLXDrawable drawable;
- GLXContext context;
-#endif
-};
-
-QShivaContext::QShivaContext()
- : initialized(false)
- , currentSurface(0)
-{
-}
-
-QShivaContext::~QShivaContext()
-{
- if (initialized)
- vgDestroyContextSH();
-}
-
-bool QShivaContext::makeCurrent(ShivaVGWindowSurfacePrivate *surface)
-{
- if (currentSurface)
- currentSurface->isCurrent = false;
- surface->isCurrent = true;
- currentSurface = surface;
- currentSize = surface->size;
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, surface->drawable, surface->context);
-#endif
- if (!initialized) {
- if (!vgCreateContextSH(currentSize.width(), currentSize.height())) {
- qWarning("vgCreateContextSH(%d, %d): could not create context", currentSize.width(), currentSize.height());
- return false;
- }
- initialized = true;
- } else {
- vgResizeSurfaceSH(currentSize.width(), currentSize.height());
- }
-#if defined(QVG_USE_FBO)
- if (surface->fbo)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface->fbo);
- else
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-#endif
- return true;
-}
-
-void QShivaContext::doneCurrent()
-{
- if (currentSurface) {
- currentSurface->isCurrent = false;
- currentSurface = 0;
- }
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, 0, 0);
-#endif
-}
-
-ShivaVGWindowSurfacePrivate::~ShivaVGWindowSurfacePrivate()
-{
-#if defined(QVG_USE_FBO)
- if (fbo) {
- glDeleteTextures(1, &texture);
- glDeleteFramebuffersEXT(1, &fbo);
- }
-#endif
-}
-
-void ShivaVGWindowSurfacePrivate::ensureContext(QWidget *widget)
-{
-#if defined(Q_WS_X11)
- Window win = widget->winId();
- if (win != drawable) {
- if (context)
- glXDestroyContext(X11->display, context);
- drawable = win;
- }
- if (context == 0) {
- const QX11Info *xinfo = qt_x11Info(widget);
- int spec[64];
- int i = 0;
- spec[i++] = GLX_DOUBLEBUFFER;
- spec[i++] = GLX_DEPTH_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_STENCIL_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_RGBA;
- spec[i++] = GLX_RED_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_GREEN_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_BLUE_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = 4;
- spec[i] = XNone;
- XVisualInfo *visual = glXChooseVisual
- (xinfo->display(), xinfo->screen(), spec);
- context = glXCreateContext(X11->display, visual, 0, True);
- if (!context)
- qWarning("glXCreateContext: could not create GL context for VG rendering");
- }
-#else
- Q_UNUSED(widget);
-#endif
-#if defined(QVG_USE_FBO)
- if (needsResize && fbo) {
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, drawable, context);
-#endif
- glDeleteTextures(1, &texture);
- glDeleteFramebuffersEXT(1, &fbo);
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, 0, 0);
-#endif
- fbo = 0;
- texture = 0;
- }
- if (!fbo) {
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, drawable, context);
-#endif
- glGenFramebuffersEXT(1, &fbo);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.width(), size.height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
- texture, 0);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, 0, 0);
-#endif
- }
-#endif
- needsResize = false;
-}
-
-ShivaVGWindowSurface::ShivaVGWindowSurface(QWidget *window)
- : QWindowSurface(window), d_ptr(new ShivaVGWindowSurfacePrivate)
-{
-}
-
-ShivaVGWindowSurface::~ShivaVGWindowSurface()
-{
- if (d_ptr->isCurrent) {
- shivaContext()->doneCurrent();
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- }
-#if defined(Q_WS_X11)
- if (d_ptr->context)
- glXDestroyContext(X11->display, d_ptr->context);
-#endif
- delete d_ptr;
-}
-
-QPaintDevice *ShivaVGWindowSurface::paintDevice()
-{
- d_ptr->ensureContext(window());
- shivaContext()->makeCurrent(d_ptr);
- glClearDepth(0.0f);
- glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- return this;
-}
-
-void ShivaVGWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(region);
- Q_UNUSED(offset);
- QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
- d_ptr->ensureContext(parent);
- QShivaContext *context = shivaContext();
- if (!d_ptr->isCurrent)
- context->makeCurrent(d_ptr);
-#if defined(QVG_USE_FBO)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- if (d_ptr->fbo) {
- static GLfloat const vertices[][2] = {
- {-1, -1}, {1, -1}, {1, 1}, {-1, 1}
- };
- static GLfloat const texCoords[][2] = {
- {0, 0}, {1, 0}, {1, 1}, {0, 1}
- };
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
- glBindTexture(GL_TEXTURE_2D, d_ptr->texture);
- glEnable(GL_TEXTURE_2D);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-#endif
-#if defined(Q_WS_X11)
- glXSwapBuffers(X11->display, d_ptr->drawable);
-#endif
- context->doneCurrent();
-}
-
-void ShivaVGWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- d_ptr->needsResize = true;
- d_ptr->size = rect.size();
-}
-
-bool ShivaVGWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- return QWindowSurface::scroll(area, dx, dy);
-}
-
-void ShivaVGWindowSurface::beginPaint(const QRegion &region)
-{
- // Nothing to do here.
- Q_UNUSED(region);
-}
-
-void ShivaVGWindowSurface::endPaint(const QRegion &region)
-{
- // Nothing to do here.
- Q_UNUSED(region);
-}
-
-Q_GLOBAL_STATIC(QVGPaintEngine, sharedPaintEngine);
-
-QPaintEngine *ShivaVGWindowSurface::paintEngine() const
-{
- if (!d_ptr->engine)
- d_ptr->engine = sharedPaintEngine();
- return d_ptr->engine;
-}
-
-int ShivaVGWindowSurface::metric(PaintDeviceMetric met) const
-{
- return qt_paint_device_metric(window(), met);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h
deleted file mode 100644
index a9de7f5239..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SHIVAVGWINDOWSURFACE_H
-#define SHIVAVGWINDOWSURFACE_H
-
-#include <QtGui/private/qwindowsurface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class ShivaVGWindowSurfacePrivate;
-
-class ShivaVGWindowSurface : public QWindowSurface, public QPaintDevice
-{
-public:
- ShivaVGWindowSurface(QWidget *window);
- virtual ~ShivaVGWindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
-
- void beginPaint(const QRegion &region);
- void endPaint(const QRegion &region);
-
- QPaintEngine *paintEngine() const;
-
-protected:
- int metric(PaintDeviceMetric metric) const;
-
-private:
- ShivaVGWindowSurfacePrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/graphicssystems/trace/main.cpp b/src/plugins/graphicssystems/trace/main.cpp
deleted file mode 100644
index c0043a2cdd..0000000000
--- a/src/plugins/graphicssystems/trace/main.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include "qgraphicssystem_trace_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QTraceGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList QTraceGraphicsSystemPlugin::keys() const
-{
- return QStringList(QLatin1String("Trace"));
-}
-
-QGraphicsSystem* QTraceGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == QLatin1String("trace"))
- return new QTraceGraphicsSystem;
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(trace, QTraceGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
deleted file mode 100644
index 502a198099..0000000000
--- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_trace_p.h"
-#include <private/qpixmap_raster_p.h>
-#include <private/qpaintbuffer_p.h>
-#include <private/qwindowsurface_raster_p.h>
-
-#include <QFile>
-#include <QPainter>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-class QTraceWindowSurface : public QRasterWindowSurface
-{
-public:
- QTraceWindowSurface(QWidget *widget);
- ~QTraceWindowSurface();
-
- QPaintDevice *paintDevice();
- void beginPaint(const QRegion &rgn);
- void endPaint(const QRegion &rgn);
-
- bool scroll(const QRegion &area, int dx, int dy);
-
-private:
- QPaintBuffer *buffer;
- QList<QRegion> updates;
-
- qulonglong winId;
-};
-
-QTraceWindowSurface::QTraceWindowSurface(QWidget *widget)
- : QRasterWindowSurface(widget)
- , buffer(0)
- , winId(0)
-{
-}
-
-QTraceWindowSurface::~QTraceWindowSurface()
-{
- if (buffer) {
- QFile outputFile(QString(QLatin1String("qtgraphics-%0.trace")).arg(winId));
- if (outputFile.open(QIODevice::WriteOnly)) {
- QDataStream out(&outputFile);
- out.setFloatingPointPrecision(QDataStream::SinglePrecision);
-
- out.writeBytes("qttraceV2", 9);
-
- uint version = 1;
-
- out << version << *buffer << updates;
- }
- delete buffer;
- }
-}
-
-QPaintDevice *QTraceWindowSurface::paintDevice()
-{
- if (!buffer) {
- buffer = new QPaintBuffer;
-#ifdef Q_WS_QPA
- buffer->setBoundingRect(QRect(QPoint(), size()));
-#else
- buffer->setBoundingRect(geometry());
-#endif
- }
- return buffer;
-}
-
-void QTraceWindowSurface::beginPaint(const QRegion &rgn)
-{
- // ensure paint buffer is created
- paintDevice();
- buffer->beginNewFrame();
-
- QRasterWindowSurface::beginPaint(rgn);
-}
-
-void QTraceWindowSurface::endPaint(const QRegion &rgn)
-{
- QPainter p(QRasterWindowSurface::paintDevice());
- buffer->draw(&p, buffer->numFrames()-1);
- p.end();
-
- winId = (qulonglong)window()->winId();
-
- updates << rgn;
-
- QRasterWindowSurface::endPaint(rgn);
-}
-
-bool QTraceWindowSurface::scroll(const QRegion &, int, int)
-{
- // TODO: scrolling should also be streamed and replayed
- // to test scrolling performance
- return false;
-}
-
-QTraceGraphicsSystem::QTraceGraphicsSystem()
-{
-}
-
-QPixmapData *QTraceGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QRasterPixmapData(type);
-}
-
-QWindowSurface *QTraceGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return new QTraceWindowSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h b/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h
deleted file mode 100644
index b6cfc60293..0000000000
--- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_TRACE_P_H
-#define QGRAPHICSSYSTEM_TRACE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qgraphicssystem_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QTraceGraphicsSystem : public QGraphicsSystem
-{
-public:
- QTraceGraphicsSystem();
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/graphicssystems/trace/trace.pro b/src/plugins/graphicssystems/trace/trace.pro
deleted file mode 100644
index f44bb3211e..0000000000
--- a/src/plugins/graphicssystems/trace/trace.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qtracegraphicssystem
-load(qt_plugin)
-
-QT += core-private gui-private network
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-symbian:TARGET.UID3 = 0x2002130E
-
-SOURCES = main.cpp qgraphicssystem_trace.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-INCLUDEPATH += ../../../3rdparty/harfbuzz/src
diff --git a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro
deleted file mode 100644
index 4c7b9b96d8..0000000000
--- a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qimsw-multi
-load(qt_plugin)
-CONFIG += warn_on
-
-DESTDIR = $$QT.gui.plugins/inputmethods
-
-HEADERS += qmultiinputcontext.h \
- qmultiinputcontextplugin.h
-SOURCES += qmultiinputcontext.cpp \
- qmultiinputcontextplugin.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/inputmethods
-INSTALLS += target
diff --git a/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.cpp b/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.cpp
deleted file mode 100644
index 258d586564..0000000000
--- a/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-**
-** Implementation of QMultiInputContext class
-**
-** Copyright (C) 2004 immodule for Qt Project. All rights reserved.
-**
-** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
-** licence. You may use this file under your Qt license. Following
-** description is copied from their original file headers. Contact
-** immodule-qt@freedesktop.org if any conditions of this licensing are
-** not clear to you.
-**
-****************************************************************************/
-
-#ifndef QT_NO_IM
-#include "qmultiinputcontext.h"
-#include <qinputcontextfactory.h>
-#include <qstringlist.h>
-#include <qaction.h>
-#include <qsettings.h>
-#include <qmenu.h>
-
-#include <stdlib.h>
-
-QT_BEGIN_NAMESPACE
-
-QMultiInputContext::QMultiInputContext()
- : QInputContext(), current(-1)
-{
- keys = QInputContextFactory::keys();
- for (int i = keys.size()-1; i >= 0; --i)
- if (keys.at(i).contains(QLatin1String("imsw")))
- keys.removeAt(i);
-
- QString def = QLatin1String(getenv("QT4_IM_MODULE"));
- if (def.isEmpty())
- def = QLatin1String(getenv("QT_IM_MODULE"));
- if (def.isEmpty()) {
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- settings.beginGroup(QLatin1String("Qt"));
- def = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString();
- }
- current = keys.indexOf(def);
- if (current < 0)
- current = 0;
-
- menu = new QMenu(tr("Select IM"));
- separator = new QAction(this);
- separator->setSeparator(true);
-
- QActionGroup *group = new QActionGroup(this);
- for (int i = 0; i < keys.size(); ++i) {
- slaves.append(0);
- const QString key = keys.at(i);
- QAction *a = menu->addAction(QInputContextFactory::displayName(key));
- a->setData(key);
- a->setCheckable(true);
- group->addAction(a);
- if (i == current) {
- slaves.replace(current, QInputContextFactory::create(key, this));
- a->setChecked(true);
- }
- }
- connect(group, SIGNAL(triggered(QAction*)), this, SLOT(changeSlave(QAction*)));
-}
-
-QMultiInputContext::~QMultiInputContext()
-{
- delete menu;
-}
-
-
-QString QMultiInputContext::identifierName()
-{
- return (slave()) ? slave()->identifierName() : QLatin1String("");
-}
-
-QString QMultiInputContext::language()
-{
- return (slave()) ? slave()->language() : QLatin1String("");
-}
-
-
-#if defined(Q_WS_X11)
-bool QMultiInputContext::x11FilterEvent(QWidget *keywidget, XEvent *event)
-{
- return (slave()) ? slave()->x11FilterEvent(keywidget, event) : false;
-}
-#endif // Q_WS_X11
-
-
-bool QMultiInputContext::filterEvent(const QEvent *event)
-{
- return (slave()) ? slave()->filterEvent(event) : false;
-}
-
-void QMultiInputContext::reset()
-{
- if (slave())
- slave()->reset();
-}
-
-void QMultiInputContext::update()
-{
- if (slave())
- slave()->update();
-}
-
-void QMultiInputContext::mouseHandler(int x, QMouseEvent *event)
-{
- if (slave())
- slave()->mouseHandler(x, event);
-}
-
-QFont QMultiInputContext::font() const
-{
- return (slave()) ? slave()->font() : QInputContext::font();
-}
-
-void QMultiInputContext::setFocusWidget(QWidget *w)
-{
- QInputContext::setFocusWidget(w);
- if (slave())
- slave()->setFocusWidget(w);
-}
-
-QWidget *QMultiInputContext::focusWidget() const
-{
- return QInputContext::focusWidget();
-}
-
-void QMultiInputContext::widgetDestroyed(QWidget *w)
-{
- if (slave())
- slave()->widgetDestroyed(w);
-}
-
-bool QMultiInputContext::isComposing() const
-{
- return (slave()) ? slave()->isComposing() : false;
-}
-
-QList<QAction *> QMultiInputContext::actions()
-{
- QList<QAction *> a = slave()->actions();
- a.append(separator);
- a.append(menu->menuAction());
- return a;
-}
-
-void QMultiInputContext::changeSlave(QAction *a)
-{
- for (int i = 0; i < slaves.size(); ++i) {
- if (keys.at(i) == a->data().toString()) {
- if (slaves.at(i) == 0)
- slaves.replace(i, QInputContextFactory::create(keys.at(i), this));
- QInputContext *qic = slaves.at(current);
- QWidget *oldWidget = qic->focusWidget();
- qic->reset();
- qic->setFocusWidget(0);
- current = i;
- qic = slaves.at(current);
- qic->setFocusWidget(oldWidget);
- return;
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_IM
diff --git a/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h b/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h
deleted file mode 100644
index 5d311b3f4b..0000000000
--- a/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-**
-** Definition of QMultiInputContext class
-**
-** Copyright (C) 2004 immodule for Qt Project. All rights reserved.
-**
-** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
-** licence. You may use this file under your Qt license. Following
-** description is copied from their original file headers. Contact
-** immodule-qt@freedesktop.org if any conditions of this licensing are
-** not clear to you.
-**
-****************************************************************************/
-
-#ifndef QMULTIINPUTCONTEXT_H
-#define QMULTIINPUTCONTEXT_H
-
-#ifndef QT_NO_IM
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qinputcontext.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qnamespace.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qpointer.h>
-#include <QtCore/qlist.h>
-
-QT_BEGIN_NAMESPACE
-
-class QMultiInputContext : public QInputContext
-{
- Q_OBJECT
-public:
- QMultiInputContext();
- ~QMultiInputContext();
-
- QString identifierName();
- QString language();
-
-#if defined(Q_WS_X11)
- bool x11FilterEvent( QWidget *keywidget, XEvent *event );
-#endif // Q_WS_X11
- bool filterEvent( const QEvent *event );
-
- void reset();
- void update();
- void mouseHandler( int x, QMouseEvent *event );
- QFont font() const;
- bool isComposing() const;
-
- QList<QAction *> actions();
-
- QWidget *focusWidget() const;
- void setFocusWidget(QWidget *w);
-
- void widgetDestroyed( QWidget *w );
-
- QInputContext *slave() { return slaves.at(current); }
- const QInputContext *slave() const { return slaves.at(current); }
-
-protected Q_SLOTS:
- void changeSlave(QAction *);
-private:
- void *unused;
- int current;
- QList<QInputContext *> slaves;
- QMenu *menu;
- QAction *separator;
- QStringList keys;
-};
-
-#endif // Q_NO_IM
-
-QT_END_NAMESPACE
-
-#endif // QMULTIINPUTCONTEXT_H
diff --git a/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.cpp b/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.cpp
deleted file mode 100644
index 1f56e2350b..0000000000
--- a/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-**
-** Implementation of QMultiInputContextPlugin class
-**
-** Copyright (C) 2004 immodule for Qt Project. All rights reserved.
-**
-** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
-** license. You may use this file under your Qt license. Following
-** description is copied from their original file headers. Contact
-** immodule-qt@freedesktop.org if any conditions of this licensing are
-** not clear to you.
-**
-****************************************************************************/
-
-#ifndef QT_NO_IM
-#include "qmultiinputcontext.h"
-#include "qmultiinputcontextplugin.h"
-#include <qinputcontextplugin.h>
-#include <qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-QMultiInputContextPlugin::QMultiInputContextPlugin()
-{
-}
-
-QMultiInputContextPlugin::~QMultiInputContextPlugin()
-{
-}
-
-QStringList QMultiInputContextPlugin::keys() const
-{
- // input method switcher should named with "imsw-" prefix to
- // prevent to be listed in ordinary input method list.
- return QStringList( QLatin1String("imsw-multi") );
-}
-
-QInputContext *QMultiInputContextPlugin::create( const QString &key )
-{
- if (key != QLatin1String("imsw-multi"))
- return 0;
- return new QMultiInputContext;
-}
-
-QStringList QMultiInputContextPlugin::languages( const QString & )
-{
- return QStringList();
-}
-
-QString QMultiInputContextPlugin::displayName( const QString &key )
-{
- if (key != QLatin1String("imsw-multi"))
- return QString();
- return tr( "Multiple input method switcher" );
-}
-
-QString QMultiInputContextPlugin::description( const QString &key )
-{
- if (key != QLatin1String("imsw-multi"))
- return QString();
- return tr( "Multiple input method switcher that uses the context menu of the text widgets" );
-}
-
-
-Q_EXPORT_STATIC_PLUGIN(QMultiInputContextPlugin)
-Q_EXPORT_PLUGIN2(qimsw_multi, QMultiInputContextPlugin)
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h b/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h
deleted file mode 100644
index c18112ff8b..0000000000
--- a/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-**
-** Definition of QMultiInputContextPlugin class
-**
-** Copyright (C) 2004 immodule for Qt Project. All rights reserved.
-**
-** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
-** license. You may use this file under your Qt license. Following
-** description is copied from their original file headers. Contact
-** immodule-qt@freedesktop.org if any conditions of this licensing are
-** not clear to you.
-**
-****************************************************************************/
-
-#ifndef QMULTIINPUTCONTEXTPLUGIN_H
-#define QMULTIINPUTCONTEXTPLUGIN_H
-
-#ifndef QT_NO_IM
-
-#include "qmultiinputcontext.h"
-#include <QtGui/qinputcontextplugin.h>
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-class QMultiInputContextPlugin : public QInputContextPlugin
-{
- Q_OBJECT
-public:
- QMultiInputContextPlugin();
- ~QMultiInputContextPlugin();
-
- QStringList keys() const;
- QInputContext *create( const QString &key );
- QStringList languages( const QString &key );
- QString displayName( const QString &key );
- QString description( const QString &key );
-};
-
-#endif // QT_NO_IM
-
-QT_END_NAMESPACE
-
-#endif // QMULTIINPUTCONTEXTPLUGIN_H
diff --git a/src/plugins/inputmethods/inputmethods.pro b/src/plugins/inputmethods/inputmethods.pro
deleted file mode 100644
index e1ca847519..0000000000
--- a/src/plugins/inputmethods/inputmethods.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS = imsw-multi
diff --git a/src/plugins/kbddrivers/kbddrivers.pro b/src/plugins/kbddrivers/kbddrivers.pro
deleted file mode 100644
index dbab47b366..0000000000
--- a/src/plugins/kbddrivers/kbddrivers.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-contains(kbd-plugins, linuxinput): SUBDIRS += linuxinput
diff --git a/src/plugins/kbddrivers/linuxinput/linuxinput.pro b/src/plugins/kbddrivers/linuxinput/linuxinput.pro
deleted file mode 100644
index 8eaa786ce0..0000000000
--- a/src/plugins/kbddrivers/linuxinput/linuxinput.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qlinuxinputkbddriver
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/kbddrivers
-target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_KBD_LINUXINPUT
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.cpp
-
diff --git a/src/plugins/kbddrivers/linuxinput/main.cpp b/src/plugins/kbddrivers/linuxinput/main.cpp
deleted file mode 100644
index 9affaa67ea..0000000000
--- a/src/plugins/kbddrivers/linuxinput/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qkbddriverplugin_qws.h>
-#include <qkbdlinuxinput_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class QLinuxInputKbdDriver : public QKbdDriverPlugin
-{
-public:
- QLinuxInputKbdDriver();
-
- QStringList keys() const;
- QWSKeyboardHandler* create(const QString &driver, const QString &device);
-};
-
-QLinuxInputKbdDriver::QLinuxInputKbdDriver()
- : QKbdDriverPlugin()
-{
-}
-
-QStringList QLinuxInputKbdDriver::keys() const
-{
- return (QStringList() << QLatin1String("LinuxInput"));
-}
-
-QWSKeyboardHandler* QLinuxInputKbdDriver::create(const QString &driver,
- const QString &device)
-{
- Q_UNUSED(device);
- if (driver.compare(QLatin1String("LinuxInput"), Qt::CaseInsensitive))
- return 0;
- return new QWSLinuxInputKeyboardHandler(device);
-}
-
-Q_EXPORT_PLUGIN2(qwslinuxinputkbddriver, QLinuxInputKbdDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/linuxtp/linuxtp.pro b/src/plugins/mousedrivers/linuxtp/linuxtp.pro
deleted file mode 100644
index e5d274a0b7..0000000000
--- a/src/plugins/mousedrivers/linuxtp/linuxtp.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qlinuxtpmousedriver
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/mousedrivers
-target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_MOUSE_LINUXTP
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmouselinuxtp_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmouselinuxtp_qws.cpp
-
diff --git a/src/plugins/mousedrivers/linuxtp/main.cpp b/src/plugins/mousedrivers/linuxtp/main.cpp
deleted file mode 100644
index 64a69ef7f1..0000000000
--- a/src/plugins/mousedrivers/linuxtp/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmousedriverplugin_qws.h>
-#include <qmouselinuxtp_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class QLinuxTPMouseDriver : public QMouseDriverPlugin
-{
-public:
- QLinuxTPMouseDriver();
-
- QStringList keys() const;
- QWSMouseHandler* create(const QString &driver, const QString &device);
-};
-
-QLinuxTPMouseDriver::QLinuxTPMouseDriver()
- : QMouseDriverPlugin()
-{
-}
-
-QStringList QLinuxTPMouseDriver::keys() const
-{
- return (QStringList() << "LinuxTP");
-}
-
-QWSMouseHandler* QLinuxTPMouseDriver::create(const QString &driver,
- const QString &device)
-{
- if (driver.compare(QLatin1String("LinuxTP"), Qt::CaseInsensitive))
- return 0;
- return new QWSLinuxTPMouseHandler(driver, device);
-}
-
-Q_EXPORT_PLUGIN2(qwslinuxtpmousehandler, QLinuxTPMouseDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/mousedrivers.pro b/src/plugins/mousedrivers/mousedrivers.pro
deleted file mode 100644
index f89682b880..0000000000
--- a/src/plugins/mousedrivers/mousedrivers.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-contains(mouse-plugins, linuxtp): SUBDIRS += linuxtp
-contains(mouse-plugins, pc): SUBDIRS += pc
-contains(mouse-plugins, tslib): SUBDIRS += tslib
-contains(mouse-plugins, linuxinput): SUBDIRS += linuxinput
diff --git a/src/plugins/mousedrivers/pc/main.cpp b/src/plugins/mousedrivers/pc/main.cpp
deleted file mode 100644
index fbd23dab0f..0000000000
--- a/src/plugins/mousedrivers/pc/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmousedriverplugin_qws.h>
-#include <qmousepc_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class QPcMouseDriver : public QMouseDriverPlugin
-{
-public:
- QPcMouseDriver();
-
- QStringList keys() const;
- QWSMouseHandler* create(const QString &driver, const QString &device);
-};
-
-QPcMouseDriver::QPcMouseDriver()
- : QMouseDriverPlugin()
-{
-}
-
-QStringList QPcMouseDriver::keys() const
-{
- return (QStringList()
- << QLatin1String("Auto")
- << QLatin1String("IntelliMouse")
- << QLatin1String("Microsoft")
- << QLatin1String("MouseSystems")
- << QLatin1String("MouseMan"));
-}
-
-QWSMouseHandler* QPcMouseDriver::create(const QString &driver,
- const QString &device)
-{
- if (!keys().contains(driver, Qt::CaseInsensitive))
- return 0;
- return new QWSPcMouseHandler(driver, device);
-}
-
-Q_EXPORT_PLUGIN2(qwspcmousehandler, QPcMouseDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/pc/pc.pro b/src/plugins/mousedrivers/pc/pc.pro
deleted file mode 100644
index 04d7b0f06f..0000000000
--- a/src/plugins/mousedrivers/pc/pc.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qpcmousedriver
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/mousedrivers
-target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_MOUSE_PC
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmousepc_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousepc_qws.cpp
-
diff --git a/src/plugins/mousedrivers/tslib/main.cpp b/src/plugins/mousedrivers/tslib/main.cpp
deleted file mode 100644
index 1d6f8535ba..0000000000
--- a/src/plugins/mousedrivers/tslib/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmousedriverplugin_qws.h>
-#include <qmousetslib_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class TslibMouseDriver : public QMouseDriverPlugin
-{
-public:
- TslibMouseDriver();
-
- QStringList keys() const;
- QWSMouseHandler* create(const QString &driver, const QString &device);
-};
-
-TslibMouseDriver::TslibMouseDriver()
- : QMouseDriverPlugin()
-{
-}
-
-QStringList TslibMouseDriver::keys() const
-{
- return (QStringList() << "tslib");
-}
-
-QWSMouseHandler* TslibMouseDriver::create(const QString &driver,
- const QString &device)
-{
- if (driver.toLower() != "tslib")
- return 0;
- return new QWSTslibMouseHandler(driver, device);
-}
-
-Q_EXPORT_STATIC_PLUGIN(TslibMouseDriver)
-Q_EXPORT_PLUGIN2(qwstslibmousehandler, TslibMouseDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/tslib/tslib.pro b/src/plugins/mousedrivers/tslib/tslib.pro
deleted file mode 100644
index 552a2e7173..0000000000
--- a/src/plugins/mousedrivers/tslib/tslib.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qtslibmousedriver
-load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/mousedrivers
-
-HEADERS = \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousedriverplugin_qws.h \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousetslib_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousetslib_qws.cpp
-
-LIBS += -lts
-
-target.path += $$[QT_INSTALL_PLUGINS]/mousedrivers
-INSTALLS += target
-
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index bfa147f948..53bd4777ec 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -2,28 +2,32 @@ TARGET = qcocoa
load(qt_plugin)
DESTDIR = $$QT.gui.plugins/platforms
-OBJECTIVE_SOURCES = main.mm \
+OBJECTIVE_SOURCES += main.mm \
qcocoaintegration.mm \
- qcocoawindowsurface.mm \
+ qcocoabackingstore.mm \
qcocoawindow.mm \
qnsview.mm \
- qcocoaeventloopintegration.mm \
qcocoaautoreleasepool.mm \
- qnswindowdelegate.mm
+ qnswindowdelegate.mm \
+ qcocoaglcontext.mm \
+ qcocoanativeinterface.mm \
+ qcocoaeventdispatcher.mm
-OBJECTIVE_HEADERS = qcocoaintegration.h \
- qcocoawindowsurface.h \
+HEADERS += qcocoaintegration.h \
+ qcocoabackingstore.h \
qcocoawindow.h \
qnsview.h \
- qcocoaeventloopintegration.h \
qcocoaautoreleasepool.h \
- qnswindowdelegate.h
+ qnswindowdelegate.h \
+ qcocoaglcontext.h \
+ qcocoanativeinterface.h \
+ qcocoaeventdispatcher.h
#add libz for freetype.
-LIBS += -lz
-LIBS += -framework cocoa
+LIBS += -lz -framework Cocoa
-include(../fontdatabases/coretext/coretext.pri)
+QT += core-private gui-private platformsupport-private
+
+CONFIG += qpa/basicunixfontdatabase
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
-
diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index 95eea2b7ea..938e27347c 100644
--- a/src/plugins/platforms/cocoa/qcocoawindowsurface.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -39,33 +39,31 @@
**
****************************************************************************/
-#ifndef QWINDOWSURFACE_COCOA_H
-#define QWINDOWSURFACE_COCOA_H
+#ifndef QBACKINGSTORE_COCOA_H
+#define QBACKINGSTORE_COCOA_H
#include <Cocoa/Cocoa.h>
#include "qcocoawindow.h"
#include "qnsview.h"
-#include <QtGui/private/qwindowsurface_p.h>
+#include <QPlatformBackingStore>
QT_BEGIN_NAMESPACE
-class QCocoaWindowSurface : public QWindowSurface
+class QCocoaBackingStore : public QPlatformBackingStore
{
public:
- QCocoaWindowSurface(QWidget *window, WId wid);
- ~QCocoaWindowSurface();
+ QCocoaBackingStore(QWindow *window);
+ ~QCocoaBackingStore();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void resize (const QSize &size);
+ void flush(QWindow *widget, const QRegion &region, const QPoint &offset);
+ void resize (const QSize &size, const QRegion &);
private:
-
QCocoaWindow *m_cocoaWindow;
QImage *m_image;
- QNSView *m_contentView;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index 16bb327196..1a25608a7a 100644
--- a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -39,10 +39,9 @@
**
****************************************************************************/
-#include "qcocoawindowsurface.h"
+#include "qcocoabackingstore.h"
#include <QtCore/qdebug.h>
-
#include <QtGui/QPainter>
QT_BEGIN_NAMESPACE
@@ -56,30 +55,28 @@ QRect flipedRect(const QRect &sourceRect,int height)
return flippedRect;
}
-QCocoaWindowSurface::QCocoaWindowSurface(QWidget *window, WId wId)
- : QWindowSurface(window)
+QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
+ : QPlatformBackingStore(window)
{
- m_cocoaWindow = static_cast<QCocoaWindow *>(window->platformWindow());
+ m_cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
const QRect geo = window->geometry();
NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height());
- m_contentView = [[QNSView alloc] initWithWidget:window];
- m_cocoaWindow->setContentView(m_contentView);
- m_image = new QImage(window->size(),QImage::Format_ARGB32);
+ m_image = new QImage(window->geometry().size(),QImage::Format_ARGB32);
}
-QCocoaWindowSurface::~QCocoaWindowSurface()
+QCocoaBackingStore::~QCocoaBackingStore()
{
delete m_image;
}
-QPaintDevice *QCocoaWindowSurface::paintDevice()
+QPaintDevice *QCocoaBackingStore::paintDevice()
{
return m_image;
}
-void QCocoaWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QCocoaBackingStore::flush(QWindow *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(widget);
Q_UNUSED(offset);
@@ -87,17 +84,15 @@ void QCocoaWindowSurface::flush(QWidget *widget, const QRegion &region, const QP
QRect geo = region.boundingRect();
NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
- [m_contentView displayRect:rect];
+ [m_cocoaWindow->m_windowSurfaceView displayRect:rect];
}
-void QCocoaWindowSurface::resize(const QSize &size)
+void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
{
- QWindowSurface::resize(size);
delete m_image;
m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied);
NSSize newSize = NSMakeSize(size.width(),size.height());
- [m_contentView setImage:m_image];
-
+ [static_cast<QNSView *>(m_cocoaWindow->m_windowSurfaceView) setImage:m_image];
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
new file mode 100644
index 0000000000..2085a437ac
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (c) 2007-2008, Apple, Inc.
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are met:
+**
+** * Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** * Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** * Neither the name of Apple, Inc. nor the names of its contributors
+** may be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+****************************************************************************/
+
+#ifndef QEVENTDISPATCHER_MAC_P_H
+#define QEVENTDISPATCHER_MAC_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qhash.h>
+#include <QtCore/qstack.h>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/private/qeventdispatcher_unix_p.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef struct _NSModalSession *NSModalSession;
+typedef struct _QCocoaModalSessionInfo {
+ QPointer<QWindow> window;
+ NSModalSession session;
+ void *nswindow;
+} QCocoaModalSessionInfo;
+
+class Q_GUI_EXPORT QMacCocoaAutoReleasePool
+{
+private:
+ void *pool;
+public:
+ QMacCocoaAutoReleasePool();
+ ~QMacCocoaAutoReleasePool();
+
+ inline void *handle() const { return pool; }
+};
+
+class QCocoaEventDispatcherPrivate;
+class QCocoaEventDispatcher : public QEventDispatcherUNIX
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QCocoaEventDispatcher)
+
+public:
+ QCocoaEventDispatcher(QAbstractEventDispatcherPrivate &priv, QObject *parent = 0);
+ explicit QCocoaEventDispatcher(QObject *parent = 0);
+ ~QCocoaEventDispatcher();
+
+
+ bool processEvents(QEventLoop::ProcessEventsFlags flags);
+ bool hasPendingEvents();
+
+ void registerSocketNotifier(QSocketNotifier *notifier);
+ void unregisterSocketNotifier(QSocketNotifier *notifier);
+
+ void registerTimer(int timerId, int interval, QObject *object);
+ bool unregisterTimer(int timerId);
+ bool unregisterTimers(QObject *object);
+ QList<TimerInfo> registeredTimers(QObject *object) const;
+
+ void wakeUp();
+ void interrupt();
+
+private:
+ //friend void qt_mac_select_timer_callbk(__EventLoopTimer*, void*);
+ friend class QApplicationPrivate;
+};
+
+struct MacTimerInfo {
+ int id;
+ int interval;
+ QObject *obj;
+ bool pending;
+ CFRunLoopTimerRef runLoopTimer;
+ bool operator==(const MacTimerInfo &other)
+ {
+ return (id == other.id);
+ }
+};
+typedef QHash<int, MacTimerInfo *> MacTimerHash;
+
+struct MacSocketInfo {
+ MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0) {}
+ CFSocketRef socket;
+ CFRunLoopSourceRef runloop;
+ QObject *readNotifier;
+ QObject *writeNotifier;
+};
+typedef QHash<int, MacSocketInfo *> MacSocketHash;
+
+class QCocoaEventDispatcherPrivate : public QEventDispatcherUNIXPrivate
+{
+ Q_DECLARE_PUBLIC(QCocoaEventDispatcher)
+
+public:
+ QCocoaEventDispatcherPrivate();
+
+ static MacTimerHash macTimerHash;
+ // Set 'blockSendPostedEvents' to true if you _really_ need
+ // to make sure that qt events are not posted while calling
+ // low-level cocoa functions (like beginModalForWindow). And
+ // use a QBoolBlocker to be safe:
+ static bool blockSendPostedEvents;
+ // The following variables help organizing modal sessions:
+ static QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
+ static bool currentExecIsNSAppRun;
+ static bool nsAppRunCalledByQt;
+ static bool cleanupModalSessionsNeeded;
+ static NSModalSession currentModalSessionCached;
+ static NSModalSession currentModalSession();
+ static void updateChildrenWorksWhenModal();
+ static void temporarilyStopAllModalSessions();
+ static void beginModalSession(QWindow *widget);
+ static void endModalSession(QWindow *widget);
+ static void cancelWaitForMoreEvents();
+ static void cleanupModalSessions();
+ static void ensureNSAppInitialized();
+
+ MacSocketHash macSockets;
+ QList<void *> queuedUserInputEvents; // NSEvent *
+ CFRunLoopSourceRef postedEventsSource;
+ CFRunLoopObserverRef waitingObserver;
+ CFRunLoopObserverRef firstTimeObserver;
+ QAtomicInt serialNumber;
+ int lastSerial;
+ static bool interrupt;
+private:
+ static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2);
+ static void postedEventsSourcePerformCallback(void *info);
+ static void activateTimer(CFRunLoopTimerRef, void *info);
+ static void waitingObserverCallback(CFRunLoopObserverRef observer,
+ CFRunLoopActivity activity, void *info);
+ static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);
+ friend void processPostedEvents(QCocoaEventDispatcherPrivate *const d, const bool blockSendPostedEvents);
+};
+
+class QtCocoaInterruptDispatcher : public QObject
+{
+ static QtCocoaInterruptDispatcher *instance;
+ bool cancelled;
+
+ QtCocoaInterruptDispatcher();
+ ~QtCocoaInterruptDispatcher();
+
+ public:
+ static void interruptLater();
+ static void cancelInterruptLater();
+};
+
+QT_END_NAMESPACE
+
+#endif // QEVENTDISPATCHER_MAC_P_H
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
new file mode 100644
index 0000000000..cfb6995f57
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -0,0 +1,1133 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (c) 2007-2008, Apple, Inc.
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are met:
+**
+** * Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** * Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** * Neither the name of Apple, Inc. nor the names of its contributors
+** may be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+****************************************************************************/
+
+#include "qcocoaeventdispatcher.h"
+#include "qguiapplication.h"
+#include "qevent.h"
+#include "qhash.h"
+#include "qmutex.h"
+#include "qsocketnotifier.h"
+#include <qplatformwindow_qpa.h>
+#include "private/qthread_p.h"
+#include "private/qguiapplication_p.h"
+#include <qdebug.h>
+
+//#include <private/qcocoaapplication_mac_p.h>
+//#include "private/qt_cocoa_helpers_mac_p.h"
+#include <Cocoa/Cocoa.h>
+#include <Carbon/Carbon.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+enum {
+ QtCocoaEventSubTypeWakeup = SHRT_MAX,
+ QtCocoaEventSubTypePostMessage = SHRT_MAX-1
+};
+
+static inline CFRunLoopRef mainRunLoop()
+{
+ return CFRunLoopGetMain();
+}
+
+QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool()
+{
+ pool = (void*)[[NSAutoreleasePool alloc] init];
+}
+
+QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool()
+{
+ [(NSAutoreleasePool*)pool release];
+}
+
+
+/*****************************************************************************
+ Timers stuff
+ *****************************************************************************/
+
+/* timer call back */
+void QCocoaEventDispatcherPrivate::activateTimer(CFRunLoopTimerRef, void *info)
+{
+ int timerID =
+#ifdef Q_OS_MAC64
+ qint64(info);
+#else
+ int(info);
+#endif
+
+ MacTimerInfo *tmr;
+ tmr = macTimerHash.value(timerID);
+ if (tmr == 0 || tmr->pending == true)
+ return; // Can't send another timer event if it's pending.
+
+
+ if (blockSendPostedEvents) {
+ QCoreApplication::postEvent(tmr->obj, new QTimerEvent(tmr->id));
+ } else {
+ tmr->pending = true;
+ QTimerEvent e(tmr->id);
+
+ QCoreApplication::sendSpontaneousEvent(tmr->obj, &e);
+ // Get the value again in case the timer gets unregistered during the sendEvent.
+ tmr = macTimerHash.value(timerID);
+ if (tmr != 0)
+ tmr->pending = false;
+ }
+
+}
+
+void QCocoaEventDispatcher::registerTimer(int timerId, int interval, QObject *obj)
+{
+#ifndef QT_NO_DEBUG
+ if (timerId < 1 || interval < 0 || !obj) {
+ qWarning("QEventDispatcherMac::registerTimer: invalid arguments");
+ return;
+ } else if (obj->thread() != thread() || thread() != QThread::currentThread()) {
+ qWarning("QObject::startTimer: timers cannot be started from another thread");
+ return;
+ }
+#endif
+
+ MacTimerInfo *t = new MacTimerInfo();
+ t->id = timerId;
+ t->interval = interval;
+ t->obj = obj;
+ t->runLoopTimer = 0;
+ t->pending = false;
+
+ CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent();
+ CFTimeInterval cfinterval = qMax(CFTimeInterval(interval) / 1000, 0.0000001);
+ fireDate += cfinterval;
+ QCocoaEventDispatcherPrivate::macTimerHash.insert(timerId, t);
+ CFRunLoopTimerContext info = { 0, (void *)timerId, 0, 0, 0 };
+ t->runLoopTimer = CFRunLoopTimerCreate(0, fireDate, cfinterval, 0, 0,
+ QCocoaEventDispatcherPrivate::activateTimer, &info);
+ if (t->runLoopTimer == 0) {
+ qFatal("QEventDispatcherMac::registerTimer: Cannot create timer");
+ }
+ CFRunLoopAddTimer(mainRunLoop(), t->runLoopTimer, kCFRunLoopCommonModes);
+}
+
+bool QCocoaEventDispatcher::unregisterTimer(int identifier)
+{
+#ifndef QT_NO_DEBUG
+ if (identifier < 1) {
+ qWarning("QEventDispatcherMac::unregisterTimer: invalid argument");
+ return false;
+ } else if (thread() != QThread::currentThread()) {
+ qWarning("QObject::killTimer: timers cannot be stopped from another thread");
+ return false;
+ }
+#endif
+ if (identifier <= 0)
+ return false; // not init'd or invalid timer
+
+ MacTimerInfo *timerInfo = QCocoaEventDispatcherPrivate::macTimerHash.take(identifier);
+ if (timerInfo == 0)
+ return false;
+
+ if (!QObjectPrivate::get(timerInfo->obj)->inThreadChangeEvent)
+ QAbstractEventDispatcherPrivate::releaseTimerId(identifier);
+ CFRunLoopTimerInvalidate(timerInfo->runLoopTimer);
+ CFRelease(timerInfo->runLoopTimer);
+ delete timerInfo;
+
+ return true;
+}
+
+bool QCocoaEventDispatcher::unregisterTimers(QObject *obj)
+{
+#ifndef QT_NO_DEBUG
+ if (!obj) {
+ qWarning("QEventDispatcherMac::unregisterTimers: invalid argument");
+ return false;
+ } else if (obj->thread() != thread() || thread() != QThread::currentThread()) {
+ qWarning("QObject::killTimers: timers cannot be stopped from another thread");
+ return false;
+ }
+#endif
+
+ MacTimerHash::iterator it = QCocoaEventDispatcherPrivate::macTimerHash.begin();
+ while (it != QCocoaEventDispatcherPrivate::macTimerHash.end()) {
+ MacTimerInfo *timerInfo = it.value();
+ if (timerInfo->obj != obj) {
+ ++it;
+ } else {
+ if (!QObjectPrivate::get(timerInfo->obj)->inThreadChangeEvent)
+ QAbstractEventDispatcherPrivate::releaseTimerId(timerInfo->id);
+ CFRunLoopTimerInvalidate(timerInfo->runLoopTimer);
+ CFRelease(timerInfo->runLoopTimer);
+ delete timerInfo;
+ it = QCocoaEventDispatcherPrivate::macTimerHash.erase(it);
+ }
+ }
+ return true;
+}
+
+QList<QCocoaEventDispatcher::TimerInfo>
+QCocoaEventDispatcher::registeredTimers(QObject *object) const
+{
+ if (!object) {
+ qWarning("QEventDispatcherMac:registeredTimers: invalid argument");
+ return QList<TimerInfo>();
+ }
+
+ QList<TimerInfo> list;
+
+ MacTimerHash::const_iterator it = QCocoaEventDispatcherPrivate::macTimerHash.constBegin();
+ while (it != QCocoaEventDispatcherPrivate::macTimerHash.constEnd()) {
+ MacTimerInfo *t = it.value();
+ if (t->obj == object)
+ list << TimerInfo(t->id, t->interval);
+ ++it;
+ }
+ return list;
+}
+
+/**************************************************************************
+ Socket Notifiers
+ *************************************************************************/
+void qt_mac_socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef,
+ const void *, void *info) {
+ QCocoaEventDispatcherPrivate *const eventDispatcher
+ = static_cast<QCocoaEventDispatcherPrivate *>(info);
+ int nativeSocket = CFSocketGetNative(s);
+ MacSocketInfo *socketInfo = eventDispatcher->macSockets.value(nativeSocket);
+ QEvent notifierEvent(QEvent::SockAct);
+
+ // There is a race condition that happen where we disable the notifier and
+ // the kernel still has a notification to pass on. We then get this
+ // notification after we've successfully disabled the CFSocket, but our Qt
+ // notifier is now gone. The upshot is we have to check the notifier
+ // everytime.
+ if (callbackType == kCFSocketReadCallBack) {
+ if (socketInfo->readNotifier)
+ QGuiApplication::sendEvent(socketInfo->readNotifier, &notifierEvent);
+ } else if (callbackType == kCFSocketWriteCallBack) {
+ if (socketInfo->writeNotifier)
+ QGuiApplication::sendEvent(socketInfo->writeNotifier, &notifierEvent);
+ }
+}
+
+/*
+ Adds a loop source for the given socket to the current run loop.
+*/
+CFRunLoopSourceRef qt_mac_add_socket_to_runloop(const CFSocketRef socket)
+{
+ CFRunLoopSourceRef loopSource = CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0);
+ if (!loopSource)
+ return 0;
+
+ CFRunLoopAddSource(mainRunLoop(), loopSource, kCFRunLoopCommonModes);
+ return loopSource;
+}
+
+/*
+ Removes the loop source for the given socket from the current run loop.
+*/
+void qt_mac_remove_socket_from_runloop(const CFSocketRef socket, CFRunLoopSourceRef runloop)
+{
+ Q_ASSERT(runloop);
+ CFRunLoopRemoveSource(mainRunLoop(), runloop, kCFRunLoopCommonModes);
+ CFSocketDisableCallBacks(socket, kCFSocketReadCallBack);
+ CFSocketDisableCallBacks(socket, kCFSocketWriteCallBack);
+ CFRunLoopSourceInvalidate(runloop);
+}
+
+/*
+ Register a QSocketNotifier with the mac event system by creating a CFSocket with
+ with a read/write callback.
+
+ Qt has separate socket notifiers for reading and writing, but on the mac there is
+ a limitation of one CFSocket object for each native socket.
+*/
+void QCocoaEventDispatcher::registerSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_ASSERT(notifier);
+ int nativeSocket = notifier->socket();
+ int type = notifier->type();
+#ifndef QT_NO_DEBUG
+ if (nativeSocket < 0 || nativeSocket > FD_SETSIZE) {
+ qWarning("QSocketNotifier: Internal error");
+ return;
+ } else if (notifier->thread() != thread()
+ || thread() != QThread::currentThread()) {
+ qWarning("QSocketNotifier: socket notifiers cannot be enabled from another thread");
+ return;
+ }
+#endif
+
+ Q_D(QCocoaEventDispatcher);
+
+ if (type == QSocketNotifier::Exception) {
+ qWarning("QSocketNotifier::Exception is not supported on Mac OS X");
+ return;
+ }
+
+ // Check if we have a CFSocket for the native socket, create one if not.
+ MacSocketInfo *socketInfo = d->macSockets.value(nativeSocket);
+ if (!socketInfo) {
+ socketInfo = new MacSocketInfo();
+
+ // Create CFSocket, specify that we want both read and write callbacks (the callbacks
+ // are enabled/disabled later on).
+ const int callbackTypes = kCFSocketReadCallBack | kCFSocketWriteCallBack;
+ CFSocketContext context = {0, d, 0, 0, 0};
+ socketInfo->socket = CFSocketCreateWithNative(kCFAllocatorDefault, nativeSocket, callbackTypes, qt_mac_socket_callback, &context);
+ if (CFSocketIsValid(socketInfo->socket) == false) {
+ qWarning("QEventDispatcherMac::registerSocketNotifier: Failed to create CFSocket");
+ return;
+ }
+
+ CFOptionFlags flags = CFSocketGetSocketFlags(socketInfo->socket);
+ flags |= kCFSocketAutomaticallyReenableWriteCallBack; //QSocketNotifier stays enabled after a write
+ flags &= ~kCFSocketCloseOnInvalidate; //QSocketNotifier doesn't close the socket upon destruction/invalidation
+ CFSocketSetSocketFlags(socketInfo->socket, flags);
+
+ // Add CFSocket to runloop.
+ if(!(socketInfo->runloop = qt_mac_add_socket_to_runloop(socketInfo->socket))) {
+ qWarning("QEventDispatcherMac::registerSocketNotifier: Failed to add CFSocket to runloop");
+ CFSocketInvalidate(socketInfo->socket);
+ CFRelease(socketInfo->socket);
+ return;
+ }
+
+ // Disable both callback types by default. This must be done after
+ // we add the CFSocket to the runloop, or else these calls will have
+ // no effect.
+ CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack);
+ CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack);
+
+ d->macSockets.insert(nativeSocket, socketInfo);
+ }
+
+ // Increment read/write counters and select enable callbacks if necessary.
+ if (type == QSocketNotifier::Read) {
+ Q_ASSERT(socketInfo->readNotifier == 0);
+ socketInfo->readNotifier = notifier;
+ CFSocketEnableCallBacks(socketInfo->socket, kCFSocketReadCallBack);
+ } else if (type == QSocketNotifier::Write) {
+ Q_ASSERT(socketInfo->writeNotifier == 0);
+ socketInfo->writeNotifier = notifier;
+ CFSocketEnableCallBacks(socketInfo->socket, kCFSocketWriteCallBack);
+ }
+}
+
+/*
+ Unregister QSocketNotifer. The CFSocket correspoding to this notifier is
+ removed from the runloop of this is the last notifier that users
+ that CFSocket.
+*/
+void QCocoaEventDispatcher::unregisterSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_ASSERT(notifier);
+ int nativeSocket = notifier->socket();
+ int type = notifier->type();
+#ifndef QT_NO_DEBUG
+ if (nativeSocket < 0 || nativeSocket > FD_SETSIZE) {
+ qWarning("QSocketNotifier: Internal error");
+ return;
+ } else if (notifier->thread() != thread() || thread() != QThread::currentThread()) {
+ qWarning("QSocketNotifier: socket notifiers cannot be disabled from another thread");
+ return;
+ }
+#endif
+
+ Q_D(QCocoaEventDispatcher);
+
+ if (type == QSocketNotifier::Exception) {
+ qWarning("QSocketNotifier::Exception is not supported on Mac OS X");
+ return;
+ }
+ MacSocketInfo *socketInfo = d->macSockets.value(nativeSocket);
+ if (!socketInfo) {
+ qWarning("QEventDispatcherMac::unregisterSocketNotifier: Tried to unregister a not registered notifier");
+ return;
+ }
+
+ // Decrement read/write counters and disable callbacks if necessary.
+ if (type == QSocketNotifier::Read) {
+ Q_ASSERT(notifier == socketInfo->readNotifier);
+ socketInfo->readNotifier = 0;
+ CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack);
+ } else if (type == QSocketNotifier::Write) {
+ Q_ASSERT(notifier == socketInfo->writeNotifier);
+ socketInfo->writeNotifier = 0;
+ CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack);
+ }
+
+ // Remove CFSocket from runloop if this was the last QSocketNotifier.
+ if (socketInfo->readNotifier == 0 && socketInfo->writeNotifier == 0) {
+ if (CFSocketIsValid(socketInfo->socket))
+ qt_mac_remove_socket_from_runloop(socketInfo->socket, socketInfo->runloop);
+ CFRunLoopSourceInvalidate(socketInfo->runloop);
+ CFRelease(socketInfo->runloop);
+ CFSocketInvalidate(socketInfo->socket);
+ CFRelease(socketInfo->socket);
+ delete socketInfo;
+ d->macSockets.remove(nativeSocket);
+ }
+}
+
+bool QCocoaEventDispatcher::hasPendingEvents()
+{
+ extern uint qGlobalPostedEventsCount();
+ extern bool qt_is_gui_used; //qapplication.cpp
+ return qGlobalPostedEventsCount() || (qt_is_gui_used && GetNumEventsInQueue(GetMainEventQueue()));
+}
+
+static bool IsMouseOrKeyEvent( NSEvent* event )
+{
+ bool result = false;
+
+ switch( [event type] )
+ {
+ case NSLeftMouseDown:
+ case NSLeftMouseUp:
+ case NSRightMouseDown:
+ case NSRightMouseUp:
+ case NSMouseMoved: // ??
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSMouseEntered:
+ case NSMouseExited:
+ case NSKeyDown:
+ case NSKeyUp:
+ case NSFlagsChanged: // key modifiers changed?
+ case NSCursorUpdate: // ??
+ case NSScrollWheel:
+ case NSTabletPoint:
+ case NSTabletProximity:
+ case NSOtherMouseDown:
+ case NSOtherMouseUp:
+ case NSOtherMouseDragged:
+#ifndef QT_NO_GESTURES
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ case NSEventTypeGesture: // touch events
+ case NSEventTypeMagnify:
+ case NSEventTypeSwipe:
+ case NSEventTypeRotate:
+ case NSEventTypeBeginGesture:
+ case NSEventTypeEndGesture:
+#endif
+#endif // QT_NO_GESTURES
+ result = true;
+ break;
+
+ default:
+ break;
+ }
+ return result;
+}
+
+static inline void qt_mac_waitForMoreEvents()
+{
+ // If no event exist in the cocoa event que, wait
+ // (and free up cpu time) until at least one event occur.
+ // This implementation is a bit on the edge, but seems to
+ // work fine:
+ NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantFuture]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ if (event)
+ [NSApp postEvent:event atStart:YES];
+}
+
+static inline void qt_mac_waitForMoreModalSessionEvents()
+{
+ // If no event exist in the cocoa event que, wait
+ // (and free up cpu time) until at least one event occur.
+ // This implementation is a bit on the edge, but seems to
+ // work fine:
+ NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantFuture]
+ inMode:NSModalPanelRunLoopMode
+ dequeue:YES];
+ if (event)
+ [NSApp postEvent:event atStart:YES];
+}
+
+bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ Q_D(QCocoaEventDispatcher);
+ d->interrupt = false;
+
+ bool interruptLater = false;
+ QtCocoaInterruptDispatcher::cancelInterruptLater();
+
+ // In case we end up recursing while we now process events, make sure
+ // that we send remaining posted Qt events before this call returns:
+ wakeUp();
+ emit awake();
+
+ bool excludeUserEvents = flags & QEventLoop::ExcludeUserInputEvents;
+ bool retVal = false;
+ forever {
+ if (d->interrupt)
+ break;
+
+ QMacCocoaAutoReleasePool pool;
+ NSEvent* event = 0;
+
+ // First, send all previously excluded input events, if any:
+ if (!excludeUserEvents) {
+ while (!d->queuedUserInputEvents.isEmpty()) {
+ event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
+ if (!filterEvent(event)) {
+ [NSApp sendEvent:event];
+ retVal = true;
+ }
+ [event release];
+ }
+ }
+
+ // If Qt is used as a plugin, or as an extension in a native cocoa
+ // application, we should not run or stop NSApplication; This will be
+ // done from the application itself. And if processEvents is called
+ // manually (rather than from a QEventLoop), we cannot enter a tight
+ // loop and block this call, but instead we need to return after one flush.
+ // Finally, if we are to exclude user input events, we cannot call [NSApp run]
+ // as we then loose control over which events gets dispatched:
+ const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
+ const bool canExec_Qt = !excludeUserEvents &&
+ (flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec) ;
+
+ if (canExec_Qt && canExec_3rdParty) {
+ // We can use exec-mode, meaning that we can stay in a tight loop until
+ // interrupted. This is mostly an optimization, but it allow us to use
+ // [NSApp run], which is the normal code path for cocoa applications.
+ if (NSModalSession session = d->currentModalSession()) {
+ QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
+ while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
+ qt_mac_waitForMoreModalSessionEvents();
+
+ if (!d->interrupt && session == d->currentModalSessionCached) {
+ // Someone called [NSApp stopModal:] from outside the event
+ // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+ // 'session' as well. As a result, we need to restart all internal sessions:
+ d->temporarilyStopAllModalSessions();
+ }
+ } else {
+ d->nsAppRunCalledByQt = true;
+ QBoolBlocker execGuard(d->currentExecIsNSAppRun, true);
+ [NSApp run];
+ }
+ retVal = true;
+ } else {
+ // We cannot block the thread (and run in a tight loop).
+ // Instead we will process all current pending events and return.
+ d->ensureNSAppInitialized();
+ if (NSModalSession session = d->currentModalSession()) {
+ // INVARIANT: a modal window is executing.
+ if (!excludeUserEvents) {
+ // Since we can dispatch all kinds of events, we choose
+ // to use cocoa's native way of running modal sessions:
+ if (flags & QEventLoop::WaitForMoreEvents)
+ qt_mac_waitForMoreModalSessionEvents();
+ NSInteger status = [NSApp runModalSession:session];
+ if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
+ // INVARIANT: Someone called [NSApp stopModal:] from outside the event
+ // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+ // 'session' as well. As a result, we need to restart all internal sessions:
+ d->temporarilyStopAllModalSessions();
+ }
+ retVal = true;
+ } else do {
+ // Dispatch all non-user events (but que non-user events up for later). In
+ // this case, we need more control over which events gets dispatched, and
+ // cannot use [NSApp runModalSession:session]:
+ event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:nil
+ inMode:NSModalPanelRunLoopMode
+ dequeue: YES];
+
+ if (event) {
+ if (IsMouseOrKeyEvent(event)) {
+ [event retain];
+ d->queuedUserInputEvents.append(event);
+ continue;
+ }
+ if (!filterEvent(event)) {
+ [NSApp sendEvent:event];
+ retVal = true;
+ }
+ }
+ } while (!d->interrupt && event != nil);
+ } else do {
+ // INVARIANT: No modal window is executing.
+ event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:nil
+ inMode:NSDefaultRunLoopMode
+ dequeue: YES];
+
+ if (event) {
+ if (flags & QEventLoop::ExcludeUserInputEvents) {
+ if (IsMouseOrKeyEvent(event)) {
+ [event retain];
+ d->queuedUserInputEvents.append(event);
+ continue;
+ }
+ }
+ if (!filterEvent(event)) {
+ [NSApp sendEvent:event];
+ retVal = true;
+ }
+ }
+ } while (!d->interrupt && event != nil);
+
+ // Be sure to flush the Qt posted events when not using exec mode
+ // (exec mode will always do this call from the event loop source):
+ if (!d->interrupt)
+ QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+
+ // Since the window that holds modality might have changed while processing
+ // events, we we need to interrupt when we return back the previous process
+ // event recursion to ensure that we spin the correct modal session.
+ // We do the interruptLater at the end of the function to ensure that we don't
+ // disturb the 'wait for more events' below (as deleteLater will post an event):
+ interruptLater = true;
+ }
+ bool canWait = (d->threadData->canWait
+ && !retVal
+ && !d->interrupt
+ && (flags & QEventLoop::WaitForMoreEvents));
+ if (canWait) {
+ // INVARIANT: We haven't processed any events yet. And we're told
+ // to stay inside this function until at least one event is processed.
+ qt_mac_waitForMoreEvents();
+ flags &= ~QEventLoop::WaitForMoreEvents;
+ } else {
+ // Done with event processing for now.
+ // Leave the function:
+ break;
+ }
+ }
+
+ // If we're interrupted, we need to interrupt the _current_
+ // recursion as well to check if it is still supposed to be
+ // executing. This way we wind down the stack until we land
+ // on a recursion that again calls processEvents (typically
+ // from QEventLoop), and set interrupt to false:
+ if (d->interrupt)
+ interrupt();
+
+ if (interruptLater)
+ QtCocoaInterruptDispatcher::interruptLater();
+
+ return retVal;
+}
+
+void QCocoaEventDispatcher::wakeUp()
+{
+ Q_D(QCocoaEventDispatcher);
+ d->serialNumber.ref();
+ CFRunLoopSourceSignal(d->postedEventsSource);
+ CFRunLoopWakeUp(mainRunLoop());
+}
+
+/*****************************************************************************
+ QEventDispatcherMac Implementation
+ *****************************************************************************/
+MacTimerHash QCocoaEventDispatcherPrivate::macTimerHash;
+bool QCocoaEventDispatcherPrivate::blockSendPostedEvents = false;
+bool QCocoaEventDispatcherPrivate::interrupt = false;
+
+
+QStack<QCocoaModalSessionInfo> QCocoaEventDispatcherPrivate::cocoaModalSessionStack;
+bool QCocoaEventDispatcherPrivate::currentExecIsNSAppRun = false;
+bool QCocoaEventDispatcherPrivate::nsAppRunCalledByQt = false;
+bool QCocoaEventDispatcherPrivate::cleanupModalSessionsNeeded = false;
+NSModalSession QCocoaEventDispatcherPrivate::currentModalSessionCached = 0;
+
+void QCocoaEventDispatcherPrivate::ensureNSAppInitialized()
+{
+ // Some elements in Cocoa require NSApplication to be running before
+ // they get fully initialized, in particular the menu bar. This
+ // function is intended for cases where a dialog is told to execute before
+ // QGuiApplication::exec is called, or the application spins the events loop
+ // manually rather than calling QGuiApplication:exec.
+ // The function makes sure that NSApplication starts running, but stops
+ // it again as soon as the send posted events callback is called. That way
+ // we let Cocoa finish the initialization it seems to need. We'll only
+ // apply this trick at most once for any application, and we avoid doing it
+ // for the common case where main just starts QGuiApplication::exec.
+ if (nsAppRunCalledByQt || [NSApp isRunning])
+ return;
+ nsAppRunCalledByQt = true;
+ QBoolBlocker block1(interrupt, true);
+ QBoolBlocker block2(currentExecIsNSAppRun, true);
+ [NSApp run];
+}
+
+void QCocoaEventDispatcherPrivate::temporarilyStopAllModalSessions()
+{
+ // Flush, and Stop, all created modal session, and as
+ // such, make them pending again. The next call to
+ // currentModalSession will recreate them again. The
+ // reason to stop all session like this is that otherwise
+ // a call [NSApp stop] would not stop NSApp, but rather
+ // the current modal session. So if we need to stop NSApp
+ // we need to stop all the modal session first. To avoid changing
+ // the stacking order of the windows while doing so, we put
+ // up a block that is used in QCocoaWindow and QCocoaPanel:
+ int stackSize = cocoaModalSessionStack.size();
+ for (int i=0; i<stackSize; ++i) {
+ QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
+ if (info.session) {
+ [NSApp endModalSession:info.session];
+ info.session = 0;
+ }
+ }
+ currentModalSessionCached = 0;
+}
+
+NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
+{
+ // If we have one or more modal windows, this function will create
+ // a session for each of those, and return the one for the top.
+ if (currentModalSessionCached)
+ return currentModalSessionCached;
+
+ if (cocoaModalSessionStack.isEmpty())
+ return 0;
+
+ int sessionCount = cocoaModalSessionStack.size();
+ for (int i=0; i<sessionCount; ++i) {
+ QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
+ if (!info.window)
+ continue;
+// ### port
+// if (info.window->testAttribute(Qt::WA_DontShowOnScreen))
+// continue;
+
+ if (!info.session) {
+ QMacCocoaAutoReleasePool pool;
+ NSWindow *window = reinterpret_cast<NSWindow *>(info.window->handle()->winId());
+ if (!window)
+ continue;
+
+ ensureNSAppInitialized();
+ QBoolBlocker block1(blockSendPostedEvents, true);
+ info.nswindow = window;
+ [(NSWindow*) info.nswindow retain];
+ int levelBeforeEnterModal = [window level];
+ info.session = [NSApp beginModalSessionForWindow:window];
+ // Make sure we don't stack the window lower that it was before
+ // entering modal, in case it e.g. had the stays-on-top flag set:
+ if (levelBeforeEnterModal > [window level])
+ [window setLevel:levelBeforeEnterModal];
+ }
+ currentModalSessionCached = info.session;
+ cleanupModalSessionsNeeded = false;
+ }
+ return currentModalSessionCached;
+}
+
+static void setChildrenWorksWhenModal(QWindow *window, bool worksWhenModal)
+{
+ // For NSPanels (but not NSWindows, sadly), we can set the flag
+ // worksWhenModal, so that they are active even when they are not modal.
+/*
+ ### not ported
+ QList<QDialog *> dialogs = window->findChildren<QDialog *>();
+ for (int i=0; i<dialogs.size(); ++i){
+ NSWindow *window = qt_mac_window_for(dialogs[i]);
+ if (window && [window isKindOfClass:[NSPanel class]]) {
+ [static_cast<NSPanel *>(window) setWorksWhenModal:worksWhenModal];
+ if (worksWhenModal && [window isVisible]){
+ [window orderFront:window];
+ }
+ }
+ }
+*/
+}
+
+void QCocoaEventDispatcherPrivate::updateChildrenWorksWhenModal()
+{
+ // Make the dialog children of the window
+ // active. And make the dialog children of
+ // the previous modal dialog unactive again:
+ QMacCocoaAutoReleasePool pool;
+ int size = cocoaModalSessionStack.size();
+ if (size > 0){
+ if (QWindow *prevModal = cocoaModalSessionStack[size-1].window)
+ setChildrenWorksWhenModal(prevModal, true);
+ if (size > 1){
+ if (QWindow *prevModal = cocoaModalSessionStack[size-2].window)
+ setChildrenWorksWhenModal(prevModal, false);
+ }
+ }
+}
+
+void QCocoaEventDispatcherPrivate::cleanupModalSessions()
+{
+ // Go through the list of modal sessions, and end those
+ // that no longer has a window assosiated; no window means
+ // the the session has logically ended. The reason we wait like
+ // this to actually end the sessions for real (rather than at the
+ // point they were marked as stopped), is that ending a session
+ // when no other session runs below it on the stack will make cocoa
+ // drop some events on the floor.
+ QMacCocoaAutoReleasePool pool;
+ int stackSize = cocoaModalSessionStack.size();
+
+ for (int i=stackSize-1; i>=0; --i) {
+ QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
+ if (info.window) {
+ // This session has a window, and is therefore not marked
+ // as stopped. So just make it current. There might still be other
+ // stopped sessions on the stack, but those will be stopped on
+ // a later "cleanup" call.
+ currentModalSessionCached = info.session;
+ break;
+ }
+ cocoaModalSessionStack.remove(i);
+ currentModalSessionCached = 0;
+ if (info.session) {
+ [NSApp endModalSession:info.session];
+ [(NSWindow *)info.nswindow release];
+ }
+ }
+
+ updateChildrenWorksWhenModal();
+ cleanupModalSessionsNeeded = false;
+}
+
+void QCocoaEventDispatcherPrivate::beginModalSession(QWindow *window)
+{
+ // Add a new, empty (null), NSModalSession to the stack.
+ // It will become active the next time QEventDispatcher::processEvents is called.
+ // A QCocoaModalSessionInfo is considered pending to become active if the window pointer
+ // is non-zero, and the session pointer is zero (it will become active upon a call to
+ // currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if
+ // the window pointer is zero, and the session pointer is non-zero (it will be fully
+ // stopped in cleanupModalSessions()).
+ QCocoaModalSessionInfo info = {window, 0, 0};
+ cocoaModalSessionStack.push(info);
+ updateChildrenWorksWhenModal();
+ currentModalSessionCached = 0;
+}
+
+void QCocoaEventDispatcherPrivate::endModalSession(QWindow *window)
+{
+ // Mark all sessions attached to window as pending to be stopped. We do this
+ // by setting the window pointer to zero, but leave the session pointer.
+ // We don't tell cocoa to stop any sessions just yet, because cocoa only understands
+ // when we stop the _current_ modal session (which is the session on top of
+ // the stack, and might not belong to 'window').
+ int stackSize = cocoaModalSessionStack.size();
+ for (int i=stackSize-1; i>=0; --i) {
+ QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
+ if (info.window == window) {
+ info.window = 0;
+ if (i == stackSize-1) {
+ // The top sessions ended. Interrupt the event dispatcher
+ // to start spinning the correct session immidiatly:
+ currentModalSessionCached = 0;
+ cleanupModalSessionsNeeded = true;
+ QCocoaEventDispatcher::instance()->interrupt();
+ }
+ }
+ }
+}
+
+QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate()
+{
+}
+
+QCocoaEventDispatcher::QCocoaEventDispatcher(QObject *parent)
+ : QEventDispatcherUNIX(*new QCocoaEventDispatcherPrivate, parent)
+{
+ Q_D(QCocoaEventDispatcher);
+ CFRunLoopSourceContext context;
+ bzero(&context, sizeof(CFRunLoopSourceContext));
+ context.info = d;
+ context.equal = QCocoaEventDispatcherPrivate::postedEventSourceEqualCallback;
+ context.perform = QCocoaEventDispatcherPrivate::postedEventsSourcePerformCallback;
+ d->postedEventsSource = CFRunLoopSourceCreate(0, 0, &context);
+ Q_ASSERT(d->postedEventsSource);
+ CFRunLoopAddSource(mainRunLoop(), d->postedEventsSource, kCFRunLoopCommonModes);
+
+ CFRunLoopObserverContext observerContext;
+ bzero(&observerContext, sizeof(CFRunLoopObserverContext));
+ observerContext.info = this;
+ d->waitingObserver = CFRunLoopObserverCreate(kCFAllocatorDefault,
+ kCFRunLoopBeforeWaiting | kCFRunLoopAfterWaiting,
+ true, 0,
+ QCocoaEventDispatcherPrivate::waitingObserverCallback,
+ &observerContext);
+ CFRunLoopAddObserver(mainRunLoop(), d->waitingObserver, kCFRunLoopCommonModes);
+
+ /* The first cycle in the loop adds the source and the events of the source
+ are not processed.
+ We use an observer to process the posted events for the first
+ execution of the loop. */
+ CFRunLoopObserverContext firstTimeObserverContext;
+ bzero(&firstTimeObserverContext, sizeof(CFRunLoopObserverContext));
+ firstTimeObserverContext.info = d;
+ d->firstTimeObserver = CFRunLoopObserverCreate(kCFAllocatorDefault,
+ kCFRunLoopEntry,
+ /* repeats = */ false,
+ 0,
+ QCocoaEventDispatcherPrivate::firstLoopEntry,
+ &firstTimeObserverContext);
+ CFRunLoopAddObserver(mainRunLoop(), d->firstTimeObserver, kCFRunLoopCommonModes);
+}
+
+void QCocoaEventDispatcherPrivate::waitingObserverCallback(CFRunLoopObserverRef,
+ CFRunLoopActivity activity, void *info)
+{
+ if (activity == kCFRunLoopBeforeWaiting)
+ emit static_cast<QCocoaEventDispatcher*>(info)->aboutToBlock();
+ else
+ emit static_cast<QCocoaEventDispatcher*>(info)->awake();
+}
+
+Boolean QCocoaEventDispatcherPrivate::postedEventSourceEqualCallback(const void *info1, const void *info2)
+{
+ return info1 == info2;
+}
+
+void processPostedEvents(QCocoaEventDispatcherPrivate *const d, const bool blockSendPostedEvents)
+{
+ if (blockSendPostedEvents) {
+ // We're told to not send posted events (because the event dispatcher
+ // is currently working on setting up the correct session to run). But
+ // we still need to make sure that we don't fall asleep until pending events
+ // are sendt, so we just signal this need, and return:
+ CFRunLoopSourceSignal(d->postedEventsSource);
+ return;
+ }
+
+ if (d->cleanupModalSessionsNeeded)
+ d->cleanupModalSessions();
+
+ if (d->interrupt) {
+ if (d->currentExecIsNSAppRun) {
+ // The event dispatcher has been interrupted. But since
+ // [NSApplication run] is running the event loop, we
+ // delayed stopping it until now (to let cocoa process
+ // pending cocoa events first).
+ if (d->currentModalSessionCached)
+ d->temporarilyStopAllModalSessions();
+ [NSApp stop:NSApp];
+ d->cancelWaitForMoreEvents();
+ }
+ return;
+ }
+
+ if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) {
+ d->lastSerial = d->serialNumber;
+ QWindowSystemInterface::sendWindowSystemEvents(d->q_func(), QEventLoop::AllEvents);
+ }
+}
+
+void QCocoaEventDispatcherPrivate::firstLoopEntry(CFRunLoopObserverRef ref,
+ CFRunLoopActivity activity,
+ void *info)
+{
+ Q_UNUSED(ref);
+ Q_UNUSED(activity);
+/*
+ // This function is called when NSApplication has finished initialization,
+ // which appears to be just after [NSApplication run] has started to execute.
+ // By setting up our apple events handlers this late, we override the ones
+ // set up by NSApplication.
+
+ // If Qt is used as a plugin, we let the 3rd party application handle events
+ // like quit and open file events. Otherwise, if we install our own handlers, we
+ // easily end up breaking functionallity the 3rd party application depend on:
+ if (QGuiApplication::testAttribute(Qt::AA_MacPluginApplication))
+ return;
+
+ QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate];
+ NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager];
+ [eventManager setEventHandler:newDelegate andSelector:@selector(appleEventQuit:withReplyEvent:)
+ forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
+ [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:)
+ forEventClass:kInternetEventClass andEventID:kAEGetURL];
+*/
+
+ processPostedEvents(static_cast<QCocoaEventDispatcherPrivate *>(info), blockSendPostedEvents);
+}
+
+void QCocoaEventDispatcherPrivate::postedEventsSourcePerformCallback(void *info)
+{
+ processPostedEvents(static_cast<QCocoaEventDispatcherPrivate *>(info), blockSendPostedEvents);
+}
+
+void QCocoaEventDispatcherPrivate::cancelWaitForMoreEvents()
+{
+ // In case the event dispatcher is waiting for more
+ // events somewhere, we post a dummy event to wake it up:
+ QMacCocoaAutoReleasePool pool;
+ [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
+ modifierFlags:0 timestamp:0. windowNumber:0 context:0
+ subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
+}
+
+void QCocoaEventDispatcher::interrupt()
+{
+ Q_D(QCocoaEventDispatcher);
+ d->interrupt = true;
+ wakeUp();
+
+ // We do nothing more here than setting d->interrupt = true, and
+ // poke the event loop if it is sleeping. Actually stopping
+ // NSApp, or the current modal session, is done inside the send
+ // posted events callback. We do this to ensure that all current pending
+ // cocoa events gets delivered before we stop. Otherwise, if we now stop
+ // the last event loop recursion, cocoa will just drop pending posted
+ // events on the floor before we get a chance to reestablish a new session.
+ d->cancelWaitForMoreEvents();
+}
+
+QCocoaEventDispatcher::~QCocoaEventDispatcher()
+{
+ Q_D(QCocoaEventDispatcher);
+ //timer cleanup
+ MacTimerHash::iterator it = QCocoaEventDispatcherPrivate::macTimerHash.begin();
+ while (it != QCocoaEventDispatcherPrivate::macTimerHash.end()) {
+ MacTimerInfo *t = it.value();
+ if (t->runLoopTimer) {
+ CFRunLoopTimerInvalidate(t->runLoopTimer);
+ CFRelease(t->runLoopTimer);
+ }
+ delete t;
+ ++it;
+ }
+ QCocoaEventDispatcherPrivate::macTimerHash.clear();
+
+ // Remove CFSockets from the runloop.
+ for (MacSocketHash::ConstIterator it = d->macSockets.constBegin(); it != d->macSockets.constEnd(); ++it) {
+ MacSocketInfo *socketInfo = (*it);
+ if (CFSocketIsValid(socketInfo->socket)) {
+ qt_mac_remove_socket_from_runloop(socketInfo->socket, socketInfo->runloop);
+ CFRunLoopSourceInvalidate(socketInfo->runloop);
+ CFRelease(socketInfo->runloop);
+ CFSocketInvalidate(socketInfo->socket);
+ CFRelease(socketInfo->socket);
+ }
+ }
+ CFRunLoopRemoveSource(mainRunLoop(), d->postedEventsSource, kCFRunLoopCommonModes);
+ CFRelease(d->postedEventsSource);
+
+ CFRunLoopObserverInvalidate(d->waitingObserver);
+ CFRelease(d->waitingObserver);
+
+ CFRunLoopObserverInvalidate(d->firstTimeObserver);
+ CFRelease(d->firstTimeObserver);
+}
+
+QtCocoaInterruptDispatcher* QtCocoaInterruptDispatcher::instance = 0;
+
+QtCocoaInterruptDispatcher::QtCocoaInterruptDispatcher() : cancelled(false)
+{
+ // The whole point of this class is that we enable a way to interrupt
+ // the event dispatcher when returning back to a lower recursion level
+ // than where interruptLater was called. This is needed to detect if
+ // [NSApp run] should still be running at the recursion level it is at.
+ // Since the interrupt is canceled if processEvents is called before
+ // this object gets deleted, we also avoid interrupting unnecessary.
+ deleteLater();
+}
+
+QtCocoaInterruptDispatcher::~QtCocoaInterruptDispatcher()
+{
+ if (cancelled)
+ return;
+ instance = 0;
+ QCocoaEventDispatcher::instance()->interrupt();
+}
+
+void QtCocoaInterruptDispatcher::cancelInterruptLater()
+{
+ if (!instance)
+ return;
+ instance->cancelled = true;
+ delete instance;
+ instance = 0;
+}
+
+void QtCocoaInterruptDispatcher::interruptLater()
+{
+ cancelInterruptLater();
+ instance = new QtCocoaInterruptDispatcher;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
deleted file mode 100644
index ac0b75e9ea..0000000000
--- a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcocoaeventloopintegration.h"
-
-#import <Cocoa/Cocoa.h>
-
-#include "qcocoaautoreleasepool.h"
-
-#include <QtCore/QElapsedTimer>
-
-#include <QDebug>
-#include <QApplication>
-
-void wakeupCallback ( void * ) {
- QPlatformEventLoopIntegration::processEvents();
-}
-
-void timerCallback( CFRunLoopTimerRef timer, void *info)
-{
- QPlatformEventLoopIntegration::processEvents();
- QCocoaEventLoopIntegration *eventLoopIntegration =
- static_cast<QCocoaEventLoopIntegration *>(info);
- qint64 nextTime = eventLoopIntegration->nextTimerEvent();
- CFAbsoluteTime nexttime = CFAbsoluteTimeGetCurrent();
- nexttime = nexttime + (double(nextTime)/1000);
- CFRunLoopTimerSetNextFireDate(timer,nexttime);
-}
-
-QCocoaEventLoopIntegration::QCocoaEventLoopIntegration() :
- QPlatformEventLoopIntegration()
-{
- [NSApplication sharedApplication];
- m_sourceContext.version = 0;
- m_sourceContext.info = this;
- m_sourceContext.retain = 0;
- m_sourceContext.release = 0;
- m_sourceContext.copyDescription = 0;
- m_sourceContext.equal = 0;
- m_sourceContext.hash = 0;
- m_sourceContext.schedule = 0;
- m_sourceContext.cancel = 0;
- m_sourceContext.perform = wakeupCallback;
-
- m_source = CFRunLoopSourceCreate(0,0,&m_sourceContext);
- CFRunLoopAddSource(CFRunLoopGetMain(),m_source,kCFRunLoopCommonModes);
-
- m_timerContext.version = 0;
- m_timerContext.info = this;
- m_timerContext.retain = 0;
- m_timerContext.release = 0;
- m_timerContext.copyDescription = 0;
- CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent ();
- CFTimeInterval interval = 30;
-
- CFRunLoopTimerRef m_timerSource = CFRunLoopTimerCreate(0,fireDate,interval,0,0,timerCallback,&m_timerContext);
- CFRunLoopAddTimer(CFRunLoopGetMain(),m_timerSource,kCFRunLoopCommonModes);
-}
-
-void QCocoaEventLoopIntegration::startEventLoop()
-{
- [[NSApplication sharedApplication] run];
-}
-
-void QCocoaEventLoopIntegration::quitEventLoop()
-{
- [[NSApplication sharedApplication] terminate:nil];
-}
-
-void QCocoaEventLoopIntegration::qtNeedsToProcessEvents()
-{
- CFRunLoopSourceSignal(m_source);
-}
-
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
new file mode 100644
index 0000000000..9af931bf6c
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -0,0 +1,42 @@
+#ifndef QCOCOAGLCONTEXT_H
+#define QCOCOAGLCONTEXT_H
+
+#include <QtCore/QWeakPointer>
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QGuiGLContext>
+#include <QtGui/QWindow>
+
+#include <Cocoa/Cocoa.h>
+
+QT_BEGIN_NAMESPACE
+
+class QCocoaGLContext : public QPlatformGLContext
+{
+public:
+ QCocoaGLContext(const QSurfaceFormat &format, QPlatformGLContext *share);
+
+ QSurfaceFormat format() const;
+
+ void swapBuffers(QPlatformSurface *surface);
+
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
+
+ void (*getProcAddress(const QByteArray &procName)) ();
+
+ void update();
+
+ static NSOpenGLPixelFormat *createNSOpenGLPixelFormat();
+ NSOpenGLContext *nsOpenGLContext() const;
+
+private:
+ void setActiveWindow(QWindow *window);
+
+ NSOpenGLContext *m_context;
+ QSurfaceFormat m_format;
+ QWeakPointer<QWindow> m_currentWindow;
+};
+
+QT_END_NAMESPACE
+
+#endif // QCOCOAGLCONTEXT_H
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
new file mode 100644
index 0000000000..c3ff18f980
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -0,0 +1,90 @@
+#include "qcocoaglcontext.h"
+#include "qcocoawindow.h"
+#include <qdebug.h>
+#include <QtCore/private/qcore_mac_p.h>
+#include <QtPlatformSupport/private/cglconvenience_p.h>
+
+#import <Cocoa/Cocoa.h>
+
+QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformGLContext *share)
+ : m_format(format)
+{
+ NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat());
+ NSOpenGLContext *actualShare = share ? static_cast<QCocoaGLContext *>(share)->m_context : 0;
+
+ m_context = [NSOpenGLContext alloc];
+ [m_context initWithFormat:pixelFormat shareContext:actualShare];
+}
+
+// Match up with createNSOpenGLPixelFormat!
+QSurfaceFormat QCocoaGLContext::format() const
+{
+ return m_format;
+}
+
+void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
+{
+ QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
+ setActiveWindow(window);
+
+ [m_context flushBuffer];
+}
+
+bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
+{
+ QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
+ setActiveWindow(window);
+
+ [m_context makeCurrentContext];
+ return true;
+}
+
+void QCocoaGLContext::setActiveWindow(QWindow *window)
+{
+ if (window == m_currentWindow.data())
+ return;
+
+ if (m_currentWindow)
+ static_cast<QCocoaWindow *>(m_currentWindow.data()->handle())->setCurrentContext(0);
+
+ Q_ASSERT(window->handle());
+
+ m_currentWindow = window;
+
+ QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
+ cocoaWindow->setCurrentContext(this);
+
+ NSView *view = cocoaWindow->windowSurfaceView();
+ [m_context setView:view];
+}
+
+void QCocoaGLContext::doneCurrent()
+{
+ if (m_currentWindow)
+ static_cast<QCocoaWindow *>(m_currentWindow.data()->handle())->setCurrentContext(0);
+
+ m_currentWindow.clear();
+
+ [NSOpenGLContext clearCurrentContext];
+}
+
+void (*QCocoaGLContext::getProcAddress(const QByteArray &procName))()
+{
+ return qcgl_getProcAddress(procName);
+}
+
+void QCocoaGLContext::update()
+{
+ [m_context update];
+}
+
+NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat()
+{
+ return static_cast<NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat());
+}
+
+NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const
+{
+ return m_context;
+}
+
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 120bee46b7..031d4056fb 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -77,15 +77,16 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *widget) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const { return mScreens; }
QPlatformFontDatabase *fontDatabase() const;
- QPlatformEventLoopIntegration *createEventLoopIntegration() const;
-
+ QPlatformNativeInterface *nativeInterface() const;
private:
QList<QPlatformScreen *> mScreens;
QPlatformFontDatabase *mFontDb;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 086f7b62e9..4d01aa0a80 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -42,13 +42,11 @@
#include "qcocoaintegration.h"
#include "qcocoawindow.h"
-#include "qcocoawindowsurface.h"
-#include "qcocoaeventloopintegration.h"
-
-#include "qcoretextfontdatabase.h"
-
-#include <QtGui/QApplication>
+#include "qcocoabackingstore.h"
+#include "qcocoanativeinterface.h"
+#include "qcocoaeventdispatcher.h"
+#include <QtPlatformSupport/private/qbasicunixfontdatabase_p.h>
#include <private/qpixmap_raster_p.h>
QT_BEGIN_NAMESPACE
@@ -74,7 +72,7 @@ QCocoaScreen::~QCocoaScreen()
}
QCocoaIntegration::QCocoaIntegration()
- : mFontDb(new QCoreTextFontDatabase())
+ : mFontDb(new QBasicUnixFontDatabase())
{
mPool = new QCocoaAutoReleasePool;
@@ -98,6 +96,7 @@ bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
{
switch (cap) {
case ThreadedPixmaps: return true;
+ case OpenGL : return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
@@ -109,15 +108,24 @@ QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) co
return new QRasterPixmapData(type);
}
-QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWindow *window) const
+{
+ return new QCocoaWindow(window);
+}
+
+QPlatformGLContext *QCocoaIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
- Q_UNUSED(winId);
- return new QCocoaWindow(widget);
+ return new QCocoaGLContext(glFormat, share);
}
-QWindowSurface *QCocoaIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QCocoaWindowSurface(widget,winId);
+ return new QCocoaBackingStore(window);
+}
+
+QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const
+{
+ return new QCocoaEventDispatcher();
}
QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const
@@ -125,8 +133,9 @@ QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const
return mFontDb;
}
-QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() const
+QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const
{
- return new QCocoaEventLoopIntegration();
+ return new QCocoaNativeInterface();
}
+
QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index 10fa61c972..f8216d8e61 100644
--- a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -39,17 +39,17 @@
**
****************************************************************************/
-#ifndef MRASTERPIXMAPDATA_H
-#define MRASTERPIXMAPDATA_H
+#ifndef QCOCOANATIVEINTERFACE_H
+#define QCOCOANATIVEINTERFACE_H
-#include <private/qpixmap_raster_p.h>
+#include <QtGui/QPlatformNativeInterface>
-class QMeeGoRasterPixmapData : public QRasterPixmapData
+class QWidget;
+
+class QCocoaNativeInterface : public QPlatformNativeInterface
{
public:
- QMeeGoRasterPixmapData();
- QMeeGoRasterPixmapData(QPixmapData::PixelType t);
- void copy(const QPixmapData *data, const QRect &rect);
+ void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
};
-#endif
+#endif // QCOCOANATIVEINTERFACE_H
diff --git a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 3d6545e017..28e3af19b6 100644
--- a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -39,22 +39,21 @@
**
****************************************************************************/
-#include "qmeegorasterpixmapdata.h"
+#include "qcocoanativeinterface.h"
+#include "qcocoaglcontext.h"
+#include "qcocoawindow.h"
+#include <qbytearray.h>
+#include <qwindow.h>
+#include "qplatformwindow_qpa.h"
+#include "qsurfaceformat.h"
+#include "qplatformglcontext_qpa.h"
+#include "qguiglcontext_qpa.h"
+#include <qdebug.h>
-/* Public */
-
-QMeeGoRasterPixmapData::QMeeGoRasterPixmapData() : QRasterPixmapData(QPixmapData::PixmapType)
-{
-}
-
-QMeeGoRasterPixmapData::QMeeGoRasterPixmapData(QPixmapData::PixelType t) : QRasterPixmapData(t)
-{
-}
-
-void QMeeGoRasterPixmapData::copy(const QPixmapData *data, const QRect &rect)
+void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
- if (data->classId() == QPixmapData::OpenGLClass)
- fromImage(data->toImage(rect).copy(), Qt::NoOpaqueDetection);
- else
- QRasterPixmapData::copy(data, rect);
+ if (resourceString == "nsopenglcontext") {
+ return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
+ }
+ return 0;
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 9e7e68b7d2..dc7907d5ab 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -46,27 +46,44 @@
#include <QPlatformWindow>
+#include "qcocoaglcontext.h"
+#include "qnsview.h"
+
QT_BEGIN_NAMESPACE
class QCocoaWindow : public QPlatformWindow
{
public:
- QCocoaWindow(QWidget *tlw);
+ QCocoaWindow(QWindow *tlw);
~QCocoaWindow();
void setGeometry(const QRect &rect);
-
void setVisible(bool visible);
+ void setWindowTitle(const QString &title);
+ void raise();
+ void lower();
WId winId() const;
-
NSView *contentView() const;
- void setContentView(NSView *contentView);
+ NSView *windowSurfaceView() const;
+ void windowDidMove();
void windowDidResize();
+ void setCurrentContext(QCocoaGLContext *context);
+ QCocoaGLContext *currentContext() const;
+
+protected:
+ void determineWindowClass();
+ NSWindow *createWindow();
private:
+ friend class QCocoaBackingStore;
NSWindow *m_nsWindow;
+ QNSView *m_contentView;
+ NSView *m_windowSurfaceView;
+ quint32 m_windowAttributes;
+ quint32 m_windowClass;
+ QCocoaGLContext *m_glContext;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index a2fdce3520..550c429179 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -41,36 +41,50 @@
#include "qcocoawindow.h"
#include "qnswindowdelegate.h"
#include "qcocoaautoreleasepool.h"
-
-#include <QWidget>
-
-#include <QtGui/QApplication>
-
+#include "qcocoaglcontext.h"
+#include "qnsview.h"
+#include <QtCore/private/qcore_mac_p.h>
+#include <qwindow.h>
#include <QWindowSystemInterface>
+#include <Cocoa/Cocoa.h>
+#include <Carbon/Carbon.h>
+
#include <QDebug>
-QCocoaWindow::QCocoaWindow(QWidget *tlw)
+QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
+ , m_glContext(0)
{
QCocoaAutoReleasePool pool;
- const QRect geo = tlw->geometry();
- NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
- m_nsWindow = [[NSWindow alloc] initWithContentRect:frame
- styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
- backing:NSBackingStoreBuffered
- defer:YES];
+ determineWindowClass();
+ m_nsWindow = createWindow();
QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
[m_nsWindow setDelegate:delegate];
- [m_nsWindow makeKeyAndOrderFront:nil];
[m_nsWindow setAcceptsMouseMovedEvents:YES];
+
+ m_contentView = [[QNSView alloc] initWithQWindow:tlw];
+
+ if (tlw->surfaceType() == QWindow::OpenGLSurface) {
+ const QRect geo = window()->geometry();
+ NSRect glFrame = NSMakeRect(0, 0, geo.width(), geo.height());
+ m_windowSurfaceView = [[NSOpenGLView alloc] initWithFrame : glFrame pixelFormat : QCocoaGLContext::createNSOpenGLPixelFormat() ];
+ [m_contentView setAutoresizesSubviews : YES];
+ [m_windowSurfaceView setAutoresizingMask : (NSViewWidthSizable | NSViewHeightSizable)];
+ [m_contentView addSubview : m_windowSurfaceView];
+ } else {
+ m_windowSurfaceView = m_contentView;
+ }
+
+ [m_nsWindow setContentView:m_contentView];
}
QCocoaWindow::~QCocoaWindow()
{
+
}
void QCocoaWindow::setGeometry(const QRect &rect)
@@ -79,16 +93,42 @@ void QCocoaWindow::setGeometry(const QRect &rect)
NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
[[m_nsWindow contentView]setFrameSize:bounds.size];
+
+ if (m_glContext)
+ m_glContext->update();
}
void QCocoaWindow::setVisible(bool visible)
{
- Q_UNUSED(visible);
+ if (visible) {
+ [m_nsWindow makeKeyAndOrderFront:nil];
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
+ } else {
+ [m_nsWindow orderOut:nil];
+ }
+}
+
+void QCocoaWindow::setWindowTitle(const QString &title)
+{
+ CFStringRef windowTitle = QCFString::toCFStringRef(title);
+ [m_nsWindow setTitle: reinterpret_cast<const NSString *>(windowTitle)];
+ CFRelease(windowTitle);
+}
+
+void QCocoaWindow::raise()
+{
+ // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm)
+ [m_nsWindow orderFront: m_nsWindow];
+}
+
+void QCocoaWindow::lower()
+{
+ [m_nsWindow orderFront: m_nsWindow];
}
WId QCocoaWindow::winId() const
{
- return WId([m_nsWindow windowNumber]);
+ return WId(m_nsWindow);
}
NSView *QCocoaWindow::contentView() const
@@ -96,9 +136,15 @@ NSView *QCocoaWindow::contentView() const
return [m_nsWindow contentView];
}
-void QCocoaWindow::setContentView(NSView *contentView)
+NSView *QCocoaWindow::windowSurfaceView() const
+{
+ return m_windowSurfaceView;
+}
+
+void QCocoaWindow::windowDidMove()
{
- [m_nsWindow setContentView:contentView];
+ if (m_glContext)
+ m_glContext->update();
}
void QCocoaWindow::windowDidResize()
@@ -106,5 +152,182 @@ void QCocoaWindow::windowDidResize()
//jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing...
NSRect rect = [[m_nsWindow contentView]frame];
QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
- QWindowSystemInterface::handleGeometryChange(widget(),geo);
+ QWindowSystemInterface::handleGeometryChange(window(),geo);
+
+ if (m_glContext)
+ m_glContext->update();
+}
+
+void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
+{
+ m_glContext = context;
}
+
+QCocoaGLContext *QCocoaWindow::currentContext() const
+{
+ return m_glContext;
+}
+
+/*
+ Determine the window class based on the window type and
+ window flags, and widget attr Sets m_windowAttributes
+ and m_windowClass.
+*/
+void QCocoaWindow::determineWindowClass()
+{
+ Qt::WindowType type = window()->windowType();
+ Qt::WindowFlags flags = window()->windowFlags();
+
+ const bool popup = (type == Qt::Popup);
+
+ if (type == Qt::ToolTip || type == Qt::SplashScreen || popup)
+ flags |= Qt::FramelessWindowHint;
+
+ m_windowClass = kSheetWindowClass;
+
+ if (popup || type == Qt::SplashScreen)
+ m_windowClass = kModalWindowClass;
+ else if (type == Qt::ToolTip)
+ m_windowClass = kHelpWindowClass;
+ else if (type == Qt::Tool)
+ m_windowClass = kFloatingWindowClass;
+ else
+ m_windowClass = kDocumentWindowClass;
+
+ m_windowAttributes = (kWindowCompositingAttribute | kWindowStandardHandlerAttribute);
+
+// if(qt_mac_is_macsheet(window())) {
+// m_windowClass = kSheetWindowClass;
+// } else
+
+ {
+ // Shift things around a bit to get the correct window class based on the presence
+ // (or lack) of the border.
+
+ bool customize = flags & Qt::CustomizeWindowHint;
+ bool framelessWindow = (flags & Qt::FramelessWindowHint || (customize && !(flags & Qt::WindowTitleHint)));
+ if (framelessWindow) {
+ if (m_windowClass == kDocumentWindowClass) {
+ m_windowAttributes |= kWindowNoTitleBarAttribute;
+ } else if (m_windowClass == kFloatingWindowClass) {
+ m_windowAttributes |= kWindowNoTitleBarAttribute;
+ } else if (m_windowClass == kMovableModalWindowClass) {
+ m_windowClass = kModalWindowClass;
+ }
+ } else {
+ m_windowAttributes |= NSTitledWindowMask;
+ if (m_windowClass != kModalWindowClass)
+ m_windowAttributes |= NSResizableWindowMask;
+ }
+
+ // Only add extra decorations (well, buttons) for widgets that can have them
+ // and have an actual border we can put them on.
+
+ if(m_windowClass != kModalWindowClass && m_windowClass != kMovableModalWindowClass
+ && m_windowClass != kSheetWindowClass && m_windowClass != kPlainWindowClass
+ && !framelessWindow && m_windowClass != kDrawerWindowClass
+ && m_windowClass != kHelpWindowClass) {
+ if (flags & Qt::WindowMinimizeButtonHint)
+ m_windowAttributes |= NSMiniaturizableWindowMask;
+ if (flags & Qt::WindowSystemMenuHint || flags & Qt::WindowCloseButtonHint)
+ m_windowAttributes |= NSClosableWindowMask;
+ } else {
+ // Clear these hints so that we aren't call them on invalid windows
+ flags &= ~(Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint
+ | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint);
+ }
+
+ }
+
+ if((popup || type == Qt::Tool) && !window()->isModal())
+ m_windowAttributes |= kWindowHideOnSuspendAttribute;
+ m_windowAttributes |= kWindowLiveResizeAttribute;
+}
+
+/*
+
+*/
+NSWindow * QCocoaWindow::createWindow()
+{
+ // Determine if we need to add in our "custom window" attribute. Cocoa is rather clever
+ // in deciding if we need the maximize button or not (i.e., it's resizeable, so you
+ // must need a maximize button). So, the only buttons we have control over are the
+ // close and minimize buttons. If someone wants to customize and NOT have the maximize
+ // button, then we have to do our hack. We only do it for these cases because otherwise
+ // the window looks different when activated. This "QtMacCustomizeWindow" attribute is
+ // intruding on a public space and WILL BREAK in the future.
+ // One can hope that there is a more public API available by that time.
+/*
+ Qt::WindowFlags flags = widget ? widget->windowFlags() : Qt::WindowFlags(0);
+ if ((flags & Qt::CustomizeWindowHint)) {
+ if ((flags & (Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint
+ | Qt::WindowMinimizeButtonHint | Qt::WindowTitleHint))
+ && !(flags & Qt::WindowMaximizeButtonHint))
+ wattr |= QtMacCustomizeWindow;
+ }
+*/
+ // If we haven't created the desktop widget, you have to pass the rectangle
+ // in "cocoa coordinates" (i.e., top points to the lower left coordinate).
+ // Otherwise, we do the conversion for you. Since we are the only ones that
+ // create the desktop widget, this is OK (but confusing).
+/*
+ NSRect geo = NSMakeRect(crect.left(),
+ (qt_root_win != 0) ? flipYCoordinate(crect.bottom() + 1) : crect.top(),
+ crect.width(), crect.height());
+*/
+ QRect geo = window()->geometry();
+ NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
+
+ QCocoaAutoReleasePool pool;
+ NSWindow *window;
+
+ switch (m_windowClass) {
+ case kMovableModalWindowClass:
+ case kModalWindowClass:
+ case kSheetWindowClass:
+ case kFloatingWindowClass:
+ case kOverlayWindowClass:
+ case kHelpWindowClass: {
+ NSPanel *panel;
+
+ BOOL needFloating = NO;
+ BOOL worksWhenModal = (this->window()->windowType() == Qt::Popup);
+
+ // Add in the extra flags if necessary.
+ switch (m_windowClass) {
+ case kSheetWindowClass:
+ m_windowAttributes |= NSDocModalWindowMask;
+ break;
+ case kFloatingWindowClass:
+ case kHelpWindowClass:
+ needFloating = YES;
+ m_windowAttributes |= NSUtilityWindowMask;
+ break;
+ default:
+ break;
+ }
+
+ panel = [[NSPanel alloc] initWithContentRect:frame
+ styleMask:m_windowAttributes
+ backing:NSBackingStoreBuffered
+ defer:YES];
+// ### crashes
+// [panel setFloatingPanel:needFloating];
+// [panel setWorksWhenModal:worksWhenModal];
+ window = panel;
+ break;
+ }
+
+ default:
+ m_nsWindow = [[NSWindow alloc] initWithContentRect:frame
+ styleMask:m_windowAttributes
+ backing:NSBackingStoreBuffered
+ defer:YES];
+ break;
+ }
+
+ //qt_syncCocoaTitleBarButtons(window, widget);
+ return window;
+}
+
+
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 69a11134bd..0b96928d5b 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -48,17 +48,18 @@
@interface QNSView : NSView {
CGImageRef m_cgImage;
- QWidget *m_widget;
+ QWindow *m_window;
Qt::MouseButtons m_buttons;
}
- (id)init;
-- (id)initWithWidget:(QWidget *)widget;
+- (id)initWithQWindow:(QWindow *)window;
- (void)setImage:(QImage *)image;
- (void)drawRect:(NSRect)dirtyRect;
- (BOOL)isFlipped;
+- (BOOL)acceptsFirstResponder;
- (void)handleMouseEvent:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
@@ -74,6 +75,12 @@
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
+- (int) convertKeyCode : (QChar)keyCode;
+- (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags;
+- (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType;
+- (void)keyDown:(NSEvent *)theEvent;
+- (void)keyUp:(NSEvent *)theEvent;
+
@end
#endif //QNSVIEW_H
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 037cbdb5d6..b2a3d73d48 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -39,12 +39,18 @@
**
****************************************************************************/
-#include "qnsview.h"
+#include <Carbon/Carbon.h>
+#include "qnsview.h"
#include <QtGui/QWindowSystemInterface>
-
#include <QtCore/QDebug>
+@interface NSEvent (Qt_Compile_Leopard_DeviceDelta)
+ - (CGFloat)deviceDeltaX;
+ - (CGFloat)deviceDeltaY;
+ - (CGFloat)deviceDeltaZ;
+@end
+
@implementation QNSView
- (id) init
@@ -52,16 +58,16 @@
self = [super init];
if (self) {
m_cgImage = 0;
- m_widget = 0;
+ m_window = 0;
m_buttons = Qt::NoButton;
}
return self;
}
-- (id)initWithWidget:(QWidget *)widget {
+- (id)initWithQWindow:(QWindow *)widget {
self = [self init];
if (self) {
- m_widget = widget;
+ m_window = widget;
}
return self;
}
@@ -91,7 +97,7 @@
bitDepth,
bytesPrLine,
cgColourSpaceRef,
- kCGImageAlphaNone,
+ kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
cgDataProviderRef,
NULL,
false,
@@ -130,82 +136,222 @@
return YES;
}
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
- (void)handleMouseEvent:(NSEvent *)theEvent;
{
- NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil];
- QPoint qt_localPoint(point.x,point.y);
+ NSPoint windowPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil];
+ QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
NSTimeInterval timestamp = [theEvent timestamp];
ulong qt_timestamp = timestamp * 1000;
- QWindowSystemInterface::handleMouseEvent(m_widget,qt_timestamp,qt_localPoint,QPoint(),m_buttons);
+ // ### Should the points be windowPoint and screenPoint?
+ QWindowSystemInterface::handleMouseEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, m_buttons);
+}
+- (void)mouseDown:(NSEvent *)theEvent
+{
+ m_buttons |= Qt::LeftButton;
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)mouseDragged:(NSEvent *)theEvent
+{
+ if (!(m_buttons & Qt::LeftButton))
+ qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)mouseUp:(NSEvent *)theEvent
+{
+ m_buttons &= QFlag(~int(Qt::LeftButton));
+ [self handleMouseEvent:theEvent];
}
- - (void)mouseDown:(NSEvent *)theEvent
- {
- m_buttons |= Qt::LeftButton;
- [self handleMouseEvent:theEvent];
- }
- - (void)mouseDragged:(NSEvent *)theEvent
- {
- if (!(m_buttons & Qt::LeftButton))
- qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
- [self handleMouseEvent:theEvent];
- }
- - (void)mouseUp:(NSEvent *)theEvent
- {
- m_buttons &= QFlag(~int(Qt::LeftButton));
- [self handleMouseEvent:theEvent];
- }
- (void)mouseMoved:(NSEvent *)theEvent
{
- qDebug() << "mouseMove";
[self handleMouseEvent:theEvent];
}
+
- (void)mouseEntered:(NSEvent *)theEvent
{
- Q_UNUSED(theEvent);
- QWindowSystemInterface::handleEnterEvent(m_widget);
+ Q_UNUSED(theEvent);
+ QWindowSystemInterface::handleEnterEvent(m_window);
}
+
- (void)mouseExited:(NSEvent *)theEvent
{
- Q_UNUSED(theEvent);
- QWindowSystemInterface::handleLeaveEvent(m_widget);
+ Q_UNUSED(theEvent);
+ QWindowSystemInterface::handleLeaveEvent(m_window);
}
+
- (void)rightMouseDown:(NSEvent *)theEvent
{
- m_buttons |= Qt::RightButton;
+ m_buttons |= Qt::RightButton;
[self handleMouseEvent:theEvent];
}
+
- (void)rightMouseDragged:(NSEvent *)theEvent
{
- if (!(m_buttons & Qt::LeftButton))
- qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
- [self handleMouseEvent:theEvent];
+ if (!(m_buttons & Qt::LeftButton))
+ qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ [self handleMouseEvent:theEvent];
}
+
- (void)rightMouseUp:(NSEvent *)theEvent
{
- m_buttons &= QFlag(~int(Qt::RightButton));
- [self handleMouseEvent:theEvent];
+ m_buttons &= QFlag(~int(Qt::RightButton));
+ [self handleMouseEvent:theEvent];
}
+
- (void)otherMouseDown:(NSEvent *)theEvent
{
- m_buttons |= Qt::RightButton;
+ m_buttons |= Qt::RightButton;
[self handleMouseEvent:theEvent];
}
+
- (void)otherMouseDragged:(NSEvent *)theEvent
{
- if (!(m_buttons & Qt::LeftButton))
- qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
- [self handleMouseEvent:theEvent];
+ if (!(m_buttons & Qt::LeftButton))
+ qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ [self handleMouseEvent:theEvent];
}
+
- (void)otherMouseUp:(NSEvent *)theEvent
{
- m_buttons &= QFlag(~int(Qt::MiddleButton));
- [self handleMouseEvent:theEvent];
+ m_buttons &= QFlag(~int(Qt::MiddleButton));
+ [self handleMouseEvent:theEvent];
}
+#ifndef QT_NO_WHEELEVENT
+- (void)scrollWheel:(NSEvent *)theEvent
+{
+ int deltaX = 0;
+ int deltaY = 0;
+ int deltaZ = 0;
+
+ const EventRef carbonEvent = (EventRef)[theEvent eventRef];
+ const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
+ const bool scrollEvent = carbonEventKind == kEventMouseScroll;
+
+ if (scrollEvent) {
+ // The mouse device containts 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.
+ // It looks like 1/4 degrees per pixel behaves most native.
+ // (NB: Qt expects the unit for delta to be 8 per degree):
+ const int pixelsToDegrees = 2; // 8 * 1/4
+ deltaX = [theEvent deviceDeltaX] * pixelsToDegrees;
+ deltaY = [theEvent deviceDeltaY] * pixelsToDegrees;
+ deltaZ = [theEvent deviceDeltaZ] * pixelsToDegrees;
+ } else {
+ // carbonEventKind == kEventMouseWheelMoved
+ // Remove acceleration, and use either -120 or 120 as delta:
+ deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120);
+ deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120);
+ deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120);
+ }
+
+ NSPoint windowPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil];
+ QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
+ NSTimeInterval timestamp = [theEvent timestamp];
+ ulong qt_timestamp = timestamp * 1000;
+
+ if (deltaX != 0)
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaX, Qt::Horizontal);
+
+ if (deltaY != 0)
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaY, Qt::Vertical);
+
+ if (deltaZ != 0)
+ // Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to
+ // try to be ahead of the pack, I'm adding this extra value.
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaY, (Qt::Orientation)3);
+}
+#endif //QT_NO_WHEELEVENT
+
+- (int) convertKeyCode : (QChar)keyChar
+{
+ if (keyChar.isLower())
+ keyChar = keyChar.toUpper();
+ int keyCode = keyChar.unicode();
+
+ int qtKeyCode = Qt::Key(keyCode); // default case, overrides below
+ switch (keyCode) {
+ case NSEnterCharacter: qtKeyCode = Qt::Key_Enter; break;
+ case NSBackspaceCharacter: qtKeyCode = Qt::Key_Backspace; break;
+ case NSTabCharacter: qtKeyCode = Qt::Key_Tab; break;
+ case NSNewlineCharacter: qtKeyCode = Qt::Key_Return; break;
+ case NSCarriageReturnCharacter: qtKeyCode = Qt::Key_Return; break;
+ case NSBackTabCharacter: qtKeyCode = Qt::Key_Backtab; break;
+ case 27 : qtKeyCode = Qt::Key_Escape; break;
+ case NSDeleteCharacter : qtKeyCode = Qt::Key_Backspace; break; // Cocoa sends us delete when pressing backspace.
+ case NSUpArrowFunctionKey: qtKeyCode = Qt::Key_Up; break;
+ case NSDownArrowFunctionKey: qtKeyCode = Qt::Key_Down; break;
+ case NSLeftArrowFunctionKey: qtKeyCode = Qt::Key_Left; break;
+ case NSRightArrowFunctionKey: qtKeyCode = Qt::Key_Right; break;
+ case NSInsertFunctionKey: qtKeyCode = Qt::Key_Insert; break;
+ case NSDeleteFunctionKey: qtKeyCode = Qt::Key_Delete; break;
+ case NSHomeFunctionKey: qtKeyCode = Qt::Key_Home; break;
+ case NSEndFunctionKey: qtKeyCode = Qt::Key_End; break;
+ case NSPageUpFunctionKey: qtKeyCode = Qt::Key_PageUp; break;
+ case NSPageDownFunctionKey: qtKeyCode = Qt::Key_PageDown; break;
+ case NSPrintScreenFunctionKey: qtKeyCode = Qt::Key_Print; break;
+ case NSScrollLockFunctionKey: qtKeyCode = Qt::Key_ScrollLock; break;
+ case NSPauseFunctionKey: qtKeyCode = Qt::Key_Pause; break;
+ case NSSysReqFunctionKey: qtKeyCode = Qt::Key_SysReq; break;
+ case NSMenuFunctionKey: qtKeyCode = Qt::Key_Menu; break;
+ case NSHelpFunctionKey: qtKeyCode = Qt::Key_Help; break;
+ default : break;
+ }
+
+ // handle all function keys (F1-F35)
+ if (keyCode >= NSF1FunctionKey && keyCode <= NSF35FunctionKey)
+ qtKeyCode = Qt::Key_F1 + (keyCode - NSF1FunctionKey);
+ return qtKeyCode;
+}
+
+- (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags
+{
+ Qt::KeyboardModifiers qtMods =Qt::NoModifier;
+ if (modifierFlags & NSShiftKeyMask)
+ qtMods |= Qt::ShiftModifier;
+ if (modifierFlags & NSControlKeyMask)
+ qtMods |= Qt::MetaModifier;
+ if (modifierFlags & NSAlternateKeyMask)
+ qtMods |= Qt::AltModifier;
+ if (modifierFlags & NSCommandKeyMask)
+ qtMods |= Qt::ControlModifier;
+ if (modifierFlags & NSNumericPadKeyMask)
+ qtMods |= Qt::KeypadModifier;
+ return qtMods;
+}
+
+- (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType
+{
+ NSTimeInterval timestamp = [theEvent timestamp];
+ ulong qt_timestamp = timestamp * 1000;
+ QString characters = QString::fromUtf8([[theEvent characters] UTF8String]);
+ Qt::KeyboardModifiers modifiers = [self convertKeyModifiers : [theEvent modifierFlags]];
+ QChar ch([[theEvent charactersIgnoringModifiers] characterAtIndex:0]);
+ int keyCode = [self convertKeyCode : ch];
+
+ QWindowSystemInterface::handleKeyEvent(m_window, qt_timestamp, QEvent::Type(eventType), keyCode, modifiers, characters);
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ [self handleKeyEvent : theEvent eventType :int(QEvent::KeyPress)];
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ [self handleKeyEvent : theEvent eventType :int(QEvent::KeyRelease)];
+}
@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index cf296c4a8b..5cd226a71d 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -46,6 +46,26 @@
#include "qcocoawindow.h"
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
+@protocol NSWindowDelegate <NSObject>
+//- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
+//- (void)windowDidMiniaturize:(NSNotification*)notification;
+- (void)windowDidResize:(NSNotification *)notification;
+- (void)windowWillClose:(NSNotification *)notification;
+//- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame;
+- (void)windowDidMove:(NSNotification *)notification;
+//- (BOOL)windowShouldClose:(id)window;
+//- (void)windowDidDeminiaturize:(NSNotification *)notification;
+//- (void)windowDidBecomeMain:(NSNotification*)notification;
+//- (void)windowDidResignMain:(NSNotification*)notification;
+//- (void)windowDidBecomeKey:(NSNotification*)notification;
+//- (void)windowDidResignKey:(NSNotification*)notification;
+//- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu;
+//- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard;
+//- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
+@end
+#endif
+
@interface QNSWindowDelegate : NSObject <NSWindowDelegate>
{
QCocoaWindow *m_cocoaWindow;
@@ -54,6 +74,7 @@
- (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow;
- (void)windowDidResize:(NSNotification *)notification;
+- (void)windowDidMove:(NSNotification *)notification;
- (void)windowWillClose:(NSNotification *)notification;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index 887b08f6d2..6521db5cf7 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -64,10 +64,18 @@
}
}
+- (void)windowDidMove:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ if (m_cocoaWindow) {
+ m_cocoaWindow->windowDidMove();
+ }
+}
+
- (void)windowWillClose:(NSNotification *)notification
{
Q_UNUSED(notification);
- QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->widget());
+ QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->window());
}
@end
diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro
index f830177dcb..fb446f6166 100644
--- a/src/plugins/platforms/directfb/directfb.pro
+++ b/src/plugins/platforms/directfb/directfb.pro
@@ -2,6 +2,8 @@ TARGET = qdirectfb
load(qt_plugin)
DESTDIR = $$QT.gui.plugins/platforms
+QT += core-private gui-private platformsupport-private
+
isEmpty(DIRECTFB_LIBS) {
DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread
}
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
index 61f1d2513b..018a5d9e2d 100644
--- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
@@ -46,7 +46,8 @@
#include "qdirectfbcursor.h"
#include "qdirectfbwindow.h"
-#include "qgenericunixfontdatabase.h"
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <private/qwindowsurface_raster_p.h>
#include <private/qpixmap_raster_p.h>
@@ -55,6 +56,7 @@
#include <QtGui/private/qpixmapdata_p.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QThread>
+#include <QtCore/QAbstractEventDispatcher>
QT_BEGIN_NAMESPACE
@@ -131,6 +133,11 @@ QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId
return new QDirectFbWindow(widget,input);
}
+QAbstractEventDispatcher *QDirectFbIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId winId) const
{
return new QDirectFbWindowSurface(widget,winId);
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h
index 0e8337a5fb..8195ebd4b5 100644
--- a/src/plugins/platforms/directfb/qdirectfbintegration.h
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.h
@@ -51,6 +51,7 @@
QT_BEGIN_NAMESPACE
class QThread;
+class QAbstractEventDispatcher;
class QDirectFBCursor;
class QDirectFbScreen : public QPlatformScreen
@@ -87,6 +88,7 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const { return mScreens; }
diff --git a/src/plugins/platforms/eglconvenience/eglconvenience.pri b/src/plugins/platforms/eglconvenience/eglconvenience.pri
deleted file mode 100644
index 322d4e4633..0000000000
--- a/src/plugins/platforms/eglconvenience/eglconvenience.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-INCLUDEPATH += $$PWD
-
-SOURCES += \
- $$PWD/qeglconvenience.cpp
-
-HEADERS += \
- $$PWD/qeglconvenience.h
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
deleted file mode 100644
index 69747a87e8..0000000000
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglconvenience.h"
-
-QT_BEGIN_NAMESPACE
-
-QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format)
-{
- int redSize = format.redBufferSize();
- int greenSize = format.greenBufferSize();
- int blueSize = format.blueBufferSize();
- int alphaSize = format.alphaBufferSize();
- int depthSize = format.depthBufferSize();
- int stencilSize = format.stencilBufferSize();
- int sampleCount = format.samples();
-
- // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
- // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1:
- if (format.alpha() && alphaSize <= 0)
- alphaSize = 1;
- if (format.depth() && depthSize <= 0)
- depthSize = 1;
- if (format.stencil() && stencilSize <= 0)
- stencilSize = 1;
- if (format.sampleBuffers() && sampleCount <= 0)
- sampleCount = 1;
-
- // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
- // the best performance. The EGL config selection algorithm is a bit stange in this regard:
- // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
- // 32-bit configs completely from the selection. So it then comes to the sorting algorithm.
- // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort
- // order is special and described as "by larger _total_ number of color bits.". So EGL will
- // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on
- // to say "If the requested number of bits in attrib_list for a particular component is 0,
- // then the number of bits for that component is not considered". This part of the spec also
- // seems to imply that setting the red/green/blue bits to zero means none of the components
- // are considered and EGL disregards the entire sorting rule. It then looks to the next
- // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being
- // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
- // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
- // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
- // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat,
- // they will probably get a 32-bit config, even when there's an RGB565 config available.
-
- // Now normalize the values so -1 becomes 0
- redSize = redSize > 0 ? redSize : 0;
- greenSize = greenSize > 0 ? greenSize : 0;
- blueSize = blueSize > 0 ? blueSize : 0;
- alphaSize = alphaSize > 0 ? alphaSize : 0;
- depthSize = depthSize > 0 ? depthSize : 0;
- stencilSize = stencilSize > 0 ? stencilSize : 0;
- sampleCount = sampleCount > 0 ? sampleCount : 0;
-
- QVector<EGLint> configAttributes;
-
- configAttributes.append(EGL_RED_SIZE);
- configAttributes.append(redSize);
-
- configAttributes.append(EGL_GREEN_SIZE);
- configAttributes.append(greenSize);
-
- configAttributes.append(EGL_BLUE_SIZE);
- configAttributes.append(blueSize);
-
- configAttributes.append(EGL_ALPHA_SIZE);
- configAttributes.append(alphaSize);
-
- configAttributes.append(EGL_DEPTH_SIZE);
- configAttributes.append(depthSize);
-
- configAttributes.append(EGL_STENCIL_SIZE);
- configAttributes.append(stencilSize);
-
- configAttributes.append(EGL_SAMPLES);
- configAttributes.append(sampleCount);
-
- configAttributes.append(EGL_SAMPLE_BUFFERS);
- configAttributes.append(sampleCount? 1:0);
-
- return configAttributes;
-}
-
-bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes)
-{
- int i = -1;
- // Reduce the complexity of a configuration request to ask for less
- // because the previous request did not result in success. Returns
- // true if the complexity was reduced, or false if no further
- // reductions in complexity are possible.
-
- i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR);
- if (i >= 0) {
- configAttributes->remove(i,2);
- }
-
-#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
- // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't
- // find a config which supports pre-multiplied formats, remove the flag on the surface type:
-
- i = configAttributes->indexOf(EGL_SURFACE_TYPE);
- if (i >= 0) {
- EGLint surfaceType = configAttributes->at(i +1);
- if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) {
- surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT;
- configAttributes->replace(i+1,surfaceType);
- return true;
- }
- }
-#endif
-
- // EGL chooses configs with the highest color depth over
- // those with smaller (but faster) lower color depths. One
- // way around this is to set EGL_BUFFER_SIZE to 16, which
- // trumps the others. Of course, there may not be a 16-bit
- // config available, so it's the first restraint we remove.
- i = configAttributes->indexOf(EGL_BUFFER_SIZE);
- if (i >= 0) {
- if (configAttributes->at(i+1) == 16) {
- configAttributes->remove(i,2);
- return true;
- }
- }
-
- i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS);
- if (i >= 0) {
- configAttributes->remove(i,2);
- i = configAttributes->indexOf(EGL_SAMPLES);
- if (i >= 0) {
- configAttributes->remove(i,2);
- }
- return true;
- }
-
- i = configAttributes->indexOf(EGL_ALPHA_SIZE);
- if (i >= 0) {
- configAttributes->remove(i,2);
-#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB)
- i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA);
- if (i >= 0) {
- configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB);
- configAttributes->replace(i+1,TRUE);
-
- }
-#endif
- return true;
- }
-
- i = configAttributes->indexOf(EGL_STENCIL_SIZE);
- if (i >= 0) {
- configAttributes->remove(i,2);
- return true;
- }
- i = configAttributes->indexOf(EGL_DEPTH_SIZE);
- if (i >= 0) {
- configAttributes->remove(i,2);
- return true;
- }
-#ifdef EGL_BIND_TO_TEXTURE_RGB
- i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB);
- if (i >= 0) {
- configAttributes->remove(i,2);
- return true;
- }
-#endif
-
- return false;
-}
-
-EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
-{
- EGLConfig cfg = 0;
- QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
- configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now
- configureAttributes.append(surfaceType);
-
- configureAttributes.append(EGL_RENDERABLE_TYPE);
- if (format.windowApi() == QPlatformWindowFormat::OpenVG) {
- configureAttributes.append(EGL_OPENVG_BIT);
- } else {
- configureAttributes.append(EGL_OPENGL_ES2_BIT);
- }
- configureAttributes.append(EGL_NONE);
-
- do {
- // Get the number of matching configurations for this set of properties.
- EGLint matching = 0;
- if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching)
- continue;
-
- // If we want the best pixel format, then return the first
- // matching configuration.
- if (highestPixelFormat) {
- eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching);
- if (matching < 1)
- continue;
- return cfg;
- }
-
- // Fetch all of the matching configurations and find the
- // first that matches the pixel format we wanted.
- int i = configureAttributes.indexOf(EGL_RED_SIZE);
- int confAttrRed = configureAttributes.at(i+1);
- i = configureAttributes.indexOf(EGL_GREEN_SIZE);
- int confAttrGreen = configureAttributes.at(i+1);
- i = configureAttributes.indexOf(EGL_BLUE_SIZE);
- int confAttrBlue = configureAttributes.at(i+1);
- i = configureAttributes.indexOf(EGL_ALPHA_SIZE);
- int confAttrAlpha = configureAttributes.at(i+1);
-
- EGLint size = matching;
- EGLConfig *configs = new EGLConfig [size];
- eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching);
- for (EGLint index = 0; index < size; ++index) {
- EGLint red, green, blue, alpha;
- eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red);
- eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green);
- eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue);
- eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha);
- if (red == confAttrRed &&
- green == confAttrGreen &&
- blue == confAttrBlue &&
- (confAttrAlpha == 0 ||
- alpha == confAttrAlpha)) {
- cfg = configs[index];
- delete [] configs;
- return cfg;
- }
- }
- delete [] configs;
- } while (q_reduceConfigAttributes(&configureAttributes));
- qWarning("Cant find EGLConfig, returning null config");
- return 0;
-}
-
-QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
-{
- QPlatformWindowFormat format;
- EGLint redSize = 0;
- EGLint greenSize = 0;
- EGLint blueSize = 0;
- EGLint alphaSize = 0;
- EGLint depthSize = 0;
- EGLint stencilSize = 0;
- EGLint sampleCount = 0;
- EGLint level = 0;
-
- eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
- eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
- eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize);
- eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize);
- eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
- eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
- eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
- eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
-
- format.setRedBufferSize(redSize);
- format.setGreenBufferSize(greenSize);
- format.setBlueBufferSize(blueSize);
- format.setAlphaBufferSize(alphaSize);
- format.setDepthBufferSize(depthSize);
- format.setStencilBufferSize(stencilSize);
- format.setSamples(sampleCount);
- format.setDirectRendering(true); // All EGL contexts are direct-rendered
- format.setRgba(true); // EGL doesn't support colour index rendering
- format.setStereo(false); // EGL doesn't support stereo buffers
- format.setAccumBufferSize(0); // EGL doesn't support accululation buffers
-
- // Clear the EGL error state because some of the above may
- // have errored out because the attribute is not applicable
- // to the surface type. Such errors don't matter.
- eglGetError();
-
- return format;
-}
-
-bool q_hasEglExtension(EGLDisplay display, const char* extensionName)
-{
- QList<QByteArray> extensions =
- QByteArray(reinterpret_cast<const char *>
- (eglQueryString(display, EGL_EXTENSIONS))).split(' ');
- return extensions.contains(extensionName);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h
deleted file mode 100644
index da4a0cdded..0000000000
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLCONVENIENCE_H
-#define QEGLCONVENIENCE_H
-
-
-#include <QtGui/QPlatformWindowFormat>
-#include <QtCore/QVector>
-
-#include <EGL/egl.h>
-QT_BEGIN_NAMESPACE
-
-QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format);
-bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes);
-EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT);
-QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config);
-bool q_hasEglExtension(EGLDisplay display,const char* extensionName);
-
-QT_END_NAMESPACE
-
-#endif //QEGLCONVENIENCE_H
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
deleted file mode 100644
index 4d1d63e37f..0000000000
--- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglplatformcontext.h"
-
-
-#include <QtGui/QPlatformWindow>
-
-#include "qeglconvenience.h"
-
-#include <EGL/egl.h>
-
-QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi)
- : QPlatformGLContext()
- , m_eglDisplay(display)
- , m_eglSurface(surface)
- , m_eglApi(eglApi)
-{
- if (m_eglSurface == EGL_NO_SURFACE) {
- qWarning("Createing QEGLPlatformContext with no surface");
- }
-
- eglBindAPI(m_eglApi);
- m_eglContext = eglCreateContext(m_eglDisplay,config, 0,contextAttrs);
- if (m_eglContext == EGL_NO_CONTEXT) {
- qWarning("Could not create the egl context\n");
- eglTerminate(m_eglDisplay);
- qFatal("EGL error");
- }
-
- m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config);
-}
-
-QEGLPlatformContext::~QEGLPlatformContext()
-{
-#ifdef QEGL_EXTRA_DEBUG
- qWarning("QEglContext::~QEglContext(): %p\n",this);
-#endif
- if (m_eglSurface != EGL_NO_SURFACE) {
- doneCurrent();
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-
- if (m_eglContext != EGL_NO_CONTEXT) {
- eglDestroyContext(m_eglDisplay, m_eglContext);
- m_eglContext = EGL_NO_CONTEXT;
- }
-}
-
-void QEGLPlatformContext::makeCurrent()
-{
- QPlatformGLContext::makeCurrent();
-#ifdef QEGL_EXTRA_DEBUG
- qWarning("QEglContext::makeCurrent: %p\n",this);
-#endif
- eglBindAPI(m_eglApi);
- bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
- if (!ok)
- qWarning("QEGLPlatformContext::makeCurrent: eglError: %d, this: %p \n", eglGetError(), this);
-#ifdef QEGL_EXTRA_DEBUG
- static bool showDebug = true;
- if (showDebug) {
- showDebug = false;
- const char *str = (const char*)glGetString(GL_VENDOR);
- qWarning("Vendor %s\n", str);
- str = (const char*)glGetString(GL_RENDERER);
- qWarning("Renderer %s\n", str);
- str = (const char*)glGetString(GL_VERSION);
- qWarning("Version %s\n", str);
-
- str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
- qWarning("Extensions %s\n",str);
-
- str = (const char*)glGetString(GL_EXTENSIONS);
- qWarning("Extensions %s\n", str);
-
- }
-#endif
-}
-void QEGLPlatformContext::doneCurrent()
-{
- QPlatformGLContext::doneCurrent();
-#ifdef QEGL_EXTRA_DEBUG
- qWarning("QEglContext::doneCurrent:%p\n",this);
-#endif
- eglBindAPI(m_eglApi);
- bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- if (!ok)
- qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this);
-}
-void QEGLPlatformContext::swapBuffers()
-{
-#ifdef QEGL_EXTRA_DEBUG
- qWarning("QEglContext::swapBuffers:%p\n",this);
-#endif
- eglBindAPI(m_eglApi);
- bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface);
- if (!ok)
- qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this);
-}
-void* QEGLPlatformContext::getProcAddress(const QString& procName)
-{
-#ifdef QEGL_EXTRA_DEBUG
- qWarning("QEglContext::getProcAddress%p\n",this);
-#endif
- eglBindAPI(m_eglApi);
- return (void *)eglGetProcAddress(qPrintable(procName));
-}
-
-QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const
-{
- return m_windowFormat;
-}
-
-EGLContext QEGLPlatformContext::eglContext() const
-{
- return m_eglContext;
-}
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
deleted file mode 100644
index 9be1480735..0000000000
--- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QOPENKODEGLINTEGRATION_H
-#define QOPENKODEGLINTEGRATION_H
-
-#include <QtGui/QPlatformGLContext>
-#include <EGL/egl.h>
-
-class QEGLPlatformContext : public QPlatformGLContext
-{
-public:
- QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi);
- ~QEGLPlatformContext();
-
- void makeCurrent();
- void doneCurrent();
- void swapBuffers();
- void* getProcAddress(const QString& procName);
-
- QPlatformWindowFormat platformWindowFormat() const;
-
- EGLContext eglContext() const;
-private:
- EGLContext m_eglContext;
- EGLDisplay m_eglDisplay;
- EGLSurface m_eglSurface;
- EGLenum m_eglApi;
-
- QPlatformWindowFormat m_windowFormat;
-};
-
-#endif //QOPENKODEGLINTEGRATION_H
diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp
deleted file mode 100644
index cbd8f7d7c6..0000000000
--- a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qxlibeglintegration.h"
-
-static int countBits(unsigned long mask)
-{
- int count = 0;
- while (mask != 0) {
- if (mask & 1)
- ++count;
- mask >>= 1;
- }
- return count;
-}
-
-VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)
-{
- VisualID visualId = 0;
- EGLint eglValue = 0;
-
- EGLint configRedSize = 0;
- eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize);
-
- EGLint configGreenSize = 0;
- eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize);
-
- EGLint configBlueSize = 0;
- eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize);
-
- EGLint configAlphaSize = 0;
- eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize);
-
- eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue);
- int configId = eglValue;
-
- // See if EGL provided a valid VisualID:
- eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
- visualId = (VisualID)eglValue;
- if (visualId) {
- // EGL has suggested a visual id, so get the rest of the visual info for that id:
- XVisualInfo visualInfoTemplate;
- memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
- visualInfoTemplate.visualid = visualId;
-
- XVisualInfo *chosenVisualInfo;
- int matchingCount = 0;
- chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount);
- if (chosenVisualInfo) {
- // Skip size checks if implementation supports non-matching visual
- // and config (http://bugreports.qt.nokia.com/browse/QTBUG-9444).
- if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) {
- XFree(chosenVisualInfo);
- return visualId;
- }
-
- int visualRedSize = countBits(chosenVisualInfo->red_mask);
- int visualGreenSize = countBits(chosenVisualInfo->green_mask);
- int visualBlueSize = countBits(chosenVisualInfo->blue_mask);
- int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size
-
- bool visualMatchesConfig = false;
- if ( visualRedSize == configRedSize &&
- visualGreenSize == configGreenSize &&
- visualBlueSize == configBlueSize )
- {
- // We need XRender to check the alpha channel size of the visual. If we don't have
- // the alpha size, we don't check it against the EGL config's alpha size.
- if (visualAlphaSize >= 0)
- visualMatchesConfig = visualAlphaSize == configAlphaSize;
- else
- visualMatchesConfig = true;
- }
-
- if (!visualMatchesConfig) {
- if (visualAlphaSize >= 0) {
- qWarning("Warning: EGL suggested using X Visual ID %d (ARGB%d%d%d%d) for EGL config %d (ARGB%d%d%d%d), but this is incompatable",
- (int)visualId, visualAlphaSize, visualRedSize, visualGreenSize, visualBlueSize,
- configId, configAlphaSize, configRedSize, configGreenSize, configBlueSize);
- } else {
- qWarning("Warning: EGL suggested using X Visual ID %d (RGB%d%d%d) for EGL config %d (RGB%d%d%d), but this is incompatable",
- (int)visualId, visualRedSize, visualGreenSize, visualBlueSize,
- configId, configRedSize, configGreenSize, configBlueSize);
- }
- visualId = 0;
- }
- } else {
- qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
- (int)visualId, configId);
- visualId = 0;
- }
- XFree(chosenVisualInfo);
- }
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
- else
- qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
-#endif
-
- if (visualId) {
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
- if (configAlphaSize > 0)
- qDebug("Using ARGB Visual ID %d provided by EGL for config %d", (int)visualId, configId);
- else
- qDebug("Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
-#endif
- return visualId;
- }
-
- // Finally, try to
- // use XGetVisualInfo and only use the bit depths to match on:
- if (!visualId) {
- XVisualInfo visualInfoTemplate;
- memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
- XVisualInfo *matchingVisuals;
- int matchingCount = 0;
-
- visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize;
- matchingVisuals = XGetVisualInfo(display,
- VisualDepthMask,
- &visualInfoTemplate,
- &matchingCount);
- if (!matchingVisuals) {
- // Try again without taking the alpha channel into account:
- visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize;
- matchingVisuals = XGetVisualInfo(display,
- VisualDepthMask,
- &visualInfoTemplate,
- &matchingCount);
- }
-
- if (matchingVisuals) {
- visualId = matchingVisuals[0].visualid;
- XFree(matchingVisuals);
- }
- }
-
- if (visualId) {
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
- qDebug("Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
-#endif
- return visualId;
- }
-
- qWarning("Unable to find an X11 visual which matches EGL config %d", configId);
- return (VisualID)0;
-}
diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h
deleted file mode 100644
index 1d02ab8677..0000000000
--- a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTESTLITEEGLINTEGRATION_H
-#define QTESTLITEEGLINTEGRATION_H
-
-#include "qeglconvenience.h"
-
-class QXlibEglIntegration
-{
-public:
- static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config);
-};
-
-#endif // QTESTLITEEGLINTEGRATION_H
diff --git a/src/plugins/platforms/eglconvenience/xlibeglintegration.pri b/src/plugins/platforms/eglconvenience/xlibeglintegration.pri
deleted file mode 100644
index 9404a70373..0000000000
--- a/src/plugins/platforms/eglconvenience/xlibeglintegration.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/qxlibeglintegration.h
-
-SOURCES += \
- $$PWD/qxlibeglintegration.cpp
diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro
index 471cf63dd8..bcf5c6153a 100644
--- a/src/plugins/platforms/eglfs/eglfs.pro
+++ b/src/plugins/platforms/eglfs/eglfs.pro
@@ -25,7 +25,7 @@ HEADERS = qeglfsintegration.h \
qeglfswindowsurface.h \
qeglfsscreen.h
-include(../fontdatabases/genericunix/genericunix.pri)
+load(qpa/fontdatabases/genericunix)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index 95a9ff51b9..4e9a728772 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -46,7 +46,7 @@
#include "qeglfsscreen.h"
#include <QPlatformWindow>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/externalplugin.pri b/src/plugins/platforms/externalplugin.pri
deleted file mode 100644
index 9b00acb4e9..0000000000
--- a/src/plugins/platforms/externalplugin.pri
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Lighthouse now has preliminarily support for building and
-# loading platform plugins from outside the Qt source/build
-# tree.
-#
-# 1) Building external plugins:
-# Set QTDIR to the Qt build directory, copy this file to
-# the plugin source repository and include it at the top
-# of the plugin's pro file. Use QT_SOURCE_TREE if you
-# want to pull in source code from Qt:
-#
-# include($$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri)
-#
-# 2) Loading external plugins:
-# Specify the path to the directory containing the
-# plugin on the command line, in addition to the
-# platform name.
-#
-# ./wiggly -platformPluginPath /path/to/myPlugin -platform gullfaksA
-#
-
-!exists($$(QTDIR)/.qmake.cache) {
- error("Please set QTDIR to the Qt build directory")
-}
-
-QT_SOURCE_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE)
-QT_BUILD_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_BUILD_TREE)
-
-load(qt_plugin)
diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp
deleted file mode 100644
index a83d739083..0000000000
--- a/src/plugins/platforms/fb_base/fb_base.cpp
+++ /dev/null
@@ -1,507 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "fb_base.h"
-#include <qpainter.h>
-#include <qdebug.h>
-#include <qbitmap.h>
-#include <QPlatformCursor>
-#include <QWindowSystemInterface>
-
-QPlatformSoftwareCursor::QPlatformSoftwareCursor(QPlatformScreen *scr)
- : QPlatformCursor(scr), currentRect(QRect()), prevRect(QRect())
-{
- graphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
- setCursor(Qt::ArrowCursor);
-}
-
-QRect QPlatformSoftwareCursor::getCurrentRect()
-{
- QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(),
- -graphic->hotspot().y());
- rect.translate(QCursor::pos());
- QPoint screenOffset = screen->geometry().topLeft();
- rect.translate(-screenOffset); // global to local translation
- return rect;
-}
-
-
-void QPlatformSoftwareCursor::pointerEvent(const QMouseEvent & e)
-{
- Q_UNUSED(e);
- QPoint screenOffset = screen->geometry().topLeft();
- currentRect = getCurrentRect();
- // global to local translation
- if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) {
- setDirty();
- }
-}
-
-QRect QPlatformSoftwareCursor::drawCursor(QPainter & painter)
-{
- dirty = false;
- if (currentRect.isNull())
- return QRect();
-
- // We need this because the cursor might be dirty due to moving off screen
- QPoint screenOffset = screen->geometry().topLeft();
- // global to local translation
- if (!currentRect.translated(screenOffset).intersects(screen->geometry()))
- return QRect();
-
- prevRect = currentRect;
- painter.drawImage(prevRect, *graphic->image());
- onScreen = true;
- return prevRect;
-}
-
-QRect QPlatformSoftwareCursor::dirtyRect()
-{
- if (onScreen) {
- onScreen = false;
- return prevRect;
- }
- return QRect();
-}
-
-void QPlatformSoftwareCursor::setCursor(Qt::CursorShape shape)
-{
- graphic->set(shape);
-}
-
-void QPlatformSoftwareCursor::setCursor(const QImage &image, int hotx, int hoty)
-{
- graphic->set(image, hotx, hoty);
-}
-
-void QPlatformSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
-{
- graphic->set(data, mask, width, height, hotX, hotY);
-}
-
-void QPlatformSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
-{
- Q_UNUSED(widget);
- Qt::CursorShape shape = widgetCursor->shape();
-
- if (shape == Qt::BitmapCursor) {
- // application supplied cursor
- QPoint spot = widgetCursor->hotSpot();
- setCursor(widgetCursor->pixmap().toImage(), spot.x(), spot.y());
- } else {
- // system cursor
- setCursor(shape);
- }
- currentRect = getCurrentRect();
- QPoint screenOffset = screen->geometry().topLeft(); // global to local translation
- if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset)))
- setDirty();
-}
-
-QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false)
-{
- mScreenImage = new QImage(mGeometry.size(), mFormat);
- redrawTimer.setSingleShot(true);
- redrawTimer.setInterval(0);
- QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw()));
-}
-
-void QFbScreen::setGeometry(QRect rect)
-{
- delete mScreenImage;
- mGeometry = rect;
- mScreenImage = new QImage(mGeometry.size(), mFormat);
- delete compositePainter;
- compositePainter = 0;
- invalidateRectCache();
-}
-
-void QFbScreen::setDepth(int depth)
-{
- mDepth = depth;
-}
-
-void QFbScreen::setPhysicalSize(QSize size)
-{
- mPhysicalSize = size;
-}
-
-void QFbScreen::setFormat(QImage::Format format)
-{
- mFormat = format;
- delete mScreenImage;
- mScreenImage = new QImage(mGeometry.size(), mFormat);
- delete compositePainter;
- compositePainter = 0;
-}
-
-QFbScreen::~QFbScreen()
-{
- delete compositePainter;
- delete mScreenImage;
-}
-
-void QFbScreen::setDirty(const QRect &rect)
-{
- QRect intersection = rect.intersected(mGeometry);
- QPoint screenOffset = mGeometry.topLeft();
- repaintRegion += intersection.translated(-screenOffset); // global to local translation
- if (!redrawTimer.isActive()) {
- redrawTimer.start();
- }
-}
-
-void QFbScreen::generateRects()
-{
- cachedRects.clear();
- QPoint screenOffset = mGeometry.topLeft();
- QRegion remainingScreen(mGeometry.translated(-screenOffset)); // global to local translation
-
- for (int i = 0; i < windowStack.length(); i++) {
- if (remainingScreen.isEmpty())
- break;
- if (!windowStack[i]->visible())
- continue;
- if (windowStack[i]->widget()->isMinimized())
- continue;
-
- if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) {
- QRect localGeometry = windowStack.at(i)->geometry().translated(-screenOffset); // global to local translation
- remainingScreen -= localGeometry;
- QRegion windowRegion(localGeometry);
- windowRegion -= remainingScreen;
- foreach(QRect rect, windowRegion.rects()) {
- cachedRects += QPair<QRect, int>(rect, i);
- }
- }
- }
- foreach (QRect rect, remainingScreen.rects())
- cachedRects += QPair<QRect, int>(rect, -1);
- isUpToDate = true;
- return;
-}
-
-
-
-QRegion QFbScreen::doRedraw()
-{
- QPoint screenOffset = mGeometry.topLeft();
-
- QRegion touchedRegion;
- if (cursor && cursor->isDirty() && cursor->isOnScreen()) {
- QRect lastCursor = cursor->dirtyRect();
- repaintRegion += lastCursor;
- }
- if (repaintRegion.isEmpty() && (!cursor || !cursor->isDirty())) {
- return touchedRegion;
- }
-
- QVector<QRect> rects = repaintRegion.rects();
-
- if (!isUpToDate)
- generateRects();
-
- if (!compositePainter)
- compositePainter = new QPainter(mScreenImage);
- for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) {
- QRegion rectRegion = rects[rectIndex];
-
- for(int i = 0; i < cachedRects.length(); i++) {
- QRect screenSubRect = cachedRects[i].first;
- int layer = cachedRects[i].second;
- QRegion intersect = rectRegion.intersected(screenSubRect);
-
- if (intersect.isEmpty())
- continue;
-
- rectRegion -= intersect;
-
- // we only expect one rectangle, but defensive coding...
- foreach (QRect rect, intersect.rects()) {
- bool firstLayer = true;
- if (layer == -1) {
- compositePainter->fillRect(rect, Qt::black);
- firstLayer = false;
- layer = windowStack.size() - 1;
- }
-
- for (int layerIndex = layer; layerIndex != -1; layerIndex--) {
- if (!windowStack[layerIndex]->visible())
- continue;
- if (windowStack[layerIndex]->widget()->isMinimized())
- continue;
- QRect windowRect = windowStack[layerIndex]->geometry().translated(-screenOffset);
- QRect windowIntersect = rect.translated(-windowRect.left(),
- -windowRect.top());
- compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(),
- windowIntersect);
- if (firstLayer) {
- firstLayer = false;
- }
- }
- }
- }
- }
-
- QRect cursorRect;
- if (cursor && (cursor->isDirty() || repaintRegion.intersects(cursor->lastPainted()))) {
- cursorRect = cursor->drawCursor(*compositePainter);
- touchedRegion += cursorRect;
- }
- touchedRegion += repaintRegion;
- repaintRegion = QRegion();
-
-
-
-// qDebug() << "QFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion;
-
-
- return touchedRegion;
-}
-
-void QFbScreen::addWindow(QFbWindow *surface)
-{
- windowStack.prepend(surface);
- surface->mScreens.append(this);
- invalidateRectCache();
- setDirty(surface->geometry());
-}
-
-void QFbScreen::removeWindow(QFbWindow * surface)
-{
- windowStack.removeOne(surface);
- surface->mScreens.removeOne(this);
- invalidateRectCache();
- setDirty(surface->geometry());
-}
-
-void QFbWindow::raise()
-{
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- while (i != end) {
- (*i)->raise(this);
- ++i;
- }
-}
-
-void QFbScreen::raise(QPlatformWindow * surface)
-{
- QFbWindow *s = static_cast<QFbWindow *>(surface);
- int index = windowStack.indexOf(s);
- if (index <= 0)
- return;
- windowStack.move(index, 0);
- invalidateRectCache();
- setDirty(s->geometry());
-}
-
-void QFbWindow::lower()
-{
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- while (i != end) {
- (*i)->lower(this);
- ++i;
- }
-}
-
-void QFbScreen::lower(QPlatformWindow * surface)
-{
- QFbWindow *s = static_cast<QFbWindow *>(surface);
- int index = windowStack.indexOf(s);
- if (index == -1 || index == (windowStack.size() - 1))
- return;
- windowStack.move(index, windowStack.size() - 1);
- invalidateRectCache();
- setDirty(s->geometry());
-}
-
-QWidget * QFbScreen::topLevelAt(const QPoint & p) const
-{
- for(int i = 0; i < windowStack.size(); i++) {
- if (windowStack[i]->geometry().contains(p, false) &&
- windowStack[i]->visible() &&
- !windowStack[i]->widget()->isMinimized()) {
- return windowStack[i]->widget();
- }
- }
- return 0;
-}
-
-QFbWindow::QFbWindow(QWidget *window)
- :QPlatformWindow(window),
- visibleFlag(false)
-{
- static QAtomicInt winIdGenerator(1);
- windowId = winIdGenerator.fetchAndAddRelaxed(1);
-}
-
-
-QFbWindow::~QFbWindow()
-{
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- while (i != end) {
- (*i)->removeWindow(this);
- ++i;
- }
-}
-
-
-QFbWindowSurface::QFbWindowSurface(QFbScreen *screen, QWidget *window)
- : QWindowSurface(window),
- mScreen(screen)
-{
- mImage = QImage(window->size(), mScreen->format());
-
- platformWindow = static_cast<QFbWindow*>(window->platformWindow());
- platformWindow->surface = this;
-}
-
-QFbWindowSurface::~QFbWindowSurface()
-{
-}
-
-void QFbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(widget);
- Q_UNUSED(offset);
-
-
-// qDebug() << "QFbWindowSurface::flush" << region;
-
-
- platformWindow->repaint(region);
-}
-
-
-void QFbWindow::repaint(const QRegion &region)
-{
- QRect currentGeometry = geometry();
-
- QRect dirtyClient = region.boundingRect();
- QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(),
- currentGeometry.top() + dirtyClient.top(),
- dirtyClient.width(),
- dirtyClient.height());
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- QRect oldGeometryLocal = oldGeometry;
- oldGeometry = currentGeometry;
- while (i != end) {
- // If this is a move, redraw the previous location
- if (oldGeometryLocal != currentGeometry) {
- (*i)->setDirty(oldGeometryLocal);
- }
- (*i)->setDirty(dirtyRegion);
- ++i;
- }
-}
-
-void QFbWindowSurface::resize(const QSize &size)
-{
- // change the widget's QImage if this is a resize
- if (mImage.size() != size)
- mImage = QImage(size, mScreen->format());
- QWindowSurface::resize(size);
-}
-
-void QFbWindow::setGeometry(const QRect &rect)
-{
-// store previous geometry for screen update
- oldGeometry = geometry();
-
-
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- while (i != end) {
- (*i)->invalidateRectCache();
- ++i;
- }
-//### QWindowSystemInterface::handleGeometryChange(window(), rect);
-
- QPlatformWindow::setGeometry(rect);
-}
-
-bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- return QWindowSurface::scroll(area, dx, dy);
-}
-
-void QFbWindowSurface::beginPaint(const QRegion &region)
-{
- Q_UNUSED(region);
-}
-
-void QFbWindowSurface::endPaint(const QRegion &region)
-{
- Q_UNUSED(region);
-}
-
-void QFbWindow::setVisible(bool visible)
-{
- visibleFlag = visible;
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- while (i != end) {
- (*i)->invalidateRectCache();
- (*i)->setDirty(geometry());
- ++i;
- }
-}
-
-Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags type)
-{
- flags = type;
- QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
- QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
- while (i != end) {
- (*i)->invalidateRectCache();
- ++i;
- }
- return flags;
-}
-
-Qt::WindowFlags QFbWindow::windowFlags() const
-{
- return flags;
-}
diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h
deleted file mode 100644
index 6b0b152482..0000000000
--- a/src/plugins/platforms/fb_base/fb_base.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLIGHTHOUSEGRAPHICSSCREEN_H
-#define QLIGHTHOUSEGRAPHICSSCREEN_H
-
-#include <qrect.h>
-#include <qimage.h>
-#include <qtimer.h>
-#include <qpainter.h>
-#include <QPlatformCursor>
-#include <QPlatformScreen>
-#include <QPlatformWindow>
-#include <QtGui/private/qwindowsurface_p.h>
-
-class QMouseEvent;
-class QSize;
-class QPainter;
-
-class QFbScreen;
-
-class QPlatformSoftwareCursor : public QPlatformCursor
-{
-public:
- QPlatformSoftwareCursor(QPlatformScreen * scr);
-
- // output methods
- QRect dirtyRect();
- virtual QRect drawCursor(QPainter & painter);
-
- // input methods
- virtual void pointerEvent(const QMouseEvent & event);
- virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);
-
- virtual void setDirty() { dirty = true; screen->setDirty(QRect()); }
- virtual bool isDirty() { return dirty; }
- virtual bool isOnScreen() { return onScreen; }
- virtual QRect lastPainted() { return prevRect; }
-
-protected:
- QPlatformCursorImage * graphic;
-
-private:
- void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
- void setCursor(Qt::CursorShape shape);
- void setCursor(const QImage &image, int hotx, int hoty);
- QRect currentRect; // next place to draw the cursor
- QRect prevRect; // last place the cursor was drawn
- QRect getCurrentRect();
- bool dirty;
- bool onScreen;
-};
-
-class QFbWindow;
-
-class QFbWindowSurface : public QWindowSurface
-{
-public:
- QFbWindowSurface(QFbScreen *screen, QWidget *window);
- ~QFbWindowSurface();
-
- virtual QPaintDevice *paintDevice() { return &mImage; }
- virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- virtual bool scroll(const QRegion &area, int dx, int dy);
-
- virtual void beginPaint(const QRegion &region);
- virtual void endPaint(const QRegion &region);
-
-
- const QImage image() { return mImage; }
- void resize(const QSize &size);
-
-protected:
- friend class QFbWindow;
- QFbWindow *platformWindow;
-
- QFbScreen *mScreen;
- QImage mImage;
-};
-
-
-class QFbWindow : public QPlatformWindow
-{
-public:
-
- QFbWindow(QWidget *window);
- ~QFbWindow();
-
-
- virtual void setVisible(bool visible);
- virtual bool visible() { return visibleFlag; }
-
- virtual void raise();
- virtual void lower();
-
- void setGeometry(const QRect &rect);
-
- virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
- virtual Qt::WindowFlags windowFlags() const;
-
- WId winId() const { return windowId; }
-
- virtual void repaint(const QRegion&);
-
-protected:
- friend class QFbWindowSurface;
- friend class QFbScreen;
- QFbWindowSurface *surface;
- QList<QFbScreen *> mScreens;
- QRect oldGeometry;
- bool visibleFlag;
- Qt::WindowFlags flags;
-
- WId windowId;
-};
-
-class QFbScreen : public QPlatformScreen
-{
- Q_OBJECT
-public:
- QFbScreen();
- ~QFbScreen();
-
- virtual QRect geometry() const { return mGeometry; }
- virtual int depth() const { return mDepth; }
- virtual QImage::Format format() const { return mFormat; }
- virtual QSize physicalSize() const { return mPhysicalSize; }
-
- virtual void setGeometry(QRect rect);
- virtual void setDepth(int depth);
- virtual void setFormat(QImage::Format format);
- virtual void setPhysicalSize(QSize size);
-
- virtual void setDirty(const QRect &rect);
-
- virtual void removeWindow(QFbWindow * surface);
- virtual void addWindow(QFbWindow * surface);
- virtual void raise(QPlatformWindow * surface);
- virtual void lower(QPlatformWindow * surface);
- virtual QWidget * topLevelAt(const QPoint & p) const;
-
- QImage * image() const { return mScreenImage; }
- QPaintDevice * paintDevice() const { return mScreenImage; }
-
-protected:
- QList<QFbWindow *> windowStack;
- QRegion repaintRegion;
- QPlatformSoftwareCursor * cursor;
- QTimer redrawTimer;
-
-protected slots:
- virtual QRegion doRedraw();
-
-protected:
- QRect mGeometry;
- int mDepth;
- QImage::Format mFormat;
- QSize mPhysicalSize;
- QImage *mScreenImage;
-
-private:
- QPainter * compositePainter;
- void generateRects();
- QList<QPair<QRect, int> > cachedRects;
-
- void invalidateRectCache() { isUpToDate = false; }
- friend class QFbWindowSurface;
- friend class QFbWindow;
- bool isUpToDate;
-};
-
-#endif // QLIGHTHOUSEGRAPHICSSCREEN_H
diff --git a/src/plugins/platforms/fb_base/fb_base.pri b/src/plugins/platforms/fb_base/fb_base.pri
deleted file mode 100644
index 41bd87fbca..0000000000
--- a/src/plugins/platforms/fb_base/fb_base.pri
+++ /dev/null
@@ -1,2 +0,0 @@
-SOURCES += ../fb_base/fb_base.cpp
-HEADERS += ../fb_base/fb_base.h
diff --git a/src/plugins/platforms/fb_base/fb_base.pro b/src/plugins/platforms/fb_base/fb_base.pro
deleted file mode 100644
index 4ebd53b407..0000000000
--- a/src/plugins/platforms/fb_base/fb_base.pro
+++ /dev/null
@@ -1,23 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2009-11-05T13:22:31
-#
-#-------------------------------------------------
-
-#QT -= core gui
-TARGET = fb_base
-#load(qt_plugin)
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-TEMPLATE = lib
-
-#DEFINES += STATIC_LIBRARY
-CONFIG += staticlib
-
-SOURCES += fb_base.cpp
-
-HEADERS += fb_base.h
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
diff --git a/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
deleted file mode 100644
index c1fbf3e411..0000000000
--- a/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
+++ /dev/null
@@ -1,88 +0,0 @@
-DEFINES += QT_NO_FONTCONFIG
-HEADERS += \
- $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h \
- $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h
-
-SOURCES += \
- $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp \
- $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
-
-DEFINES += QT_COMPILES_IN_HARFBUZZ
-
-INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
-
-INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix
-
-CONFIG += opentype
-
-contains(QT_CONFIG, freetype) {
- SOURCES += \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbase.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbbox.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftdebug.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftglyph.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftinit.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftmm.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/fttype1.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftsynth.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbitmap.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/bdf/bdf.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cache/ftcache.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cff/cff.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cid/type1cid.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/gzip/ftgzip.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pcf/pcf.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pfr/pfr.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/psaux/psaux.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pshinter/pshinter.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/psnames/psmodule.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/raster/raster.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/sfnt/sfnt.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/smooth/smooth.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/truetype/truetype.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/type1/type1.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/type42/type42.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/winfonts/winfnt.c \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/lzw/ftlzw.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvalid.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvbase.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgdef.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvjstf.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvcommn.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgpos.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgsub.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvmod.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afangles.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afglobal.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/aflatin.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afmodule.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afdummy.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afhints.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afloader.c\
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/autofit.c
-
- symbian {
- SOURCES += \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftsystem.c
- } else {
- SOURCES += \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/builds/unix/ftsystem.c
- INCLUDEPATH += \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/builds/unix
- }
-
- INCLUDEPATH += \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/src \
- $$QT_SOURCE_TREE/src/3rdparty/freetype/include
-
- DEFINES += FT2_BUILD_LIBRARY
- contains(QT_CONFIG, system-zlib) {
- DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
- }
-
- } else:contains(QT_CONFIG, system-freetype) {
- # pull in the proper freetype2 include directory
- include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
- LIBS_PRIVATE += -lfreetype
- }
-
diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
deleted file mode 100644
index 001d377ca0..0000000000
--- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qbasicunixfontdatabase.h"
-
-#include <QtGui/private/qapplication_p.h>
-#include <QtGui/QPlatformScreen>
-
-#include <QtCore/QFile>
-#include <QtCore/QLibraryInfo>
-#include <QtCore/QDir>
-
-#undef QT_NO_FREETYPE
-#include <QtGui/private/qfontengine_ft_p.h>
-#include <QtGui/private/qfontengine_p.h>
-
-#include <ft2build.h>
-#include FT_TRUETYPE_TABLES_H
-
-#define SimplifiedChineseCsbBit 18
-#define TraditionalChineseCsbBit 20
-#define JapaneseCsbBit 17
-#define KoreanCsbBit 21
-
-static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
- // Any,
- { 127, 127 },
- // Latin,
- { 0, 127 },
- // Greek,
- { 7, 127 },
- // Cyrillic,
- { 9, 127 },
- // Armenian,
- { 10, 127 },
- // Hebrew,
- { 11, 127 },
- // Arabic,
- { 13, 127 },
- // Syriac,
- { 71, 127 },
- //Thaana,
- { 72, 127 },
- //Devanagari,
- { 15, 127 },
- //Bengali,
- { 16, 127 },
- //Gurmukhi,
- { 17, 127 },
- //Gujarati,
- { 18, 127 },
- //Oriya,
- { 19, 127 },
- //Tamil,
- { 20, 127 },
- //Telugu,
- { 21, 127 },
- //Kannada,
- { 22, 127 },
- //Malayalam,
- { 23, 127 },
- //Sinhala,
- { 73, 127 },
- //Thai,
- { 24, 127 },
- //Lao,
- { 25, 127 },
- //Tibetan,
- { 70, 127 },
- //Myanmar,
- { 74, 127 },
- // Georgian,
- { 26, 127 },
- // Khmer,
- { 80, 127 },
- // SimplifiedChinese,
- { 126, 127 },
- // TraditionalChinese,
- { 126, 127 },
- // Japanese,
- { 126, 127 },
- // Korean,
- { 56, 127 },
- // Vietnamese,
- { 0, 127 }, // same as latin1
- // Other,
- { 126, 127 },
- // Ogham,
- { 78, 127 },
- // Runic,
- { 79, 127 },
- // Nko,
- { 14, 127 },
-};
-
-static QSupportedWritingSystems determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2])
-{
- QSupportedWritingSystems writingSystems;
- bool hasScript = false;
-
- int i;
- for(i = 0; i < QFontDatabase::WritingSystemsCount; i++) {
- int bit = requiredUnicodeBits[i][0];
- int index = bit/32;
- int flag = 1 << (bit&31);
- if (bit != 126 && unicodeRange[index] & flag) {
- bit = requiredUnicodeBits[i][1];
- index = bit/32;
-
- flag = 1 << (bit&31);
- if (bit == 127 || unicodeRange[index] & flag) {
- writingSystems.setSupported(QFontDatabase::WritingSystem(i));
- hasScript = true;
- // qDebug("font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i);
- }
- }
- }
- if(codePageRange[0] & (1 << SimplifiedChineseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::SimplifiedChinese);
- hasScript = true;
- //qDebug("font %s supports Simplified Chinese", familyName.latin1());
- }
- if(codePageRange[0] & (1 << TraditionalChineseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::TraditionalChinese);
- hasScript = true;
- //qDebug("font %s supports Traditional Chinese", familyName.latin1());
- }
- if(codePageRange[0] & (1 << JapaneseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Japanese);
- hasScript = true;
- //qDebug("font %s supports Japanese", familyName.latin1());
- }
- if(codePageRange[0] & (1 << KoreanCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Korean);
- hasScript = true;
- //qDebug("font %s supports Korean", familyName.latin1());
- }
- if (!hasScript)
- writingSystems.setSupported(QFontDatabase::Symbol);
-
- return writingSystems;
-}
-
-static inline bool scriptRequiresOpenType(int script)
-{
- return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
- || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
-}
-
-void QBasicUnixFontDatabase::populateFontDatabase()
-{
- QPlatformFontDatabase::populateFontDatabase();
- QString fontpath = fontDir();
-
- if(!QFile::exists(fontpath)) {
- qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?",
- qPrintable(fontpath));
- }
-
- QDir dir(fontpath);
- dir.setNameFilters(QStringList() << QLatin1String("*.ttf")
- << QLatin1String("*.ttc") << QLatin1String("*.pfa")
- << QLatin1String("*.pfb"));
- dir.refresh();
- for (int i = 0; i < int(dir.count()); ++i) {
- const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
-// qDebug() << "looking at" << file;
- addTTFile(QByteArray(), file);
- }
-}
-
-QFontEngine *QBasicUnixFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *usrPtr)
-{
- QFontEngineFT *engine;
- FontFile *fontfile = static_cast<FontFile *> (usrPtr);
- QFontEngine::FaceId fid;
- fid.filename = fontfile->fileName.toLocal8Bit();
- fid.index = fontfile->indexValue;
- engine = new QFontEngineFT(fontDef);
-
- bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
- QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
- if (!engine->init(fid,antialias,format)) {
- delete engine;
- engine = 0;
- return engine;
- }
- if (engine->invalid()) {
- delete engine;
- engine = 0;
- } else if (scriptRequiresOpenType(script)) {
- HB_Face hbFace = engine->harfbuzzFace();
- if (!hbFace || !hbFace->supported_scripts[script]) {
- delete engine;
- engine = 0;
- }
- }
-
- return engine;
-}
-
-QStringList QBasicUnixFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const
-{
- Q_UNUSED(family);
- Q_UNUSED(style);
- Q_UNUSED(script);
- return QStringList();
-}
-
-QStringList QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)
-{
- return addTTFile(fontData,fileName.toLocal8Bit());
-}
-
-void QBasicUnixFontDatabase::releaseHandle(void *handle)
-{
- FontFile *file = static_cast<FontFile *>(handle);
- delete file;
-}
-
-QStringList QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file)
-{
- extern FT_Library qt_getFreetype();
- FT_Library library = qt_getFreetype();
-
- int index = 0;
- int numFaces = 0;
- QStringList families;
- do {
- FT_Face face;
- FT_Error error;
- if (!fontData.isEmpty()) {
- error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
- } else {
- error = FT_New_Face(library, file.constData(), index, &face);
- }
- if (error != FT_Err_Ok) {
- qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error;
- break;
- }
- numFaces = face->num_faces;
-
- QFont::Weight weight = QFont::Normal;
-
- QFont::Style style = QFont::StyleNormal;
- if (face->style_flags & FT_STYLE_FLAG_ITALIC)
- style = QFont::StyleItalic;
-
- if (face->style_flags & FT_STYLE_FLAG_BOLD)
- weight = QFont::Bold;
-
- QSupportedWritingSystems writingSystems;
- // detect symbol fonts
- for (int i = 0; i < face->num_charmaps; ++i) {
- FT_CharMap cm = face->charmaps[i];
- if (cm->encoding == ft_encoding_adobe_custom
- || cm->encoding == ft_encoding_symbol) {
- writingSystems.setSupported(QFontDatabase::Symbol);
- break;
- }
- }
-
- TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
- if (os2) {
- quint32 unicodeRange[4] = {
- os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4
- };
- quint32 codePageRange[2] = {
- os2->ulCodePageRange1, os2->ulCodePageRange2
- };
-
- writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
- }
-
- QString family = QString::fromAscii(face->family_name);
- FontFile *fontFile = new FontFile;
- fontFile->fileName = file;
- fontFile->indexValue = index;
-
- QFont::Stretch stretch = QFont::Unstretched;
-
- registerFont(family,"",weight,style,stretch,true,true,0,writingSystems,fontFile);
-
- families.append(family);
-
- FT_Done_Face(face);
- ++index;
- } while (index < numFaces);
- return families;
-}
diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h
deleted file mode 100644
index f7fc0e547b..0000000000
--- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBASICUNIXFONTDATABASE_H
-#define QBASICUNIXFONTDATABASE_H
-
-#include <QPlatformFontDatabase>
-#include <QtCore/QByteArray>
-#include <QtCore/QString>
-
-struct FontFile
-{
- QString fileName;
- int indexValue;
-};
-
-class QBasicUnixFontDatabase : public QPlatformFontDatabase
-{
-public:
- void populateFontDatabase();
- QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
- QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const;
- QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
- void releaseHandle(void *handle);
-
- static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file);
-};
-
-#endif // QBASICUNIXFONTDATABASE_H
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri b/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri
deleted file mode 100644
index 19c74ed089..0000000000
--- a/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri
+++ /dev/null
@@ -1,12 +0,0 @@
-include(../basicunix/basicunix.pri)
-
-HEADERS += \
- $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
-
-SOURCES += \
- $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
-
-INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig
-LIBS_PRIVATE += -lfontconfig
-
-
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
deleted file mode 100644
index 377d6552d5..0000000000
--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ /dev/null
@@ -1,601 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfontconfigdatabase.h"
-
-#include <QtCore/QList>
-#include <QtGui/private/qfont_p.h>
-
-#include <QtCore/QElapsedTimer>
-
-#include <QtGui/private/qapplication_p.h>
-#include <QtGui/QPlatformScreen>
-
-#include <QtGui/private/qfontengine_ft_p.h>
-#include <QtGui/private/qfontengine_p.h>
-
-
-
-#include <ft2build.h>
-#include FT_TRUETYPE_TABLES_H
-
-#include <fontconfig/fontconfig.h>
-
-#define SimplifiedChineseCsbBit 18
-#define TraditionalChineseCsbBit 20
-#define JapaneseCsbBit 17
-#define KoreanCsbBit 21
-
-static inline bool requiresOpenType(int writingSystem)
-{
- return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
- || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
-}
-static inline bool scriptRequiresOpenType(int script)
-{
- return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
- || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
-}
-
-static int getFCWeight(int fc_weight)
-{
- int qtweight = QFont::Black;
- if (fc_weight <= (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2)
- qtweight = QFont::Light;
- else if (fc_weight <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2)
- qtweight = QFont::Normal;
- else if (fc_weight <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2)
- qtweight = QFont::DemiBold;
- else if (fc_weight <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2)
- qtweight = QFont::Bold;
-
- return qtweight;
-}
-
-static const char *specialLanguages[] = {
- "en", // Common
- "el", // Greek
- "ru", // Cyrillic
- "hy", // Armenian
- "he", // Hebrew
- "ar", // Arabic
- "syr", // Syriac
- "div", // Thaana
- "hi", // Devanagari
- "bn", // Bengali
- "pa", // Gurmukhi
- "gu", // Gujarati
- "or", // Oriya
- "ta", // Tamil
- "te", // Telugu
- "kn", // Kannada
- "ml", // Malayalam
- "si", // Sinhala
- "th", // Thai
- "lo", // Lao
- "bo", // Tibetan
- "my", // Myanmar
- "ka", // Georgian
- "ko", // Hangul
- "", // Ogham
- "", // Runic
- "km", // Khmer
- "" // N'Ko
-};
-enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
-
-static const ushort specialChars[] = {
- 0, // English
- 0, // Greek
- 0, // Cyrillic
- 0, // Armenian
- 0, // Hebrew
- 0, // Arabic
- 0, // Syriac
- 0, // Thaana
- 0, // Devanagari
- 0, // Bengali
- 0, // Gurmukhi
- 0, // Gujarati
- 0, // Oriya
- 0, // Tamil
- 0xc15, // Telugu
- 0xc95, // Kannada
- 0xd15, // Malayalam
- 0xd9a, // Sinhala
- 0, // Thai
- 0, // Lao
- 0, // Tibetan
- 0x1000, // Myanmar
- 0, // Georgian
- 0, // Hangul
- 0x1681, // Ogham
- 0x16a0, // Runic
- 0, // Khmer
- 0x7ca // N'Ko
-};
-enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
-
-// this could become a list of all languages used for each writing
-// system, instead of using the single most common language.
-static const char *languageForWritingSystem[] = {
- 0, // Any
- "en", // Latin
- "el", // Greek
- "ru", // Cyrillic
- "hy", // Armenian
- "he", // Hebrew
- "ar", // Arabic
- "syr", // Syriac
- "div", // Thaana
- "hi", // Devanagari
- "bn", // Bengali
- "pa", // Gurmukhi
- "gu", // Gujarati
- "or", // Oriya
- "ta", // Tamil
- "te", // Telugu
- "kn", // Kannada
- "ml", // Malayalam
- "si", // Sinhala
- "th", // Thai
- "lo", // Lao
- "bo", // Tibetan
- "my", // Myanmar
- "ka", // Georgian
- "km", // Khmer
- "zh-cn", // SimplifiedChinese
- "zh-tw", // TraditionalChinese
- "ja", // Japanese
- "ko", // Korean
- "vi", // Vietnamese
- 0, // Symbol
- 0, // Ogham
- 0, // Runic
- 0 // N'Ko
-};
-enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
-
-// Unfortunately FontConfig doesn't know about some languages. We have to test these through the
-// charset. The lists below contain the systems where we need to do this.
-static const ushort sampleCharForWritingSystem[] = {
- 0, // Any
- 0, // Latin
- 0, // Greek
- 0, // Cyrillic
- 0, // Armenian
- 0, // Hebrew
- 0, // Arabic
- 0, // Syriac
- 0, // Thaana
- 0, // Devanagari
- 0, // Bengali
- 0, // Gurmukhi
- 0, // Gujarati
- 0, // Oriya
- 0, // Tamil
- 0xc15, // Telugu
- 0xc95, // Kannada
- 0xd15, // Malayalam
- 0xd9a, // Sinhala
- 0, // Thai
- 0, // Lao
- 0, // Tibetan
- 0x1000, // Myanmar
- 0, // Georgian
- 0, // Khmer
- 0, // SimplifiedChinese
- 0, // TraditionalChinese
- 0, // Japanese
- 0, // Korean
- 0, // Vietnamese
- 0, // Symbol
- 0x1681, // Ogham
- 0x16a0, // Runic
- 0x7ca // N'Ko
-};
-enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) };
-
-// Newer FontConfig let's us sort out fonts that contain certain glyphs, but no
-// open type tables for is directly. Do this so we don't pick some strange
-// pseudo unicode font
-static const char *openType[] = {
- 0, // Any
- 0, // Latin
- 0, // Greek
- 0, // Cyrillic
- 0, // Armenian
- 0, // Hebrew
- 0, // Arabic
- "syrc", // Syriac
- "thaa", // Thaana
- "deva", // Devanagari
- "beng", // Bengali
- "guru", // Gurmukhi
- "gurj", // Gujarati
- "orya", // Oriya
- "taml", // Tamil
- "telu", // Telugu
- "knda", // Kannada
- "mlym", // Malayalam
- "sinh", // Sinhala
- 0, // Thai
- 0, // Lao
- "tibt", // Tibetan
- "mymr", // Myanmar
- 0, // Georgian
- "khmr", // Khmer
- 0, // SimplifiedChinese
- 0, // TraditionalChinese
- 0, // Japanese
- 0, // Korean
- 0, // Vietnamese
- 0, // Symbol
- 0, // Ogham
- 0, // Runic
- "nko " // N'Ko
-};
-
-static const char *getFcFamilyForStyleHint(const QFont::StyleHint style)
-{
- const char *stylehint = 0;
- switch (style) {
- case QFont::SansSerif:
- stylehint = "sans-serif";
- break;
- case QFont::Serif:
- stylehint = "serif";
- break;
- case QFont::TypeWriter:
- stylehint = "monospace";
- break;
- default:
- break;
- }
- return stylehint;
-}
-
-void QFontconfigDatabase::populateFontDatabase()
-{
- FcFontSet *fonts;
-
- QString familyName;
- FcChar8 *value = 0;
- int weight_value;
- int slant_value;
- int spacing_value;
- FcChar8 *file_value;
- int indexValue;
- FcChar8 *foundry_value;
- FcBool scalable;
- FcBool antialias;
-
- {
- FcObjectSet *os = FcObjectSetCreate();
- FcPattern *pattern = FcPatternCreate();
- const char *properties [] = {
- FC_FAMILY, FC_WEIGHT, FC_SLANT,
- FC_SPACING, FC_FILE, FC_INDEX,
- FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT,
- FC_WIDTH,
-#if FC_VERSION >= 20297
- FC_CAPABILITY,
-#endif
- (const char *)0
- };
- const char **p = properties;
- while (*p) {
- FcObjectSetAdd(os, *p);
- ++p;
- }
- fonts = FcFontList(0, pattern, os);
- FcObjectSetDestroy(os);
- FcPatternDestroy(pattern);
- }
-
- for (int i = 0; i < fonts->nfont; i++) {
- if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
- continue;
- // capitalize(value);
- familyName = QString::fromUtf8((const char *)value);
- slant_value = FC_SLANT_ROMAN;
- weight_value = FC_WEIGHT_MEDIUM;
- spacing_value = FC_PROPORTIONAL;
- file_value = 0;
- indexValue = 0;
- scalable = FcTrue;
-
-
- if (FcPatternGetInteger (fonts->fonts[i], FC_SLANT, 0, &slant_value) != FcResultMatch)
- slant_value = FC_SLANT_ROMAN;
- if (FcPatternGetInteger (fonts->fonts[i], FC_WEIGHT, 0, &weight_value) != FcResultMatch)
- weight_value = FC_WEIGHT_MEDIUM;
- if (FcPatternGetInteger (fonts->fonts[i], FC_SPACING, 0, &spacing_value) != FcResultMatch)
- spacing_value = FC_PROPORTIONAL;
- if (FcPatternGetString (fonts->fonts[i], FC_FILE, 0, &file_value) != FcResultMatch)
- file_value = 0;
- if (FcPatternGetInteger (fonts->fonts[i], FC_INDEX, 0, &indexValue) != FcResultMatch)
- indexValue = 0;
- if (FcPatternGetBool(fonts->fonts[i], FC_SCALABLE, 0, &scalable) != FcResultMatch)
- scalable = FcTrue;
- if (FcPatternGetString(fonts->fonts[i], FC_FOUNDRY, 0, &foundry_value) != FcResultMatch)
- foundry_value = 0;
- if(FcPatternGetBool(fonts->fonts[i],FC_ANTIALIAS,0,&antialias) != FcResultMatch)
- antialias = true;
-
- QSupportedWritingSystems writingSystems;
- FcLangSet *langset = 0;
- FcResult res = FcPatternGetLangSet(fonts->fonts[i], FC_LANG, 0, &langset);
- if (res == FcResultMatch) {
- for (int i = 1; i < LanguageCount; ++i) {
- const FcChar8 *lang = (const FcChar8*) languageForWritingSystem[i];
- if (lang) {
- FcLangResult langRes = FcLangSetHasLang(langset, lang);
- if (langRes != FcLangDifferentLang)
- writingSystems.setSupported(QFontDatabase::WritingSystem(i));
- }
- }
- } else {
- // we set Other to supported for symbol fonts. It makes no
- // sense to merge these with other ones, as they are
- // special in a way.
- writingSystems.setSupported(QFontDatabase::Other);
- }
-
- FcCharSet *cs = 0;
- res = FcPatternGetCharSet(fonts->fonts[i], FC_CHARSET, 0, &cs);
- if (res == FcResultMatch) {
- // some languages are not supported by FontConfig, we rather check the
- // charset to detect these
- for (int i = 1; i < SampleCharCount; ++i) {
- if (!sampleCharForWritingSystem[i])
- continue;
- if (FcCharSetHasChar(cs, sampleCharForWritingSystem[i]))
- writingSystems.setSupported(QFontDatabase::WritingSystem(i));
- }
- }
-
-#if FC_VERSION >= 20297
- for (int j = 1; j < LanguageCount; ++j) {
- if (writingSystems.supported(QFontDatabase::WritingSystem(j))
- && requiresOpenType(j) && openType[j]) {
- FcChar8 *cap;
- res = FcPatternGetString (fonts->fonts[i], FC_CAPABILITY, 0, &cap);
- if (res != FcResultMatch || !strstr((const char *)cap, openType[j]))
- writingSystems.setSupported(QFontDatabase::WritingSystem(j),false);
- }
- }
-#endif
-
- FontFile *fontFile = new FontFile;
- fontFile->fileName = QLatin1String((const char *)file_value);
- fontFile->indexValue = indexValue;
-
- QFont::Style style = (slant_value == FC_SLANT_ITALIC)
- ? QFont::StyleItalic
- : ((slant_value == FC_SLANT_OBLIQUE)
- ? QFont::StyleOblique
- : QFont::StyleNormal);
- QFont::Weight weight = QFont::Weight(getFCWeight(weight_value));
-
- double pixel_size = 0;
- if (!scalable) {
- int width = 100;
- FcPatternGetInteger (fonts->fonts[i], FC_WIDTH, 0, &width);
- FcPatternGetDouble (fonts->fonts[i], FC_PIXEL_SIZE, 0, &pixel_size);
- }
-
- QFont::Stretch stretch = QFont::Unstretched;
- QPlatformFontDatabase::registerFont(familyName,QLatin1String((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,writingSystems,fontFile);
-// qDebug() << familyName << (const char *)foundry_value << weight << style << &writingSystems << scalable << true << pixel_size;
- }
-
- FcFontSetDestroy (fonts);
-
- struct FcDefaultFont {
- const char *qtname;
- const char *rawname;
- bool fixed;
- };
- const FcDefaultFont defaults[] = {
- { "Serif", "serif", false },
- { "Sans Serif", "sans-serif", false },
- { "Monospace", "monospace", true },
- { 0, 0, false }
- };
- const FcDefaultFont *f = defaults;
- // aliases only make sense for 'common', not for any of the specials
- QSupportedWritingSystems ws;
- ws.setSupported(QFontDatabase::Latin);
-
-
- while (f->qtname) {
- registerFont(f->qtname,QLatin1String(""),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,ws,0);
- registerFont(f->qtname,QLatin1String(""),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,ws,0);
- registerFont(f->qtname,QLatin1String(""),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,ws,0);
- ++f;
- }
-
- //Lighthouse has very lazy population of the font db. We want it to be initialized when
- //QApplication is constructed, so that the population procedure can do something like this to
- //set the default font
-// const FcDefaultFont *s = defaults;
-// QFont font("Sans Serif");
-// font.setPointSize(9);
-// QApplication::setFont(font);
-}
-
-QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr)
-{
- if (!usrPtr)
- return 0;
- QFontDef fontDef = f;
-
- QFontEngineFT *engine;
- FontFile *fontfile = static_cast<FontFile *> (usrPtr);
- QFontEngine::FaceId fid;
- fid.filename = fontfile->fileName.toLocal8Bit();
- fid.index = fontfile->indexValue;
-
- //try and get the pattern
- FcPattern *pattern = FcPatternCreate();
-
- bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
- QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
-
- engine = new QFontEngineFT(fontDef);
-
- FcValue value;
- value.type = FcTypeString;
- QByteArray cs = fontDef.family.toUtf8();
- value.u.s = (const FcChar8 *)cs.data();
- FcPatternAdd(pattern,FC_FAMILY,value,true);
-
-
- value.u.s = (const FcChar8 *)fid.filename.data();
- FcPatternAdd(pattern,FC_FILE,value,true);
-
- value.type = FcTypeInteger;
- value.u.i = fid.index;
- FcPatternAdd(pattern,FC_INDEX,value,true);
-
- QFontEngineFT::HintStyle default_hint_style;
-
- if (FcConfigSubstitute(0,pattern,FcMatchPattern)) {
-
- //hinting
- int hint_style = 0;
- if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
- hint_style = QFontEngineFT::HintFull;
- switch (hint_style) {
- case FC_HINT_NONE:
- default_hint_style = QFontEngineFT::HintNone;
- break;
- case FC_HINT_SLIGHT:
- default_hint_style = QFontEngineFT::HintLight;
- break;
- case FC_HINT_MEDIUM:
- default_hint_style = QFontEngineFT::HintMedium;
- break;
- default:
- default_hint_style = QFontEngineFT::HintFull;
- break;
- }
- }
-
- engine->setDefaultHintStyle(default_hint_style);
- if (!engine->init(fid,antialias,format)) {
- delete engine;
- engine = 0;
- return engine;
- }
- if (engine->invalid()) {
- delete engine;
- engine = 0;
- } else if (scriptRequiresOpenType(script)) {
- HB_Face hbFace = engine->harfbuzzFace();
- if (!hbFace || !hbFace->supported_scripts[script]) {
- delete engine;
- engine = 0;
- }
- }
-
- return engine;
-}
-
-QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
-{
- QStringList fallbackFamilies;
- FcPattern *pattern = FcPatternCreate();
- if (!pattern)
- return fallbackFamilies;
-
- FcValue value;
- value.type = FcTypeString;
- QByteArray cs = family.toUtf8();
- value.u.s = (const FcChar8 *)cs.data();
- FcPatternAdd(pattern,FC_FAMILY,value,true);
-
- int slant_value = FC_SLANT_ROMAN;
- if (style == QFont::StyleItalic)
- slant_value = FC_SLANT_ITALIC;
- else if (style == QFont::StyleOblique)
- slant_value = FC_SLANT_OBLIQUE;
- FcPatternAddInteger(pattern, FC_SLANT, slant_value);
-
- if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') {
- Q_ASSERT(script < QUnicodeTables::ScriptCount);
- FcLangSet *ls = FcLangSetCreate();
- FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
- FcPatternAddLangSet(pattern, FC_LANG, ls);
- FcLangSetDestroy(ls);
- }
-
- const char *stylehint = getFcFamilyForStyleHint(styleHint);
- if (stylehint) {
- value.u.s = (const FcChar8 *)stylehint;
- FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
- }
-
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcConfigSubstitute(0, pattern, FcMatchFont);
-
- FcResult result = FcResultMatch;
- FcFontSet *fontSet = FcFontSort(0,pattern,FcFalse,0,&result);
-
- if (fontSet && result == FcResultMatch)
- {
- for (int i = 0; i < fontSet->nfont; i++) {
- FcChar8 *value = 0;
- if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
- continue;
- // capitalize(value);
- QString familyName = QString::fromUtf8((const char *)value);
- if (!fallbackFamilies.contains(familyName,Qt::CaseInsensitive)) {
- fallbackFamilies << familyName;
- }
-
- }
- }
-// qDebug() << "fallbackFamilies for:" << family << fallbackFamilies;
-
- return fallbackFamilies;
-}
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
deleted file mode 100644
index 61700e391a..0000000000
--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFONTCONFIGDATABASE_H
-#define QFONTCONFIGDATABASE_H
-
-#include <QPlatformFontDatabase>
-#include "qbasicunixfontdatabase.h"
-
-class QFontconfigDatabase : public QBasicUnixFontDatabase
-{
-public:
- void populateFontDatabase();
- QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
- QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
-};
-
-#endif // QFONTCONFIGDATABASE_H
diff --git a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri
deleted file mode 100644
index 1153ab36b7..0000000000
--- a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-contains(QT_CONFIG, fontconfig) {
- include(../fontconfig/fontconfig.pri)
- DEFINES += Q_FONTCONFIGDATABASE
-} else {
- include(../basicunix/basicunix.pri)
-}
-
-INCLUDEPATH += $$PWD
-HEADERS += \
- $$PWD/qgenericunixfontdatabase.h
diff --git a/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h
deleted file mode 100644
index 8bf542a215..0000000000
--- a/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGENERICUNIXFONTDATABASE_H
-#define QGENERICUNIXFONTDATABASE_H
-
-#ifdef Q_FONTCONFIGDATABASE
-#include "qfontconfigdatabase.h"
-typedef QFontconfigDatabase QGenericUnixFontDatabase;
-#else
-#include "qbasicunixfontdatabase.h"
-typedef QBasicUnixFontDatabase QGenericUnixFontDatabase;
-#endif //Q_FONTCONFIGDATABASE
-
-#endif // QGENERICUNIXFONTDATABASE_H
diff --git a/src/plugins/platforms/glxconvenience/glxconvenience.pri b/src/plugins/platforms/glxconvenience/glxconvenience.pri
deleted file mode 100644
index b4d43a30b5..0000000000
--- a/src/plugins/platforms/glxconvenience/glxconvenience.pri
+++ /dev/null
@@ -1,15 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/qglxconvenience.h
-
-SOURCES += \
- $$PWD/qglxconvenience.cpp
-
-CONFIG += xrender
-
-xrender {
- LIBS += -lXrender
-} else {
- DEFINES += QT_NO_XRENDER
-}
diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp
deleted file mode 100644
index 34633d9692..0000000000
--- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglxconvenience.h"
-
-#include <QtCore/QVector>
-
-#ifndef QT_NO_XRENDER
-#include <X11/extensions/Xrender.h>
-#endif
-
-enum {
- XFocusOut = FocusOut,
- XFocusIn = FocusIn,
- XKeyPress = KeyPress,
- XKeyRelease = KeyRelease,
- XNone = None,
- XRevertToParent = RevertToParent,
- XGrayScale = GrayScale,
- XCursorShape = CursorShape
-};
-#undef FocusOut
-#undef FocusIn
-#undef KeyPress
-#undef KeyRelease
-#undef None
-#undef RevertToParent
-#undef GrayScale
-#undef CursorShape
-
-#ifdef FontChange
-#undef FontChange
-#endif
-
-QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit)
-{
- QVector<int> spec(48);
- int i = 0;
-
- spec[i++] = GLX_LEVEL;
- spec[i++] = 0;
- spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit;
-
- if (format.rgba()) {
- spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
- spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
- spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
- spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
- if (format.alpha()) {
- spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
- }
-
- if (format.accum()) {
- spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
-
- if (format.alpha()) {
- spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- }
- }
- } else {
- spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
- spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
- }
-
- spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
- spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
-
- if (format.depth()) {
- spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
- }
-
- if (format.stencil()) {
- spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
- }
- if (format.sampleBuffers()) {
- spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = format.samples() == -1 ? 4 : format.samples();
- }
-
- spec[i++] = XNone;
- return spec;
-}
-
-GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit)
-{
- bool reduced = true;
- GLXFBConfig chosenConfig = 0;
- QPlatformWindowFormat reducedFormat = format;
- while (!chosenConfig && reduced) {
- QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit);
- int confcount = 0;
- GLXFBConfig *configs;
- configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount);
- if (confcount)
- {
- for (int i = 0; i < confcount; i++) {
- chosenConfig = configs[i];
- // Make sure we try to get an ARGB visual if the format asked for an alpha:
- if (reducedFormat.alpha()) {
- int alphaSize;
- glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize);
- if (alphaSize > 0) {
- XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig);
-#if !defined(QT_NO_XRENDER)
- XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual);
- if (pictFormat->direct.alphaMask > 0)
- break;
-#else
- if (visual->depth == 32)
- break;
-#endif
- }
- } else {
- break; // Just choose the first in the list if there's no alpha requested
- }
- }
-
- XFree(configs);
- }
- reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced);
- }
-
- if (!chosenConfig)
- qWarning("Warning: no suitable glx confiuration found");
-
- return chosenConfig;
-}
-
-XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format)
-{
- GLXFBConfig config = qglx_findConfig(display,screen,format);
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config);
- return visualInfo;
-}
-
-QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
-{
- QPlatformWindowFormat format;
- int redSize = 0;
- int greenSize = 0;
- int blueSize = 0;
- int alphaSize = 0;
- int depthSize = 0;
- int stencilSize = 0;
- int sampleBuffers = 0;
- int sampleCount = 0;
- int level = 0;
- int rgba = 0;
- int stereo = 0;
- int accumSizeA = 0;
- int accumSizeR = 0;
- int accumSizeG = 0;
- int accumSizeB = 0;
-
- XVisualInfo *vi = glXGetVisualFromFBConfig(display,config);
- glXGetConfig(display,vi,GLX_RGBA,&rgba);
- XFree(vi);
- glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize);
- glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize);
- glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize);
- glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize);
- glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize);
- glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
- glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers);
- glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level);
- glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB);
-
- format.setRedBufferSize(redSize);
- format.setGreenBufferSize(greenSize);
- format.setBlueBufferSize(blueSize);
- format.setAlphaBufferSize(alphaSize);
- format.setDepthBufferSize(depthSize);
- format.setStencilBufferSize(stencilSize);
- format.setSampleBuffers(sampleBuffers);
- if (format.sampleBuffers()) {
- glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
- format.setSamples(sampleCount);
- }
-
- format.setDirectRendering(glXIsDirect(display, ctx));
- format.setRgba(rgba);
- format.setStereo(stereo);
- format.setAccumBufferSize(accumSizeB);
-
- return format;
-}
-
-QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
-{
- QPlatformWindowFormat retFormat = format;
- *reduced = true;
-
- if (retFormat.sampleBuffers()) {
- retFormat.setSampleBuffers(false);
- } else if (retFormat.stereo()) {
- retFormat.setStereo(false);
- } else if (retFormat.accum()) {
- retFormat.setAccum(false);
- }else if (retFormat.stencil()) {
- retFormat.setStencil(false);
- }else if (retFormat.alpha()) {
- retFormat.setAlpha(false);
- }else if (retFormat.depth()) {
- retFormat.setDepth(false);
- }else if (retFormat.doubleBuffer()) {
- retFormat.setDoubleBuffer(false);
- }else{
- *reduced = false;
- }
- return retFormat;
-}
diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h
deleted file mode 100644
index 7478abfeba..0000000000
--- a/src/plugins/platforms/glxconvenience/qglxconvenience.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGLXCONVENIENCE_H
-#define QGLXCONVENIENCE_H
-
-#include <QPlatformWindowFormat>
-
-#include <X11/Xlib.h>
-#include <GL/glx.h>
-
-XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format);
-GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT);
-QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
-QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT);
-QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced);
-
-#endif // QGLXCONVENIENCE_H
diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro
index ce6814ecc1..9375486d8b 100644
--- a/src/plugins/platforms/linuxfb/linuxfb.pro
+++ b/src/plugins/platforms/linuxfb/linuxfb.pro
@@ -3,6 +3,8 @@ load(qt_plugin)
DESTDIR = $$QT.gui.plugins/platforms
+QT += core-private gui-private platformsupport-private
+
SOURCES = main.cpp qlinuxfbintegration.cpp
HEADERS = qlinuxfbintegration.h
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
index 4a24d6614a..c2388ceb85 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
@@ -42,6 +42,7 @@
#include "qlinuxfbintegration.h"
#include "../fb_base/fb_base.h"
#include "qgenericunixfontdatabase.h"
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <qimage.h>
@@ -810,6 +811,11 @@ QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId
return w;
}
+QAbstractEventDispatcher *QMinimalIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const
{
return fontDb;
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
index b96749ff03..62c2a59187 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
@@ -70,6 +70,7 @@ class QLinuxFbIntegrationPrivate;
struct fb_cmap;
struct fb_var_screeninfo;
struct fb_fix_screeninfo;
+class QAbstractEventDispatcher;
class QLinuxFbIntegration : public QPlatformIntegration
{
@@ -82,6 +83,7 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const { return mScreens; }
diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
index d51b6b2ed0..392d12d19a 100644
--- a/src/plugins/platforms/minimal/minimal.pro
+++ b/src/plugins/platforms/minimal/minimal.pro
@@ -1,14 +1,14 @@
TARGET = qminimal
load(qt_plugin)
-QT = core-private gui-private
+QT += core-private gui-private platformsupport-private
DESTDIR = $$QT.gui.plugins/platforms
SOURCES = main.cpp \
qminimalintegration.cpp \
- qminimalwindowsurface.cpp
+ qminimalbackingstore.cpp
HEADERS = qminimalintegration.h \
- qminimalwindowsurface.h
+ qminimalbackingstore.h
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp b/src/plugins/platforms/minimal/qminimalbackingstore.cpp
index 91c68d1d2d..bd4f04dfcd 100644
--- a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp
+++ b/src/plugins/platforms/minimal/qminimalbackingstore.cpp
@@ -40,45 +40,44 @@
****************************************************************************/
-#include "qminimalwindowsurface.h"
+#include "qminimalbackingstore.h"
#include <QtCore/qdebug.h>
-#include <QtGui/private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
-QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window)
- : QWindowSurface(window)
+QMinimalBackingStore::QMinimalBackingStore(QWindow *window)
+ : QPlatformBackingStore(window)
{
- //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this;
+ //qDebug() << "QMinimalBackingStore::QMinimalBackingStore:" << (long)this;
}
-QMinimalWindowSurface::~QMinimalWindowSurface()
+QMinimalBackingStore::~QMinimalBackingStore()
{
}
-QPaintDevice *QMinimalWindowSurface::paintDevice()
+QPaintDevice *QMinimalBackingStore::paintDevice()
{
- //qDebug() << "QMinimalWindowSurface::paintDevice";
+ //qDebug() << "QMinimalBackingStore::paintDevice";
return &mImage;
}
-void QMinimalWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QMinimalBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
- Q_UNUSED(widget);
+ Q_UNUSED(window);
Q_UNUSED(region);
Q_UNUSED(offset);
static int c = 0;
QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0'));
- qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData();
+ qDebug() << "QMinimalBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData();
mImage.save(filename);
}
-void QMinimalWindowSurface::resize(const QSize &size)
+void QMinimalBackingStore::resize(const QSize &size, const QRegion &)
{
- //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect;
- QWindowSurface::resize(size);
- QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+ //qDebug() << "QMinimalBackingStore::setGeometry:" << (long)this << rect;
+ QImage::Format format = QGuiApplicationPrivate::platformIntegration()->screens().first()->format();
if (mImage.size() != size)
mImage = QImage(size, format);
}
diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.h b/src/plugins/platforms/minimal/qminimalbackingstore.h
index 2c6196a19a..9b61275e9d 100644
--- a/src/plugins/platforms/minimal/qminimalwindowsurface.h
+++ b/src/plugins/platforms/minimal/qminimalbackingstore.h
@@ -39,24 +39,24 @@
**
****************************************************************************/
-#ifndef QWINDOWSURFACE_MINIMAL_H
-#define QWINDOWSURFACE_MINIMAL_H
-
-#include <QtGui/private/qwindowsurface_p.h>
+#ifndef QBACKINGSTORE_MINIMAL_H
+#define QBACKINGSTORE_MINIMAL_H
+#include <QtGui/QPlatformBackingStore>
#include <QtGui/QPlatformWindow>
+#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
-class QMinimalWindowSurface : public QWindowSurface
+class QMinimalBackingStore : public QPlatformBackingStore
{
public:
- QMinimalWindowSurface(QWidget *window);
- ~QMinimalWindowSurface();
+ QMinimalBackingStore(QWindow *window);
+ ~QMinimalBackingStore();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size, const QRegion &staticContents);
private:
QImage mImage;
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
index b9ab528b50..d9f4801f70 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.cpp
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -40,7 +40,12 @@
****************************************************************************/
#include "qminimalintegration.h"
-#include "qminimalwindowsurface.h"
+#include "qminimalbackingstore.h"
+#ifndef Q_OS_WIN
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#else
+#include <QtCore/private/qeventdispatcher_win_p.h>
+#endif
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/QPlatformWindow>
@@ -69,14 +74,23 @@ QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type)
return new QRasterPixmapData(type);
}
-QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const
{
- Q_UNUSED(winId);
- return new QPlatformWindow(widget);
+ Q_UNUSED(window);
+ return new QPlatformWindow(window);
}
-QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QPlatformBackingStore *QMinimalIntegration::createPlatformBackingStore(QWindow *window) const
{
- Q_UNUSED(winId);
- return new QMinimalWindowSurface(widget);
+ return new QMinimalBackingStore(window);
}
+
+QAbstractEventDispatcher *QMinimalIntegration::createEventDispatcher() const
+{
+#ifndef Q_OS_WIN
+ return createUnixEventDispatcher();
+#else
+ return new QEventDispatcherWin32();
+#endif
+}
+
diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h
index d1fcc42c68..dc111757db 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.h
+++ b/src/plugins/platforms/minimal/qminimalintegration.h
@@ -72,8 +72,9 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const { return mScreens; }
diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp
index c6fe6d0176..2215cd0a92 100644
--- a/src/plugins/platforms/openkode/qopenkodewindow.cpp
+++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp
@@ -53,7 +53,7 @@
#include <EGL/egl.h>
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtGui/private/qwidget_p.h>
#include <QtGui/private/qapplication_p.h>
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index 492569796f..9d7ae296a9 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -9,3 +9,7 @@ contains(QT_CONFIG, wayland) {
contains(QT_CONFIG, xcb) {
SUBDIRS += xcb
}
+
+mac {
+ SUBDIRS += cocoa
+}
diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro
index 5db8533264..a95b13efc7 100644
--- a/src/plugins/platforms/qvfb/qvfb.pro
+++ b/src/plugins/platforms/qvfb/qvfb.pro
@@ -3,6 +3,7 @@ load(qt_plugin)
DESTDIR = $$QT.gui.plugins/platforms
+QT += core-private gui-private platformsupport-private
SOURCES = main.cpp qvfbintegration.cpp qvfbwindowsurface.cpp
HEADERS = qvfbintegration.h qvfbwindowsurface.h
diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp
index 6b54420402..214f6a8368 100644
--- a/src/plugins/platforms/qvfb/qvfbintegration.cpp
+++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp
@@ -63,6 +63,7 @@
#include <QWindowSystemInterface>
#include "qgenericunixfontdatabase.h"
+#include "qgenericunixeventdispatcher.h"
QT_BEGIN_NAMESPACE
@@ -438,6 +439,11 @@ QPlatformWindow *QVFbIntegration::createPlatformWindow(QWidget *widget, WId) con
return new QVFbWindow(mPrimaryScreen, widget);
}
+QAbstractEventDispatcher *QVFbIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
QPlatformFontDatabase *QVFbIntegration::fontDatabase() const
{
return mFontDb;
diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h
index ae3ba7bcc3..aaf20a37ec 100644
--- a/src/plugins/platforms/qvfb/qvfbintegration.h
+++ b/src/plugins/platforms/qvfb/qvfbintegration.h
@@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE
class QVFbScreenPrivate;
+class QAbstractEventDispatcher;
class QVFbScreen : public QPlatformScreen
{
@@ -81,6 +82,7 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const { return mScreens; }
diff --git a/src/plugins/platforms/uikit/uikit.pro b/src/plugins/platforms/uikit/uikit.pro
index 45a48dc92a..5e3a0e6b7c 100644
--- a/src/plugins/platforms/uikit/uikit.pro
+++ b/src/plugins/platforms/uikit/uikit.pro
@@ -1,5 +1,5 @@
TARGET = quikit
-load(qt_plugin)
+load(qpa/plugin)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
QT += opengl
@@ -22,6 +22,6 @@ HEADERS = quikitsoftwareinputhandler.h
#add libz for freetype.
LIBS += -lz
-#include(../fontdatabases/basicunix/basicunix.pri)
+#load(qpa/fontdatabases/basicunix)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp
index 1e8c6c1bc5..459eefd599 100644
--- a/src/plugins/platforms/vnc/qvncintegration.cpp
+++ b/src/plugins/platforms/vnc/qvncintegration.cpp
@@ -173,6 +173,10 @@ QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const
return surface;
}
+QAbstractEventDispatcher *QVFbIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
{
diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h
index 3e13bc3b8d..dbdac51c73 100644
--- a/src/plugins/platforms/vnc/qvncintegration.h
+++ b/src/plugins/platforms/vnc/qvncintegration.h
@@ -74,7 +74,7 @@ private:
};
class QVNCIntegrationPrivate;
-
+class QAbstractEventDispatcher;
class QVNCIntegration : public QPlatformIntegration
{
@@ -85,6 +85,7 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QAbstractEventDispatcher createEventDispatcher() const;
QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp
index 8b25e054d1..37412b6bd1 100644
--- a/src/plugins/platforms/vnc/qvncserver.cpp
+++ b/src/plugins/platforms/vnc/qvncserver.cpp
@@ -43,7 +43,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qregexp.h>
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtGui/qpolygon.h>
#include <QtGui/qpainter.h>
diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro
index 85bffb0637..321cee4790 100644
--- a/src/plugins/platforms/vnc/vnc.pro
+++ b/src/plugins/platforms/vnc/vnc.pro
@@ -1,7 +1,7 @@
TARGET = qvncgraphicssystem
load(qt_plugin)
-QT += network
+QT += network core-private gui-private platformsupport-private
DESTDIR = $$QT.gui.plugins/platforms
diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
index d9b5fa9bff..20c3aa0bd9 100644
--- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
+++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
@@ -3,12 +3,10 @@ contains(QT_CONFIG, opengl) {
QT += opengl
HEADERS += \
- $$PWD/qwaylandglintegration.h \
- $$PWD/qwaylandglwindowsurface.h
+ $$PWD/qwaylandglintegration.h
SOURCES += \
- $$PWD/qwaylandglintegration.cpp \
- $$PWD/qwaylandglwindowsurface.cpp
+ $$PWD/qwaylandglintegration.cpp
QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG)
contains(QT_CONFIG, opengles2) {
@@ -22,6 +20,9 @@ SOURCES += \
QT_WAYLAND_GL_INTEGRATION = xcomposite_egl
CONFIG += xcomposite_egl
}
+ } else:mac {
+ QT_WAYLAND_GL_INTEGRATION = readback_cgl
+ CONFIG += readback_cgl
} else {
isEqual(QT_WAYLAND_GL_CONFIG, readback) {
QT_WAYLAND_GL_INTEGRATION = readback_glx
@@ -48,6 +49,10 @@ readback_glx {
include ($$PWD/readback_glx/readback_glx.pri)
}
+readback_cgl {
+ include ($$PWD/readback_cgl/readback_cgl.pri)
+}
+
xcomposite_glx {
include ($$PWD/xcomposite_glx/xcomposite_glx.pri)
}
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
index 4b50b4bd68..2b4f9fe028 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
@@ -44,7 +44,10 @@
class QWaylandWindow;
class QWaylandDisplay;
-class QWidget;
+class QWindow;
+
+class QPlatformGLContext;
+class QSurfaceFormat;
class QWaylandGLIntegration
{
@@ -54,7 +57,8 @@ public:
virtual void initialize() = 0;
- virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0;
+ virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
+ virtual QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const = 0;
static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay);
};
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
deleted file mode 100644
index fef07e6bf7..0000000000
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaylandglwindowsurface.h"
-
-#include "qwaylanddisplay.h"
-#include "qwaylandwindow.h"
-#include "qwaylandscreen.h"
-
-#include <QtOpenGL/QGLFramebufferObject>
-#include <QtOpenGL/QGLContext>
-
-#include <QtOpenGL/private/qglengineshadermanager_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
-{
-#if !defined(QT_OPENGL_ES_2)
- QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-#endif
- const GLenum target = GL_TEXTURE_2D;
- QRectF src = br.isEmpty()
- ? QRectF(QPointF(), texSize)
- : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size());
-
- if (target == GL_TEXTURE_2D) {
- qreal width = texSize.width();
- qreal height = texSize.height();
-
- src.setLeft(src.left() / width);
- src.setRight(src.right() / width);
- src.setTop(src.top() / height);
- src.setBottom(src.bottom() / height);
- }
-
- const GLfloat tx1 = src.left();
- const GLfloat tx2 = src.right();
- const GLfloat ty1 = src.top();
- const GLfloat ty2 = src.bottom();
-
- GLfloat texCoordArray[4*2] = {
- tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
- };
-
- GLfloat vertexArray[4*2];
- vertexArray[0] = rect.left(); vertexArray[1] = rect.top();
- vertexArray[2] = rect.right(); vertexArray[3] = rect.top();
- vertexArray[4] = rect.right(); vertexArray[5] = rect.bottom();
- vertexArray[6] = rect.left(); vertexArray[7] = rect.bottom();
-
- glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray);
- glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray);
-
- glBindTexture(target, tex_id);
-
- glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
-
- glBindTexture(target, 0);
-}
-
-static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
-{
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_BLEND);
- glViewport(0, 0, viewport.width(), viewport.height());
-
- QGLShaderProgram *blitProgram =
- QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
- blitProgram->bind();
- blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
-
- // The shader manager's blit program does not multiply the
- // vertices by the pmv matrix, so we need to do the effect
- // of the orthographic projection here ourselves.
- QRectF r;
- qreal w = viewport.width();
- qreal h = viewport.height();
- r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
- if (targetRect.right() == (viewport.width() - 1))
- r.setRight(1.0f);
- else
- r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
- r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
- if (targetRect.bottom() == (viewport.height() - 1))
- r.setTop(1.0f);
- else
- r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
-
- drawTexture(r, texture, texSize, sourceRect);
-}
-
-QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWidget *window)
- : QWindowSurface(window)
- , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
- , mPaintDevice(0)
-{
-
-}
-
-QWaylandGLWindowSurface::~QWaylandGLWindowSurface()
-{
- delete mPaintDevice;
-}
-
-QPaintDevice *QWaylandGLWindowSurface::paintDevice()
-{
- return mPaintDevice;
-}
-
-void QWaylandGLWindowSurface::beginPaint(const QRegion &)
-{
- window()->platformWindow()->glContext()->makeCurrent();
- glClearColor(0,0,0,0xff);
- glClear(GL_COLOR_BUFFER_BIT);
-}
-
-void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(offset);
- Q_UNUSED(region);
- QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();
-
- if (mPaintDevice->isBound())
- mPaintDevice->release();
-
- QRect rect(0,0,size().width(),size().height());
- QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext());
- blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
- ww->glContext()->swapBuffers();
-}
-
-void QWaylandGLWindowSurface::resize(const QSize &size)
-{
- QWindowSurface::resize(size);
- window()->platformWindow()->glContext()->makeCurrent();
- delete mPaintDevice;
- mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp
index 829996b0b0..d0712a3989 100644
--- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp
@@ -39,50 +39,68 @@
**
****************************************************************************/
-#include "qgraphicssystem_vg_p.h"
-#include <QtOpenVG/private/qpixmapdata_vg_p.h>
-#include <QtOpenVG/private/qwindowsurface_vg_p.h>
-#include <QtOpenVG/private/qvgimagepool_p.h>
-#if defined(Q_OS_SYMBIAN)
-#include <QtGui/private/qwidget_p.h>
-#endif
-#include <QtGui/private/qapplication_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QVGGraphicsSystem::QVGGraphicsSystem()
+#include "qwaylandreadbackcglcontext.h"
+
+#include "qwaylandshmbackingstore.h"
+#include "qwaylandreadbackcglwindow.h"
+
+#include <QtGui/QGuiGLContext>
+#include <QtCore/QDebug>
+
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/glext.h>
+#include <OpenGL/glu.h>
+
+#include <QtPlatformSupport/private/cglconvenience_p.h>
+
+QWaylandReadbackCGLContext::QWaylandReadbackCGLContext(QPlatformGLContext *share)
+ : QPlatformGLContext()
+{
+ Q_UNUSED(share);
+ m_glContext = qcgl_createGlContext();
+}
+
+QSurfaceFormat QWaylandReadbackCGLContext::format() const
{
- QApplicationPrivate::graphics_system_name = QLatin1String("openvg");
+ return qcgl_surfaceFormat();
}
-QPixmapData *QVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
+bool QWaylandReadbackCGLContext::makeCurrent(QPlatformSurface *surface)
{
-#if !defined(QVG_NO_SINGLE_CONTEXT) && !defined(QVG_NO_PIXMAP_DATA)
- // Pixmaps can use QVGPixmapData; bitmaps must use raster.
- if (type == QPixmapData::PixmapType)
- return new QVGPixmapData(type);
- else
- return new QRasterPixmapData(type);
-#else
- return new QRasterPixmapData(type);
-#endif
+ QWaylandReadbackCGLWindow *window = static_cast<QWaylandReadbackCGLWindow *>(surface);
+ CGLSetPBuffer(m_glContext, window->pixelBuffer(), 0, 0, 0);
+ CGLSetCurrentContext(m_glContext);
+ return true;
}
-QWindowSurface *QVGGraphicsSystem::createWindowSurface(QWidget *widget) const
+void QWaylandReadbackCGLContext::doneCurrent()
{
-#if defined(Q_OS_SYMBIAN)
- if (!QApplicationPrivate::instance()->useTranslucentEGLSurfaces) {
- QWidgetPrivate *d = qt_widget_private(widget);
- if (!d->isOpaque && widget->testAttribute(Qt::WA_TranslucentBackground))
- return d->createDefaultWindowSurface_sys();
+ CGLSetCurrentContext(0);
+}
+
+void QWaylandReadbackCGLContext::swapBuffers(QPlatformSurface *surface)
+{
+ Q_UNUSED(surface);
+
+ if (QGuiGLContext::currentContext()->handle() != this) {
+ makeCurrent(surface);
}
-#endif
- return new QVGWindowSurface(widget);
+ CGLFlushDrawable(m_glContext);
+
+ QWaylandReadbackCGLWindow *window = static_cast<QWaylandReadbackCGLWindow *>(surface);
+ QSize size = window->geometry().size();
+
+ uchar *dstBits = const_cast<uchar *>(window->buffer());
+ glReadPixels(0,0, size.width(), size.height(), GL_BGRA,GL_UNSIGNED_BYTE, dstBits);
+
+ window->damage(QRect(QPoint(0,0),size));
+
+ // ### Should sync here but this call deadlocks with the server.
+ //window->waitForFrameSync();
}
-void QVGGraphicsSystem::releaseCachedResources()
+void (*QWaylandReadbackCGLContext::getProcAddress(const QByteArray &procName)) ()
{
- QVGImagePool::instance()->hibernate();
+ return qcgl_getProcAddress(procName);
}
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h
index 00da6976b8..7f727ae8f9 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h
@@ -39,31 +39,34 @@
**
****************************************************************************/
-#ifndef QWAYLANDDRMSURFACE_H
-#define QWAYLANDDRMSURFACE_H
+#ifndef QWAYLANDREADBACKCGLCONTEXT_H
+#define QWAYLANDREADBACKCGLCONTEXT_H
-#include "qwaylanddisplay.h"
+#include <QPlatformGLContext>
-#include <QtGui/private/qwindowsurface_p.h>
+#include "qwaylandreadbackcglintegration.h"
-class QGLFramebufferObject;
+#include <OpenGL/OpenGL.h>
-class QWaylandGLWindowSurface : public QWindowSurface
+class QWaylandReadbackCGLWindow;
+class QWaylandShmBuffer;
+
+class QWaylandReadbackCGLContext : public QPlatformGLContext
{
public:
- QWaylandGLWindowSurface(QWidget *window);
- ~QWaylandGLWindowSurface();
+ QWaylandReadbackCGLContext(QPlatformGLContext *share);
- void beginPaint(const QRegion &);
+ QSurfaceFormat format() const;
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
+ void swapBuffers(QPlatformSurface *surface);
+ void (*getProcAddress(const QByteArray &procName)) ();
- void resize(const QSize &size);
+ void geometryChanged();
private:
- QWaylandDisplay *mDisplay;
- QGLFramebufferObject *mPaintDevice;
+ CGLContextObj m_glContext;
};
-#endif // QWAYLANDDRMSURFACE_H
+#endif // QWAYLANDREADBACKCGLCONTEXT_H
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp
index e5ac994a05..c9cc7b4fa1 100644
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp
@@ -39,46 +39,44 @@
**
****************************************************************************/
-#include "eglnullwswindowsurface.h"
-#include "eglnullwsscreenplugin.h"
+#include "qwaylandreadbackcglintegration.h"
+#include "qwaylandreadbackcglcontext.h"
+#include "qwaylandreadbackcglwindow.h"
-#include <QGLWidget>
+#include <QtCore/QDebug>
-static const QWSWindowSurface::SurfaceFlags Flags
- = QWSWindowSurface::RegionReserved | QWSWindowSurface::RegionReserved;
-
-EGLNullWSWindowSurface::EGLNullWSWindowSurface(QWidget *w)
- :
- QWSGLWindowSurface(w),
- widget(w)
+QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
{
- setSurfaceFlags(Flags);
+ return new QWaylandReadbackCGLIntegration(waylandDisplay);
}
-EGLNullWSWindowSurface::EGLNullWSWindowSurface()
- : widget(0)
+QWaylandReadbackCGLIntegration::QWaylandReadbackCGLIntegration(QWaylandDisplay * waylandDispaly)
+ : QWaylandGLIntegration()
+ , mWaylandDisplay(waylandDispaly)
{
- setSurfaceFlags(Flags);
+ qDebug() << "Using Readback-CGL";
}
-EGLNullWSWindowSurface::~EGLNullWSWindowSurface() {}
+QWaylandReadbackCGLIntegration::~QWaylandReadbackCGLIntegration()
+{
+
+}
-QString EGLNullWSWindowSurface::key() const
+void QWaylandReadbackCGLIntegration::initialize()
{
- return QLatin1String(PluginName);
}
-QPaintDevice *EGLNullWSWindowSurface::paintDevice()
+QWaylandWindow * QWaylandReadbackCGLIntegration::createEglWindow(QWindow *window)
{
- return widget;
+ return new QWaylandReadbackCGLWindow(window,this);
}
-bool EGLNullWSWindowSurface::isValid() const
+QPlatformGLContext *QWaylandReadbackCGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
- return qobject_cast<QGLWidget *>(window());
+ return new QWaylandReadbackCGLContext(share);
}
-QImage EGLNullWSWindowSurface::image() const
+QWaylandDisplay * QWaylandReadbackCGLIntegration::waylandDisplay() const
{
- return QImage();
+ return mWaylandDisplay;
}
diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h
index 6f8f8dce66..63b95f5efa 100644
--- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h
@@ -39,35 +39,33 @@
**
****************************************************************************/
-#ifndef QGRAPHICSSYSTEM_VG_P_H
-#define QGRAPHICSSYSTEM_VG_P_H
+#ifndef QWAYLANDREADBACKGLXINTEGRATION_H
+#define QWAYLANDREADBACKGLXINTEGRATION_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#include "gl_integration/qwaylandglintegration.h"
-#include <QtGui/private/qgraphicssystem_p.h>
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+#include <QtGui/QWindow>
-QT_BEGIN_NAMESPACE
+#include <X11/Xlib.h>
-class QVGGraphicsSystem : public QGraphicsSystem
+class QWaylandReadbackCGLIntegration : public QWaylandGLIntegration
{
public:
- QVGGraphicsSystem();
+ QWaylandReadbackCGLIntegration(QWaylandDisplay * waylandDispaly);
+ ~QWaylandReadbackCGLIntegration();
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
+ void initialize();
- void releaseCachedResources();
-};
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
+ QWaylandDisplay *waylandDisplay() const;
-QT_END_NAMESPACE
+private:
+ QWaylandDisplay *mWaylandDisplay;
+};
-#endif
+#endif // QWAYLANDREADBACKGLXINTEGRATION_H
diff --git a/src/plugins/graphicssystems/opengl/main.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp
index ee0fa802dd..9e7f8520c9 100644
--- a/src/plugins/graphicssystems/opengl/main.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp
@@ -39,57 +39,68 @@
**
****************************************************************************/
-#include <private/qgraphicssystemplugin_p.h>
-#include <private/qgraphicssystem_gl_p.h>
-#include <qgl.h>
+#include "qwaylandreadbackcglwindow.h"
+#include "qwaylandshmbackingstore.h"
-QT_BEGIN_NAMESPACE
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/glext.h>
-class QGLGraphicsSystemPlugin : public QGraphicsSystemPlugin
+QWaylandReadbackCGLWindow::QWaylandReadbackCGLWindow(QWindow *window, QWaylandReadbackCGLIntegration *cglIntegration)
+ : QWaylandShmWindow(window)
+ , m_CglIntegration(cglIntegration)
+ , mContext(0)
+ , m_buffer(0)
+ , m_pixelBuffer(0)
{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
+}
-QStringList QGLGraphicsSystemPlugin::keys() const
+QWaylandWindow::WindowType QWaylandReadbackCGLWindow::windowType() const
{
- QStringList list;
- list << QLatin1String("OpenGL") << QLatin1String("OpenGL1");
-#if !defined(QT_OPENGL_ES_1)
- list << QLatin1String("OpenGL2");
-#endif
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- list << QLatin1String("X11GL");
-#endif
- return list;
+ //yeah. this type needs a new name
+ return QWaylandWindow::Egl;
}
-QGraphicsSystem* QGLGraphicsSystemPlugin::create(const QString& system)
+
+void QWaylandReadbackCGLWindow::setGeometry(const QRect &rect)
{
- if (system.toLower() == QLatin1String("opengl1")) {
- QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);
- return new QGLGraphicsSystem(false);
- }
+ QWaylandShmWindow::setGeometry(rect);
+
+ if (m_buffer) {
+ delete m_buffer;
+ m_buffer = 0;
-#if !defined(QT_OPENGL_ES_1)
- if (system.toLower() == QLatin1String("opengl2")) {
- QGL::setPreferredPaintEngine(QPaintEngine::OpenGL2);
- return new QGLGraphicsSystem(false);
+ CGLDestroyPBuffer(m_pixelBuffer);
+ m_pixelBuffer = 0;
}
-#endif
+}
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (system.toLower() == QLatin1String("x11gl"))
- return new QGLGraphicsSystem(true);
-#endif
+CGLPBufferObj QWaylandReadbackCGLWindow::pixelBuffer()
+{
+ if (!m_pixelBuffer)
+ createSurface();
- if (system.toLower() == QLatin1String("opengl"))
- return new QGLGraphicsSystem(false);
+ return m_pixelBuffer;
+}
- return 0;
+uchar *QWaylandReadbackCGLWindow::buffer()
+{
+ return m_buffer->image()->bits();
}
-Q_EXPORT_PLUGIN2(opengl, QGLGraphicsSystemPlugin)
+void QWaylandReadbackCGLWindow::createSurface()
+{
+ QSize size(geometry().size());
+ if (size.isEmpty()) {
+ //QGLWidget wants a context for a window without geometry
+ size = QSize(1,1);
+ }
+
+ waitForFrameSync();
+
+ CGLCreatePBuffer(size.width(), size.height(), GL_TEXTURE_RECTANGLE_ARB, GL_BGRA, 0, &m_pixelBuffer);
+
+ delete m_buffer;
+ m_buffer = new QWaylandShmBuffer(m_CglIntegration->waylandDisplay(),size,QImage::Format_ARGB32);
+ attach(m_buffer);
+}
-QT_END_NAMESPACE
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h
index bdb1d42d7e..0598cf9037 100644
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h
@@ -39,25 +39,32 @@
**
****************************************************************************/
-#ifndef EGLNULLWSWINDOWSURFACE_H
-#define EGLNULLWSWINDOWSURFACE_H
+#ifndef QWAYLANDREADBACKGLXWINDOW_H
+#define QWAYLANDREADBACKGLXWINDOW_H
-#include <private/qglwindowsurface_qws_p.h>
+#include "qwaylandshmwindow.h"
+#include "qwaylandreadbackcglintegration.h"
+#include "qwaylandreadbackcglcontext.h"
-class EGLNullWSWindowSurface : public QWSGLWindowSurface
+#include <OpenGL/OpenGL.h>
+
+class QWaylandReadbackCGLWindow : public QWaylandShmWindow
{
public:
- EGLNullWSWindowSurface(QWidget *widget);
- EGLNullWSWindowSurface();
- virtual ~EGLNullWSWindowSurface();
-
- virtual QString key() const;
- virtual QPaintDevice *paintDevice();
- virtual bool isValid() const;
- virtual QImage image() const;
+ QWaylandReadbackCGLWindow(QWindow *window, QWaylandReadbackCGLIntegration *cglIntegration);
+ WindowType windowType() const;
+ void setGeometry(const QRect &rect);
+ CGLPBufferObj pixelBuffer();
+ uchar *buffer();
private:
- QWidget *widget;
+ void createSurface();
+
+ QWaylandReadbackCGLIntegration *m_CglIntegration;
+ QWaylandReadbackCGLContext *mContext;
+
+ QWaylandShmBuffer *m_buffer;
+ CGLPBufferObj m_pixelBuffer;
};
-#endif // EGLNULLWSWINDOWSURFACE_H
+#endif // QWAYLANDREADBACKGLXWINDOW_H
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri b/src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri
new file mode 100644
index 0000000000..91cb90a30c
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri
@@ -0,0 +1,10 @@
+HEADERS += \
+ $$PWD/qwaylandreadbackcglintegration.h \
+ $$PWD/qwaylandreadbackcglwindow.h \
+ $$PWD/qwaylandreadbackcglcontext.h
+
+SOURCES += \
+ $$PWD/qwaylandreadbackcglintegration.cpp \
+ $$PWD/qwaylandreadbackcglwindow.cpp \
+ $$PWD/qwaylandreadbackcglcontext.cpp
+
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp
index f02a10a05b..cd6ab188f7 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp
@@ -41,14 +41,16 @@
#include "qwaylandreadbackeglcontext.h"
-#include "../../../eglconvenience/qeglconvenience.h"
+#include <QPlatformSupport/eglconvenience/qeglconvenience_p.h>
+
+#include <QtCore/QDebug>
+#include <QtGui/QWindowContext>
#include <QtOpenGL/QGLContext>
#include <QtOpenGL/private/qglextensions_p.h>
#include "qwaylandshmsurface.h"
-#include <QtCore/QDebug>
static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
{
@@ -77,7 +79,7 @@ QWaylandReadbackEglContext::QWaylandReadbackEglContext(QWaylandReadbackEglIntegr
, mWindow(window)
, mBuffer(0)
, mPixmap(0)
- , mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT))
+ , mConfig(q_configFromQWindowFormat(eglIntegration->eglDisplay(),window->window()->requestedWindowFormat(),true,EGL_PIXMAP_BIT))
, mPixmapSurface(EGL_NO_SURFACE)
{
QVector<EGLint> eglContextAttrs;
@@ -97,8 +99,6 @@ QWaylandReadbackEglContext::~QWaylandReadbackEglContext()
void QWaylandReadbackEglContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
-
mWindow->waitForFrameSync();
eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext);
@@ -114,7 +114,7 @@ void QWaylandReadbackEglContext::swapBuffers()
{
eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface);
- if (QPlatformGLContext::currentContext() != this) {
+ if (QWindowContext::currentContext()->handle() != this) {
makeCurrent();
}
@@ -143,9 +143,9 @@ void * QWaylandReadbackEglContext::getProcAddress(const QString &procName)
return (void *) eglGetProcAddress(procName.toLatin1().data());
}
-QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const
+QWindowFormat QWaylandReadbackEglContext::windowFormat() const
{
- return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
+ return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
}
void QWaylandReadbackEglContext::geometryChanged()
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
index f9ab3783dd..f57ac46667 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
@@ -43,7 +43,6 @@
#define QWAYLANDREADBACKEGLGLCONTEXT_H
#include <QPlatformGLContext>
-#include <QtGui/QWidget>
#include "qwaylandreadbackeglintegration.h"
#include "qwaylandreadbackeglwindow.h"
@@ -61,7 +60,7 @@ public:
void swapBuffers();
void* getProcAddress(const QString& procName);
- virtual QPlatformWindowFormat platformWindowFormat() const;
+ virtual QWindowFormat windowFormat() const;
void geometryChanged();
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
index 6bbac603cf..773087f513 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
@@ -81,9 +81,14 @@ void QWaylandReadbackEglIntegration::initialize()
}
}
-QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandReadbackEglWindow(widget,this);
+ return new QWaylandReadbackEglWindow(window, this);
+}
+
+QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
+{
+ return new QWaylandReadbackEglContext(glFormat, share, this);
}
EGLDisplay QWaylandReadbackEglIntegration::eglDisplay()
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
index ae1e8e5095..d96e6cface 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
@@ -48,7 +48,8 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtCore/QEvent>
+#include <QtGui/QCursor>
#include <X11/Xlib.h>
@@ -61,7 +62,8 @@ public:
~QWaylandReadbackEglIntegration();
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
Display *xDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp
index 868e32e030..39ccafec5c 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp
@@ -43,7 +43,7 @@
#include "qwaylandreadbackeglcontext.h"
-QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration)
+QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration)
: QWaylandShmWindow(window)
, mEglIntegration(eglIntegration)
, mContext(0)
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
index 1433483923..63ab7a55ae 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
@@ -50,7 +50,7 @@ class QWaylandReadbackEglContext;
class QWaylandReadbackEglWindow : public QWaylandShmWindow
{
public:
- QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration);
+ QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration);
WindowType windowType() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri b/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri
index 0d8e01b6bb..3325fe8ec9 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri
@@ -1,14 +1,12 @@
-
LIBS += -lX11 -lXext -lEGL
+load(qpa/egl/convenience)
HEADERS += \
$$PWD/qwaylandreadbackeglintegration.h \
$$PWD/qwaylandreadbackeglcontext.h \
$$PWD/qwaylandreadbackeglwindow.h \
- $$PWD/../../../eglconvenience/qeglconvenience.h
SOURCES += \
$$PWD/qwaylandreadbackeglintegration.cpp \
$$PWD/qwaylandreadbackeglwindow.cpp \
$$PWD/qwaylandreadbackeglcontext.cpp \
- $$PWD/../../../eglconvenience/qeglconvenience.cpp
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
index 857c1db6e3..dec2cdd428 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
@@ -41,9 +41,10 @@
#include "qwaylandreadbackglxcontext.h"
-#include "qwaylandshmsurface.h"
+#include "qwaylandshmbackingstore.h"
#include "qwaylandreadbackglxwindow.h"
+#include <QtGui/QGuiGLContext>
#include <QtCore/QDebug>
static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
@@ -68,96 +69,66 @@ static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
}
}
-QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window)
- : QPlatformGLContext()
- , mGlxIntegration(glxIntegration)
- , mWindow(window)
- , mBuffer(0)
- , mPixmap(0)
- , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat(),GLX_PIXMAP_BIT))
- , mGlxPixmap(0)
+QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QSurfaceFormat &format,
+ QPlatformGLContext *share, Display *display, int screen)
+ : m_display(display)
{
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig);
- mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE);
+ GLXFBConfig config = qglx_findConfig(display, screen, format, GLX_PIXMAP_BIT);
- geometryChanged();
+ GLXContext shareContext = share ? static_cast<QWaylandReadbackGlxContext *>(share)->m_context : 0;
+
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
+ m_context = glXCreateContext(display, visualInfo, shareContext, TRUE);
+ m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context);
+}
+
+QSurfaceFormat QWaylandReadbackGlxContext::format() const
+{
+ return m_format;
}
-void QWaylandReadbackGlxContext::makeCurrent()
+bool QWaylandReadbackGlxContext::makeCurrent(QPlatformSurface *surface)
{
- QPlatformGLContext::makeCurrent();
+ GLXPixmap glxPixmap = static_cast<QWaylandReadbackGlxWindow *>(surface)->glxPixmap();
- glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext);
+ return glXMakeCurrent(m_display, glxPixmap, m_context);
}
void QWaylandReadbackGlxContext::doneCurrent()
{
- QPlatformGLContext::doneCurrent();
+ glXMakeCurrent(m_display, 0, 0);
}
-void QWaylandReadbackGlxContext::swapBuffers()
+void QWaylandReadbackGlxContext::swapBuffers(QPlatformSurface *surface)
{
- if (QPlatformGLContext::currentContext() != this) {
- makeCurrent();
- }
+ // #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext()
+ if (QGuiGLContext::currentContext()->handle() != this)
+ makeCurrent(surface);
+
+ QWaylandReadbackGlxWindow *w = static_cast<QWaylandReadbackGlxWindow *>(surface);
- QSize size = mWindow->geometry().size();
+ QSize size = w->geometry().size();
- QImage img(size,QImage::Format_ARGB32);
+ QImage img(size, QImage::Format_ARGB32);
const uchar *constBits = img.bits();
void *pixels = const_cast<uchar *>(constBits);
- glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels);
+ glReadPixels(0, 0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels);
img = img.mirrored();
- qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV);
+ qgl_byteSwapImage(img, GL_UNSIGNED_INT_8_8_8_8_REV);
constBits = img.bits();
- const uchar *constDstBits = mBuffer->image()->bits();
+ const uchar *constDstBits = w->buffer();
uchar *dstBits = const_cast<uchar *>(constDstBits);
- memcpy(dstBits,constBits,(img.width()*4) * img.height());
+ memcpy(dstBits, constBits, (img.width() * 4) * img.height());
+ w->damage(QRect(QPoint(), size));
- mWindow->damage(QRegion(QRect(QPoint(0,0),size)));
- mWindow->waitForFrameSync();
-
+ w->waitForFrameSync();
}
-void * QWaylandReadbackGlxContext::getProcAddress(const QString &procName)
+void (*QWaylandReadbackGlxContext::getProcAddress(const QByteArray &procName)) ()
{
- return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data()));
-}
-
-QPlatformWindowFormat QWaylandReadbackGlxContext::platformWindowFormat() const
-{
- return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext);
-}
-
-void QWaylandReadbackGlxContext::geometryChanged()
-{
- QSize size(mWindow->geometry().size());
- if (size.isEmpty()) {
- //QGLWidget wants a context for a window without geometry
- size = QSize(1,1);
- }
-
- mWindow->waitForFrameSync();
-
- delete mBuffer;
- //XFreePixmap deletes the glxPixmap as well
- if (mPixmap) {
- XFreePixmap(mGlxIntegration->xDisplay(),mPixmap);
- }
-
- mBuffer = new QWaylandShmBuffer(mGlxIntegration->waylandDisplay(),size,QImage::Format_ARGB32);
- mWindow->attach(mBuffer);
- int depth = XDefaultDepth(mGlxIntegration->xDisplay(),mGlxIntegration->screen());
- mPixmap = XCreatePixmap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),size.width(),size.height(),depth);
- XSync(mGlxIntegration->xDisplay(),False);
-
- mGlxPixmap = glXCreatePixmap(mGlxIntegration->xDisplay(),mConfig,mPixmap,0);
-
- if (!mGlxPixmap) {
- qDebug() << "Could not make egl surface out of pixmap :(";
- }
+ return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName.constData()));
}
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
index 07e0f620de..d3a028f51a 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
@@ -43,10 +43,11 @@
#define QWAYLANDREADBACKGLXCONTEXT_H
#include <QPlatformGLContext>
+#include <QSurfaceFormat>
#include "qwaylandreadbackglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
class QWaylandReadbackGlxWindow;
class QWaylandShmBuffer;
@@ -54,26 +55,22 @@ class QWaylandShmBuffer;
class QWaylandReadbackGlxContext : public QPlatformGLContext
{
public:
- QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window);
+ QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen);
- void makeCurrent();
- void doneCurrent();
- void swapBuffers();
- void* getProcAddress(const QString& procName);
+ QSurfaceFormat format() const;
+
+ void swapBuffers(QPlatformSurface *surface);
- QPlatformWindowFormat platformWindowFormat() const;
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
- void geometryChanged();
+ void (*getProcAddress(const QByteArray &procName)) ();
private:
- QWaylandReadbackGlxIntegration *mGlxIntegration;
- QWaylandReadbackGlxWindow *mWindow;
- QWaylandShmBuffer *mBuffer;
+ GLXContext m_context;
- Pixmap mPixmap;
- GLXFBConfig mConfig;
- GLXContext mContext;
- GLXPixmap mGlxPixmap;
+ Display *m_display;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDREADBACKGLXCONTEXT_H
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
index 37a14a9f4c..22ff5dc0c6 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
@@ -66,9 +66,14 @@ void QWaylandReadbackGlxIntegration::initialize()
{
}
-QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandReadbackGlxWindow(widget,this);
+ return new QWaylandReadbackGlxWindow(window,this);
+}
+
+QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
+{
+ return new QWaylandReadbackGlxContext(glFormat, share, mDisplay, mScreen);
}
QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
index d267d8dffe..05c224263b 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
@@ -48,7 +48,7 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
#include <X11/Xlib.h>
@@ -60,7 +60,8 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
index 98198dfa06..35c3ca3154 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
@@ -39,12 +39,19 @@
**
****************************************************************************/
+#include <QtDebug>
+
#include "qwaylandreadbackglxwindow.h"
+#include "qwaylandshmbackingstore.h"
-QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration)
+QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration)
: QWaylandShmWindow(window)
- , mGlxIntegration(glxIntegration)
- , mContext(0)
+ , m_glxIntegration(glxIntegration)
+ , m_buffer(0)
+ , m_pixmap(0)
+ , m_config(0)
+ , m_glxPixmap(0)
+ , m_window(window)
{
}
@@ -54,20 +61,54 @@ QWaylandWindow::WindowType QWaylandReadbackGlxWindow::windowType() const
return QWaylandWindow::Egl;
}
-QPlatformGLContext * QWaylandReadbackGlxWindow::glContext() const
+void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect)
{
- if (!mContext) {
- QWaylandReadbackGlxWindow *that = const_cast<QWaylandReadbackGlxWindow *>(this);
- that->mContext = new QWaylandReadbackGlxContext(mGlxIntegration,that);
+ QWaylandShmWindow::setGeometry(rect);
+
+ if (m_pixmap) {
+ delete mBuffer;
+ //XFreePixmap deletes the glxPixmap as well
+ XFreePixmap(m_glxIntegration->xDisplay(), m_pixmap);
+ m_pixmap = 0;
}
- return mContext;
}
-void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect)
+GLXPixmap QWaylandReadbackGlxWindow::glxPixmap() const
{
- QWaylandShmWindow::setGeometry(rect);
+ if (!m_pixmap)
+ const_cast<QWaylandReadbackGlxWindow *>(this)->createSurface();
+
+ return m_glxPixmap;
+}
- if (mContext) {
- mContext->geometryChanged();
+uchar *QWaylandReadbackGlxWindow::buffer()
+{
+ return m_buffer->image()->bits();
+}
+
+void QWaylandReadbackGlxWindow::createSurface()
+{
+ QSize size(geometry().size());
+ if (size.isEmpty()) {
+ //QGLWidget wants a context for a window without geometry
+ size = QSize(1,1);
}
+
+ waitForFrameSync();
+
+ m_buffer = new QWaylandShmBuffer(m_glxIntegration->waylandDisplay(), size, QImage::Format_ARGB32);
+ attach(m_buffer);
+
+ int depth = XDefaultDepth(m_glxIntegration->xDisplay(), m_glxIntegration->screen());
+ m_pixmap = XCreatePixmap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), size.width(), size.height(), depth);
+ XSync(m_glxIntegration->xDisplay(), False);
+
+ if (!m_config)
+ m_config = qglx_findConfig(m_glxIntegration->xDisplay(), m_glxIntegration->screen(), m_window->format());
+
+ m_glxPixmap = glXCreatePixmap(m_glxIntegration->xDisplay(), m_config, m_pixmap,0);
+
+ if (!m_glxPixmap)
+ qDebug() << "Could not make glx surface out of pixmap :(";
}
+
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
index d478961d53..c92646c80d 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
@@ -49,17 +49,25 @@
class QWaylandReadbackGlxWindow : public QWaylandShmWindow
{
public:
- QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration);
+ QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLContext *glContext() const;
-
void setGeometry(const QRect &rect);
+ Pixmap glxPixmap() const;
+
+ uchar *buffer();
+
private:
- QWaylandReadbackGlxIntegration *mGlxIntegration;
- QWaylandReadbackGlxContext *mContext;
+ void createSurface();
+
+ QWaylandReadbackGlxIntegration *m_glxIntegration;
+ QWaylandShmBuffer *m_buffer;
+ Pixmap m_pixmap;
+ GLXFBConfig m_config;
+ GLXPixmap m_glxPixmap;
+ QWindow *m_window;
};
#endif // QWAYLANDREADBACKGLXWINDOW_H
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri
index f8ea005937..746d594fa2 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri
@@ -1,4 +1,3 @@
-include (../../../glxconvenience/glxconvenience.pri)
HEADERS += \
$$PWD/qwaylandreadbackglxintegration.h \
$$PWD/qwaylandreadbackglxwindow.h \
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
index d4deb01022..ab154017ec 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
@@ -44,11 +44,12 @@
#include "gl_integration/qwaylandglintegration.h"
#include "qwaylandeglwindow.h"
+#include "qwaylandglcontext.h"
#include <QtCore/QDebug>
QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay)
- : mWaylandDisplay(waylandDisplay)
+ : m_waylandDisplay(waylandDisplay)
{
qDebug() << "Using Wayland-EGL";
}
@@ -56,31 +57,36 @@ QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay
QWaylandEglIntegration::~QWaylandEglIntegration()
{
- eglTerminate(mEglDisplay);
+ eglTerminate(m_eglDisplay);
}
void QWaylandEglIntegration::initialize()
{
EGLint major,minor;
- mEglDisplay = eglGetDisplay(mWaylandDisplay);
- if (mEglDisplay == NULL) {
+ m_eglDisplay = eglGetDisplay(m_waylandDisplay);
+ if (m_eglDisplay == NULL) {
qWarning("EGL not available");
} else {
- if (!eglInitialize(mEglDisplay, &major, &minor)) {
+ if (!eglInitialize(m_eglDisplay, &major, &minor)) {
qWarning("failed to initialize EGL display");
return;
}
}
}
-QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWidget *window)
+QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window)
{
return new QWaylandEglWindow(window);
}
+QPlatformGLContext *QWaylandEglIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
+{
+ return new QWaylandGLContext(m_eglDisplay, glFormat, share);
+}
+
EGLDisplay QWaylandEglIntegration::eglDisplay() const
{
- return mEglDisplay;
+ return m_eglDisplay;
}
QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
index ea8b0f725c..5e39e39fe8 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
@@ -47,7 +47,7 @@
#include "qwaylandeglinclude.h"
class QWaylandWindow;
-class QWidget;
+class QWindow;
class QWaylandEglIntegration : public QWaylandGLIntegration
{
@@ -57,14 +57,15 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *window);
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
EGLDisplay eglDisplay() const;
- struct wl_egl_display *nativeDisplay() const;
+
private:
- struct wl_display *mWaylandDisplay;
+ struct wl_display *m_waylandDisplay;
- EGLDisplay mEglDisplay;
+ EGLDisplay m_eglDisplay;
};
#endif // QWAYLANDEGLINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
index cd8b5b3524..245097ef6c 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
@@ -44,19 +44,29 @@
#include "qwaylandscreen.h"
#include "qwaylandglcontext.h"
-QWaylandEglWindow::QWaylandEglWindow(QWidget *window)
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+
+#include <QtGui/QWindow>
+
+QWaylandEglWindow::QWaylandEglWindow(QWindow *window)
: QWaylandWindow(window)
- , mGLContext(0)
- , mWaylandEglWindow(0)
+ , m_waylandEglWindow(0)
+ , m_eglSurface(0)
+ , m_eglConfig(0)
+ , m_format(window->format())
{
- mEglIntegration = static_cast<QWaylandEglIntegration *>(mDisplay->eglIntegration());
+ m_eglIntegration = static_cast<QWaylandEglIntegration *>(mDisplay->eglIntegration());
+
//super creates a new surface
newSurfaceCreated();
}
QWaylandEglWindow::~QWaylandEglWindow()
{
- delete mGLContext;
+ if (m_eglSurface) {
+ eglDestroySurface(m_eglIntegration->eglDisplay(), m_eglSurface);
+ m_eglSurface = 0;
+ }
}
QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
@@ -67,46 +77,46 @@ QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
void QWaylandEglWindow::setGeometry(const QRect &rect)
{
QWaylandWindow::setGeometry(rect);
- if (mWaylandEglWindow) {
- wl_egl_window_resize(mWaylandEglWindow,rect.width(),rect.height(),0,0);
- }
+ if (m_waylandEglWindow)
+ wl_egl_window_resize(m_waylandEglWindow, rect.width(), rect.height(), 0, 0);
}
-void QWaylandEglWindow::setParent(const QPlatformWindow *parent)
+void QWaylandEglWindow::newSurfaceCreated()
{
- const QWaylandWindow *wParent = static_cast<const QWaylandWindow *>(parent);
+ if (m_waylandEglWindow)
+ wl_egl_window_destroy(m_waylandEglWindow);
- mParentWindow = wParent;
-}
-
-QPlatformGLContext * QWaylandEglWindow::glContext() const
-{
- if (!mGLContext) {
- QWaylandEglWindow *that = const_cast<QWaylandEglWindow *>(this);
- that->mGLContext = new QWaylandGLContext(mEglIntegration->eglDisplay(),widget()->platformWindowFormat());
+ wl_visual *visual = QWaylandScreen::waylandScreenFromWindow(window())->visual();
+ QSize size = geometry().size();
+ if (!size.isValid())
+ size = QSize(0,0);
- EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
- EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
- that->mGLContext->setEglSurface(surface);
+ if (m_eglSurface) {
+ eglDestroySurface(m_eglIntegration->eglDisplay(), m_eglSurface);
+ m_eglSurface = 0;
}
- return mGLContext;
+ m_waylandEglWindow = wl_egl_window_create(mSurface, size.width(), size.height(), visual);
}
-void QWaylandEglWindow::newSurfaceCreated()
+QSurfaceFormat QWaylandEglWindow::format() const
{
- if (mWaylandEglWindow) {
- wl_egl_window_destroy(mWaylandEglWindow);
- }
- wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual();
- QSize size = geometry().size();
- if (!size.isValid())
- size = QSize(0,0);
+ return m_format;
+}
- mWaylandEglWindow = wl_egl_window_create(mSurface,size.width(),size.height(),visual);
- if (mGLContext) {
- EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
- EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
- mGLContext->setEglSurface(surface);
+EGLSurface QWaylandEglWindow::eglSurface() const
+{
+ if (!m_waylandEglWindow)
+ return 0;
+
+ if (!m_eglSurface) {
+ if (!m_eglConfig)
+ m_eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), window()->format(), true);
+
+ EGLNativeWindowType window = m_waylandEglWindow;
+ m_eglSurface = eglCreateWindowSurface(m_eglIntegration->eglDisplay(), m_eglConfig, window, 0);
}
+
+ return m_eglSurface;
}
+
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
index 6d2038824a..d435a511c4 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
@@ -51,20 +51,28 @@ class QWaylandGLContext;
class QWaylandEglWindow : public QWaylandWindow
{
public:
- QWaylandEglWindow(QWidget *window);
+ QWaylandEglWindow(QWindow *window);
~QWaylandEglWindow();
WindowType windowType() const;
void setGeometry(const QRect &rect);
- void setParent(const QPlatformWindow *parent);
- QPlatformGLContext *glContext() const;
+
+ EGLSurface eglSurface() const;
+
+ QSurfaceFormat format() const;
+
protected:
void newSurfaceCreated();
+
private:
- QWaylandEglIntegration *mEglIntegration;
- QWaylandGLContext *mGLContext;
- struct wl_egl_window *mWaylandEglWindow;
+ QWaylandEglIntegration *m_eglIntegration;
+ struct wl_egl_window *m_waylandEglWindow;
+
+ const QWaylandWindow *m_parentWindow;
+
+ mutable EGLSurface m_eglSurface;
+ mutable EGLConfig m_eglConfig;
- const QWaylandWindow *mParentWindow;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDEGLWINDOW_H
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
index 0f27501c71..d3ece7c7a9 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
@@ -43,26 +43,21 @@
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
+#include "qwaylandeglwindow.h"
-#include "../../../eglconvenience/qeglconvenience.h"
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtGui/QPlatformGLContext>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtCore/QMutex>
-QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format)
+QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformGLContext *share)
: QPlatformGLContext()
- , mEglDisplay(eglDisplay)
- , mSurface(EGL_NO_SURFACE)
- , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true))
- , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig))
+ , m_eglDisplay(eglDisplay)
+ , m_config(q_configFromGLFormat(m_eglDisplay, format, true))
+ , m_format(q_glFormatFromConfig(m_eglDisplay, m_config))
{
- QPlatformGLContext *sharePlatformContext = 0;
- sharePlatformContext = format.sharedGLContext();
- mFormat.setSharedContext(sharePlatformContext);
- EGLContext shareEGLContext = EGL_NO_CONTEXT;
- if (sharePlatformContext)
- shareEGLContext = static_cast<const QWaylandGLContext*>(sharePlatformContext)->mContext;
+ EGLContext shareEGLContext = share ? static_cast<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
eglBindAPI(EGL_OPENGL_ES_API);
@@ -71,63 +66,38 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo
eglContextAttrs.append(2);
eglContextAttrs.append(EGL_NONE);
- mContext = eglCreateContext(mEglDisplay, mConfig,
- shareEGLContext, eglContextAttrs.constData());
+ m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData());
}
-QWaylandGLContext::QWaylandGLContext()
- : QPlatformGLContext()
- , mEglDisplay(0)
- , mContext(EGL_NO_CONTEXT)
- , mSurface(EGL_NO_SURFACE)
- , mConfig(0)
-{ }
-
QWaylandGLContext::~QWaylandGLContext()
{
- eglDestroyContext(mEglDisplay,mContext);
+ eglDestroyContext(m_eglDisplay, m_context);
}
-void QWaylandGLContext::makeCurrent()
+bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
{
- QPlatformGLContext::makeCurrent();
- if (mSurface == EGL_NO_SURFACE) {
- qWarning("makeCurrent with EGL_NO_SURFACE");
- }
- eglMakeCurrent(mEglDisplay, mSurface, mSurface, mContext);
+ EGLSurface eglSurface = static_cast<QWaylandEglWindow *>(surface)->eglSurface();
+ return eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_context);
}
void QWaylandGLContext::doneCurrent()
{
- QPlatformGLContext::doneCurrent();
- eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-}
-
-void QWaylandGLContext::swapBuffers()
-{
- eglSwapBuffers(mEglDisplay,mSurface);
+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
-void *QWaylandGLContext::getProcAddress(const QString &string)
+void QWaylandGLContext::swapBuffers(QPlatformSurface *surface)
{
- return (void *) eglGetProcAddress(string.toLatin1().data());
+ EGLSurface eglSurface = static_cast<QWaylandEglWindow *>(surface)->eglSurface();
+ eglSwapBuffers(m_eglDisplay, eglSurface);
}
-void QWaylandGLContext::setEglSurface(EGLSurface surface)
+void (*QWaylandGLContext::getProcAddress(const QByteArray &procName)) ()
{
- bool wasCurrent = false;
- if (QPlatformGLContext::currentContext() == this) {
- wasCurrent = true;
- doneCurrent();
- }
- mSurface = surface;
- if (wasCurrent) {
- makeCurrent();
- }
+ return eglGetProcAddress(procName.constData());
}
EGLConfig QWaylandGLContext::eglConfig() const
{
- return mConfig;
+ return m_config;
}
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h
index 2c6feb498c..592f3d18f5 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h
@@ -53,27 +53,27 @@ class QWaylandGLWindowSurface;
class QWaylandGLContext : public QPlatformGLContext {
public:
- QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format);
+ QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformGLContext *share);
~QWaylandGLContext();
- void makeCurrent();
+
+ void swapBuffers(QPlatformSurface *surface);
+
+ bool makeCurrent(QPlatformSurface *surface);
void doneCurrent();
- void swapBuffers();
- void* getProcAddress(const QString&);
- QPlatformWindowFormat platformWindowFormat() const { return mFormat; }
+ void (*getProcAddress(const QByteArray &procName)) ();
- void setEglSurface(EGLSurface surface);
- EGLConfig eglConfig() const;
-private:
- EGLDisplay mEglDisplay;
+ QSurfaceFormat format() const { return m_format; }
- EGLContext mContext;
- EGLSurface mSurface;
- EGLConfig mConfig;
- QPlatformWindowFormat mFormat;
+ EGLConfig eglConfig() const;
+ EGLContext eglContext() const { return m_context; }
- QWaylandGLContext();
+private:
+ EGLDisplay m_eglDisplay;
+ EGLContext m_context;
+ EGLConfig m_config;
+ QSurfaceFormat m_format;
};
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
index cd0701150f..6f4edb08a6 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
@@ -1,4 +1,4 @@
-include (../../../eglconvenience/eglconvenience.pri)
+load(qpa/egl/convenience)
LIBS += -lwayland-egl -lEGL
INCLUDEPATH += $$PWD
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
index 999a411397..6c1018d79a 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
@@ -42,128 +42,31 @@
#include "qwaylandxcompositeeglcontext.h"
#include "qwaylandxcompositeeglwindow.h"
-#include "qwaylandxcompositebuffer.h"
-#include "wayland-xcomposite-client-protocol.h"
#include <QtCore/QDebug>
+#include <QtGui/QRegion>
-#include "qeglconvenience.h"
-#include "qxlibeglintegration.h"
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <X11/extensions/Xcomposite.h>
-
-QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(QWaylandXCompositeEGLIntegration *glxIntegration, QWaylandXCompositeEGLWindow *window)
- : QPlatformGLContext()
- , mEglIntegration(glxIntegration)
- , mWindow(window)
- , mBuffer(0)
- , mXWindow(0)
- , mConfig(q_configFromQPlatformWindowFormat(glxIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_WINDOW_BIT))
- , mWaitingForSync(false)
-{
- QVector<EGLint> eglContextAttrs;
- eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); eglContextAttrs.append(2);
- eglContextAttrs.append(EGL_NONE);
-
- mContext = eglCreateContext(glxIntegration->eglDisplay(),mConfig,EGL_NO_CONTEXT,eglContextAttrs.constData());
- if (mContext == EGL_NO_CONTEXT) {
- qFatal("failed to find context");
- }
-
- geometryChanged();
-}
-
-void QWaylandXCompositeEGLContext::makeCurrent()
-{
- QPlatformGLContext::makeCurrent();
-
- eglMakeCurrent(mEglIntegration->eglDisplay(),mEglWindowSurface,mEglWindowSurface,mContext);
-}
-
-void QWaylandXCompositeEGLContext::doneCurrent()
+QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display)
+ : QEGLPlatformContext(format, share, display)
{
- QPlatformGLContext::doneCurrent();
- eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
}
-void QWaylandXCompositeEGLContext::swapBuffers()
+void QWaylandXCompositeEGLContext::swapBuffers(QPlatformSurface *surface)
{
- QSize size = mWindow->geometry().size();
+ QEGLPlatformContext::swapBuffers(surface);
- eglSwapBuffers(mEglIntegration->eglDisplay(),mEglWindowSurface);
- mWindow->damage(QRect(QPoint(0,0),size));
- mWindow->waitForFrameSync();
-}
+ QWaylandXCompositeEGLWindow *w =
+ static_cast<QWaylandXCompositeEGLWindow *>(surface);
-void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName)
-{
- return (void *)eglGetProcAddress(qPrintable(procName));
-}
+ QSize size = w->geometry().size();
-QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const
-{
- return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
+ w->damage(QRect(QPoint(), size));
+ w->waitForFrameSync();
}
-void QWaylandXCompositeEGLContext::sync_function(void *data)
+EGLSurface QWaylandXCompositeEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
{
- QWaylandXCompositeEGLContext *that = static_cast<QWaylandXCompositeEGLContext *>(data);
- that->mWaitingForSync = false;
-}
-
-void QWaylandXCompositeEGLContext::geometryChanged()
-{
- QSize size(mWindow->geometry().size());
- if (size.isEmpty()) {
- //QGLWidget wants a context for a window without geometry
- size = QSize(1,1);
- }
-
- delete mBuffer;
- //XFreePixmap deletes the glxPixmap as well
- if (mXWindow) {
- XDestroyWindow(mEglIntegration->xDisplay(),mXWindow);
- }
-
- VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(mEglIntegration->xDisplay(),mEglIntegration->eglDisplay(),mConfig);
-
- XVisualInfo visualInfoTemplate;
- memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
- visualInfoTemplate.visualid = visualId;
-
- int matchingCount = 0;
- XVisualInfo *visualInfo = XGetVisualInfo(mEglIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
-
- Colormap cmap = XCreateColormap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),visualInfo->visual,AllocNone);
-
- XSetWindowAttributes a;
- a.colormap = cmap;
- mXWindow = XCreateWindow(mEglIntegration->xDisplay(), mEglIntegration->rootWindow(),0, 0, size.width(), size.height(),
- 0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWColormap, &a);
-
- XCompositeRedirectWindow(mEglIntegration->xDisplay(), mXWindow, CompositeRedirectManual);
- XMapWindow(mEglIntegration->xDisplay(), mXWindow);
-
- mEglWindowSurface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mConfig,mXWindow,0);
- if (mEglWindowSurface == EGL_NO_SURFACE) {
- qFatal("Could not make eglsurface");
- }
-
- XSync(mEglIntegration->xDisplay(),False);
- mBuffer = new QWaylandXCompositeBuffer(mEglIntegration->waylandXComposite(),
- (uint32_t)mXWindow,
- size,
- mEglIntegration->waylandDisplay()->argbVisual());
- mWindow->attach(mBuffer);
- wl_display_sync_callback(mEglIntegration->waylandDisplay()->wl_display(),
- QWaylandXCompositeEGLContext::sync_function,
- this);
-
- mWaitingForSync = true;
- wl_display_sync(mEglIntegration->waylandDisplay()->wl_display(),0);
- mEglIntegration->waylandDisplay()->flushRequests();
- while (mWaitingForSync) {
- mEglIntegration->waylandDisplay()->readEvents();
- }
+ return static_cast<QWaylandXCompositeEGLWindow *>(surface)->eglSurface();
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h
index 9d9dd53e0b..f0e96a19af 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h
@@ -44,39 +44,21 @@
#include <QtGui/QPlatformGLContext>
-#include <QtCore/QWaitCondition>
-
-#include "qwaylandbuffer.h"
#include "qwaylandxcompositeeglintegration.h"
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+
class QWaylandXCompositeEGLWindow;
-class QWaylandXCompositeEGLContext : public QPlatformGLContext
+class QWaylandXCompositeEGLContext : public QEGLPlatformContext
{
public:
- QWaylandXCompositeEGLContext(QWaylandXCompositeEGLIntegration *glxIntegration, QWaylandXCompositeEGLWindow *window);
-
- void makeCurrent();
- void doneCurrent();
- void swapBuffers();
- void* getProcAddress(const QString& procName);
+ QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display);
- QPlatformWindowFormat platformWindowFormat() const;
-
- void geometryChanged();
+ void swapBuffers(QPlatformSurface *surface);
private:
- QWaylandXCompositeEGLIntegration *mEglIntegration;
- QWaylandXCompositeEGLWindow *mWindow;
- QWaylandBuffer *mBuffer;
-
- Window mXWindow;
- EGLConfig mConfig;
- EGLContext mContext;
- EGLSurface mEglWindowSurface;
-
- static void sync_function(void *data);
- bool mWaitingForSync;
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
};
#endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
index 53199e87b8..47454dccab 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
@@ -70,9 +70,14 @@ void QWaylandXCompositeEGLIntegration::initialize()
{
}
-QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandXCompositeEGLWindow(widget,this);
+ return new QWaylandXCompositeEGLWindow(window,this);
+}
+
+QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
+{
+ return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay());
}
Display * QWaylandXCompositeEGLIntegration::xDisplay() const
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
index 1e8055944f..1f67bf28e1 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
@@ -49,7 +49,9 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
+
+#include <QPlatformGLContext>
#include <QWaitCondition>
@@ -66,7 +68,8 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
struct wl_xcomposite *waylandXComposite() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
index 1047cb8b0a..320113f58d 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
@@ -40,17 +40,29 @@
****************************************************************************/
#include "qwaylandxcompositeeglwindow.h"
+#include "qwaylandxcompositebuffer.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
+
+#include "wayland-xcomposite-client-protocol.h"
+
+#include <X11/extensions/Xcomposite.h>
#include "qwaylandxcompositeeglintegration.h"
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
#include <QtCore/QDebug>
-QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration)
+QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration)
: QWaylandWindow(window)
- , mGlxIntegration(glxIntegration)
- , mContext(0)
+ , m_glxIntegration(glxIntegration)
+ , m_context(0)
+ , m_buffer(0)
+ , m_xWindow(0)
+ , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true))
+ , m_surface(0)
+ , m_waitingForSync(false)
{
-
}
QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const
@@ -59,23 +71,83 @@ QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const
return QWaylandWindow::Egl;
}
-QPlatformGLContext * QWaylandXCompositeEGLWindow::glContext() const
+void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect)
{
- if (!mContext) {
- qDebug() << "creating glcontext;";
- QWaylandXCompositeEGLWindow *that = const_cast<QWaylandXCompositeEGLWindow *>(this);
- that->mContext = new QWaylandXCompositeEGLContext(mGlxIntegration,that);
+ QWaylandWindow::setGeometry(rect);
+
+ if (m_surface) {
+ eglDestroySurface(m_glxIntegration->eglDisplay(), m_surface);
+ m_surface = 0;
}
- return mContext;
}
-void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect)
+EGLSurface QWaylandXCompositeEGLWindow::eglSurface() const
{
- QWaylandWindow::setGeometry(rect);
+ if (!m_surface)
+ const_cast<QWaylandXCompositeEGLWindow *>(this)->createEglSurface();
+ return m_surface;
+}
+
+void QWaylandXCompositeEGLWindow::createEglSurface()
+{
+ QSize size(geometry().size());
+ if (size.isEmpty()) {
+ // QGLWidget wants a context for a window without geometry
+ size = QSize(1,1);
+ }
- if (mContext) {
- mContext->geometryChanged();
+ delete m_buffer;
+ //XFreePixmap deletes the glxPixmap as well
+ if (m_xWindow) {
+ XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
}
+
+ VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(m_glxIntegration->xDisplay(), m_glxIntegration->eglDisplay(), m_config);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = visualId;
+
+ int matchingCount = 0;
+ XVisualInfo *visualInfo = XGetVisualInfo(m_glxIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
+
+ Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(),m_glxIntegration->rootWindow(),visualInfo->visual,AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(),
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual);
+ XMapWindow(m_glxIntegration->xDisplay(), m_xWindow);
+
+ m_surface = eglCreateWindowSurface(m_glxIntegration->eglDisplay(), m_config, m_xWindow,0);
+ if (m_surface == EGL_NO_SURFACE) {
+ qFatal("Could not make eglsurface");
+ }
+
+ XSync(m_glxIntegration->xDisplay(),False);
+ mBuffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
+ (uint32_t)m_xWindow,
+ size,
+ m_glxIntegration->waylandDisplay()->argbVisual());
+ attach(m_buffer);
+ wl_display_sync_callback(m_glxIntegration->waylandDisplay()->wl_display(),
+ QWaylandXCompositeEGLWindow::sync_function,
+ this);
+
+ m_waitingForSync = true;
+ wl_display_sync(m_glxIntegration->waylandDisplay()->wl_display(),0);
+ m_glxIntegration->waylandDisplay()->flushRequests();
+ while (m_waitingForSync)
+ m_glxIntegration->waylandDisplay()->readEvents();
+}
+
+void QWaylandXCompositeEGLWindow::sync_function(void *data)
+{
+ QWaylandXCompositeEGLWindow *that = static_cast<QWaylandXCompositeEGLWindow *>(data);
+ that->m_waitingForSync = false;
}
void QWaylandXCompositeEGLWindow::requestActivateWindow()
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
index ea4dd2d626..b2f8fbe6c4 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
@@ -43,24 +43,36 @@
#define QWAYLANDXCOMPOSITEEGLWINDOW_H
#include "qwaylandwindow.h"
+#include "qwaylandbuffer.h"
+
#include "qwaylandxcompositeeglintegration.h"
#include "qwaylandxcompositeeglcontext.h"
class QWaylandXCompositeEGLWindow : public QWaylandWindow
{
public:
- QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration);
+ QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLContext *glContext() const;
-
void setGeometry(const QRect &rect);
void requestActivateWindow();
+ EGLSurface eglSurface() const;
+
private:
- QWaylandXCompositeEGLIntegration *mGlxIntegration;
- QWaylandXCompositeEGLContext *mContext;
+ void createEglSurface();
+
+ QWaylandXCompositeEGLIntegration *m_glxIntegration;
+ QWaylandXCompositeEGLContext *m_context;
+ QWaylandBuffer *m_buffer;
+
+ Window m_xWindow;
+ EGLConfig m_config;
+ EGLSurface m_surface;
+
+ bool m_waitingForSync;
+ static void sync_function(void *data);
};
#endif // QWAYLANDXCOMPOSITEEGLWINDOW_H
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri
index c3533f9ce3..5f86bd9588 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri
@@ -1,6 +1,4 @@
include (../xcomposite_share/xcomposite_share.pri)
-include (../../../eglconvenience/eglconvenience.pri)
-include (../../../eglconvenience/xlibeglintegration.pri)
LIBS += -lXcomposite -lEGL
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
index 3d49790f3a..20fb0396f8 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
@@ -39,114 +39,56 @@
**
****************************************************************************/
+#include <QtCore/QDebug>
+
#include "qwaylandxcompositeglxcontext.h"
#include "qwaylandxcompositeglxwindow.h"
-#include "qwaylandxcompositebuffer.h"
-#include "wayland-xcomposite-client-protocol.h"
-#include <QtCore/QDebug>
+#include <QRegion>
-#include <X11/extensions/Xcomposite.h>
-
-QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window)
- : QPlatformGLContext()
- , mGlxIntegration(glxIntegration)
- , mWindow(window)
- , mBuffer(0)
- , mXWindow(0)
- , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat()))
- , mWaitingForSyncCallback(false)
+QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen)
+ : m_display(display)
{
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig);
- mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE);
-
- geometryChanged();
+ qDebug("creating XComposite-GLX context");
+ GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0;
+ GLXFBConfig config = qglx_findConfig(display, screen, format);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
+ m_context = glXCreateContext(display, visualInfo, shareContext, true);
+ m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context);
}
-void QWaylandXCompositeGLXContext::makeCurrent()
+bool QWaylandXCompositeGLXContext::makeCurrent(QPlatformSurface *surface)
{
- QPlatformGLContext::makeCurrent();
- glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext);
+ Window xWindow = static_cast<QWaylandXCompositeGLXWindow *>(surface)->xWindow();
+
+ return glXMakeCurrent(m_display, xWindow, m_context);
}
void QWaylandXCompositeGLXContext::doneCurrent()
{
- glXMakeCurrent(mGlxIntegration->xDisplay(),0,0);
- QPlatformGLContext::doneCurrent();
+ glXMakeCurrent(m_display, 0, 0);
}
-void QWaylandXCompositeGLXContext::swapBuffers()
+void QWaylandXCompositeGLXContext::swapBuffers(QPlatformSurface *surface)
{
- QSize size = mWindow->geometry().size();
+ QWaylandXCompositeGLXWindow *w = static_cast<QWaylandXCompositeGLXWindow *>(surface);
- glXSwapBuffers(mGlxIntegration->xDisplay(),mXWindow);
- mWindow->damage(QRect(QPoint(0,0),size));
- mWindow->waitForFrameSync();
-}
+ QSize size = w->geometry().size();
-void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName)
-{
- return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data()));
-}
+ glXSwapBuffers(m_display, w->xWindow());
-QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const
-{
- return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext);
+ w->damage(QRect(QPoint(), size));
+ w->waitForFrameSync();
}
-void QWaylandXCompositeGLXContext::sync_function(void *data)
+void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName)) ()
{
- QWaylandXCompositeGLXContext *that = static_cast<QWaylandXCompositeGLXContext *>(data);
- that->mWaitingForSyncCallback = false;
+ return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName.constData()));
}
-void QWaylandXCompositeGLXContext::waitForSync()
+QSurfaceFormat QWaylandXCompositeGLXContext::format() const
{
- wl_display_sync_callback(mGlxIntegration->waylandDisplay()->wl_display(),
- QWaylandXCompositeGLXContext::sync_function,
- this);
- mWaitingForSyncCallback = true;
- wl_display_sync(mGlxIntegration->waylandDisplay()->wl_display(),0);
- mGlxIntegration->waylandDisplay()->flushRequests();
- while (mWaitingForSyncCallback) {
- mGlxIntegration->waylandDisplay()->readEvents();
- }
+ return m_format;
}
-void QWaylandXCompositeGLXContext::geometryChanged()
-{
- QSize size(mWindow->geometry().size());
- if (size.isEmpty()) {
- //QGLWidget wants a context for a window without geometry
- size = QSize(1,1);
- }
-
- delete mBuffer;
- //XFreePixmap deletes the glxPixmap as well
- if (mXWindow) {
- XDestroyWindow(mGlxIntegration->xDisplay(),mXWindow);
- }
-
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(mGlxIntegration->xDisplay(),mConfig);
- Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone);
-
- XSetWindowAttributes a;
- a.background_pixel = WhitePixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
- a.border_pixel = BlackPixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
- a.colormap = cmap;
- mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(),
- 0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWBackPixel|CWBorderPixel|CWColormap, &a);
-
- XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual);
- XMapWindow(mGlxIntegration->xDisplay(), mXWindow);
-
- XSync(mGlxIntegration->xDisplay(),False);
- mBuffer = new QWaylandXCompositeBuffer(mGlxIntegration->waylandXComposite(),
- (uint32_t)mXWindow,
- size,
- mGlxIntegration->waylandDisplay()->argbVisual());
- mWindow->attach(mBuffer);
- waitForSync();
-}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
index b6ee2bbc23..cabdbe1a82 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
@@ -44,12 +44,8 @@
#include <QtGui/QPlatformGLContext>
-#include <QtCore/QWaitCondition>
-
-#include "qwaylandbuffer.h"
#include "qwaylandxcompositeglxintegration.h"
-
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
class QWaylandXCompositeGLXWindow;
class QWaylandShmBuffer;
@@ -57,29 +53,22 @@ class QWaylandShmBuffer;
class QWaylandXCompositeGLXContext : public QPlatformGLContext
{
public:
- QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window);
+ QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen);
- void makeCurrent();
- void doneCurrent();
- void swapBuffers();
- void* getProcAddress(const QString& procName);
+ QSurfaceFormat format() const;
- QPlatformWindowFormat platformWindowFormat() const;
+ void swapBuffers(QPlatformSurface *surface);
- void geometryChanged();
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
-private:
- QWaylandXCompositeGLXIntegration *mGlxIntegration;
- QWaylandXCompositeGLXWindow *mWindow;
- QWaylandBuffer *mBuffer;
+ void (*getProcAddress(const QByteArray &procName)) ();
- Window mXWindow;
- GLXFBConfig mConfig;
- GLXContext mContext;
+private:
+ GLXContext m_context;
- static void sync_function(void *data);
- void waitForSync();
- bool mWaitingForSyncCallback;
+ Display *m_display;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
index e8dbea48c6..8c27fa1cd8 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
@@ -52,12 +52,15 @@ QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDispl
return new QWaylandXCompositeGLXIntegration(waylandDisplay);
}
-QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly)
- : QWaylandGLIntegration()
- , mWaylandDisplay(waylandDispaly)
+QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay *waylandDisplay)
+ : mWaylandDisplay(waylandDisplay)
+ , mWaylandComposite(0)
+ , mDisplay(0)
+ , mScreen(0)
+ , mRootWindow(0)
{
qDebug() << "Using XComposite-GLX";
- wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal,
+ wl_display_add_global_listener(waylandDisplay->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal,
this);
}
@@ -70,9 +73,14 @@ void QWaylandXCompositeGLXIntegration::initialize()
{
}
-QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandXCompositeGLXWindow(widget,this);
+ return new QWaylandXCompositeGLXWindow(window, this);
+}
+
+QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
+{
+ return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen);
}
Display * QWaylandXCompositeGLXIntegration::xDisplay() const
@@ -107,6 +115,7 @@ void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display
{
Q_UNUSED(version);
if (strcmp(interface, "wl_xcomposite") == 0) {
+ qDebug("XComposite-GLX: got wl_xcomposite global");
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
@@ -119,6 +128,8 @@ void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite
Q_UNUSED(xcomposite);
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
+ qDebug("XComposite-GLX: xcomposite listener callback");
+
integration->mDisplay = XOpenDisplay(display_name);
integration->mRootWindow = (Window) root_window;
integration->mScreen = XDefaultScreen(integration->mDisplay);
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
index 17f2f6d4e4..5a779bf58a 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
@@ -49,7 +49,7 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
#include <X11/Xlib.h>
@@ -63,7 +63,8 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
struct wl_xcomposite *waylandXComposite() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
index cd7ae1964c..abaf3b16a9 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
@@ -40,15 +40,24 @@
****************************************************************************/
#include "qwaylandxcompositeglxwindow.h"
+#include "qwaylandxcompositebuffer.h"
#include <QtCore/QDebug>
-QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration)
+#include "wayland-xcomposite-client-protocol.h"
+#include <QtGui/QRegion>
+
+#include <X11/extensions/Xcomposite.h>
+
+
+QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration)
: QWaylandWindow(window)
- , mGlxIntegration(glxIntegration)
- , mContext(0)
+ , m_glxIntegration(glxIntegration)
+ , m_xWindow(0)
+ , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format()))
+ , m_buffer(0)
+ , m_waitingForSync(false)
{
-
}
QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const
@@ -57,21 +66,79 @@ QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const
return QWaylandWindow::Egl;
}
-QPlatformGLContext * QWaylandXCompositeGLXWindow::glContext() const
+void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect)
{
- if (!mContext) {
- qDebug() << "creating glcontext;";
- QWaylandXCompositeGLXWindow *that = const_cast<QWaylandXCompositeGLXWindow *>(this);
- that->mContext = new QWaylandXCompositeGLXContext(mGlxIntegration,that);
+ QWaylandWindow::setGeometry(rect);
+
+ if (m_xWindow) {
+ delete m_buffer;
+
+ XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
+ m_xWindow = 0;
}
- return mContext;
}
-void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect)
+Window QWaylandXCompositeGLXWindow::xWindow() const
{
- QWaylandWindow::setGeometry(rect);
+ if (!m_xWindow)
+ const_cast<QWaylandXCompositeGLXWindow *>(this)->createSurface();
- if (mContext) {
- mContext->geometryChanged();
+ return m_xWindow;
+}
+
+void QWaylandXCompositeGLXWindow::waitForSync()
+{
+ wl_display_sync_callback(m_glxIntegration->waylandDisplay()->wl_display(),
+ QWaylandXCompositeGLXWindow::sync_function,
+ this);
+ m_waitingForSync= true;
+ wl_display_sync(m_glxIntegration->waylandDisplay()->wl_display(), 0);
+ m_glxIntegration->waylandDisplay()->flushRequests();
+ while (m_waitingForSync)
+ m_glxIntegration->waylandDisplay()->readEvents();
+}
+
+
+void QWaylandXCompositeGLXWindow::createSurface()
+{
+ QSize size(geometry().size());
+ if (size.isEmpty()) {
+ //QGLWidget wants a context for a window without geometry
+ size = QSize(1,1);
}
+
+ if (!m_glxIntegration->xDisplay()) {
+ qWarning("XCompositeGLXWindow: X display still null?!");
+ return;
+ }
+
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config);
+ Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),
+ visualInfo->visual, AllocNone);
+
+ XSetWindowAttributes a;
+ a.background_pixel = WhitePixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen());
+ a.border_pixel = BlackPixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen());
+ a.colormap = cmap;
+ m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(),
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWBackPixel|CWBorderPixel|CWColormap, &a);
+
+ XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual);
+ XMapWindow(m_glxIntegration->xDisplay(), m_xWindow);
+
+ XSync(m_glxIntegration->xDisplay(), False);
+ m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
+ (uint32_t)m_xWindow,
+ size,
+ m_glxIntegration->waylandDisplay()->argbVisual());
+ attach(m_buffer);
+ waitForSync();
+}
+
+void QWaylandXCompositeGLXWindow::sync_function(void *data)
+{
+ QWaylandXCompositeGLXWindow *that = static_cast<QWaylandXCompositeGLXWindow *>(data);
+ that->m_waitingForSync = false;
}
+
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
index 8808f2d482..acf6c8e63e 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
@@ -46,20 +46,34 @@
#include "qwaylandxcompositeglxintegration.h"
#include "qwaylandxcompositeglxcontext.h"
+#include <QtCore/QWaitCondition>
+
+#include "qwaylandbuffer.h"
+
class QWaylandXCompositeGLXWindow : public QWaylandWindow
{
public:
- QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration);
+ QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLContext *glContext() const;
-
void setGeometry(const QRect &rect);
+ Window xWindow() const;
+
private:
- QWaylandXCompositeGLXIntegration *mGlxIntegration;
- QWaylandXCompositeGLXContext *mContext;
+ void createSurface();
+
+ QWaylandXCompositeGLXIntegration *m_glxIntegration;
+
+ Window m_xWindow;
+ GLXFBConfig m_config;
+
+ QWaylandBuffer *m_buffer;
+
+ void waitForSync();
+ bool m_waitingForSync;
+ static void sync_function(void *data);
};
#endif // QWAYLANDXCOMPOSITEGLXWINDOW_H
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri
index 43295e91e7..bbd6c12e42 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri
@@ -1,5 +1,4 @@
include (../xcomposite_share/xcomposite_share.pri)
-include (../../../glxconvenience/glxconvenience.pri)
LIBS += -lXcomposite
SOURCES += \
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp
index 7d309ef877..f4bacc3c1f 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp
@@ -42,6 +42,7 @@
#include "qwaylandxcompositebuffer.h"
#include "wayland-client.h"
+#include "wayland-xcomposite-client-protocol.h"
QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size, wl_visual *visual)
:mSize(size)
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h
index cbd40ad381..02176d7850 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h
@@ -43,8 +43,10 @@
#define QWAYLANDXCOMPOSITEBUFFER_H
#include "qwaylandbuffer.h"
+#include <stdint.h>
-#include "wayland-xcomposite-client-protocol.h"
+struct wl_xcomposite;
+struct wl_visual;
class QWaylandXCompositeBuffer : public QWaylandBuffer
{
diff --git a/src/plugins/platforms/wayland/main.cpp b/src/plugins/platforms/wayland/main.cpp
index ba365ca3a1..e4d420d68a 100644
--- a/src/plugins/platforms/wayland/main.cpp
+++ b/src/plugins/platforms/wayland/main.cpp
@@ -54,8 +54,7 @@ public:
QStringList QWaylandIntegrationPlugin::keys() const
{
QStringList list;
- list << "Wayland";
- list << "WaylandGL";
+ list << "wayland";
return list;
}
@@ -63,9 +62,7 @@ QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, c
{
Q_UNUSED(paramList);
if (system.toLower() == "wayland")
- return new QWaylandIntegration;
- if (system.toLower() == "waylandgl")
- return new QWaylandIntegration(true);
+ return new QWaylandIntegration();
return 0;
}
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
index 1ef063fec1..da5da4285a 100644
--- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
@@ -43,7 +43,7 @@
#include "qwaylanddisplay.h"
#include "qwaylandinputdevice.h"
#include <QtGui/QPlatformNativeInterface>
-#include <QtGui/QApplication>
+#include <QtGui/QGuiApplication>
#include <QtCore/QMimeData>
#include <QtCore/QStringList>
#include <QtCore/QFile>
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp
index 87b846cefb..6612d67cb4 100644
--- a/src/plugins/platforms/wayland/qwaylandcursor.cpp
+++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp
@@ -43,8 +43,8 @@
#include "qwaylanddisplay.h"
#include "qwaylandinputdevice.h"
-#include "qwaylandshmsurface.h"
#include "qwaylandscreen.h"
+#include "qwaylandshmbackingstore.h"
#include <QtGui/QImageReader>
@@ -108,11 +108,11 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
{
}
-void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget)
+void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
{
const struct pointer_image *p;
- if (widget == NULL)
+ if (window == NULL)
return;
p = NULL;
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h
index 236bfc56ee..4409eea828 100644
--- a/src/plugins/platforms/wayland/qwaylandcursor.h
+++ b/src/plugins/platforms/wayland/qwaylandcursor.h
@@ -52,7 +52,7 @@ class QWaylandCursor : QPlatformCursor {
public:
QWaylandCursor(QWaylandScreen *screen);
- void changeCursor(QCursor *cursor, QWidget *widget);
+ void changeCursor(QCursor *cursor, QWindow *window);
QWaylandShmBuffer *mBuffer;
QWaylandDisplay *mDisplay;
};
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index 26e0e8ebeb..1314eda012 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -56,8 +56,7 @@
#endif
#include <QtCore/QAbstractEventDispatcher>
-#include <QtGui/QApplication>
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <unistd.h>
#include <fcntl.h>
@@ -156,9 +155,12 @@ QWaylandDisplay::QWaylandDisplay(void)
mEglIntegration->initialize();
#endif
- connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
-
mFd = wl_display_get_fd(mDisplay, sourceUpdate, this);
+}
+
+void QWaylandDisplay::eventDispatcherCreated(QAbstractEventDispatcher *dispatcher)
+{
+ connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this);
connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents()));
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
index 4dff24d086..14812885a3 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.h
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -49,6 +49,7 @@
#include <wayland-client.h>
+class QAbstractEventDispatcher;
class QWaylandInputDevice;
class QSocketNotifier;
class QWaylandBuffer;
@@ -91,6 +92,8 @@ public:
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
+ void eventDispatcherCreated(QAbstractEventDispatcher *dispatcher);
+
public slots:
void createNewScreen(struct wl_output *output, QRect geometry);
void readEvents();
@@ -142,6 +145,7 @@ private:
static void handleVisual(void *data,
struct wl_compositor *compositor,
uint32_t id, uint32_t token);
+
#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration *mEglIntegration;
#endif
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
index 3c9afafada..c1e2325766 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -113,7 +113,7 @@ void QWaylandInputDevice::inputHandleMotion(void *data,
inputDevice->mSurfacePos = QPoint(surface_x, surface_y);
inputDevice->mGlobalPos = QPoint(x, y);
inputDevice->mTime = time;
- QWindowSystemInterface::handleMouseEvent(window->widget(),
+ QWindowSystemInterface::handleMouseEvent(window->window(),
time,
inputDevice->mSurfacePos,
inputDevice->mGlobalPos,
@@ -155,7 +155,7 @@ void QWaylandInputDevice::inputHandleButton(void *data,
inputDevice->mButtons &= ~qt_button;
inputDevice->mTime = time;
- QWindowSystemInterface::handleMouseEvent(window->widget(),
+ QWindowSystemInterface::handleMouseEvent(window->window(),
time,
inputDevice->mSurfacePos,
inputDevice->mGlobalPos,
@@ -272,7 +272,7 @@ void QWaylandInputDevice::inputHandleKey(void *data,
sym = translateKey(sym, s, sizeof s);
if (window) {
- QWindowSystemInterface::handleKeyEvent(window->widget(),
+ QWindowSystemInterface::handleKeyEvent(window->window(),
time, type, sym,
inputDevice->mModifiers,
QString::fromLatin1(s));
@@ -295,13 +295,13 @@ void QWaylandInputDevice::inputHandlePointerFocus(void *data,
if (inputDevice->mPointerFocus) {
window = inputDevice->mPointerFocus;
- QWindowSystemInterface::handleLeaveEvent(window->widget());
+ QWindowSystemInterface::handleLeaveEvent(window->window());
inputDevice->mPointerFocus = NULL;
}
if (surface) {
window = (QWaylandWindow *) wl_surface_get_user_data(surface);
- QWindowSystemInterface::handleEnterEvent(window->widget());
+ QWindowSystemInterface::handleEnterEvent(window->window());
inputDevice->mPointerFocus = window;
}
@@ -333,7 +333,7 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data,
if (surface) {
window = (QWaylandWindow *) wl_surface_get_user_data(surface);
inputDevice->mKeyboardFocus = window;
- QWindowSystemInterface::handleWindowActivated(window->widget());
+ QWindowSystemInterface::handleWindowActivated(window->window());
} else {
inputDevice->mKeyboardFocus = NULL;
QWindowSystemInterface::handleWindowActivated(0);
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 5df71dc936..9a581c265f 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -42,28 +42,27 @@
#include "qwaylandintegration.h"
#include "qwaylanddisplay.h"
-#include "qwaylandshmsurface.h"
+#include "qwaylandshmbackingstore.h"
#include "qwaylandshmwindow.h"
#include "qwaylandnativeinterface.h"
#include "qwaylandclipboard.h"
-#include "qgenericunixfontdatabase.h"
+#include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h"
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtGui/QWindowSystemInterface>
#include <QtGui/QPlatformCursor>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtGui/private/qpixmap_raster_p.h>
+
#ifdef QT_WAYLAND_GL_SUPPORT
#include "gl_integration/qwaylandglintegration.h"
-#include "gl_integration/qwaylandglwindowsurface.h"
-#include <QtOpenGL/private/qpixmapdata_gl_p.h>
#endif
-QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
+QWaylandIntegration::QWaylandIntegration()
: mFontDb(new QGenericUnixFontDatabase())
, mDisplay(new QWaylandDisplay())
- , mUseOpenGL(useOpenGL)
, mNativeInterface(new QWaylandNativeInterface)
{
}
@@ -83,55 +82,56 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co
{
switch (cap) {
case ThreadedPixmaps: return true;
- case OpenGL: return hasOpenGL();
+ case OpenGL:
+#ifdef QT_WAYLAND_GL_SUPPORT
+ return true;
+#else
+ return false;
+#endif
default: return QPlatformIntegration::hasCapability(cap);
}
}
QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
{
-#ifdef QT_WAYLAND_GL_SUPPORT
- if (mUseOpenGL)
- return new QGLPixmapData(type);
-#endif
return new QRasterPixmapData(type);
}
-QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
{
- Q_UNUSED(winId);
#ifdef QT_WAYLAND_GL_SUPPORT
- bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
- if (useOpenGL)
- return mDisplay->eglIntegration()->createEglWindow(widget);
+ if (window->surfaceType() == QWindow::OpenGLSurface)
+ return mDisplay->eglIntegration()->createEglWindow(window);
#endif
- return new QWaylandShmWindow(widget);
+ return new QWaylandShmWindow(window);
}
-QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
- Q_UNUSED(winId);
- Q_UNUSED(winId);
#ifdef QT_WAYLAND_GL_SUPPORT
- bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
- if (useOpenGL)
- return new QWaylandGLWindowSurface(widget);
+ return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share);
+#else
+ Q_UNUSED(glFormat);
+ Q_UNUSED(share);
+ return 0;
#endif
- return new QWaylandShmWindowSurface(widget);
}
-QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
+QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *window) const
{
- return mFontDb;
+ return new QWaylandShmBackingStore(window);
}
-bool QWaylandIntegration::hasOpenGL() const
+QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
{
-#ifdef QT_WAYLAND_GL_SUPPORT
- return true;
-#else
- return false;
-#endif
+ QAbstractEventDispatcher *dispatcher = createUnixEventDispatcher();
+ mDisplay->eventDispatcherCreated(dispatcher);
+ return dispatcher;
+}
+
+QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
+{
+ return mFontDb;
}
QPlatformClipboard *QWaylandIntegration::clipboard() const
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
index f617d9697b..c08c040261 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.h
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -48,16 +48,19 @@ QT_BEGIN_NAMESPACE
class QWaylandBuffer;
class QWaylandDisplay;
+class QAbstractEventDispatcher;
class QWaylandIntegration : public QPlatformIntegration
{
public:
- QWaylandIntegration(bool useOpenGL = false);
+ QWaylandIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const;
@@ -68,11 +71,8 @@ public:
QPlatformClipboard *clipboard() const;
private:
- bool hasOpenGL() const;
-
QPlatformFontDatabase *mFontDb;
QWaylandDisplay *mDisplay;
- bool mUseOpenGL;
QPlatformNativeInterface *mNativeInterface;
};
diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
index 43be74a6ea..f6028f69b2 100644
--- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
@@ -43,30 +43,30 @@
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
-void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();
if (lowerCaseResource == "display")
- return qPlatformScreenForWidget(widget)->display()->wl_display();
+ return qPlatformScreenForWindow(window)->display()->wl_display();
if (lowerCaseResource == "surface") {
- return ((QWaylandWindow *) widget->platformWindow())->wl_surface();
+ return ((QWaylandWindow *) window->handle())->wl_surface();
}
return NULL;
}
-QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QWaylandScreen *screen;
- if (widget) {
- screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ if (window) {
+ screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWindow(window));
} else {
- screen = static_cast<QWaylandScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ screen = static_cast<QWaylandScreen *>(QGuiApplicationPrivate::platformIntegration()->screens()[0]);
}
return screen;
}
diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.h b/src/plugins/platforms/wayland/qwaylandnativeinterface.h
index d33a41b00b..f1d4fe9402 100644
--- a/src/plugins/platforms/wayland/qwaylandnativeinterface.h
+++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.h
@@ -49,11 +49,11 @@
class QWaylandNativeInterface : public QPlatformNativeInterface
{
public:
- void *nativeResourceForWidget(const QByteArray &resourceString,
- QWidget *widget);
+ void *nativeResourceForWindow(const QByteArray &resourceString,
+ QWindow *window);
private:
- static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget);
+ static QWaylandScreen *qPlatformScreenForWindow(QWindow *window);
};
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp
index be6dcb2e88..3a63e78207 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.cpp
+++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp
@@ -81,9 +81,9 @@ QImage::Format QWaylandScreen::format() const
return mFormat;
}
-QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget)
+QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
{
- QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget);
+ QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window);
return static_cast<QWaylandScreen *>(platformScreen);
}
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h
index f2b3bcefbc..9bf4f6574a 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.h
+++ b/src/plugins/platforms/wayland/qwaylandscreen.h
@@ -62,7 +62,7 @@ public:
wl_visual *visual() const;
- static QWaylandScreen *waylandScreenFromWidget(QWidget *widget);
+ static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
private:
QWaylandDisplay *mWaylandDisplay;
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp
index b24c419424..25a1b466d4 100644
--- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp
@@ -38,10 +38,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qwaylandshmsurface.h"
+#include "qwaylandshmbackingstore.h"
#include <QtCore/qdebug.h>
-#include <QtGui/private/qapplication_p.h>
#include "qwaylanddisplay.h"
#include "qwaylandshmwindow.h"
@@ -91,34 +90,34 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void)
wl_buffer_destroy(mBuffer);
}
-QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window)
- : QWindowSurface(window)
+QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window)
+ : QPlatformBackingStore(window)
, mBuffer(0)
- , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
{
}
-QWaylandShmWindowSurface::~QWaylandShmWindowSurface()
+QWaylandShmBackingStore::~QWaylandShmBackingStore()
{
}
-QPaintDevice *QWaylandShmWindowSurface::paintDevice()
+QPaintDevice *QWaylandShmBackingStore::paintDevice()
{
return mBuffer->image();
}
-void QWaylandShmWindowSurface::beginPaint(const QRegion &)
+void QWaylandShmBackingStore::beginPaint(const QRegion &)
{
- QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle());
Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
waylandWindow->waitForFrameSync();
}
-void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QWaylandShmBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
- Q_UNUSED(widget);
+ Q_UNUSED(window);
Q_UNUSED(offset);
- QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window->handle());
Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
QVector<QRect> rects = region.rects();
for (int i = 0; i < rects.size(); i++) {
@@ -128,13 +127,12 @@ void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion &region, con
}
}
-void QWaylandShmWindowSurface::resize(const QSize &size)
+void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &)
{
- QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle());
Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
- QWindowSurface::resize(size);
- QImage::Format format = QPlatformScreen::platformScreenForWidget(window())->format();
+ QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format();
if (mBuffer != NULL && mBuffer->size() == size)
return;
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmbackingstore.h
index f3db8b86e5..5e6959dc2f 100644
--- a/src/plugins/platforms/wayland/qwaylandshmsurface.h
+++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.h
@@ -39,12 +39,12 @@
**
****************************************************************************/
-#ifndef QWINDOWSURFACE_WAYLAND_H
-#define QWINDOWSURFACE_WAYLAND_H
+#ifndef QWAYLANDSHMBACKINGSTORE_H
+#define QWAYLANDSHMBACKINGSTORE_H
#include "qwaylandbuffer.h"
-#include <QtGui/private/qwindowsurface_p.h>
-
+#include <QtGui/QPlatformBackingStore>
+#include <QtGui/QImage>
#include <QtGui/QPlatformWindow>
QT_BEGIN_NAMESPACE
@@ -62,15 +62,15 @@ private:
QImage mImage;
};
-class QWaylandShmWindowSurface : public QWindowSurface
+class QWaylandShmBackingStore : public QPlatformBackingStore
{
public:
- QWaylandShmWindowSurface(QWidget *window);
- ~QWaylandShmWindowSurface();
+ QWaylandShmBackingStore(QWindow *window);
+ ~QWaylandShmBackingStore();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size, const QRegion &staticContents);
void beginPaint(const QRegion &);
private:
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
index a6b7050f7a..ba5e46cab1 100644
--- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
@@ -47,8 +47,8 @@
#include <QtCore/QDebug>
-QWaylandShmWindow::QWaylandShmWindow(QWidget *widget)
- : QWaylandWindow(widget)
+QWaylandShmWindow::QWaylandShmWindow(QWindow *window)
+ : QWaylandWindow(window)
{
newSurfaceCreated();
}
@@ -63,9 +63,3 @@ QWaylandWindow::WindowType QWaylandShmWindow::windowType() const
return QWaylandWindow::Shm;
}
-QPlatformGLContext * QWaylandShmWindow::glContext() const
-{
- qWarning("Trying to retrieve a glContext from a Raster window surface!");
- return 0;
-}
-
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h
index 8033703391..36f9f225b7 100644
--- a/src/plugins/platforms/wayland/qwaylandshmwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h
@@ -48,11 +48,11 @@
class QWaylandShmWindow : public QWaylandWindow
{
public:
- QWaylandShmWindow(QWidget *widget);
+ QWaylandShmWindow(QWindow *window);
~QWaylandShmWindow();
WindowType windowType() const;
- QPlatformGLContext *glContext() const;
+ QSurfaceFormat format() const { return QSurfaceFormat(); }
};
#endif // QWAYLANDSHMWINDOW_H
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index ef2047e0f3..f685dae729 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -46,20 +46,21 @@
#include "qwaylandinputdevice.h"
#include "qwaylandscreen.h"
+#include <QtGui/QWindow>
+
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
#endif
#include <QCoreApplication>
-#include <QtGui/QWidget>
#include <QtGui/QWindowSystemInterface>
#include <QDebug>
-QWaylandWindow::QWaylandWindow(QWidget *window)
+QWaylandWindow::QWaylandWindow(QWindow *window)
: QPlatformWindow(window)
, mSurface(0)
- , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
, mBuffer(0)
, mWaitingForFrameSync(false)
{
@@ -112,11 +113,11 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges,
{
Q_UNUSED(time);
Q_UNUSED(edges);
- QRect geometry = QRect(x, y, width, height);
+ QRect geometry = QRect(x, y, width, height);
setGeometry(geometry);
- QWindowSystemInterface::handleGeometryChange(widget(), geometry);
+ QWindowSystemInterface::handleGeometryChange(window(), geometry);
}
void QWaylandWindow::attach(QWaylandBuffer *buffer)
@@ -124,6 +125,7 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer)
mBuffer = buffer;
if (mSurface) {
wl_surface_attach(mSurface, buffer->buffer(),0,0);
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
}
}
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
index b91f6b6eb8..4f1e2c8183 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow.h
@@ -59,7 +59,7 @@ public:
Egl
};
- QWaylandWindow(QWidget *window);
+ QWaylandWindow(QWindow *window);
~QWaylandWindow();
virtual WindowType windowType() const = 0;
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index 857a2918ce..9f4563a88c 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -1,19 +1,23 @@
TARGET = qwayland
load(qt_plugin)
-QT+=gui-private core-private opengl-private
+CONFIG += qpa/genericunixfontdatabase
DESTDIR = $$QT.gui.plugins/platforms
DEFINES += Q_PLATFORM_WAYLAND
DEFINES += $$QMAKE_DEFINES_WAYLAND
-QT += core-private gui-private opengl-private
+mac {
+ DEFINES += QT_NO_WAYLAND_XKB
+}
+
+QT += core-private gui-private opengl-private platformsupport-private
SOURCES = main.cpp \
qwaylandintegration.cpp \
qwaylandnativeinterface.cpp \
- qwaylandshmsurface.cpp \
+ qwaylandshmbackingstore.cpp \
qwaylandinputdevice.cpp \
qwaylandcursor.cpp \
qwaylanddisplay.cpp \
@@ -28,22 +32,21 @@ HEADERS = qwaylandintegration.h \
qwaylanddisplay.h \
qwaylandwindow.h \
qwaylandscreen.h \
- qwaylandshmsurface.h \
+ qwaylandshmbackingstore.h \
qwaylandbuffer.h \
qwaylandshmwindow.h \
qwaylandclipboard.h
INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
LIBS += $$QMAKE_LIBS_WAYLAND
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
-
-INCLUDEPATH += $$PWD
+mac {
+ LIBS += -lwayland-client
+}
-include ($$PWD/gl_integration/gl_integration.pri)
-include ($$PWD/windowmanager_integration/windowmanager_integration.pri)
-
-include (../fontdatabases/genericunix/genericunix.pri)
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
+include ($$PWD/gl_integration/gl_integration.pri)
+include ($$PWD/windowmanager_integration/windowmanager_integration.pri)
diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README
index 17a86e6d08..d2884f109c 100644
--- a/src/plugins/platforms/xcb/README
+++ b/src/plugins/platforms/xcb/README
@@ -1,3 +1,3 @@
Required packages:
-libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev
+libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev
diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp
index 8bcdacb92b..8eef1b6111 100644
--- a/src/plugins/platforms/xcb/qdri2context.cpp
+++ b/src/plugins/platforms/xcb/qdri2context.cpp
@@ -45,7 +45,7 @@
#include "qxcbconnection.h"
#include <QtCore/QDebug>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include <xcb/dri2.h>
#include <xcb/xfixes.h>
@@ -146,7 +146,6 @@ QDri2Context::~QDri2Context()
void QDri2Context::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
Q_D(QDri2Context);
eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext);
@@ -156,7 +155,6 @@ void QDri2Context::makeCurrent()
void QDri2Context::doneCurrent()
{
- QPlatformGLContext::doneCurrent();
Q_D(QDri2Context);
eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
}
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 8e04cbcb71..38f760ede9 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -50,70 +50,66 @@
#include <X11/Xutil.h>
#include <GL/glx.h>
+#include <QtGui/QGuiGLContext>
+
#include "qglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
#include <dlfcn.h>
#endif
-QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format)
+QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformGLContext *share)
: QPlatformGLContext()
, m_screen(screen)
- , m_drawable((Drawable)window)
, m_context(0)
{
Q_XCB_NOOP(m_screen->connection());
- const QPlatformGLContext *sharePlatformContext;
- sharePlatformContext = format.sharedGLContext();
GLXContext shareGlxContext = 0;
- if (sharePlatformContext)
- shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
+ if (share)
+ shareGlxContext = static_cast<const QGLXContext*>(share)->glxContext();
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
- m_windowFormat = qglx_platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
+ m_format = qglx_surfaceFormatFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
Q_XCB_NOOP(m_screen->connection());
}
-QGLXContext::QGLXContext(QXcbScreen *screen, Drawable drawable, GLXContext context)
- : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
-{
-
-}
-
QGLXContext::~QGLXContext()
{
Q_XCB_NOOP(m_screen->connection());
- if (m_context)
- glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context);
+ glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context);
Q_XCB_NOOP(m_screen->connection());
}
-void QGLXContext::makeCurrent()
+bool QGLXContext::makeCurrent(QPlatformSurface *surface)
{
+ Q_ASSERT(surface);
+
Q_XCB_NOOP(m_screen->connection());
- QPlatformGLContext::makeCurrent();
- glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context);
+
+ GLXDrawable glxDrawable = static_cast<QXcbWindow *>(surface)->xcb_window();
+
+ bool result = glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), glxDrawable, m_context);
+
Q_XCB_NOOP(m_screen->connection());
+ return result;
}
void QGLXContext::doneCurrent()
{
- Q_XCB_NOOP(m_screen->connection());
- QPlatformGLContext::doneCurrent();
glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
- Q_XCB_NOOP(m_screen->connection());
}
-void QGLXContext::swapBuffers()
+void QGLXContext::swapBuffers(QPlatformSurface *surface)
{
Q_XCB_NOOP(m_screen->connection());
- glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable);
+ GLXDrawable glxDrawable = static_cast<QXcbWindow *>(surface)->xcb_window();
+ glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), glxDrawable);
Q_XCB_NOOP(m_screen->connection());
}
-void* QGLXContext::getProcAddress(const QString& procName)
+void (*QGLXContext::getProcAddress(const QByteArray &procName)) ()
{
Q_XCB_NOOP(m_screen->connection());
typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
@@ -144,10 +140,10 @@ void* QGLXContext::getProcAddress(const QString& procName)
}
if (!glXGetProcAddressARB)
return 0;
- return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
+ return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData()));
}
-QPlatformWindowFormat QGLXContext::platformWindowFormat() const
+QSurfaceFormat QGLXContext::format() const
{
- return m_windowFormat;
+ return m_format;
}
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
index 84de7b7143..b431a45741 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -43,9 +43,10 @@
#define QGLXINTEGRATION_H
#include "qxcbwindow.h"
+#include "qxcbscreen.h"
#include <QtGui/QPlatformGLContext>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtCore/QMutex>
@@ -54,25 +55,22 @@
class QGLXContext : public QPlatformGLContext
{
public:
- QGLXContext(Window window, QXcbScreen *xd, const QPlatformWindowFormat &format);
+ QGLXContext(QXcbScreen *xd, const QSurfaceFormat &format, QPlatformGLContext *share);
~QGLXContext();
- virtual void makeCurrent();
- virtual void doneCurrent();
- virtual void swapBuffers();
- virtual void* getProcAddress(const QString& procName);
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
+ void swapBuffers(QPlatformSurface *surface);
+ void (*getProcAddress(const QByteArray &procName)) ();
- GLXContext glxContext() const { return m_context; }
+ QSurfaceFormat format() const;
- QPlatformWindowFormat platformWindowFormat() const;
+ GLXContext glxContext() const { return m_context; }
private:
QXcbScreen *m_screen;
- Drawable m_drawable;
GLXContext m_context;
- QPlatformWindowFormat m_windowFormat;
-
- QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context);
+ QSurfaceFormat m_format;
};
#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 4fcd207df3..3def577462 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qxcbwindowsurface.h"
+#include "qxcbbackingstore.h"
#include "qxcbconnection.h"
#include "qxcbscreen.h"
@@ -52,6 +52,7 @@
#include <sys/shm.h>
#include <stdio.h>
+#include <errno.h>
#include <qdebug.h>
#include <qpainter.h>
@@ -63,6 +64,7 @@ public:
~QXcbShmImage() { destroy(); }
QImage *image() { return &m_qimage; }
+ QSize size() const { return m_qimage.size(); }
void put(xcb_window_t window, const QPoint &dst, const QRect &source);
void preparePaint(const QRegion &region);
@@ -97,30 +99,44 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
~0,
0);
- m_shm_info.shmid = shmget (IPC_PRIVATE,
- m_xcb_image->stride * m_xcb_image->height, IPC_CREAT|0777);
+ const int segmentSize = m_xcb_image->stride * m_xcb_image->height;
+ if (!segmentSize)
+ return;
+ int id = shmget(IPC_PRIVATE, segmentSize, IPC_CREAT | 0777);
+ if (id == -1)
+ qWarning("QXcbShmImage: shmget() failed (%d) for size %d (%dx%d)",
+ errno, segmentSize, size.width(), size.height());
+ else
+ m_shm_info.shmid = id;
m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0);
m_shm_info.shmseg = xcb_generate_id(xcb_connection());
xcb_generic_error_t *error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false));
if (error) {
- qWarning() << "QXcbWindowSurface: Unable to attach to shared memory segment";
+ qWarning() << "QXcbBackingStore: Unable to attach to shared memory segment";
free(error);
}
if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1)
- qWarning() << "QXcbWindowSurface: Error while marking the shared memory segment to be destroyed";
+ qWarning() << "QXcbBackingStore: Error while marking the shared memory segment to be destroyed";
m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
}
void QXcbShmImage::destroy()
{
- Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg));
+ const int segmentSize = m_xcb_image ? (m_xcb_image->stride * m_xcb_image->height) : 0;
+ if (segmentSize)
+ Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg));
+
xcb_image_destroy(m_xcb_image);
- shmdt(m_shm_info.shmaddr);
- shmctl(m_shm_info.shmid, IPC_RMID, 0);
+
+ if (segmentSize) {
+ shmdt(m_shm_info.shmaddr);
+ shmctl(m_shm_info.shmid, IPC_RMID, 0);
+ }
+
if (m_gc)
Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc));
}
@@ -168,29 +184,30 @@ void QXcbShmImage::preparePaint(const QRegion &region)
}
}
-QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface)
- : QWindowSurface(widget, setDefaultSurface)
+QXcbBackingStore::QXcbBackingStore(QWindow *window)
+ : QPlatformBackingStore(window)
, m_image(0)
, m_syncingResize(false)
{
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window));
setConnection(screen->connection());
}
-QXcbWindowSurface::~QXcbWindowSurface()
+QXcbBackingStore::~QXcbBackingStore()
{
delete m_image;
}
-QPaintDevice *QXcbWindowSurface::paintDevice()
+QPaintDevice *QXcbBackingStore::paintDevice()
{
return m_image->image();
}
-void QXcbWindowSurface::beginPaint(const QRegion &region)
+void QXcbBackingStore::beginPaint(const QRegion &region)
{
m_image->preparePaint(region);
+#if 0
if (m_image->image()->hasAlphaChannel()) {
QPainter p(m_image->image());
p.setCompositionMode(QPainter::CompositionMode_Source);
@@ -200,29 +217,27 @@ void QXcbWindowSurface::beginPaint(const QRegion &region)
p.fillRect(*it, blank);
}
}
+#endif
}
-void QXcbWindowSurface::endPaint(const QRegion &)
+void QXcbBackingStore::endPaint(const QRegion &)
{
}
-void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QXcbBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
QRect bounds = region.boundingRect();
- if (size().isEmpty() || !geometry().contains(bounds))
+ if (!m_image || m_image->size().isEmpty())
return;
Q_XCB_NOOP(connection());
- QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow());
-
- extern QWidgetData* qt_widget_data(QWidget *);
- QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
+ QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle());
QVector<QRect> rects = region.rects();
for (int i = 0; i < rects.size(); ++i)
- m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
+ m_image->put(platformWindow->xcb_window(), rects.at(i).topLeft(), rects.at(i).translated(offset));
Q_XCB_NOOP(connection());
@@ -230,23 +245,22 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
xcb_flush(xcb_connection());
connection()->sync();
m_syncingResize = false;
- window->updateSyncRequestCounter();
+ platformWindow->updateSyncRequestCounter();
}
}
-void QXcbWindowSurface::resize(const QSize &size)
+void QXcbBackingStore::resize(const QSize &size, const QRegion &)
{
- if (size == QWindowSurface::size())
+ if (m_image && size == m_image->size())
return;
Q_XCB_NOOP(connection());
- QWindowSurface::resize(size);
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
- QXcbWindow* win = static_cast<QXcbWindow *>(window()->platformWindow());
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window()));
+ QXcbWindow* win = static_cast<QXcbWindow *>(window()->handle());
delete m_image;
- m_image = new QXcbShmImage(screen, size, win->depth(), win->format());
+ m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat());
Q_XCB_NOOP(connection());
m_syncingResize = true;
@@ -254,9 +268,9 @@ void QXcbWindowSurface::resize(const QSize &size)
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
-bool QXcbWindowSurface::scroll(const QRegion &area, int dx, int dy)
+bool QXcbBackingStore::scroll(const QRegion &area, int dx, int dy)
{
- if (m_image->image()->isNull())
+ if (!m_image || m_image->image()->isNull())
return false;
m_image->preparePaint(area);
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbbackingstore.h
index 5f61815b65..db94d26b09 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.h
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.h
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#ifndef QXCBWINDOWSURFACE_H
-#define QXCBWINDOWSURFACE_H
+#ifndef QXCBBACKINGSTORE_H
+#define QXCBBACKINGSTORE_H
-#include <private/qwindowsurface_p.h>
+#include <qplatformbackingstore_qpa.h>
#include <xcb/xcb.h>
@@ -50,15 +50,15 @@
class QXcbShmImage;
-class QXcbWindowSurface : public QXcbObject, public QWindowSurface
+class QXcbBackingStore : public QXcbObject, public QPlatformBackingStore
{
public:
- QXcbWindowSurface(QWidget *widget, bool setDefaultSurface = true);
- ~QXcbWindowSurface();
+ QXcbBackingStore(QWindow *widget);
+ ~QXcbBackingStore();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size);
+ 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);
void beginPaint(const QRegion &);
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
new file mode 100644
index 0000000000..550b8cbd73
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -0,0 +1,848 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbclipboard.h"
+
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#include "qxcbmime.h"
+
+#include <private/qguiapplication_p.h>
+#include <QElapsedTimer>
+
+#include <QtCore/QDebug>
+
+#include <xcb/xcb_icccm.h>
+
+class QXcbClipboardMime : public QXcbMime
+{
+ Q_OBJECT
+public:
+ QXcbClipboardMime(QClipboard::Mode mode, QXcbClipboard *clipboard)
+ : QXcbMime()
+ , m_clipboard(clipboard)
+ {
+ switch (mode) {
+ case QClipboard::Selection:
+ modeAtom = XCB_ATOM_PRIMARY;
+ break;
+
+ case QClipboard::Clipboard:
+ modeAtom = m_clipboard->atom(QXcbAtom::CLIPBOARD);
+ break;
+
+ default:
+ qWarning("QTestLiteMime: Internal error: Unsupported clipboard mode");
+ break;
+ }
+ }
+
+protected:
+ QStringList formats_sys() const
+ {
+ if (empty())
+ return QStringList();
+
+ if (!formatList.count()) {
+ QXcbClipboardMime *that = const_cast<QXcbClipboardMime *>(this);
+ // get the list of targets from the current clipboard owner - we do this
+ // once so that multiple calls to this function don't require multiple
+ // server round trips...
+ that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->atom(QXcbAtom::TARGETS));
+
+ if (format_atoms.size() > 0) {
+ xcb_atom_t *targets = (xcb_atom_t *) format_atoms.data();
+ int size = format_atoms.size() / sizeof(xcb_atom_t);
+
+ for (int i = 0; i < size; ++i) {
+ if (targets[i] == 0)
+ continue;
+
+ QString format = mimeAtomToString(m_clipboard->connection(), targets[i]);
+ if (!formatList.contains(format))
+ that->formatList.append(format);
+ }
+ }
+ }
+
+ return formatList;
+ }
+
+ bool hasFormat_sys(const QString &format) const
+ {
+ QStringList list = formats();
+ return list.contains(format);
+ }
+
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
+ {
+ if (fmt.isEmpty() || empty())
+ return QByteArray();
+
+ (void)formats(); // trigger update of format list
+
+ QList<xcb_atom_t> atoms;
+ xcb_atom_t *targets = (xcb_atom_t *) format_atoms.data();
+ int size = format_atoms.size() / sizeof(xcb_atom_t);
+ for (int i = 0; i < size; ++i)
+ atoms.append(targets[i]);
+
+ QByteArray encoding;
+ xcb_atom_t fmtatom = mimeAtomForFormat(m_clipboard->connection(), fmt, requestedType, atoms, &encoding);
+
+ if (fmtatom == 0)
+ return QVariant();
+
+ return mimeConvertToFormat(m_clipboard->connection(), fmtatom, m_clipboard->getDataInFormat(modeAtom, fmtatom), fmt, requestedType, encoding);
+ }
+private:
+ bool empty() const
+ {
+ return m_clipboard->getSelectionOwner(modeAtom) == XCB_NONE;
+ }
+
+
+ xcb_atom_t modeAtom;
+ QXcbClipboard *m_clipboard;
+ QStringList formatList;
+ QByteArray format_atoms;
+};
+
+const int QXcbClipboard::clipboard_timeout = 5000;
+
+QXcbClipboard::QXcbClipboard(QXcbConnection *c)
+ : QXcbObject(c), QPlatformClipboard()
+ , m_requestor(XCB_NONE)
+ , m_owner(XCB_NONE)
+{
+ Q_ASSERT(QClipboard::Clipboard == 0);
+ Q_ASSERT(QClipboard::Selection == 1);
+ m_xClipboard[QClipboard::Clipboard] = 0;
+ m_xClipboard[QClipboard::Selection] = 0;
+ m_clientClipboard[QClipboard::Clipboard] = 0;
+ m_clientClipboard[QClipboard::Selection] = 0;
+ m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
+ m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME;
+
+ m_screen = connection()->screens().at(connection()->primaryScreen());
+
+ int x = 0, y = 0, w = 3, h = 3;
+
+ m_owner = xcb_generate_id(xcb_connection());
+ 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
+ x, y, w, h,
+ 0, // border width
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
+ m_screen->screen()->root_visual, // visual
+ 0, // value mask
+ 0)); // value list
+
+ if (connection()->hasXFixes()) {
+ const uint32_t mask = XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
+ XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |
+ XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE;
+ Q_XCB_CALL(xcb_xfixes_select_selection_input_checked(xcb_connection(), m_owner, XCB_ATOM_PRIMARY, mask));
+ Q_XCB_CALL(xcb_xfixes_select_selection_input_checked(xcb_connection(), m_owner, atom(QXcbAtom::CLIPBOARD), mask));
+ }
+}
+
+QXcbClipboard::~QXcbClipboard()
+{
+ // Transfer the clipboard content to the clipboard manager if we own a selection
+ if (m_timestamp[QClipboard::Clipboard] != XCB_CURRENT_TIME ||
+ m_timestamp[QClipboard::Selection] != XCB_CURRENT_TIME) {
+
+ // First we check if there is a clipboard manager.
+ xcb_get_selection_owner_cookie_t cookie = xcb_get_selection_owner(xcb_connection(), atom(QXcbAtom::CLIPBOARD_MANAGER));
+ xcb_get_selection_owner_reply_t *reply = xcb_get_selection_owner_reply(xcb_connection(), cookie, 0);
+ if (reply && reply->owner != XCB_NONE) {
+ // we delete the property so the manager saves all TARGETS.
+ xcb_delete_property(xcb_connection(), m_owner, atom(QXcbAtom::_QT_SELECTION));
+ xcb_convert_selection(xcb_connection(), m_owner, atom(QXcbAtom::CLIPBOARD_MANAGER), atom(QXcbAtom::SAVE_TARGETS),
+ atom(QXcbAtom::_QT_SELECTION), connection()->time());
+ connection()->sync();
+
+ // waiting until the clipboard manager fetches the content.
+ if (!waitForClipboardEvent(m_owner, XCB_SELECTION_NOTIFY, 5000)) {
+ qWarning("QClipboard: Unable to receive an event from the "
+ "clipboard manager in a reasonable time");
+ }
+ }
+ }
+}
+
+
+xcb_window_t QXcbClipboard::getSelectionOwner(xcb_atom_t atom) const
+{
+ xcb_connection_t *c = xcb_connection();
+ xcb_get_selection_owner_cookie_t cookie = xcb_get_selection_owner(c, atom);
+ xcb_get_selection_owner_reply_t *reply;
+ reply = xcb_get_selection_owner_reply(c, cookie, 0);
+ xcb_window_t win = reply->owner;
+ free(reply);
+ return win;
+}
+
+xcb_atom_t QXcbClipboard::atomForMode(QClipboard::Mode mode) const
+{
+ if (mode == QClipboard::Clipboard)
+ return atom(QXcbAtom::CLIPBOARD);
+ if (mode == QClipboard::Selection)
+ return XCB_ATOM_PRIMARY;
+ return XCB_NONE;
+}
+
+QClipboard::Mode QXcbClipboard::modeForAtom(xcb_atom_t a) const
+{
+ if (a == XCB_ATOM_PRIMARY)
+ return QClipboard::Selection;
+ if (a == atom(QXcbAtom::CLIPBOARD))
+ return QClipboard::Clipboard;
+ // not supported enum value, used to detect errors
+ return QClipboard::FindBuffer;
+}
+
+
+QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode)
+{
+ if (mode > QClipboard::Selection)
+ return 0;
+
+ xcb_window_t clipboardOwner = getSelectionOwner(atomForMode(mode));
+ if (clipboardOwner == owner()) {
+ return m_clientClipboard[mode];
+ } else {
+ if (!m_xClipboard[mode])
+ m_xClipboard[mode] = new QXcbClipboardMime(mode, this);
+
+ return m_xClipboard[mode];
+ }
+}
+
+void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ if (mode > QClipboard::Selection)
+ return;
+
+ xcb_atom_t modeAtom = atomForMode(mode);
+
+ if (m_clientClipboard[mode] == data)
+ return;
+
+ xcb_window_t newOwner = XCB_NONE;
+
+ if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection])
+ delete m_clientClipboard[mode];
+ m_clientClipboard[mode] = 0;
+ m_timestamp[mode] = XCB_CURRENT_TIME;
+
+ if (data) {
+ newOwner = owner();
+
+ m_clientClipboard[mode] = data;
+ m_timestamp[mode] = connection()->time();
+ }
+
+ xcb_set_selection_owner(xcb_connection(), newOwner, modeAtom, connection()->time());
+
+ if (getSelectionOwner(modeAtom) != newOwner) {
+ qWarning("QClipboard::setData: Cannot set X11 selection owner");
+ }
+
+}
+
+bool QXcbClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ if (mode <= QClipboard::Selection)
+ return true;
+ return false;
+}
+
+bool QXcbClipboard::ownsMode(QClipboard::Mode mode) const
+{
+ if (m_owner == XCB_NONE || mode > QClipboard::Selection)
+ return false;
+
+ Q_ASSERT(m_timestamp[mode] == XCB_CURRENT_TIME || getSelectionOwner(atomForMode(mode)) == m_owner);
+
+ return m_timestamp[mode] != XCB_CURRENT_TIME;
+}
+
+xcb_window_t QXcbClipboard::requestor() const
+{
+ if (!m_requestor) {
+ const int x = 0, y = 0, w = 3, h = 3;
+ QXcbClipboard *that = const_cast<QXcbClipboard *>(this);
+
+ xcb_window_t window = xcb_generate_id(xcb_connection());
+ 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
+ x, y, w, h,
+ 0, // border width
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
+ m_screen->screen()->root_visual, // visual
+ 0, // value mask
+ 0)); // value list
+
+ uint32_t mask = XCB_EVENT_MASK_PROPERTY_CHANGE;
+ xcb_change_window_attributes(xcb_connection(), window, XCB_CW_EVENT_MASK, &mask);
+
+ that->setRequestor(window);
+ }
+ return m_requestor;
+}
+
+void QXcbClipboard::setRequestor(xcb_window_t window)
+{
+ if (m_requestor != XCB_NONE) {
+ xcb_destroy_window(xcb_connection(), m_requestor);
+ }
+ m_requestor = window;
+}
+
+xcb_window_t QXcbClipboard::owner() const
+{
+ return m_owner;
+}
+
+xcb_atom_t QXcbClipboard::sendTargetsSelection(QMimeData *d, xcb_window_t window, xcb_atom_t property)
+{
+ QVector<xcb_atom_t> types;
+ QStringList formats = QInternalMimeData::formatsHelper(d);
+ for (int i = 0; i < formats.size(); ++i) {
+ QList<xcb_atom_t> atoms = QXcbMime::mimeAtomsForFormat(connection(), formats.at(i));
+ for (int j = 0; j < atoms.size(); ++j) {
+ if (!types.contains(atoms.at(j)))
+ types.append(atoms.at(j));
+ }
+ }
+ types.append(atom(QXcbAtom::TARGETS));
+ types.append(atom(QXcbAtom::MULTIPLE));
+ types.append(atom(QXcbAtom::TIMESTAMP));
+ types.append(atom(QXcbAtom::SAVE_TARGETS));
+
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, XCB_ATOM_ATOM,
+ 32, types.size(), (const void *)types.constData());
+ return property;
+}
+
+xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_window_t window, xcb_atom_t property)
+{
+ xcb_atom_t atomFormat = target;
+ int dataFormat = 0;
+ QByteArray data;
+
+ QString fmt = QXcbMime::mimeAtomToString(connection(), target);
+ if (fmt.isEmpty()) { // Not a MIME type we have
+// qDebug() << "QClipboard: send_selection(): converting to type" << connection()->atomName(target) << "is not supported";
+ return XCB_NONE;
+ }
+// qDebug() << "QClipboard: send_selection(): converting to type" << fmt;
+
+ if (QXcbMime::mimeDataForAtom(connection(), target, d, &data, &atomFormat, &dataFormat)) {
+
+ // don't allow INCR transfers when using MULTIPLE or to
+ // Motif clients (since Motif doesn't support INCR)
+ static xcb_atom_t motif_clip_temporary = atom(QXcbAtom::CLIP_TEMPORARY);
+ bool allow_incr = property != motif_clip_temporary;
+
+ // X_ChangeProperty protocol request is 24 bytes
+ const int increment = (xcb_get_maximum_request_length(xcb_connection()) * 4) - 24;
+ if (data.size() > increment && allow_incr) {
+ long bytes = data.size();
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property,
+ atom(QXcbAtom::INCR), 32, 1, (const void *)&bytes);
+
+// (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
+ qWarning() << "not implemented INCR just YET!";
+ return property;
+ }
+
+ // make sure we can perform the XChangeProperty in a single request
+ if (data.size() > increment)
+ return XCB_NONE; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
+ int dataSize = data.size() / (dataFormat / 8);
+ // use a single request to transfer data
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, atomFormat,
+ dataFormat, dataSize, (const void *)data.constData());
+ }
+ return property;
+}
+
+void QXcbClipboard::handleSelectionClearRequest(xcb_selection_clear_event_t *event)
+{
+ QClipboard::Mode mode = modeForAtom(event->selection);
+ if (mode > QClipboard::Selection)
+ return;
+
+ // ignore the event if it was generated before we gained selection ownership
+ if (m_timestamp[mode] != XCB_CURRENT_TIME && event->time <= m_timestamp[mode])
+ return;
+
+// DEBUG("QClipboard: new selection owner 0x%lx at time %lx (ours %lx)",
+// XGetSelectionOwner(dpy, XA_PRIMARY),
+// xevent->xselectionclear.time, d->timestamp);
+
+// if (!waiting_for_data) {
+ setMimeData(0, mode);
+ emitChanged(mode);
+// } else {
+// pending_selection_changed = true;
+// if (! pending_timer_id)
+// pending_timer_id = QApplication::clipboard()->startTimer(0);
+// }
+}
+
+void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
+{
+ if (requestor() && req->requestor == requestor()) {
+ qDebug() << "This should be caught before";
+ return;
+ }
+
+ xcb_selection_notify_event_t event;
+ event.response_type = XCB_SELECTION_NOTIFY;
+ event.requestor = req->requestor;
+ event.selection = req->selection;
+ event.target = req->target;
+ event.property = XCB_NONE;
+ event.time = req->time;
+
+ QMimeData *d;
+ QClipboard::Mode mode = modeForAtom(req->selection);
+ if (mode > QClipboard::Selection) {
+ qWarning() << "QClipboard: Unknown selection" << connection()->atomName(req->selection);
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ return;
+ }
+
+ d = m_clientClipboard[mode];
+
+ if (!d) {
+ qWarning("QClipboard: Cannot transfer data, no data available");
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ return;
+ }
+
+ if (m_timestamp[mode] == XCB_CURRENT_TIME // we don't own the selection anymore
+ || (req->time != XCB_CURRENT_TIME && req->time < m_timestamp[mode])) {
+ qDebug("QClipboard: SelectionRequest too old");
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ return;
+ }
+
+ xcb_atom_t xa_targets = atom(QXcbAtom::TARGETS);
+ xcb_atom_t xa_multiple = atom(QXcbAtom::MULTIPLE);
+ xcb_atom_t xa_timestamp = atom(QXcbAtom::TIMESTAMP);
+
+ struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = 0;
+ xcb_atom_t multi_type = XCB_NONE;
+ int multi_format = 0;
+ int nmulti = 0;
+ int imulti = -1;
+ bool multi_writeback = false;
+
+ if (req->target == xa_multiple) {
+ QByteArray multi_data;
+ if (req->property == XCB_NONE
+ || !clipboardReadProperty(req->requestor, req->property, false, &multi_data,
+ 0, &multi_type, &multi_format)
+ || multi_format != 32) {
+ // MULTIPLE property not formatted correctly
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ return;
+ }
+ nmulti = multi_data.size()/sizeof(*multi);
+ multi = new AtomPair[nmulti];
+ memcpy(multi,multi_data.data(),multi_data.size());
+ imulti = 0;
+ }
+
+ for (; imulti < nmulti; ++imulti) {
+ xcb_atom_t target;
+ xcb_atom_t property;
+
+ if (multi) {
+ target = multi[imulti].target;
+ property = multi[imulti].property;
+ } else {
+ target = req->target;
+ property = req->property;
+ if (property == XCB_NONE) // obsolete client
+ property = target;
+ }
+
+ xcb_atom_t ret = XCB_NONE;
+ if (target == XCB_NONE || property == XCB_NONE) {
+ ;
+ } else if (target == xa_timestamp) {
+ if (m_timestamp[mode] != XCB_CURRENT_TIME) {
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, req->requestor,
+ property, XCB_ATOM_INTEGER, 32, 1, &m_timestamp[mode]);
+ ret = property;
+ } else {
+ qWarning("QClipboard: Invalid data timestamp");
+ }
+ } else if (target == xa_targets) {
+ ret = sendTargetsSelection(d, req->requestor, property);
+ } else {
+ ret = sendSelection(d, target, req->requestor, property);
+ }
+
+ if (nmulti > 0) {
+ if (ret == XCB_NONE) {
+ multi[imulti].property = XCB_NONE;
+ multi_writeback = true;
+ }
+ } else {
+ event.property = ret;
+ break;
+ }
+ }
+
+ if (nmulti > 0) {
+ if (multi_writeback) {
+ // according to ICCCM 2.6.2 says to put None back
+ // into the original property on the requestor window
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, req->requestor, req->property,
+ multi_type, 32, nmulti*2, (const void *)multi);
+ }
+
+ delete [] multi;
+ event.property = req->property;
+ }
+
+ // send selection notify to requestor
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+}
+
+void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_event_t *event)
+{
+ QClipboard::Mode mode = modeForAtom(event->selection);
+ if (event->owner != owner() && m_clientClipboard[mode] && m_timestamp[mode] < event->selection_timestamp) {
+ setMimeData(0, mode);
+ emitChanged(mode);
+ }
+}
+
+
+static inline int maxSelectionIncr(xcb_connection_t *c)
+{
+ int l = xcb_get_maximum_request_length(c);
+ return (l > 65536 ? 65536*4 : l*4) - 100;
+}
+
+bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property, bool deleteProperty, QByteArray *buffer, int *size, xcb_atom_t *type, int *format) const
+{
+ int maxsize = maxSelectionIncr(xcb_connection());
+ ulong bytes_left; // bytes_after
+ xcb_atom_t dummy_type;
+ int dummy_format;
+
+ if (!type) // allow null args
+ type = &dummy_type;
+ if (!format)
+ format = &dummy_format;
+
+ // Don't read anything, just get the size of the property data
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, 0, 0));
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
+ if (!reply || reply->type == XCB_NONE) {
+ buffer->resize(0);
+ return false;
+ }
+ *type = reply->type;
+ *format = reply->format;
+ bytes_left = reply->bytes_after;
+ free(reply);
+
+ int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left;
+
+ switch (*format) {
+ case 8:
+ default:
+ format_inc = sizeof(char) / 1;
+ break;
+
+ case 16:
+ format_inc = sizeof(short) / 2;
+ proplen *= sizeof(short) / 2;
+ break;
+
+ case 32:
+ format_inc = sizeof(long) / 4;
+ proplen *= sizeof(long) / 4;
+ break;
+ }
+
+ int newSize = proplen;
+ buffer->resize(newSize);
+
+ bool ok = (buffer->size() == newSize);
+
+ if (ok && newSize) {
+ // could allocate buffer
+
+ while (bytes_left) {
+ // more to read...
+
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, offset, maxsize/4));
+ reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
+ if (!reply || reply->type == XCB_NONE) {
+ free(reply);
+ break;
+ }
+ *type = reply->type;
+ *format = reply->format;
+ bytes_left = reply->bytes_after;
+ char *data = (char *)xcb_get_property_value(reply);
+ int length = xcb_get_property_value_length(reply);
+
+ offset += length / (32 / *format);
+ length *= format_inc * (*format) / 8;
+
+ // Here we check if we get a buffer overflow and tries to
+ // recover -- this shouldn't normally happen, but it doesn't
+ // hurt to be defensive
+ if ((int)(buffer_offset + length) > buffer->size()) {
+ length = buffer->size() - buffer_offset;
+
+ // escape loop
+ bytes_left = 0;
+ }
+
+ memcpy(buffer->data() + buffer_offset, data, length);
+ buffer_offset += length;
+
+ free(reply);
+ }
+ }
+
+
+ // correct size, not 0-term.
+ if (size)
+ *size = buffer_offset;
+
+ if (deleteProperty)
+ xcb_delete_property(xcb_connection(), win, property);
+
+ connection()->flush();
+
+ return ok;
+}
+
+
+namespace
+{
+ class Notify {
+ public:
+ Notify(xcb_window_t win, int t)
+ : window(win), type(t) {}
+ xcb_window_t window;
+ int type;
+ bool check(xcb_generic_event_t *event) const {
+ if (!event)
+ return false;
+ int t = event->response_type & 0x7f;
+ if (t != type)
+ return false;
+ if (t == XCB_PROPERTY_NOTIFY) {
+ xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ if (pn->window == window)
+ return true;
+ } else if (t == XCB_SELECTION_NOTIFY) {
+ xcb_selection_notify_event_t *sn = (xcb_selection_notify_event_t *)event;
+ if (sn->requestor == window)
+ return true;
+ }
+ return false;
+ }
+ };
+ class ClipboardEvent {
+ public:
+ ClipboardEvent(QXcbConnection *c)
+ { clipboard = c->internAtom("CLIPBOARD"); }
+ xcb_atom_t clipboard;
+ bool check(xcb_generic_event_t *e) const {
+ if (!e)
+ return false;
+ int type = e->response_type & 0x7f;
+ if (type == XCB_SELECTION_REQUEST) {
+ xcb_selection_request_event_t *sr = (xcb_selection_request_event_t *)e;
+ return sr->selection == XCB_ATOM_PRIMARY || sr->selection == clipboard;
+ } else if (type == XCB_SELECTION_CLEAR) {
+ xcb_selection_clear_event_t *sc = (xcb_selection_clear_event_t *)e;
+ return sc->selection == XCB_ATOM_PRIMARY || sc->selection == clipboard;
+ }
+ return false;
+ }
+ };
+}
+
+xcb_generic_event_t *QXcbClipboard::waitForClipboardEvent(xcb_window_t win, int type, int timeout)
+{
+ QElapsedTimer timer;
+ timer.start();
+ do {
+ Notify notify(win, type);
+ xcb_generic_event_t *e = connection()->checkEvent(notify);
+ if (e)
+ return e;
+
+ // process other clipboard events, since someone is probably requesting data from us
+ ClipboardEvent clipboard(connection());
+ e = connection()->checkEvent(clipboard);
+ if (e) {
+ connection()->handleXcbEvent(e);
+ free(e);
+ }
+
+ connection()->flush();
+
+ // sleep 50 ms, so we don't use up CPU cycles all the time.
+ struct timeval usleep_tv;
+ usleep_tv.tv_sec = 0;
+ usleep_tv.tv_usec = 50000;
+ select(0, 0, 0, 0, &usleep_tv);
+ } while (timer.elapsed() < timeout);
+
+ return 0;
+}
+
+QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb_atom_t property, int nbytes, bool nullterm)
+{
+ QByteArray buf;
+ QByteArray tmp_buf;
+ bool alloc_error = false;
+ int length;
+ int offset = 0;
+
+ if (nbytes > 0) {
+ // Reserve buffer + zero-terminator (for text data)
+ // We want to complete the INCR transfer even if we cannot
+ // allocate more memory
+ buf.resize(nbytes+1);
+ alloc_error = buf.size() != nbytes+1;
+ }
+
+ for (;;) {
+ connection()->flush();
+ xcb_generic_event_t *ge = waitForClipboardEvent(win, XCB_PROPERTY_NOTIFY, clipboard_timeout);
+ if (!ge)
+ break;
+
+ xcb_property_notify_event_t *event = (xcb_property_notify_event_t *)ge;
+ if (event->atom != property || event->state != XCB_PROPERTY_NEW_VALUE)
+ continue;
+ if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
+ if (length == 0) { // no more data, we're done
+ if (nullterm) {
+ buf.resize(offset+1);
+ buf[offset] = '\0';
+ } else {
+ buf.resize(offset);
+ }
+ return buf;
+ } else if (!alloc_error) {
+ if (offset+length > (int)buf.size()) {
+ buf.resize(offset+length+65535);
+ if (buf.size() != offset+length+65535) {
+ alloc_error = true;
+ length = buf.size() - offset;
+ }
+ }
+ memcpy(buf.data()+offset, tmp_buf.constData(), length);
+ tmp_buf.resize(0);
+ offset += length;
+ }
+ } else {
+ break;
+ }
+
+ free(ge);
+ }
+
+ // timed out ... create a new requestor window, otherwise the requestor
+ // could consider next request to be still part of this timed out request
+ setRequestor(0);
+
+ return QByteArray();
+}
+
+QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAtom)
+{
+ return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::_QT_SELECTION));
+}
+
+QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property)
+{
+ QByteArray buf;
+ xcb_window_t win = requestor();
+
+ xcb_delete_property(xcb_connection(), win, property);
+ xcb_convert_selection(xcb_connection(), win, selection, target, property, connection()->time());
+
+ connection()->sync();
+
+ xcb_generic_event_t *ge = waitForClipboardEvent(win, XCB_SELECTION_NOTIFY, clipboard_timeout);
+ bool no_selection = !ge || ((xcb_selection_notify_event_t *)ge)->property == XCB_NONE;
+ free(ge);
+
+ if (no_selection)
+ return buf;
+
+ xcb_atom_t type;
+ if (clipboardReadProperty(win, property, true, &buf, 0, &type, 0)) {
+ if (type == atom(QXcbAtom::INCR)) {
+ int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
+ buf = clipboardReadIncrementalProperty(win, property, nbytes, false);
+ }
+ }
+
+ return buf;
+}
+
+#include "qxcbclipboard.moc"
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h
new file mode 100644
index 0000000000..d23f93529b
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbclipboard.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBCLIPBOARD_H
+#define QXCBCLIPBOARD_H
+
+#include <QPlatformClipboard>
+#include <qxcbobject.h>
+#include <xcb/xcb.h>
+#include <xcb/xfixes.h>
+
+class QXcbConnection;
+class QXcbScreen;
+class QXcbClipboardMime;
+
+class QXcbClipboard : public QXcbObject, public QPlatformClipboard
+{
+public:
+ QXcbClipboard(QXcbConnection *connection);
+ ~QXcbClipboard();
+
+ QMimeData *mimeData(QClipboard::Mode mode);
+ void setMimeData(QMimeData *data, QClipboard::Mode mode);
+
+ bool supportsMode(QClipboard::Mode mode) const;
+ bool ownsMode(QClipboard::Mode mode) const;
+
+ QXcbScreen *screen() const { return m_screen; }
+
+ xcb_window_t requestor() const;
+ void setRequestor(xcb_window_t window);
+
+ xcb_window_t owner() const;
+
+ void handleSelectionRequest(xcb_selection_request_event_t *event);
+ void handleSelectionClearRequest(xcb_selection_clear_event_t *event);
+ void handleXFixesSelectionRequest(xcb_xfixes_selection_notify_event_t *event);
+
+ bool clipboardReadProperty(xcb_window_t win, xcb_atom_t property, bool deleteProperty, QByteArray *buffer, int *size, xcb_atom_t *type, int *format) const;
+ QByteArray clipboardReadIncrementalProperty(xcb_window_t win, xcb_atom_t property, int nbytes, bool nullterm);
+
+ QByteArray getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtatom);
+
+ xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
+ QByteArray getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property);
+
+private:
+ xcb_generic_event_t *waitForClipboardEvent(xcb_window_t win, int type, int timeout);
+
+ xcb_atom_t sendTargetsSelection(QMimeData *d, xcb_window_t window, xcb_atom_t property);
+ xcb_atom_t sendSelection(QMimeData *d, xcb_atom_t target, xcb_window_t window, xcb_atom_t property);
+
+ 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];
+ xcb_timestamp_t m_timestamp[2];
+
+ xcb_window_t m_requestor;
+ xcb_window_t m_owner;
+
+ static const int clipboard_timeout;
+
+};
+
+#endif // QXCBCLIPBOARD_H
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 80a1624380..1e18077ea2 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -39,33 +39,40 @@
**
****************************************************************************/
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtCore/QDebug>
+
#include "qxcbconnection.h"
#include "qxcbkeyboard.h"
#include "qxcbscreen.h"
#include "qxcbwindow.h"
+#include "qxcbclipboard.h"
+#include "qxcbdrag.h"
+#include "qxcbwmsupport.h"
#include <QtAlgorithms>
#include <QSocketNotifier>
-#include <QtGui/private/qapplication_p.h>
#include <QAbstractEventDispatcher>
-#include <QtCore/QDebug>
-
#include <stdio.h>
#include <errno.h>
+#include <xcb/xfixes.h>
#ifdef XCB_USE_XLIB
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
#endif
+#ifdef XCB_USE_RENDER
+#include <xcb/render.h>
+#endif
+
#ifdef XCB_USE_EGL //dont pull in eglext prototypes
#include <EGL/egl.h>
#endif
#ifdef XCB_USE_DRI2
#include <xcb/dri2.h>
-#include <xcb/xfixes.h>
extern "C" {
#include <xf86drm.h>
}
@@ -83,12 +90,13 @@ QXcbConnection::QXcbConnection(const char *displayName)
, m_dri2_support_probed(false)
, m_has_support_for_dri2(false)
#endif
+ , xfixes_first_event(0)
{
- int primaryScreen = 0;
+ m_primaryScreen = 0;
#ifdef XCB_USE_XLIB
Display *dpy = XOpenDisplay(m_displayName.constData());
- primaryScreen = DefaultScreen(dpy);
+ m_primaryScreen = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy);
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
m_xlib_display = dpy;
@@ -100,13 +108,17 @@ QXcbConnection::QXcbConnection(const char *displayName)
m_has_egl = eglInitialize(eglDisplay,&major,&minor);
#endif //XCB_USE_EGL
#else
- m_connection = xcb_connect(m_displayName.constData(), &primaryScreen);
+ m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreen);
#endif //XCB_USE_XLIB
+ xcb_prefetch_extension_data (m_connection, &xcb_xfixes_id);
+
m_setup = xcb_get_setup(xcb_connection());
initializeAllAtoms();
+ m_time = XCB_CURRENT_TIME;
+
xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup);
int screenNumber = 0;
@@ -115,23 +127,24 @@ QXcbConnection::QXcbConnection(const char *displayName)
xcb_screen_next(&it);
}
+ initializeXFixes();
+ initializeXRender();
+
+ m_wmSupport = new QXcbWMSupport(this);
m_keyboard = new QXcbKeyboard(this);
+ m_clipboard = new QXcbClipboard(this);
+ m_drag = new QXcbDrag(this);
#ifdef XCB_USE_DRI2
initializeDri2();
#endif
-
- QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));
-
- QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(qApp->thread());
- connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));
-
sync();
}
QXcbConnection::~QXcbConnection()
{
+ delete m_clipboard;
+
qDeleteAll(m_screens);
#ifdef XCB_USE_XLIB
@@ -143,22 +156,35 @@ QXcbConnection::~QXcbConnection()
delete m_keyboard;
}
-QXcbWindow *platformWindowFromId(xcb_window_t id)
+void QXcbConnection::setEventDispatcher(QAbstractEventDispatcher *dispatcher)
{
- QWidget *widget = QWidget::find(id);
- if (widget)
- return static_cast<QXcbWindow *>(widget->platformWindow());
- return 0;
+ QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
+ connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));
+
+ connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));
+ connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents()));
+}
+
+void QXcbConnection::addWindow(xcb_window_t id, QXcbWindow *window)
+{
+ m_mapper.insert(id, window);
+}
+
+void QXcbConnection::removeWindow(xcb_window_t id)
+{
+ m_mapper.remove(id);
}
-#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \
+QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id)
+{
+ return m_mapper.value(id, 0);
+}
+
+#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \
{ \
event_t *e = (event_t *)event; \
- if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) { \
- QObjectPrivate *d = QObjectPrivate::get(platformWindow->widget()); \
- if (!d->wasDeleted) \
- platformWindow->handler(e); \
- } \
+ if (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) \
+ platformWindow->handler(e); \
} \
break;
@@ -166,7 +192,7 @@ break;
{ \
event_t *e = (event_t *)event; \
if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \
- m_keyboard->handler(platformWindow->widget(), e); \
+ m_keyboard->handler(platformWindow, e); \
} \
break;
@@ -409,69 +435,177 @@ void QXcbConnection::handleXcbError(xcb_generic_error_t *error)
#endif
}
+void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+{
+#ifdef Q_XCB_DEBUG
+ {
+ int i = 0;
+ for (; i < m_callLog.size(); ++i)
+ if (m_callLog.at(i).sequence >= event->sequence)
+ break;
+ m_callLog.remove(0, i);
+ }
+#endif
+ bool handled = true;
+
+ uint response_type = event->response_type & ~0x80;
+
+ switch (response_type) {
+ case XCB_EXPOSE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
+ case XCB_BUTTON_PRESS:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
+ case XCB_BUTTON_RELEASE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
+ case XCB_MOTION_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
+ case XCB_CONFIGURE_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
+ case XCB_MAP_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_map_notify_event_t, event, handleMapNotifyEvent);
+ case XCB_UNMAP_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_unmap_notify_event_t, event, handleUnmapNotifyEvent);
+ case XCB_CLIENT_MESSAGE:
+ handleClientMessageEvent((xcb_client_message_event_t *)event);
+ case XCB_ENTER_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent);
+ case XCB_LEAVE_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent);
+ case XCB_FOCUS_IN:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent);
+ case XCB_FOCUS_OUT:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent);
+ case XCB_KEY_PRESS:
+ HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent);
+ case XCB_KEY_RELEASE:
+ HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
+ case XCB_MAPPING_NOTIFY:
+ m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
+ break;
+ case XCB_SELECTION_REQUEST:
+ {
+ xcb_selection_request_event_t *sr = (xcb_selection_request_event_t *)event;
+ if (sr->selection == atom(QXcbAtom::XdndSelection))
+ m_drag->handleSelectionRequest(sr);
+ else
+ m_clipboard->handleSelectionRequest(sr);
+ break;
+ }
+ case XCB_SELECTION_CLEAR:
+ setTime(((xcb_selection_clear_event_t *)event)->time);
+ m_clipboard->handleSelectionClearRequest((xcb_selection_clear_event_t *)event);
+ handled = true;
+ break;
+ case XCB_SELECTION_NOTIFY:
+ setTime(((xcb_selection_notify_event_t *)event)->time);
+ qDebug() << "XCB_SELECTION_NOTIFY";
+ handled = false;
+ break;
+ case XCB_PROPERTY_NOTIFY:
+ setTime(((xcb_property_notify_event_t *)event)->time);
+// qDebug() << "XCB_PROPERTY_NOTIFY";
+ handled = false;
+ break;
+ default:
+ handled = false;
+ break;
+ }
+
+ if (!handled) {
+ if (response_type == xfixes_first_event + XCB_XFIXES_SELECTION_NOTIFY) {
+ setTime(((xcb_xfixes_selection_notify_event_t *)event)->timestamp);
+ m_clipboard->handleXFixesSelectionRequest((xcb_xfixes_selection_notify_event_t *)event);
+ handled = true;
+ }
+ }
+
+ if (handled)
+ printXcbEvent("Handled XCB event", event);
+ else
+ printXcbEvent("Unhandled XCB event", event);
+}
+
+void QXcbConnection::addPeekFunc(PeekFunc f)
+{
+ m_peekFuncs.append(f);
+}
+
void QXcbConnection::processXcbEvents()
{
- while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) {
- bool handled = true;
+ while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection()))
+ eventqueue.append(event);
+
+ for(int i = 0; i < eventqueue.size(); ++i) {
+ xcb_generic_event_t *event = eventqueue.at(i);
+ if (!event)
+ continue;
+ eventqueue[i] = 0;
uint response_type = event->response_type & ~0x80;
if (!response_type) {
handleXcbError((xcb_generic_error_t *)event);
- continue;
+ } else {
+ QVector<PeekFunc>::iterator it = m_peekFuncs.begin();
+ while (it != m_peekFuncs.end()) {
+ // These callbacks return true if the event is what they were
+ // waiting for, remove them from the list in that case.
+ if ((*it)(event))
+ it = m_peekFuncs.erase(it);
+ else
+ ++it;
+ }
+ handleXcbEvent(event);
}
-#ifdef Q_XCB_DEBUG
- {
- int i = 0;
- for (; i < m_callLog.size(); ++i)
- if (m_callLog.at(i).sequence >= event->sequence)
- break;
- m_callLog.remove(0, i);
- }
-#endif
-
- switch (response_type) {
- case XCB_EXPOSE:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
- case XCB_BUTTON_PRESS:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
- case XCB_BUTTON_RELEASE:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
- case XCB_MOTION_NOTIFY:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
- case XCB_CONFIGURE_NOTIFY:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
- case XCB_CLIENT_MESSAGE:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent);
- case XCB_ENTER_NOTIFY:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent);
- case XCB_LEAVE_NOTIFY:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent);
- case XCB_FOCUS_IN:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent);
- case XCB_FOCUS_OUT:
- HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent);
- case XCB_KEY_PRESS:
- HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent);
- case XCB_KEY_RELEASE:
- HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
- case XCB_MAPPING_NOTIFY:
- m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
- break;
- default:
- handled = false;
- break;
- }
- if (handled)
- printXcbEvent("Handled XCB event", event);
- else
- printXcbEvent("Unhandled XCB event", event);
+ free(event);
}
+ eventqueue.clear();
+
+ // Indicate with a null event that the event the callbacks are waiting for
+ // is not in the queue currently.
+ Q_FOREACH (PeekFunc f, m_peekFuncs)
+ f(0);
+ m_peekFuncs.clear();
+
xcb_flush(xcb_connection());
}
+void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t *event)
+{
+ if (event->format != 32)
+ return;
+
+ if (event->type == atom(QXcbAtom::XdndStatus)) {
+ drag()->handleStatus(event, false);
+ } else if (event->type == atom(QXcbAtom::XdndFinished)) {
+ drag()->handleFinished(event, false);
+ }
+
+ QXcbWindow *window = platformWindowFromId(event->window);
+ if (!window)
+ return;
+
+ window->handleClientMessageEvent(event);
+}
+
+
+xcb_generic_event_t *QXcbConnection::checkEvent(int type)
+{
+ while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection()))
+ eventqueue.append(event);
+
+ for (int i = 0; i < eventqueue.size(); ++i) {
+ xcb_generic_event_t *event = eventqueue.at(i);
+ if (event->response_type == type) {
+ eventqueue[i] = 0;
+ return event;
+ }
+ }
+ return 0;
+}
+
static const char * xcb_atomnames = {
// window-manager <-> client protocols
"WM_PROTOCOLS\0"
@@ -579,7 +713,6 @@ static const char * xcb_atomnames = {
"_NET_ACTIVE_WINDOW\0"
// Property formats
- "COMPOUND_TEXT\0"
"TEXT\0"
"UTF8_STRING\0"
@@ -659,8 +792,57 @@ void QXcbConnection::initializeAllAtoms() {
for (i = 0; i < QXcbAtom::NAtoms; ++i)
cookies[i] = xcb_intern_atom(xcb_connection(), false, strlen(names[i]), names[i]);
- for (i = 0; i < QXcbAtom::NAtoms; ++i)
- m_allAtoms[i] = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0)->atom;
+ for (i = 0; i < QXcbAtom::NAtoms; ++i) {
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0);
+ m_allAtoms[i] = reply->atom;
+ free(reply);
+ }
+}
+
+xcb_atom_t QXcbConnection::internAtom(const char *name)
+{
+ if (!name || *name == 0)
+ return XCB_NONE;
+
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(xcb_connection(), false, strlen(name), name);
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcb_connection(), cookie, 0);
+ int atom = reply->atom;
+ free(reply);
+ return atom;
+}
+
+QByteArray QXcbConnection::atomName(xcb_atom_t atom)
+{
+ if (!atom)
+ return QByteArray();
+
+ xcb_generic_error_t *error = 0;
+ xcb_get_atom_name_cookie_t cookie = Q_XCB_CALL(xcb_get_atom_name(xcb_connection(), atom));
+ xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(xcb_connection(), cookie, &error);
+ if (error) {
+ qWarning() << "QXcbConnection::atomName: bad Atom" << atom;
+ }
+ if (reply) {
+ QByteArray result(xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
+ free(reply);
+ return result;
+ }
+ return QByteArray();
+}
+
+const xcb_format_t *QXcbConnection::formatForDepth(uint8_t depth) const
+{
+ xcb_format_iterator_t iterator =
+ xcb_setup_pixmap_formats_iterator(m_setup);
+
+ while (iterator.rem) {
+ xcb_format_t *format = iterator.data;
+ if (format->depth == depth)
+ return format;
+ xcb_format_next(&iterator);
+ }
+
+ return 0;
}
void QXcbConnection::sync()
@@ -670,6 +852,43 @@ void QXcbConnection::sync()
free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0));
}
+void QXcbConnection::initializeXFixes()
+{
+ xcb_generic_error_t *error = 0;
+ const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_xfixes_id);
+ xfixes_first_event = reply->first_event;
+
+ xcb_xfixes_query_version_cookie_t xfixes_query_cookie = xcb_xfixes_query_version(m_connection,
+ XCB_XFIXES_MAJOR_VERSION,
+ XCB_XFIXES_MINOR_VERSION);
+ xcb_xfixes_query_version_reply_t *xfixes_query = xcb_xfixes_query_version_reply (m_connection,
+ xfixes_query_cookie, &error);
+ if (!xfixes_query || error || xfixes_query->major_version < 2) {
+ qWarning("Failed to initialize XFixes");
+ free(error);
+ xfixes_first_event = 0;
+ }
+ free(xfixes_query);
+
+}
+
+void QXcbConnection::initializeXRender()
+{
+#ifdef XCB_USE_RENDER
+ xcb_generic_error_t *error = 0;
+ xcb_render_query_version_cookie_t xrender_query_cookie = xcb_render_query_version(m_connection,
+ XCB_RENDER_MAJOR_VERSION,
+ XCB_RENDER_MINOR_VERSION);
+ xcb_render_query_version_reply_t *xrender_query = xcb_render_query_version_reply(m_connection,
+ xrender_query_cookie, &error);
+ if (!xrender_query || error || (xrender_query->major_version == 0 && xrender_query->minor_version < 5)) {
+ qWarning("Failed to initialize XRender");
+ free(error);
+ }
+ free(xrender_query);
+#endif
+}
+
#if defined(XCB_USE_EGL)
bool QXcbConnection::hasEgl() const
{
@@ -740,26 +959,12 @@ bool QXcbConnection::hasSupportForDri2() const
if (!m_dri2_support_probed) {
xcb_generic_error_t *error = 0;
- xcb_prefetch_extension_data (m_connection, &xcb_xfixes_id);
xcb_prefetch_extension_data (m_connection, &xcb_dri2_id);
- xcb_xfixes_query_version_cookie_t xfixes_query_cookie = xcb_xfixes_query_version(m_connection,
- XCB_XFIXES_MAJOR_VERSION,
- XCB_XFIXES_MINOR_VERSION);
-
xcb_dri2_query_version_cookie_t dri2_query_cookie = xcb_dri2_query_version (m_connection,
XCB_DRI2_MAJOR_VERSION,
XCB_DRI2_MINOR_VERSION);
- xcb_xfixes_query_version_reply_t *xfixes_query = xcb_xfixes_query_version_reply (m_connection,
- xfixes_query_cookie, &error);
- if (!xfixes_query || error || xfixes_query->major_version < 2) {
- delete error;
- delete xfixes_query;
- return false;
- }
- delete xfixes_query;
-
xcb_dri2_query_version_reply_t *dri2_query = xcb_dri2_query_version_reply (m_connection,
dri2_query_cookie, &error);
if (!dri2_query || error) {
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 01bc719546..bc90f5fcdc 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -44,6 +44,7 @@
#include <xcb/xcb.h>
+#include <QHash>
#include <QList>
#include <QObject>
#include <QVector>
@@ -51,6 +52,13 @@
#define Q_XCB_DEBUG
class QXcbScreen;
+class QXcbWindow;
+class QXcbDrag;
+class QXcbKeyboard;
+class QXcbClipboard;
+class QXcbWMSupport;
+
+typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper;
namespace QXcbAtom {
enum Atom {
@@ -160,7 +168,6 @@ namespace QXcbAtom {
_NET_ACTIVE_WINDOW,
// Property formats
- COMPOUND_TEXT,
TEXT,
UTF8_STRING,
@@ -215,8 +222,7 @@ namespace QXcbAtom {
};
}
-class QXcbKeyboard;
-
+class QAbstractEventDispatcher;
class QXcbConnection : public QObject
{
Q_OBJECT
@@ -226,17 +232,28 @@ public:
QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); }
- QList<QXcbScreen *> screens() const { return m_screens; }
+ void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
+
+ const QList<QXcbScreen *> &screens() const { return m_screens; }
int primaryScreen() const { return m_primaryScreen; }
xcb_atom_t atom(QXcbAtom::Atom atom);
+ xcb_atom_t internAtom(const char *name);
+ QByteArray atomName(xcb_atom_t atom);
const char *displayName() const { return m_displayName.constData(); }
xcb_connection_t *xcb_connection() const { return m_connection; }
+ const xcb_setup_t *setup() const { return m_setup; }
+ const xcb_format_t *formatForDepth(uint8_t depth) const;
QXcbKeyboard *keyboard() const { return m_keyboard; }
+ QXcbClipboard *clipboard() const { return m_clipboard; }
+ QXcbDrag *drag() const { return m_drag; }
+
+ QXcbWMSupport *wmSupport() const { return m_wmSupport; }
+
#ifdef XCB_USE_XLIB
void *xlib_display() const { return m_xlib_display; }
#endif
@@ -253,7 +270,26 @@ public:
#endif
void sync();
+ void flush() { xcb_flush(m_connection); }
+
void handleXcbError(xcb_generic_error_t *error);
+ void handleXcbEvent(xcb_generic_event_t *event);
+
+ void addWindow(xcb_window_t id, QXcbWindow *window);
+ void removeWindow(xcb_window_t id);
+ QXcbWindow *platformWindowFromId(xcb_window_t id);
+
+ xcb_generic_event_t *checkEvent(int type);
+ template<typename T>
+ inline xcb_generic_event_t *checkEvent(const T &checker);
+
+ typedef bool (*PeekFunc)(xcb_generic_event_t *);
+ void addPeekFunc(PeekFunc f);
+
+ inline xcb_timestamp_t time() const { return m_time; }
+ inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; }
+
+ bool hasXFixes() const { return xfixes_first_event > 0; }
private slots:
void processXcbEvents();
@@ -261,9 +297,12 @@ private slots:
private:
void initializeAllAtoms();
void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0);
+ void initializeXFixes();
+ void initializeXRender();
#ifdef XCB_USE_DRI2
void initializeDri2();
#endif
+ void handleClientMessageEvent(const xcb_client_message_event_t *event);
xcb_connection_t *m_connection;
const xcb_setup_t *m_setup;
@@ -273,9 +312,14 @@ private:
xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
+ xcb_timestamp_t m_time;
+
QByteArray m_displayName;
QXcbKeyboard *m_keyboard;
+ QXcbClipboard *m_clipboard;
+ QXcbDrag *m_drag;
+ QXcbWMSupport *m_wmSupport;
#if defined(XCB_USE_XLIB)
void *m_xlib_display;
@@ -303,10 +347,34 @@ private:
template <typename cookie_t>
friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line);
#endif
+ QVector<xcb_generic_event_t *> eventqueue;
+
+ WindowMapper m_mapper;
+
+ QVector<PeekFunc> m_peekFuncs;
+
+ uint32_t xfixes_first_event;
};
#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
+template<typename T>
+xcb_generic_event_t *QXcbConnection::checkEvent(const T &checker)
+{
+ while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection()))
+ eventqueue.append(event);
+
+ for (int i = 0; i < eventqueue.size(); ++i) {
+ xcb_generic_event_t *event = eventqueue.at(i);
+ if (checker.check(event)) {
+ eventqueue[i] = 0;
+ return event;
+ }
+ }
+ return 0;
+}
+
+
#ifdef Q_XCB_DEBUG
template <typename cookie_t>
cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line)
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
new file mode 100644
index 0000000000..f6856d5694
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -0,0 +1,546 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbcursor.h"
+#include "qxcbconnection.h"
+#include "qxcbwindow.h"
+#include "qxcbimage.h"
+#include <QtCore/QLibrary>
+#include <QtGui/QWindow>
+#include <QtGui/QBitmap>
+#include <QtGui/private/qguiapplication_p.h>
+#include <X11/cursorfont.h>
+#include <xcb/xfixes.h>
+#include <xcb/xcb_image.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef int (*PtrXcursorLibraryLoadCursor)(void *, const char *);
+static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = 0;
+static xcb_font_t cursorFont = 0;
+static int cursorCount = 0;
+
+static uint8_t cur_blank_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uint8_t cur_ver_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
+ 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
+static const uint8_t mcur_ver_bits[] = {
+ 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
+ 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
+ 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
+static const uint8_t cur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
+ 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t mcur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
+ 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
+ 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
+static const uint8_t cur_bdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
+ 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
+ 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t mcur_bdiag_bits[] = {
+ 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
+ 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
+ 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t cur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
+ 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
+ 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t mcur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
+ 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
+ 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
+static const uint8_t *cursor_bits16[] = {
+ cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
+ cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
+ 0, 0, cur_blank_bits, cur_blank_bits };
+
+static const uint8_t vsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t vsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t hsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
+ 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t hsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
+ 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
+ 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
+ 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uint8_t whatsthis_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
+ 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
+ 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
+ 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
+ 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
+ 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+static const uint8_t whatsthism_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
+ 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
+ 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
+ 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
+ 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
+ 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+static const uint8_t busy_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+ 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
+ 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
+ 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
+ 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
+ 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static const uint8_t busym_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+ 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
+ 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
+ 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
+ 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
+ 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static const uint8_t * const cursor_bits32[] = {
+ vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
+ 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
+};
+
+static const uint8_t forbidden_bits[] = {
+ 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
+ 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
+ 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
+ 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
+
+static const uint8_t forbiddenm_bits[] = {
+ 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
+ 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
+ 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
+ 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
+
+static const uint8_t openhand_bits[] = {
+ 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
+ 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
+ 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
+static const uint8_t openhandm_bits[] = {
+ 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
+ 0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
+ 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
+static const uint8_t closedhand_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
+ 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
+ 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
+static const uint8_t closedhandm_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
+ 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
+ 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
+
+static const uint8_t * const cursor_bits20[] = {
+ forbidden_bits, forbiddenm_bits
+};
+
+static const char * const cursorNames[] = {
+ "left_ptr",
+ "up_arrow",
+ "cross",
+ "wait",
+ "ibeam",
+ "size_ver",
+ "size_hor",
+ "size_bdiag",
+ "size_fdiag",
+ "size_all",
+ "blank",
+ "split_v",
+ "split_h",
+ "pointing_hand",
+ "forbidden",
+ "whats_this",
+ "left_ptr_watch",
+ "openhand",
+ "closedhand",
+ "copy",
+ "move",
+ "link"
+};
+
+QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
+ : QXcbObject(conn), QPlatformCursor(screen), m_screen(screen)
+{
+ if (cursorCount++)
+ return;
+
+ cursorFont = xcb_generate_id(xcb_connection());
+ const char *cursorStr = "cursor";
+ xcb_open_font(xcb_connection(), cursorFont, strlen(cursorStr), cursorStr);
+
+#ifdef XCB_USE_XLIB
+ QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
+ bool xcursorFound = xcursorLib.load();
+ if (!xcursorFound) { // try without the version number
+ xcursorLib.setFileName(QLatin1String("Xcursor"));
+ xcursorFound = xcursorLib.load();
+ }
+ if (xcursorFound)
+ ptrXcursorLibraryLoadCursor =
+ (PtrXcursorLibraryLoadCursor) xcursorLib.resolve("XcursorLibraryLoadCursor");
+#endif
+}
+
+QXcbCursor::~QXcbCursor()
+{
+ if (!--cursorCount)
+ xcb_close_font(xcb_connection(), cursorFont);
+}
+
+void QXcbCursor::changeCursor(QCursor *cursor, QWindow *widget)
+{
+ QXcbWindow *w = 0;
+ if (widget && widget->handle())
+ w = static_cast<QXcbWindow *>(widget->handle());
+ else
+ // No X11 cursor control when there is no widget under the cursor
+ return;
+
+ xcb_cursor_t c;
+ if (cursor->shape() == Qt::BitmapCursor) {
+ qint64 id = cursor->pixmap().cacheKey();
+ if (!m_bitmapCursorMap.contains(id))
+ m_bitmapCursorMap.insert(id, createBitmapCursor(cursor));
+ c = m_bitmapCursorMap.value(id);
+ } else {
+ int id = cursor->handle();
+ if (!m_shapeCursorMap.contains(id))
+ m_shapeCursorMap.insert(id, createFontCursor(cursor->shape()));
+ c = m_shapeCursorMap.value(id);
+ }
+
+ w->setCursor(c);
+}
+
+static int cursorIdForShape(int cshape)
+{
+ int cursorId = 0;
+ switch (cshape) {
+ case Qt::ArrowCursor:
+ cursorId = XC_left_ptr;
+ break;
+ case Qt::UpArrowCursor:
+ cursorId = XC_center_ptr;
+ break;
+ case Qt::CrossCursor:
+ cursorId = XC_crosshair;
+ break;
+ case Qt::WaitCursor:
+ cursorId = XC_watch;
+ break;
+ case Qt::IBeamCursor:
+ cursorId = XC_xterm;
+ break;
+ case Qt::SizeAllCursor:
+ cursorId = XC_fleur;
+ break;
+ case Qt::PointingHandCursor:
+ cursorId = XC_hand2;
+ break;
+ case Qt::SizeBDiagCursor:
+ cursorId = XC_top_right_corner;
+ break;
+ case Qt::SizeFDiagCursor:
+ cursorId = XC_bottom_right_corner;
+ break;
+ case Qt::SizeVerCursor:
+ case Qt::SplitVCursor:
+ cursorId = XC_sb_v_double_arrow;
+ break;
+ case Qt::SizeHorCursor:
+ case Qt::SplitHCursor:
+ cursorId = XC_sb_h_double_arrow;
+ break;
+ case Qt::WhatsThisCursor:
+ cursorId = XC_question_arrow;
+ break;
+ case Qt::ForbiddenCursor:
+ cursorId = XC_circle;
+ break;
+ case Qt::BusyCursor:
+ cursorId = XC_watch;
+ break;
+ default:
+ break;
+ }
+ return cursorId;
+}
+
+xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
+{
+ xcb_cursor_t cursor = 0;
+ xcb_connection_t *conn = xcb_connection();
+
+ if (cshape == Qt::BlankCursor) {
+ xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16,
+ 1, 0, 0, 0);
+ xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16,
+ 1, 0, 0, 0);
+ cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
+ } else if (cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor) {
+ int i = (cshape - Qt::SizeVerCursor) * 2;
+ xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(cursor_bits16[i]),
+ 16, 16, 1, 0, 0, 0);
+ xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(cursor_bits16[i + 1]),
+ 16, 16, 1, 0, 0, 0);
+ cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
+ } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
+ || cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) {
+ int i = (cshape - Qt::SplitVCursor) * 2;
+ xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(cursor_bits32[i]),
+ 32, 32, 1, 0, 0, 0);
+ xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(cursor_bits32[i + 1]),
+ 32, 32, 1, 0, 0, 0);
+ int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor
+ || cshape == Qt::BusyCursor) ? 0 : 16;
+ cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, hs, hs);
+ } else if (cshape == Qt::ForbiddenCursor) {
+ int i = (cshape - Qt::ForbiddenCursor) * 2;
+ xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(cursor_bits20[i]),
+ 20, 20, 1, 0, 0, 0);
+ xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(cursor_bits20[i + 1]),
+ 20, 20, 1, 0, 0, 0);
+ cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 10, 10);
+ } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
+ bool open = cshape == Qt::OpenHandCursor;
+ xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(open ? openhand_bits : closedhand_bits),
+ 16, 16, 1, 0, 0, 0);
+ xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
+ const_cast<uint8_t*>(open ? openhandm_bits : closedhandm_bits),
+ 16, 16, 1, 0, 0, 0);
+ cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
+ } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor
+ || cshape == Qt::DragLinkCursor) {
+ QImage image = QGuiApplicationPrivate::instance()->getPixmapCursor(static_cast<Qt::CursorShape>(cshape)).toImage();
+ xcb_pixmap_t pm = qt_xcb_XPixmapFromBitmap(m_screen, image);
+ xcb_pixmap_t pmm = qt_xcb_XPixmapFromBitmap(m_screen, image.createAlphaMask());
+ cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
+ }
+
+ return cursor;
+}
+
+xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
+{
+ xcb_connection_t *conn = xcb_connection();
+ int cursorId = cursorIdForShape(cshape);
+ xcb_cursor_t cursor = XCB_NONE;
+
+ // Try Xcursor first
+#ifdef XCB_USE_XLIB
+ if (ptrXcursorLibraryLoadCursor && cshape >= 0 && cshape < Qt::LastCursor) {
+ void *dpy = connection()->xlib_display();
+ // special case for non-standard dnd-* cursors
+ switch (cshape) {
+ case Qt::DragCopyCursor:
+ cursor = ptrXcursorLibraryLoadCursor(dpy, "dnd-copy");
+ break;
+ case Qt::DragMoveCursor:
+ cursor = ptrXcursorLibraryLoadCursor(dpy, "dnd-move");
+ break;
+ case Qt::DragLinkCursor:
+ cursor = ptrXcursorLibraryLoadCursor(dpy, "dnd-link");
+ break;
+ default:
+ break;
+ }
+ if (!cursor)
+ cursor = ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]);
+ }
+ if (cursor)
+ return cursor;
+#endif
+
+ // Non-standard X11 cursors are created from bitmaps
+ cursor = createNonStandardCursor(cshape);
+
+ // Create a glpyh cursor if everything else failed
+ if (!cursor && cursorId) {
+ cursor = xcb_generate_id(conn);
+ xcb_create_glyph_cursor(conn, cursor, cursorFont, cursorFont,
+ cursorId, cursorId + 1,
+ 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0);
+ }
+
+ if (cursor && cshape >= 0 && cshape < Qt::LastCursor) {
+ const char *name = cursorNames[cshape];
+ xcb_xfixes_set_cursor_name(conn, cursor, strlen(name), name);
+ }
+
+ return cursor;
+}
+
+xcb_cursor_t QXcbCursor::createBitmapCursor(QCursor *cursor)
+{
+ xcb_connection_t *conn = xcb_connection();
+ QPoint spot = cursor->hotSpot();
+ xcb_cursor_t c = XCB_NONE;
+ if (cursor->pixmap().depth() > 1)
+ c = qt_xcb_createCursorXRender(m_screen, cursor->pixmap().toImage(), spot);
+ if (!c) {
+ xcb_pixmap_t cp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->bitmap()->toImage());
+ xcb_pixmap_t mp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->mask()->toImage());
+ c = xcb_generate_id(conn);
+ xcb_create_cursor(conn, c, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF,
+ spot.x(), spot.y());
+ xcb_free_pixmap(conn, cp);
+ xcb_free_pixmap(conn, mp);
+ }
+ return c;
+}
+
+static void getPosAndRoot(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos)
+{
+ if (pos)
+ *pos = QPoint();
+ xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(conn));
+ while (it.rem) {
+ xcb_window_t root = it.data->root;
+ xcb_query_pointer_cookie_t cookie = xcb_query_pointer(conn, root);
+ xcb_generic_error_t *err = 0;
+ xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(conn, cookie, &err);
+ if (!err && reply) {
+ if (pos)
+ *pos = QPoint(reply->root_x, reply->root_y);
+ if (rootWin)
+ *rootWin = root;
+ free(reply);
+ return;
+ }
+ free(err);
+ free(reply);
+ xcb_screen_next(&it);
+ }
+}
+
+QPoint QXcbCursor::pos() const
+{
+ QPoint p;
+ getPosAndRoot(xcb_connection(), 0, &p);
+ return p;
+}
+
+void QXcbCursor::setPos(const QPoint &pos)
+{
+ xcb_connection_t *conn = xcb_connection();
+ xcb_window_t root;
+ getPosAndRoot(conn, &root, 0);
+ xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/platforms/xcb/qxcbcursor.h
index 6641379261..4bbb9a928b 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbcursor.h
@@ -39,36 +39,33 @@
**
****************************************************************************/
-#ifndef QDIRECTFBKEYBOARD_H
-#define QDIRECTFBKEYBOARD_H
+#ifndef QXCBCURSOR_H
+#define QXCBCURSOR_H
-#include <qglobal.h>
-#include <QtGui/qkbd_qws.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
+#include <QtGui/QPlatformCursor>
+#include "qxcbscreen.h"
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
-class QDirectFBKeyboardHandlerPrivate;
-
-class QDirectFBKeyboardHandler : public QWSKeyboardHandler
+class QXcbCursor : public QXcbObject, public QPlatformCursor
{
public:
- QDirectFBKeyboardHandler(const QString &device);
- ~QDirectFBKeyboardHandler();
+ QXcbCursor(QXcbConnection *conn, QXcbScreen *screen);
+ ~QXcbCursor();
+ void changeCursor(QCursor *cursor, QWindow *widget);
+ QPoint pos() const;
+ void setPos(const QPoint &pos);
private:
- QDirectFBKeyboardHandlerPrivate *d;
+ xcb_cursor_t createFontCursor(int cshape);
+ xcb_cursor_t createBitmapCursor(QCursor *cursor);
+ xcb_cursor_t createNonStandardCursor(int cshape);
+
+ QXcbScreen *m_screen;
+ QMap<int, xcb_cursor_t> m_shapeCursorMap;
+ QMap<qint64, xcb_cursor_t> m_bitmapCursorMap;
};
QT_END_NAMESPACE
-#endif // QT_NO_QWS_DIRECTFB
-
-QT_END_HEADER
-
-#endif // QDIRECTFBKEYBOARD_H
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
new file mode 100644
index 0000000000..f4e8afadc7
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -0,0 +1,1330 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbdrag.h"
+#include <xcb/xcb.h>
+#include "qxcbconnection.h"
+#include "qxcbclipboard.h"
+#include "qxcbmime.h"
+#include "qxcbwindow.h"
+#include "qxcbscreen.h"
+#include "qwindow.h"
+#include <private/qdnd_p.h>
+#include <qdebug.h>
+#include <qevent.h>
+#include <qguiapplication.h>
+#include <qrect.h>
+
+QT_BEGIN_NAMESPACE
+
+//#define DND_DEBUG
+#ifdef DND_DEBUG
+#define DEBUG qDebug
+#else
+#define DEBUG if(0) qDebug
+#endif
+
+#ifdef DND_DEBUG
+#define DNDDEBUG qDebug()
+#else
+#define DNDDEBUG if(0) qDebug()
+#endif
+
+const int xdnd_version = 5;
+
+static inline xcb_window_t xcb_window(QWindow *w)
+{
+ return static_cast<QXcbWindow *>(w->handle())->xcb_window();
+}
+
+
+static xcb_window_t xdndProxy(QXcbConnection *c, xcb_window_t w)
+{
+ xcb_window_t proxy = XCB_NONE;
+
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL2(xcb_get_property(c->xcb_connection(), false, w, c->atom(QXcbAtom::XdndProxy),
+ XCB_ATOM_WINDOW, 0, 1), c);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(c->xcb_connection(), cookie, 0);
+
+ if (reply && reply->type == XCB_ATOM_WINDOW)
+ proxy = *((xcb_window_t *)xcb_get_property_value(reply));
+ free(reply);
+
+ if (proxy == XCB_NONE)
+ return proxy;
+
+ // exists and is real?
+ cookie = Q_XCB_CALL2(xcb_get_property(c->xcb_connection(), false, proxy, c->atom(QXcbAtom::XdndProxy),
+ XCB_ATOM_WINDOW, 0, 1), c);
+ reply = xcb_get_property_reply(c->xcb_connection(), cookie, 0);
+
+ if (reply && reply->type == XCB_ATOM_WINDOW) {
+ xcb_window_t p = *((xcb_window_t *)xcb_get_property_value(reply));
+ if (proxy != p)
+ proxy = 0;
+ } else {
+ proxy = 0;
+ }
+
+ free(reply);
+
+ return proxy;
+}
+
+
+class QDropData : public QXcbMime
+{
+public:
+ QDropData(QXcbDrag *d);
+ ~QDropData();
+
+protected:
+ bool hasFormat_sys(const QString &mimeType) const;
+ QStringList formats_sys() const;
+ QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
+
+ QVariant xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const;
+
+ QXcbDrag *drag;
+};
+
+
+QXcbDrag::QXcbDrag(QXcbConnection *c)
+ : QXcbObject(c)
+{
+ dropData = new QDropData(this);
+
+ init();
+ heartbeat = -1;
+
+ transaction_expiry_timer = -1;
+}
+
+QXcbDrag::~QXcbDrag()
+{
+ delete dropData;
+}
+
+void QXcbDrag::init()
+{
+ currentWindow.clear();
+
+ xdnd_dragsource = XCB_NONE;
+ last_target_accepted_action = Qt::IgnoreAction;
+
+ waiting_for_status = false;
+ current_target = XCB_NONE;
+ current_proxy_target = XCB_NONE;
+ xdnd_dragging = false;
+
+ source_time = XCB_CURRENT_TIME;
+ target_time = XCB_CURRENT_TIME;
+
+ current_screen = 0;
+ drag_types.clear();
+}
+
+QMimeData *QXcbDrag::platformDropData()
+{
+ return dropData;
+}
+
+void QXcbDrag::startDrag()
+{
+ init();
+
+ heartbeat = startTimer(200);
+ xdnd_dragging = true;
+
+ xcb_set_selection_owner(xcb_connection(), connection()->clipboard()->owner(),
+ atom(QXcbAtom::XdndSelection), connection()->time());
+
+ QDragManager *manager = QDragManager::self();
+ QStringList fmts = QXcbMime::formatsHelper(manager->dropData());
+ for (int i = 0; i < fmts.size(); ++i) {
+ QList<xcb_atom_t> atoms = QXcbMime::mimeAtomsForFormat(connection(), fmts.at(i));
+ for (int j = 0; j < atoms.size(); ++j) {
+ if (!drag_types.contains(atoms.at(j)))
+ drag_types.append(atoms.at(j));
+ }
+ }
+ if (drag_types.size() > 3)
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->clipboard()->owner(),
+ atom(QXcbAtom::XdndTypelist),
+ XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
+
+ QMouseEvent me(QEvent::MouseMove, QCursor::pos(), QCursor::pos(), Qt::LeftButton,
+ QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
+ move(&me);
+
+// if (!QWidget::mouseGrabber())
+// manager->shapedPixmapWindow->grabMouse();
+}
+
+void QXcbDrag::endDrag()
+{
+ Q_ASSERT(heartbeat != -1);
+ killTimer(heartbeat);
+ heartbeat = -1;
+
+ xdnd_dragging = false;
+}
+
+static xcb_translate_coordinates_reply_t *
+translateCoordinates(QXcbConnection *c, xcb_window_t from, xcb_window_t to, int x, int y)
+{
+ xcb_translate_coordinates_cookie_t cookie =
+ xcb_translate_coordinates(c->xcb_connection(), from, to, x, y);
+ return xcb_translate_coordinates_reply(c->xcb_connection(), cookie, 0);
+}
+
+void QXcbDrag::move(const QMouseEvent *me)
+{
+ DEBUG() << "QDragManager::move enter";
+
+ // ###
+ QPoint globalPos = me->globalPos();
+
+ if (source_sameanswer.contains(globalPos) && source_sameanswer.isValid())
+ return;
+
+ const QList<QXcbScreen *> &screens = connection()->screens();
+ QXcbScreen *screen = screens.at(connection()->primaryScreen());
+ for (int i = 0; i < screens.size(); ++i) {
+ if (screens.at(i)->geometry().contains(globalPos)) {
+ screen = screens.at(i);
+ break;
+ }
+ }
+ if (screen != current_screen) {
+ // ### need to recreate the shaped pixmap window?
+// int screen = QCursor::x11Screen();
+// if ((qt_xdnd_current_screen == -1 && screen != X11->defaultScreen) || (screen != qt_xdnd_current_screen)) {
+// // recreate the pixmap on the new screen...
+// delete xdnd_data.deco;
+// QWidget* parent = object->source()->window()->x11Info().screen() == screen
+// ? object->source()->window() : QApplication::desktop()->screen(screen);
+// xdnd_data.deco = new QShapedPixmapWidget(parent);
+// if (!QWidget::mouseGrabber()) {
+// updatePixmap();
+// xdnd_data.deco->grabMouse();
+// }
+// }
+// xdnd_data.deco->move(QCursor::pos() - xdnd_data.deco->pm_hot);
+ current_screen = screen;
+ }
+
+
+// qt_xdnd_current_screen = screen;
+ xcb_window_t rootwin = current_screen->root();
+ xcb_translate_coordinates_reply_t *translate =
+ ::translateCoordinates(connection(), rootwin, rootwin, globalPos.x(), globalPos.y());
+ if (!translate)
+ return;
+ xcb_window_t target = translate->child;
+ int lx = translate->dst_x;
+ int ly = translate->dst_y;
+ free (translate);
+
+ if (target == rootwin) {
+ // Ok.
+ } else if (target) {
+ //me
+ xcb_window_t src = rootwin;
+ while (target != 0) {
+ DNDDEBUG << "checking target for XdndAware" << target;
+
+ // translate coordinates
+ translate = ::translateCoordinates(connection(), src, target, lx, ly);
+ if (!translate) {
+ target = 0;
+ break;
+ }
+ lx = translate->dst_x;
+ ly = translate->dst_y;
+ src = translate->child;
+ free(translate);
+
+ // check if it has XdndAware
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(xcb_connection(), false, target,
+ atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0));
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
+ bool aware = reply && reply->type != XCB_NONE;
+ free(reply);
+ if (aware) {
+ DNDDEBUG << "Found XdndAware on " << target;
+ break;
+ }
+
+ // find child at the coordinates
+ translate = ::translateCoordinates(connection(), src, src, lx, ly);
+ if (!translate) {
+ target = 0;
+ break;
+ }
+ target = translate->child;
+ free(translate);
+ }
+ // ####
+// if (xdnd_data.deco && (!target || target == xdnd_data.deco->effectiveWinId())) {
+// DNDDEBUG << "need to find real window";
+// target = findRealWindow(globalPos, rootwin, 6);
+// DNDDEBUG << "real window found" << QWidget::find(target) << target;
+// }
+ }
+
+ QXcbWindow *w = 0;
+ if (target) {
+ w = connection()->platformWindowFromId(target);
+ if (w && (w->window()->windowType() == Qt::Desktop) /*&& !w->acceptDrops()*/)
+ w = 0;
+ } else {
+ w = 0;
+ target = rootwin;
+ }
+
+ DNDDEBUG << "and the final target is " << target;
+ DNDDEBUG << "the widget w is" << (w ? w->window() : 0);
+
+ xcb_window_t proxy_target = xdndProxy(connection(), target);
+ if (!proxy_target)
+ proxy_target = target;
+ int target_version = 1;
+
+ if (proxy_target) {
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, target,
+ atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 1);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
+ if (!reply || reply->type == XCB_NONE)
+ target = 0;
+ target_version = xcb_get_property_value_length(reply) == 1 ? *(uint32_t *)xcb_get_property_value(reply) : 1;
+ if (target_version > xdnd_version)
+ target_version = xdnd_version;
+
+ free(reply);
+ }
+
+ DEBUG() << "target=" << target << "current_target=" << current_target;
+ if (target != current_target) {
+ if (current_target)
+ send_leave();
+
+ current_target = target;
+ current_proxy_target = proxy_target;
+ if (target) {
+ int flags = target_version << 24;
+ if (drag_types.size() > 3)
+ flags |= 0x0001;
+
+ xcb_client_message_event_t enter;
+ enter.response_type = XCB_CLIENT_MESSAGE;
+ enter.window = target;
+ enter.format = 32;
+ enter.type = atom(QXcbAtom::XdndEnter);
+ enter.data.data32[0] = connection()->clipboard()->owner();
+ enter.data.data32[1] = flags;
+ enter.data.data32[2] = drag_types.size()>0 ? drag_types.at(0) : 0;
+ enter.data.data32[3] = drag_types.size()>1 ? drag_types.at(1) : 0;
+ enter.data.data32[4] = drag_types.size()>2 ? drag_types.at(2) : 0;
+ // provisionally set the rectangle to 5x5 pixels...
+ source_sameanswer = QRect(globalPos.x() - 2, globalPos.y() -2 , 5, 5);
+
+ DEBUG() << "sending Xdnd enter source=" << enter.data.data32[0];
+ if (w)
+ handleEnter(w->window(), &enter);
+ else if (target)
+ xcb_send_event(xcb_connection(), false, proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&enter);
+ waiting_for_status = false;
+ }
+ }
+ if (waiting_for_status)
+ return;
+
+ QDragManager *m = QDragManager::self();
+
+ if (target) {
+ waiting_for_status = true;
+
+ xcb_client_message_event_t move;
+ move.response_type = XCB_CLIENT_MESSAGE;
+ move.window = target;
+ move.format = 32;
+ move.type = atom(QXcbAtom::XdndPosition);
+ move.window = target;
+ move.data.data32[0] = connection()->clipboard()->owner();
+ move.data.data32[1] = 0; // flags
+ move.data.data32[2] = (globalPos.x() << 16) + globalPos.y();
+ move.data.data32[3] = connection()->time();
+ move.data.data32[4] = toXdndAction(m->defaultAction(m->dragPrivate()->possible_actions, QGuiApplication::keyboardModifiers()));
+ DEBUG() << "sending Xdnd position source=" << move.data.data32[0] << "target=" << move.window;
+
+ source_time = connection()->time();
+
+ if (w)
+ handle_xdnd_position(w->window(), &move, false);
+ else
+ xcb_send_event(xcb_connection(), false, proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&move);
+ } else {
+ if (m->willDrop) {
+ m->willDrop = false;
+ m->updateCursor();
+ }
+ }
+ DEBUG() << "QDragManager::move leave";
+}
+
+void QXcbDrag::drop(const QMouseEvent *)
+{
+ endDrag();
+
+ if (!current_target)
+ return;
+
+ xcb_client_message_event_t drop;
+ drop.response_type = XCB_CLIENT_MESSAGE;
+ drop.window = current_target;
+ drop.format = 32;
+ drop.type = atom(QXcbAtom::XdndDrop);
+ drop.data.data32[0] = connection()->clipboard()->owner();
+ drop.data.data32[1] = 0; // flags
+ drop.data.data32[2] = connection()->time();
+
+ drop.data.data32[3] = 0;
+ drop.data.data32[4] = 0;
+
+ QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target);
+
+ if (w && (w->window()->windowType() == Qt::Desktop) /*&& !w->acceptDrops()*/)
+ w = 0;
+
+ QDragManager *manager = QDragManager::self();
+
+ Transaction t = {
+ connection()->time(),
+ current_target,
+ current_proxy_target,
+ (w ? w->window() : 0),
+// current_embedding_widget,
+ manager->object
+ };
+ transactions.append(t);
+ restartDropExpiryTimer();
+
+ if (w)
+ handleDrop(w->window(), &drop, false);
+ else
+ xcb_send_event(xcb_connection(), false, current_proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&drop);
+
+ current_target = 0;
+ current_proxy_target = 0;
+ source_time = 0;
+// current_embedding_widget = 0;
+ manager->object = 0;
+}
+
+Qt::DropAction QXcbDrag::toDropAction(xcb_atom_t a) const
+{
+ if (a == atom(QXcbAtom::XdndActionCopy) || a == 0)
+ return Qt::CopyAction;
+ if (a == atom(QXcbAtom::XdndActionLink))
+ return Qt::LinkAction;
+ if (a == atom(QXcbAtom::XdndActionMove))
+ return Qt::MoveAction;
+ return Qt::CopyAction;
+}
+
+xcb_atom_t QXcbDrag::toXdndAction(Qt::DropAction a) const
+{
+ switch (a) {
+ case Qt::CopyAction:
+ return atom(QXcbAtom::XdndActionCopy);
+ case Qt::LinkAction:
+ return atom(QXcbAtom::XdndActionLink);
+ case Qt::MoveAction:
+ case Qt::TargetMoveAction:
+ return atom(QXcbAtom::XdndActionMove);
+ case Qt::IgnoreAction:
+ return XCB_NONE;
+ default:
+ return atom(QXcbAtom::XdndActionCopy);
+ }
+}
+
+// timer used to discard old XdndDrop transactions
+enum { XdndDropTransactionTimeout = 5000 }; // 5 seconds
+
+void QXcbDrag::restartDropExpiryTimer()
+{
+ if (transaction_expiry_timer != -1)
+ killTimer(transaction_expiry_timer);
+ transaction_expiry_timer = startTimer(XdndDropTransactionTimeout);
+}
+
+int QXcbDrag::findTransactionByWindow(xcb_window_t window)
+{
+ int at = -1;
+ for (int i = 0; i < transactions.count(); ++i) {
+ const Transaction &t = transactions.at(i);
+ if (t.target == window || t.proxy_target == window) {
+ at = i;
+ break;
+ }
+ }
+ return at;
+}
+
+int QXcbDrag::findTransactionByTime(xcb_timestamp_t timestamp)
+{
+ int at = -1;
+ for (int i = 0; i < transactions.count(); ++i) {
+ const Transaction &t = transactions.at(i);
+ if (t.timestamp == timestamp) {
+ at = i;
+ break;
+ }
+ }
+ return at;
+}
+
+#if 0
+
+// find an ancestor with XdndAware on it
+static Window findXdndAwareParent(Window window)
+{
+ Window target = 0;
+ forever {
+ // check if window has XdndAware
+ Atom type = 0;
+ int f;
+ unsigned long n, a;
+ unsigned char *data = 0;
+ if (XGetWindowProperty(X11->display, window, ATOM(XdndAware), 0, 0, False,
+ AnyPropertyType, &type, &f,&n,&a,&data) == Success) {
+ if (data)
+ XFree(data);
+ if (type) {
+ target = window;
+ break;
+ }
+ }
+
+ // try window's parent
+ Window root;
+ Window parent;
+ Window *children;
+ uint unused;
+ if (!XQueryTree(X11->display, window, &root, &parent, &children, &unused))
+ break;
+ if (children)
+ XFree(children);
+ if (window == root)
+ break;
+ window = parent;
+ }
+ return target;
+}
+
+
+// for embedding only
+static QWidget* current_embedding_widget = 0;
+static xcb_client_message_event_t last_enter_event;
+
+
+static bool checkEmbedded(QWidget* w, const XEvent* xe)
+{
+ if (!w)
+ return false;
+
+ if (current_embedding_widget != 0 && current_embedding_widget != w) {
+ current_target = ((QExtraWidget*)current_embedding_widget)->extraData()->xDndProxy;
+ current_proxy_target = current_target;
+ qt_xdnd_send_leave();
+ current_target = 0;
+ current_proxy_target = 0;
+ current_embedding_widget = 0;
+ }
+
+ QWExtra* extra = ((QExtraWidget*)w)->extraData();
+ if (extra && extra->xDndProxy != 0) {
+
+ if (current_embedding_widget != w) {
+
+ last_enter_event.xany.window = extra->xDndProxy;
+ XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, &last_enter_event);
+ current_embedding_widget = w;
+ }
+
+ ((XEvent*)xe)->xany.window = extra->xDndProxy;
+ XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, (XEvent*)xe);
+ if (currentWindow != w) {
+ currentWindow = w;
+ }
+ return true;
+ }
+ current_embedding_widget = 0;
+ return false;
+}
+#endif
+
+
+void QXcbDrag::handleEnter(QWindow *window, const xcb_client_message_event_t *event)
+{
+ Q_UNUSED(window);
+ DEBUG() << "handleEnter" << window;
+
+ xdnd_types.clear();
+// motifdnd_active = false;
+// last_enter_event.xclient = xe->xclient;
+
+ int version = (int)(event->data.data32[1] >> 24);
+ if (version > xdnd_version)
+ return;
+
+ xdnd_dragsource = event->data.data32[0];
+
+ if (event->data.data32[1] & 1) {
+ // get the types from XdndTypeList
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, xdnd_dragsource,
+ atom(QXcbAtom::XdndTypelist), XCB_ATOM_ATOM,
+ 0, xdnd_max_type);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
+ if (reply && reply->type != XCB_NONE && reply->format == 32) {
+ int length = xcb_get_property_value_length(reply) / 4;
+ if (length > xdnd_max_type)
+ length = xdnd_max_type;
+
+ xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply);
+ for (int i = 0; i < length; ++i)
+ xdnd_types.append(atoms[i]);
+ }
+ free(reply);
+ } else {
+ // get the types from the message
+ for(int i = 2; i < 5; i++) {
+ if (event->data.data32[i])
+ xdnd_types.append(event->data.data32[i]);
+ }
+ }
+ for(int i = 0; i < xdnd_types.length(); ++i)
+ DEBUG() << " " << connection()->atomName(xdnd_types.at(i));
+}
+
+void QXcbDrag::handle_xdnd_position(QWindow *w, const xcb_client_message_event_t *e, bool passive)
+{
+ QPoint p((e->data.data32[2] & 0xffff0000) >> 16, e->data.data32[2] & 0x0000ffff);
+ Q_ASSERT(w);
+ QRect geometry = w->geometry();
+
+ p -= geometry.topLeft();
+
+ // ####
+// if (!passive && checkEmbedded(w, e))
+// return;
+
+ if (!w || (/*!w->acceptDrops() &&*/ (w->windowType() == Qt::Desktop)))
+ return;
+
+ if (e->data.data32[0] != xdnd_dragsource) {
+ DEBUG("xdnd drag position from unexpected source (%x not %x)", e->data.data32[0], xdnd_dragsource);
+ return;
+ }
+
+ // timestamp from the source
+ if (e->data.data32[3] != XCB_NONE)
+ target_time /*= X11->userTime*/ = e->data.data32[3];
+
+ QDragManager *manager = QDragManager::self();
+ QMimeData *dropData = manager->dropData();
+
+ xcb_client_message_event_t response;
+ response.response_type = XCB_CLIENT_MESSAGE;
+ response.window = xdnd_dragsource;
+ response.format = 32;
+ response.type = atom(QXcbAtom::XdndStatus);
+ response.data.data32[0] = xcb_window(w);
+ response.data.data32[1] = 0; // flags
+ response.data.data32[2] = 0; // x, y
+ response.data.data32[3] = 0; // w, h
+ response.data.data32[4] = 0; // action
+
+ if (!passive) { // otherwise just reject
+ QRect answerRect(p + geometry.topLeft(), QSize(1,1));
+
+ if (manager->object) {
+ manager->possible_actions = manager->dragPrivate()->possible_actions;
+ } else {
+ manager->possible_actions = Qt::DropActions(toDropAction(e->data.data32[4]));
+ }
+ QDragMoveEvent me(p, manager->possible_actions, dropData,
+ QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
+
+ Qt::DropAction accepted_action = Qt::IgnoreAction;
+
+ currentPosition = p;
+
+ if (w != currentWindow.data()) {
+ if (currentWindow) {
+ QDragLeaveEvent e;
+ QGuiApplication::sendEvent(currentWindow.data(), &e);
+ }
+ currentWindow = w;
+
+ last_target_accepted_action = Qt::IgnoreAction;
+ QDragEnterEvent de(p, manager->possible_actions, dropData,
+ QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
+ QGuiApplication::sendEvent(w, &de);
+ if (de.isAccepted() && de.dropAction() != Qt::IgnoreAction)
+ last_target_accepted_action = de.dropAction();
+ }
+
+ DEBUG() << "qt_handle_xdnd_position action=" << connection()->atomName(e->data.data32[4]);
+
+ if (last_target_accepted_action != Qt::IgnoreAction) {
+ me.setDropAction(last_target_accepted_action);
+ me.accept();
+ }
+ QGuiApplication::sendEvent(w, &me);
+ if (me.isAccepted()) {
+ response.data.data32[1] = 1; // yes
+ accepted_action = me.dropAction();
+ last_target_accepted_action = accepted_action;
+ } else {
+ response.data.data32[0] = 0;
+ last_target_accepted_action = Qt::IgnoreAction;
+ }
+ answerRect = me.answerRect().translated(geometry.topLeft()).intersected(geometry);
+
+ if (answerRect.left() < 0)
+ answerRect.setLeft(0);
+ if (answerRect.right() > 4096)
+ answerRect.setRight(4096);
+ if (answerRect.top() < 0)
+ answerRect.setTop(0);
+ if (answerRect.bottom() > 4096)
+ answerRect.setBottom(4096);
+ if (answerRect.width() < 0)
+ answerRect.setWidth(0);
+ if (answerRect.height() < 0)
+ answerRect.setHeight(0);
+
+// response.data.data32[2] = (answerRect.x() << 16) + answerRect.y();
+// response.data.data32[3] = (answerRect.width() << 16) + answerRect.height();
+ response.data.data32[4] = toXdndAction(accepted_action);
+ }
+
+ // reset
+ target_time = XCB_CURRENT_TIME;
+
+ DEBUG() << "sending XdndStatus" << (xdnd_dragsource == connection()->clipboard()->owner()) << xdnd_dragsource
+ << response.data.data32[1] << connection()->atomName(response.data.data32[4]);
+ if (xdnd_dragsource == connection()->clipboard()->owner())
+ handle_xdnd_status(&response, passive);
+ else
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, xdnd_dragsource,
+ XCB_EVENT_MASK_NO_EVENT, (const char *)&response));
+}
+
+namespace
+{
+ class ClientMessageScanner {
+ public:
+ ClientMessageScanner(xcb_atom_t a) : atom(a) {}
+ xcb_atom_t atom;
+ bool check(xcb_generic_event_t *event) const {
+ if (!event)
+ return false;
+ if ((event->response_type & 0x7f) != XCB_CLIENT_MESSAGE)
+ return false;
+ return ((xcb_client_message_event_t *)event)->type == atom;
+ }
+ };
+}
+
+void QXcbDrag::handlePosition(QWindow * w, const xcb_client_message_event_t *event, bool passive)
+{
+ xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event);
+ xcb_generic_event_t *nextEvent;
+ ClientMessageScanner scanner(atom(QXcbAtom::XdndPosition));
+ while ((nextEvent = connection()->checkEvent(scanner))) {
+ if (lastEvent != event)
+ free(lastEvent);
+ lastEvent = (xcb_client_message_event_t *)nextEvent;
+ }
+
+ handle_xdnd_position(w, lastEvent, passive);
+ if (lastEvent != event)
+ free(lastEvent);
+}
+
+void QXcbDrag::handle_xdnd_status(const xcb_client_message_event_t *event, bool)
+{
+ DEBUG("xdndHandleStatus");
+ // ignore late status messages
+ if (event->data.data32[0] && event->data.data32[0] != current_proxy_target)
+ return;
+
+ Qt::DropAction newAction = (event->data.data32[1] & 0x1) ? toDropAction(event->data.data32[4]) : Qt::IgnoreAction;
+
+ if ((event->data.data32[1] & 2) == 0) {
+ QPoint p((event->data.data32[2] & 0xffff0000) >> 16, event->data.data32[2] & 0x0000ffff);
+ QSize s((event->data.data32[3] & 0xffff0000) >> 16, event->data.data32[3] & 0x0000ffff);
+ source_sameanswer = QRect(p, s);
+ } else {
+ source_sameanswer = QRect();
+ }
+ QDragManager *manager = QDragManager::self();
+ manager->willDrop = (event->data.data32[1] & 0x1);
+ if (manager->global_accepted_action != newAction) {
+ manager->global_accepted_action = newAction;
+ manager->emitActionChanged(newAction);
+ }
+ DEBUG() << "willDrop=" << manager->willDrop << "action=" << newAction;
+ manager->updateCursor();
+ waiting_for_status = false;
+}
+
+void QXcbDrag::handleStatus(const xcb_client_message_event_t *event, bool passive)
+{
+ if (event->window != connection()->clipboard()->owner())
+ return;
+
+ xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event);
+ qDebug() << "handleStatus" << lastEvent->window << lastEvent->data.data32[0];
+ xcb_generic_event_t *nextEvent;
+ ClientMessageScanner scanner(atom(QXcbAtom::XdndStatus));
+ while ((nextEvent = connection()->checkEvent(scanner))) {
+ if (lastEvent != event)
+ free(lastEvent);
+ lastEvent = (xcb_client_message_event_t *)nextEvent;
+ }
+
+ handle_xdnd_status(lastEvent, passive);
+ if (lastEvent != event)
+ free(lastEvent);
+ DEBUG("xdndHandleStatus end");
+}
+
+void QXcbDrag::handleLeave(QWindow *w, const xcb_client_message_event_t *event, bool /*passive*/)
+{
+ DEBUG("xdnd leave");
+ if (!currentWindow || w != currentWindow.data())
+ return; // sanity
+
+ // ###
+// if (checkEmbedded(current_embedding_widget, event)) {
+// current_embedding_widget = 0;
+// currentWindow.clear();
+// return;
+// }
+
+ if (event->data.data32[0] != xdnd_dragsource) {
+ // This often happens - leave other-process window quickly
+ DEBUG("xdnd drag leave from unexpected source (%x not %x", event->data.data32[0], xdnd_dragsource);
+ }
+
+ QDragLeaveEvent e;
+ QGuiApplication::sendEvent(currentWindow.data(), &e);
+
+ xdnd_dragsource = 0;
+ xdnd_types.clear();
+ currentWindow.clear();
+}
+
+void QXcbDrag::send_leave()
+{
+ if (!current_target)
+ return;
+
+ QDragManager *manager = QDragManager::self();
+
+ xcb_client_message_event_t leave;
+ leave.response_type = XCB_CLIENT_MESSAGE;
+ leave.window = current_target;
+ leave.format = 32;
+ leave.type = atom(QXcbAtom::XdndLeave);
+ leave.data.data32[0] = connection()->clipboard()->owner();
+ leave.data.data32[1] = 0; // flags
+ leave.data.data32[2] = 0; // x, y
+ leave.data.data32[3] = 0; // w, h
+ leave.data.data32[4] = 0; // just null
+
+ QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target);
+
+ if (w && (w->window()->windowType() == Qt::Desktop) /*&& !w->acceptDrops()*/)
+ w = 0;
+
+ if (w)
+ handleLeave(w->window(), (const xcb_client_message_event_t *)&leave, false);
+ else
+ xcb_send_event(xcb_connection(), false,current_proxy_target,
+ XCB_EVENT_MASK_NO_EVENT, (const char *)&leave);
+
+ // reset the drag manager state
+ manager->willDrop = false;
+ if (manager->global_accepted_action != Qt::IgnoreAction)
+ manager->emitActionChanged(Qt::IgnoreAction);
+ manager->global_accepted_action = Qt::IgnoreAction;
+ manager->updateCursor();
+ current_target = 0;
+ current_proxy_target = 0;
+ source_time = XCB_CURRENT_TIME;
+ waiting_for_status = false;
+}
+
+void QXcbDrag::handleDrop(QWindow *, const xcb_client_message_event_t *event, bool passive)
+{
+ DEBUG("xdndHandleDrop");
+ if (!currentWindow) {
+ xdnd_dragsource = 0;
+ return; // sanity
+ }
+
+ // ###
+// if (!passive && checkEmbedded(currentWindow, xe)){
+// current_embedding_widget = 0;
+// xdnd_dragsource = 0;
+// currentWindow = 0;
+// return;
+// }
+ const uint32_t *l = event->data.data32;
+
+ QDragManager *manager = QDragManager::self();
+ DEBUG("xdnd drop");
+
+ if (l[0] != xdnd_dragsource) {
+ DEBUG("xdnd drop from unexpected source (%x not %x", l[0], xdnd_dragsource);
+ return;
+ }
+
+ // update the "user time" from the timestamp in the event.
+ if (l[2] != 0)
+ target_time = /*X11->userTime =*/ l[2];
+
+ if (!passive) {
+ // this could be a same-application drop, just proxied due to
+ // some XEMBEDding, so try to find the real QMimeData used
+ // based on the timestamp for this drop.
+ QMimeData *dropData = 0;
+ // ###
+// int at = findXdndDropTransactionByTime(target_time);
+// if (at != -1)
+// dropData = QDragManager::dragPrivate(X11->dndDropTransactions.at(at).object)->data;
+ // if we can't find it, then use the data in the drag manager
+ if (!dropData)
+ dropData = manager->dropData();
+
+ // Drop coming from another app? Update keyboard modifiers.
+// if (!qt_xdnd_dragging) {
+// QApplicationPrivate::modifier_buttons = currentKeyboardModifiers();
+// }
+
+ QDropEvent de(currentPosition, manager->possible_actions, dropData,
+ QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
+ QGuiApplication::sendEvent(currentWindow.data(), &de);
+ if (!de.isAccepted()) {
+ // Ignore a failed drag
+ manager->global_accepted_action = Qt::IgnoreAction;
+ } else {
+ manager->global_accepted_action = de.dropAction();
+ }
+ xcb_client_message_event_t finished;
+ finished.response_type = XCB_CLIENT_MESSAGE;
+ finished.window = xdnd_dragsource;
+ finished.format = 32;
+ finished.type = atom(QXcbAtom::XdndFinished);
+ DNDDEBUG << "xdndHandleDrop"
+ << "currentWindow" << currentWindow.data()
+ << (currentWindow ? xcb_window(currentWindow.data()) : 0);
+ finished.data.data32[0] = currentWindow ? xcb_window(currentWindow.data()) : XCB_NONE;
+ finished.data.data32[1] = de.isAccepted() ? 1 : 0; // flags
+ finished.data.data32[2] = toXdndAction(manager->global_accepted_action);
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, xdnd_dragsource,
+ XCB_EVENT_MASK_NO_EVENT, (char *)&finished));
+ } else {
+ QDragLeaveEvent e;
+ QGuiApplication::sendEvent(currentWindow.data(), &e);
+ }
+ xdnd_dragsource = 0;
+ currentWindow.clear();
+ waiting_for_status = false;
+
+ // reset
+ target_time = XCB_CURRENT_TIME;
+}
+
+
+void QXcbDrag::handleFinished(const xcb_client_message_event_t *event, bool)
+{
+ DEBUG("xdndHandleFinished");
+ if (event->window != connection()->clipboard()->owner())
+ return;
+
+ const unsigned long *l = (const unsigned long *)event->data.data32;
+
+ DNDDEBUG << "xdndHandleFinished, l[0]" << l[0]
+ << "current_target" << current_target
+ << "qt_xdnd_current_proxy_targe" << current_proxy_target;
+
+ if (l[0]) {
+ int at = findTransactionByWindow(l[0]);
+ if (at != -1) {
+ restartDropExpiryTimer();
+
+ Transaction t = transactions.takeAt(at);
+// QDragManager *manager = QDragManager::self();
+
+// Window target = current_target;
+// Window proxy_target = current_proxy_target;
+// QWidget *embedding_widget = current_embedding_widget;
+// QDrag *currentObject = manager->object;
+
+// current_target = t.target;
+// current_proxy_target = t.proxy_target;
+// current_embedding_widget = t.embedding_widget;
+// manager->object = t.object;
+
+// if (!passive)
+// (void) checkEmbedded(currentWindow, xe);
+
+// current_embedding_widget = 0;
+// current_target = 0;
+// current_proxy_target = 0;
+
+ if (t.object)
+ t.object->deleteLater();
+
+// current_target = target;
+// current_proxy_target = proxy_target;
+// current_embedding_widget = embedding_widget;
+// manager->object = currentObject;
+ }
+ }
+ waiting_for_status = false;
+}
+
+
+void QXcbDrag::timerEvent(QTimerEvent* e)
+{
+ if (e->timerId() == heartbeat && source_sameanswer.isNull()) {
+ QMouseEvent me(QEvent::MouseMove, QCursor::pos(), QCursor::pos(), Qt::LeftButton,
+ QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
+ move(&me);
+ } else if (e->timerId() == transaction_expiry_timer) {
+ for (int i = 0; i < transactions.count(); ++i) {
+ const Transaction &t = transactions.at(i);
+ if (t.targetWindow) {
+ // dnd within the same process, don't delete these
+ continue;
+ }
+ t.object->deleteLater();
+ transactions.removeAt(i--);
+ }
+
+ killTimer(transaction_expiry_timer);
+ transaction_expiry_timer = -1;
+ }
+}
+
+void QXcbDrag::cancel()
+{
+ DEBUG("QXcbDrag::cancel");
+ endDrag();
+
+ if (current_target)
+ send_leave();
+
+ current_target = 0;
+}
+
+#if 0
+
+static
+Window findRealWindow(const QPoint & pos, Window w, int md)
+{
+ if (xdnd_data.deco && w == xdnd_data.deco->effectiveWinId())
+ return 0;
+
+ if (md) {
+ X11->ignoreBadwindow();
+ XWindowAttributes attr;
+ XGetWindowAttributes(X11->display, w, &attr);
+ if (X11->badwindow())
+ return 0;
+
+ if (attr.map_state == IsViewable
+ && QRect(attr.x,attr.y,attr.width,attr.height).contains(pos)) {
+ {
+ Atom type = XNone;
+ int f;
+ unsigned long n, a;
+ unsigned char *data;
+
+ XGetWindowProperty(X11->display, w, ATOM(XdndAware), 0, 0, False,
+ AnyPropertyType, &type, &f,&n,&a,&data);
+ if (data) XFree(data);
+ if (type)
+ return w;
+ }
+
+ Window r, p;
+ Window* c;
+ uint nc;
+ if (XQueryTree(X11->display, w, &r, &p, &c, &nc)) {
+ r=0;
+ for (uint i=nc; !r && i--;) {
+ r = findRealWindow(pos-QPoint(attr.x,attr.y),
+ c[i], md-1);
+ }
+ XFree(c);
+ if (r)
+ return r;
+
+ // We didn't find a client window! Just use the
+ // innermost window.
+ }
+
+ // No children!
+ return w;
+ }
+ }
+ return 0;
+}
+#endif
+
+void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event)
+{
+ xcb_selection_notify_event_t notify;
+ notify.response_type = XCB_SELECTION_NOTIFY;
+ notify.requestor = event->requestor;
+ notify.selection = event->selection;
+ notify.target = XCB_NONE;
+ notify.property = XCB_NONE;
+ notify.time = event->time;
+
+ QDragManager *manager = QDragManager::self();
+ QDrag *currentObject = manager->object;
+
+ // which transaction do we use? (note: -2 means use current manager->object)
+ int at = -1;
+
+ // figure out which data the requestor is really interested in
+ if (manager->object && event->time == source_time) {
+ // requestor wants the current drag data
+ at = -2;
+ } else {
+ // if someone has requested data in response to XdndDrop, find the corresponding transaction. the
+ // spec says to call XConvertSelection() using the timestamp from the XdndDrop
+ at = findTransactionByTime(event->time);
+ if (at == -1) {
+ // no dice, perhaps the client was nice enough to use the same window id in XConvertSelection()
+ // that we sent the XdndDrop event to.
+ at = findTransactionByWindow(event->requestor);
+ }
+// if (at == -1 && event->time == XCB_CURRENT_TIME) {
+// // previous Qt versions always requested the data on a child of the target window
+// // using CurrentTime... but it could be asking for either drop data or the current drag's data
+// Window target = findXdndAwareParent(event->requestor);
+// if (target) {
+// if (current_target && current_target == target)
+// at = -2;
+// else
+// at = findXdndDropTransactionByWindow(target);
+// }
+// }
+ }
+ if (at >= 0) {
+ restartDropExpiryTimer();
+
+ // use the drag object from an XdndDrop tansaction
+ manager->object = transactions.at(at).object;
+ } else if (at != -2) {
+ // no transaction found, we'll have to reject the request
+ manager->object = 0;
+ }
+ if (manager->object) {
+ xcb_atom_t atomFormat = event->target;
+ int dataFormat = 0;
+ QByteArray data;
+ if (QXcbMime::mimeDataForAtom(connection(), event->target, manager->dragPrivate()->data,
+ &data, &atomFormat, &dataFormat)) {
+ int dataSize = data.size() / (dataFormat / 8);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, event->requestor, event->property,
+ atomFormat, dataFormat, dataSize, (const void *)data.constData());
+ notify.property = event->property;
+ notify.target = atomFormat;
+ }
+ }
+
+ // reset manager->object in case we modified it above
+ manager->object = currentObject;
+
+ xcb_send_event(xcb_connection(), false, event->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&notify);
+}
+
+
+bool QXcbDrag::dndEnable(QXcbWindow *w, bool on)
+{
+ DNDDEBUG << "xdndEnable" << w << on;
+ if (on) {
+ QXcbWindow *xdnd_widget = 0;
+ if ((w->window()->windowType() == Qt::Desktop)) {
+ if (desktop_proxy) // *WE* already have one.
+ return false;
+
+ xcb_grab_server(xcb_connection());
+
+ // As per Xdnd4, use XdndProxy
+ xcb_window_t proxy_id = xdndProxy(connection(), w->xcb_window());
+
+ if (!proxy_id) {
+ desktop_proxy = new QWindow;
+ xdnd_widget = static_cast<QXcbWindow *>(desktop_proxy->handle());
+ proxy_id = xdnd_widget->xcb_window();
+ xcb_atom_t xdnd_proxy = atom(QXcbAtom::XdndProxy);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, w->xcb_window(), xdnd_proxy,
+ XCB_ATOM_WINDOW, 32, 1, &proxy_id);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, proxy_id, xdnd_proxy,
+ XCB_ATOM_WINDOW, 32, 1, &proxy_id);
+ }
+
+ xcb_ungrab_server(xcb_connection());
+ } else {
+ xdnd_widget = w;
+ }
+ if (xdnd_widget) {
+ DNDDEBUG << "setting XdndAware for" << xdnd_widget << xdnd_widget->xcb_window();
+ xcb_atom_t atm = xdnd_version;
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, xdnd_widget->xcb_window(),
+ atom(QXcbAtom::XdndAware), XCB_ATOM_ATOM, 32, 1, &atm);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ if ((w->window()->windowType() == Qt::Desktop)) {
+ xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy));
+ delete desktop_proxy;
+ desktop_proxy = 0;
+ } else {
+ DNDDEBUG << "not deleting XDndAware";
+ }
+ return true;
+ }
+}
+
+
+
+
+QDropData::QDropData(QXcbDrag *d)
+ : QXcbMime(),
+ drag(d)
+{
+}
+
+QDropData::~QDropData()
+{
+}
+
+QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
+{
+ QByteArray mime = mimetype.toLatin1();
+ QVariant data = /*X11->motifdnd_active
+ ? X11->motifdndObtainData(mime)
+ :*/ xdndObtainData(mime, requestedType);
+ return data;
+}
+
+QVariant QDropData::xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const
+{
+ QByteArray result;
+
+ QDragManager *manager = QDragManager::self();
+ QXcbConnection *c = drag->connection();
+ QXcbWindow *xcb_window = c->platformWindowFromId(drag->xdnd_dragsource);
+ if (xcb_window && manager->object && xcb_window->window()->windowType() != Qt::Desktop) {
+ QDragPrivate *o = manager->dragPrivate();
+ if (o->data->hasFormat(QLatin1String(format)))
+ result = o->data->data(QLatin1String(format));
+ return result;
+ }
+
+ QList<xcb_atom_t> atoms = drag->xdnd_types;
+ QByteArray encoding;
+ xcb_atom_t a = mimeAtomForFormat(c, QLatin1String(format), requestedType, atoms, &encoding);
+ if (a == XCB_NONE)
+ return result;
+
+ if (c->clipboard()->getSelectionOwner(drag->atom(QXcbAtom::XdndSelection)) == XCB_NONE)
+ return result; // should never happen?
+
+ xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection);
+ result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection);
+
+ return mimeConvertToFormat(c, a, result, QLatin1String(format), requestedType, encoding);
+}
+
+
+bool QDropData::hasFormat_sys(const QString &format) const
+{
+ return formats().contains(format);
+}
+
+QStringList QDropData::formats_sys() const
+{
+ QStringList formats;
+// if (X11->motifdnd_active) {
+// int i = 0;
+// QByteArray fmt;
+// while (!(fmt = X11->motifdndFormat(i)).isEmpty()) {
+// formats.append(QLatin1String(fmt));
+// ++i;
+// }
+// } else {
+ for (int i = 0; i < drag->xdnd_types.size(); ++i) {
+ QString f = mimeAtomToString(drag->connection(), drag->xdnd_types.at(i));
+ if (!formats.contains(f))
+ formats.append(f);
+ }
+// }
+ return formats;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h
new file mode 100644
index 0000000000..ce0f8faa54
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBDRAG_H
+#define QXCBDRAG_H
+
+#include <qplatformdrag_qpa.h>
+#include <qxcbobject.h>
+#include <xcb/xcb.h>
+#include <qlist.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include <qsharedpointer.h>
+#include <qvector.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMouseEvent;
+class QWindow;
+class QXcbConnection;
+class QXcbWindow;
+class QDropData;
+class QXcbScreen;
+class QDrag;
+
+class QXcbDrag : public QObject, public QXcbObject, public QPlatformDrag
+{
+public:
+ QXcbDrag(QXcbConnection *c);
+ ~QXcbDrag();
+
+ virtual QMimeData *platformDropData();
+
+// virtual Qt::DropAction drag(QDrag *);
+
+ virtual void startDrag();
+ virtual void cancel();
+ virtual void move(const QMouseEvent *me);
+ virtual void drop(const QMouseEvent *me);
+ void endDrag();
+
+ void handleEnter(QWindow *window, const xcb_client_message_event_t *event);
+ void handlePosition(QWindow *w, const xcb_client_message_event_t *event, bool passive);
+ void handleLeave(QWindow *w, const xcb_client_message_event_t *event, bool /*passive*/);
+ void handleDrop(QWindow *, const xcb_client_message_event_t *event, bool passive);
+
+ void handleStatus(const xcb_client_message_event_t *event, bool passive);
+ void handleSelectionRequest(const xcb_selection_request_event_t *event);
+ void handleFinished(const xcb_client_message_event_t *event, bool passive);
+
+ bool dndEnable(QXcbWindow *win, bool on);
+
+protected:
+ void timerEvent(QTimerEvent* e);
+
+private:
+ friend class QDropData;
+
+ void init();
+
+ void handle_xdnd_position(QWindow *w, const xcb_client_message_event_t *event, bool passive);
+ void handle_xdnd_status(const xcb_client_message_event_t *event, bool);
+ void send_leave();
+
+ Qt::DropAction toDropAction(xcb_atom_t atom) const;
+ xcb_atom_t toXdndAction(Qt::DropAction a) const;
+
+ QWeakPointer<QWindow> currentWindow;
+ QPoint currentPosition;
+
+ QDropData *dropData;
+
+ QWindow *desktop_proxy;
+
+ xcb_atom_t xdnd_dragsource;
+
+ // the types in this drop. 100 is no good, but at least it's big.
+ enum { xdnd_max_type = 100 };
+ QList<xcb_atom_t> xdnd_types;
+
+ xcb_timestamp_t target_time;
+ xcb_timestamp_t source_time;
+ Qt::DropAction last_target_accepted_action;
+
+ // rectangle in which the answer will be the same
+ QRect source_sameanswer;
+ bool waiting_for_status;
+
+ // top-level window we sent position to last.
+ xcb_window_t current_target;
+ // window to send events to (always valid if current_target)
+ xcb_window_t current_proxy_target;
+
+ QXcbScreen *current_screen;
+
+ int heartbeat;
+ bool xdnd_dragging;
+
+ QVector<xcb_atom_t> drag_types;
+
+ struct Transaction
+ {
+ xcb_timestamp_t timestamp;
+ xcb_window_t target;
+ xcb_window_t proxy_target;
+ QWindow *targetWindow;
+// QWidget *embedding_widget;
+ QDrag *object;
+ };
+ QList<Transaction> transactions;
+
+ int transaction_expiry_timer;
+ void restartDropExpiryTimer();
+ int findTransactionByWindow(xcb_window_t window);
+ int findTransactionByTime(xcb_timestamp_t timestamp);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h b/src/plugins/platforms/xcb/qxcbeglsurface.h
index a4c8cd67e4..a1e6c148a2 100644
--- a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h
+++ b/src/plugins/platforms/xcb/qxcbeglsurface.h
@@ -39,22 +39,30 @@
**
****************************************************************************/
-#ifndef SHIVAVGGRAPHICSSYSTEM_H
-#define SHIVAVGGRAPHICSSYSTEM_H
+#ifndef QXCBEGLSURFACE_H
+#define QXCBEGLSURFACE_H
-#include <QtGui/private/qgraphicssystem_p.h>
+#include <EGL/egl.h>
-QT_BEGIN_NAMESPACE
-
-class ShivaVGGraphicsSystem : public QGraphicsSystem
+class QXcbEGLSurface
{
public:
- ShivaVGGraphicsSystem();
+ QXcbEGLSurface(EGLDisplay display, EGLSurface surface)
+ : m_display(display)
+ , m_surface(surface)
+ {
+ }
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
+ ~QXcbEGLSurface()
+ {
+ eglDestroySurface(m_display, m_surface);
+ }
-QT_END_NAMESPACE
+ EGLSurface surface() const { return m_surface; }
+
+private:
+ EGLDisplay m_display;
+ EGLSurface m_surface;
+};
#endif
diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp
new file mode 100644
index 0000000000..569e4fc4e4
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbimage.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbimage.h"
+#include <QtGui/QColor>
+#include <QtGui/private/qimage_p.h>
+#include <QtGui/private/qdrawhelper_p.h>
+#ifdef XCB_USE_RENDER
+#include <xcb/render.h>
+// 'template' is used as a function argument name in xcb_renderutil.h
+#define template template_param
+// extern "C" is missing too
+extern "C" {
+#include <xcb/xcb_renderutil.h>
+}
+#undef template
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QImage::Format qt_xcb_imageFormatForVisual(QXcbConnection *connection, uint8_t depth,
+ const xcb_visualtype_t *visual)
+{
+ const xcb_format_t *format = connection->formatForDepth(depth);
+
+ if (!visual || !format)
+ return QImage::Format_Invalid;
+
+ if (depth == 32 && format->bits_per_pixel == 32 && visual->red_mask == 0xff0000
+ && visual->green_mask == 0xff00 && visual->blue_mask == 0xff)
+ return QImage::Format_ARGB32_Premultiplied;
+
+ if (depth == 24 && format->bits_per_pixel == 32 && visual->red_mask == 0xff0000
+ && visual->green_mask == 0xff00 && visual->blue_mask == 0xff)
+ return QImage::Format_RGB32;
+
+ if (depth == 16 && format->bits_per_pixel == 16 && visual->red_mask == 0xf800
+ && visual->green_mask == 0x7e0 && visual->blue_mask == 0x1f)
+ return QImage::Format_RGB16;
+
+ return QImage::Format_Invalid;
+}
+
+QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap,
+ int width, int height, int depth,
+ const xcb_visualtype_t *visual)
+{
+ xcb_connection_t *conn = connection->xcb_connection();
+ xcb_generic_error_t *error = 0;
+
+ xcb_get_image_cookie_t get_image_cookie =
+ xcb_get_image(conn, XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap,
+ 0, 0, width, height, 0xffffffff);
+
+ xcb_get_image_reply_t *image_reply =
+ xcb_get_image_reply(conn, get_image_cookie, &error);
+
+ if (!image_reply) {
+ if (error) {
+ connection->handleXcbError(error);
+ free(error);
+ }
+ return QPixmap();
+ }
+
+ uint8_t *data = xcb_get_image_data(image_reply);
+ uint32_t length = xcb_get_image_data_length(image_reply);
+
+ QPixmap result;
+
+ QImage::Format format = qt_xcb_imageFormatForVisual(connection, depth, visual);
+ if (format != QImage::Format_Invalid) {
+ uint32_t bytes_per_line = length / height;
+ QImage image(const_cast<uint8_t *>(data), width, height, bytes_per_line, format);
+ uint8_t image_byte_order = connection->setup()->image_byte_order;
+
+ // we may have to swap the byte order
+ if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && image_byte_order == XCB_IMAGE_ORDER_MSB_FIRST)
+ || (QSysInfo::ByteOrder == QSysInfo::BigEndian && image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST))
+ {
+ for (int i=0; i < image.height(); i++) {
+ switch (format) {
+ case QImage::Format_RGB16: {
+ ushort *p = (ushort*)image.scanLine(i);
+ ushort *end = p + image.width();
+ while (p < end) {
+ *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);
+ p++;
+ }
+ break;
+ }
+ case QImage::Format_RGB32: // fall-through
+ case QImage::Format_ARGB32_Premultiplied: {
+ uint *p = (uint*)image.scanLine(i);
+ uint *end = p + image.width();
+ while (p < end) {
+ *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
+ | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
+ p++;
+ }
+ break;
+ }
+ default:
+ Q_ASSERT(false);
+ }
+ }
+ }
+
+ // fix-up alpha channel
+ if (format == QImage::Format_RGB32) {
+ QRgb *p = (QRgb *)image.bits();
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x)
+ p[x] |= 0xff000000;
+ p += bytes_per_line / 4;
+ }
+ }
+
+ result = QPixmap::fromImage(image.copy());
+ }
+
+ free(image_reply);
+ return result;
+}
+
+xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image)
+{
+ xcb_connection_t *conn = screen->xcb_connection();
+ QImage bitmap = image.convertToFormat(QImage::Format_MonoLSB);
+ const QRgb c0 = QColor(Qt::black).rgb();
+ const QRgb c1 = QColor(Qt::white).rgb();
+ if (bitmap.color(0) == c0 && bitmap.color(1) == c1) {
+ bitmap.invertPixels();
+ bitmap.setColor(0, c1);
+ bitmap.setColor(1, c0);
+ }
+ const int width = bitmap.width();
+ const int height = bitmap.height();
+ const int bytesPerLine = bitmap.bytesPerLine();
+ int destLineSize = width / 8;
+ if (width % 8)
+ ++destLineSize;
+ const uchar *map = bitmap.bits();
+ uint8_t *buf = new uint8_t[height * destLineSize];
+ for (int i = 0; i < height; i++)
+ memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize);
+ xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, screen->root(), buf,
+ width, height, 1, 0, 0, 0);
+ delete[] buf;
+ return pm;
+}
+
+xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image,
+ const QPoint &spot)
+{
+#ifdef XCB_USE_RENDER
+ xcb_connection_t *conn = screen->xcb_connection();
+ const int w = image.width();
+ const int h = image.height();
+ xcb_generic_error_t *error = 0;
+ xcb_render_query_pict_formats_cookie_t formatsCookie = xcb_render_query_pict_formats(conn);
+ xcb_render_query_pict_formats_reply_t *formatsReply = xcb_render_query_pict_formats_reply(conn,
+ formatsCookie,
+ &error);
+ if (!formatsReply || error) {
+ qWarning("createCursorXRender: query_pict_formats failed");
+ free(formatsReply);
+ free(error);
+ return XCB_NONE;
+ }
+ xcb_render_pictforminfo_t *fmt = xcb_render_util_find_standard_format(formatsReply,
+ XCB_PICT_STANDARD_ARGB_32);
+ if (!fmt) {
+ qWarning("createCursorXRender: Failed to find format PICT_STANDARD_ARGB_32");
+ free(formatsReply);
+ return XCB_NONE;
+ }
+
+ QImage img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ xcb_image_t *xi = xcb_image_create(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
+ 32, 32, 32, 32,
+ QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST,
+ XCB_IMAGE_ORDER_MSB_FIRST,
+ 0, 0, 0);
+ if (!xi) {
+ qWarning("createCursorXRender: xcb_image_create failed");
+ free(formatsReply);
+ return XCB_NONE;
+ }
+ xi->data = (uint8_t *) malloc(xi->stride * h);
+ if (!xi->data) {
+ qWarning("createCursorXRender: Failed to malloc() image data");
+ xcb_image_destroy(xi);
+ free(formatsReply);
+ return XCB_NONE;
+ }
+ memcpy(xi->data, img.constBits(), img.byteCount());
+
+ xcb_pixmap_t pix = xcb_generate_id(conn);
+ xcb_create_pixmap(conn, 32, pix, screen->root(), w, h);
+
+ xcb_render_picture_t pic = xcb_generate_id(conn);
+ xcb_render_create_picture(conn, pic, pix, fmt->id, 0, 0);
+
+ xcb_gcontext_t gc = xcb_generate_id(conn);
+ xcb_create_gc(conn, gc, pix, 0, 0);
+ xcb_image_put(conn, pix, gc, xi, 0, 0, 0);
+ xcb_free_gc(conn, gc);
+
+ xcb_cursor_t cursor = xcb_generate_id(conn);
+ xcb_render_create_cursor(conn, cursor, pic, spot.x(), spot.y());
+
+ free(xi->data);
+ xcb_image_destroy(xi);
+ xcb_render_free_picture(conn, pic);
+ xcb_free_pixmap(conn, pix);
+ free(formatsReply);
+ return cursor;
+
+#else
+ Q_UNUSED(screen);
+ Q_UNUSED(image);
+ Q_UNUSED(spot);
+ return XCB_NONE;
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h b/src/plugins/platforms/xcb/qxcbimage.h
index 014486bdb4..1e7f104084 100644
--- a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h
+++ b/src/plugins/platforms/xcb/qxcbimage.h
@@ -39,50 +39,26 @@
**
****************************************************************************/
-#ifndef QSCREENVNC_QWS_H
-#define QSCREENVNC_QWS_H
+#ifndef QXCBIMAGE_H
+#define QXCBIMAGE_H
-#include <QtGui/qscreenproxy_qws.h>
-
-#ifndef QT_NO_QWS_VNC
-
-QT_BEGIN_HEADER
+#include "qxcbscreen.h"
+#include <QtCore/QPair>
+#include <QtGui/QImage>
+#include <QtGui/QPixmap>
+#include <xcb/xcb_image.h>
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
-class QVNCScreenPrivate;
-
-class QVNCScreen : public QProxyScreen
-{
-public:
- explicit QVNCScreen(int display_id);
- virtual ~QVNCScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
-
- void setDirty(const QRect&);
-
-private:
- friend class QVNCCursor;
- friend class QVNCClientCursor;
- friend class QVNCServer;
- friend class QVNCScreenPrivate;
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- bool swapBytes() const;
-#endif
-
- QVNCScreenPrivate *d_ptr;
-};
+QImage::Format qt_xcb_imageFormatForVisual(QXcbConnection *connection,
+ uint8_t depth, const xcb_visualtype_t *visual);
+QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap,
+ int width, int height, int depth,
+ const xcb_visualtype_t *visual);
+xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image);
+xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image,
+ const QPoint &spot);
QT_END_NAMESPACE
-QT_END_HEADER
-
-#endif // QT_NO_QWS_VNC
-#endif // QSCREENVNC_QWS_H
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 12b63f36ea..fcc17b28b2 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -43,14 +43,20 @@
#include "qxcbconnection.h"
#include "qxcbscreen.h"
#include "qxcbwindow.h"
-#include "qxcbwindowsurface.h"
+#include "qxcbbackingstore.h"
#include "qxcbnativeinterface.h"
+#include "qxcbclipboard.h"
+#include "qxcbdrag.h"
+#include "qxcbimage.h"
+
+#include <QtPlatformSupport/private/qgenericunixprintersupport_p.h>
#include <xcb/xcb.h>
#include <private/qpixmap_raster_p.h>
-#include "qgenericunixfontdatabase.h"
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <stdio.h>
@@ -58,14 +64,28 @@
#include <EGL/egl.h>
#endif
+#if defined(XCB_USE_GLX)
+#include "qglxintegration.h"
+#elif defined(XCB_USE_EGL)
+#include "qxcbeglsurface.h"
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#endif
+
+#define XCB_USE_IBUS
+#if defined(XCB_USE_IBUS)
+#include "QtPlatformSupport/qibusplatforminputcontext.h"
+#endif
+
QXcbIntegration::QXcbIntegration()
- : m_connection(new QXcbConnection)
+ : m_connection(new QXcbConnection), m_printerSupport(new QGenericUnixPrinterSupport)
{
foreach (QXcbScreen *screen, m_connection->screens())
m_screens << screen;
m_fontDatabase = new QGenericUnixFontDatabase();
m_nativeInterface = new QXcbNativeInterface;
+
+ m_inputContext = 0;
}
QXcbIntegration::~QXcbIntegration()
@@ -87,16 +107,53 @@ QPixmapData *QXcbIntegration::createPixmapData(QPixmapData::PixelType type) cons
return new QRasterPixmapData(type);
}
-QPlatformWindow *QXcbIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
{
- Q_UNUSED(winId);
- return new QXcbWindow(widget);
+ return new QXcbWindow(window);
}
-QWindowSurface *QXcbIntegration::createWindowSurface(QWidget *widget, WId winId) const
+#if defined(XCB_USE_EGL)
+class QEGLXcbPlatformContext : public QEGLPlatformContext
+{
+public:
+ QEGLXcbPlatformContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share, EGLDisplay display)
+ : QEGLPlatformContext(glFormat, share, display)
+ {
+ }
+
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ {
+ return static_cast<QXcbWindow *>(surface)->eglSurface()->surface();
+ }
+};
+#endif
+
+QPlatformGLContext *QXcbIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
- Q_UNUSED(winId);
- return new QXcbWindowSurface(widget);
+#if defined(XCB_USE_GLX)
+ return new QGLXContext(static_cast<QXcbScreen *>(m_screens.at(0)), glFormat, share);
+#elif defined(XCB_USE_EGL)
+ return new QEGLXcbPlatformContext(glFormat, share, m_connection->egl_display());
+#elif defined(XCB_USE_DRI2)
+ return new QDri2Context(glFormat, share);
+#endif
+}
+
+QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const
+{
+ return new QXcbBackingStore(window);
+}
+
+QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const
+{
+ QAbstractEventDispatcher *eventDispatcher = createUnixEventDispatcher();
+ m_connection->setEventDispatcher(eventDispatcher);
+#ifdef XCB_USE_IBUS
+ // A bit hacky to do this here, but we need an eventloop before we can instantiate
+ // the input context.
+ const_cast<QXcbIntegration *>(this)->m_inputContext = new QIBusPlatformInputContext;
+#endif
+ return eventDispatcher;
}
QList<QPlatformScreen *> QXcbIntegration::screens() const
@@ -104,7 +161,7 @@ QList<QPlatformScreen *> QXcbIntegration::screens() const
return m_screens;
}
-void QXcbIntegration::moveToScreen(QWidget *window, int screen)
+void QXcbIntegration::moveToScreen(QWindow *window, int screen)
{
Q_UNUSED(window);
Q_UNUSED(screen);
@@ -122,14 +179,123 @@ QPlatformFontDatabase *QXcbIntegration::fontDatabase() const
QPixmap QXcbIntegration::grabWindow(WId window, int x, int y, int width, int height) const
{
- Q_UNUSED(window);
- Q_UNUSED(x);
- Q_UNUSED(y);
- Q_UNUSED(width);
- Q_UNUSED(height);
- return QPixmap();
-}
+ if (width == 0 || height == 0)
+ return QPixmap();
+ xcb_connection_t *connection = m_connection->xcb_connection();
+
+ xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry(connection, window);
+
+ xcb_generic_error_t *error;
+ xcb_get_geometry_reply_t *reply =
+ xcb_get_geometry_reply(connection, geometry_cookie, &error);
+
+ if (!reply) {
+ if (error) {
+ m_connection->handleXcbError(error);
+ free(error);
+ }
+ return QPixmap();
+ }
+
+ if (width < 0)
+ width = reply->width - x;
+ if (height < 0)
+ height = reply->height - y;
+
+ // TODO: handle multiple screens
+ QXcbScreen *screen = m_connection->screens().at(0);
+ xcb_window_t root = screen->root();
+ geometry_cookie = xcb_get_geometry(connection, root);
+ xcb_get_geometry_reply_t *root_reply =
+ xcb_get_geometry_reply(connection, geometry_cookie, &error);
+
+ if (!root_reply) {
+ if (error) {
+ m_connection->handleXcbError(error);
+ free(error);
+ }
+ free(reply);
+ return QPixmap();
+ }
+
+ if (reply->depth == root_reply->depth) {
+ // if the depth of the specified window and the root window are the
+ // same, grab pixels from the root window (so that we get the any
+ // overlapping windows and window manager frames)
+
+ // map x and y to the root window
+ xcb_translate_coordinates_cookie_t translate_cookie =
+ xcb_translate_coordinates(connection, window, root, x, y);
+
+ xcb_translate_coordinates_reply_t *translate_reply =
+ xcb_translate_coordinates_reply(connection, translate_cookie, &error);
+
+ if (!translate_reply) {
+ if (error) {
+ m_connection->handleXcbError(error);
+ free(error);
+ }
+ free(reply);
+ free(root_reply);
+ return QPixmap();
+ }
+
+ x = translate_reply->dst_x;
+ y = translate_reply->dst_y;
+
+ window = root;
+
+ free(translate_reply);
+ free(reply);
+ reply = root_reply;
+ } else {
+ free(root_reply);
+ root_reply = 0;
+ }
+
+ xcb_get_window_attributes_reply_t *attributes_reply =
+ xcb_get_window_attributes_reply(connection, xcb_get_window_attributes(connection, window), &error);
+
+ if (!attributes_reply) {
+ if (error) {
+ m_connection->handleXcbError(error);
+ free(error);
+ }
+ free(reply);
+ return QPixmap();
+ }
+
+ const xcb_visualtype_t *visual = screen->visualForId(attributes_reply->visual);
+ free(attributes_reply);
+
+ xcb_pixmap_t pixmap = xcb_generate_id(connection);
+ error = xcb_request_check(connection, xcb_create_pixmap_checked(connection, reply->depth, pixmap, window, width, height));
+ if (error) {
+ m_connection->handleXcbError(error);
+ free(error);
+ }
+
+ uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE;
+ uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS };
+
+ xcb_gcontext_t gc = xcb_generate_id(connection);
+ xcb_create_gc(connection, gc, pixmap, gc_value_mask, gc_value_list);
+
+ error = xcb_request_check(connection, xcb_copy_area_checked(connection, window, pixmap, gc, x, y, 0, 0, width, height));
+ if (error) {
+ m_connection->handleXcbError(error);
+ free(error);
+ }
+
+ QPixmap result = qt_xcb_pixmapFromXPixmap(m_connection, pixmap, width, height, reply->depth, visual);
+
+ free(reply);
+ xcb_free_gc(connection, gc);
+ xcb_free_pixmap(connection, pixmap);
+
+ return result;
+}
bool QXcbIntegration::hasOpenGL() const
{
@@ -149,3 +315,23 @@ QPlatformNativeInterface * QXcbIntegration::nativeInterface() const
{
return m_nativeInterface;
}
+
+QPlatformPrinterSupport *QXcbIntegration::printerSupport() const
+{
+ return m_printerSupport;
+}
+
+QPlatformClipboard *QXcbIntegration::clipboard() const
+{
+ return m_connection->clipboard();
+}
+
+QPlatformDrag *QXcbIntegration::drag() const
+{
+ return m_connection->drag();
+}
+
+QPlatformInputContext *QXcbIntegration::inputContext() const
+{
+ return m_inputContext;
+}
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index cd68919b54..a89ffc89c6 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QXcbConnection;
+class QAbstractEventDispatcher;
class QXcbIntegration : public QPlatformIntegration
{
@@ -57,11 +58,13 @@ public:
bool hasCapability(Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QList<QPlatformScreen *> screens() const;
- void moveToScreen(QWidget *window, int screen);
+ void moveToScreen(QWindow *window, int screen);
bool isVirtualDesktop();
QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
@@ -69,6 +72,12 @@ public:
QPlatformNativeInterface *nativeInterface()const;
+ QPlatformPrinterSupport *printerSupport() const;
+ QPlatformClipboard *clipboard() const;
+ QPlatformDrag *drag() const;
+
+ QPlatformInputContext *inputContext() const;
+
private:
bool hasOpenGL() const;
QList<QPlatformScreen *> m_screens;
@@ -76,6 +85,9 @@ private:
QPlatformFontDatabase *m_fontDatabase;
QPlatformNativeInterface *m_nativeInterface;
+ QPlatformPrinterSupport *m_printerSupport;
+
+ QPlatformInputContext *m_inputContext;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 6bbc3c18ca..adaed53106 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -40,16 +40,20 @@
****************************************************************************/
#include "qxcbkeyboard.h"
-
+#include "qxcbwindow.h"
+#include "qxcbscreen.h"
#include <xcb/xcb_keysyms.h>
-
#include <X11/keysym.h>
-
#include <QtGui/QWindowSystemInterface>
#include <QtCore/QTextCodec>
-
+#include <private/qguiapplication_p.h>
#include <stdio.h>
+#define XCB_USE_IBUS
+#if defined(XCB_USE_IBUS)
+#include "QtPlatformSupport/qibusplatforminputcontext.h"
+#endif
+
#ifndef XK_ISO_Left_Tab
#define XK_ISO_Left_Tab 0xFE20
#endif
@@ -898,12 +902,9 @@ QString QXcbKeyboard::translateKeySym(xcb_keysym_t keysym, uint xmodifiers,
QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
: QXcbObject(connection)
- , m_alt_mask(0)
- , m_super_mask(0)
- , m_hyper_mask(0)
- , m_meta_mask(0)
{
m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
+ setupModifiers();
}
QXcbKeyboard::~QXcbKeyboard()
@@ -911,18 +912,113 @@ QXcbKeyboard::~QXcbKeyboard()
xcb_key_symbols_free(m_key_symbols);
}
-// #define XCB_KEYBOARD_DEBUG
+void QXcbKeyboard::setupModifiers()
+{
+ m_alt_mask = 0;
+ m_super_mask = 0;
+ m_hyper_mask = 0;
+ m_meta_mask = 0;
+ m_mode_switch_mask = 0;
+ m_num_lock_mask = 0;
+ m_caps_lock_mask = 0;
+
+ xcb_generic_error_t *error = 0;
+ xcb_connection_t *conn = xcb_connection();
+ xcb_get_modifier_mapping_cookie_t modMapCookie = xcb_get_modifier_mapping(conn);
+ xcb_get_modifier_mapping_reply_t *modMapReply =
+ xcb_get_modifier_mapping_reply(conn, modMapCookie, &error);
+ if (error) {
+ qWarning("xcb keyboard: failed to get modifier mapping");
+ free(error);
+ return;
+ }
+
+ // Figure out the modifier mapping, ICCCM 6.6
+ typedef QPair<uint, xcb_keycode_t *> SymCodes;
+ QList<SymCodes> modKeyCodes;
+
+ // for Alt and Meta L and R are the same
+ modKeyCodes << SymCodes(XK_Alt_L, xcb_key_symbols_get_keycode(m_key_symbols, XK_Alt_L));
+ modKeyCodes << SymCodes(XK_Meta_L, xcb_key_symbols_get_keycode(m_key_symbols, XK_Meta_L));
+ modKeyCodes << SymCodes(XK_Super_L, xcb_key_symbols_get_keycode(m_key_symbols, XK_Super_L));
+ modKeyCodes << SymCodes(XK_Super_R, xcb_key_symbols_get_keycode(m_key_symbols, XK_Super_R));
+ modKeyCodes << SymCodes(XK_Hyper_L, xcb_key_symbols_get_keycode(m_key_symbols, XK_Hyper_L));
+ modKeyCodes << SymCodes(XK_Hyper_R, xcb_key_symbols_get_keycode(m_key_symbols, XK_Hyper_R));
+ modKeyCodes << SymCodes(XK_Num_Lock, xcb_key_symbols_get_keycode(m_key_symbols, XK_Num_Lock));
+ modKeyCodes << SymCodes(XK_Mode_switch, xcb_key_symbols_get_keycode(m_key_symbols, XK_Mode_switch));
+ modKeyCodes << SymCodes(XK_Caps_Lock, xcb_key_symbols_get_keycode(m_key_symbols, XK_Caps_Lock));
+
+ xcb_keycode_t *modMap = xcb_get_modifier_mapping_keycodes(modMapReply);
+ const int w = modMapReply->keycodes_per_modifier;
+ for (int i = 0; i < modKeyCodes.count(); ++i) {
+ for (int bit = 0; bit < 8; ++bit) {
+ uint mask = 1 << bit;
+ for (int x = 0; x < w; ++x) {
+ xcb_keycode_t keyCode = modMap[x + bit * w];
+ xcb_keycode_t *itk = modKeyCodes.at(i).second;
+ while (itk && *itk != XCB_NO_SYMBOL)
+ if (*itk++ == keyCode)
+ setMask(modKeyCodes.at(i).first, mask);
+ }
+ }
+ }
-void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
+ for (int i = 0; i < modKeyCodes.count(); ++i)
+ free(modKeyCodes.at(i).second);
+ free(modMapReply);
+}
+
+void QXcbKeyboard::setMask(uint sym, uint mask)
{
- int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0;
+ if (m_alt_mask == 0
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Alt_L || sym == XK_Alt_R))
+ m_alt_mask = mask;
+
+ if (m_meta_mask == 0
+ && m_alt_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Meta_L || sym == XK_Meta_R))
+ m_meta_mask = mask;
+
+ if (m_super_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Super_L || sym == XK_Super_R))
+ m_super_mask = mask;
+
+ if (m_hyper_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && (sym == XK_Hyper_L || sym == XK_Hyper_R))
+ m_hyper_mask = mask;
+
+ if (m_mode_switch_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && sym == XK_Mode_switch)
+ m_mode_switch_mask = mask;
+
+ if (m_num_lock_mask == 0 && sym == XK_Num_Lock)
+ m_num_lock_mask = mask;
+
+ if (m_caps_lock_mask == 0 && sym == XK_Caps_Lock)
+ m_caps_lock_mask = mask;
+}
- const int altGrOffset = 4;
- if (state & 128)
- col += altGrOffset;
+// #define XCB_KEYBOARD_DEBUG
+void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code,
+ quint16 state, xcb_timestamp_t time)
+{
Q_XCB_NOOP(connection());
-
#ifdef XCB_KEYBOARD_DEBUG
printf("key code: %d, state: %d, syms: ", code, state);
for (int i = 0; i <= 5; ++i) {
@@ -931,43 +1027,96 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod
printf("\n");
#endif
- Q_XCB_NOOP(connection());
+ QByteArray chars;
+ xcb_keysym_t sym = lookupString(window, state, code, type, &chars);
+
+ QIBusPlatformInputContext *ic = static_cast<QIBusPlatformInputContext *>(QGuiApplicationPrivate::platformIntegration()->inputContext());
+ if (ic && ic->x11FilterEvent(sym, code, state, type == QEvent::KeyPress))
+ return;
+ Qt::KeyboardModifiers modifiers;
+ int qtcode = 0;
+ int count = chars.count();
+ QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
+ QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
+ code, 0, state, string.left(count));
+}
+
+#ifdef XCB_USE_XLIB
+extern "C" {
+ int XLookupString(void *event, char *buf, int count, void *keysym, void *comp);
+}
+typedef struct { // must match XKeyEvent in Xlib.h
+ int type;
+ unsigned long serial;
+ int send_event;
+ void *display;
+ unsigned long window;
+ unsigned long root;
+ unsigned long subwindow;
+ unsigned long time;
+ int x, y;
+ int x_root, y_root;
+ unsigned int state;
+ unsigned int keycode;
+ int same_screen;
+} FakeXKeyEvent;
+#endif
+
+xcb_keysym_t QXcbKeyboard::lookupString(QWindow *window, uint state, xcb_keycode_t code,
+ QEvent::Type type, QByteArray *chars)
+{
+#ifdef XCB_USE_XLIB
+
+ xcb_keysym_t sym = XCB_NO_SYMBOL;
+ chars->resize(512);
+ FakeXKeyEvent event;
+ memset(&event, 0, sizeof(event));
+ event.type = (type == QEvent::KeyRelease ? 3 : 2);
+ event.display = connection()->xlib_display();
+ event.window = static_cast<QXcbWindow *>(window->handle())->xcb_window();
+ event.root = connection()->screens().at(0)->root();
+ event.state = state;
+ event.keycode = code;
+ int count = XLookupString(&event, chars->data(), chars->size(), &sym, 0);
+ chars->resize(count);
+ return sym;
+
+#else
+
+ // No XLookupString available. The following is really incomplete...
+
+ int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0;
+ const int altGrOffset = 4;
+ if (state & 128)
+ col += altGrOffset;
xcb_keysym_t sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col);
if (sym == XCB_NO_SYMBOL)
sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col ^ 0x1);
-
if (state & XCB_MOD_MASK_LOCK && sym <= 0x7f && isprint(sym)) {
if (isupper(sym))
sym = tolower(sym);
else
sym = toupper(sym);
}
+ return sym;
- Q_XCB_NOOP(connection());
-
- QByteArray chars;
-
- Qt::KeyboardModifiers modifiers;
- int qtcode = 0;
- int count = 0;
-
- QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
-
- QWindowSystemInterface::handleExtendedKeyEvent(widget, time, type, qtcode, modifiers, code, 0, state, string.left(count));
+#endif
}
-void QXcbKeyboard::handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event)
+void QXcbKeyboard::handleKeyPressEvent(QXcbWindow *window, const xcb_key_press_event_t *event)
{
- handleKeyEvent(widget, QEvent::KeyPress, event->detail, event->state, event->time);
+ window->updateNetWmUserTime(event->time);
+ handleKeyEvent(window->window(), QEvent::KeyPress, event->detail, event->state, event->time);
}
-void QXcbKeyboard::handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event)
+void QXcbKeyboard::handleKeyReleaseEvent(QXcbWindow *window, const xcb_key_release_event_t *event)
{
- handleKeyEvent(widget, QEvent::KeyRelease, event->detail, event->state, event->time);
+ handleKeyEvent(window->window(), QEvent::KeyRelease, event->detail, event->state, event->time);
}
void QXcbKeyboard::handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event)
{
xcb_refresh_keyboard_mapping(m_key_symbols, const_cast<xcb_mapping_notify_event_t *>(event));
+ setupModifiers();
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index 095c3e4efb..ea5f84e8c2 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -48,26 +48,32 @@
#include <QEvent>
+class QWindow;
+
class QXcbKeyboard : public QXcbObject
{
public:
QXcbKeyboard(QXcbConnection *connection);
~QXcbKeyboard();
- void handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event);
- void handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event);
+ void handleKeyPressEvent(QXcbWindow *window, const xcb_key_press_event_t *event);
+ void handleKeyReleaseEvent(QXcbWindow *window, const xcb_key_release_event_t *event);
void handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event);
Qt::KeyboardModifiers translateModifiers(int s);
private:
- void handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
+ void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
int translateKeySym(uint key) const;
QString translateKeySym(xcb_keysym_t keysym, uint xmodifiers,
int &code, Qt::KeyboardModifiers &modifiers,
QByteArray &chars, int &count);
+ void setupModifiers();
+ void setMask(uint sym, uint mask);
+ xcb_keysym_t lookupString(QWindow *window, uint state, xcb_keycode_t code,
+ QEvent::Type type, QByteArray *chars);
uint m_alt_mask;
uint m_super_mask;
@@ -75,6 +81,7 @@ private:
uint m_meta_mask;
uint m_mode_switch_mask;
uint m_num_lock_mask;
+ uint m_caps_lock_mask;
xcb_key_symbols_t *m_key_symbols;
};
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
new file mode 100644
index 0000000000..d4f80ca09d
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -0,0 +1,288 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbmime.h"
+
+#include <QtCore/QTextCodec>
+#include <QtGui/QImageWriter>
+#include <QtCore/QBuffer>
+#include <qdebug.h>
+
+#include <X11/Xutil.h>
+
+#undef XCB_ATOM_STRING
+#undef XCB_ATOM_PIXMAP
+#undef XCB_ATOM_BITMAP
+
+QXcbMime::QXcbMime()
+ : QInternalMimeData()
+{ }
+
+QXcbMime::~QXcbMime()
+{}
+
+
+
+QString QXcbMime::mimeAtomToString(QXcbConnection *connection, xcb_atom_t a)
+{
+ if (a == XCB_NONE)
+ return QString();
+
+ // special cases for string type
+ if (a == XCB_ATOM_STRING
+ || a == connection->atom(QXcbAtom::UTF8_STRING)
+ || a == connection->atom(QXcbAtom::TEXT))
+ return QLatin1String("text/plain");
+
+ // special case for images
+ if (a == XCB_ATOM_PIXMAP)
+ return QLatin1String("image/ppm");
+
+ QByteArray atomName = connection->atomName(a);
+
+ // special cases for uris
+ if (atomName == "text/x-moz-url")
+ atomName = "text/uri-list";
+
+ return QString::fromLatin1(atomName.constData());
+}
+
+bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data,
+ xcb_atom_t *atomFormat, int *dataFormat)
+{
+ if (!data)
+ return false;
+
+ bool ret = false;
+ *atomFormat = a;
+ *dataFormat = 8;
+
+ if ((a == connection->atom(QXcbAtom::UTF8_STRING)
+ || a == XCB_ATOM_STRING
+ || a == connection->atom(QXcbAtom::TEXT))
+ && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
+ if (a == connection->atom(QXcbAtom::UTF8_STRING)) {
+ *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
+ ret = true;
+ } else if (a == XCB_ATOM_STRING ||
+ a == connection->atom(QXcbAtom::TEXT)) {
+ // ICCCM says STRING is latin1
+ *data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLatin1();
+ ret = true;
+ }
+ return ret;
+ }
+
+ QString atomName = mimeAtomToString(connection, a);
+ if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
+ *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
+ if (atomName == QLatin1String("application/x-color"))
+ *dataFormat = 16;
+ ret = true;
+ } else if (atomName == QLatin1String("text/x-moz-url") &&
+ QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) {
+ QByteArray uri = QInternalMimeData::renderDataHelper(
+ QLatin1String("text/uri-list"), mimeData).split('\n').first();
+ QString mozUri = QString::fromLatin1(uri, uri.size());
+ mozUri += QLatin1Char('\n');
+ *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
+ ret = true;
+ } else if ((a == XCB_ATOM_PIXMAP || a == XCB_ATOM_BITMAP) && mimeData->hasImage()) {
+ ret = true;
+ }
+ return ret;
+}
+
+QList<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, const QString &format)
+{
+ QList<xcb_atom_t> atoms;
+ atoms.append(connection->internAtom(format.toLatin1()));
+
+ // special cases for strings
+ if (format == QLatin1String("text/plain")) {
+ atoms.append(connection->atom(QXcbAtom::UTF8_STRING));
+ atoms.append(XCB_ATOM_STRING);
+ atoms.append(connection->atom(QXcbAtom::TEXT));
+ }
+
+ // special cases for uris
+ if (format == QLatin1String("text/uri-list"))
+ atoms.append(connection->internAtom("text/x-moz-url"));
+
+ //special cases for images
+ if (format == QLatin1String("image/ppm"))
+ atoms.append(XCB_ATOM_PIXMAP);
+ if (format == QLatin1String("image/pbm"))
+ atoms.append(XCB_ATOM_BITMAP);
+
+ return atoms;
+}
+
+QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format,
+ QVariant::Type requestedType, const QByteArray &encoding)
+{
+ QString atomName = mimeAtomToString(connection, a);
+// qDebug() << "mimeConvertDataToFormat" << format << atomName << data;
+
+ if (!encoding.isEmpty()
+ && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
+
+ if (requestedType == QVariant::String) {
+ QTextCodec *codec = QTextCodec::codecForName(encoding);
+ if (codec)
+ return codec->toUnicode(data);
+ }
+
+ return data;
+ }
+
+ // special cases for string types
+ if (format == QLatin1String("text/plain")) {
+ if (a == connection->atom(QXcbAtom::UTF8_STRING))
+ return QString::fromUtf8(data);
+ if (a == XCB_ATOM_STRING ||
+ a == connection->atom(QXcbAtom::TEXT))
+ return QString::fromLatin1(data);
+ }
+
+ // special case for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ if (atomName == QLatin1String("text/x-moz-url")) {
+ // we expect this as utf16 <url><space><title>
+ // the first part is a url that should only contain ascci char
+ // so it should be safe to check that the second char is 0
+ // to verify that it is utf16
+ if (data.size() > 1 && data.at(1) == 0)
+ return QString::fromRawData((const QChar *)data.constData(),
+ data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
+ }
+ }
+
+ if (atomName == format)
+ return data;
+
+#if 0 // ###
+ // special case for images
+ if (format == QLatin1String("image/ppm")) {
+ if (a == XCB_ATOM_PIXMAP && data.size() == sizeof(Pixmap)) {
+ Pixmap xpm = *((Pixmap*)data.data());
+ if (!xpm)
+ return QByteArray();
+ Window root;
+ int x;
+ int y;
+ uint width;
+ uint height;
+ uint border_width;
+ uint depth;
+
+ XGetGeometry(display, xpm, &root, &x, &y, &width, &height, &border_width, &depth);
+ XImage *ximg = XGetImage(display,xpm,x,y,width,height,AllPlanes,depth==1 ? XYPixmap : ZPixmap);
+ QImage qimg = QXlibStatic::qimageFromXImage(ximg);
+ XDestroyImage(ximg);
+
+ QImageWriter imageWriter;
+ imageWriter.setFormat("PPMRAW");
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ imageWriter.setDevice(&buf);
+ imageWriter.write(qimg);
+ return buf.buffer();
+ }
+ }
+#endif
+ return QVariant();
+}
+
+xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+ const QList<xcb_atom_t> &atoms, QByteArray *requestedEncoding)
+{
+ requestedEncoding->clear();
+
+ // find matches for string types
+ if (format == QLatin1String("text/plain")) {
+ if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING)))
+ return connection->atom(QXcbAtom::UTF8_STRING);
+ if (atoms.contains(XCB_ATOM_STRING))
+ return XCB_ATOM_STRING;
+ if (atoms.contains(connection->atom(QXcbAtom::TEXT)))
+ return connection->atom(QXcbAtom::TEXT);
+ }
+
+ // find matches for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ xcb_atom_t a = connection->internAtom(format.toLatin1());
+ if (a && atoms.contains(a))
+ return a;
+ a = connection->internAtom("text/x-moz-url");
+ if (a && atoms.contains(a))
+ return a;
+ }
+
+ // find match for image
+ if (format == QLatin1String("image/ppm")) {
+ if (atoms.contains(XCB_ATOM_PIXMAP))
+ return XCB_ATOM_PIXMAP;
+ }
+
+ // for string/text requests try to use a format with a well-defined charset
+ // first to avoid encoding problems
+ if (requestedType == QVariant::String
+ && format.startsWith(QLatin1String("text/"))
+ && !format.contains(QLatin1String("charset="))) {
+
+ QString formatWithCharset = format;
+ formatWithCharset.append(QLatin1String(";charset=utf-8"));
+
+ xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1());
+ if (a && atoms.contains(a)) {
+ *requestedEncoding = "utf-8";
+ return a;
+ }
+ }
+
+ xcb_atom_t a = connection->internAtom(format.toLatin1());
+ if (a && atoms.contains(a))
+ return a;
+
+ return 0;
+}
diff --git a/src/plugins/platforms/xcb/qxcbmime.h b/src/plugins/platforms/xcb/qxcbmime.h
new file mode 100644
index 0000000000..4ab38ed803
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbmime.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBMIME_H
+#define QXCBMIME_H
+
+#include <private/qdnd_p.h>
+
+#include <QtGui/QClipboard>
+
+#include "qxcbintegration.h"
+#include "qxcbconnection.h"
+
+class QXcbMime : public QInternalMimeData {
+ Q_OBJECT
+public:
+ QXcbMime();
+ ~QXcbMime();
+
+ static QList<xcb_atom_t> mimeAtomsForFormat(QXcbConnection *connection, const QString &format);
+ static QString mimeAtomToString(QXcbConnection *connection, xcb_atom_t a);
+ static bool mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data,
+ xcb_atom_t *atomFormat, int *dataFormat);
+ static QVariant mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format,
+ QVariant::Type requestedType, const QByteArray &encoding);
+ static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+ const QList<xcb_atom_t> &atoms, QByteArray *requestedEncoding);
+};
+
+#endif // QXCBMIME_H
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 6423f1b798..28b62b3aec 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -43,13 +43,15 @@
#include "qxcbscreen.h"
-#include <QtGui/private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
#include <QtCore/QMap>
#include <QtCore/QDebug>
+#include <QtGui/qguiglcontext_qpa.h>
+
#if defined(XCB_USE_EGL)
-#include "../eglconvenience/qeglplatformcontext.h"
+#include "QtPlatformSupport/private/qeglplatformcontext_p.h"
#elif defined (XCB_USE_DRI2)
#include "qdri2context.h"
#endif
@@ -71,29 +73,41 @@ public:
Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
-void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QGuiGLContext *context)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+ ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
+ void *result = 0;
+ switch(resource) {
+ case EglContext:
+ result = eglContextForContext(context);
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+}
+
+void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();
ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
void *result = 0;
switch(resource) {
case Display:
- result = displayForWidget(widget);
+ result = displayForWindow(window);
break;
case EglDisplay:
- result = eglDisplayForWidget(widget);
+ result = eglDisplayForWindow(window);
break;
case Connection:
- result = connectionForWidget(widget);
+ result = connectionForWindow(window);
break;
case Screen:
- result = qPlatformScreenForWidget(widget);
+ result = qPlatformScreenForWindow(window);
break;
case GraphicsDevice:
- result = graphicsDeviceForWidget(widget);
- break;
- case EglContext:
- result = eglContextForWidget(widget);
+ result = graphicsDeviceForWindow(window);
break;
default:
result = 0;
@@ -101,75 +115,76 @@ void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceStr
return result;
}
-QXcbScreen *QXcbNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QXcbScreen *screen;
- if (widget) {
- screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ if (window) {
+ screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window));
}else {
- screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens()[0]);
}
return screen;
}
-void *QXcbNativeInterface::displayForWidget(QWidget *widget)
+void *QXcbNativeInterface::displayForWindow(QWindow *window)
{
#if defined(XCB_USE_XLIB)
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->connection()->xlib_display();
#else
- Q_UNUSED(widget);
+ Q_UNUSED(window);
return 0;
#endif
}
-void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget)
+void *QXcbNativeInterface::eglDisplayForWindow(QWindow *window)
{
#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->connection()->egl_display();
#else
- Q_UNUSED(widget)
+ Q_UNUSED(window)
return 0;
#endif
}
-void *QXcbNativeInterface::connectionForWidget(QWidget *widget)
+void *QXcbNativeInterface::connectionForWindow(QWindow *window)
{
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->xcb_connection();
}
-void *QXcbNativeInterface::screenForWidget(QWidget *widget)
+void *QXcbNativeInterface::screenForWindow(QWindow *window)
{
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->screen();
}
-void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
+void *QXcbNativeInterface::graphicsDeviceForWindow(QWindow *window)
{
#if defined(XCB_USE_DRI2)
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
QByteArray deviceName = screen->connection()->dri2DeviceName();
return deviceName.data();
#else
- Q_UNUSED(widget);
+ Q_UNUSED(window);
return 0;
#endif
}
-void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
+void * QXcbNativeInterface::eglContextForContext(QGuiGLContext *context)
{
- Q_ASSERT(widget);
- if (!widget->platformWindow()) {
- qDebug() << "QPlatformWindow does not exist for widget" << widget
- << "cannot return EGLContext";
- return 0;
- }
- QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
+ Q_ASSERT(context);
+#if defined(XCB_USE_EGL)
+ QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
+ return eglPlatformContext->eglContext();
+#endif
+#if 0
+ Q_ASSERT(window);
+ QPlatformGLContext *platformContext = window->glContext()->handle();
if (!platformContext) {
- qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
+ qDebug() << "QWindow" << window << "does not have a glContext"
<< "cannot return EGLContext";
return 0;
}
@@ -182,4 +197,7 @@ void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
#else
return 0;
#endif
+#else
+ return 0;
+#endif
}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index 3fb0fa5e2d..e9b1df4511 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -59,17 +59,19 @@ public:
EglContext
};
- void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
+ void *nativeResourceForContext(const QByteArray &resourceString, QGuiGLContext *context);
+ void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
- void *displayForWidget(QWidget *widget);
- void *eglDisplayForWidget(QWidget *widget);
- void *connectionForWidget(QWidget *widget);
- void *screenForWidget(QWidget *widget);
- void *graphicsDeviceForWidget(QWidget *widget);
- void *eglContextForWidget(QWidget *widget);
+ void *displayForWindow(QWindow *window);
+ void *eglDisplayForWindow(QWindow *window);
+ void *connectionForWindow(QWindow *window);
+ void *screenForWindow(QWindow *window);
+ void *graphicsDeviceForWindow(QWindow *window);
+
+ void *eglContextForContext(QGuiGLContext *context);
private:
- static QXcbScreen *qPlatformScreenForWidget(QWidget *widget);
+ static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
};
#endif // QXCBNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 9a4858123b..6c3d1813b0 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+#include "qxcbcursor.h"
#include <stdio.h>
@@ -102,10 +104,103 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int num
free(reply);
m_syncRequestSupported = m_windowManagerName != QLatin1String("KWin");
+
+ m_clientLeader = xcb_generate_id(xcb_connection());
+ Q_XCB_CALL2(xcb_create_window(xcb_connection(),
+ XCB_COPY_FROM_PARENT,
+ m_clientLeader,
+ m_screen->root,
+ 0, 0, 1, 1,
+ 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ m_screen->root_visual,
+ 0, 0), connection);
+
+ Q_XCB_CALL2(xcb_change_property(xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_clientLeader,
+ atom(QXcbAtom::WM_CLIENT_LEADER),
+ XCB_ATOM_WINDOW,
+ 32,
+ 1,
+ &m_clientLeader), connection);
+
+ xcb_depth_iterator_t depth_iterator =
+ xcb_screen_allowed_depths_iterator(screen);
+
+ while (depth_iterator.rem) {
+ xcb_depth_t *depth = depth_iterator.data;
+ xcb_visualtype_iterator_t visualtype_iterator =
+ xcb_depth_visuals_iterator(depth);
+
+ while (visualtype_iterator.rem) {
+ xcb_visualtype_t *visualtype = visualtype_iterator.data;
+ m_visuals.insert(visualtype->visual_id, *visualtype);
+ xcb_visualtype_next(&visualtype_iterator);
+ }
+
+ xcb_depth_next(&depth_iterator);
+ }
+
+ m_cursor = new QXcbCursor(connection, this);
}
QXcbScreen::~QXcbScreen()
{
+ delete m_cursor;
+}
+
+QWindow *QXcbScreen::topLevelAt(const QPoint &p) const
+{
+ xcb_window_t root = m_screen->root;
+
+ int x = p.x();
+ int y = p.y();
+
+ xcb_generic_error_t *error;
+
+ xcb_window_t parent = root;
+ xcb_window_t child = root;
+
+ do {
+ xcb_translate_coordinates_cookie_t translate_cookie =
+ xcb_translate_coordinates(xcb_connection(), parent, child, x, y);
+
+ xcb_translate_coordinates_reply_t *translate_reply =
+ xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, &error);
+
+ if (!translate_reply) {
+ if (error) {
+ connection()->handleXcbError(error);
+ free(error);
+ }
+ return 0;
+ }
+
+ parent = child;
+ child = translate_reply->child;
+ x = translate_reply->dst_x;
+ y = translate_reply->dst_y;
+
+ free(translate_reply);
+
+ if (!child || child == root)
+ return 0;
+
+ QPlatformWindow *platformWindow = connection()->platformWindowFromId(child);
+ if (platformWindow)
+ return platformWindow->window();
+ } while (parent != child);
+
+ return 0;
+}
+
+const xcb_visualtype_t *QXcbScreen::visualForId(xcb_visualid_t visualid) const
+{
+ QMap<xcb_visualid_t, xcb_visualtype_t>::const_iterator it = m_visuals.find(visualid);
+ if (it == m_visuals.constEnd())
+ return 0;
+ return &*it;
}
QRect QXcbScreen::geometry() const
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index a78ee822f4..5b8492faa5 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -50,6 +50,7 @@
#include "qxcbobject.h"
class QXcbConnection;
+class QXcbCursor;
class QXcbScreen : public QXcbObject, public QPlatformScreen
{
@@ -57,6 +58,8 @@ public:
QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number);
~QXcbScreen();
+ QWindow *topLevelAt(const QPoint &point) const;
+
QRect geometry() const;
int depth() const;
QImage::Format format() const;
@@ -67,14 +70,21 @@ public:
xcb_screen_t *screen() const { return m_screen; }
xcb_window_t root() const { return m_screen->root; }
+ xcb_window_t clientLeader() const { return m_clientLeader; }
+
QString windowManagerName() const { return m_windowManagerName; }
bool syncRequestSupported() const { return m_syncRequestSupported; }
+ const xcb_visualtype_t *visualForId(xcb_visualid_t) const;
+
private:
xcb_screen_t *m_screen;
int m_number;
QString m_windowManagerName;
bool m_syncRequestSupported;
+ xcb_window_t m_clientLeader;
+ QMap<xcb_visualid_t, xcb_visualtype_t> m_visuals;
+ QXcbCursor *m_cursor;
};
#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 0a02c7eff5..f63cbe25e6 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -45,15 +45,19 @@
#include "qxcbconnection.h"
#include "qxcbscreen.h"
+#include "qxcbdrag.h"
+#include "qxcbwmsupport.h"
+
#ifdef XCB_USE_DRI2
#include "qdri2context.h"
#endif
#include <xcb/xcb_icccm.h>
-#include <private/qapplication_p.h>
-#include <private/qwindowsurface_p.h>
+#include <private/qguiapplication_p.h>
+#include <private/qwindow_p.h>
+#include <QtGui/QPlatformBackingStore>
#include <QtGui/QWindowSystemInterface>
#include <stdio.h>
@@ -65,38 +69,73 @@
#if defined(XCB_USE_GLX)
#include "qglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
#elif defined(XCB_USE_EGL)
-#include "../eglconvenience/qeglplatformcontext.h"
-#include "../eglconvenience/qeglconvenience.h"
-#include "../eglconvenience/qxlibeglintegration.h"
+#include "qxcbeglsurface.h"
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
#endif
+#define XCOORD_MAX 16383
+
+//#ifdef NET_WM_STATE_DEBUG
+
// Returns true if we should set WM_TRANSIENT_FOR on \a w
-static inline bool isTransient(const QWidget *w)
+static inline bool isTransient(const QWindow *w)
{
- return ((w->windowType() == Qt::Dialog
- || w->windowType() == Qt::Sheet
- || w->windowType() == Qt::Tool
- || w->windowType() == Qt::SplashScreen
- || w->windowType() == Qt::ToolTip
- || w->windowType() == Qt::Drawer
- || w->windowType() == Qt::Popup)
- && !w->testAttribute(Qt::WA_X11BypassTransientForHint));
+ return w->windowType() == Qt::Dialog
+ || w->windowType() == Qt::Sheet
+ || w->windowType() == Qt::Tool
+ || w->windowType() == Qt::SplashScreen
+ || w->windowType() == Qt::ToolTip
+ || w->windowType() == Qt::Drawer
+ || w->windowType() == Qt::Popup;
}
-QXcbWindow::QXcbWindow(QWidget *tlw)
- : QPlatformWindow(tlw)
- , m_context(0)
+QXcbWindow::QXcbWindow(QWindow *window)
+ : QPlatformWindow(window)
+ , m_window(0)
+ , m_syncCounter(0)
+ , m_mapped(false)
+ , m_netWmUserTimeWindow(XCB_NONE)
+#if defined(XCB_USE_EGL)
+ , m_eglSurface(0)
+#endif
{
- m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+ m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0));
setConnection(m_screen->connection());
- const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK;
+ create();
+}
+
+void QXcbWindow::create()
+{
+ bool wasCreated = (m_window != 0);
+ destroy();
+
+ m_windowState = Qt::WindowNoState;
+ m_hasReceivedSyncRequest = false;
+ m_dirtyFrameMargins = true;
+
+ Qt::WindowType type = window()->windowType();
+
+ if (type == Qt::Desktop) {
+ m_window = m_screen->root();
+ m_depth = m_screen->screen()->root_depth;
+ m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ connection()->addWindow(m_window, this);
+ return;
+ }
+
+ const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK;
const quint32 values[] = {
// XCB_CW_BACK_PIXMAP
XCB_NONE,
+ // XCB_CW_OVERRIDE_REDIRECT
+ type == Qt::Popup || type == Qt::ToolTip,
+ // XCB_CW_SAVE_UNDER
+ type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer,
// XCB_CW_EVENT_MASK
XCB_EVENT_MASK_EXPOSURE
| XCB_EVENT_MASK_STRUCTURE_NOTIFY
@@ -107,20 +146,30 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
| XCB_EVENT_MASK_BUTTON_MOTION
| XCB_EVENT_MASK_ENTER_WINDOW
| XCB_EVENT_MASK_LEAVE_WINDOW
+ | XCB_EVENT_MASK_POINTER_MOTION
| XCB_EVENT_MASK_PROPERTY_CHANGE
| XCB_EVENT_MASK_FOCUS_CHANGE
};
+ QRect rect = window()->geometry();
+ QPlatformWindow::setGeometry(rect);
+
+ xcb_window_t xcb_parent_id = m_screen->root();
+ if (parent())
+ xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();
+
+ m_requestedFormat = window()->format();
+
#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
- if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
- && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
- || tlw->platformWindowFormat().alpha())
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
+ || window()->format().hasAlpha())
{
#if defined(XCB_USE_GLX)
- XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat());
+ XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window()->format());
+
#elif defined(XCB_USE_EGL)
EGLDisplay eglDisplay = connection()->egl_display();
- EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true);
+ EGLConfig eglConfig = q_configFromGLFormat(eglDisplay, window()->format(), true);
VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig);
XVisualInfo visualInfoTemplate;
@@ -133,18 +182,16 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
#endif //XCB_USE_GLX
if (visualInfo) {
m_depth = visualInfo->depth;
- m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
- Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone);
+ m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ 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.colormap = cmap;
- m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(),
+ m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(),
0, visualInfo->depth, InputOutput, visualInfo->visual,
CWBackPixel|CWBorderPixel|CWColormap, &a);
-
- printf("created GL window: %d\n", m_window);
} else {
qFatal("no window!");
}
@@ -153,25 +200,25 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
{
m_window = xcb_generate_id(xcb_connection());
m_depth = m_screen->screen()->root_depth;
- m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
m_window, // window id
- m_screen->root(), // parent window id
- tlw->x(),
- tlw->y(),
- tlw->width(),
- tlw->height(),
+ xcb_parent_id, // parent window id
+ rect.x(),
+ rect.y(),
+ rect.width(),
+ rect.height(),
0, // border width
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
m_screen->screen()->root_visual, // visual
0, // value mask
0)); // value list
-
- printf("created regular window: %d\n", m_window);
}
+ connection()->addWindow(m_window, this);
+
Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
xcb_atom_t properties[4];
@@ -183,7 +230,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
if (m_screen->syncRequestSupported())
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);
- if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint)
+ if (window()->windowFlags() & Qt::WindowContextHelpButtonHint)
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP);
Q_XCB_CALL(xcb_change_property(xcb_connection(),
@@ -211,29 +258,48 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
&m_syncCounter));
}
- if (isTransient(tlw) && tlw->parentWidget()) {
- // ICCCM 4.1.2.6
- QWidget *p = tlw->parentWidget()->window();
- xcb_window_t parentWindow = p->winId();
- Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
- XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
- 1, &parentWindow));
-
- }
-
// set the PID to let the WM kill the application if unresponsive
long pid = getpid();
Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32,
1, &pid));
+
+ xcb_wm_hints_t hints;
+ memset(&hints, 0, sizeof(hints));
+ xcb_wm_hints_set_normal(&hints);
+
+ xcb_set_wm_hints(xcb_connection(), m_window, &hints);
+
+ xcb_window_t leader = m_screen->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));
+
+ if (wasCreated)
+ setWindowFlags(window()->windowFlags());
+
+ connection()->drag()->dndEnable(this, true);
}
QXcbWindow::~QXcbWindow()
{
- delete m_context;
- if (m_screen->syncRequestSupported())
+ destroy();
+}
+
+void QXcbWindow::destroy()
+{
+ if (m_syncCounter && m_screen->syncRequestSupported())
Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter));
- Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window));
+ if (m_window) {
+ connection()->removeWindow(m_window);
+ Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window));
+ }
+ m_mapped = false;
+
+#if defined(XCB_USE_EGL)
+ delete m_eglSurface;
+ m_eglSurface = 0;
+#endif
}
void QXcbWindow::setGeometry(const QRect &rect)
@@ -241,40 +307,182 @@ void QXcbWindow::setGeometry(const QRect &rect)
QPlatformWindow::setGeometry(rect);
const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
- const quint32 values[] = { rect.x(), rect.y(), rect.width(), rect.height() };
+ const quint32 values[] = { rect.x(),
+ rect.y(),
+ qBound(1, rect.width(), XCOORD_MAX),
+ qBound(1, rect.height(), XCOORD_MAX) };
Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values));
}
+QMargins QXcbWindow::frameMargins() const
+{
+ if (m_dirtyFrameMargins) {
+ xcb_window_t window = m_window;
+ xcb_window_t parent = m_window;
+
+ bool foundRoot = false;
+
+ const QVector<xcb_window_t> &virtualRoots =
+ connection()->wmSupport()->virtualRoots();
+
+ while (!foundRoot) {
+ xcb_query_tree_cookie_t cookie = xcb_query_tree(xcb_connection(), parent);
+
+ xcb_generic_error_t *error;
+ xcb_query_tree_reply_t *reply = xcb_query_tree_reply(xcb_connection(), cookie, &error);
+ if (reply) {
+ if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1) {
+ foundRoot = true;
+ } else {
+ window = parent;
+ parent = reply->parent;
+ }
+
+ free(reply);
+ } else {
+ if (error) {
+ connection()->handleXcbError(error);
+ free(error);
+ }
+
+ m_dirtyFrameMargins = false;
+ m_frameMargins = QMargins();
+ return m_frameMargins;
+ }
+ }
+
+ QPoint offset;
+
+ xcb_generic_error_t *error;
+ xcb_translate_coordinates_reply_t *reply =
+ xcb_translate_coordinates_reply(
+ xcb_connection(),
+ xcb_translate_coordinates(xcb_connection(), window, parent, 0, 0),
+ &error);
+
+ if (reply) {
+ offset = QPoint(reply->dst_x, reply->dst_y);
+ free(reply);
+ } else if (error) {
+ free(error);
+ }
+
+ xcb_get_geometry_reply_t *geom =
+ xcb_get_geometry_reply(
+ xcb_connection(),
+ xcb_get_geometry(xcb_connection(), parent),
+ &error);
+
+ if (geom) {
+ // --
+ // add the border_width for the window managers frame... some window managers
+ // do not use a border_width of zero for their frames, and if we the left and
+ // top strut, we ensure that pos() is absolutely correct. frameGeometry()
+ // will still be incorrect though... perhaps i should have foffset as well, to
+ // indicate the frame offset (equal to the border_width on X).
+ // - Brad
+ // -- copied from qwidget_x11.cpp
+
+ int left = offset.x() + geom->border_width;
+ int top = offset.y() + geom->border_width;
+ int right = geom->width + geom->border_width - geometry().width() - offset.x();
+ int bottom = geom->height + geom->border_width - geometry().height() - offset.y();
+
+ m_frameMargins = QMargins(left, top, right, bottom);
+
+ free(geom);
+ } else if (error) {
+ free(error);
+ }
+
+ m_dirtyFrameMargins = false;
+ }
+
+ return m_frameMargins;
+}
+
void QXcbWindow::setVisible(bool visible)
{
- xcb_wm_hints_t hints;
- if (visible) {
- if (widget()->isMinimized())
+ if (visible)
+ show();
+ else
+ hide();
+}
+
+void QXcbWindow::show()
+{
+ if (window()->isTopLevel()) {
+ xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window);
+
+ xcb_generic_error_t *error;
+
+ xcb_wm_hints_t hints;
+ xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error);
+
+ if (error) {
+ connection()->handleXcbError(error);
+ free(error);
+ }
+
+ m_dirtyFrameMargins = true;
+
+ if (window()->windowState() & Qt::WindowMinimized)
xcb_wm_hints_set_iconic(&hints);
else
xcb_wm_hints_set_normal(&hints);
+
xcb_set_wm_hints(xcb_connection(), m_window, &hints);
- Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window));
- connection()->sync();
- } else {
- 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.sequence = 0; // does this matter?
- 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));
- xcb_flush(xcb_connection());
+ // update WM_NORMAL_HINTS
+ propagateSizeHints();
+
+ // update WM_TRANSIENT_FOR
+ if (window()->transientParent() && isTransient(window())) {
+ QXcbWindow *transientXcbParent = static_cast<QXcbWindow *>(window()->transientParent()->handle());
+ if (transientXcbParent) {
+ // ICCCM 4.1.2.6
+ xcb_window_t parentWindow = transientXcbParent->xcb_window();
+
+ // todo: set transient for group (wm_client_leader) if no parent, a la qwidget_x11.cpp
+ Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
+ XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
+ 1, &parentWindow));
+ }
+ }
+
+ // update _MOTIF_WM_HINTS
+ updateMotifWmHintsBeforeMap();
+
+ // update _NET_WM_STATE
+ updateNetWmStateBeforeMap();
}
+
+ Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window));
+ xcb_flush(xcb_connection());
+
+ connection()->sync();
+}
+
+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));
+
+ xcb_flush(xcb_connection());
+
+ m_mapped = false;
}
-struct QtMWMHints {
+struct QtMotifWmHints {
quint32 flags, functions, decorations;
qint32 input_mode;
quint32 status;
@@ -307,33 +515,142 @@ enum {
MWM_INPUT_FULL_APPLICATION_MODAL = 3L
};
+static QtMotifWmHints getMotifWmHints(QXcbConnection *c, xcb_window_t window)
+{
+ QtMotifWmHints hints;
+
+ xcb_get_property_cookie_t get_cookie =
+ xcb_get_property(c->xcb_connection(), 0, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS),
+ c->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20);
+
+ xcb_generic_error_t *error;
+
+ xcb_get_property_reply_t *reply =
+ xcb_get_property_reply(c->xcb_connection(), get_cookie, &error);
+
+ if (reply && reply->format == 32 && reply->type == c->atom(QXcbAtom::_MOTIF_WM_HINTS)) {
+ hints = *((QtMotifWmHints *)xcb_get_property_value(reply));
+ } else if (error) {
+ c->handleXcbError(error);
+ free(error);
+
+ hints.flags = 0L;
+ hints.functions = MWM_FUNC_ALL;
+ hints.decorations = MWM_DECOR_ALL;
+ hints.input_mode = 0L;
+ hints.status = 0L;
+ }
+
+ free(reply);
+
+ return hints;
+}
+
+static void setMotifWmHints(QXcbConnection *c, xcb_window_t window, const QtMotifWmHints &hints)
+{
+ if (hints.flags != 0l) {
+ Q_XCB_CALL2(xcb_change_property(c->xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ window,
+ c->atom(QXcbAtom::_MOTIF_WM_HINTS),
+ c->atom(QXcbAtom::_MOTIF_WM_HINTS),
+ 32,
+ 5,
+ &hints), c);
+ } else {
+ Q_XCB_CALL2(xcb_delete_property(c->xcb_connection(), window, c->atom(QXcbAtom::_MOTIF_WM_HINTS)), c);
+ }
+}
+
+void QXcbWindow::printNetWmState(const QVector<xcb_atom_t> &state)
+{
+ printf("_NET_WM_STATE (%d): ", state.size());
+ for (int i = 0; i < state.size(); ++i) {
+#define CHECK_WM_STATE(state_atom) \
+ if (state.at(i) == atom(QXcbAtom::state_atom))\
+ printf(#state_atom " ");
+ CHECK_WM_STATE(_NET_WM_STATE_ABOVE)
+ CHECK_WM_STATE(_NET_WM_STATE_BELOW)
+ CHECK_WM_STATE(_NET_WM_STATE_FULLSCREEN)
+ CHECK_WM_STATE(_NET_WM_STATE_MAXIMIZED_HORZ)
+ CHECK_WM_STATE(_NET_WM_STATE_MAXIMIZED_VERT)
+ CHECK_WM_STATE(_NET_WM_STATE_MODAL)
+ CHECK_WM_STATE(_NET_WM_STATE_STAYS_ON_TOP)
+ CHECK_WM_STATE(_NET_WM_STATE_DEMANDS_ATTENTION)
+#undef CHECK_WM_STATE
+ }
+ printf("\n");
+}
+
+QVector<xcb_atom_t> QXcbWindow::getNetWmState()
+{
+ QVector<xcb_atom_t> result;
+
+ xcb_get_property_cookie_t get_cookie =
+ xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE),
+ XCB_ATOM_ATOM, 0, 1024);
+
+ xcb_generic_error_t *error;
+
+ xcb_get_property_reply_t *reply =
+ xcb_get_property_reply(xcb_connection(), get_cookie, &error);
+
+ if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) {
+ result.resize(reply->length);
+
+ memcpy(result.data(), xcb_get_property_value(reply), reply->length * sizeof(xcb_atom_t));
+
+#ifdef NET_WM_STATE_DEBUG
+ printf("getting net wm state (%x)\n", m_window);
+ printNetWmState(result);
+#endif
+
+ free(reply);
+ } else if (error) {
+ connection()->handleXcbError(error);
+ free(error);
+ } else {
+#ifdef NET_WM_STATE_DEBUG
+ printf("getting net wm state (%x), empty\n", m_window);
+#endif
+ }
+
+ return result;
+}
+
+void QXcbWindow::setNetWmState(const QVector<xcb_atom_t> &atoms)
+{
+ if (atoms.isEmpty()) {
+ Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_STATE)));
+ } else {
+ Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
+ atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 32,
+ atoms.count(), atoms.constData()));
+ }
+ xcb_flush(xcb_connection());
+}
+
+
Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
{
Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
- setNetWmWindowTypes(flags);
-
if (type == Qt::ToolTip)
flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;
if (type == Qt::Popup)
flags |= Qt::X11BypassWindowManagerHint;
- bool topLevel = (flags & Qt::Window);
- bool popup = (type == Qt::Popup);
- bool dialog = (type == Qt::Dialog
- || type == Qt::Sheet);
- bool desktop = (type == Qt::Desktop);
- bool tool = (type == Qt::Tool || type == Qt::SplashScreen
- || type == Qt::ToolTip || type == Qt::Drawer);
+ setNetWmWindowFlags(flags);
+ setMotifWindowFlags(flags);
- Q_UNUSED(topLevel);
- Q_UNUSED(dialog);
- Q_UNUSED(desktop);
- Q_UNUSED(tool);
+ return flags;
+}
- bool tooltip = (type == Qt::ToolTip);
+void QXcbWindow::setMotifWindowFlags(Qt::WindowFlags flags)
+{
+ Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
- QtMWMHints mwmhints;
+ QtMotifWmHints mwmhints;
mwmhints.flags = 0L;
mwmhints.functions = 0L;
mwmhints.decorations = 0;
@@ -393,30 +710,90 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
mwmhints.decorations = 0;
}
- if (mwmhints.flags != 0l) {
- Q_XCB_CALL(xcb_change_property(xcb_connection(),
- XCB_PROP_MODE_REPLACE,
- m_window,
- atom(QXcbAtom::_MOTIF_WM_HINTS),
- atom(QXcbAtom::_MOTIF_WM_HINTS),
- 32,
- 5,
- &mwmhints));
- } else {
- Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS)));
- }
+ setMotifWmHints(connection(), m_window, mwmhints);
+}
- if (popup || tooltip) {
- const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER;
- const quint32 values[] = { true, true };
+void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two)
+{
+ xcb_client_message_event_t event;
+
+ event.response_type = XCB_CLIENT_MESSAGE;
+ event.format = 32;
+ event.window = m_window;
+ event.type = atom(QXcbAtom::_NET_WM_STATE);
+ event.data.data32[0] = set ? 1 : 0;
+ event.data.data32[1] = one;
+ event.data.data32[2] = 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));
+}
+
+Qt::WindowState QXcbWindow::setWindowState(Qt::WindowState state)
+{
+ if (state == m_windowState)
+ return state;
+
+ m_dirtyFrameMargins = true;
+
+ // unset old state
+ switch (m_windowState) {
+ case Qt::WindowMinimized:
+ Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window));
+ break;
+ case Qt::WindowMaximized:
+ changeNetWmState(false,
+ atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ),
+ atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT));
+ break;
+ case Qt::WindowFullScreen:
+ changeNetWmState(false, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN));
+ break;
+ default:
+ break;
+ }
- Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
+ // set new state
+ switch (state) {
+ case Qt::WindowMinimized:
+ {
+ xcb_client_message_event_t event;
+
+ event.response_type = XCB_CLIENT_MESSAGE;
+ event.format = 32;
+ event.window = m_window;
+ event.type = atom(QXcbAtom::WM_CHANGE_STATE);
+ event.data.data32[0] = XCB_WM_STATE_ICONIC;
+ event.data.data32[1] = 0;
+ event.data.data32[2] = 0;
+ 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));
+ }
+ break;
+ case Qt::WindowMaximized:
+ changeNetWmState(true,
+ atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ),
+ atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT));
+ break;
+ case Qt::WindowFullScreen:
+ changeNetWmState(true, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN));
+ break;
+ case Qt::WindowNoState:
+ break;
+ default:
+ break;
}
- return QPlatformWindow::setWindowFlags(flags);
+ connection()->sync();
+
+ m_windowState = state;
+ return m_windowState;
}
-void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags)
+void QXcbWindow::setNetWmWindowFlags(Qt::WindowFlags flags)
{
// in order of decreasing priority
QVector<uint> windowTypes;
@@ -452,6 +829,127 @@ void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags)
windowTypes.count(), windowTypes.constData()));
}
+void QXcbWindow::updateMotifWmHintsBeforeMap()
+{
+ QtMotifWmHints mwmhints = getMotifWmHints(connection(), m_window);
+
+ if (window()->windowModality() != Qt::NonModal) {
+ switch (window()->windowModality()) {
+ case Qt::WindowModal:
+ mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL;
+ break;
+ case Qt::ApplicationModal:
+ default:
+ mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL;
+ break;
+ }
+ mwmhints.flags |= MWM_HINTS_INPUT_MODE;
+ } else {
+ mwmhints.input_mode = MWM_INPUT_MODELESS;
+ mwmhints.flags &= ~MWM_HINTS_INPUT_MODE;
+ }
+
+ if (window()->minimumSize() == window()->maximumSize()) {
+ // fixed size, remove the resize handle (since mwm/dtwm
+ // isn't smart enough to do it itself)
+ mwmhints.flags |= MWM_HINTS_FUNCTIONS;
+ if (mwmhints.functions == MWM_FUNC_ALL) {
+ mwmhints.functions = MWM_FUNC_MOVE;
+ } else {
+ mwmhints.functions &= ~MWM_FUNC_RESIZE;
+ }
+
+ if (mwmhints.decorations == MWM_DECOR_ALL) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
+ mwmhints.decorations = (MWM_DECOR_BORDER
+ | MWM_DECOR_TITLE
+ | MWM_DECOR_MENU);
+ } else {
+ mwmhints.decorations &= ~MWM_DECOR_RESIZEH;
+ }
+ }
+
+ if (window()->windowFlags() & Qt::WindowMinimizeButtonHint) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
+ mwmhints.decorations |= MWM_DECOR_MINIMIZE;
+ mwmhints.functions |= MWM_FUNC_MINIMIZE;
+ }
+ if (window()->windowFlags() & Qt::WindowMaximizeButtonHint) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
+ mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
+ mwmhints.functions |= MWM_FUNC_MAXIMIZE;
+ }
+ if (window()->windowFlags() & Qt::WindowCloseButtonHint)
+ mwmhints.functions |= MWM_FUNC_CLOSE;
+
+ setMotifWmHints(connection(), m_window, mwmhints);
+}
+
+void QXcbWindow::updateNetWmStateBeforeMap()
+{
+ QVector<xcb_atom_t> netWmState;
+
+ Qt::WindowFlags flags = window()->windowFlags();
+ if (flags & Qt::WindowStaysOnTopHint) {
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_ABOVE));
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP));
+ } else if (flags & Qt::WindowStaysOnBottomHint) {
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_BELOW));
+ }
+
+ if (window()->windowState() & Qt::WindowFullScreen) {
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN));
+ }
+
+ if (window()->windowState() & Qt::WindowMaximized) {
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ));
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT));
+ }
+
+ if (window()->windowModality() != Qt::NonModal) {
+ netWmState.append(atom(QXcbAtom::_NET_WM_STATE_MODAL));
+ }
+
+ setNetWmState(netWmState);
+}
+
+void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp)
+{
+ xcb_window_t wid = m_window;
+
+ const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW));
+ if (m_netWmUserTimeWindow || isSupportedByWM) {
+ if (!m_netWmUserTimeWindow) {
+ m_netWmUserTimeWindow = xcb_generate_id(xcb_connection());
+ Q_XCB_CALL(xcb_create_window(xcb_connection(),
+ XCB_COPY_FROM_PARENT, // depth -- same as root
+ m_netWmUserTimeWindow, // window id
+ m_window, // parent window id
+ -1, -1, 1, 1,
+ 0, // border width
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
+ m_screen->screen()->root_visual, // visual
+ 0, // value mask
+ 0)); // value list
+ wid = m_netWmUserTimeWindow;
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW),
+ XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow);
+ xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME));
+ } else if (!isSupportedByWM) {
+ // WM no longer supports it, then we should remove the
+ // _NET_WM_USER_TIME_WINDOW atom.
+ xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW));
+ xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow);
+ m_netWmUserTimeWindow = XCB_NONE;
+ } else {
+ wid = m_netWmUserTimeWindow;
+ }
+ }
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::_NET_WM_USER_TIME),
+ XCB_ATOM_CARDINAL, 32, 1, &timestamp);
+}
+
+
WId QXcbWindow::winId() const
{
return m_window;
@@ -459,8 +957,13 @@ WId QXcbWindow::winId() const
void QXcbWindow::setParent(const QPlatformWindow *parent)
{
+ // re-create for compatibility
+ create();
+
QPoint topLeft = geometry().topLeft();
- Q_XCB_CALL(xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y()));
+
+ xcb_window_t xcb_parent_id = parent ? static_cast<const QXcbWindow *>(parent)->xcb_window() : m_screen->root();
+ Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), xcb_parent_id, topLeft.x(), topLeft.y()));
}
void QXcbWindow::setWindowTitle(const QString &title)
@@ -490,56 +993,87 @@ void QXcbWindow::lower()
Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values));
}
+void QXcbWindow::propagateSizeHints()
+{
+ // update WM_NORMAL_HINTS
+ xcb_size_hints_t hints;
+ memset(&hints, 0, sizeof(hints));
+
+ QRect rect = geometry();
+
+ xcb_size_hints_set_position(&hints, true, rect.x(), rect.y());
+ xcb_size_hints_set_size(&hints, true, rect.width(), rect.height());
+ xcb_size_hints_set_win_gravity(&hints, XCB_GRAVITY_STATIC);
+
+ QWindow *win = window();
+
+ QSize minimumSize = win->minimumSize();
+ QSize maximumSize = win->maximumSize();
+ QSize baseSize = win->baseSize();
+ QSize sizeIncrement = win->sizeIncrement();
+
+ if (minimumSize.width() > 0 || minimumSize.height() > 0)
+ xcb_size_hints_set_min_size(&hints, minimumSize.width(), minimumSize.height());
+
+ if (maximumSize.width() < QWINDOWSIZE_MAX || maximumSize.height() < QWINDOWSIZE_MAX)
+ xcb_size_hints_set_max_size(&hints,
+ qMin(XCOORD_MAX, maximumSize.width()),
+ qMin(XCOORD_MAX, maximumSize.height()));
+
+ if (sizeIncrement.width() > 0 || sizeIncrement.height() > 0) {
+ xcb_size_hints_set_base_size(&hints, baseSize.width(), baseSize.height());
+ xcb_size_hints_set_resize_inc(&hints, sizeIncrement.width(), sizeIncrement.height());
+ }
+
+ xcb_set_wm_normal_hints(xcb_connection(), m_window, &hints);
+}
+
void QXcbWindow::requestActivateWindow()
{
- Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, XCB_TIME_CURRENT_TIME));
+ if (m_mapped){
+ updateNetWmUserTime(connection()->time());
+ Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time()));
+ }
connection()->sync();
}
-QPlatformGLContext *QXcbWindow::glContext() const
+QSurfaceFormat QXcbWindow::format() const
{
- if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
- printf("no opengl\n");
- return 0;
- }
- if (!m_context) {
-#if defined(XCB_USE_GLX)
- QXcbWindow *that = const_cast<QXcbWindow *>(this);
- that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat());
-#elif defined(XCB_USE_EGL)
+ // ### return actual format
+ return m_requestedFormat;
+}
+
+#if defined(XCB_USE_EGL)
+QXcbEGLSurface *QXcbWindow::eglSurface() const
+{
+ if (!m_eglSurface) {
EGLDisplay display = connection()->egl_display();
- EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true);
- QVector<EGLint> eglContextAttrs;
- eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
- eglContextAttrs.append(2);
- eglContextAttrs.append(EGL_NONE);
-
- EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)m_window,0);
- QXcbWindow *that = const_cast<QXcbWindow *>(this);
- that->m_context = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API);
-#elif defined(XCB_USE_DRI2)
- QXcbWindow *that = const_cast<QXcbWindow *>(this);
- that->m_context = new QDri2Context(that);
-#endif
+ EGLConfig config = q_configFromGLFormat(display, window()->format(), true);
+ EGLSurface surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)m_window, 0);
+
+ m_eglSurface = new QXcbEGLSurface(display, surface);
}
- return m_context;
+
+ return m_eglSurface;
}
+#endif
void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
{
- QWindowSurface *surface = widget()->windowSurface();
- if (surface) {
- QRect rect(event->x, event->y, event->width, event->height);
-
- surface->flush(widget(), rect, QPoint());
- }
+ QRect rect(event->x, event->y, event->width, event->height);
+ QWindowSystemInterface::handleExposeEvent(window(), rect);
}
void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event)
{
- if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) {
+ if (event->format != 32)
+ return;
+
+ if (event->type == atom(QXcbAtom::WM_PROTOCOLS)) {
if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) {
- QWindowSystemInterface::handleCloseEvent(widget());
+ QWindowSystemInterface::handleCloseEvent(window());
+ } else if (event->data.data32[0] == atom(QXcbAtom::WM_TAKE_FOCUS)) {
+ connection()->setTime(event->data.data32[1]);
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) {
xcb_client_message_event_t reply = *event;
@@ -549,13 +1083,26 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
xcb_send_event(xcb_connection(), 0, m_screen->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]);
if (!m_hasReceivedSyncRequest) {
m_hasReceivedSyncRequest = true;
printf("Window manager supports _NET_WM_SYNC_REQUEST, syncing resizes\n");
}
m_syncValue.lo = event->data.data32[2];
m_syncValue.hi = event->data.data32[3];
+ } else {
+ qWarning() << "unhandled WM_PROTOCOLS message:" << connection()->atomName(event->data.data32[0]);
}
+ } else if (event->type == atom(QXcbAtom::XdndEnter)) {
+ connection()->drag()->handleEnter(window(), event);
+ } else if (event->type == atom(QXcbAtom::XdndPosition)) {
+ connection()->drag()->handlePosition(window(), event, false);
+ } else if (event->type == atom(QXcbAtom::XdndLeave)) {
+ connection()->drag()->handleLeave(window(), event, false);
+ } else if (event->type == atom(QXcbAtom::XdndDrop)) {
+ connection()->drag()->handleDrop(window(), event, false);
+ } else {
+ qWarning() << "unhandled client message:" << connection()->atomName(event->type);
}
}
@@ -575,7 +1122,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
return;
QPlatformWindow::setGeometry(rect);
- QWindowSystemInterface::handleGeometryChange(widget(), rect);
+ QWindowSystemInterface::handleGeometryChange(window(), rect);
#if XCB_USE_DRI2
if (m_context)
@@ -583,6 +1130,22 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
#endif
}
+void QXcbWindow::handleMapNotifyEvent(const xcb_map_notify_event_t *event)
+{
+ if (event->window == m_window) {
+ m_mapped = true;
+ QWindowSystemInterface::handleMapEvent(window());
+ }
+}
+
+void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+{
+ if (event->window == m_window) {
+ m_mapped = false;
+ QWindowSystemInterface::handleUnmapEvent(window());
+ }
+}
+
static Qt::MouseButtons translateMouseButtons(int s)
{
Qt::MouseButtons ret = 0;
@@ -611,6 +1174,8 @@ static Qt::MouseButton translateMouseButton(xcb_button_t s)
void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
{
+ updateNetWmUserTime(event->time);
+
QPoint local(event->event_x, event->event_y);
QPoint global(event->root_x, event->root_y);
@@ -623,7 +1188,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
&& (modifiers & Qt::AltModifier))
|| (event->detail == 6 || event->detail == 7));
- QWindowSystemInterface::handleWheelEvent(widget(), event->time,
+ QWindowSystemInterface::handleWheelEvent(window(), event->time,
local, global, delta, hor ? Qt::Horizontal : Qt::Vertical);
return;
}
@@ -649,32 +1214,65 @@ void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global)
{
+ connection()->setTime(time);
+
Qt::MouseButtons buttons = translateMouseButtons(state);
Qt::MouseButton button = translateMouseButton(detail);
buttons ^= button; // X event uses state *before*, Qt uses state *after*
- QWindowSystemInterface::handleMouseEvent(widget(), time, local, global, buttons);
+ QWindowSystemInterface::handleMouseEvent(window(), time, local, global, buttons);
}
-void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
+void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event)
{
- QWindowSystemInterface::handleEnterEvent(widget());
+ connection()->setTime(event->time);
+
+ if ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB)
+ || event->detail == XCB_NOTIFY_DETAIL_VIRTUAL
+ || event->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL)
+ {
+ return;
+ }
+
+ QWindowSystemInterface::handleEnterEvent(window());
}
-void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
+void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
{
- QWindowSystemInterface::handleLeaveEvent(widget());
+ connection()->setTime(event->time);
+
+ if ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB)
+ || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)
+ {
+ return;
+ }
+
+ QWindowSystemInterface::handleLeaveEvent(window());
}
void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *)
{
- QWindowSystemInterface::handleWindowActivated(widget());
+ QWindowSystemInterface::handleWindowActivated(window());
+}
+
+static bool focusInPeeker(xcb_generic_event_t *event)
+{
+ if (!event) {
+ // FocusIn event is not in the queue, proceed with FocusOut normally.
+ QWindowSystemInterface::handleWindowActivated(0);
+ return true;
+ }
+ uint response_type = event->response_type & ~0x80;
+ return response_type == XCB_FOCUS_IN;
}
void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *)
{
- QWindowSystemInterface::handleWindowActivated(0);
+ // Do not set the active window to 0 if there is a FocusIn coming.
+ // There is however no equivalent for XPutBackEvent so register a
+ // callback for QXcbConnection instead.
+ connection()->addPeekFunc(focusInPeeker);
}
void QXcbWindow::updateSyncRequestCounter()
@@ -688,3 +1286,46 @@ void QXcbWindow::updateSyncRequestCounter()
m_syncValue.hi = 0;
}
}
+
+bool QXcbWindow::setKeyboardGrabEnabled(bool grab)
+{
+ if (!grab) {
+ xcb_ungrab_keyboard(xcb_connection(), XCB_TIME_CURRENT_TIME);
+ return true;
+ }
+ xcb_grab_keyboard_cookie_t cookie = xcb_grab_keyboard(xcb_connection(), false,
+ m_window, XCB_TIME_CURRENT_TIME,
+ GrabModeAsync, GrabModeAsync);
+ xcb_generic_error_t *err;
+ xcb_grab_keyboard_reply_t *reply = xcb_grab_keyboard_reply(xcb_connection(), cookie, &err);
+ bool result = !(err || !reply || reply->status != XCB_GRAB_STATUS_SUCCESS);
+ free(reply);
+ free(err);
+ return result;
+}
+
+bool QXcbWindow::setMouseGrabEnabled(bool grab)
+{
+ if (!grab) {
+ xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME);
+ return true;
+ }
+ xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer(xcb_connection(), false, m_window,
+ (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
+ | EnterWindowMask | LeaveWindowMask | PointerMotionMask),
+ GrabModeAsync, GrabModeAsync,
+ XCB_WINDOW_NONE, XCB_CURSOR_NONE,
+ XCB_TIME_CURRENT_TIME);
+ xcb_generic_error_t *err;
+ xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, &err);
+ bool result = !(err || !reply || reply->status != XCB_GRAB_STATUS_SUCCESS);
+ free(reply);
+ free(err);
+ return result;
+}
+
+void QXcbWindow::setCursor(xcb_cursor_t cursor)
+{
+ xcb_change_window_attributes(xcb_connection(), m_window, XCB_CW_CURSOR, &cursor);
+ xcb_flush(xcb_connection());
+}
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 69d0bc2f1d..89be3b78b2 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -43,7 +43,7 @@
#define QXCBWINDOW_H
#include <QtGui/QPlatformWindow>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtGui/QImage>
#include <xcb/xcb.h>
@@ -52,35 +52,47 @@
#include "qxcbobject.h"
class QXcbScreen;
+class QXcbEGLSurface;
class QXcbWindow : public QXcbObject, public QPlatformWindow
{
public:
- QXcbWindow(QWidget *tlw);
+ QXcbWindow(QWindow *window);
~QXcbWindow();
void setGeometry(const QRect &rect);
+ QMargins frameMargins() const;
+
void setVisible(bool visible);
Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ Qt::WindowState setWindowState(Qt::WindowState state);
WId winId() const;
void setParent(const QPlatformWindow *window);
void setWindowTitle(const QString &title);
void raise();
void lower();
+ void propagateSizeHints();
void requestActivateWindow();
- QPlatformGLContext *glContext() const;
+ bool setKeyboardGrabEnabled(bool grab);
+ bool setMouseGrabEnabled(bool grab);
+
+ void setCursor(xcb_cursor_t cursor);
- xcb_window_t window() const { return m_window; }
+ QSurfaceFormat format() const;
+
+ xcb_window_t xcb_window() const { return m_window; }
uint depth() const { return m_depth; }
- QImage::Format format() const { return m_format; }
+ QImage::Format imageFormat() const { return m_imageFormat; }
void handleExposeEvent(const xcb_expose_event_t *event);
void handleClientMessageEvent(const xcb_client_message_event_t *event);
void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
+ void handleMapNotifyEvent(const xcb_map_notify_event_t *event);
+ void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event);
void handleButtonPressEvent(const xcb_button_press_event_t *event);
void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
@@ -93,22 +105,55 @@ public:
void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global);
void updateSyncRequestCounter();
+ void updateNetWmUserTime(xcb_timestamp_t timestamp);
+ void netWmUserTime() const;
+
+#if defined(XCB_USE_EGL)
+ QXcbEGLSurface *eglSurface() const;
+#endif
private:
- void setNetWmWindowTypes(Qt::WindowFlags flags);
+ void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
+ QVector<xcb_atom_t> getNetWmState();
+ void setNetWmState(const QVector<xcb_atom_t> &atoms);
+ void printNetWmState(const QVector<xcb_atom_t> &state);
+
+ void setNetWmWindowFlags(Qt::WindowFlags flags);
+ void setMotifWindowFlags(Qt::WindowFlags flags);
+
+ void updateMotifWmHintsBeforeMap();
+ void updateNetWmStateBeforeMap();
+
+ void create();
+ void destroy();
+
+ void show();
+ void hide();
QXcbScreen *m_screen;
xcb_window_t m_window;
- QPlatformGLContext *m_context;
uint m_depth;
- QImage::Format m_format;
+ QImage::Format m_imageFormat;
xcb_sync_int64_t m_syncValue;
xcb_sync_counter_t m_syncCounter;
bool m_hasReceivedSyncRequest;
+ Qt::WindowState m_windowState;
+
+ bool m_mapped;
+ xcb_window_t m_netWmUserTimeWindow;
+
+ QSurfaceFormat m_requestedFormat;
+
+ mutable bool m_dirtyFrameMargins;
+ mutable QMargins m_frameMargins;
+
+#if defined(XCB_USE_EGL)
+ mutable QXcbEGLSurface *m_eglSurface;
+#endif
};
#endif
diff --git a/src/plugins/platforms/xcb/qxcbwmsupport.cpp b/src/plugins/platforms/xcb/qxcbwmsupport.cpp
new file mode 100644
index 0000000000..5fb67b6377
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwmsupport.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbwmsupport.h"
+#include "qxcbscreen.h"
+
+#include <qdebug.h>
+
+QXcbWMSupport::QXcbWMSupport(QXcbConnection *c)
+ : QXcbObject(c)
+{
+ updateNetWMAtoms();
+ updateVirtualRoots();
+}
+
+bool QXcbWMSupport::isSupportedByWM(xcb_atom_t atom) const
+{
+ return net_wm_atoms.contains(atom);
+}
+
+
+
+void QXcbWMSupport::updateNetWMAtoms()
+{
+ net_wm_atoms.clear();
+
+ xcb_window_t root = connection()->screens().at(connection()->primaryScreen())->root();
+ int offset = 0;
+ int remaining = 0;
+ do {
+ xcb_generic_error_t *error = 0;
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, &error);
+ if (!reply || error)
+ break;
+
+ remaining = 0;
+
+ if (reply->type == XCB_ATOM_ATOM && reply->format == 32) {
+ int len = xcb_get_property_value_length(reply)/4;
+ xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply);
+ int s = net_wm_atoms.size();
+ net_wm_atoms.resize(s + len);
+ memcpy(net_wm_atoms.data() + s, atoms, len*sizeof(xcb_atom_t));
+
+ remaining = reply->bytes_after;
+ offset += len;
+ }
+
+ free(reply);
+ } while (remaining > 0);
+
+// qDebug() << "======== updateNetWMAtoms";
+// for (int i = 0; i < net_wm_atoms.size(); ++i)
+// qDebug() << atomName(net_wm_atoms.at(i));
+// qDebug() << "======== updateNetWMAtoms";
+}
+
+// update the virtual roots array
+void QXcbWMSupport::updateVirtualRoots()
+{
+ net_virtual_roots.clear();
+
+ if (!isSupportedByWM(atom(QXcbAtom::_NET_VIRTUAL_ROOTS)))
+ return;
+
+ xcb_window_t root = connection()->screens().at(connection()->primaryScreen())->root();
+ int offset = 0;
+ int remaining = 0;
+ do {
+ xcb_generic_error_t *error = 0;
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_VIRTUAL_ROOTS), XCB_ATOM_ATOM, offset, 1024);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, &error);
+ if (!reply || error)
+ break;
+
+ remaining = 0;
+
+ if (reply->type == XCB_ATOM_ATOM && reply->format == 32) {
+ int len = xcb_get_property_value_length(reply)/4;
+ xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply);
+ int s = net_wm_atoms.size();
+ net_wm_atoms.resize(s + len);
+ memcpy(net_wm_atoms.data() + s, atoms, len*sizeof(xcb_atom_t));
+
+ remaining = reply->bytes_after;
+ offset += len;
+ }
+
+ free(reply);
+ } while (remaining > 0);
+
+ qDebug() << "======== updateVirtualRoots";
+ for (int i = 0; i < net_virtual_roots.size(); ++i)
+ qDebug() << connection()->atomName(net_virtual_roots.at(i));
+ qDebug() << "======== updateVirtualRoots";
+}
+
diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h b/src/plugins/platforms/xcb/qxcbwmsupport.h
index 5765483fc7..3b02ef3e7e 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h
+++ b/src/plugins/platforms/xcb/qxcbwmsupport.h
@@ -38,28 +38,30 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef QXCBWMSUPPORT_H
+#define QXCBWMSUPPORT_H
-#ifndef QCOCAEVENTLOOPINTEGRATION_H
-#define QCOCAEVENTLOOPINTEGRATION_H
+#include "qxcbobject.h"
+#include "qxcbconnection.h"
+#include <qvector.h>
-#include <Cocoa/Cocoa.h>
-
-#include <QPlatformEventLoopIntegration>
-
-
-class QCocoaEventLoopIntegration : public QPlatformEventLoopIntegration
+class QXcbWMSupport : public QXcbObject
{
public:
- QCocoaEventLoopIntegration();
- void startEventLoop();
- void quitEventLoop();
- void qtNeedsToProcessEvents();
+ QXcbWMSupport(QXcbConnection *c);
+
+
+ bool isSupportedByWM(xcb_atom_t atom) const;
+ const QVector<xcb_window_t> &virtualRoots() const { return net_virtual_roots; }
private:
- CFRunLoopSourceContext m_sourceContext;
- CFRunLoopTimerContext m_timerContext;
- CFRunLoopSourceRef m_source;
+ friend class QXcbConnection;
+ void updateNetWMAtoms();
+ void updateVirtualRoots();
+
+ QVector<xcb_atom_t> net_wm_atoms;
+ QVector<xcb_window_t> net_virtual_roots;
};
-#endif // QCOCAEVENTLOOPINTEGRATION_H
+#endif
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index 27d10b6756..4b242428fe 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -3,34 +3,59 @@ TARGET = xcb
load(qt_plugin)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
-QT += core-private gui-private
+QT += core-private gui-private platformsupport-private
SOURCES = \
+ qxcbclipboard.cpp \
qxcbconnection.cpp \
qxcbintegration.cpp \
qxcbkeyboard.cpp \
+ qxcbmime.cpp \
+ qxcbdrag.cpp \
qxcbscreen.cpp \
qxcbwindow.cpp \
- qxcbwindowsurface.cpp \
+ qxcbbackingstore.cpp \
+ qxcbwmsupport.cpp \
main.cpp \
- qxcbnativeinterface.cpp
+ qxcbnativeinterface.cpp \
+ qxcbcursor.cpp \
+ qxcbimage.cpp
HEADERS = \
+ qxcbclipboard.h \
qxcbconnection.h \
qxcbintegration.h \
qxcbkeyboard.h \
+ qxcbdrag.h \
+ qxcbmime.h \
qxcbobject.h \
qxcbscreen.h \
qxcbwindow.h \
- qxcbwindowsurface.h \
- qxcbnativeinterface.h
+ qxcbbackingstore.h \
+ qxcbwmsupport.h \
+ qxcbnativeinterface.h \
+ qxcbcursor.h \
+ qxcbimage.h
+
+
+# needed by GLX, Xcursor, XLookupString, ...
+contains(QT_CONFIG, xcb-xlib) {
+ DEFINES += XCB_USE_XLIB
+ LIBS += -lX11 -lX11-xcb
+}
+
+# to support custom cursors with depth > 1
+contains(QT_CONFIG, xcb-render) {
+ DEFINES += XCB_USE_RENDER
+ LIBS += -lxcb-render -lxcb-render-util
+}
contains(QT_CONFIG, opengl) {
QT += opengl
# DEFINES += XCB_USE_DRI2
contains(DEFINES, XCB_USE_DRI2) {
- LIBS += -lxcb-dri2 -lxcb-xfixes -lEGL
+ LIBS += -lxcb-dri2 -lEGL
CONFIG += link_pkgconfig
PKGCONFIG += libdrm
@@ -39,34 +64,28 @@ contains(QT_CONFIG, opengl) {
SOURCES += qdri2context.cpp
} else {
- DEFINES += XCB_USE_XLIB
- LIBS += -lX11 -lX11-xcb
-
contains(QT_CONFIG, opengles2) {
DEFINES += XCB_USE_EGL
- HEADERS += \
- ../eglconvenience/qeglplatformcontext.h \
- ../eglconvenience/qeglconvenience.h \
- ../eglconvenience/qxlibeglintegration.h
-
- SOURCES += \
- ../eglconvenience/qeglplatformcontext.cpp \
- ../eglconvenience/qeglconvenience.cpp \
- ../eglconvenience/qxlibeglintegration.cpp
-
LIBS += -lEGL
+ HEADERS += qxcbeglsurface.h
} else {
DEFINES += XCB_USE_GLX
- include (../glxconvenience/glxconvenience.pri)
HEADERS += qglxintegration.h
SOURCES += qglxintegration.cpp
}
}
}
-LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync
+LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync -lxcb-xfixes
+
+DEFINES += $$QMAKE_DEFINES_XCB
+LIBS += $$QMAKE_LIBS_XCB
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
+
+CONFIG += qpa/genericunixfontdatabase
-include (../fontdatabases/genericunix/genericunix.pri)
+QT += dbus
+LIBS += -ldbus-1
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp
index 02104d9f74..f659d439ec 100644
--- a/src/plugins/platforms/xlib/qxlibintegration.cpp
+++ b/src/plugins/platforms/xlib/qxlibintegration.cpp
@@ -45,7 +45,8 @@
#include <QtCore/qdebug.h>
#include "qxlibwindow.h"
-#include "qgenericunixfontdatabase.h"
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include "qxlibscreen.h"
#include "qxlibclipboard.h"
#include "qxlibdisplay.h"
@@ -106,7 +107,10 @@ QPlatformWindow *QXlibIntegration::createPlatformWindow(QWidget *widget, WId /*w
return new QXlibWindow(widget);
}
-
+QAbstractEventDispatcher *QXlibIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
QPixmap QXlibIntegration::grabWindow(WId window, int x, int y, int width, int height) const
{
diff --git a/src/plugins/platforms/xlib/qxlibintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h
index 9c814ead69..ce5f35a41d 100644
--- a/src/plugins/platforms/xlib/qxlibintegration.h
+++ b/src/plugins/platforms/xlib/qxlibintegration.h
@@ -64,6 +64,7 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QAbstractEventDispatcher *createEventDispatcher() const;
QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro
index 2cba5513d5..0c97d31f11 100644
--- a/src/plugins/platforms/xlib/xlib.pro
+++ b/src/plugins/platforms/xlib/xlib.pro
@@ -1,9 +1,9 @@
TARGET = qxlib
-load(qt_plugin)
+load(qpa/plugin)
DESTDIR = $$QT.gui.plugins/platforms
-QT += core-private gui-private opengl-private
+QT += core-private gui-private opengl-private platformsupport-private
SOURCES = \
main.cpp \
@@ -43,19 +43,13 @@ include (../fontdatabases/genericunix/genericunix.pri)
contains(QT_CONFIG, opengl) {
QT += opengl
!contains(QT_CONFIG, opengles2) {
- include (../glxconvenience/glxconvenience.pri)
+ load(qpa/glx/convenience)
HEADERS += qglxintegration.h
SOURCES += qglxintegration.cpp
} else { # There is no easy way to detect if we'r suppose to use glx or not
- HEADERS += \
- ../eglconvenience/qeglplatformcontext.h \
- ../eglconvenience/qeglconvenience.h \
- ../eglconvenience/qxlibeglintegration.h
-
- SOURCES += \
- ../eglconvenience/qeglplatformcontext.cpp \
- ../eglconvenience/qeglconvenience.cpp \
- ../eglconvenience/qxlibeglintegration.cpp
+ load(qpa/egl/context)
+ load(qpa/egl/convenience)
+ load(qpa/egl/xlibintegration)
LIBS += -lEGL
}
}
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index c1aff35428..0936cd2102 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -7,9 +7,6 @@ unix:!symbian {
SUBDIRS *= codecs
}
!contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats
-!embedded:!qpa:SUBDIRS *= graphicssystems
-embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers
-!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods
!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible
symbian:SUBDIRS += s60
qpa:SUBDIRS += platforms