summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore82
-rw-r--r--.gitlab-ci.yml216
-rwxr-xr-x.gitlab-ci/check-piglit-results.sh30
-rwxr-xr-x.gitlab-ci/cross-prereqs-build.sh8
-rw-r--r--.gitlab-ci/debian-install.sh91
-rwxr-xr-x.gitlab-ci/meson-build.sh145
-rw-r--r--.mailmap365
-rw-r--r--Xext/bigreq.c5
-rw-r--r--Xext/dpms.c222
-rw-r--r--Xext/panoramiX.c11
-rw-r--r--Xext/panoramiXprocs.c5
-rw-r--r--Xext/saver.c33
-rw-r--r--Xext/security.c22
-rw-r--r--Xext/shape.c11
-rw-r--r--Xext/shm.c28
-rw-r--r--Xext/sleepuntil.c4
-rw-r--r--Xext/sync.c38
-rw-r--r--Xext/xace.c2
-rw-r--r--Xext/xf86bigfont.c22
-rw-r--r--Xext/xres.c4
-rw-r--r--Xext/xselinux.h8
-rw-r--r--Xext/xselinux_ext.c5
-rw-r--r--Xext/xselinux_hooks.c12
-rw-r--r--Xext/xselinux_label.c11
-rw-r--r--Xext/xselinuxint.h1
-rw-r--r--Xext/xtest.c71
-rw-r--r--Xext/xvdisp.c8
-rw-r--r--Xext/xvmain.c4
-rw-r--r--Xext/xvmc.c6
-rw-r--r--Xi/chgprop.c7
-rw-r--r--Xi/closedev.c2
-rw-r--r--Xi/exevents.c39
-rw-r--r--Xi/getprop.c8
-rw-r--r--Xi/getselev.c4
-rw-r--r--Xi/selectev.c7
-rw-r--r--Xi/ungrdevb.c8
-rw-r--r--Xi/ungrdevk.c8
-rw-r--r--Xi/xiallowev.c8
-rw-r--r--Xi/xibarriers.c4
-rw-r--r--Xi/xichangecursor.c10
-rw-r--r--Xi/xichangehierarchy.c31
-rw-r--r--Xi/xigetclientpointer.c8
-rw-r--r--Xi/xipassivegrab.c37
-rw-r--r--Xi/xiproperty.c17
-rw-r--r--Xi/xiquerypointer.c12
-rw-r--r--Xi/xiselectev.c11
-rw-r--r--Xi/xisetclientpointer.c4
-rw-r--r--Xi/xiwarppointer.c9
-rw-r--r--composite/compalloc.c8
-rw-r--r--composite/compext.c43
-rw-r--r--composite/compinit.c3
-rw-r--r--composite/compint.h2
-rw-r--r--composite/compositeext.h1
-rw-r--r--composite/compositeext_priv.h17
-rw-r--r--composite/compoverlay.c6
-rw-r--r--composite/compwindow.c23
-rw-r--r--config/10-quirks.conf10
-rw-r--r--config/dbus-core.c3
-rw-r--r--config/dbus-core.h (renamed from include/dbus-core.h)0
-rw-r--r--config/hal.c3
-rw-r--r--config/wscons.c9
-rw-r--r--damageext/damageext.c8
-rw-r--r--dbe/dbe.c8
-rw-r--r--dbe/dbestruct.h1
-rw-r--r--dbe/meson.build8
-rw-r--r--dbe/midbe.c6
-rw-r--r--dix/callback_priv.h15
-rw-r--r--dix/closestr.h (renamed from include/closestr.h)0
-rw-r--r--dix/color.c884
-rw-r--r--dix/colormap.c31
-rw-r--r--dix/colormap_priv.h10
-rw-r--r--dix/cursor.c18
-rw-r--r--dix/devices.c129
-rw-r--r--dix/dispatch.c167
-rw-r--r--dix/dix_priv.h81
-rw-r--r--dix/dixfonts.c47
-rw-r--r--dix/dixutils.c62
-rw-r--r--dix/enterleave.c130
-rw-r--r--dix/enterleave.h2
-rw-r--r--dix/eventconvert.c3
-rw-r--r--dix/eventconvert.h (renamed from include/eventconvert.h)21
-rw-r--r--dix/events.c83
-rw-r--r--dix/extension.c6
-rw-r--r--dix/gc.c24
-rw-r--r--dix/gc_priv.h44
-rw-r--r--dix/gestures.c13
-rw-r--r--dix/getevents.c120
-rw-r--r--dix/globals.c3
-rw-r--r--dix/grabs.c12
-rw-r--r--dix/main.c21
-rw-r--r--dix/meson.build1
-rw-r--r--dix/pixmap.c51
-rw-r--r--dix/privates.c26
-rw-r--r--dix/property.c6
-rw-r--r--dix/protocol.txt18
-rw-r--r--dix/ptrveloc.c26
-rw-r--r--dix/ptrveloc_priv.h58
-rw-r--r--dix/region.c4
-rw-r--r--dix/registry.c24
-rw-r--r--dix/registry_priv.h37
-rw-r--r--dix/resource.c60
-rw-r--r--dix/screenint_priv.h29
-rw-r--r--dix/selection.c4
-rw-r--r--dix/touch.c12
-rw-r--r--dix/window.c47
-rw-r--r--doc/Xserver-spec.xml11
-rw-r--r--dri3/dri3.c15
-rw-r--r--dri3/dri3.h38
-rw-r--r--dri3/dri3_priv.h3
-rw-r--r--dri3/dri3_request.c148
-rw-r--r--dri3/dri3_screen.c77
-rw-r--r--exa/exa.c2
-rw-r--r--exa/exa_accel.c2
-rw-r--r--exa/exa_classic.c2
-rw-r--r--exa/exa_driver.c2
-rw-r--r--exa/exa_glyphs.c2
-rw-r--r--exa/exa_mixed.c2
-rw-r--r--exa/exa_priv.h10
-rw-r--r--fb/fb.h46
-rw-r--r--fb/fbcmap_mi.c37
-rw-r--r--fb/fbfill.c38
-rw-r--r--fb/fbpict.c2
-rw-r--r--fb/fbpixmap.c2
-rw-r--r--fb/fbscreen.c12
-rw-r--r--fb/fbtile.c163
-rw-r--r--fb/fbwindow.c2
-rw-r--r--fb/meson.build1
-rw-r--r--fb/wfbrename.h3
-rw-r--r--glamor/glamor.c169
-rw-r--r--glamor/glamor.h6
-rw-r--r--glamor/glamor_composite_glyphs.c33
-rw-r--r--glamor/glamor_compositerects.c8
-rw-r--r--glamor/glamor_copy.c50
-rw-r--r--glamor/glamor_core.c5
-rw-r--r--glamor/glamor_dash.c22
-rw-r--r--glamor/glamor_debug.h4
-rw-r--r--glamor/glamor_egl.c267
-rw-r--r--glamor/glamor_egl_stubs.c60
-rw-r--r--glamor/glamor_fbo.c2
-rw-r--r--glamor/glamor_glx_provider.c (renamed from hw/xwayland/xwayland-glx.c)21
-rw-r--r--glamor/glamor_glx_provider.h (renamed from hw/xwayland/xwayland-glx.h)4
-rw-r--r--glamor/glamor_glyphblt.c15
-rw-r--r--glamor/glamor_gradient.c72
-rw-r--r--glamor/glamor_image.c6
-rw-r--r--glamor/glamor_lines.c4
-rw-r--r--glamor/glamor_picture.c7
-rw-r--r--glamor/glamor_pixmap.c20
-rw-r--r--glamor/glamor_points.c7
-rw-r--r--glamor/glamor_prepare.c56
-rw-r--r--glamor/glamor_priv.h67
-rw-r--r--glamor/glamor_program.c95
-rw-r--r--glamor/glamor_program.h11
-rw-r--r--glamor/glamor_rects.c8
-rw-r--r--glamor/glamor_render.c170
-rw-r--r--glamor/glamor_segs.c4
-rw-r--r--glamor/glamor_spans.c6
-rw-r--r--glamor/glamor_sync.c3
-rw-r--r--glamor/glamor_text.c43
-rw-r--r--glamor/glamor_transfer.c101
-rw-r--r--glamor/glamor_transfer.h15
-rw-r--r--glamor/glamor_transform.c14
-rw-r--r--glamor/glamor_transform.h13
-rw-r--r--glamor/glamor_utils.c3
-rw-r--r--glamor/glamor_utils.h11
-rw-r--r--glamor/glamor_xv.c334
-rw-r--r--glamor/meson.build11
-rw-r--r--glx/glxcmds.c16
-rw-r--r--glx/glxext.c3
-rw-r--r--glx/indirect_reqsize.h2
-rw-r--r--glx/indirect_size.h2
-rw-r--r--glx/indirect_size_get.c2
-rw-r--r--glx/indirect_size_get.h2
-rw-r--r--glx/vndcmds.c9
-rw-r--r--glx/vndext.c4
-rw-r--r--glx/vndserver.h89
-rw-r--r--glx/vndserver_priv.h118
-rw-r--r--glx/vndservermapping.c2
-rw-r--r--glx/xfont.c2
-rw-r--r--hw/kdrive/ephyr/ephyr.c12
-rw-r--r--hw/kdrive/ephyr/ephyr_glamor.c62
-rw-r--r--hw/kdrive/ephyr/ephyr_glamor_xv.c8
-rw-r--r--hw/kdrive/ephyr/ephyrcursor.c2
-rw-r--r--hw/kdrive/ephyr/ephyrinit.c4
-rw-r--r--hw/kdrive/ephyr/hostx.c67
-rw-r--r--hw/kdrive/ephyr/hostx.h3
-rw-r--r--hw/kdrive/ephyr/meson.build2
-rw-r--r--hw/kdrive/src/kcmap.c2
-rw-r--r--hw/kdrive/src/kdrive.c8
-rw-r--r--hw/kdrive/src/kinput.c4
-rw-r--r--hw/vfb/InitInput.c18
-rw-r--r--hw/vfb/InitOutput.c40
-rw-r--r--hw/xfree86/common/compiler.h50
-rw-r--r--hw/xfree86/common/dgaproc.h12
-rw-r--r--hw/xfree86/common/dgaproc_priv.h19
-rw-r--r--hw/xfree86/common/xf86.h10
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c16
-rw-r--r--hw/xfree86/common/xf86Bus.c1
-rw-r--r--hw/xfree86/common/xf86Config.c9
-rw-r--r--hw/xfree86/common/xf86Configure.c4
-rw-r--r--hw/xfree86/common/xf86Cursor.c1
-rw-r--r--hw/xfree86/common/xf86DGA.c15
-rw-r--r--hw/xfree86/common/xf86Events.c5
-rw-r--r--hw/xfree86/common/xf86Globals.c1
-rw-r--r--hw/xfree86/common/xf86Helper.c18
-rw-r--r--hw/xfree86/common/xf86Init.c26
-rw-r--r--hw/xfree86/common/xf86Mode.c4
-rw-r--r--hw/xfree86/common/xf86Module.h2
-rw-r--r--hw/xfree86/common/xf86Priv.h3
-rw-r--r--hw/xfree86/common/xf86Xinput.c6
-rw-r--r--hw/xfree86/common/xf86cmap.c5
-rw-r--r--hw/xfree86/common/xf86fbBus.c2
-rw-r--r--hw/xfree86/common/xf86noBus.c2
-rw-r--r--hw/xfree86/common/xf86pciBus.c1
-rw-r--r--hw/xfree86/common/xf86platformBus.c64
-rw-r--r--hw/xfree86/common/xf86platformBus.h4
-rw-r--r--hw/xfree86/common/xf86str.h2
-rw-r--r--hw/xfree86/ddc/ddc.c2
-rw-r--r--hw/xfree86/doc/ddxDesign.xml25
-rw-r--r--hw/xfree86/dri/dri.c15
-rw-r--r--hw/xfree86/dri/xf86dri.c7
-rw-r--r--hw/xfree86/dri2/dri2ext.c3
-rw-r--r--hw/xfree86/drivers/modesetting/dri2.c7
-rw-r--r--hw/xfree86/drivers/modesetting/driver.c285
-rw-r--r--hw/xfree86/drivers/modesetting/driver.h23
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c378
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.h29
-rw-r--r--hw/xfree86/drivers/modesetting/meson.build2
-rw-r--r--hw/xfree86/drivers/modesetting/modesetting.man15
-rw-r--r--hw/xfree86/drivers/modesetting/pageflip.c310
-rw-r--r--hw/xfree86/drivers/modesetting/present.c47
-rw-r--r--hw/xfree86/drivers/modesetting/vblank.c136
-rw-r--r--hw/xfree86/fbdevhw/fbdevhw.c45
-rw-r--r--hw/xfree86/glamor_egl/meson.build2
-rw-r--r--hw/xfree86/int10/generic.c7
-rw-r--r--hw/xfree86/int10/helper_exec.c4
-rw-r--r--hw/xfree86/int10/vbe.h5
-rw-r--r--hw/xfree86/man/Xorg.man3
-rw-r--r--hw/xfree86/man/xorg.conf.man26
-rw-r--r--hw/xfree86/modes/xf86Crtc.h9
-rw-r--r--hw/xfree86/modes/xf86Cursors.c9
-rw-r--r--hw/xfree86/modes/xf86DiDGA.c1
-rw-r--r--hw/xfree86/modes/xf86RandR12.c8
-rw-r--r--hw/xfree86/modes/xf86Rotate.c26
-rw-r--r--hw/xfree86/os-support/bsd/alpha_video.c7
-rw-r--r--hw/xfree86/os-support/bsd/arm_video.c5
-rw-r--r--hw/xfree86/os-support/bsd/bsd_VTsw.c7
-rw-r--r--hw/xfree86/os-support/bsd/bsd_bell.c1
-rw-r--r--hw/xfree86/os-support/bsd/bsd_ev56.c3
-rw-r--r--hw/xfree86/os-support/bsd/bsd_init.c47
-rw-r--r--hw/xfree86/os-support/bsd/i386_video.c26
-rw-r--r--hw/xfree86/os-support/bsd/ppc_video.c13
-rw-r--r--hw/xfree86/os-support/bsd/sparc64_video.c4
-rw-r--r--hw/xfree86/os-support/bus/bsd_pci.c2
-rw-r--r--hw/xfree86/os-support/hurd/hurd_bell.c1
-rw-r--r--hw/xfree86/os-support/hurd/hurd_init.c1
-rw-r--r--hw/xfree86/os-support/hurd/hurd_video.c5
-rw-r--r--hw/xfree86/os-support/linux/int10/linux.c64
-rw-r--r--hw/xfree86/os-support/linux/lnx_acpi.c11
-rw-r--r--hw/xfree86/os-support/linux/lnx_agp.c24
-rw-r--r--hw/xfree86/os-support/linux/lnx_apm.c2
-rw-r--r--hw/xfree86/os-support/linux/lnx_bell.c3
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c8
-rw-r--r--hw/xfree86/os-support/linux/lnx_video.c5
-rw-r--r--hw/xfree86/os-support/linux/systemd-logind.c37
-rw-r--r--hw/xfree86/os-support/meson.build7
-rw-r--r--hw/xfree86/os-support/misc/SlowBcopy.c25
-rw-r--r--hw/xfree86/os-support/shared/VTsw_noop.c1
-rw-r--r--hw/xfree86/os-support/shared/VTsw_usl.c3
-rw-r--r--hw/xfree86/os-support/shared/agp_noop.c10
-rw-r--r--hw/xfree86/os-support/shared/drm_platform.c (renamed from hw/xfree86/os-support/linux/lnx_platform.c)11
-rw-r--r--hw/xfree86/os-support/shared/platform_noop.c1
-rw-r--r--hw/xfree86/os-support/shared/pm_noop.c3
-rw-r--r--hw/xfree86/os-support/shared/posix_tty.c12
-rw-r--r--hw/xfree86/os-support/shared/sigio.c6
-rw-r--r--hw/xfree86/os-support/shared/sigiostubs.c2
-rw-r--r--hw/xfree86/os-support/shared/vidmem.c2
-rw-r--r--hw/xfree86/os-support/solaris/solaris-amd64.S2
-rw-r--r--hw/xfree86/os-support/solaris/solaris-ia32.S2
-rw-r--r--hw/xfree86/os-support/solaris/solaris-sparcv8plus.S2
-rw-r--r--hw/xfree86/os-support/solaris/sun_VTsw.c3
-rw-r--r--hw/xfree86/os-support/solaris/sun_agp.c25
-rw-r--r--hw/xfree86/os-support/solaris/sun_apm.c6
-rw-r--r--hw/xfree86/os-support/solaris/sun_bell.c4
-rw-r--r--hw/xfree86/os-support/solaris/sun_init.c10
-rw-r--r--hw/xfree86/os-support/solaris/sun_vid.c14
-rw-r--r--hw/xfree86/os-support/stub/stub_bell.c2
-rw-r--r--hw/xfree86/os-support/stub/stub_init.c1
-rw-r--r--hw/xfree86/os-support/stub/stub_video.c2
-rw-r--r--hw/xfree86/os-support/xf86OSpriv.h41
-rw-r--r--hw/xfree86/os-support/xf86_OSlib.h54
-rw-r--r--hw/xfree86/os-support/xf86_OSproc.h48
-rw-r--r--hw/xfree86/os-support/xf86_os_support.h70
-rw-r--r--hw/xfree86/parser/write.c46
-rw-r--r--hw/xfree86/ramdac/xf86CursorPriv.h2
-rw-r--r--hw/xfree86/ramdac/xf86CursorRD.c15
-rw-r--r--hw/xfree86/ramdac/xf86HWCurs.c12
-rwxr-xr-xhw/xfree86/sdksyms.sh9
-rw-r--r--hw/xfree86/vgahw/vgaHW.c8
-rw-r--r--hw/xfree86/x86emu/prim_ops.c4
-rw-r--r--hw/xfree86/x86emu/sys.c33
-rw-r--r--hw/xfree86/x86emu/x86emu/debug.h37
-rw-r--r--hw/xfree86/xkb/xkbPrivate.c1
-rw-r--r--hw/xnest/Args.c2
-rw-r--r--hw/xnest/Args.h3
-rw-r--r--hw/xnest/Color.c12
-rw-r--r--hw/xnest/Color.h3
-rw-r--r--hw/xnest/Cursor.c7
-rw-r--r--hw/xnest/Display.c10
-rw-r--r--hw/xnest/Events.c5
-rw-r--r--hw/xnest/Font.c6
-rw-r--r--hw/xnest/GC.c2
-rw-r--r--hw/xnest/GCOps.c4
-rw-r--r--hw/xnest/Init.c7
-rw-r--r--hw/xnest/Init.h2
-rw-r--r--hw/xnest/Keyboard.c2
-rw-r--r--hw/xnest/Pixmap.c2
-rw-r--r--hw/xnest/Screen.c26
-rw-r--r--hw/xnest/Screen.h3
-rw-r--r--hw/xnest/Visual.h2
-rw-r--r--hw/xnest/Window.c8
-rw-r--r--hw/xnest/XNCursor.h15
-rw-r--r--hw/xnest/XNFont.h2
-rw-r--r--hw/xnest/XNGC.h2
-rw-r--r--hw/xnest/XNPixmap.h2
-rw-r--r--hw/xnest/XNWindow.h2
-rw-r--r--hw/xquartz/NSUserDefaults+XQuartzDefaults.m9
-rw-r--r--hw/xquartz/X11Controller.m47
-rw-r--r--hw/xquartz/applewm.c4
-rw-r--r--hw/xquartz/bundle/Info.plist.cpp4
-rw-r--r--hw/xquartz/bundle/meson.build6
-rw-r--r--hw/xquartz/darwin.c4
-rw-r--r--hw/xquartz/defaults.plist17
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c13
-rw-r--r--hw/xquartz/mach-startup/stub.c111
-rw-r--r--hw/xquartz/meson.build17
-rw-r--r--hw/xquartz/pbproxy/meson.build5
-rw-r--r--hw/xquartz/quartzStartup.c2
-rw-r--r--hw/xquartz/xpr/appledri.c4
-rw-r--r--hw/xquartz/xpr/xprFrame.c26
-rw-r--r--hw/xwayland/desktop/org.freedesktop.Xwayland.desktop.in8
-rw-r--r--hw/xwayland/man/Xwayland.man82
-rw-r--r--hw/xwayland/meson.build157
-rw-r--r--hw/xwayland/xwayland-cursor.c24
-rw-r--r--hw/xwayland/xwayland-cvt.c50
-rw-r--r--hw/xwayland/xwayland-dmabuf.c795
-rw-r--r--hw/xwayland/xwayland-dmabuf.h115
-rw-r--r--hw/xwayland/xwayland-drm-lease.c46
-rw-r--r--hw/xwayland/xwayland-glamor-eglstream.c1123
-rw-r--r--hw/xwayland/xwayland-glamor-gbm.c859
-rw-r--r--hw/xwayland/xwayland-glamor-gbm.h45
-rw-r--r--hw/xwayland/xwayland-glamor.c373
-rw-r--r--hw/xwayland/xwayland-glamor.h129
-rw-r--r--hw/xwayland/xwayland-input.c467
-rw-r--r--hw/xwayland/xwayland-input.h17
-rw-r--r--hw/xwayland/xwayland-output.c466
-rw-r--r--hw/xwayland/xwayland-output.h32
-rw-r--r--hw/xwayland/xwayland-pixmap.c18
-rw-r--r--hw/xwayland/xwayland-pixmap.h7
-rw-r--r--hw/xwayland/xwayland-present.c536
-rw-r--r--hw/xwayland/xwayland-present.h21
-rw-r--r--hw/xwayland/xwayland-screen.c458
-rw-r--r--hw/xwayland/xwayland-screen.h69
-rw-r--r--hw/xwayland/xwayland-shm.c36
-rw-r--r--hw/xwayland/xwayland-types.h2
-rw-r--r--hw/xwayland/xwayland-vidmode.c42
-rw-r--r--hw/xwayland/xwayland-window-buffers.c373
-rw-r--r--hw/xwayland/xwayland-window-buffers.h9
-rw-r--r--hw/xwayland/xwayland-window.c1563
-rw-r--r--hw/xwayland/xwayland-window.h83
-rw-r--r--hw/xwayland/xwayland-xtest.c936
-rw-r--r--hw/xwayland/xwayland-xtest.h35
-rw-r--r--hw/xwayland/xwayland.c168
-rw-r--r--hw/xwayland/xwayland.pc.in15
-rw-r--r--hw/xwin/InitInput.c4
-rw-r--r--hw/xwin/InitOutput.c22
-rw-r--r--hw/xwin/glx/meson.build4
-rw-r--r--hw/xwin/win.h17
-rw-r--r--hw/xwin/winallpriv.c18
-rw-r--r--hw/xwin/winauth.c3
-rw-r--r--hw/xwin/winclipboard/debug.c20
-rw-r--r--hw/xwin/wincmap.c34
-rw-r--r--hw/xwin/wincreatewnd.c34
-rw-r--r--hw/xwin/windialogs.c14
-rw-r--r--hw/xwin/winerror.c4
-rw-r--r--hw/xwin/winmouse.c2
-rw-r--r--hw/xwin/winmsg.c4
-rw-r--r--hw/xwin/winmsgwindow.c4
-rw-r--r--hw/xwin/winmultiwindowicons.c2
-rw-r--r--hw/xwin/winmultiwindowshape.c4
-rw-r--r--hw/xwin/winmultiwindowwindow.c64
-rw-r--r--hw/xwin/winmultiwindowwm.c29
-rw-r--r--hw/xwin/winmultiwindowwndproc.c30
-rw-r--r--hw/xwin/winprefs.c2
-rw-r--r--hw/xwin/winprocarg.c9
-rw-r--r--hw/xwin/winscrinit.c14
-rw-r--r--hw/xwin/winshadddnl.c78
-rw-r--r--hw/xwin/winshadgdi.c36
-rw-r--r--hw/xwin/winwindow.c18
-rw-r--r--hw/xwin/winwindow.h6
-rw-r--r--hw/xwin/winwndproc.c40
-rw-r--r--include/Xprintf.h2
-rw-r--r--include/Xserver.d2
-rw-r--r--include/callback.h5
-rw-r--r--include/colormap.h1
-rw-r--r--include/cursor.h4
-rw-r--r--include/displaymode.h1
-rw-r--r--include/dix.h64
-rw-r--r--include/dixfont.h1
-rw-r--r--include/dixfontstr.h1
-rw-r--r--include/eventstr.h3
-rw-r--r--include/exevents.h7
-rw-r--r--include/extinit.h1
-rw-r--r--include/fourcc.h39
-rw-r--r--include/gc.h51
-rw-r--r--include/globals.h8
-rw-r--r--include/input.h9
-rw-r--r--include/inputstr.h1
-rw-r--r--include/list.h11
-rw-r--r--include/meson.build60
-rw-r--r--include/misc.h6
-rw-r--r--include/opaque.h6
-rw-r--r--include/os.h277
-rw-r--r--include/pixmap.h9
-rw-r--r--include/pixmapstr.h2
-rw-r--r--include/probes.h2
-rw-r--r--include/protocol-versions.h17
-rw-r--r--include/ptrveloc.h55
-rw-r--r--include/registry.h58
-rw-r--r--include/resource.h36
-rw-r--r--include/screenint.h24
-rw-r--r--include/scrnintstr.h2
-rw-r--r--include/xkbfile.h7
-rw-r--r--include/xkbsrv.h25
-rw-r--r--include/xkbstr.h1
-rw-r--r--include/xorg-config.h.meson.in3
-rw-r--r--include/xorg-server.h.meson.in3
-rw-r--r--include/xwayland-config.h.meson.in13
-rw-r--r--include/xwin-config.h.meson.in4
-rw-r--r--m4/ac_define_dir.m449
-rw-r--r--m4/ax_pthread.m4337
-rw-r--r--man/Xserver.man7
-rw-r--r--man/meson.build36
-rw-r--r--meson.build187
-rw-r--r--meson_options.txt25
-rw-r--r--mi/mi.h5
-rw-r--r--mi/mi_priv.h12
-rw-r--r--mi/miarc.c6
-rw-r--r--mi/micmap.c4
-rw-r--r--mi/midispcur.c3
-rw-r--r--mi/miexpose.c28
-rw-r--r--mi/miinitext.c13
-rw-r--r--mi/mipointer.c27
-rw-r--r--mi/miscrinit.c25
-rw-r--r--mi/miwideline.c10
-rw-r--r--miext/damage/damage.c11
-rw-r--r--miext/rootless/README.txt8
-rw-r--r--miext/rootless/rootless.h3
-rw-r--r--miext/rootless/rootlessCommon.c44
-rw-r--r--miext/rootless/rootlessCommon.h19
-rw-r--r--miext/rootless/rootlessConfig.h4
-rw-r--r--miext/rootless/rootlessGC.c8
-rw-r--r--miext/rootless/rootlessWindow.c387
-rw-r--r--miext/sync/misync.c2
-rw-r--r--miext/sync/misync.h25
-rw-r--r--miext/sync/misync_priv.h33
-rw-r--r--miext/sync/misyncfd.c4
-rw-r--r--miext/sync/misyncshm.c15
-rw-r--r--miext/sync/misyncstr.h14
-rw-r--r--os/WaitFor.c16
-rw-r--r--os/access.c118
-rw-r--r--os/alloc.c60
-rw-r--r--os/audit.h18
-rw-r--r--os/auth.c11
-rw-r--r--os/auth.h114
-rw-r--r--os/backtrace.c5
-rw-r--r--os/busfault.c4
-rw-r--r--os/busfault.h (renamed from include/busfault.h)11
-rw-r--r--os/client.c169
-rw-r--r--os/cmdline.h20
-rw-r--r--os/connection.c30
-rw-r--r--os/fmt.c101
-rw-r--r--os/fmt.h15
-rw-r--r--os/io.c8
-rw-r--r--os/log.c37
-rw-r--r--os/meson.build42
-rw-r--r--os/mitauth.c3
-rw-r--r--os/mitauth.h13
-rw-r--r--os/oscolor.c1661
-rw-r--r--os/osdep.h140
-rw-r--r--os/osinit.c17
-rw-r--r--os/rpcauth.c8
-rw-r--r--os/rpcauth.h13
-rw-r--r--os/strcasestr.c2
-rw-r--r--os/string.c73
-rw-r--r--os/utils.c369
-rw-r--r--os/xdmauth.c9
-rw-r--r--os/xdmauth.h13
-rw-r--r--os/xdmcp.c8
-rw-r--r--os/xdmcp.h29
-rw-r--r--os/xprintf.c2
-rw-r--r--os/xsha1.c2
-rw-r--r--os/xsha1.h (renamed from include/xsha1.h)0
-rw-r--r--present/present.c17
-rw-r--r--present/present.h13
-rw-r--r--present/present_event.c9
-rw-r--r--present/present_execute.c50
-rw-r--r--present/present_notify.c4
-rw-r--r--present/present_priv.h42
-rw-r--r--present/present_request.c189
-rw-r--r--present/present_scmd.c124
-rw-r--r--present/present_screen.c32
-rw-r--r--present/present_vblank.c50
-rw-r--r--randr/randr.c2
-rw-r--r--randr/randrstr.h143
-rw-r--r--randr/randrstr_priv.h139
-rw-r--r--randr/rrcrtc.c5
-rw-r--r--randr/rrdispatch.c7
-rw-r--r--randr/rrlease.c12
-rw-r--r--randr/rrmode.c4
-rw-r--r--randr/rrmonitor.c42
-rw-r--r--randr/rroutput.c5
-rw-r--r--randr/rrproperty.c8
-rw-r--r--randr/rrprovider.c11
-rw-r--r--randr/rrproviderproperty.c4
-rw-r--r--randr/rrscreen.c4
-rw-r--r--randr/rrsdispatch.c2
-rw-r--r--randr/rrtransform.h8
-rw-r--r--randr/rrxinerama.c9
-rw-r--r--record/record.c5
-rw-r--r--record/set.c15
-rw-r--r--render/animcur.c6
-rw-r--r--render/filter.c44
-rw-r--r--render/glyph.c11
-rw-r--r--render/glyphstr.h66
-rw-r--r--render/glyphstr_priv.h64
-rw-r--r--render/picture.c13
-rw-r--r--render/picture.h5
-rw-r--r--render/picturestr.h36
-rw-r--r--render/picturestr_priv.h46
-rw-r--r--render/render.c48
-rw-r--r--test/bugs/bug1354.c149
-rw-r--r--test/bugs/meson.build39
-rw-r--r--test/fixes.c14
-rw-r--r--test/hashtabletest.c74
-rw-r--r--test/input.c90
-rw-r--r--test/list.c32
-rw-r--r--test/meson.build123
-rw-r--r--test/misc.c14
-rwxr-xr-xtest/scripts/xephyr-glamor-gles2-piglit.sh34
-rwxr-xr-xtest/scripts/xephyr-glamor-gles3-piglit.sh34
-rwxr-xr-xtest/scripts/xephyr-glamor-piglit.sh2
-rwxr-xr-xtest/scripts/xinit-piglit-session.sh2
-rwxr-xr-xtest/scripts/xwayland-piglit.sh33
-rw-r--r--test/signal-logging.c87
-rw-r--r--test/simple-xinit.c4
-rw-r--r--test/string.c11
-rw-r--r--test/test_xkb.c24
-rw-r--r--test/tests-common.c37
-rw-r--r--test/tests-common.h3
-rw-r--r--test/tests.c2
-rw-r--r--test/tests.h77
-rw-r--r--test/touch.c130
-rw-r--r--test/xfree86.c19
-rw-r--r--test/xi1/protocol-xchangedevicecontrol.c30
-rw-r--r--test/xi2/protocol-common.c47
-rw-r--r--test/xi2/protocol-common.h23
-rw-r--r--test/xi2/protocol-eventconvert.c29
-rw-r--r--test/xi2/protocol-xigetclientpointer.c52
-rw-r--r--test/xi2/protocol-xigetselectedevents.c68
-rw-r--r--test/xi2/protocol-xipassivegrabdevice.c80
-rw-r--r--test/xi2/protocol-xiquerydevice.c93
-rw-r--r--test/xi2/protocol-xiquerypointer.c80
-rw-r--r--test/xi2/protocol-xiqueryversion.c85
-rw-r--r--test/xi2/protocol-xiselectevents.c47
-rw-r--r--test/xi2/protocol-xisetclientpointer.c25
-rw-r--r--test/xi2/protocol-xiwarppointer.c16
-rw-r--r--test/xi2/xi2.c8
-rw-r--r--test/xtest.c46
-rw-r--r--xfixes/cursor.c30
-rw-r--r--xfixes/disconnect.c4
-rw-r--r--xfixes/region.c12
-rw-r--r--xfixes/saveset.c2
-rw-r--r--xfixes/select.c2
-rw-r--r--xfixes/xfixes.c2
-rw-r--r--xfixes/xfixesint.h2
-rw-r--r--xkb/XKBMAlloc.c1
-rw-r--r--xkb/XKBMisc.c1
-rw-r--r--xkb/ddxLoad.c20
-rw-r--r--xkb/maprules.c1
-rw-r--r--xkb/xkb-procs.h (renamed from xkb/xkb.h)3
-rw-r--r--xkb/xkb.c180
-rw-r--r--xkb/xkbAccessX.c6
-rw-r--r--xkb/xkbActions.c1
-rw-r--r--xkb/xkbEvents.c1
-rw-r--r--xkb/xkbInit.c10
-rw-r--r--xkb/xkbLEDs.c39
-rw-r--r--xkb/xkbSwap.c2
-rw-r--r--xkb/xkbUtils.c10
-rw-r--r--xkb/xkbfmisc.c36
-rw-r--r--xkb/xkbout.c1
-rw-r--r--xkb/xkbtext.c1
-rw-r--r--xkb/xkmread.c17
602 files changed, 17834 insertions, 10558 deletions
diff --git a/.gitignore b/.gitignore
index dc56b4651..a73481552 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,82 +1,4 @@
-#
-# X.Org module default exclusion patterns
-# The next section if for module specific patterns
-#
-# Do not edit the following section
-# GNU Build System (Autotools)
-aclocal.m4
-autom4te.cache/
-autoscan.log
-ChangeLog
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config-ml.in
-config.py
-config.status
-config.status.lineno
-config.sub
-configure
-configure.scan
-depcomp
-.deps/
-INSTALL
-install-sh
-.libs/
-libtool
-libtool.m4
-ltmain.sh
-lt~obsolete.m4
-ltoptions.m4
-ltsugar.m4
-ltversion.m4
-Makefile
-Makefile.in
-mdate-sh
-missing
-mkinstalldirs
-*.pc
-py-compile
-stamp-h?
-symlink-tree
-test-driver
-texinfo.tex
-ylwrap
-
-# Do not edit the following section
-# Edit Compile Debug Document Distribute
*~
-*.[0-9]
-*.[0-9]x
-*.bak
-*.bin
-core
-*.dll
-*.exe
-*-ISO*.bdf
-*-JIS*.bdf
-*-KOI8*.bdf
-*.kld
-*.ko
-*.ko.cmd
-*.lai
-*.l[oa]
-*.[oa]
-*.obj
+*.swp
*.patch
-*.so
-*.pcf.gz
-*.pdb
-*.tar.bz2
-*.tar.gz
-#
-# Add & Override patterns for xserver
-#
-# Edit the following section as needed
-# For example, !report.pc overrides *.pc. See 'man gitignore'
-#
-doltcompile
-doltlibtool
-xserver.ent
+tags
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c7851fbf7..dd055e284 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,11 @@
+# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
+#
+# This CI uses the freedesktop.org ci-templates.
+# Please see the ci-templates documentation for details:
+# https://freedesktop.pages.freedesktop.org/ci-templates/
+
+.templates_sha: &template_sha c5626190ec14b475271288dda7a7dae8dbe0cd76 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
+
# FDO_DISTRIBUTION_TAG is the tag of the docker image used for the build jobs.
# If the image doesn't exist yet, the docker-image stage generates it.
#
@@ -9,18 +17,25 @@
# using the same tag.
variables:
FDO_UPSTREAM_REPO: xorg/xserver
- FDO_DISTRIBUTION_VERSION: buster-slim
+ FDO_DISTRIBUTION_VERSION: bullseye-slim
FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/debian-install.sh'
- FDO_DISTRIBUTION_TAG: "2021-10-22"
+ FDO_DISTRIBUTION_TAG: "2024-03-26-explicit-sync-2"
+ MESON_BUILDDIR: "build"
include:
- project: 'freedesktop/ci-templates'
- ref: 4f06663cd1507136a0f8440925a2521098adb298
+ ref: *template_sha
file: '/templates/debian.yml'
+ - project: 'freedesktop/ci-templates'
+ ref: *template_sha
+ file: '/templates/ci-fairy.yml'
+ - template: Security/SAST.gitlab-ci.yml
stages:
- docker-image
- build-and-test
+ - drivers
+ - test
.ci-run-policy:
# Retry jobs after runner system failures
@@ -31,7 +46,55 @@ stages:
# Cancel CI run if a newer commit is pushed to the same branch
interruptible: true
-debian-buster:
+# This is everything but the DDXen
+.dix_paths: &dix_paths
+ # Directories
+ - .gitlab-ci/**/*
+ - composite/**/*
+ - config/**/*
+ - damageext/**/*
+ - dbe/**/*
+ - dix/**/*
+ - doc/**/*
+ - dri3/**/*
+ - exa/**/*
+ - fb/**/*
+ - glamor/**/*
+ - glx/**/*
+ - include/**/*
+ - m4/**/*
+ - man/**/*
+ - mi/**/*
+ - miext/**/*
+ - os/**/*
+ - present/**/*
+ - pseudoramiX/**/*
+ - randr/**/*
+ - record/**/*
+ - render/**/*
+ - test/**/*
+ - Xext/**/*
+ - xfixes/**/*
+ - Xi/**/*
+ - xkb/**/*
+ # Files
+ - hw/meson.build
+ - .gitlab-ci.yml
+ - meson*
+ - xorg-server.m4
+ - xorg-server.pc.in
+ - xserver.ent.in
+
+.xorg_paths: &xorg_paths
+ - hw/xfree86/**/*
+
+.xwayland_paths: &xwayland_paths
+ - hw/xwayland/**/*
+
+.all_ddx_paths:
+ - hw/**/*
+
+debian-bullseye:
extends:
- .fdo.container-build@debian
- .ci-run-policy
@@ -45,10 +108,12 @@ debian-buster:
- .ci-run-policy
stage: build-and-test
artifacts:
- when: on_failure
+ when: always
paths:
- - build/test/piglit-results/
+ - $MESON_BUILDDIR/meson-logs/
+ - $MESON_BUILDDIR/test/piglit-results/
variables:
+ MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=true
CCACHE_COMPILERCHECK: content
CCACHE_DIR: /cache/xserver/cache
LC_ALL: C.UTF-8
@@ -62,19 +127,146 @@ debian-buster:
meson:
extends: .common-build-and-test
script:
- - meson -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=true $MESON_EXTRA_OPTIONS build/
- - ninja -j${FDO_CI_CONCURRENT:-4} -C build/ dist
- - PIGLIT_DIR=/root/piglit XTEST_DIR=/root/xts ninja -j${FDO_CI_CONCURRENT:-4} -C build/ test
+ - .gitlab-ci/meson-build.sh --run-test
+ - .gitlab-ci/check-piglit-results.sh
- .gitlab-ci/manpages-check
+ variables:
+ XTEST_DIR: /root/xts
+ PIGLIT_DIR: /root/piglit
+ LP_NUM_THREADS: 0
meson-noglamor:
extends: meson
variables:
- MESON_EXTRA_OPTIONS: >
+ MESON_EXTRA_ARGS: >
-Dglamor=false
+meson-nolibdecor:
+ extends: meson
+ variables:
+ MESON_EXTRA_ARGS: >
+ -Dlibdecor=false
+
mingw-cross-build:
extends: .common-build-and-test
script:
- - meson --cross-file=.gitlab-ci/cross-i686-w64-mingw32.txt -Dglx=false -Dsecure-rpc=false -Dlisten_tcp=true build/
- - ninja -j${FDO_CI_CONCURRENT:-4} -C build/ install
+ - .gitlab-ci/meson-build.sh --run-install
+ variables:
+ MESON_ARGS: --cross-file=.gitlab-ci/cross-i686-w64-mingw32.txt -Dglx=false -Dsecure-rpc=false -Dlisten_tcp=true
+
+meson-dist:
+ extends: .common-build-and-test
+ artifacts:
+ when: always
+ paths:
+ - $MESON_BUILDDIR/meson-logs/
+ - $MESON_BUILDDIR/xserver-*/$MESON_BUILDDIR/meson-logs/
+ script:
+ - .gitlab-ci/meson-build.sh --run-dist
+ - mkdir xserver-tarball
+ - tar xf $MESON_BUILDDIR/meson-dist/xserver-*.tar.xz -C xserver-tarball --strip-components=1
+ - .gitlab-ci/meson-build.sh -C xserver-tarball --skip-test --skip-dist --run-install
+ variables:
+ MESON_DIST_ARGS: --no-tests
+ DESTDIR: xserver-tarball/install/
+
+xf86-driver-build-test:
+ extends:
+ - .fdo.distribution-image@debian
+ - .ci-run-policy
+ stage: drivers
+ parallel:
+ matrix:
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev
+ SHA: xf86-input-evdev-2.10.6
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput
+ SHA: xf86-input-libinput-1.4.0
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse
+ SHA: xf86-input-mouse-1.9.5
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-synaptics
+ SHA: xf86-input-synaptics-1.9.2
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu
+ SHA: xf86-video-amdgpu-23.0.0
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-ati
+ SHA: xf86-video-ati-22.0.0
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-qxl
+ SHA: xf86-video-qxl-0.1.6
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vesa
+ SHA: xf86-video-vesa-2.6.0
+ - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vmware
+ SHA: xf86-video-vmware-13.4.0
+ script:
+ # Install the server first
+ - .gitlab-ci/meson-build.sh --skip-test --run-install
+ - unset MESON_EXTRA_ARGS
+ - DRIVER=$(basename $REPO)
+ - git clone "$REPO" "$DRIVER"
+ - GIT_DIR="$DRIVER/.git" git checkout -f "$SHA"
+ - |
+ if [[ -e "$DRIVER/meson.build" ]]; then
+ .gitlab-ci/meson-build.sh -C "$DRIVER" --skip-test
+ else
+ pushd "$DRIVER" || exit 1
+ ./autogen.sh && make
+ fi
+ needs:
+ - "meson"
+ variables:
+ GIT_DEPTH: 1
+ MESON_ARGS: -Dprefix=/usr/
+ MESON_EXTRA_ARGS: -Dxwayland=false -Dxnest=false -Dxvfb=false -Dxquartz=false -Ddocs=false
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ changes:
+ *dix_paths
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ changes:
+ *xorg_paths
+
+#
+# Verify that commit messages are as expected
+#
+check-commits:
+ extends:
+ - .fdo.ci-fairy
+ needs: []
+ stage: test
+ script:
+ - ci-fairy check-commits --junit-xml=results.xml
+ except:
+ - master@xorg/xserver
+ variables:
+ GIT_DEPTH: 100
+ artifacts:
+ reports:
+ junit: results.xml
+ allow_failure: true
+
+#
+# Verify that the merge request has the allow-collaboration checkbox ticked
+#
+check-merge-request:
+ extends:
+ - .fdo.ci-fairy
+ needs: []
+ stage: test
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ script:
+ - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
+ artifacts:
+ when: on_failure
+ reports:
+ junit: results.xml
+ allow_failure: true
+
+#
+# Workflow rules needed due to:
+# https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438
+#
+workflow:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ - if: $CI_OPEN_MERGE_REQUESTS
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'push'
diff --git a/.gitlab-ci/check-piglit-results.sh b/.gitlab-ci/check-piglit-results.sh
new file mode 100755
index 000000000..182579ed2
--- /dev/null
+++ b/.gitlab-ci/check-piglit-results.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+set -o xtrace
+
+if [[ -z "$MESON_BUILDDIR" ]]; then
+ echo "\$MESON_BUILDDIR not set"
+ exit 1
+fi
+
+check_piglit_results ()
+{
+ local EXPECTED_RESULTS="$MESON_BUILDDIR"/test/piglit-results/$1
+ local DEPENDENCY="$MESON_BUILDDIR"/$2
+
+ if ! test -e $DEPENDENCY; then
+ return
+ fi
+
+ if test -e $EXPECTED_RESULTS; then
+ return
+ fi
+
+ echo Expected $EXPECTED_RESULTS does not exist
+ exit 1
+}
+
+check_piglit_results xephyr-glamor hw/kdrive/ephyr/Xephyr.p/ephyr_glamor.c.o
+check_piglit_results xvfb hw/vfb/Xvfb
+check_piglit_results xwayland hw/xwayland/Xwayland
diff --git a/.gitlab-ci/cross-prereqs-build.sh b/.gitlab-ci/cross-prereqs-build.sh
index 4596667a1..916d95a3d 100755
--- a/.gitlab-ci/cross-prereqs-build.sh
+++ b/.gitlab-ci/cross-prereqs-build.sh
@@ -49,14 +49,16 @@ build 'https://gitlab.freedesktop.org/pixman/pixman.git' 'pixman-0.38.4'
build 'https://gitlab.freedesktop.org/xorg/lib/pthread-stubs.git' '0.4'
# we can't use the xorgproto pkgconfig files from /usr/share/pkgconfig, because
# these would add -I/usr/include to CFLAGS, which breaks cross-compilation
-build 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' 'xorgproto-2021.4.99.2' '--datadir=/lib'
+build 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' 'xorgproto-2024.1' '--datadir=/lib'
build 'https://gitlab.freedesktop.org/xorg/lib/libXau.git' 'libXau-1.0.9'
-build 'https://gitlab.freedesktop.org/xorg/proto/xcbproto.git' 'xcb-proto-1.14'
+build 'https://gitlab.freedesktop.org/xorg/proto/xcbproto.git' 'xcb-proto-1.14.1'
build 'https://gitlab.freedesktop.org/xorg/lib/libxcb.git' 'libxcb-1.14'
build 'https://gitlab.freedesktop.org/xorg/lib/libxtrans.git' 'xtrans-1.4.0'
# the default value of keysymdefdir is taken from the includedir variable for
# xproto, which isn't adjusted by pkg-config for the sysroot
-build 'https://gitlab.freedesktop.org/xorg/lib/libX11.git' 'libX11-1.6.9' "--with-keysymdefdir=/usr/${HOST}/include/X11"
+# Using -fcommon to address build failure when cross-compiling for windows.
+# See discussion at https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/913
+CFLAGS="-fcommon" build 'https://gitlab.freedesktop.org/xorg/lib/libX11.git' 'libX11-1.6.9' "--with-keysymdefdir=/usr/${HOST}/include/X11"
build 'https://gitlab.freedesktop.org/xorg/lib/libxkbfile.git' 'libxkbfile-1.1.0'
# freetype needs an explicit --build to know it's cross-compiling
# disable png as freetype tries to use libpng-config, even when cross-compiling
diff --git a/.gitlab-ci/debian-install.sh b/.gitlab-ci/debian-install.sh
index 89ca49e14..59bcea4b0 100644
--- a/.gitlab-ci/debian-install.sh
+++ b/.gitlab-ci/debian-install.sh
@@ -6,10 +6,8 @@ set -o xtrace
# Packages which are needed by this script, but not for the xserver build
EPHEMERAL="
libcairo2-dev
- libevdev-dev
libexpat-dev
libgles2-mesa-dev
- libinput-dev
libxkbcommon-dev
x11-utils
x11-xserver-utils
@@ -17,6 +15,10 @@ EPHEMERAL="
xvfb
"
+# Add bullseye-backports for the newer linux-libc-dev package
+echo 'deb http://deb.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list
+apt update
+
apt-get install -y \
$EPHEMERAL \
autoconf \
@@ -32,8 +34,8 @@ apt-get install -y \
libaudit-dev \
libbsd-dev \
libcairo2 \
+ libcairo2-dev \
libdbus-1-dev \
- libdmx-dev \
libdrm-dev \
libegl1-mesa-dev \
libepoxy-dev \
@@ -46,14 +48,19 @@ apt-get install -y \
libgles2 \
libglx-mesa0 \
libinput10 \
+ libinput-dev \
libnvidia-egl-wayland-dev \
+ libpango1.0-0 \
+ libpango1.0-dev \
libpciaccess-dev \
libpixman-1-dev \
libselinux1-dev \
+ libspice-protocol-dev \
libsystemd-dev \
libtool \
libudev-dev \
libunwind-dev \
+ libwayland-dev \
libx11-dev \
libx11-xcb-dev \
libxau-dev \
@@ -90,14 +97,19 @@ apt-get install -y \
libxtst-dev \
libxv-dev \
libz-mingw-w64-dev \
+ linux-libc-dev/bullseye-backports \
mesa-common-dev \
meson \
mingw-w64-tools \
nettle-dev \
pkg-config \
+ python3-attr \
+ python3-jinja2 \
python3-mako \
python3-numpy \
python3-six \
+ weston \
+ x11-xkb-utils \
xfonts-utils \
xkb-data \
xtrans-dev \
@@ -107,60 +119,79 @@ apt-get install -y \
cd /root
+# Xwayland requires drm 2.4.116 for drmSyncobjEventfd
+git clone https://gitlab.freedesktop.org/mesa/drm --depth 1 --branch=libdrm-2.4.116
+cd drm
+meson _build
+ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
+cd ..
+rm -rf drm
+
# xserver requires libxcvt
-git clone https://gitlab.freedesktop.org/xorg/lib//libxcvt.git --depth 1 --branch=libxcvt-0.1.0
+git clone https://gitlab.freedesktop.org/xorg/lib/libxcvt.git --depth 1 --branch=libxcvt-0.1.0
cd libxcvt
meson _build
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf libxcvt
-# xserver requires xorgproto >= 2021.4.99.2 for XI 2.3.99.1
-git clone https://gitlab.freedesktop.org/xorg/proto/xorgproto.git --depth 1 --branch=xorgproto-2021.4.99.2
+# xserver requires xorgproto >= 2024.1 for XWAYLAND
+git clone https://gitlab.freedesktop.org/xorg/proto/xorgproto.git --depth 1 --branch=xorgproto-2024.1
pushd xorgproto
./autogen.sh
make -j${FDO_CI_CONCURRENT:-4} install
popd
rm -rf xorgproto
-# weston 9.0 requires libwayland >= 1.18
-git clone https://gitlab.freedesktop.org/wayland/wayland.git --depth 1 --branch=1.18.0
+# wayland-protocols requires wayland-scanner 1.20, but Debian bullseye has 1.18 only
+git clone https://gitlab.freedesktop.org/wayland/wayland.git --depth 1 --branch=1.21.0
cd wayland
-meson _build -D{documentation,dtd_validation}=false
+meson -Dtests=false -Ddocumentation=false -Ddtd_validation=false _build
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf wayland
-# Xwayland requires wayland-protocols >= 1.22, but Debian buster has 1.17 only
-git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git --depth 1 --branch=1.22
+# Xwayland requires wayland-protocols >= 1.34, but Debian bullseye has 1.20 only
+git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git --depth 1 --branch=1.34
cd wayland-protocols
-./autogen.sh
-make -j${FDO_CI_CONCURRENT:-4} install
+meson _build
+ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf wayland-protocols
-# Xwayland requires weston > 5.0, but Debian buster has 5.0 only
-git clone https://gitlab.freedesktop.org/wayland/weston.git --depth 1 --branch=9.0
-cd weston
-meson _build -Dbackend-{drm,drm-screencast-vaapi,fbdev,rdp,wayland,x11}=false \
- -Dbackend-default=headless -Dcolor-management-{colord,lcms}=false \
- -Ddemo-clients=false -Dimage-{jpeg,webp}=false \
- -D{pipewire,remoting,screenshare,test-junit-xml,wcap-decode,weston-launch,xwayland}=false \
- -Dshell-{fullscreen,ivi,kiosk}=false -Dsimple-clients=
+# Install libdecor for Xwayland
+git clone https://gitlab.gnome.org/jadahl/libdecor.git --depth 1 --branch=0.1.0
+cd libdecor
+meson _build -D{demo,install_demo}=false
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
-rm -rf weston
+rm -rf libdecor
-git clone https://gitlab.freedesktop.org/mesa/piglit.git --depth 1
+# Install libei for Xwayland
+git clone https://gitlab.freedesktop.org/libinput/libei.git --depth 1 --branch=1.0.0
+cd libei
+meson setup _build -Dtests=disabled -Ddocumentation=[] -Dliboeffis=enabled
+ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
+cd ..
+rm -rf libei
+
+git clone https://gitlab.freedesktop.org/mesa/piglit.git
+cd piglit
+git checkout 265896c86f90cb72e8f218ba6a3617fca8b9a1e3
+cd ..
-git clone https://gitlab.freedesktop.org/xorg/test/xts --depth 1
+git clone https://gitlab.freedesktop.org/xorg/test/xts
cd xts
-./autogen.sh
+git checkout dbbfa96c036e596346147081cbceda136e7c86c1
+# Using -fcommon until we get a proper fix into xtst.
+# See discussion at https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/913
+CFLAGS=-fcommon ./autogen.sh
xvfb-run make -j${FDO_CI_CONCURRENT:-4}
cd ..
-git clone https://gitlab.freedesktop.org/xorg/test/rendercheck --depth 1
+git clone https://gitlab.freedesktop.org/xorg/test/rendercheck
cd rendercheck
+git checkout 67a820621b1475ebfcf3d4f9d7f03a5fc3b9769a
meson build
ninja -j${FDO_CI_CONCURRENT:-4} -C build install
cd ..
@@ -173,14 +204,6 @@ echo 'path=/root/xts' >> piglit/piglit.conf
find -name \*.a -o -name \*.o -o -name \*.c -o -name \*.h -o -name \*.la\* | xargs rm
strip xts/xts5/*/.libs/*
-# Running meson dist requires xkbcomp 1.4.1 or newer, but Debian buster has 1.4.0 only
-git clone https://gitlab.freedesktop.org/xorg/app/xkbcomp.git --depth 1 --branch=xkbcomp-1.4.1
-cd xkbcomp
-./autogen.sh --datarootdir=/usr/share
-make -j${FDO_CI_CONCURRENT:-4} install
-cd ..
-rm -rf xkbcomp
-
apt-get purge -y \
$EPHEMERAL
diff --git a/.gitlab-ci/meson-build.sh b/.gitlab-ci/meson-build.sh
new file mode 100755
index 000000000..abc50b1c2
--- /dev/null
+++ b/.gitlab-ci/meson-build.sh
@@ -0,0 +1,145 @@
+#!/usr/bin/env bash
+#
+# This script is sourced from here:
+# https://gitlab.freedesktop.org/whot/meson-helper
+#
+# SPDX-License-Identifier: MIT
+#
+# Usage:
+# meson-build.sh
+# [-C directory] ... change to directory before doing anything
+# [--skip-build] ... skip the compilation
+# [--skip-test|--run-test] ... skip or explicitly run meson test
+# [--skip-dist|--run-dist] ... skip or explicitly run meson dist
+# [--skip-install|--run-install] ... skip or explicitly run meson install
+#
+#
+# Environment variables:
+# If the .meson_environment file exists in $PWD, it is sourced at the start of the script.
+# This file is sourced before the -C directory option takes effect.
+#
+# MESON_BUILDDIR
+# MESON_ARGS, MESON_EXTRA_ARGS:
+# Args passed to meson setup. The MESON_EXTRA_ARGS exist to make it easier for
+# callers to have a default set of arguments and a variable set of arguments.
+# MESON_TEST_ARGS, MESON_DIST_ARGS, MESON_INSTALL_ARGS:
+# Args passed directly to the respective meson command. If these args are set it implies
+# --run-$cmd. Use --skip-$cmd to skip.
+# NINJA_ARGS - args passed to ninja via meson compile
+
+set -x
+if [[ -f .meson_environment ]]; then
+ . .meson_environment
+fi
+
+# If test args are set, we assume we want to run the tests
+MESON_RUN_TEST="$MESON_TEST_ARGS"
+MESON_RUN_INSTALL="$MESON_INSTALL_ARGS"
+MESON_RUN_DIST="$MESON_DIST_ARGS"
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ -C)
+ directory=$2
+ shift 2
+ pushd "$directory" || exit 1
+ ;;
+ --skip-setup)
+ shift
+ MESON_SKIP_SETUP="1"
+ ;;
+ --skip-build)
+ shift
+ MESON_SKIP_BUILD="1"
+ ;;
+ --skip-test)
+ shift
+ MESON_RUN_TEST=""
+ ;;
+ --run-test)
+ shift
+ MESON_RUN_TEST="1"
+ ;;
+ --skip-dist)
+ shift
+ MESON_RUN_DIST=""
+ ;;
+ --run-dist)
+ shift
+ MESON_RUN_DIST="1"
+ ;;
+ --skip-install)
+ shift
+ MESON_RUN_INSTALL=""
+ ;;
+ --run-install)
+ shift
+ MESON_RUN_INSTALL="1"
+ ;;
+ *)
+ echo "Unknow commandline argument $1"
+ exit 1
+ ;;
+ esac
+done
+
+if [[ -z "$MESON_BUILDDIR" ]]; then
+ echo "\$MESON_BUILDDIR undefined."
+ exit 1
+fi
+
+# emulate a few gitlab variables to make it easier to
+# run and debug locally.
+if [[ -z "$CI_JOB_ID" ]] || [[ -z "$CI_JOB_NAME" ]]; then
+ echo "Missing \$CI_JOB_ID or \$CI_JOB_NAME".
+ CI_PROJECT_NAME=$(basename "$PWD")
+ CI_JOB_ID=$(date +%s)
+ CI_JOB_NAME="$CI_PROJECT_NAME-job-local"
+ echo "Simulating gitlab environment: "
+ echo " CI_JOB_ID=$CI_JOB_ID"
+ echo " CI_JOB_NAME=$CI_JOB_NAME"
+fi
+
+if [[ -n "$FDO_CI_CONCURRENT" ]]; then
+ jobcount="-j$FDO_CI_CONCURRENT"
+ export MESON_TESTTHREADS="$FDO_CI_CONCURRENT"
+fi
+
+if [[ -n "$MESON_EXTRA_ARGS" ]]; then
+ MESON_ARGS="$MESON_ARGS $MESON_EXTRA_ARGS"
+fi
+
+echo "*************************************************"
+echo "builddir: $MESON_BUILDDIR"
+echo "meson args: $MESON_ARGS"
+echo "ninja args: $NINJA_ARGS"
+echo "meson test args: $MESON_TEST_ARGS"
+echo "job count: ${jobcount-0}"
+echo "*************************************************"
+
+set -e
+
+if [[ -z "$MESON_SKIP_SETUP" ]]; then
+ rm -rf "$MESON_BUILDDIR"
+ meson setup "$MESON_BUILDDIR" $MESON_ARGS
+fi
+meson configure "$MESON_BUILDDIR"
+
+if [[ -z "$MESON_SKIP_BUILD" ]]; then
+ if [[ -n "$NINJA_ARGS" ]]; then
+ ninja_args="--ninja-args $NINJA_ARGS"
+ fi
+ meson compile -v -C "$MESON_BUILDDIR" $jobcount $ninja_args
+fi
+
+if [[ -n "$MESON_RUN_TEST" ]]; then
+ meson test -C "$MESON_BUILDDIR" --print-errorlogs $MESON_TEST_ARGS
+fi
+
+if [[ -n "$MESON_RUN_INSTALL" ]]; then
+ meson install --no-rebuild -C "$MESON_BUILDDIR" $MESON_INSTALL_ARGS
+fi
+
+if [[ -n "$MESON_RUN_DIST" ]]; then
+ meson dist -C "$MESON_BUILDDIR" $MESON_DIST_ARGS
+fi
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 000000000..0c3d52f5a
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,365 @@
+Adam Jackson <ajax@redhat.com> <ajax@aspartame.nwnk.net>
+Adam Jackson <ajax@redhat.com> <ajax@benzedrine.nwnk.net>
+Adam Jackson <ajax@redhat.com> <ajax@nwnk.net>
+Adam Jackson <ajax@redhat.com> <ajax@theobromine.nwnk.net>
+
+Adam Tkac <atkac@redhat.com> <vonsch@gmail.com>
+
+Alan Coopersmith <alan.coopersmith@oracle.com> <alan.coopersmith@sun.com>
+Alan Coopersmith <alan.coopersmith@oracle.com> <alanc@alf.(none)>
+
+Alan Hourihane <alanh@vmware.com> <alanh@fairlite.demon.co.uk>
+Alan Hourihane <alanh@vmware.com> <alanh@tungstengraphics.com>
+
+Alex Deucher <alexdeucher@gmail.com> <agd5f@yahoo.com>
+Alex Deucher <alexdeucher@gmail.com> <alex@botch2.(none)>
+Alex Deucher <alexdeucher@gmail.com> <alex@botch2.com>
+Alex Deucher <alexdeucher@gmail.com> <alex@cube.(none)>
+Alex Deucher <alexdeucher@gmail.com> <alex@samba.(none)>
+Alex Deucher <alexdeucher@gmail.com> <alexander.deucher@amd.com>
+
+Alexandr Shadchin <alexandr.shadchin@gmail.com> <Alexandr.Shadchin@gmail.com>
+
+Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com> <ander@mandriva.com.br>
+
+Arjan van de Ven <arjan@infradead.org> <arjan@linux.intel.com>
+
+Arkadiusz Miśkiewicz <arekm@maven.pl>
+
+Axel Davy <davyaxel0@gmail.com> <axel.davy@ens.fr>
+
+Bart Trojanowski <bart@jukie.net> <bart@symbio-technologies.com>
+
+Ben Byer <bbyer@apple.com> <bbyer@bbyer.(none)>
+Ben Byer <bbyer@apple.com> <bbyer@bbyer.apple.com>
+Ben Byer <bbyer@apple.com> <bbyer@bbyer.local>
+Ben Byer <bbyer@apple.com> <bbyer@bushing.apple.com>
+Ben Byer <bbyer@apple.com> <bbyer@freedesktop.org>
+Ben Byer <bbyer@apple.com> <bbyer@xyzzy.local>
+
+Ben Gamari <bgamari.foss@gmail.com> <bgamari@gmail.com>
+
+Ben Skeggs <bskeggs@redhat.com> <skeggsb@gmail.com>
+
+Benjamin Close <benjamin.close@clearchain.com> <Benjamin.Close@clearchain.com>
+
+Benjamin Tissoires <benjamin.tissoires@gmail.com> <tissoire@cena.fr>
+
+Brian Paul <brianp@vmware.com> Brian <brian@i915.localnet.net>
+Brian Paul <brianp@vmware.com> Brian <brian@yutani.localnet.net>
+Brian Paul <brianp@vmware.com> <brian.paul@tungstengraphics.com>
+
+Brice Goglin <bgoglin@debian.org> <brice.goglin@ens-lyon.org>
+
+Carl Worth <cworth@cworth.org> <cworth@samich.home.cworth.org>
+Carl Worth <cworth@cworth.org> <root@samich.home.cworth.org>
+
+Chase Douglas <chase.douglas@canonical.com> <chase.douglas@ubuntu.com>
+Chase Douglas <chase.douglas@canonical.com> <chasedouglas@gmail.com>
+
+Christian König <christian.koenig@amd.com> <christian.koenig at amd.com>
+
+Colin Guthrie <gmane@colin.guthr.ie> <cguthrie@mandriva.org>
+
+Colin Harrison <colin@xming.myzen.co.uk> <colin.harrison-at-virgin.net>
+Colin Harrison <colin@xming.myzen.co.uk> <colin.harrison@virgin.net>
+
+Dan Nicholson <dbn.lists@gmail.com> <dan@conor.dwcab.com>
+
+Daniel Drake <drake@endlessm.com> <d.drake@mmm.com>
+Daniel Drake <drake@endlessm.com> <dsd@gentoo.org>
+Daniel Drake <drake@endlessm.com> <dsd@laptop.org>
+
+Daniel Martin <consume.noise@gmail.com> <daniel.martin@secunet.com>
+
+Daniel Stone <daniels@collabora.com> <daniel.stone@nokia.com>
+Daniel Stone <daniels@collabora.com> <daniel@fooishbar.org>
+
+Dave Airlie <airlied@redhat.com> <airlied@clockmaker.usersys.redhat.com>
+Dave Airlie <airlied@redhat.com> <airlied@gmail.com>
+Dave Airlie <airlied@redhat.com> <airlied@linux.ie>
+Dave Airlie <airlied@redhat.com> <airlied@panoply-rh.(none)>
+Dave Airlie <airlied@redhat.com> <airlied@pegasus.(none)>
+
+David Heidelberg <david@ixit.cz> David Heidelberger <david.heidelberger@ixit.cz>
+
+David Miller <davem@davemloft.net>
+
+David Nusinow <dnusinow@debian.org> <david@nee.(none)>
+
+David Reveman <reveman@chromium.org> <c99drn@cs.umu.se>
+David Reveman <reveman@chromium.org> <davidr@novell.com>
+
+Demi Marie Obenour <demiobenour@gmail.com> <demi@invisiblethingslab.com>
+
+Dodji Seketeli <dodji@seketeli.org> <dodji@openedhand.com>
+
+Donnie Berkholz <dberkholz@gentoo.org> <donnie@supernova.(none)>
+Donnie Berkholz <dberkholz@gentoo.org> <spyderous@gentoo.org>
+
+Drew Parsons <dparsons@debian.org> <drew@emerall.com>
+Drew Parsons <dparsons@debian.org> <drew@pug.localdomain>
+
+Eamon Walsh <ewalsh@tycho.nsa.gov> <efw@eamonwalsh.com>
+Eamon Walsh <ewalsh@tycho.nsa.gov> <ewalsh@epoch.ncsc.mil>
+Eamon Walsh <ewalsh@tycho.nsa.gov> <ewalsh@moss-huskies.epoch.ncsc.mil>
+Eamon Walsh <ewalsh@tycho.nsa.gov> <ewalsh@moss-uranus.epoch.ncsc.mil>
+
+Egbert Eich <eich@suse.de> <eich@freedesktop.org>
+Egbert Eich <eich@suse.de> <eich@ovid.suse.de>
+Egbert Eich <eich@suse.de> <eich@pdx.freedesktop.org>
+
+Emil Velikov <emil.l.velikov@gmail.com> <emil.velikov@collabora.com>
+
+Emma Anholt <emma@anholt.net> <anholt@FreeBSD.org>
+Emma Anholt <emma@anholt.net> <eric@anholt.net>
+
+Eric Engestrom <eric@igalia.com> <eric@engestrom.ch>
+Eric Engestrom <eric@igalia.com> <eric.engestrom@imgtec.com>
+
+Éric Piel <eric.piel@trempin-utc.net>
+Éric Piel <eric.piel@trempin-utc.net> <E.A.B.Piel@tudelft.nl>
+
+Erik Andrén <erik.andren@gmail.com>
+
+Faith Ekstrand <faith.ekstrand@collabora.com> <jason@jlekstrand.net>
+Faith Ekstrand <faith.ekstrand@collabora.com> <jason.ekstrand@intel.com>
+Faith Ekstrand <faith.ekstrand@collabora.com> <faith@gfxstrand.net>
+
+Felix Kuehling <felix.kuehling@amd.com> <fxkuehl@gmx.de>
+
+François Tigeot <ftigeot@wolfpond.org>
+
+George Sapountzis <gsapountzis@gmail.com> <gsap7@yahoo.gr>
+
+George Staplin <gstaplin@apple.com> <gps@Georges-Workstation.local>
+George Staplin <gstaplin@apple.com> <georgestaplin@george-staplins-mac-pro.local>
+
+Haihao Xiang <haihao.xiang@intel.com>
+
+Hans de Goede <hdegoede@redhat.com>
+Hans de Goede <hdegoede@redhat.com> <j.w.r.degoede@hhs.nl>
+
+Henry Zhao <henry.zhao@oracle.com> <henryz@localhost.localdomain>
+
+Ian Romanick <ian.d.romanick@intel.com> <idr@localhost.localdomain>
+Ian Romanick <ian.d.romanick@intel.com> <idr@umwelt.(none)>
+Ian Romanick <ian.d.romanick@intel.com> <idr@us.ibm.com>
+
+Jan Beich <jbeich@freebsd.org> <jbeich@FreeBSD.org>
+
+Jay Cotton <jay.cotton@oracle.com> <jay.cotton@sun.com>
+
+Jeffrey Smith <whydoubt@gmail.com>
+Jeffrey Smith <whydoubt@gmail.com> <whydoubt@yahoo.com>
+
+Jeremy C. Reed <reed@glacier.reedmedia.net> <reed@reedmedia.net>
+
+Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+Jeremy Huddleston Sequoia <jeremyhu@apple.com> <jeremy@dhcp-38-248.EECS.Berkeley.EDU>
+Jeremy Huddleston Sequoia <jeremyhu@apple.com> <jeremy@tifa-2.local>
+Jeremy Huddleston Sequoia <jeremyhu@apple.com> <jeremy@tifa.local>
+Jeremy Huddleston Sequoia <jeremyhu@apple.com> <jeremy@yuffie.local>
+Jeremy Huddleston Sequoia <jeremyhu@apple.com> <jeremyhu@freedesktop.org>
+
+Jeremy Uejio <jeremy.uejio@oracle.com> <jeremy.uejio@sun.com>
+
+Jerome Glisse <jglisse@redhat.com> <glisse@freedesktop.org>
+
+Jesse Adkins <jesserayadkins@gmail.com> <jesse_adkins7@yahoo.com>
+
+Jesse Barnes <jesse.barnes@intel.com> <jbarnes@jbarnes-mobile.amr.corp.intel.com>
+Jesse Barnes <jesse.barnes@intel.com> <jbarnes@jbarnes-t61.(none)>
+Jesse Barnes <jesse.barnes@intel.com> <jbarnes@nietzche.virtuousgeek.org>
+Jesse Barnes <jesse.barnes@intel.com> <jbarnes@virtuousgeek.org>
+
+Joel Bosveld <joel.bosveld@gmail.com> <Joel.Bosveld@gmail.com>
+
+John Tapsell <johnflux@gmail.com> <john.tapsell@john-desktop.(none)>
+
+Jon Turney <jon.turney@dronecode.org.uk>
+
+Julien Isorce <j.isorce@samsung.com> <julien.isorce@gmail.com>
+
+Keith Packard <keithp@keithp.com> <keithp@dulcimer.keithp.com>
+Keith Packard <keithp@keithp.com> <keithp@guitar.keithp.com>
+Keith Packard <keithp@keithp.com> <keithp@koto.keithp.com>
+Keith Packard <keithp@keithp.com> <keithp@mandolin.keithp.com>
+Keith Packard <keithp@keithp.com> <keithp@neko.keithp.com>
+Keith Packard <keithp@keithp.com> <keithp@ukulele.keithp.com>
+Keith Packard <keithp@keithp.com> <keithp@viola.jf.intel.com>
+
+Kevin E Martin <kem@redhat.com> <kem@freedesktop.org>
+Kevin E Martin <kem@redhat.com> <kem@kem.org>
+
+Kristian Høgsberg <krh@bitplanet.net>
+Kristian Høgsberg <krh@bitplanet.net> <krh@redhat.com>
+Kristian Høgsberg <krh@bitplanet.net> <krh@sasori.boston.redhat.com>
+Kristian Høgsberg <krh@bitplanet.net> <krh@temari.boston.redhat.com>
+
+Laércio de Sousa <laerciosousa@sme-mogidascruzes.sp.gov.br>
+Laércio de Sousa <laerciosousa@sme-mogidascruzes.sp.gov.br> <lbsousajr@gmail.com>
+
+Lina Versace <lina@kiwitree.net> <chad.versace@linux.intel.com>
+
+Lucas Stach <dev@lynxeye.de> <l.stach@pengutronix.de>
+
+Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
+Łukasz Spintzyk <lukasz.spintzyk@synaptics.com> <lukasz.spintzyk@gmail.com>
+
+Lyude Paul <lyude@redhat.com>
+Lyude Paul <lyude@redhat.com> <cpaul@redhat.com>
+
+Maarten Lankhorst <maarten.lankhorst@ubuntu.com> <dev@mblankhorst.nl>
+Maarten Lankhorst <maarten.lankhorst@ubuntu.com> <maarten.lankhorst@canonical.com>
+
+Marc Aurele La France <tsi@ualberta.ca> <tsi@ualberta.edu>
+
+Mario Kleiner <mario.kleiner.de@gmail.com> <mario.kleiner@tuebingen.mpg.de>
+
+Mark Kettenis <kettenis@openbsd.org> <mark.kettenis@xs4all.nl>
+
+Matthew Allum <mallum@openedhand.com> <breakfast@10.am>
+Matthew Allum <mallum@openedhand.com> <mallum@polystyrene.(none)>
+
+Matthieu Herrb <matthieu@herrb.eu> <matthieu.herrb@laas.fr>
+Matthieu Herrb <matthieu@herrb.eu> <matthieu@bluenote.herrb.com>
+Matthieu Herrb <matthieu@herrb.eu> <matthieu@blues.laas.fr>
+Matthieu Herrb <matthieu@herrb.eu> <matthieu@crux.(none)>
+Matthieu Herrb <matthieu@herrb.eu> <matthieu@deville.herrb.com>
+Matthieu Herrb <matthieu@herrb.eu> <matthieu@laas.fr>
+Matthieu Herrb <matthieu@herrb.eu> <matthieu@roadrock.(none)>
+
+Max Schwarz <Max@x-quadraht.de> <max.schwarz@online.de>
+
+Maya Rashish <maya@NetBSD.org>
+Maya Rashish <maya@NetBSD.org> <coypu@sdf.org>
+
+Michal Srb <msrb@suse.com> <msrb@novell.com>
+
+Michal Suchanek <hramrach@gmail.com> <hramrach@centrum.cz>
+
+Michał Górny <gentoo@mgorny.alt.pl>
+Michał Górny <gentoo@mgorny.alt.pl> <mgorny@gentoo.org>
+
+Michael Vogt <mvo@ubuntu.com> <michael.vogt@ubuntu.com>
+
+Michel Dänzer <michel@daenzer.net>
+Michel Dänzer <michel@daenzer.net> <daenzer@debian.org>
+Michel Dänzer <michel@daenzer.net> <daenzer@vmware.com>
+Michel Dänzer <michel@daenzer.net> <mdaenzer@redhat.com>
+Michel Dänzer <michel@daenzer.net> <michel.daenzer@amd.com>
+Michel Dänzer <michel@daenzer.net> <michel@tungstengraphics.com>
+
+Michele Baldessari <michele@redhat.com> <michele@acksyn.org>
+
+Neil Roberts <nroberts@igalia.com> <neil@linux.intel.com>
+
+nerdopolis <bluescreen_avenger@verizon.net> nerdopolis <rbos@rbos>
+
+Nicolai Hähnle <nicolai.haehnle@amd.com>
+Nicolai Hähnle <nicolai.haehnle@amd.com> <nhaehnle@gmail.com>
+
+Niveditha Rau <niveditha.rau@oracle.com> <niveditha.rau@sun.com>
+
+Oliver McFadden <oliver.mcfadden@linux.intel.com> <oliver.mcfadden@nokia.com>
+
+Olivier Fourdan <ofourdan@redhat.com> <fourdan@xfce.org>
+
+Owen W. Taylor <otaylor@fishsoup.net>
+Owen W. Taylor <otaylor@fishsoup.net> <otaylor@huygens.home.fishsoup.net>
+Owen W. Taylor <otaylor@fishsoup.net> <otaylor@redhat.com>
+
+Pauli Nieminen <pauli.nieminen@linux.intel.com> <ext-pauli.nieminen@nokia.com>
+
+Paulo Zanoni <paulo.r.zanoni@intel.com> Paulo Ricardo Zanoni <prz05@c3sl.ufpr.br>
+Paulo Zanoni <paulo.r.zanoni@intel.com> Paulo Ricardo Zanoni <pzanoni@mandriva.com>
+
+Pekka Paalanen <pekka.paalanen@collabora.co.uk> <pekka.paalanen@collabora.com>
+
+Peter Harris <pharris@opentext.com> <peter.harris@hummingbird.com>
+
+Peter Hutterer <peter.hutterer@who-t.net> <peter.hutterer@redhat.com>
+Peter Hutterer <peter.hutterer@who-t.net> <peter@cs.unisa.edu.au>
+Peter Hutterer <peter.hutterer@who-t.net> <whot@potoroo.wearablelab.ml.unisa.edu.au>
+Peter Hutterer <peter.hutterer@who-t.net> rpm-build <rpm-build>
+
+Pierre Willenbrock <pierre@pirsoft.de> <pierre@pirsoft.dnsalias.org>
+
+Qiang Yu <yuq825@gmail.com> <Qiang.Yu@amd.com>
+
+Rami Ylimaki <rami.ylimaki@vincit.fi>
+Rami Ylimaki <rami.ylimaki@vincit.fi> <ext-rami.ylimaki@nokia.com>
+
+Rémi Cardona <remi@gentoo.org>
+Rémi Cardona <remi@gentoo.org> <remi.cardona@lri.fr>
+
+Rob Clark <robclark@freedesktop.org> <robdclark@gmail.com>
+
+Roland Bär <roland@verifysoft.de>
+
+Roland Scheidegger <sroland@vmware.com> <rscheidegger_lists@hispeed.ch>
+Roland Scheidegger <sroland@vmware.com> <sroland@tungstengraphics.com>
+
+Roman Gilg <subdiff@gmail.com>
+Roman Kapl <code@rkapl.cz>
+
+Ross Burton <ross.burton@intel.com> <ross@burtonini.com>
+Ross Burton <ross.burton@intel.com> <ross@linux.intel.com>
+
+Sam Lau <sam.lau@oracle.com> <sam.lau@sun.com>
+
+Simon Farnsworth <simon.farnsworth@onelan.com> <simon.farnsworth@onelan.co.uk>
+
+Sjoerd Simons <sjoerd@collabora.com> <sjoerd.simons@collabora.co.uk>
+
+Søren Sandmann Pedersen <sandmann@redhat.com>
+Søren Sandmann Pedersen <sandmann@redhat.com> <soren.sandmann@gmail.com>
+Søren Sandmann Pedersen <sandmann@redhat.com> <sandmann@daimi.au.dk>
+Søren Sandmann Pedersen <sandmann@redhat.com> <ssp@l3000.localdomain>
+Søren Sandmann Pedersen <sandmann@redhat.com> <ssp@redhat.com>
+Søren Sandmann Pedersen <sandmann@redhat.com> <ssp@dhcp83-218.boston.redhat.com>
+
+Stuart Kreitman <stuart.kreitman@oracle.com> <stuart.kreitman@sun.com>
+
+Thierry Reding <treding@nvidia.com> <thierry.reding@avionic-design.de>
+Thierry Reding <treding@nvidia.com> <thierry.reding@gmail.com>
+
+Thomas Hellstrom <thellstrom@vmware.com> <thomas-at-tungstengraphics-dot-com>
+Thomas Hellstrom <thellstrom@vmware.com> <thomas-at-tungstengraphics.com>
+Thomas Hellstrom <thellstrom@vmware.com> <unichrome@shipmail.org>
+
+Thomas Jaeger <thjaeger@gmail.com> <ThJaeger@gmail.com>
+
+Tiago Vignatti <tiago.vignatti@nokia.com>
+Tiago Vignatti <tiago.vignatti@nokia.com> <tiago.vignatti@Nokia.com>
+Tiago Vignatti <tiago.vignatti@nokia.com> <tiagov@balalaika.(none)>
+Tiago Vignatti <tiago.vignatti@nokia.com> <tv02@c3sl.ufpr.br>
+Tiago Vignatti <tiago.vignatti@nokia.com> <vignatti@c3sl.ufpr.br>
+
+Timo Aaltonen <tjaalton@debian.org> <tjaalton@cc.hut.fi>
+Timo Aaltonen <tjaalton@debian.org> <tjaalton@ubuntu.com>
+
+Tomas Carnecky <tomas.carnecky@gmail.com> <tom@dbservice.com>
+
+Tormod Volden <debian.tormod@gmail.com> <lists.tormod@gmail.com>
+Tormod Volden <debian.tormod@gmail.com> <bugzi06.fdo.tormod@xoxy.net>
+
+Ville Syrjälä <ville.syrjala@linux.intel.com>
+Ville Syrjälä <ville.syrjala@linux.intel.com> <syrjala@sci.fi>
+Ville Syrjälä <ville.syrjala@linux.intel.com> <ville.syrjala@nokia.com>
+
+Yuriy Vasilev <uuvasiliev@yandex.ru>
+
+Zack Rusin <zackr@vmware.com> <zack@kde.org>
+Zack Rusin <zackr@vmware.com> <zack@tungstengraphics.com>
+
+Zephaniah E. Hull <warp@aehallh.com> <warp@agamemnon.b5>
+
+Zhenyu Wang <zhenyuw@linux.intel.com> <zhenyu.z.wang@intel.com>
+
+Zhigang Gong <zhigang.gong@intel.com> <zhigang.gong@gmail.com>
+Zhigang Gong <zhigang.gong@intel.com> <zhigang.gong@linux.intel.com>
+
+Zoltán Böszörményi <zboszor@gmail.com>
+Zoltán Böszörményi <zboszor@gmail.com> <zboszor@pr.hu>
diff --git a/Xext/bigreq.c b/Xext/bigreq.c
index c78a1e4b4..aca5afb96 100644
--- a/Xext/bigreq.c
+++ b/Xext/bigreq.c
@@ -32,11 +32,14 @@ from The Open Group.
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/extensions/bigreqsproto.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
-#include <X11/extensions/bigreqsproto.h>
#include "opaque.h"
#include "extinit.h"
diff --git a/Xext/dpms.c b/Xext/dpms.c
index e43a37974..bbc7890eb 100644
--- a/Xext/dpms.c
+++ b/Xext/dpms.c
@@ -42,6 +42,7 @@ Equipment Corporation.
#include "extinit.h"
#include "scrnintstr.h"
#include "windowstr.h"
+#include "protocol-versions.h"
CARD16 DPMSPowerLevel = 0;
Bool DPMSDisabledSwitch = FALSE;
@@ -50,6 +51,178 @@ CARD32 DPMSSuspendTime = -1;
CARD32 DPMSOffTime = -1;
Bool DPMSEnabled;
+static int DPMSReqCode = 0;
+static RESTYPE ClientType, DPMSEventType; /* resource types for event masks */
+static XID eventResource;
+
+typedef struct _DPMSEvent *DPMSEventPtr;
+typedef struct _DPMSEvent {
+ DPMSEventPtr next;
+ ClientPtr client;
+ XID clientResource;
+ unsigned int mask;
+} DPMSEventRec;
+
+ /*ARGSUSED*/ static int
+DPMSFreeClient(void *data, XID id)
+{
+ DPMSEventPtr pEvent;
+ DPMSEventPtr *pHead, pCur, pPrev;
+
+ pEvent = (DPMSEventPtr) data;
+ dixLookupResourceByType((void *) &pHead, eventResource, DPMSEventType,
+ NullClient, DixUnknownAccess);
+ if (pHead) {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pEvent; pCur = pCur->next)
+ pPrev = pCur;
+ if (pCur) {
+ if (pPrev)
+ pPrev->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ }
+ }
+ free((void *) pEvent);
+ return 1;
+}
+
+ /*ARGSUSED*/ static int
+DPMSFreeEvents(void *data, XID id)
+{
+ DPMSEventPtr *pHead, pCur, pNext;
+
+ pHead = (DPMSEventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext) {
+ pNext = pCur->next;
+ FreeResource(pCur->clientResource, ClientType);
+ free((void *) pCur);
+ }
+ free((void *) pHead);
+ return 1;
+}
+
+static void
+SDPMSInfoNotifyEvent(xGenericEvent * from,
+ xGenericEvent * to)
+{
+ *to = *from;
+ swaps(&to->sequenceNumber);
+ swapl(&to->length);
+ swaps(&to->evtype);
+ if (from->evtype == DPMSInfoNotify) {
+ xDPMSInfoNotifyEvent *c = (xDPMSInfoNotifyEvent *) to;
+ swapl(&c->timestamp);
+ swaps(&c->power_level);
+ }
+}
+
+static int
+ProcDPMSSelectInput(register ClientPtr client)
+{
+ REQUEST(xDPMSSelectInputReq);
+ DPMSEventPtr pEvent, pNewEvent, *pHead;
+ XID clientResource;
+ int i;
+
+ REQUEST_SIZE_MATCH(xDPMSSelectInputReq);
+ i = dixLookupResourceByType((void **)&pHead, eventResource, DPMSEventType,
+ client,
+ DixWriteAccess);
+ if (stuff->eventMask == DPMSInfoNotifyMask) {
+ if (i == Success && pHead) {
+ /* check for existing entry. */
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if (pEvent->client == client) {
+ pEvent->mask = stuff->eventMask;
+ return Success;
+ }
+ }
+ }
+
+ /* build the entry */
+ pNewEvent = (DPMSEventPtr)malloc(sizeof(DPMSEventRec));
+ if (!pNewEvent)
+ return BadAlloc;
+ pNewEvent->next = 0;
+ pNewEvent->client = client;
+ pNewEvent->mask = stuff->eventMask;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID(client->index);
+ pNewEvent->clientResource = clientResource;
+ if (!AddResource(clientResource, ClientType, (void *)pNewEvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input
+ */
+ if (i != Success || !pHead) {
+ pHead = (DPMSEventPtr *)malloc(sizeof(DPMSEventPtr));
+ if (!pHead ||
+ !AddResource(eventResource, DPMSEventType, (void *)pHead)) {
+ FreeResource(clientResource, X11_RESTYPE_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewEvent->next = *pHead;
+ *pHead = pNewEvent;
+ }
+ else if (stuff->eventMask == 0) {
+ /* delete the interest */
+ if (i == Success && pHead) {
+ pNewEvent = 0;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if (pEvent->client == client)
+ break;
+ pNewEvent = pEvent;
+ }
+ if (pEvent) {
+ FreeResource(pEvent->clientResource, ClientType);
+ if (pNewEvent)
+ pNewEvent->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ free(pEvent);
+ }
+ }
+ }
+ else {
+ client->errorValue = stuff->eventMask;
+ return BadValue;
+ }
+ return Success;
+}
+
+static void
+SendDPMSInfoNotify(void)
+{
+ DPMSEventPtr *pHead, pEvent;
+ xDPMSInfoNotifyEvent se;
+ int i;
+
+ i = dixLookupResourceByType((void **)&pHead, eventResource, DPMSEventType,
+ serverClient,
+ DixReadAccess);
+ if (i != Success || !pHead)
+ return;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if ((pEvent->mask & DPMSInfoNotifyMask) == 0)
+ continue;
+ se.type = GenericEvent;
+ se.extension = DPMSReqCode;
+ se.length = (sizeof(xDPMSInfoNotifyEvent) - 32) >> 2;
+ se.evtype = DPMSInfoNotify;
+ se.timestamp = currentTime.milliseconds;
+ se.power_level = DPMSPowerLevel;
+ se.state = DPMSEnabled;
+ WriteEventsToClient(pEvent->client, 1, (xEvent *)&se);
+ }
+}
+
Bool
DPMSSupported(void)
{
@@ -86,6 +259,7 @@ int
DPMSSet(ClientPtr client, int level)
{
int rc, i;
+ int old_level = DPMSPowerLevel;
DPMSPowerLevel = level;
@@ -109,6 +283,9 @@ DPMSSet(ClientPtr client, int level)
if (screenInfo.gpuscreens[i]->DPMS != NULL)
screenInfo.gpuscreens[i]->DPMS(screenInfo.gpuscreens[i], level);
+ if (DPMSPowerLevel != old_level)
+ SendDPMSInfoNotify();
+
return Success;
}
@@ -120,8 +297,8 @@ ProcDPMSGetVersion(ClientPtr client)
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
- .majorVersion = DPMSMajorVersion,
- .minorVersion = DPMSMinorVersion
+ .majorVersion = SERVER_DPMS_MAJOR_VERSION,
+ .minorVersion = SERVER_DPMS_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
@@ -212,8 +389,10 @@ ProcDPMSEnable(ClientPtr client)
REQUEST_SIZE_MATCH(xDPMSEnableReq);
DPMSEnabled = TRUE;
- if (!was_enabled)
+ if (!was_enabled) {
SetScreenSaverTimer();
+ SendDPMSInfoNotify();
+ }
return Success;
}
@@ -221,6 +400,8 @@ ProcDPMSEnable(ClientPtr client)
static int
ProcDPMSDisable(ClientPtr client)
{
+ Bool was_enabled = DPMSEnabled;
+
/* REQUEST(xDPMSDisableReq); */
REQUEST_SIZE_MATCH(xDPMSDisableReq);
@@ -228,6 +409,8 @@ ProcDPMSDisable(ClientPtr client)
DPMSSet(client, DPMSModeOn);
DPMSEnabled = FALSE;
+ if (was_enabled)
+ SendDPMSInfoNotify();
return Success;
}
@@ -298,6 +481,8 @@ ProcDPMSDispatch(ClientPtr client)
return ProcDPMSForceLevel(client);
case X_DPMSInfo:
return ProcDPMSInfo(client);
+ case X_DPMSSelectInput:
+ return ProcDPMSSelectInput(client);
default:
return BadRequest;
}
@@ -398,6 +583,18 @@ SProcDPMSInfo(ClientPtr client)
}
static int _X_COLD
+SProcDPMSSelectInput(ClientPtr client)
+{
+ REQUEST(xDPMSSelectInputReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xDPMSSelectInputReq);
+ swapl(&stuff->eventMask);
+ return ProcDPMSSelectInput(client);
+}
+
+
+
+static int _X_COLD
SProcDPMSDispatch(ClientPtr client)
{
REQUEST(xReq);
@@ -418,6 +615,8 @@ SProcDPMSDispatch(ClientPtr client)
return SProcDPMSForceLevel(client);
case X_DPMSInfo:
return SProcDPMSInfo(client);
+ case X_DPMSSelectInput:
+ return SProcDPMSSelectInput(client);
default:
return BadRequest;
}
@@ -432,6 +631,8 @@ DPMSCloseDownExtension(ExtensionEntry *e)
void
DPMSExtensionInit(void)
{
+ ExtensionEntry *extEntry;
+
#define CONDITIONALLY_SET_DPMS_TIMEOUT(_timeout_value_) \
if (_timeout_value_ == -1) { /* not yet set from config */ \
_timeout_value_ = ScreenSaverTime; \
@@ -444,8 +645,15 @@ DPMSExtensionInit(void)
DPMSPowerLevel = DPMSModeOn;
DPMSEnabled = DPMSSupported();
- if (DPMSEnabled)
- AddExtension(DPMSExtensionName, 0, 0,
- ProcDPMSDispatch, SProcDPMSDispatch,
- DPMSCloseDownExtension, StandardMinorOpcode);
+ ClientType = CreateNewResourceType(DPMSFreeClient, "DPMSClient");
+ DPMSEventType = CreateNewResourceType(DPMSFreeEvents, "DPMSEvent");
+ eventResource = FakeClientID(0);
+
+ if (DPMSEnabled && ClientType && DPMSEventType &&
+ (extEntry = AddExtension(DPMSExtensionName, 0, 0,
+ ProcDPMSDispatch, SProcDPMSDispatch,
+ DPMSCloseDownExtension, StandardMinorOpcode))) {
+ DPMSReqCode = extEntry->base;
+ GERegisterExtension(DPMSReqCode, SDPMSInfoNotifyEvent);
+ }
}
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index bd9c45b03..94c81a7c8 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -27,14 +27,14 @@ Equipment Corporation.
#include <dix-config.h>
#endif
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xarch.h>
+#include <X11/extensions/panoramiXproto.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "cursor.h"
#include "cursorstr.h"
@@ -47,12 +47,11 @@ Equipment Corporation.
#include "windowstr.h"
#include "pixmapstr.h"
#include "panoramiX.h"
-#include <X11/extensions/panoramiXproto.h>
#include "panoramiXsrv.h"
#include "globals.h"
#include "servermd.h"
#include "resource.h"
-#include "picturestr.h"
+#include "picturestr_priv.h"
#include "xfixesint.h"
#include "damageextint.h"
#ifdef COMPOSITE
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 32424fcbd..3e3567590 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -32,6 +32,9 @@ Equipment Corporation.
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+
#include "windowstr.h"
#include "dixfontstr.h"
#include "gcstruct.h"
@@ -475,7 +478,7 @@ PanoramiXConfigureWindow(ClientPtr client)
/* because we need the parent */
result = dixLookupResourceByType((void **) &pWin, stuff->window,
- RT_WINDOW, client, DixWriteAccess);
+ X11_RESTYPE_WINDOW, client, DixWriteAccess);
if (result != Success)
return result;
diff --git a/Xext/saver.c b/Xext/saver.c
index f813ba08d..29f280369 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -30,8 +30,13 @@ in this Software without prior written authorization from the X Consortium.
#include <dix-config.h>
#endif
+#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/extensions/saverproto.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "os.h"
#include "windowstr.h"
@@ -41,7 +46,6 @@ in this Software without prior written authorization from the X Consortium.
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
-#include <X11/extensions/saverproto.h>
#include "gcstruct.h"
#include "cursorstr.h"
#include "colormapst.h"
@@ -56,9 +60,6 @@ in this Software without prior written authorization from the X Consortium.
#include "dpmsproc.h"
#endif
#include "protocol-versions.h"
-
-#include <stdio.h>
-
#include "extinit.h"
static int ScreenSaverEventBase = 0;
@@ -450,7 +451,7 @@ UninstallSaverColormap(ScreenPtr pScreen)
if (pPriv && pPriv->installedMap != None) {
rc = dixLookupResourceByType((void **) &pCmap, pPriv->installedMap,
- RT_COLORMAP, serverClient,
+ X11_RESTYPE_COLORMAP, serverClient,
DixUninstallAccess);
if (rc == Success)
(*pCmap->pScreen->UninstallColormap) (pCmap);
@@ -474,7 +475,7 @@ CreateSaverWindow(ScreenPtr pScreen)
pSaver = &pScreen->screensaver;
if (pSaver->pWindow) {
pSaver->pWindow = NullWindow;
- FreeResource(pSaver->wid, RT_NONE);
+ FreeResource(pSaver->wid, X11_RESTYPE_NONE);
if (pPriv) {
UninstallSaverColormap(pScreen);
pPriv->hasWindow = FALSE;
@@ -498,7 +499,7 @@ CreateSaverWindow(ScreenPtr pScreen)
if (!pWin)
return FALSE;
- if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin))
+ if (!AddResource(pWin->drawable.id, X11_RESTYPE_WINDOW, pWin))
return FALSE;
mask = 0;
@@ -518,7 +519,7 @@ CreateSaverWindow(ScreenPtr pScreen)
CursorPtr cursor;
if (!pWin->optional)
if (!MakeWindowOptional(pWin)) {
- FreeResource(pWin->drawable.id, RT_NONE);
+ FreeResource(pWin->drawable.id, X11_RESTYPE_NONE);
return FALSE;
}
cursor = RefCursor(pAttr->pCursor);
@@ -546,7 +547,7 @@ CreateSaverWindow(ScreenPtr pScreen)
if (wantMap == None || IsMapInstalled(wantMap, pWin))
return TRUE;
- result = dixLookupResourceByType((void **) &pCmap, wantMap, RT_COLORMAP,
+ result = dixLookupResourceByType((void **) &pCmap, wantMap, X11_RESTYPE_COLORMAP,
serverClient, DixInstallAccess);
if (result != Success)
return TRUE;
@@ -570,7 +571,7 @@ DestroySaverWindow(ScreenPtr pScreen)
pSaver = &pScreen->screensaver;
if (pSaver->pWindow) {
pSaver->pWindow = NullWindow;
- FreeResource(pSaver->wid, RT_NONE);
+ FreeResource(pSaver->wid, X11_RESTYPE_NONE);
}
pPriv->hasWindow = FALSE;
CheckScreenPrivate(pScreen);
@@ -899,7 +900,7 @@ ScreenSaverSetAttributes(ClientPtr client)
else {
ret =
dixLookupResourceByType((void **) &pPixmap, pixID,
- RT_PIXMAP, client, DixReadAccess);
+ X11_RESTYPE_PIXMAP, client, DixReadAccess);
if (ret == Success) {
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
@@ -931,7 +932,7 @@ ScreenSaverSetAttributes(ClientPtr client)
else {
ret =
dixLookupResourceByType((void **) &pPixmap, pixID,
- RT_PIXMAP, client, DixReadAccess);
+ X11_RESTYPE_PIXMAP, client, DixReadAccess);
if (ret == Success) {
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
@@ -1014,7 +1015,7 @@ ScreenSaverSetAttributes(ClientPtr client)
break;
case CWColormap:
cmap = (Colormap) * pVlist;
- ret = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
+ ret = dixLookupResourceByType((void **) &pCmap, cmap, X11_RESTYPE_COLORMAP,
client, DixUseAccess);
if (ret != Success) {
client->errorValue = cmap;
@@ -1034,7 +1035,7 @@ ScreenSaverSetAttributes(ClientPtr client)
}
else {
ret = dixLookupResourceByType((void **) &pCursor, cursorID,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (ret != Success) {
client->errorValue = cursorID;
goto PatchUp;
@@ -1051,7 +1052,7 @@ ScreenSaverSetAttributes(ClientPtr client)
pVlist++;
}
if (pPriv->attr)
- FreeScreenAttr(pPriv->attr);
+ FreeResource(pPriv->attr->resource, AttrType);
pPriv->attr = pAttr;
pAttr->resource = FakeClientID(client->index);
if (!AddResource(pAttr->resource, AttrType, (void *) pAttr))
@@ -1231,7 +1232,7 @@ ProcScreenSaverSuspend(ClientPtr client)
if (suspend == TRUE)
this->count++;
else if (--this->count == 0)
- FreeResource(this->clientResource, RT_NONE);
+ FreeResource(this->clientResource, X11_RESTYPE_NONE);
return Success;
}
diff --git a/Xext/security.c b/Xext/security.c
index 162d07ae0..cf5f4051a 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -28,13 +28,17 @@ in this Software without prior written authorization from The Open Group.
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+#include "dix/registry_priv.h"
+#include "os/audit.h"
+#include "os/auth.h"
+
#include "scrnintstr.h"
#include "inputstr.h"
#include "windowstr.h"
#include "propertyst.h"
#include "colormapst.h"
#include "privates.h"
-#include "registry.h"
#include "xacestr.h"
#include "securitysrv.h"
#include <X11/extensions/securproto.h>
@@ -147,7 +151,7 @@ SecurityLabelInitial(void)
/*
* Looks up a request name
*/
-static _X_INLINE const char *
+static inline const char *
SecurityLookupRequestName(ClientPtr client)
{
return LookupRequestName(client->majorOp, client->minorOp);
@@ -198,7 +202,7 @@ SecurityDeleteAuthorization(void *value, XID id)
.authId = pAuth->id
};
WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are);
- FreeResource(pEventClient->resource, RT_NONE);
+ FreeResource(pEventClient->resource, X11_RESTYPE_NONE);
}
/* kill all clients using this auth */
@@ -304,7 +308,7 @@ SecurityAuthorizationExpired(OsTimerPtr timer, CARD32 time, void *pval)
pAuth->secondsRemaining);
}
else {
- FreeResource(pAuth->id, RT_NONE);
+ FreeResource(pAuth->id, X11_RESTYPE_NONE);
return 0;
}
} /* SecurityAuthorizationExpired */
@@ -368,7 +372,7 @@ SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
pEventClient; pEventClient = pEventClient->next) {
if (SameClient(pEventClient, client)) {
if (mask == 0)
- FreeResource(pEventClient->resource, RT_NONE);
+ FreeResource(pEventClient->resource, X11_RESTYPE_NONE);
else
pEventClient->mask = mask;
return Success;
@@ -580,7 +584,7 @@ ProcSecurityRevokeAuthorization(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->authId, RT_NONE);
+ FreeResource(stuff->authId, X11_RESTYPE_NONE);
return Success;
} /* ProcSecurityRevokeAuthorization */
@@ -747,12 +751,12 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
/* disable background None for untrusted windows */
- if ((requested & DixCreateAccess) && (rec->rtype == RT_WINDOW))
+ if ((requested & DixCreateAccess) && (rec->rtype == X11_RESTYPE_WINDOW))
if (subj->haveState && subj->trustLevel != XSecurityClientTrusted)
((WindowPtr) rec->res)->forcedBG = TRUE;
/* additional permissions for specific resource types */
- if (rec->rtype == RT_WINDOW)
+ if (rec->rtype == X11_RESTYPE_WINDOW)
allowed |= SecurityWindowExtraMask;
/* special checks for server-owned resources */
@@ -761,7 +765,7 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
/* additional operations allowed on root windows */
allowed |= SecurityRootWindowExtraMask;
- else if (rec->rtype == RT_COLORMAP)
+ else if (rec->rtype == X11_RESTYPE_COLORMAP)
/* allow access to default colormaps */
allowed = requested;
diff --git a/Xext/shape.c b/Xext/shape.c
index e7c7a45b0..792c20f71 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -29,9 +29,13 @@ in this Software without prior written authorization from The Open Group.
#endif
#include <stdlib.h>
-
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/extensions/shapeproto.h>
+
+#include "dix/dix_priv.h"
+#include "dix/gc_priv.h"
+
#include "misc.h"
#include "os.h"
#include "windowstr.h"
@@ -41,7 +45,6 @@ in this Software without prior written authorization from The Open Group.
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
-#include <X11/extensions/shapeproto.h>
#include "regionstr.h"
#include "gcstruct.h"
#include "extinit.h"
@@ -362,7 +365,7 @@ ProcShapeMask(ClientPtr client)
srcRgn = 0;
else {
rc = dixLookupResourceByType((void **) &pPixmap, stuff->src,
- RT_PIXMAP, client, DixReadAccess);
+ X11_RESTYPE_PIXMAP, client, DixReadAccess);
if (rc != Success)
return rc;
if (pPixmap->drawable.pScreen != pScreen ||
@@ -783,7 +786,7 @@ ProcShapeSelectInput(ClientPtr client)
if (!pHead ||
!AddResource(pWin->drawable.id, ShapeEventType,
(void *) pHead)) {
- FreeResource(clientResource, RT_NONE);
+ FreeResource(clientResource, X11_RESTYPE_NONE);
return BadAlloc;
}
*pHead = 0;
diff --git a/Xext/shm.c b/Xext/shm.c
index 071bd1a41..a17915a67 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -35,14 +35,17 @@ in this Software without prior written authorization from The Open Group.
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
-#ifdef HAVE_MEMFD_CREATE
#include <sys/mman.h>
-#endif
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "os/auth.h"
+#include "os/busfault.h"
+#include "os/osdep.h"
+
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
@@ -59,7 +62,6 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xfuncproto.h>
#include <sys/mman.h>
#include "protocol-versions.h"
-#include "busfault.h"
/* Needed for Solaris cross-zone shared memory extension */
#ifdef HAVE_SHMCTL64
@@ -93,6 +95,8 @@ in this Software without prior written authorization from The Open Group.
#include "panoramiXsrv.h"
#endif
+#include "dix/dix_priv.h"
+
#include "extinit.h"
typedef struct _ShmScrPrivateRec {
@@ -459,7 +463,7 @@ ProcShmDetach(ClientPtr client)
REQUEST_SIZE_MATCH(xShmDetachReq);
VERIFY_SHMSEG(stuff->shmseg, shmdesc, client);
- FreeResource(stuff->shmseg, RT_NONE);
+ FreeResource(stuff->shmseg, X11_RESTYPE_NONE);
return Success;
}
@@ -997,7 +1001,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
if (pMap) {
result = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid,
- RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess);
+ X11_RESTYPE_PIXMAP, pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (result != Success) {
pDraw->pScreen->DestroyPixmap(pMap);
break;
@@ -1006,7 +1010,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id;
- if (!AddResource(newPix->info[j].id, RT_PIXMAP, (void *) pMap)) {
+ if (!AddResource(newPix->info[j].id, X11_RESTYPE_PIXMAP, (void *) pMap)) {
result = BadAlloc;
break;
}
@@ -1019,7 +1023,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
if (result != Success) {
while (j--)
- FreeResource(newPix->info[j].id, RT_NONE);
+ FreeResource(newPix->info[j].id, X11_RESTYPE_NONE);
free(newPix);
}
else
@@ -1111,8 +1115,8 @@ ProcShmCreatePixmap(ClientPtr client)
shmdesc->addr +
stuff->offset);
if (pMap) {
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
- pMap, RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, X11_RESTYPE_PIXMAP,
+ pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) {
pDraw->pScreen->DestroyPixmap(pMap);
return rc;
@@ -1121,7 +1125,7 @@ ProcShmCreatePixmap(ClientPtr client)
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
- if (AddResource(stuff->pid, RT_PIXMAP, (void *) pMap)) {
+ if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap)) {
return Success;
}
}
@@ -1139,7 +1143,7 @@ ShmBusfaultNotify(void *context)
(unsigned int) shmdesc->resource);
busfault_unregister(shmdesc->busfault);
shmdesc->busfault = NULL;
- FreeResource (shmdesc->resource, RT_NONE);
+ FreeResource (shmdesc->resource, X11_RESTYPE_NONE);
}
static int
@@ -1321,7 +1325,7 @@ ProcShmCreateSegment(ClientPtr client)
}
if (WriteFdToClient(client, fd, TRUE) < 0) {
- FreeResource(stuff->shmseg, RT_NONE);
+ FreeResource(stuff->shmseg, X11_RESTYPE_NONE);
close(fd);
return BadAlloc;
}
diff --git a/Xext/sleepuntil.c b/Xext/sleepuntil.c
index 334c2784a..3ff7a1d04 100644
--- a/Xext/sleepuntil.c
+++ b/Xext/sleepuntil.c
@@ -166,7 +166,7 @@ SertafiedBlockHandler(void *data, void *wt)
pNext = pReq->next;
if (CompareTimeStamps(pReq->revive, now) == LATER)
break;
- FreeResource(pReq->id, RT_NONE);
+ FreeResource(pReq->id, X11_RESTYPE_NONE);
/* AttendClient() may have been called via the resource delete
* function so a client may have input to be processed and so
@@ -195,7 +195,7 @@ SertafiedWakeupHandler(void *data, int i)
pNext = pReq->next;
if (CompareTimeStamps(pReq->revive, now) == LATER)
break;
- FreeResource(pReq->id, RT_NONE);
+ FreeResource(pReq->id, X11_RESTYPE_NONE);
}
if (!pPending) {
RemoveBlockAndWakeupHandlers(SertafiedBlockHandler,
diff --git a/Xext/sync.c b/Xext/sync.c
index fd2ceb042..950951e74 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -54,10 +54,14 @@ PERFORMANCE OF THIS SOFTWARE.
#endif
#include <string.h>
-
+#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xmd.h>
+#include <X11/extensions/syncproto.h>
+
+#include "dix/dix_priv.h"
+
#include "scrnintstr.h"
#include "os.h"
#include "extnsionst.h"
@@ -65,13 +69,12 @@ PERFORMANCE OF THIS SOFTWARE.
#include "pixmapstr.h"
#include "resource.h"
#include "opaque.h"
-#include <X11/extensions/syncproto.h>
#include "syncsrv.h"
#include "syncsdk.h"
#include "protocol-versions.h"
#include "inputstr.h"
+#include "misync_priv.h"
-#include <stdio.h>
#if !defined(WIN32)
#include <sys/time.h>
#endif
@@ -693,7 +696,7 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
/* unblock the client */
AttendClient(pAwaitUnion->header.client);
/* delete the await */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE);
}
static int64_t
@@ -748,7 +751,7 @@ SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
* nothing, since it's already got them.
*/
if (!wantevents) {
- FreeResource(pClients->delete_id, RT_NONE);
+ FreeResource(pClients->delete_id, X11_RESTYPE_NONE);
}
return Success;
}
@@ -931,7 +934,7 @@ SyncCreateFenceFromFD(ClientPtr client, DrawablePtr pDraw, XID id, int fd, BOOL
status = miSyncInitFenceFromFD(pDraw, pFence, fd, initially_triggered);
if (status != Success) {
- FreeResource(pFence->sync.id, RT_NONE);
+ FreeResource(pFence->sync.id, X11_RESTYPE_NONE);
return status;
}
@@ -989,7 +992,7 @@ SyncCreateSystemCounter(const char *name,
psci = malloc(sizeof(SysCounterInfo));
if (!psci) {
- FreeResource(pCounter->sync.id, RT_NONE);
+ FreeResource(pCounter->sync.id, X11_RESTYPE_NONE);
return pCounter;
}
pCounter->pSysCounterInfo = psci;
@@ -1012,7 +1015,7 @@ SyncDestroySystemCounter(void *pSysCounter)
{
SyncCounter *pCounter = (SyncCounter *) pSysCounter;
- FreeResource(pCounter->sync.id, RT_NONE);
+ FreeResource(pCounter->sync.id, X11_RESTYPE_NONE);
}
static void
@@ -1125,7 +1128,7 @@ FreeAlarm(void *addr, XID id)
/* delete event selections */
while (pAlarm->pEventClients)
- FreeResource(pAlarm->pEventClients->delete_id, RT_NONE);
+ FreeResource(pAlarm->pEventClients->delete_id, X11_RESTYPE_NONE);
SyncDeleteTriggerFromSyncObject(&pAlarm->trigger);
@@ -1490,7 +1493,7 @@ ProcSyncDestroyCounter(ClientPtr client)
client->errorValue = stuff->counter;
return BadAccess;
}
- FreeResource(pCounter->sync.id, RT_NONE);
+ FreeResource(pCounter->sync.id, X11_RESTYPE_NONE);
return Success;
}
@@ -1591,7 +1594,7 @@ ProcSyncAwait(ClientPtr client)
/* this should take care of removing any triggers created by
* this request that have already been registered on sync objects
*/
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE);
client->errorValue = pProtocolWaitConds->counter;
return SyncErrorBase + XSyncBadCounter;
}
@@ -1611,7 +1614,7 @@ ProcSyncAwait(ClientPtr client)
/* this should take care of removing any triggers created by
* this request that have already been registered on sync objects
*/
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE);
return status;
}
/* this is not a mistake -- same function works for both cases */
@@ -1742,7 +1745,7 @@ ProcSyncCreateAlarm(ClientPtr client)
if (!SyncCheckWarnIsCounter(pTrigger->pSync,
WARN_INVALID_COUNTER_ALARM)) {
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
return BadAlloc;
}
@@ -1873,7 +1876,7 @@ ProcSyncDestroyAlarm(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->alarm, RT_NONE);
+ FreeResource(stuff->alarm, X11_RESTYPE_NONE);
return Success;
}
@@ -1978,7 +1981,7 @@ ProcSyncDestroyFence(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->fid, RT_NONE);
+ FreeResource(stuff->fid, X11_RESTYPE_NONE);
return Success;
}
@@ -2056,7 +2059,7 @@ ProcSyncAwaitFence(ClientPtr client)
/* this should take care of removing any triggers created by
* this request that have already been registered on sync objects
*/
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE);
client->errorValue = *pProtocolFences;
return SyncErrorBase + XSyncBadFence;
}
@@ -2075,7 +2078,7 @@ ProcSyncAwaitFence(ClientPtr client)
/* this should take care of removing any triggers created by
* this request that have already been registered on sync objects
*/
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE);
return status;
}
/* this is not a mistake -- same function works for both cases */
@@ -2318,6 +2321,7 @@ SProcSyncCreateFence(ClientPtr client)
REQUEST(xSyncCreateFenceReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
+ swapl(&stuff->d);
swapl(&stuff->fid);
return ProcSyncCreateFence(client);
diff --git a/Xext/xace.c b/Xext/xace.c
index f8f8d139b..580566a5d 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "gcstruct.h"
#include "xacestr.h"
-_X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = { 0 };
+CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = { 0 };
/* Special-cased hook functions. Called by Xserver.
*/
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index 529595bb7..44a8e7dd8 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -39,7 +39,7 @@
#endif
#include <sys/types.h>
-#ifdef HAS_SHM
+#ifdef MITSHM
#ifdef SVR4
#include <sys/sysmacros.h>
#endif
@@ -73,7 +73,7 @@
static void XF86BigfontResetProc(ExtensionEntry * /* extEntry */
);
-#ifdef HAS_SHM
+#ifdef MITSHM
/* A random signature, transmitted to the clients so they can verify that the
shared memory segment they are attaching to was really established by the
@@ -126,7 +126,7 @@ CheckForShmSyscall(void)
/* ========== Management of shared memory segments ========== */
-#ifdef HAS_SHM
+#ifdef MITSHM
#ifdef __linux__
/* On Linux, shared memory marked as "removed" can still be attached.
@@ -221,7 +221,7 @@ shmdealloc(ShmDescPtr pDesc)
void
XF86BigfontFreeFontShm(FontPtr pFont)
{
-#ifdef HAS_SHM
+#ifdef MITSHM
ShmDescPtr pDesc;
/* If during shutdown of the server, XF86BigfontCleanup() has already
@@ -240,7 +240,7 @@ XF86BigfontFreeFontShm(FontPtr pFont)
void
XF86BigfontCleanup(void)
{
-#ifdef HAS_SHM
+#ifdef MITSHM
while (ShmList)
shmdealloc(ShmList);
#endif
@@ -277,7 +277,7 @@ ProcXF86BigfontQueryVersion(ClientPtr client)
.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION,
.uid = geteuid(),
.gid = getegid(),
-#ifdef HAS_SHM
+#ifdef MITSHM
.signature = signature,
.capabilities = (client->local && !client->swapped)
? XF86Bigfont_CAP_LocalShm : 0
@@ -329,7 +329,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
int nCharInfos;
int shmid;
-#ifdef HAS_SHM
+#ifdef MITSHM
ShmDescPtr pDesc = NULL;
#else
#define pDesc 0
@@ -374,7 +374,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
nUniqCharInfos = 0;
if (nCharInfos > 0) {
-#ifdef HAS_SHM
+#ifdef MITSHM
if (!badSysCall)
pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
if (pDesc) {
@@ -395,7 +395,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
pCI = xallocarray(nCharInfos, sizeof(xCharInfo));
if (!pCI)
return BadAlloc;
-#ifdef HAS_SHM
+#ifdef MITSHM
}
#endif
/* Fill nCharInfos starting at pCI. */
@@ -427,7 +427,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
}
}
}
-#ifdef HAS_SHM
+#ifdef MITSHM
if (pDesc && !badSysCall) {
*(CARD32 *) (pCI + nCharInfos) = signature;
if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) {
@@ -694,7 +694,7 @@ XFree86BigfontExtensionInit(void)
ProcXF86BigfontDispatch,
SProcXF86BigfontDispatch,
XF86BigfontResetProc, StandardMinorOpcode)) {
-#ifdef HAS_SHM
+#ifdef MITSHM
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
/*
* Note: Local-clients will not be optimized without shared memory
diff --git a/Xext/xres.c b/Xext/xres.c
index 354329802..96c1844fd 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -11,12 +11,14 @@
#include <X11/X.h>
#include <X11/Xproto.h>
#include <assert.h>
+
+#include "dix/registry_priv.h"
+
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "swaprep.h"
-#include "registry.h"
#include <X11/extensions/XResproto.h>
#include "pixmapstr.h"
#include "windowstr.h"
diff --git a/Xext/xselinux.h b/Xext/xselinux.h
index 5be7088c8..52e720fd7 100644
--- a/Xext/xselinux.h
+++ b/Xext/xselinux.h
@@ -136,4 +136,12 @@ typedef struct {
CARD32 pad6;
} SELinuxListItemsReply;
+#ifdef XSELINUX
+#define SELINUX_MODE_DEFAULT 0
+#define SELINUX_MODE_DISABLED 1
+#define SELINUX_MODE_PERMISSIVE 2
+#define SELINUX_MODE_ENFORCING 3
+extern int selinuxEnforcingState;
+#endif
+
#endif /* _XSELINUX_H */
diff --git a/Xext/xselinux_ext.c b/Xext/xselinux_ext.c
index 99501eeef..c7ce19c49 100644
--- a/Xext/xselinux_ext.c
+++ b/Xext/xselinux_ext.c
@@ -21,6 +21,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "selection.h"
#include "inputstr.h"
#include "windowstr.h"
@@ -44,6 +46,9 @@ typedef struct {
CARD32 id;
} SELinuxListItemRec;
+Bool noSELinuxExtension = FALSE;
+int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
+
/*
* Extension Dispatch
*/
diff --git a/Xext/xselinux_hooks.c b/Xext/xselinux_hooks.c
index 57b24e452..63fc18f93 100644
--- a/Xext/xselinux_hooks.c
+++ b/Xext/xselinux_hooks.c
@@ -26,13 +26,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <dix-config.h>
#endif
+#include <errno.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdarg.h>
-
#include <libaudit.h>
-
#include <X11/Xatom.h>
+
+#include "dix/registry_priv.h"
+
#include "selection.h"
#include "inputstr.h"
#include "scrnintstr.h"
@@ -199,7 +201,7 @@ SELinuxLabelInitial(void)
/* Do the default colormap */
dixLookupResourceByType(&unused, screenInfo.screens[i]->defColormap,
- RT_COLORMAP, serverClient, DixCreateAccess);
+ X11_RESTYPE_COLORMAP, serverClient, DixCreateAccess);
}
}
@@ -662,7 +664,7 @@ SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
rec->status = rc;
/* Perform the background none check on windows */
- if (access_mode & DixCreateAccess && rec->rtype == RT_WINDOW) {
+ if (access_mode & DixCreateAccess && rec->rtype == X11_RESTYPE_WINDOW) {
rc = SELinuxDoCheck(subj, obj, class, DixBlendAccess, &auditdata);
if (rc != Success)
((WindowPtr) rec->res)->forcedBG = TRUE;
@@ -764,7 +766,7 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxObjectRec *obj;
WindowPtr pWin;
- if (rec->type != RT_WINDOW)
+ if (rec->type != X11_RESTYPE_WINDOW)
return;
if (rec->state != ResourceStateAdding)
return;
diff --git a/Xext/xselinux_label.c b/Xext/xselinux_label.c
index 48414d88a..08159ff0b 100644
--- a/Xext/xselinux_label.c
+++ b/Xext/xselinux_label.c
@@ -23,7 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <selinux/label.h>
-#include "registry.h"
+#include "dix/registry_priv.h"
+
#include "xselinuxint.h"
/* selection and property atom cache */
@@ -322,13 +323,13 @@ SELinuxTypeToClass(RESTYPE type)
if (type & RC_DRAWABLE)
class = SECCLASS_X_DRAWABLE;
- else if (type == RT_GC)
+ else if (type == X11_RESTYPE_GC)
class = SECCLASS_X_GC;
- else if (type == RT_FONT)
+ else if (type == X11_RESTYPE_FONT)
class = SECCLASS_X_FONT;
- else if (type == RT_CURSOR)
+ else if (type == X11_RESTYPE_CURSOR)
class = SECCLASS_X_CURSOR;
- else if (type == RT_COLORMAP)
+ else if (type == X11_RESTYPE_COLORMAP)
class = SECCLASS_X_COLORMAP;
else {
/* Need to do a string lookup */
diff --git a/Xext/xselinuxint.h b/Xext/xselinuxint.h
index 5a5874075..dddae86e2 100644
--- a/Xext/xselinuxint.h
+++ b/Xext/xselinuxint.h
@@ -28,7 +28,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dixstruct.h"
#include "privates.h"
#include "resource.h"
-#include "registry.h"
#include "inputstr.h"
#include "xselinux.h"
diff --git a/Xext/xtest.c b/Xext/xtest.c
index bf27eb590..96f898656 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -33,6 +33,13 @@
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xatom.h>
+#include <X11/extensions/xtestproto.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+
+#include "dix/dix_priv.h"
+#include "os/osdep.h"
+
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
@@ -45,16 +52,12 @@
#include "mi.h"
#include "xkbsrv.h"
#include "xkbstr.h"
-#include <X11/extensions/xtestproto.h>
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
#include "exglobals.h"
#include "mipointer.h"
#include "xserver-properties.h"
#include "exevents.h"
#include "eventstr.h"
#include "inpututils.h"
-
#include "extinit.h"
/* XTest events are sent during request processing and may be interrupted by
@@ -129,7 +132,7 @@ ProcXTestCompareCursor(ClientPtr client)
pCursor = GetSpriteCursor(ptr);
else {
rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor,
- RT_CURSOR, client, DixReadAccess);
+ X11_RESTYPE_CURSOR, client, DixReadAccess);
if (rc != Success) {
client->errorValue = stuff->cursor;
return rc;
@@ -148,6 +151,35 @@ ProcXTestCompareCursor(ClientPtr client)
return Success;
}
+void
+XTestDeviceSendEvents(DeviceIntPtr dev,
+ int type,
+ int detail,
+ int flags,
+ const ValuatorMask *mask)
+{
+ int nevents = 0;
+ int i;
+
+ switch (type) {
+ case MotionNotify:
+ nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, mask);
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ nevents = GetPointerEvents(xtest_evlist, dev, type, detail, flags, mask);
+ break;
+ case KeyPress:
+ case KeyRelease:
+ nevents =
+ GetKeyboardEvents(xtest_evlist, dev, type, detail);
+ break;
+ }
+
+ for (i = 0; i < nevents; i++)
+ mieqProcessDeviceEvent(dev, &xtest_evlist[i], miPointerGetScreen(inputInfo.pointer));
+}
+
static int
ProcXTestFakeInput(ClientPtr client)
{
@@ -161,8 +193,6 @@ ProcXTestFakeInput(ClientPtr client)
int valuators[MAX_VALUATORS] = { 0 };
int numValuators = 0;
int firstValuator = 0;
- int nevents = 0;
- int i;
int base = 0;
int flags = 0;
int need_ptr_update = 1;
@@ -408,26 +438,10 @@ ProcXTestFakeInput(ClientPtr client)
if (screenIsSaved == SCREEN_SAVER_ON)
dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
- switch (type) {
- case MotionNotify:
- valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
- nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, &mask);
- break;
- case ButtonPress:
- case ButtonRelease:
- valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
- nevents = GetPointerEvents(xtest_evlist, dev, type, ev->u.u.detail,
- flags, &mask);
- break;
- case KeyPress:
- case KeyRelease:
- nevents =
- GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail);
- break;
- }
+ valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
- for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(dev, &xtest_evlist[i], miPointerGetScreen(inputInfo.pointer));
+ if (dev->sendEventsProc)
+ (*dev->sendEventsProc) (dev, type, ev->u.u.detail, flags, &mask);
if (need_ptr_update)
miPointerUpdateSprite(dev);
@@ -502,10 +516,11 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
+ int evtype = ev->u.u.type & 0177;
/* Swap event */
- proc = EventSwapVector[ev->u.u.type & 0177];
+ proc = EventSwapVector[evtype];
/* no swapping proc; invalid event type? */
- if (!proc || proc == NotImplemented) {
+ if (!proc || proc == NotImplemented || evtype == GenericEvent) {
client->errorValue = ev->u.u.type;
return BadValue;
}
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index 5232b37d6..eb80561b7 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -29,6 +29,11 @@ SOFTWARE.
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "scrnintstr.h"
#include "windowstr.h"
@@ -37,9 +42,6 @@ SOFTWARE.
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
-
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/Xvproto.h>
#include "xvdix.h"
#ifdef MITSHM
#include <X11/extensions/shmproto.h>
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index f62747193..2a08f8744 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -811,8 +811,10 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
tpn = pn;
while (tpn) {
if (tpn->client == client) {
- if (!onoff)
+ if (!onoff) {
tpn->client = NULL;
+ FreeResource(tpn->id, XvRTVideoNotify);
+ }
return Success;
}
if (!tpn->client)
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index c7338b766..a1fb6238b 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -290,7 +290,7 @@ ProcXvMCDestroyContext(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->context_id, RT_NONE);
+ FreeResource(stuff->context_id, X11_RESTYPE_NONE);
return Success;
}
@@ -368,7 +368,7 @@ ProcXvMCDestroySurface(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->surface_id, RT_NONE);
+ FreeResource(stuff->surface_id, X11_RESTYPE_NONE);
return Success;
}
@@ -496,7 +496,7 @@ ProcXvMCDestroySubpicture(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->subpicture_id, RT_NONE);
+ FreeResource(stuff->subpicture_id, X11_RESTYPE_NONE);
return Success;
}
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index 1d72770f1..892ac4a23 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -54,14 +54,15 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+#include "dix/dix_priv.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h"
#include "exevents.h"
#include "exglobals.h"
-
#include "chgprop.h"
#include "grabdev.h"
diff --git a/Xi/closedev.c b/Xi/closedev.c
index f68b5231a..af60d7e99 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -102,7 +102,7 @@ DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
next = grab->next;
if ((grab->device == dev) &&
(client->clientAsMask == CLIENT_BITS(grab->resource)))
- FreeResource(grab->resource, RT_NONE);
+ FreeResource(grab->resource, X11_RESTYPE_NONE);
}
}
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 217baa956..7ef0f2df6 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -82,13 +82,18 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include "inputstr.h"
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include <X11/extensions/XI2proto.h>
#include <X11/extensions/geproto.h>
+#include <X11/extensions/XKBproto.h>
+
+#include "dix/dix_priv.h"
+#include "dix/eventconvert.h"
+
+#include "inputstr.h"
#include "windowstr.h"
#include "miscstruct.h"
#include "region.h"
@@ -102,12 +107,9 @@ SOFTWARE.
#include "listdev.h" /* for CopySwapXXXClass */
#include "xace.h"
#include "xiquerydevice.h" /* For List*Info */
-#include "eventconvert.h"
#include "eventstr.h"
#include "inpututils.h"
#include "mi.h"
-
-#include <X11/extensions/XKBproto.h>
#include "xkbsrv.h"
#define WID(w) ((w) ? ((w)->drawable.id) : 0)
@@ -605,22 +607,25 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
to->button = calloc(1, sizeof(ButtonClassRec));
if (!to->button)
FatalError("[Xi] no memory for class shift.\n");
+ to->button->numButtons = from->button->numButtons;
}
else
classes->button = NULL;
}
if (from->button->xkb_acts) {
- if (!to->button->xkb_acts) {
- to->button->xkb_acts = calloc(1, sizeof(XkbAction));
- if (!to->button->xkb_acts)
- FatalError("[Xi] not enough memory for xkb_acts.\n");
- }
+ size_t maxbuttons = max(to->button->numButtons, from->button->numButtons);
+ to->button->xkb_acts = xnfreallocarray(to->button->xkb_acts,
+ maxbuttons,
+ sizeof(XkbAction));
+ memset(to->button->xkb_acts, 0, maxbuttons * sizeof(XkbAction));
memcpy(to->button->xkb_acts, from->button->xkb_acts,
- sizeof(XkbAction));
+ from->button->numButtons * sizeof(XkbAction));
}
- else
+ else {
free(to->button->xkb_acts);
+ to->button->xkb_acts = NULL;
+ }
memcpy(to->button->labels, from->button->labels,
from->button->numButtons * sizeof(Atom));
@@ -1533,7 +1538,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
l = &ti->listeners[ti->num_listeners - 1];
l->listener = g->resource;
l->grab = g;
- //l->resource_type = RT_NONE;
+ //l->resource_type = X11_RESTYPE_NONE;
if (devgrab->grabtype != XI2 || devgrab->type != XI_TouchBegin)
l->type = TOUCH_LISTENER_POINTER_GRAB;
@@ -2499,7 +2504,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
cursor = NullCursor;
else {
rc = dixLookupResourceByType((void **) &cursor, param->cursor,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (rc != Success) {
client->errorValue = param->cursor;
return rc;
@@ -2598,7 +2603,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type,
cursor = NullCursor;
else {
rc = dixLookupResourceByType((void **) &cursor, param->cursor,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (rc != Success) {
client->errorValue = param->cursor;
return rc;
@@ -2686,7 +2691,7 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
if (i == EMASKSIZE) {
RecalculateDeviceDeliverableEvents(pWin);
if (ShouldFreeInputMasks(pWin, FALSE))
- FreeResource(others->resource, RT_NONE);
+ FreeResource(others->resource, X11_RESTYPE_NONE);
return Success;
}
}
@@ -3113,7 +3118,7 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
ic = inputMasks->inputClients;
for (i = 0; i < EMASKSIZE; i++)
inputMasks->dontPropagateMask[i] = 0;
- FreeResource(ic->resource, RT_NONE);
+ FreeResource(ic->resource, X11_RESTYPE_NONE);
}
}
@@ -3236,7 +3241,7 @@ DeviceEventSuppressForWindow(WindowPtr pWin, ClientPtr client, Mask mask,
}
RecalculateDeviceDeliverableEvents(pWin);
if (ShouldFreeInputMasks(pWin, FALSE))
- FreeResource(inputMasks->inputClients->resource, RT_NONE);
+ FreeResource(inputMasks->inputClients->resource, X11_RESTYPE_NONE);
return Success;
}
diff --git a/Xi/getprop.c b/Xi/getprop.c
index b744f35cb..282831310 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -54,13 +54,15 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structs */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+
+#include "dix/dix_priv.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structs */
#include "exglobals.h"
#include "swaprep.h"
-
#include "getprop.h"
extern XExtEventInfo EventInfo[];
diff --git a/Xi/getselev.c b/Xi/getselev.c
index 0623c7ac4..b85eca3ff 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -56,11 +56,13 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+
+#include "dix/dix_priv.h"
+
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window struct */
#include "exglobals.h"
#include "swaprep.h"
-
#include "getprop.h"
#include "getselev.h"
diff --git a/Xi/selectev.c b/Xi/selectev.c
index 65c7bc868..6b7bdc512 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -54,11 +54,14 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/XIproto.h>
+
+#include "dix/dix_priv.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
#include "exevents.h"
#include "exglobals.h"
diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c
index 47b97d716..0f5c7913c 100644
--- a/Xi/ungrdevb.c
+++ b/Xi/ungrdevb.c
@@ -54,13 +54,15 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+
+#include "dix/dix_priv.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
#include "exglobals.h"
#include "dixgrabs.h"
-
#include "ungrdevb.h"
#define AllModifiersMask ( \
diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c
index 753b14d70..8aa797b4d 100644
--- a/Xi/ungrdevk.c
+++ b/Xi/ungrdevk.c
@@ -54,15 +54,17 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+
+#include "dix/dix_priv.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
#include "exglobals.h"
#include "dixgrabs.h"
#include "xkbsrv.h"
#include "xkbstr.h"
-
#include "ungrdevk.h"
#define AllModifiersMask ( \
diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index 676480157..ab83a19e7 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -33,13 +33,15 @@
#include <dix-config.h>
#endif
+#include <X11/extensions/XI2.h>
+#include <X11/extensions/XI2proto.h>
+
+#include "dix/dix_priv.h"
+
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "mi.h"
#include "eventstr.h"
-#include <X11/extensions/XI2.h>
-#include <X11/extensions/XI2proto.h>
-
#include "exglobals.h" /* BadDevice */
#include "exevents.h"
#include "xiallowev.h"
diff --git a/Xi/xibarriers.c b/Xi/xibarriers.c
index 1926762ad..da6964453 100644
--- a/Xi/xibarriers.c
+++ b/Xi/xibarriers.c
@@ -45,6 +45,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "xibarriers.h"
#include "scrnintstr.h"
#include "cursorstr.h"
@@ -829,7 +831,7 @@ XIDestroyPointerBarrier(ClientPtr client,
if (CLIENT_ID(stuff->barrier) != client->index)
return BadAccess;
- FreeResource(stuff->barrier, RT_NONE);
+ FreeResource(stuff->barrier, X11_RESTYPE_NONE);
return Success;
}
diff --git a/Xi/xichangecursor.c b/Xi/xichangecursor.c
index a9a1ac9fc..9f2a616d9 100644
--- a/Xi/xichangecursor.c
+++ b/Xi/xichangecursor.c
@@ -35,16 +35,18 @@
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XI2proto.h>
+
+#include "dix/dix_priv.h"
+
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XI2proto.h>
#include "extnsionst.h"
#include "exevents.h"
#include "exglobals.h"
#include "input.h"
-
#include "xichangecursor.h"
/***********************************************************************
@@ -97,7 +99,7 @@ ProcXIChangeCursor(ClientPtr client)
}
else {
rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (rc != Success)
return rc;
}
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index 504defe56..72d00451e 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -270,7 +270,7 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
- if (!IsMaster(newptr)) {
+ if (!IsMaster(newptr) || !IsPointerDevice(newptr)) {
client->errorValue = r->return_pointer;
rc = BadDevice;
goto unwind;
@@ -281,7 +281,7 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
- if (!IsMaster(newkeybd)) {
+ if (!IsMaster(newkeybd) || !IsKeyboardDevice(newkeybd)) {
client->errorValue = r->return_keyboard;
rc = BadDevice;
goto unwind;
@@ -416,6 +416,11 @@ ProcXIChangeHierarchy(ClientPtr client)
size_t len; /* length of data remaining in request */
int rc = Success;
int flags[MAXDEVICES] = { 0 };
+ enum {
+ NO_CHANGE,
+ FLUSH,
+ CHANGED,
+ } changes = NO_CHANGE;
REQUEST(xXIChangeHierarchyReq);
REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq);
@@ -465,8 +470,9 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = add_master(client, c, flags);
if (rc != Success)
goto unwind;
- }
+ changes = FLUSH;
break;
+ }
case XIRemoveMaster:
{
xXIRemoveMasterInfo *r = (xXIRemoveMasterInfo *) any;
@@ -475,8 +481,9 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = remove_master(client, r, flags);
if (rc != Success)
goto unwind;
- }
+ changes = FLUSH;
break;
+ }
case XIDetachSlave:
{
xXIDetachSlaveInfo *c = (xXIDetachSlaveInfo *) any;
@@ -485,8 +492,9 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = detach_slave(client, c, flags);
if (rc != Success)
goto unwind;
- }
+ changes = CHANGED;
break;
+ }
case XIAttachSlave:
{
xXIAttachSlaveInfo *c = (xXIAttachSlaveInfo *) any;
@@ -495,16 +503,25 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = attach_slave(client, c, flags);
if (rc != Success)
goto unwind;
+ changes = CHANGED;
+ break;
}
+ default:
break;
}
+ if (changes == FLUSH) {
+ XISendDeviceHierarchyEvent(flags);
+ memset(flags, 0, sizeof(flags));
+ changes = NO_CHANGE;
+ }
+
len -= any->length * 4;
any = (xXIAnyHierarchyChangeInfo *) ((char *) any + any->length * 4);
}
unwind:
-
- XISendDeviceHierarchyEvent(flags);
+ if (changes != NO_CHANGE)
+ XISendDeviceHierarchyEvent(flags);
return rc;
}
diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c
index c3d494d61..f63d6006e 100644
--- a/Xi/xigetclientpointer.c
+++ b/Xi/xigetclientpointer.c
@@ -29,16 +29,18 @@
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XI2proto.h>
+
+#include "dix/dix_priv.h"
+
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XI2proto.h>
#include "extnsionst.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
-
#include "xigetclientpointer.h"
/***********************************************************************
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 2769fb7c9..900a3e113 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -33,12 +33,14 @@
#include <dix-config.h>
#endif
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structure */
#include <X11/extensions/XI2.h>
#include <X11/extensions/XI2proto.h>
-#include "swaprep.h"
+#include "dix/dix_priv.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include "swaprep.h"
#include "exglobals.h" /* BadDevice */
#include "exevents.h"
#include "xipassivegrab.h"
@@ -93,6 +95,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
GrabParameters param;
void *tmp;
int mask_len;
+ uint32_t length;
REQUEST(xXIPassiveGrabDeviceReq);
REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
@@ -137,6 +140,12 @@ ProcXIPassiveGrabDevice(ClientPtr client)
return BadValue;
}
+ /* XI2 allows 32-bit keycodes but thanks to XKB we can never
+ * implement this. Just return an error for all keycodes that
+ * cannot work anyway, same for buttons > 255. */
+ if (stuff->detail > 255)
+ return XIAlreadyGrabbed;
+
if (XICheckInvalidMaskBits(client, (unsigned char *) &stuff[1],
stuff->mask_len * 4) != Success)
return BadValue;
@@ -166,7 +175,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
if (stuff->cursor != None) {
ret = dixLookupResourceByType(&tmp, stuff->cursor,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (ret != Success) {
client->errorValue = stuff->cursor;
goto out;
@@ -207,14 +216,8 @@ ProcXIPassiveGrabDevice(ClientPtr client)
&param, XI2, &mask);
break;
case XIGrabtypeKeycode:
- /* XI2 allows 32-bit keycodes but thanks to XKB we can never
- * implement this. Just return an error for all keycodes that
- * cannot work anyway */
- if (stuff->detail > 255)
- status = XIAlreadyGrabbed;
- else
- status = GrabKey(client, dev, mod_dev, stuff->detail,
- &param, XI2, &mask);
+ status = GrabKey(client, dev, mod_dev, stuff->detail,
+ &param, XI2, &mask);
break;
case XIGrabtypeEnter:
case XIGrabtypeFocusIn:
@@ -247,9 +250,11 @@ ProcXIPassiveGrabDevice(ClientPtr client)
}
}
+ /* save the value before SRepXIPassiveGrabDevice swaps it */
+ length = rep.length;
WriteReplyToClient(client, sizeof(rep), &rep);
if (rep.num_modifiers)
- WriteToClient(client, rep.length * 4, modifiers_failed);
+ WriteToClient(client, length * 4, modifiers_failed);
out:
free(modifiers_failed);
@@ -334,6 +339,12 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
return BadValue;
}
+ /* We don't allow passive grabs for details > 255 anyway */
+ if (stuff->detail > 255) {
+ client->errorValue = stuff->detail;
+ return BadValue;
+ }
+
rc = dixLookupWindow(&win, stuff->grab_window, client, DixSetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index a36f7d61d..9c44f9d3e 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -416,7 +416,7 @@ XIResetProperties(void)
* @param buf_return Pointer to an array of at least @nelem_return values.
* @return Success or the error code if an error occurred.
*/
-_X_EXPORT int
+int
XIPropToInt(XIPropertyValuePtr val, int *nelem_return, int **buf_return)
{
int i;
@@ -486,7 +486,7 @@ XIPropToInt(XIPropertyValuePtr val, int *nelem_return, int **buf_return)
* @param buf_return Pointer to an array of at least @nelem_return values.
* @return Success or the error code if an error occurred.
*/
-_X_EXPORT int
+int
XIPropToFloat(XIPropertyValuePtr val, int *nelem_return, float **buf_return)
{
int i;
@@ -730,7 +730,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
XIDestroyDeviceProperty(prop);
return BadAlloc;
}
- new_value.size = len;
+ new_value.size = total_len;
new_value.type = type;
new_value.format = format;
@@ -747,7 +747,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
case PropModePrepend:
new_data = new_value.data;
old_data = (void *) (((char *) new_value.data) +
- (prop_value->size * size_in_bytes));
+ (len * size_in_bytes));
break;
}
if (new_data)
@@ -890,7 +890,7 @@ ProcXChangeDeviceProperty(ClientPtr client)
REQUEST(xChangeDevicePropertyReq);
DeviceIntPtr dev;
unsigned long len;
- int totalSize;
+ uint64_t totalSize;
int rc;
REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
@@ -902,6 +902,8 @@ ProcXChangeDeviceProperty(ClientPtr client)
rc = check_change_property(client, stuff->property, stuff->type,
stuff->format, stuff->mode, stuff->nUnits);
+ if (rc != Success)
+ return rc;
len = stuff->nUnits;
if (len > (bytes_to_int32(0xffffffff - sizeof(xChangeDevicePropertyReq))))
@@ -1128,7 +1130,7 @@ ProcXIChangeProperty(ClientPtr client)
{
int rc;
DeviceIntPtr dev;
- int totalSize;
+ uint64_t totalSize;
unsigned long len;
REQUEST(xXIChangePropertyReq);
@@ -1141,6 +1143,9 @@ ProcXIChangeProperty(ClientPtr client)
rc = check_change_property(client, stuff->property, stuff->type,
stuff->format, stuff->mode, stuff->num_items);
+ if (rc != Success)
+ return rc;
+
len = stuff->num_items;
if (len > bytes_to_int32(0xffffffff - sizeof(xXIChangePropertyReq)))
return BadLength;
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 5b77b1a44..7da45fdc2 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -35,14 +35,17 @@
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2proto.h>
+
+#include "dix/dix_priv.h"
+#include "dix/eventconvert.h"
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
#include "extnsionst.h"
#include "exevents.h"
#include "exglobals.h"
-#include "eventconvert.h"
#include "scrnintstr.h"
#include "xkbsrv.h"
@@ -149,8 +152,7 @@ ProcXIQueryPointer(ClientPtr client)
if (pDev->button) {
int i;
- rep.buttons_len =
- bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
+ rep.buttons_len = bytes_to_int32(bits_to_bytes(256)); /* button map up to 255 */
rep.length += rep.buttons_len;
buttons = calloc(rep.buttons_len, 4);
if (!buttons)
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index edcb8a0d3..4d025b6e0 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -27,13 +27,15 @@
#include <dix-config.h>
#endif
+#include <X11/extensions/XI2proto.h>
+
+#include "dix/dix_priv.h"
+
#include "dixstruct.h"
#include "windowstr.h"
#include "exglobals.h"
#include "exevents.h"
-#include <X11/extensions/XI2proto.h>
#include "inpututils.h"
-
#include "xiselectev.h"
/**
@@ -349,6 +351,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
InputClientsPtr others = NULL;
xXIEventMask *evmask = NULL;
DeviceIntPtr dev;
+ uint32_t length;
REQUEST(xXIGetSelectedEventsReq);
REQUEST_SIZE_MATCH(xXIGetSelectedEventsReq);
@@ -418,10 +421,12 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
}
+ /* save the value before SRepXIGetSelectedEvents swaps it */
+ length = reply.length;
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &reply);
if (reply.num_masks)
- WriteToClient(client, reply.length * 4, buffer);
+ WriteToClient(client, length * 4, buffer);
free(buffer);
return Success;
diff --git a/Xi/xisetclientpointer.c b/Xi/xisetclientpointer.c
index e02eac4bc..a865c164c 100644
--- a/Xi/xisetclientpointer.c
+++ b/Xi/xisetclientpointer.c
@@ -36,6 +36,9 @@
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
+
+#include "dix/dix_priv.h"
+
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
@@ -44,7 +47,6 @@
#include "extnsionst.h"
#include "exevents.h"
#include "exglobals.h"
-
#include "xisetclientpointer.h"
int _X_COLD
diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c
index 955fdb965..1d8926935 100644
--- a/Xi/xiwarppointer.c
+++ b/Xi/xiwarppointer.c
@@ -35,17 +35,20 @@
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XI2proto.h>
+
+#include "dix/dix_priv.h"
+
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XI2proto.h>
#include "extnsionst.h"
#include "exevents.h"
#include "exglobals.h"
#include "mipointer.h" /* for miPointerUpdateSprite */
-
#include "xiwarppointer.h"
+
/***********************************************************************
*
* This procedure allows a client to warp the pointer of a device.
diff --git a/composite/compalloc.c b/composite/compalloc.c
index eaabf0d91..f97b6c688 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -217,7 +217,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
}
if (!compCheckRedirect(pWin)) {
- FreeResource(ccw->id, RT_NONE);
+ FreeResource(ccw->id, X11_RESTYPE_NONE);
return BadAlloc;
}
@@ -329,7 +329,7 @@ compUnredirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
for (ccw = cw->clients; ccw; ccw = ccw->next)
if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index) {
- FreeResource(ccw->id, RT_NONE);
+ FreeResource(ccw->id, X11_RESTYPE_NONE);
return Success;
}
return BadValue;
@@ -477,7 +477,7 @@ compUnredirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
return BadValue;
for (ccw = csw->clients; ccw; ccw = ccw->next)
if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index) {
- FreeResource(ccw->id, RT_NONE);
+ FreeResource(ccw->id, X11_RESTYPE_NONE);
return Success;
}
return BadValue;
diff --git a/composite/compext.c b/composite/compext.c
index 34a2a5363..cfdb7a216 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -130,7 +130,7 @@ ProcCompositeQueryVersion(ClientPtr client)
do { \
int err; \
err = dixLookupResourceByType((void **) &pWindow, wid, \
- RT_WINDOW, client, mode); \
+ X11_RESTYPE_WINDOW, client, mode);\
if (err != Success) { \
client->errorValue = wid; \
return err; \
@@ -252,20 +252,20 @@ ProcCompositeNameWindowPixmap(ClientPtr client)
return BadMatch;
/* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP,
- pPixmap, RT_WINDOW, pWin, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, X11_RESTYPE_PIXMAP,
+ pPixmap, X11_RESTYPE_WINDOW, pWin, DixCreateAccess);
if (rc != Success)
return rc;
++pPixmap->refcnt;
- if (!AddResource(stuff->pixmap, RT_PIXMAP, (void *) pPixmap))
+ if (!AddResource(stuff->pixmap, X11_RESTYPE_PIXMAP, (void *) pPixmap))
return BadAlloc;
if (pScreen->NameWindowPixmap) {
rc = pScreen->NameWindowPixmap(pWin, pPixmap, stuff->pixmap);
if (rc != Success) {
- FreeResource(stuff->pixmap, RT_NONE);
+ FreeResource(stuff->pixmap, X11_RESTYPE_NONE);
return rc;
}
}
@@ -302,14 +302,15 @@ ProcCompositeGetOverlayWindow(ClientPtr client)
cs = GetCompScreen(pScreen);
if (cs->pOverlayWin == NULL)
if (!compCreateOverlayWindow(pScreen)) {
- FreeResource(pOc->resource, RT_NONE);
+ FreeResource(pOc->resource, X11_RESTYPE_NONE);
return BadAlloc;
}
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
- RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
+ X11_RESTYPE_WINDOW, cs->pOverlayWin, X11_RESTYPE_NONE,
+ NULL, DixGetAttrAccess);
if (rc != Success) {
- FreeResource(pOc->resource, RT_NONE);
+ FreeResource(pOc->resource, X11_RESTYPE_NONE);
return rc;
}
@@ -349,7 +350,7 @@ ProcCompositeReleaseOverlayWindow(ClientPtr client)
return BadMatch;
/* The delete function will free the client structure */
- FreeResource(pOc->resource, RT_NONE);
+ FreeResource(pOc->resource, X11_RESTYPE_NONE);
return Success;
}
@@ -515,7 +516,7 @@ GetCompositeWindowBytes(void *value, XID id, ResourceSizePtr size)
/* account for redirection */
if (window->redirectDraw != RedirectDrawNone)
{
- SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+ SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(X11_RESTYPE_PIXMAP);
ResourceSizeRec pixmapSize = { 0, 0 };
ScreenPtr screen = window->drawable.pScreen;
PixmapPtr pixmap = screen->GetWindowPixmap(window);
@@ -556,8 +557,8 @@ CompositeExtensionInit(void)
if (!CompositeClientWindowType)
return;
- coreGetWindowBytes = GetResourceTypeSizeFunc(RT_WINDOW);
- SetResourceTypeSizeFunc(RT_WINDOW, GetCompositeWindowBytes);
+ coreGetWindowBytes = GetResourceTypeSizeFunc(X11_RESTYPE_WINDOW);
+ SetResourceTypeSizeFunc(X11_RESTYPE_WINDOW, GetCompositeWindowBytes);
CompositeClientSubwindowsType = CreateNewResourceType
(FreeCompositeClientSubwindows, "CompositeClientSubwindows");
@@ -728,7 +729,8 @@ PanoramiXCompositeNameWindowPixmap(ClientPtr client)
FOR_NSCREENS(i) {
rc = dixLookupResourceByType((void **) &pWin, win->info[i].id,
- RT_WINDOW, client, DixGetAttrAccess);
+ X11_RESTYPE_WINDOW, client,
+ DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
free(newPix);
@@ -752,7 +754,7 @@ PanoramiXCompositeNameWindowPixmap(ClientPtr client)
return BadMatch;
}
- if (!AddResource(newPix->info[i].id, RT_PIXMAP, (void *) pPixmap))
+ if (!AddResource(newPix->info[i].id, X11_RESTYPE_PIXMAP, (void *) pPixmap))
return BadAlloc;
++pPixmap->refcnt;
@@ -796,7 +798,8 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
FOR_NSCREENS_BACKWARD(i) {
rc = dixLookupResourceByType((void **) &pWin, win->info[i].id,
- RT_WINDOW, client, DixGetAttrAccess);
+ X11_RESTYPE_WINDOW, client,
+ DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
free(overlayWin);
@@ -820,17 +823,17 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
cs = GetCompScreen(pScreen);
if (cs->pOverlayWin == NULL)
if (!compCreateOverlayWindow(pScreen)) {
- FreeResource(pOc->resource, RT_NONE);
+ FreeResource(pOc->resource, X11_RESTYPE_NONE);
free(overlayWin);
return BadAlloc;
}
rc = XaceHook(XACE_RESOURCE_ACCESS, client,
cs->pOverlayWin->drawable.id,
- RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL,
+ X11_RESTYPE_WINDOW, cs->pOverlayWin, X11_RESTYPE_NONE, NULL,
DixGetAttrAccess);
if (rc != Success) {
- FreeResource(pOc->resource, RT_NONE);
+ FreeResource(pOc->resource, X11_RESTYPE_NONE);
free(overlayWin);
return rc;
}
@@ -898,7 +901,7 @@ PanoramiXCompositeReleaseOverlayWindow(ClientPtr client)
return BadMatch;
/* The delete function will free the client structure */
- FreeResource(pOc->resource, RT_NONE);
+ FreeResource(pOc->resource, X11_RESTYPE_NONE);
}
return Success;
diff --git a/composite/compinit.c b/composite/compinit.c
index a62c8d3c4..7e324afdc 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -59,6 +59,7 @@ compCloseScreen(ScreenPtr pScreen)
Bool ret;
free(cs->alternateVisuals);
+ free(cs->implicitRedirectExceptions);
pScreen->CloseScreen = cs->CloseScreen;
pScreen->InstallColormap = cs->InstallColormap;
diff --git a/composite/compint.h b/composite/compint.h
index 423b641ff..cb73c386d 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/composite/compositeext.h b/composite/compositeext.h
index 5aad0735e..24f4edac3 100644
--- a/composite/compositeext.h
+++ b/composite/compositeext.h
@@ -41,6 +41,7 @@ extern _X_EXPORT Bool CompositeRegisterImplicitRedirectionException(ScreenPtr pS
extern _X_EXPORT Bool compIsAlternateVisual(ScreenPtr pScreen, XID visual);
+
extern _X_EXPORT RESTYPE CompositeClientWindowType;
#endif /* _COMPOSITEEXT_H_ */
diff --git a/composite/compositeext_priv.h b/composite/compositeext_priv.h
new file mode 100644
index 000000000..c969269ba
--- /dev/null
+++ b/composite/compositeext_priv.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 1987, 1998 The Open Group
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_COMPOSITEEXT_PRIV_H_
+#define _XSERVER_COMPOSITEEXT_PRIV_H_
+
+#include <X11/X.h>
+
+#include "screenint.h"
+
+Bool CompositeIsImplicitRedirectException(ScreenPtr pScreen,
+ XID parentVisual,
+ XID winVisual);
+
+#endif /* _XSERVER_COMPOSITEEXT_PRIV_H_ */
diff --git a/composite/compoverlay.c b/composite/compoverlay.c
index 20c860d5f..18538ed98 100644
--- a/composite/compoverlay.c
+++ b/composite/compoverlay.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -152,7 +152,7 @@ compCreateOverlayWindow(ScreenPtr pScreen)
if (pWin == NULL)
return FALSE;
- if (!AddResource(pWin->drawable.id, RT_WINDOW, (void *) pWin))
+ if (!AddResource(pWin->drawable.id, X11_RESTYPE_WINDOW, (void *) pWin))
return FALSE;
MapWindow(pWin, serverClient);
@@ -169,5 +169,5 @@ compDestroyOverlayWindow(ScreenPtr pScreen)
CompScreenPtr cs = GetCompScreen(pScreen);
cs->pOverlayWin = NullWindow;
- FreeResource(cs->overlayWid, RT_NONE);
+ FreeResource(cs->overlayWid, X11_RESTYPE_NONE);
}
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 73a1871a0..3d62358b9 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -45,7 +45,11 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+#include "os/osdep.h"
+
#include "compint.h"
+#include "compositeext_priv.h"
#ifdef PANORAMIX
#include "panoramiXsrv.h"
@@ -339,9 +343,9 @@ compIsAlternateVisual(ScreenPtr pScreen, XID visual)
return FALSE;
}
-static Bool
-compIsImplicitRedirectException(ScreenPtr pScreen,
- XID parentVisual, XID winVisual)
+Bool
+CompositeIsImplicitRedirectException(ScreenPtr pScreen,
+ XID parentVisual, XID winVisual)
{
CompScreenPtr cs = GetCompScreen(pScreen);
int i;
@@ -362,7 +366,7 @@ compImplicitRedirect(WindowPtr pWin, WindowPtr pParent)
XID winVisual = wVisual(pWin);
XID parentVisual = wVisual(pParent);
- if (compIsImplicitRedirectException(pScreen, parentVisual, winVisual))
+ if (CompositeIsImplicitRedirectException(pScreen, parentVisual, winVisual))
return FALSE;
if (winVisual != parentVisual &&
@@ -607,9 +611,9 @@ compDestroyWindow(WindowPtr pWin)
pScreen->DestroyWindow = cs->DestroyWindow;
while ((cw = GetCompWindow(pWin)))
- FreeResource(cw->clients->id, RT_NONE);
+ FreeResource(cw->clients->id, X11_RESTYPE_NONE);
while ((csw = GetCompSubwindows(pWin)))
- FreeResource(csw->clients->id, RT_NONE);
+ FreeResource(csw->clients->id, X11_RESTYPE_NONE);
if (pWin->redirectDraw != RedirectDrawNone) {
PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
@@ -620,6 +624,11 @@ compDestroyWindow(WindowPtr pWin)
ret = (*pScreen->DestroyWindow) (pWin);
cs->DestroyWindow = pScreen->DestroyWindow;
pScreen->DestroyWindow = compDestroyWindow;
+
+ /* Did we just destroy the overlay window? */
+ if (pWin == cs->pOverlayWin)
+ cs->pOverlayWin = NULL;
+
/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
return ret;
}
diff --git a/config/10-quirks.conf b/config/10-quirks.conf
index 47907d82d..54dd908a7 100644
--- a/config/10-quirks.conf
+++ b/config/10-quirks.conf
@@ -36,3 +36,13 @@ Section "InputClass"
MatchDriver "evdev"
Option "TypeName" "MOUSE"
EndSection
+
+# https://bugzilla.redhat.com/show_bug.cgi?id=2152414
+# Xorg server does not correctly select the DCP for the display without
+# a quirk on Apple Silicon
+Section "OutputClass"
+ Identifier "appledrm"
+ MatchDriver "apple"
+ Driver "modesetting"
+ Option "PrimaryGPU" "true"
+EndSection
diff --git a/config/dbus-core.c b/config/dbus-core.c
index 6d9a3f917..180ca9364 100644
--- a/config/dbus-core.c
+++ b/config/dbus-core.c
@@ -32,7 +32,8 @@
#include "dix.h"
#include "os.h"
-#include "dbus-core.h"
+
+#include "config/dbus-core.h"
/* How often to attempt reconnecting when we get booted off the bus. */
#define RECONNECT_DELAY (10 * 1000) /* in ms */
diff --git a/include/dbus-core.h b/config/dbus-core.h
index d6260dc66..d6260dc66 100644
--- a/include/dbus-core.h
+++ b/config/dbus-core.h
diff --git a/config/hal.c b/config/hal.c
index e33e3330b..7e0e88498 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -33,7 +33,8 @@
#include <string.h>
#include <sys/select.h>
-#include "dbus-core.h"
+#include "config/dbus-core.h"
+
#include "input.h"
#include "inputstr.h"
#include "hotplug.h"
diff --git a/config/wscons.c b/config/wscons.c
index e9368be6a..a7beb85a4 100644
--- a/config/wscons.c
+++ b/config/wscons.c
@@ -25,6 +25,7 @@
#include <dix-config.h>
#endif
+#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsksymdef.h>
@@ -52,7 +53,7 @@
struct nameint {
int val;
- char *name;
+ const char *name;
} kbdenc[] = {
KB_OVRENC,
KB_ENCTAB
@@ -125,8 +126,7 @@ wscons_add_keyboard(void)
input_options = input_option_new(input_options, "name", WSCONS_KBD_DEVICE);
input_options = input_option_new(input_options, "driver", "kbd");
- config_info = Xprintf("wscons:%s", WSCONS_KBD_DEVICE);
- if (!config_info)
+ if (asprintf(&config_info, "wscons:%s", WSCONS_KBD_DEVICE) == -1)
goto unwind;
if (KB_ENCODING(wsenc) == KB_USER) {
/* Ignore wscons "user" layout */
@@ -189,8 +189,7 @@ wscons_add_pointer(const char *path, const char *driver, int flags)
char *config_info = NULL;
int rc;
- config_info = Xprintf("wscons:%s", path);
- if (!config_info)
+ if (asprintf(&config_info, "wscons:%s", path) == -1)
return;
input_options = input_option_new(input_options, "_source", "server/wscons");
diff --git a/damageext/damageext.c b/damageext/damageext.c
index c8194da07..fd6fcc87e 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -25,6 +25,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "damageextint.h"
#include "damagestr.h"
#include "protocol-versions.h"
@@ -161,7 +163,7 @@ DamageExtDestroy(DamagePtr pDamage, void *closure)
pDamageExt->pDamage = 0;
if (pDamageExt->id)
- FreeResource(pDamageExt->id, RT_NONE);
+ FreeResource(pDamageExt->id, X11_RESTYPE_NONE);
}
void
@@ -314,7 +316,7 @@ ProcDamageDestroy(ClientPtr client)
REQUEST_SIZE_MATCH(xDamageDestroyReq);
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess);
- FreeResource(stuff->damage, RT_NONE);
+ FreeResource(stuff->damage, X11_RESTYPE_NONE);
return Success;
}
@@ -683,7 +685,7 @@ PanoramiXDamageCreate(ClientPtr client)
}
if (rc != Success)
- FreeResource(stuff->damage, RT_NONE);
+ FreeResource(stuff->damage, X11_RESTYPE_NONE);
return rc;
}
diff --git a/dbe/dbe.c b/dbe/dbe.c
index cdab3e9e5..3cf0a3ef9 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -40,12 +40,14 @@
#include <stdint.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+
#include "scrnintstr.h"
#include "extnsionst.h"
#include "extinit.h"
#include "gcstruct.h"
#include "dixstruct.h"
-#define NEED_DBE_PROTOCOL
#include "dbestruct.h"
#include "midbe.h"
#include "xace.h"
@@ -411,7 +413,7 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
return dbeErrorBase + DbeBadBuffer;
}
- FreeResource(stuff->buffer, RT_NONE);
+ FreeResource(stuff->buffer, X11_RESTYPE_NONE);
return Success;
@@ -1312,7 +1314,7 @@ DbeDestroyWindow(WindowPtr pWin)
* NULL if there are no more buffer IDs associated with this
* window.
*/
- FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
+ FreeResource(pDbeWindowPriv->IDs[0], X11_RESTYPE_NONE);
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
}
}
diff --git a/dbe/dbestruct.h b/dbe/dbestruct.h
index ce99fbea8..ef08118c0 100644
--- a/dbe/dbestruct.h
+++ b/dbe/dbestruct.h
@@ -35,7 +35,6 @@
/* INCLUDES */
-#define NEED_DBE_PROTOCOL
#include <X11/extensions/dbeproto.h>
#include "windowstr.h"
#include "privates.h"
diff --git a/dbe/meson.build b/dbe/meson.build
index 2aa595aa3..e10bde199 100644
--- a/dbe/meson.build
+++ b/dbe/meson.build
@@ -3,16 +3,8 @@ srcs_dbe = [
'midbe.c',
]
-hdrs_dbe = [
- 'dbestruct.h',
-]
-
libxserver_dbe = static_library('libxserver_dbe',
srcs_dbe,
include_directories: inc,
dependencies: common_dep,
)
-
-if build_xorg
- install_data(hdrs_dbe, install_dir: xorgsdkdir)
-endif
diff --git a/dbe/midbe.c b/dbe/midbe.c
index 9684d45bd..eb6057748 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -171,13 +171,13 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
/* Security creation/labeling check. */
rc = XaceHook(XACE_RESOURCE_ACCESS, serverClient, bufId,
dbeDrawableResType, pDbeWindowPriv->pBackBuffer,
- RT_WINDOW, pWin, DixCreateAccess);
+ X11_RESTYPE_WINDOW, pWin, DixCreateAccess);
/* Make the back pixmap a DBE drawable resource. */
if (rc != Success || !AddResource(bufId, dbeDrawableResType,
pDbeWindowPriv->pBackBuffer)) {
/* free the buffer and the drawable resource */
- FreeResource(bufId, RT_NONE);
+ FreeResource(bufId, X11_RESTYPE_NONE);
return (rc == Success) ? BadAlloc : rc;
}
@@ -599,7 +599,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
/* DbeWindowPrivDelete() will free the window private if there no
* more buffer IDs associated with this window.
*/
- FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
+ FreeResource(pDbeWindowPriv->IDs[0], X11_RESTYPE_NONE);
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
}
diff --git a/dix/callback_priv.h b/dix/callback_priv.h
new file mode 100644
index 000000000..d0240bfd7
--- /dev/null
+++ b/dix/callback_priv.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_CALLBACK_PRIV_H
+#define _XSERVER_CALLBACK_PRIV_H
+
+#include "callback.h"
+
+typedef struct _CallbackList *CallbackListPtr;
+
+void InitCallbackManager(void);
+void DeleteCallbackManager(void);
+
+#endif /* _XSERVER_CALLBACK_PRIV_H */
diff --git a/include/closestr.h b/dix/closestr.h
index 60e6f09bc..60e6f09bc 100644
--- a/include/closestr.h
+++ b/dix/closestr.h
diff --git a/dix/color.c b/dix/color.c
new file mode 100644
index 000000000..8252e2e88
--- /dev/null
+++ b/dix/color.c
@@ -0,0 +1,884 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/keysym.h>
+
+#include "dix/dix_priv.h"
+#include "include/dix.h"
+
+typedef struct _builtinColor {
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+ const char *name;
+} BuiltinColor;
+
+static const BuiltinColor BuiltinColors[] = {
+/* R G B name */
+ { 240, 248, 255, "alice blue" },
+ { 240, 248, 255, "AliceBlue" },
+ { 250, 235, 215, "antique white" },
+ { 250, 235, 215, "AntiqueWhite" },
+ { 255, 239, 219, "AntiqueWhite1" },
+ { 238, 223, 204, "AntiqueWhite2" },
+ { 205, 192, 176, "AntiqueWhite3" },
+ { 139, 131, 120, "AntiqueWhite4" },
+ { 0, 255, 255, "aqua" },
+ { 127, 255, 212, "aquamarine" },
+ { 127, 255, 212, "aquamarine1" },
+ { 118, 238, 198, "aquamarine2" },
+ { 102, 205, 170, "aquamarine3" },
+ { 69, 139, 116, "aquamarine4" },
+ { 240, 255, 255, "azure" },
+ { 240, 255, 255, "azure1" },
+ { 224, 238, 238, "azure2" },
+ { 193, 205, 205, "azure3" },
+ { 131, 139, 139, "azure4" },
+ { 245, 245, 220, "beige" },
+ { 255, 228, 196, "bisque" },
+ { 255, 228, 196, "bisque1" },
+ { 238, 213, 183, "bisque2" },
+ { 205, 183, 158, "bisque3" },
+ { 139, 125, 107, "bisque4" },
+ { 0, 0, 0, "black" },
+ { 255, 235, 205, "blanched almond" },
+ { 255, 235, 205, "BlanchedAlmond" },
+ { 0, 0, 255, "blue" },
+ { 138, 43, 226, "blue violet" },
+ { 0, 0, 255, "blue1" },
+ { 0, 0, 238, "blue2" },
+ { 0, 0, 205, "blue3" },
+ { 0, 0, 139, "blue4" },
+ { 138, 43, 226, "BlueViolet" },
+ { 165, 42, 42, "brown" },
+ { 255, 64, 64, "brown1" },
+ { 238, 59, 59, "brown2" },
+ { 205, 51, 51, "brown3" },
+ { 139, 35, 35, "brown4" },
+ { 222, 184, 135, "burlywood" },
+ { 255, 211, 155, "burlywood1" },
+ { 238, 197, 145, "burlywood2" },
+ { 205, 170, 125, "burlywood3" },
+ { 139, 115, 85, "burlywood4" },
+ { 95, 158, 160, "cadet blue" },
+ { 95, 158, 160, "CadetBlue" },
+ { 152, 245, 255, "CadetBlue1" },
+ { 142, 229, 238, "CadetBlue2" },
+ { 122, 197, 205, "CadetBlue3" },
+ { 83, 134, 139, "CadetBlue4" },
+ { 127, 255, 0, "chartreuse" },
+ { 127, 255, 0, "chartreuse1" },
+ { 118, 238, 0, "chartreuse2" },
+ { 102, 205, 0, "chartreuse3" },
+ { 69, 139, 0, "chartreuse4" },
+ { 210, 105, 30, "chocolate" },
+ { 255, 127, 36, "chocolate1" },
+ { 238, 118, 33, "chocolate2" },
+ { 205, 102, 29, "chocolate3" },
+ { 139, 69, 19, "chocolate4" },
+ { 255, 127, 80, "coral" },
+ { 255, 114, 86, "coral1" },
+ { 238, 106, 80, "coral2" },
+ { 205, 91, 69, "coral3" },
+ { 139, 62, 47, "coral4" },
+ { 100, 149, 237, "cornflower blue" },
+ { 100, 149, 237, "CornflowerBlue" },
+ { 255, 248, 220, "cornsilk" },
+ { 255, 248, 220, "cornsilk1" },
+ { 238, 232, 205, "cornsilk2" },
+ { 205, 200, 177, "cornsilk3" },
+ { 139, 136, 120, "cornsilk4" },
+ { 220, 20, 60, "crimson" },
+ { 0, 255, 255, "cyan" },
+ { 0, 255, 255, "cyan1" },
+ { 0, 238, 238, "cyan2" },
+ { 0, 205, 205, "cyan3" },
+ { 0, 139, 139, "cyan4" },
+ { 0, 0, 139, "dark blue" },
+ { 0, 139, 139, "dark cyan" },
+ { 184, 134, 11, "dark goldenrod" },
+ { 169, 169, 169, "dark gray" },
+ { 0, 100, 0, "dark green" },
+ { 169, 169, 169, "dark grey" },
+ { 189, 183, 107, "dark khaki" },
+ { 139, 0, 139, "dark magenta" },
+ { 85, 107, 47, "dark olive green" },
+ { 255, 140, 0, "dark orange" },
+ { 153, 50, 204, "dark orchid" },
+ { 139, 0, 0, "dark red" },
+ { 233, 150, 122, "dark salmon" },
+ { 143, 188, 143, "dark sea green" },
+ { 72, 61, 139, "dark slate blue" },
+ { 47, 79, 79, "dark slate gray" },
+ { 47, 79, 79, "dark slate grey" },
+ { 0, 206, 209, "dark turquoise" },
+ { 148, 0, 211, "dark violet" },
+ { 0, 0, 139, "DarkBlue" },
+ { 0, 139, 139, "DarkCyan" },
+ { 184, 134, 11, "DarkGoldenrod" },
+ { 255, 185, 15, "DarkGoldenrod1" },
+ { 238, 173, 14, "DarkGoldenrod2" },
+ { 205, 149, 12, "DarkGoldenrod3" },
+ { 139, 101, 8, "DarkGoldenrod4" },
+ { 169, 169, 169, "DarkGray" },
+ { 0, 100, 0, "DarkGreen" },
+ { 169, 169, 169, "DarkGrey" },
+ { 189, 183, 107, "DarkKhaki" },
+ { 139, 0, 139, "DarkMagenta" },
+ { 85, 107, 47, "DarkOliveGreen" },
+ { 202, 255, 112, "DarkOliveGreen1" },
+ { 188, 238, 104, "DarkOliveGreen2" },
+ { 162, 205, 90, "DarkOliveGreen3" },
+ { 110, 139, 61, "DarkOliveGreen4" },
+ { 255, 140, 0, "DarkOrange" },
+ { 255, 127, 0, "DarkOrange1" },
+ { 238, 118, 0, "DarkOrange2" },
+ { 205, 102, 0, "DarkOrange3" },
+ { 139, 69, 0, "DarkOrange4" },
+ { 153, 50, 204, "DarkOrchid" },
+ { 191, 62, 255, "DarkOrchid1" },
+ { 178, 58, 238, "DarkOrchid2" },
+ { 154, 50, 205, "DarkOrchid3" },
+ { 104, 34, 139, "DarkOrchid4" },
+ { 139, 0, 0, "DarkRed" },
+ { 233, 150, 122, "DarkSalmon" },
+ { 143, 188, 143, "DarkSeaGreen" },
+ { 193, 255, 193, "DarkSeaGreen1" },
+ { 180, 238, 180, "DarkSeaGreen2" },
+ { 155, 205, 155, "DarkSeaGreen3" },
+ { 105, 139, 105, "DarkSeaGreen4" },
+ { 72, 61, 139, "DarkSlateBlue" },
+ { 47, 79, 79, "DarkSlateGray" },
+ { 151, 255, 255, "DarkSlateGray1" },
+ { 141, 238, 238, "DarkSlateGray2" },
+ { 121, 205, 205, "DarkSlateGray3" },
+ { 82, 139, 139, "DarkSlateGray4" },
+ { 47, 79, 79, "DarkSlateGrey" },
+ { 0, 206, 209, "DarkTurquoise" },
+ { 148, 0, 211, "DarkViolet" },
+ { 255, 20, 147, "deep pink" },
+ { 0, 191, 255, "deep sky blue" },
+ { 255, 20, 147, "DeepPink" },
+ { 255, 20, 147, "DeepPink1" },
+ { 238, 18, 137, "DeepPink2" },
+ { 205, 16, 118, "DeepPink3" },
+ { 139, 10, 80, "DeepPink4" },
+ { 0, 191, 255, "DeepSkyBlue" },
+ { 0, 191, 255, "DeepSkyBlue1" },
+ { 0, 178, 238, "DeepSkyBlue2" },
+ { 0, 154, 205, "DeepSkyBlue3" },
+ { 0, 104, 139, "DeepSkyBlue4" },
+ { 105, 105, 105, "dim gray" },
+ { 105, 105, 105, "dim grey" },
+ { 105, 105, 105, "DimGray" },
+ { 105, 105, 105, "DimGrey" },
+ { 30, 144, 255, "dodger blue" },
+ { 30, 144, 255, "DodgerBlue" },
+ { 30, 144, 255, "DodgerBlue1" },
+ { 28, 134, 238, "DodgerBlue2" },
+ { 24, 116, 205, "DodgerBlue3" },
+ { 16, 78, 139, "DodgerBlue4" },
+ { 178, 34, 34, "firebrick" },
+ { 255, 48, 48, "firebrick1" },
+ { 238, 44, 44, "firebrick2" },
+ { 205, 38, 38, "firebrick3" },
+ { 139, 26, 26, "firebrick4" },
+ { 255, 250, 240, "floral white" },
+ { 255, 250, 240, "FloralWhite" },
+ { 34, 139, 34, "forest green" },
+ { 34, 139, 34, "ForestGreen" },
+ { 255, 0, 255, "fuchsia" },
+ { 220, 220, 220, "gainsboro" },
+ { 248, 248, 255, "ghost white" },
+ { 248, 248, 255, "GhostWhite" },
+ { 255, 215, 0, "gold" },
+ { 255, 215, 0, "gold1" },
+ { 238, 201, 0, "gold2" },
+ { 205, 173, 0, "gold3" },
+ { 139, 117, 0, "gold4" },
+ { 218, 165, 32, "goldenrod" },
+ { 255, 193, 37, "goldenrod1" },
+ { 238, 180, 34, "goldenrod2" },
+ { 205, 155, 29, "goldenrod3" },
+ { 139, 105, 20, "goldenrod4" },
+ { 190, 190, 190, "gray" },
+ { 0, 0, 0, "gray0" },
+ { 3, 3, 3, "gray1" },
+ { 26, 26, 26, "gray10" },
+ { 255, 255, 255, "gray100" },
+ { 28, 28, 28, "gray11" },
+ { 31, 31, 31, "gray12" },
+ { 33, 33, 33, "gray13" },
+ { 36, 36, 36, "gray14" },
+ { 38, 38, 38, "gray15" },
+ { 41, 41, 41, "gray16" },
+ { 43, 43, 43, "gray17" },
+ { 46, 46, 46, "gray18" },
+ { 48, 48, 48, "gray19" },
+ { 5, 5, 5, "gray2" },
+ { 51, 51, 51, "gray20" },
+ { 54, 54, 54, "gray21" },
+ { 56, 56, 56, "gray22" },
+ { 59, 59, 59, "gray23" },
+ { 61, 61, 61, "gray24" },
+ { 64, 64, 64, "gray25" },
+ { 66, 66, 66, "gray26" },
+ { 69, 69, 69, "gray27" },
+ { 71, 71, 71, "gray28" },
+ { 74, 74, 74, "gray29" },
+ { 8, 8, 8, "gray3" },
+ { 77, 77, 77, "gray30" },
+ { 79, 79, 79, "gray31" },
+ { 82, 82, 82, "gray32" },
+ { 84, 84, 84, "gray33" },
+ { 87, 87, 87, "gray34" },
+ { 89, 89, 89, "gray35" },
+ { 92, 92, 92, "gray36" },
+ { 94, 94, 94, "gray37" },
+ { 97, 97, 97, "gray38" },
+ { 99, 99, 99, "gray39" },
+ { 10, 10, 10, "gray4" },
+ { 102, 102, 102, "gray40" },
+ { 105, 105, 105, "gray41" },
+ { 107, 107, 107, "gray42" },
+ { 110, 110, 110, "gray43" },
+ { 112, 112, 112, "gray44" },
+ { 115, 115, 115, "gray45" },
+ { 117, 117, 117, "gray46" },
+ { 120, 120, 120, "gray47" },
+ { 122, 122, 122, "gray48" },
+ { 125, 125, 125, "gray49" },
+ { 13, 13, 13, "gray5" },
+ { 127, 127, 127, "gray50" },
+ { 130, 130, 130, "gray51" },
+ { 133, 133, 133, "gray52" },
+ { 135, 135, 135, "gray53" },
+ { 138, 138, 138, "gray54" },
+ { 140, 140, 140, "gray55" },
+ { 143, 143, 143, "gray56" },
+ { 145, 145, 145, "gray57" },
+ { 148, 148, 148, "gray58" },
+ { 150, 150, 150, "gray59" },
+ { 15, 15, 15, "gray6" },
+ { 153, 153, 153, "gray60" },
+ { 156, 156, 156, "gray61" },
+ { 158, 158, 158, "gray62" },
+ { 161, 161, 161, "gray63" },
+ { 163, 163, 163, "gray64" },
+ { 166, 166, 166, "gray65" },
+ { 168, 168, 168, "gray66" },
+ { 171, 171, 171, "gray67" },
+ { 173, 173, 173, "gray68" },
+ { 176, 176, 176, "gray69" },
+ { 18, 18, 18, "gray7" },
+ { 179, 179, 179, "gray70" },
+ { 181, 181, 181, "gray71" },
+ { 184, 184, 184, "gray72" },
+ { 186, 186, 186, "gray73" },
+ { 189, 189, 189, "gray74" },
+ { 191, 191, 191, "gray75" },
+ { 194, 194, 194, "gray76" },
+ { 196, 196, 196, "gray77" },
+ { 199, 199, 199, "gray78" },
+ { 201, 201, 201, "gray79" },
+ { 20, 20, 20, "gray8" },
+ { 204, 204, 204, "gray80" },
+ { 207, 207, 207, "gray81" },
+ { 209, 209, 209, "gray82" },
+ { 212, 212, 212, "gray83" },
+ { 214, 214, 214, "gray84" },
+ { 217, 217, 217, "gray85" },
+ { 219, 219, 219, "gray86" },
+ { 222, 222, 222, "gray87" },
+ { 224, 224, 224, "gray88" },
+ { 227, 227, 227, "gray89" },
+ { 23, 23, 23, "gray9" },
+ { 229, 229, 229, "gray90" },
+ { 232, 232, 232, "gray91" },
+ { 235, 235, 235, "gray92" },
+ { 237, 237, 237, "gray93" },
+ { 240, 240, 240, "gray94" },
+ { 242, 242, 242, "gray95" },
+ { 245, 245, 245, "gray96" },
+ { 247, 247, 247, "gray97" },
+ { 250, 250, 250, "gray98" },
+ { 252, 252, 252, "gray99" },
+ { 0, 255, 0, "green" },
+ { 173, 255, 47, "green yellow" },
+ { 0, 255, 0, "green1" },
+ { 0, 238, 0, "green2" },
+ { 0, 205, 0, "green3" },
+ { 0, 139, 0, "green4" },
+ { 173, 255, 47, "GreenYellow" },
+ { 190, 190, 190, "grey" },
+ { 0, 0, 0, "grey0" },
+ { 3, 3, 3, "grey1" },
+ { 26, 26, 26, "grey10" },
+ { 255, 255, 255, "grey100" },
+ { 28, 28, 28, "grey11" },
+ { 31, 31, 31, "grey12" },
+ { 33, 33, 33, "grey13" },
+ { 36, 36, 36, "grey14" },
+ { 38, 38, 38, "grey15" },
+ { 41, 41, 41, "grey16" },
+ { 43, 43, 43, "grey17" },
+ { 46, 46, 46, "grey18" },
+ { 48, 48, 48, "grey19" },
+ { 5, 5, 5, "grey2" },
+ { 51, 51, 51, "grey20" },
+ { 54, 54, 54, "grey21" },
+ { 56, 56, 56, "grey22" },
+ { 59, 59, 59, "grey23" },
+ { 61, 61, 61, "grey24" },
+ { 64, 64, 64, "grey25" },
+ { 66, 66, 66, "grey26" },
+ { 69, 69, 69, "grey27" },
+ { 71, 71, 71, "grey28" },
+ { 74, 74, 74, "grey29" },
+ { 8, 8, 8, "grey3" },
+ { 77, 77, 77, "grey30" },
+ { 79, 79, 79, "grey31" },
+ { 82, 82, 82, "grey32" },
+ { 84, 84, 84, "grey33" },
+ { 87, 87, 87, "grey34" },
+ { 89, 89, 89, "grey35" },
+ { 92, 92, 92, "grey36" },
+ { 94, 94, 94, "grey37" },
+ { 97, 97, 97, "grey38" },
+ { 99, 99, 99, "grey39" },
+ { 10, 10, 10, "grey4" },
+ { 102, 102, 102, "grey40" },
+ { 105, 105, 105, "grey41" },
+ { 107, 107, 107, "grey42" },
+ { 110, 110, 110, "grey43" },
+ { 112, 112, 112, "grey44" },
+ { 115, 115, 115, "grey45" },
+ { 117, 117, 117, "grey46" },
+ { 120, 120, 120, "grey47" },
+ { 122, 122, 122, "grey48" },
+ { 125, 125, 125, "grey49" },
+ { 13, 13, 13, "grey5" },
+ { 127, 127, 127, "grey50" },
+ { 130, 130, 130, "grey51" },
+ { 133, 133, 133, "grey52" },
+ { 135, 135, 135, "grey53" },
+ { 138, 138, 138, "grey54" },
+ { 140, 140, 140, "grey55" },
+ { 143, 143, 143, "grey56" },
+ { 145, 145, 145, "grey57" },
+ { 148, 148, 148, "grey58" },
+ { 150, 150, 150, "grey59" },
+ { 15, 15, 15, "grey6" },
+ { 153, 153, 153, "grey60" },
+ { 156, 156, 156, "grey61" },
+ { 158, 158, 158, "grey62" },
+ { 161, 161, 161, "grey63" },
+ { 163, 163, 163, "grey64" },
+ { 166, 166, 166, "grey65" },
+ { 168, 168, 168, "grey66" },
+ { 171, 171, 171, "grey67" },
+ { 173, 173, 173, "grey68" },
+ { 176, 176, 176, "grey69" },
+ { 18, 18, 18, "grey7" },
+ { 179, 179, 179, "grey70" },
+ { 181, 181, 181, "grey71" },
+ { 184, 184, 184, "grey72" },
+ { 186, 186, 186, "grey73" },
+ { 189, 189, 189, "grey74" },
+ { 191, 191, 191, "grey75" },
+ { 194, 194, 194, "grey76" },
+ { 196, 196, 196, "grey77" },
+ { 199, 199, 199, "grey78" },
+ { 201, 201, 201, "grey79" },
+ { 20, 20, 20, "grey8" },
+ { 204, 204, 204, "grey80" },
+ { 207, 207, 207, "grey81" },
+ { 209, 209, 209, "grey82" },
+ { 212, 212, 212, "grey83" },
+ { 214, 214, 214, "grey84" },
+ { 217, 217, 217, "grey85" },
+ { 219, 219, 219, "grey86" },
+ { 222, 222, 222, "grey87" },
+ { 224, 224, 224, "grey88" },
+ { 227, 227, 227, "grey89" },
+ { 23, 23, 23, "grey9" },
+ { 229, 229, 229, "grey90" },
+ { 232, 232, 232, "grey91" },
+ { 235, 235, 235, "grey92" },
+ { 237, 237, 237, "grey93" },
+ { 240, 240, 240, "grey94" },
+ { 242, 242, 242, "grey95" },
+ { 245, 245, 245, "grey96" },
+ { 247, 247, 247, "grey97" },
+ { 250, 250, 250, "grey98" },
+ { 252, 252, 252, "grey99" },
+ { 240, 255, 240, "honeydew" },
+ { 240, 255, 240, "honeydew1" },
+ { 224, 238, 224, "honeydew2" },
+ { 193, 205, 193, "honeydew3" },
+ { 131, 139, 131, "honeydew4" },
+ { 255, 105, 180, "hot pink" },
+ { 255, 105, 180, "HotPink" },
+ { 255, 110, 180, "HotPink1" },
+ { 238, 106, 167, "HotPink2" },
+ { 205, 96, 144, "HotPink3" },
+ { 139, 58, 98, "HotPink4" },
+ { 205, 92, 92, "indian red" },
+ { 205, 92, 92, "IndianRed" },
+ { 255, 106, 106, "IndianRed1" },
+ { 238, 99, 99, "IndianRed2" },
+ { 205, 85, 85, "IndianRed3" },
+ { 139, 58, 58, "IndianRed4" },
+ { 75, 0, 130, "indigo" },
+ { 255, 255, 240, "ivory" },
+ { 255, 255, 240, "ivory1" },
+ { 238, 238, 224, "ivory2" },
+ { 205, 205, 193, "ivory3" },
+ { 139, 139, 131, "ivory4" },
+ { 240, 230, 140, "khaki" },
+ { 255, 246, 143, "khaki1" },
+ { 238, 230, 133, "khaki2" },
+ { 205, 198, 115, "khaki3" },
+ { 139, 134, 78, "khaki4" },
+ { 230, 230, 250, "lavender" },
+ { 255, 240, 245, "lavender blush" },
+ { 255, 240, 245, "LavenderBlush" },
+ { 255, 240, 245, "LavenderBlush1" },
+ { 238, 224, 229, "LavenderBlush2" },
+ { 205, 193, 197, "LavenderBlush3" },
+ { 139, 131, 134, "LavenderBlush4" },
+ { 124, 252, 0, "lawn green" },
+ { 124, 252, 0, "LawnGreen" },
+ { 255, 250, 205, "lemon chiffon" },
+ { 255, 250, 205, "LemonChiffon" },
+ { 255, 250, 205, "LemonChiffon1" },
+ { 238, 233, 191, "LemonChiffon2" },
+ { 205, 201, 165, "LemonChiffon3" },
+ { 139, 137, 112, "LemonChiffon4" },
+ { 173, 216, 230, "light blue" },
+ { 240, 128, 128, "light coral" },
+ { 224, 255, 255, "light cyan" },
+ { 238, 221, 130, "light goldenrod" },
+ { 250, 250, 210, "light goldenrod yellow" },
+ { 211, 211, 211, "light gray" },
+ { 144, 238, 144, "light green" },
+ { 211, 211, 211, "light grey" },
+ { 255, 182, 193, "light pink" },
+ { 255, 160, 122, "light salmon" },
+ { 32, 178, 170, "light sea green" },
+ { 135, 206, 250, "light sky blue" },
+ { 132, 112, 255, "light slate blue" },
+ { 119, 136, 153, "light slate gray" },
+ { 119, 136, 153, "light slate grey" },
+ { 176, 196, 222, "light steel blue" },
+ { 255, 255, 224, "light yellow" },
+ { 173, 216, 230, "LightBlue" },
+ { 191, 239, 255, "LightBlue1" },
+ { 178, 223, 238, "LightBlue2" },
+ { 154, 192, 205, "LightBlue3" },
+ { 104, 131, 139, "LightBlue4" },
+ { 240, 128, 128, "LightCoral" },
+ { 224, 255, 255, "LightCyan" },
+ { 224, 255, 255, "LightCyan1" },
+ { 209, 238, 238, "LightCyan2" },
+ { 180, 205, 205, "LightCyan3" },
+ { 122, 139, 139, "LightCyan4" },
+ { 238, 221, 130, "LightGoldenrod" },
+ { 255, 236, 139, "LightGoldenrod1" },
+ { 238, 220, 130, "LightGoldenrod2" },
+ { 205, 190, 112, "LightGoldenrod3" },
+ { 139, 129, 76, "LightGoldenrod4" },
+ { 250, 250, 210, "LightGoldenrodYellow" },
+ { 211, 211, 211, "LightGray" },
+ { 144, 238, 144, "LightGreen" },
+ { 211, 211, 211, "LightGrey" },
+ { 255, 182, 193, "LightPink" },
+ { 255, 174, 185, "LightPink1" },
+ { 238, 162, 173, "LightPink2" },
+ { 205, 140, 149, "LightPink3" },
+ { 139, 95, 101, "LightPink4" },
+ { 255, 160, 122, "LightSalmon" },
+ { 255, 160, 122, "LightSalmon1" },
+ { 238, 149, 114, "LightSalmon2" },
+ { 205, 129, 98, "LightSalmon3" },
+ { 139, 87, 66, "LightSalmon4" },
+ { 32, 178, 170, "LightSeaGreen" },
+ { 135, 206, 250, "LightSkyBlue" },
+ { 176, 226, 255, "LightSkyBlue1" },
+ { 164, 211, 238, "LightSkyBlue2" },
+ { 141, 182, 205, "LightSkyBlue3" },
+ { 96, 123, 139, "LightSkyBlue4" },
+ { 132, 112, 255, "LightSlateBlue" },
+ { 119, 136, 153, "LightSlateGray" },
+ { 119, 136, 153, "LightSlateGrey" },
+ { 176, 196, 222, "LightSteelBlue" },
+ { 202, 225, 255, "LightSteelBlue1" },
+ { 188, 210, 238, "LightSteelBlue2" },
+ { 162, 181, 205, "LightSteelBlue3" },
+ { 110, 123, 139, "LightSteelBlue4" },
+ { 255, 255, 224, "LightYellow" },
+ { 255, 255, 224, "LightYellow1" },
+ { 238, 238, 209, "LightYellow2" },
+ { 205, 205, 180, "LightYellow3" },
+ { 139, 139, 122, "LightYellow4" },
+ { 0, 255, 0, "lime" },
+ { 50, 205, 50, "lime green" },
+ { 50, 205, 50, "LimeGreen" },
+ { 250, 240, 230, "linen" },
+ { 255, 0, 255, "magenta" },
+ { 255, 0, 255, "magenta1" },
+ { 238, 0, 238, "magenta2" },
+ { 205, 0, 205, "magenta3" },
+ { 139, 0, 139, "magenta4" },
+ { 176, 48, 96, "maroon" },
+ { 255, 52, 179, "maroon1" },
+ { 238, 48, 167, "maroon2" },
+ { 205, 41, 144, "maroon3" },
+ { 139, 28, 98, "maroon4" },
+ { 102, 205, 170, "medium aquamarine" },
+ { 0, 0, 205, "medium blue" },
+ { 186, 85, 211, "medium orchid" },
+ { 147, 112, 219, "medium purple" },
+ { 60, 179, 113, "medium sea green" },
+ { 123, 104, 238, "medium slate blue" },
+ { 0, 250, 154, "medium spring green" },
+ { 72, 209, 204, "medium turquoise" },
+ { 199, 21, 133, "medium violet red" },
+ { 102, 205, 170, "MediumAquamarine" },
+ { 0, 0, 205, "MediumBlue" },
+ { 186, 85, 211, "MediumOrchid" },
+ { 224, 102, 255, "MediumOrchid1" },
+ { 209, 95, 238, "MediumOrchid2" },
+ { 180, 82, 205, "MediumOrchid3" },
+ { 122, 55, 139, "MediumOrchid4" },
+ { 147, 112, 219, "MediumPurple" },
+ { 171, 130, 255, "MediumPurple1" },
+ { 159, 121, 238, "MediumPurple2" },
+ { 137, 104, 205, "MediumPurple3" },
+ { 93, 71, 139, "MediumPurple4" },
+ { 60, 179, 113, "MediumSeaGreen" },
+ { 123, 104, 238, "MediumSlateBlue" },
+ { 0, 250, 154, "MediumSpringGreen" },
+ { 72, 209, 204, "MediumTurquoise" },
+ { 199, 21, 133, "MediumVioletRed" },
+ { 25, 25, 112, "midnight blue" },
+ { 25, 25, 112, "MidnightBlue" },
+ { 245, 255, 250, "mint cream" },
+ { 245, 255, 250, "MintCream" },
+ { 255, 228, 225, "misty rose" },
+ { 255, 228, 225, "MistyRose" },
+ { 255, 228, 225, "MistyRose1" },
+ { 238, 213, 210, "MistyRose2" },
+ { 205, 183, 181, "MistyRose3" },
+ { 139, 125, 123, "MistyRose4" },
+ { 255, 228, 181, "moccasin" },
+ { 255, 222, 173, "navajo white" },
+ { 255, 222, 173, "NavajoWhite" },
+ { 255, 222, 173, "NavajoWhite1" },
+ { 238, 207, 161, "NavajoWhite2" },
+ { 205, 179, 139, "NavajoWhite3" },
+ { 139, 121, 94, "NavajoWhite4" },
+ { 0, 0, 128, "navy" },
+ { 0, 0, 128, "navy blue" },
+ { 0, 0, 128, "NavyBlue" },
+ { 253, 245, 230, "old lace" },
+ { 253, 245, 230, "OldLace" },
+ { 128, 128, 0, "olive" },
+ { 107, 142, 35, "olive drab" },
+ { 107, 142, 35, "OliveDrab" },
+ { 192, 255, 62, "OliveDrab1" },
+ { 179, 238, 58, "OliveDrab2" },
+ { 154, 205, 50, "OliveDrab3" },
+ { 105, 139, 34, "OliveDrab4" },
+ { 255, 165, 0, "orange" },
+ { 255, 69, 0, "orange red" },
+ { 255, 165, 0, "orange1" },
+ { 238, 154, 0, "orange2" },
+ { 205, 133, 0, "orange3" },
+ { 139, 90, 0, "orange4" },
+ { 255, 69, 0, "OrangeRed" },
+ { 255, 69, 0, "OrangeRed1" },
+ { 238, 64, 0, "OrangeRed2" },
+ { 205, 55, 0, "OrangeRed3" },
+ { 139, 37, 0, "OrangeRed4" },
+ { 218, 112, 214, "orchid" },
+ { 255, 131, 250, "orchid1" },
+ { 238, 122, 233, "orchid2" },
+ { 205, 105, 201, "orchid3" },
+ { 139, 71, 137, "orchid4" },
+ { 238, 232, 170, "pale goldenrod" },
+ { 152, 251, 152, "pale green" },
+ { 175, 238, 238, "pale turquoise" },
+ { 219, 112, 147, "pale violet red" },
+ { 238, 232, 170, "PaleGoldenrod" },
+ { 152, 251, 152, "PaleGreen" },
+ { 154, 255, 154, "PaleGreen1" },
+ { 144, 238, 144, "PaleGreen2" },
+ { 124, 205, 124, "PaleGreen3" },
+ { 84, 139, 84, "PaleGreen4" },
+ { 175, 238, 238, "PaleTurquoise" },
+ { 187, 255, 255, "PaleTurquoise1" },
+ { 174, 238, 238, "PaleTurquoise2" },
+ { 150, 205, 205, "PaleTurquoise3" },
+ { 102, 139, 139, "PaleTurquoise4" },
+ { 219, 112, 147, "PaleVioletRed" },
+ { 255, 130, 171, "PaleVioletRed1" },
+ { 238, 121, 159, "PaleVioletRed2" },
+ { 205, 104, 137, "PaleVioletRed3" },
+ { 139, 71, 93, "PaleVioletRed4" },
+ { 255, 239, 213, "papaya whip" },
+ { 255, 239, 213, "PapayaWhip" },
+ { 255, 218, 185, "peach puff" },
+ { 255, 218, 185, "PeachPuff" },
+ { 255, 218, 185, "PeachPuff1" },
+ { 238, 203, 173, "PeachPuff2" },
+ { 205, 175, 149, "PeachPuff3" },
+ { 139, 119, 101, "PeachPuff4" },
+ { 205, 133, 63, "peru" },
+ { 255, 192, 203, "pink" },
+ { 255, 181, 197, "pink1" },
+ { 238, 169, 184, "pink2" },
+ { 205, 145, 158, "pink3" },
+ { 139, 99, 108, "pink4" },
+ { 221, 160, 221, "plum" },
+ { 255, 187, 255, "plum1" },
+ { 238, 174, 238, "plum2" },
+ { 205, 150, 205, "plum3" },
+ { 139, 102, 139, "plum4" },
+ { 176, 224, 230, "powder blue" },
+ { 176, 224, 230, "PowderBlue" },
+ { 160, 32, 240, "purple" },
+ { 155, 48, 255, "purple1" },
+ { 145, 44, 238, "purple2" },
+ { 125, 38, 205, "purple3" },
+ { 85, 26, 139, "purple4" },
+ { 102, 51, 153, "rebecca purple" },
+ { 102, 51, 153, "RebeccaPurple" },
+ { 255, 0, 0, "red" },
+ { 255, 0, 0, "red1" },
+ { 238, 0, 0, "red2" },
+ { 205, 0, 0, "red3" },
+ { 139, 0, 0, "red4" },
+ { 188, 143, 143, "rosy brown" },
+ { 188, 143, 143, "RosyBrown" },
+ { 255, 193, 193, "RosyBrown1" },
+ { 238, 180, 180, "RosyBrown2" },
+ { 205, 155, 155, "RosyBrown3" },
+ { 139, 105, 105, "RosyBrown4" },
+ { 65, 105, 225, "royal blue" },
+ { 65, 105, 225, "RoyalBlue" },
+ { 72, 118, 255, "RoyalBlue1" },
+ { 67, 110, 238, "RoyalBlue2" },
+ { 58, 95, 205, "RoyalBlue3" },
+ { 39, 64, 139, "RoyalBlue4" },
+ { 139, 69, 19, "saddle brown" },
+ { 139, 69, 19, "SaddleBrown" },
+ { 250, 128, 114, "salmon" },
+ { 255, 140, 105, "salmon1" },
+ { 238, 130, 98, "salmon2" },
+ { 205, 112, 84, "salmon3" },
+ { 139, 76, 57, "salmon4" },
+ { 244, 164, 96, "sandy brown" },
+ { 244, 164, 96, "SandyBrown" },
+ { 46, 139, 87, "sea green" },
+ { 46, 139, 87, "SeaGreen" },
+ { 84, 255, 159, "SeaGreen1" },
+ { 78, 238, 148, "SeaGreen2" },
+ { 67, 205, 128, "SeaGreen3" },
+ { 46, 139, 87, "SeaGreen4" },
+ { 255, 245, 238, "seashell" },
+ { 255, 245, 238, "seashell1" },
+ { 238, 229, 222, "seashell2" },
+ { 205, 197, 191, "seashell3" },
+ { 139, 134, 130, "seashell4" },
+ { 160, 82, 45, "sienna" },
+ { 255, 130, 71, "sienna1" },
+ { 238, 121, 66, "sienna2" },
+ { 205, 104, 57, "sienna3" },
+ { 139, 71, 38, "sienna4" },
+ { 192, 192, 192, "silver" },
+ { 135, 206, 235, "sky blue" },
+ { 135, 206, 235, "SkyBlue" },
+ { 135, 206, 255, "SkyBlue1" },
+ { 126, 192, 238, "SkyBlue2" },
+ { 108, 166, 205, "SkyBlue3" },
+ { 74, 112, 139, "SkyBlue4" },
+ { 106, 90, 205, "slate blue" },
+ { 112, 128, 144, "slate gray" },
+ { 112, 128, 144, "slate grey" },
+ { 106, 90, 205, "SlateBlue" },
+ { 131, 111, 255, "SlateBlue1" },
+ { 122, 103, 238, "SlateBlue2" },
+ { 105, 89, 205, "SlateBlue3" },
+ { 71, 60, 139, "SlateBlue4" },
+ { 112, 128, 144, "SlateGray" },
+ { 198, 226, 255, "SlateGray1" },
+ { 185, 211, 238, "SlateGray2" },
+ { 159, 182, 205, "SlateGray3" },
+ { 108, 123, 139, "SlateGray4" },
+ { 112, 128, 144, "SlateGrey" },
+ { 255, 250, 250, "snow" },
+ { 255, 250, 250, "snow1" },
+ { 238, 233, 233, "snow2" },
+ { 205, 201, 201, "snow3" },
+ { 139, 137, 137, "snow4" },
+ { 0, 255, 127, "spring green" },
+ { 0, 255, 127, "SpringGreen" },
+ { 0, 255, 127, "SpringGreen1" },
+ { 0, 238, 118, "SpringGreen2" },
+ { 0, 205, 102, "SpringGreen3" },
+ { 0, 139, 69, "SpringGreen4" },
+ { 70, 130, 180, "steel blue" },
+ { 70, 130, 180, "SteelBlue" },
+ { 99, 184, 255, "SteelBlue1" },
+ { 92, 172, 238, "SteelBlue2" },
+ { 79, 148, 205, "SteelBlue3" },
+ { 54, 100, 139, "SteelBlue4" },
+ { 210, 180, 140, "tan" },
+ { 255, 165, 79, "tan1" },
+ { 238, 154, 73, "tan2" },
+ { 205, 133, 63, "tan3" },
+ { 139, 90, 43, "tan4" },
+ { 0, 128, 128, "teal" },
+ { 216, 191, 216, "thistle" },
+ { 255, 225, 255, "thistle1" },
+ { 238, 210, 238, "thistle2" },
+ { 205, 181, 205, "thistle3" },
+ { 139, 123, 139, "thistle4" },
+ { 255, 99, 71, "tomato" },
+ { 255, 99, 71, "tomato1" },
+ { 238, 92, 66, "tomato2" },
+ { 205, 79, 57, "tomato3" },
+ { 139, 54, 38, "tomato4" },
+ { 64, 224, 208, "turquoise" },
+ { 0, 245, 255, "turquoise1" },
+ { 0, 229, 238, "turquoise2" },
+ { 0, 197, 205, "turquoise3" },
+ { 0, 134, 139, "turquoise4" },
+ { 238, 130, 238, "violet" },
+ { 208, 32, 144, "violet red" },
+ { 208, 32, 144, "VioletRed" },
+ { 255, 62, 150, "VioletRed1" },
+ { 238, 58, 140, "VioletRed2" },
+ { 205, 50, 120, "VioletRed3" },
+ { 139, 34, 82, "VioletRed4" },
+ { 128, 128, 128, "web gray" },
+ { 0, 128, 0, "web green" },
+ { 128, 128, 128, "web grey" },
+ { 128, 0, 0, "web maroon" },
+ { 128, 0, 128, "web purple" },
+ { 128, 128, 128, "WebGray" },
+ { 0, 128, 0, "WebGreen" },
+ { 128, 128, 128, "WebGrey" },
+ { 128, 0, 0, "WebMaroon" },
+ { 128, 0, 128, "WebPurple" },
+ { 245, 222, 179, "wheat" },
+ { 255, 231, 186, "wheat1" },
+ { 238, 216, 174, "wheat2" },
+ { 205, 186, 150, "wheat3" },
+ { 139, 126, 102, "wheat4" },
+ { 255, 255, 255, "white" },
+ { 245, 245, 245, "white smoke" },
+ { 245, 245, 245, "WhiteSmoke" },
+ { 190, 190, 190, "x11 gray" },
+ { 0, 255, 0, "x11 green" },
+ { 190, 190, 190, "x11 grey" },
+ { 176, 48, 96, "x11 maroon" },
+ { 160, 32, 240, "x11 purple" },
+ { 190, 190, 190, "X11Gray" },
+ { 0, 255, 0, "X11Green" },
+ { 190, 190, 190, "X11Grey" },
+ { 176, 48, 96, "X11Maroon" },
+ { 160, 32, 240, "X11Purple" },
+ { 255, 255, 0, "yellow" },
+ { 154, 205, 50, "yellow green" },
+ { 255, 255, 0, "yellow1" },
+ { 238, 238, 0, "yellow2" },
+ { 205, 205, 0, "yellow3" },
+ { 139, 139, 0, "yellow4" },
+ { 154, 205, 50, "YellowGreen" },
+};
+
+Bool
+dixLookupBuiltinColor(int screen,
+ char *name,
+ unsigned int len,
+ unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue)
+{
+ int low = 0;
+ int high = ARRAY_SIZE(BuiltinColors) - 1;
+
+ while (high >= low) {
+ int mid = (low + high) / 2;
+ const BuiltinColor *c = &BuiltinColors[mid];
+ const int currentLen = strlen(c->name);
+ const int r = strncasecmp(c->name, name, min(len, currentLen));
+
+ if (r == 0) {
+ if (len == currentLen) {
+ *pred = c->red * 0x101;
+ *pgreen = c->green * 0x101;
+ *pblue = c->blue * 0x101;
+ return TRUE;
+ } else if (len > currentLen) {
+ low = mid + 1;
+ } else {
+ high = mid - 1;
+ }
+ } else if (r > 0) {
+ high = mid - 1;
+ } else {
+ low = mid + 1;
+ }
+ }
+ return FALSE;
+}
diff --git a/dix/colormap.c b/dix/colormap.c
index 7a00d14d6..ec787349f 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -53,6 +53,9 @@ SOFTWARE.
#include <stdio.h>
#include <string.h>
#include <strings.h>
+
+#include "dix/colormap_priv.h"
+
#include "misc.h"
#include "dix.h"
#include "dixstruct.h"
@@ -370,16 +373,16 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
}
pmap->flags |= BeingCreated;
- if (!AddResource(mid, RT_COLORMAP, (void *) pmap))
+ if (!AddResource(mid, X11_RESTYPE_COLORMAP, (void *) pmap))
return BadAlloc;
/*
* Security creation/labeling check
*/
- i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP,
- pmap, RT_NONE, NULL, DixCreateAccess);
+ i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, X11_RESTYPE_COLORMAP,
+ pmap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (i != Success) {
- FreeResource(mid, RT_NONE);
+ FreeResource(mid, X11_RESTYPE_NONE);
return i;
}
@@ -387,7 +390,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
* this is it. In specific, if this is a Static colormap, this is the
* time to fill in the colormap's values */
if (!(*pScreen->CreateColormap) (pmap)) {
- FreeResource(mid, RT_NONE);
+ FreeResource(mid, X11_RESTYPE_NONE);
return BadAlloc;
}
pmap->flags &= ~BeingCreated;
@@ -566,7 +569,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client)
}
if (pmap->class & DynamicClass)
UpdateColors(pmap);
- /* XXX should worry about removing any RT_CMAPENTRY resource */
+ /* XXX should worry about removing any X11_RESTYPE_CMAPENTRY resource */
return Success;
}
@@ -1016,7 +1019,7 @@ AllocColor(ColormapPtr pmap,
ColormapPtr prootmap;
dixLookupResourceByType((void **) &prootmap,
- pmap->pScreen->defColormap, RT_COLORMAP,
+ pmap->pScreen->defColormap, X11_RESTYPE_COLORMAP,
clients[client], DixReadAccess);
if (pmap->class == prootmap->class)
@@ -1034,7 +1037,7 @@ AllocColor(ColormapPtr pmap,
ColormapPtr prootmap;
dixLookupResourceByType((void **) &prootmap,
- pmap->pScreen->defColormap, RT_COLORMAP,
+ pmap->pScreen->defColormap, X11_RESTYPE_COLORMAP,
clients[client], DixReadAccess);
if (pmap->class == prootmap->class) {
@@ -1087,7 +1090,7 @@ AllocColor(ColormapPtr pmap,
}
pcr->mid = pmap->mid;
pcr->client = client;
- if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (void *) pcr))
+ if (!AddResource(FakeClientID(client), X11_RESTYPE_CMAPENTRY, (void *) pcr))
return BadAlloc;
}
return Success;
@@ -1472,7 +1475,7 @@ FreeClientPixels(void *value, XID fakeid)
colorResource *pcr = value;
int rc;
- rc = dixLookupResourceByType(&pmap, pcr->mid, RT_COLORMAP, serverClient,
+ rc = dixLookupResourceByType(&pmap, pcr->mid, X11_RESTYPE_COLORMAP, serverClient,
DixRemoveAccess);
if (rc == Success)
FreePixels((ColormapPtr) pmap, pcr->client);
@@ -1535,7 +1538,7 @@ AllocColorCells(int client, ColormapPtr pmap, int colors, int planes,
if ((ok == Success) && pcr) {
pcr->mid = pmap->mid;
pcr->client = client;
- if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (void *) pcr))
+ if (!AddResource(FakeClientID(client), X11_RESTYPE_CMAPENTRY, (void *) pcr))
ok = BadAlloc;
}
else
@@ -1617,7 +1620,7 @@ AllocColorPlanes(int client, ColormapPtr pmap, int colors,
if ((ok == Success) && pcr) {
pcr->mid = pmap->mid;
pcr->client = client;
- if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (void *) pcr))
+ if (!AddResource(FakeClientID(client), X11_RESTYPE_CMAPENTRY, (void *) pcr))
ok = BadAlloc;
}
else
@@ -2092,7 +2095,7 @@ FreeColors(ColormapPtr pmap, int client, int count, Pixel * pixels, Pixel mask)
clients[client]->errorValue = *pixels | mask;
result = BadValue;
}
- /* XXX should worry about removing any RT_CMAPENTRY resource */
+ /* XXX should worry about removing any X11_RESTYPE_CMAPENTRY resource */
return result;
}
@@ -2539,7 +2542,7 @@ ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth)
cdata.visuals = visuals;
cdata.pScreen = pScreen;
- FindClientResourcesByType(serverClient, RT_COLORMAP,
+ FindClientResourcesByType(serverClient, X11_RESTYPE_COLORMAP,
_colormap_find_resource, &cdata);
pScreen->visuals = visuals;
diff --git a/dix/colormap_priv.h b/dix/colormap_priv.h
new file mode 100644
index 000000000..9f3d211a3
--- /dev/null
+++ b/dix/colormap_priv.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_DIX_COLORMAP_PRIV_H
+#define _XSERVER_DIX_COLORMAP_PRIv_H
+
+typedef struct _CMEntry *EntryPtr;
+
+#endif /* _XSERVER_DIX_COLORMAP_PRIV_H */
diff --git a/dix/cursor.c b/dix/cursor.c
index a9ad34467..dcbcaaa77 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -69,8 +69,6 @@ typedef struct _GlyphShare {
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr) NULL;
-DevScreenPrivateKeyRec cursorScreenDevPriv;
-
static CARD32 cursorSerial;
static void
@@ -278,8 +276,8 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
pCurs->id = cid;
/* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
- pCurs, RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, X11_RESTYPE_CURSOR,
+ pCurs, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success)
goto error;
@@ -336,13 +334,13 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
CursorPtr pCurs;
GlyphSharePtr pShare;
- rc = dixLookupResourceByType((void **) &sourcefont, source, RT_FONT,
+ rc = dixLookupResourceByType((void **) &sourcefont, source, X11_RESTYPE_FONT,
client, DixUseAccess);
if (rc != Success) {
client->errorValue = source;
return rc;
}
- rc = dixLookupResourceByType((void **) &maskfont, mask, RT_FONT, client,
+ rc = dixLookupResourceByType((void **) &maskfont, mask, X11_RESTYPE_FONT, client,
DixUseAccess);
if (rc != Success && mask != None) {
client->errorValue = mask;
@@ -458,8 +456,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pCurs->id = cid;
/* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
- pCurs, RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, X11_RESTYPE_CURSOR,
+ pCurs, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success)
goto error;
@@ -502,7 +500,7 @@ CreateRootCursor(char *unused1, unsigned int unused2)
if (err != Success)
return NullCursor;
- err = dixLookupResourceByType((void **) &cursorfont, fontID, RT_FONT,
+ err = dixLookupResourceByType((void **) &cursorfont, fontID, X11_RESTYPE_FONT,
serverClient, DixReadAccess);
if (err != Success)
return NullCursor;
@@ -510,7 +508,7 @@ CreateRootCursor(char *unused1, unsigned int unused2)
&curs, serverClient, (XID) 0) != Success)
return NullCursor;
- if (!AddResource(FakeClientID(0), RT_CURSOR, (void *) curs))
+ if (!AddResource(FakeClientID(0), X11_RESTYPE_CURSOR, (void *) curs))
return NullCursor;
return curs;
diff --git a/dix/devices.c b/dix/devices.c
index 5f9ce1678..b37523262 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -49,10 +49,14 @@ SOFTWARE.
#endif
#include <X11/X.h>
-#include "misc.h"
-#include "resource.h"
#include <X11/Xproto.h>
#include <X11/Xatom.h>
+
+#include "dix/dix_priv.h"
+#include "dix/ptrveloc_priv.h"
+
+#include "misc.h"
+#include "resource.h"
#include "windowstr.h"
#include "inputstr.h"
#include "scrnintstr.h"
@@ -283,6 +287,8 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
dev->deviceGrab.sync.event = calloc(1, sizeof(InternalEvent));
+ dev->sendEventsProc = XTestDeviceSendEvents;
+
XkbSetExtension(dev, ProcessKeyboardEvent);
dev->coreEvents = TRUE;
@@ -422,6 +428,10 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
if (!IsMaster(dev) && !IsFloating(dev))
XkbPushLockedStateToSlaves(GetMaster(dev, MASTER_KEYBOARD), 0, 0);
+
+ /* Now make sure our LEDs are in sync with the locked state */
+ XkbForceUpdateDeviceLEDs(dev);
+
RecalculateMasterButtons(dev);
/* initialise an idle timer for this device*/
@@ -447,14 +457,20 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
{
DeviceIntPtr *prev, other;
BOOL enabled;
+ BOOL dev_in_devices_list = FALSE;
int flags[MAXDEVICES] = { 0 };
if (!dev->enabled)
return TRUE;
- for (prev = &inputInfo.devices;
- *prev && (*prev != dev); prev = &(*prev)->next);
- if (*prev != dev)
+ for (other = inputInfo.devices; other; other = other->next) {
+ if (other == dev) {
+ dev_in_devices_list = TRUE;
+ break;
+ }
+ }
+
+ if (!dev_in_devices_list)
return FALSE;
TouchEndPhysicallyActiveTouches(dev);
@@ -471,6 +487,13 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
flags[other->id] |= XISlaveDetached;
}
}
+
+ for (other = inputInfo.off_devices; other; other = other->next) {
+ if (!IsMaster(other) && GetMaster(other, MASTER_ATTACHED) == dev) {
+ AttachDevice(NULL, other, NULL);
+ flags[other->id] |= XISlaveDetached;
+ }
+ }
}
else {
for (other = inputInfo.devices; other; other = other->next) {
@@ -505,6 +528,9 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
LeaveWindow(dev);
SetFocusOut(dev);
+ for (prev = &inputInfo.devices;
+ *prev && (*prev != dev); prev = &(*prev)->next);
+
*prev = dev->next;
dev->next = inputInfo.off_devices;
inputInfo.off_devices = dev;
@@ -774,7 +800,7 @@ InitAndStartDevices(void)
/**
* Free the given device class and reset the pointer to NULL.
*/
-static void
+void
FreeDeviceClass(int type, void **class)
{
if (!(*class))
@@ -823,6 +849,14 @@ FreeDeviceClass(int type, void **class)
free((*t));
break;
}
+ case XIGestureClass:
+ {
+ GestureClassPtr *g = (GestureClassPtr *) class;
+
+ GestureFreeGestureInfo(&(*g)->gesture);
+ free((*g));
+ break;
+ }
case FocusClass:
{
FocusClassPtr *f = (FocusClassPtr *) class;
@@ -937,6 +971,7 @@ FreeAllDeviceClasses(ClassesPtr classes)
FreeDeviceClass(ButtonClass, (void *) &classes->button);
FreeDeviceClass(FocusClass, (void *) &classes->focus);
FreeDeviceClass(ProximityClass, (void *) &classes->proximity);
+ FreeDeviceClass(XIGestureClass, (void*) &classes->gesture);
FreeFeedbackClass(KbdFeedbackClass, (void *) &classes->kbdfeed);
FreeFeedbackClass(PtrFeedbackClass, (void *) &classes->ptrfeed);
@@ -1008,7 +1043,7 @@ CloseDevice(DeviceIntPtr dev)
free(dev->config_info); /* Allocated in xf86ActivateDevice. */
free(dev->last.scroll);
for (j = 0; j < dev->last.num_touches; j++)
- free(dev->last.touches[j].valuators);
+ valuator_mask_free(&dev->last.touches[j].valuators);
free(dev->last.touches);
dev->config_info = NULL;
dixFreePrivates(dev->devPrivates, PRIVATE_DEVICE);
@@ -1018,8 +1053,7 @@ CloseDevice(DeviceIntPtr dev)
/**
* Shut down all devices of one list and free all resources.
*/
-static
- void
+static void
CloseDeviceList(DeviceIntPtr *listHead)
{
/* Used to mark devices that we tried to free */
@@ -1065,6 +1099,11 @@ CloseDownDevices(void)
dev->master = NULL;
}
+ for (dev = inputInfo.off_devices; dev; dev = dev->next) {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ dev->master = NULL;
+ }
+
CloseDeviceList(&inputInfo.devices);
CloseDeviceList(&inputInfo.off_devices);
@@ -1121,6 +1160,26 @@ UndisplayDevices(void)
screen->DisplayCursor(dev, screen, NullCursor);
}
+static int
+CloseOneDevice(const DeviceIntPtr dev, DeviceIntPtr *listHead)
+{
+ DeviceIntPtr tmp, next, prev = NULL;
+
+ for (tmp = *listHead; tmp; (prev = tmp), (tmp = next)) {
+ next = tmp->next;
+ if (tmp == dev) {
+ if (prev == NULL)
+ *listHead = next;
+ else
+ prev->next = next;
+
+ CloseDevice(tmp);
+ return Success;
+ }
+ }
+ return BadMatch;
+}
+
/**
* Remove a device from the device list, closes it and thus frees all
* resources.
@@ -1137,12 +1196,12 @@ UndisplayDevices(void)
int
RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
{
- DeviceIntPtr prev, tmp, next;
int ret = BadMatch;
ScreenPtr screen = screenInfo.screens[0];
int deviceid;
int initialized;
int flags[MAXDEVICES] = { 0 };
+ int flag;
DebugF("(dix) removing device %d\n", dev->id);
@@ -1160,41 +1219,13 @@ RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
flags[dev->id] = XIDeviceDisabled;
}
- input_lock();
-
- prev = NULL;
- for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
- next = tmp->next;
- if (tmp == dev) {
-
- if (prev == NULL)
- inputInfo.devices = next;
- else
- prev->next = next;
+ flag = IsMaster(dev) ? XIMasterRemoved : XISlaveRemoved;
- flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
- CloseDevice(tmp);
- ret = Success;
- break;
- }
- }
-
- prev = NULL;
- for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
- next = tmp->next;
- if (tmp == dev) {
- flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
- CloseDevice(tmp);
-
- if (prev == NULL)
- inputInfo.off_devices = next;
- else
- prev->next = next;
+ input_lock();
- ret = Success;
- break;
- }
- }
+ if ((ret = CloseOneDevice(dev, &inputInfo.devices)) == Success ||
+ (ret = CloseOneDevice(dev, &inputInfo.off_devices)) == Success)
+ flags[deviceid] = flag;
input_unlock();
@@ -1322,6 +1353,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
ValuatorClassPtr valc;
BUG_RETURN_VAL(dev == NULL, FALSE);
+ BUG_RETURN_VAL(numAxes == 0, FALSE);
if (numAxes > MAX_VALUATORS) {
LogMessage(X_WARNING,
@@ -2526,6 +2558,8 @@ RecalculateMasterButtons(DeviceIntPtr slave)
if (master->button && master->button->numButtons != maxbuttons) {
int i;
+ int last_num_buttons = master->button->numButtons;
+
DeviceChangedEvent event = {
.header = ET_Internal,
.type = ET_DeviceChanged,
@@ -2536,6 +2570,14 @@ RecalculateMasterButtons(DeviceIntPtr slave)
};
master->button->numButtons = maxbuttons;
+ if (last_num_buttons < maxbuttons) {
+ master->button->xkb_acts = xnfreallocarray(master->button->xkb_acts,
+ maxbuttons,
+ sizeof(XkbAction));
+ memset(&master->button->xkb_acts[last_num_buttons],
+ 0,
+ (maxbuttons - last_num_buttons) * sizeof(XkbAction));
+ }
memcpy(&event.buttons.names, master->button->labels, maxbuttons *
sizeof(Atom));
@@ -2630,6 +2672,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
screen = miPointerGetScreen(dev);
screen->DeviceCursorCleanup(dev, screen);
free(dev->spriteInfo->sprite);
+ dev->spriteInfo->sprite = NULL;
}
dev->master = master;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 460296197..77d6217a7 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -74,7 +74,7 @@ Equipment Corporation.
******************************************************************/
/* XSERVER_DTRACE additions:
- * Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005-2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -101,21 +101,24 @@ Equipment Corporation.
#include <version-config.h>
#endif
-#ifdef PANORAMIX_DEBUG
-#include <stdio.h>
-int ProcInitialConnection();
-#endif
-
-#include "windowstr.h"
+#include <stddef.h>
#include <X11/fonts/fontstruct.h>
#include <X11/fonts/libxfont2.h>
+
+#include "dix/dix_priv.h"
+#include "dix/gc_priv.h"
+#include "dix/registry_priv.h"
+#include "dix/screenint_priv.h"
+#include "os/auth.h"
+#include "os/osdep.h"
+
+#include "windowstr.h"
#include "dixfontstr.h"
#include "gcstruct.h"
#include "selection.h"
#include "colormapst.h"
#include "cursorstr.h"
#include "scrnintstr.h"
-#include "opaque.h"
#include "input.h"
#include "servermd.h"
#include "extnsionst.h"
@@ -130,8 +133,10 @@ int ProcInitialConnection();
#include "client.h"
#include "xfixesint.h"
+// temporary workaround for win32/mingw32 name clash
+#undef CreateWindow
+
#ifdef XSERVER_DTRACE
-#include "registry.h"
#include "probes.h"
#endif
@@ -492,10 +497,10 @@ Dispatch(void)
if (!WaitForSomething(clients_are_ready()))
continue;
- /*****************
- * Handle events in round robin fashion, doing input between
- * each round
- *****************/
+ /*****************
+ * Handle events in round robin fashion, doing input between
+ * each round
+ *****************/
if (!dispatchException && clients_are_ready()) {
client = SmartScheduleClient();
@@ -638,11 +643,11 @@ CreateConnectionBlock(void)
if (!ConnectionInfo)
return FALSE;
- memmove(ConnectionInfo, (char *) &setup, sizeof(xConnSetup));
+ memcpy(ConnectionInfo, &setup, sizeof(xConnSetup));
sizesofar = sizeof(xConnSetup);
pBuf = ConnectionInfo + sizeof(xConnSetup);
- memmove(pBuf, VendorString, (int) setup.nbytesVendor);
+ memcpy(pBuf, VendorString, (size_t) setup.nbytesVendor);
sizesofar += setup.nbytesVendor;
pBuf += setup.nbytesVendor;
i = padding_for_int32(setup.nbytesVendor);
@@ -655,7 +660,7 @@ CreateConnectionBlock(void)
format.depth = screenInfo.formats[i].depth;
format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
format.scanLinePad = screenInfo.formats[i].scanlinePad;
- memmove(pBuf, (char *) &format, sizeof(xPixmapFormat));
+ memcpy(pBuf, &format, sizeof(xPixmapFormat));
pBuf += sizeof(xPixmapFormat);
sizesofar += sizeof(xPixmapFormat);
}
@@ -685,7 +690,7 @@ CreateConnectionBlock(void)
root.saveUnders = FALSE;
root.rootDepth = pScreen->rootDepth;
root.nDepths = pScreen->numDepths;
- memmove(pBuf, (char *) &root, sizeof(xWindowRoot));
+ memcpy(pBuf, &root, sizeof(xWindowRoot));
sizesofar += sizeof(xWindowRoot);
pBuf += sizeof(xWindowRoot);
@@ -702,7 +707,7 @@ CreateConnectionBlock(void)
pBuf += sizesofar;
depth.depth = pDepth->depth;
depth.nVisuals = pDepth->numVids;
- memmove(pBuf, (char *) &depth, sizeof(xDepth));
+ memcpy(pBuf, &depth, sizeof(xDepth));
pBuf += sizeof(xDepth);
sizesofar += sizeof(xDepth);
for (k = 0; k < pDepth->numVids; k++) {
@@ -716,7 +721,7 @@ CreateConnectionBlock(void)
visual.redMask = pVisual->redMask;
visual.greenMask = pVisual->greenMask;
visual.blueMask = pVisual->blueMask;
- memmove(pBuf, (char *) &visual, sizeof(xVisualType));
+ memcpy(pBuf, &visual, sizeof(xVisualType));
pBuf += sizeof(xVisualType);
sizesofar += sizeof(xVisualType);
}
@@ -765,7 +770,7 @@ ProcCreateWindow(ClientPtr client)
Mask mask = pWin->eventMask;
pWin->eventMask = 0; /* subterfuge in case AddResource fails */
- if (!AddResource(stuff->wid, RT_WINDOW, (void *) pWin))
+ if (!AddResource(stuff->wid, X11_RESTYPE_WINDOW, (void *) pWin))
return BadAlloc;
pWin->eventMask = mask;
}
@@ -830,7 +835,7 @@ ProcDestroyWindow(ClientPtr client)
DixRemoveAccess);
if (rc != Success)
return rc;
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
}
return Success;
}
@@ -1323,10 +1328,10 @@ ProcCloseFont(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupResourceByType((void **) &pFont, stuff->id, RT_FONT,
+ rc = dixLookupResourceByType((void **) &pFont, stuff->id, X11_RESTYPE_FONT,
client, DixDestroyAccess);
if (rc == Success) {
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
return Success;
}
else {
@@ -1511,13 +1516,13 @@ ProcCreatePixmap(ClientPtr client)
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
/* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
- pMap, RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, X11_RESTYPE_PIXMAP,
+ pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) {
(*pDraw->pScreen->DestroyPixmap) (pMap);
return rc;
}
- if (AddResource(stuff->pid, RT_PIXMAP, (void *) pMap))
+ if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap))
return Success;
}
return BadAlloc;
@@ -1532,10 +1537,10 @@ ProcFreePixmap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupResourceByType((void **) &pMap, stuff->id, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &pMap, stuff->id, X11_RESTYPE_PIXMAP,
client, DixDestroyAccess);
if (rc == Success) {
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
return Success;
}
else {
@@ -1569,7 +1574,7 @@ ProcCreateGC(ClientPtr client)
stuff->gc, client);
if (error != Success)
return error;
- if (!AddResource(stuff->gc, RT_GC, (void *) pGC))
+ if (!AddResource(stuff->gc, X11_RESTYPE_GC, (void *) pGC))
return BadAlloc;
return Success;
}
@@ -1684,7 +1689,7 @@ ProcFreeGC(ClientPtr client)
if (rc != Success)
return rc;
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
return Success;
}
@@ -2187,7 +2192,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
pBoundingDraw = &pPix->drawable;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
relx -= pPix->screen_x;
rely -= pPix->screen_y;
#endif
@@ -2467,12 +2472,12 @@ ProcFreeColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupResourceByType((void **) &pmap, stuff->id, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pmap, stuff->id, X11_RESTYPE_COLORMAP,
client, DixDestroyAccess);
if (rc == Success) {
/* Freeing a default colormap is a no-op */
if (!(pmap->flags & IsDefault))
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
return Success;
}
else {
@@ -2494,7 +2499,7 @@ ProcCopyColormapAndFree(ClientPtr client)
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
rc = dixLookupResourceByType((void **) &pSrcMap, stuff->srcCmap,
- RT_COLORMAP, client,
+ X11_RESTYPE_COLORMAP, client,
DixReadAccess | DixRemoveAccess);
if (rc == Success)
return CopyColormapAndFree(mid, pSrcMap, client->index);
@@ -2511,7 +2516,7 @@ ProcInstallColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->id, X11_RESTYPE_COLORMAP,
client, DixInstallAccess);
if (rc != Success)
goto out;
@@ -2540,7 +2545,7 @@ ProcUninstallColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->id, X11_RESTYPE_COLORMAP,
client, DixUninstallAccess);
if (rc != Success)
goto out;
@@ -2608,7 +2613,7 @@ ProcAllocColor(ClientPtr client)
REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq);
- rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorReply acr = {
@@ -2645,7 +2650,7 @@ ProcAllocNamedColor(ClientPtr client)
REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocNamedColorReply ancr = {
@@ -2653,7 +2658,7 @@ ProcAllocNamedColor(ClientPtr client)
.sequenceNumber = client->sequence,
.length = 0
};
- if (OsLookupColor
+ if (dixLookupBuiltinColor
(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
&ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) {
ancr.screenRed = ancr.exactRed;
@@ -2690,7 +2695,7 @@ ProcAllocColorCells(ClientPtr client)
REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
int npixels, nmasks;
@@ -2751,7 +2756,7 @@ ProcAllocColorPlanes(ClientPtr client)
REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorPlanesReply acpr;
@@ -2813,7 +2818,7 @@ ProcFreeColors(ClientPtr client)
REQUEST(xFreeColorsReq);
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixRemoveAccess);
if (rc == Success) {
int count;
@@ -2839,7 +2844,7 @@ ProcStoreColors(ClientPtr client)
REQUEST(xStoreColorsReq);
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixWriteAccess);
if (rc == Success) {
int count;
@@ -2865,13 +2870,17 @@ ProcStoreNamedColor(ClientPtr client)
REQUEST(xStoreNamedColorReq);
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixWriteAccess);
if (rc == Success) {
xColorItem def;
- if (OsLookupColor(pcmp->pScreen->myNum, (char *) &stuff[1],
- stuff->nbytes, &def.red, &def.green, &def.blue)) {
+ if (dixLookupBuiltinColor(pcmp->pScreen->myNum,
+ (char *) &stuff[1],
+ stuff->nbytes,
+ &def.red,
+ &def.green,
+ &def.blue)) {
def.flags = stuff->flags;
def.pixel = stuff->pixel;
return StoreColors(pcmp, 1, &def, client);
@@ -2893,7 +2902,7 @@ ProcQueryColors(ClientPtr client)
REQUEST(xQueryColorsReq);
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixReadAccess);
if (rc == Success) {
int count;
@@ -2940,14 +2949,17 @@ ProcLookupColor(ClientPtr client)
REQUEST(xLookupColorReq);
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
- rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixReadAccess);
if (rc == Success) {
CARD16 exactRed, exactGreen, exactBlue;
- if (OsLookupColor
- (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
- &exactRed, &exactGreen, &exactBlue)) {
+ if (dixLookupBuiltinColor(pcmp->pScreen->myNum,
+ (char *) &stuff[1],
+ stuff->nbytes,
+ &exactRed,
+ &exactGreen,
+ &exactBlue)) {
xLookupColorReply lcr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
@@ -2991,7 +3003,7 @@ ProcCreateCursor(ClientPtr client)
REQUEST_SIZE_MATCH(xCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
- rc = dixLookupResourceByType((void **) &src, stuff->source, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &src, stuff->source, X11_RESTYPE_PIXMAP,
client, DixReadAccess);
if (rc != Success) {
client->errorValue = stuff->source;
@@ -3003,7 +3015,7 @@ ProcCreateCursor(ClientPtr client)
/* Find and validate cursor mask pixmap, if one is provided */
if (stuff->mask != None) {
- rc = dixLookupResourceByType((void **) &msk, stuff->mask, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &msk, stuff->mask, X11_RESTYPE_PIXMAP,
client, DixReadAccess);
if (rc != Success) {
client->errorValue = stuff->mask;
@@ -3060,7 +3072,7 @@ ProcCreateCursor(ClientPtr client)
if (rc != Success)
goto bail;
- if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) {
+ if (!AddResource(stuff->cid, X11_RESTYPE_CURSOR, (void *) pCursor)) {
rc = BadAlloc;
goto bail;
}
@@ -3090,7 +3102,7 @@ ProcCreateGlyphCursor(ClientPtr client)
&pCursor, client, stuff->cid);
if (res != Success)
return res;
- if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor))
+ if (AddResource(stuff->cid, X11_RESTYPE_CURSOR, (void *) pCursor))
return Success;
return BadAlloc;
}
@@ -3104,10 +3116,10 @@ ProcFreeCursor(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupResourceByType((void **) &pCursor, stuff->id, RT_CURSOR,
+ rc = dixLookupResourceByType((void **) &pCursor, stuff->id, X11_RESTYPE_CURSOR,
client, DixDestroyAccess);
if (rc == Success) {
- FreeResource(stuff->id, RT_NONE);
+ FreeResource(stuff->id, X11_RESTYPE_NONE);
return Success;
}
else {
@@ -3657,11 +3669,11 @@ ProcInitialConnection(ClientPtr client)
prefix = (xConnClientPrefix *) ((char *)stuff + sz_xReq);
order = prefix->byteOrder;
if (order != 'l' && order != 'B' && order != 'r' && order != 'R')
- return client->noClientException = -1;
+ return client->noClientException = -1;
if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) ||
- (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) {
- client->swapped = TRUE;
- SwapConnClientPrefix(prefix);
+ (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) {
+ client->swapped = TRUE;
+ SwapConnClientPrefix(prefix);
}
stuff->reqType = 2;
stuff->length += bytes_to_int32(prefix->nbytesAuthProto) +
@@ -3670,7 +3682,7 @@ ProcInitialConnection(ClientPtr client)
swaps(&stuff->length);
}
if (order == 'r' || order == 'R') {
- client->local = FALSE;
+ client->local = FALSE;
}
ResetCurrentRequest(client);
return Success;
@@ -3771,28 +3783,30 @@ int
ProcEstablishConnection(ClientPtr client)
{
const char *reason;
- char *auth_proto, *auth_string;
xConnClientPrefix *prefix;
REQUEST(xReq);
prefix = (xConnClientPrefix *) ((char *) stuff + sz_xReq);
- auth_proto = (char *) prefix + sz_xConnClientPrefix;
- auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto);
- if ((client->req_len << 2) != sz_xReq + sz_xConnClientPrefix +
- pad_to_int32(prefix->nbytesAuthProto) +
- pad_to_int32(prefix->nbytesAuthString))
+ if (client->swapped && !AllowByteSwappedClients) {
+ reason = "Prohibited client endianess, see the Xserver man page ";
+ } else if ((client->req_len << 2) != sz_xReq + sz_xConnClientPrefix +
+ pad_to_int32(prefix->nbytesAuthProto) +
+ pad_to_int32(prefix->nbytesAuthString))
reason = "Bad length";
else if ((prefix->majorVersion != X_PROTOCOL) ||
(prefix->minorVersion != X_PROTOCOL_REVISION))
reason = "Protocol version mismatch";
- else
+ else {
+ char *auth_proto = (char *) prefix + sz_xConnClientPrefix;
+ char *auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto);
reason = ClientAuthorized(client,
(unsigned short) prefix->nbytesAuthProto,
auth_proto,
(unsigned short) prefix->nbytesAuthString,
auth_string);
+ }
return (SendConnSetup(client, reason));
}
@@ -3999,9 +4013,6 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
update_desktop_dimensions();
- dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR,
- 0);
-
return i;
}
@@ -4049,16 +4060,6 @@ AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
update_desktop_dimensions();
- /*
- * We cannot register the Screen PRIVATE_CURSOR key if cursors are already
- * created, because dix/privates.c does not have relocation code for
- * PRIVATE_CURSOR. Once this is fixed the if() can be removed and we can
- * register the Screen PRIVATE_CURSOR key unconditionally.
- */
- if (!dixPrivatesCreated(PRIVATE_CURSOR))
- dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen,
- PRIVATE_CURSOR, 0);
-
return i;
}
@@ -4079,7 +4080,7 @@ RemoveGPUScreen(ScreenPtr pScreen)
/* this gets freed later in the resource list, but without
* the screen existing it causes crashes - so remove it here */
if (pScreen->defColormap)
- FreeResource(pScreen->defColormap, RT_COLORMAP);
+ FreeResource(pScreen->defColormap, X11_RESTYPE_COLORMAP);
free(pScreen);
}
diff --git a/dix/dix_priv.h b/dix/dix_priv.h
new file mode 100644
index 000000000..4b3c9ba29
--- /dev/null
+++ b/dix/dix_priv.h
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_DIX_PRIV_H
+#define _XSERVER_DIX_PRIV_H
+
+#include <X11/Xdefs.h>
+
+/* This file holds global DIX settings to be used inside the Xserver,
+ * but NOT supposed to be accessed directly by external server modules like
+ * drivers or extension modules. Thus the definitions here are not part of the
+ * Xserver's module API/ABI.
+ */
+
+#include <X11/Xdefs.h>
+#include <X11/Xfuncproto.h>
+
+#include "include/dix.h"
+#include "include/gc.h"
+#include "include/window.h"
+
+/* server setting: maximum size for big requests */
+#define MAX_BIG_REQUEST_SIZE 4194303
+extern long maxBigRequestSize;
+
+extern char dispatchExceptionAtReset;
+extern int terminateDelay;
+extern Bool touchEmulatePointer;
+
+extern HWEventQueuePtr checkForInput[2];
+
+static inline _X_NOTSAN Bool
+InputCheckPending(void)
+{
+ return (*checkForInput[0] != *checkForInput[1]);
+}
+
+void ClearWorkQueue(void);
+void ProcessWorkQueue(void);
+void ProcessWorkQueueZombies(void);
+
+void CloseDownClient(ClientPtr client);
+ClientPtr GetCurrentClient(void);
+void InitClient(ClientPtr client, int i, void *ospriv);
+
+/* lookup builtin color by name */
+Bool dixLookupBuiltinColor(int screen,
+ char *name,
+ unsigned len,
+ unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue);
+
+void DeleteWindowFromAnySaveSet(WindowPtr pWin);
+
+#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, mode) \
+ do { \
+ int tmprc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY, mode); \
+ if (tmprc != Success) \
+ return tmprc; \
+ tmprc = dixLookupGC(&(pGC), stuff->gc, client, DixUseAccess); \
+ if (tmprc != Success) \
+ return tmprc; \
+ if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen)) \
+ return BadMatch; \
+ if (pGC->serialNumber != pDraw->serialNumber) \
+ ValidateGC(pDraw, pGC); \
+ } while (0)
+
+int dixLookupGC(GCPtr *result,
+ XID id,
+ ClientPtr client,
+ Mask access_mode);
+
+int dixLookupClient(ClientPtr *result,
+ XID id,
+ ClientPtr client,
+ Mask access_mode);
+
+#endif /* _XSERVER_DIX_PRIV_H */
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 58a385f71..914ceb7a3 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -52,9 +52,17 @@ Equipment Corporation.
#include <dix-config.h>
#endif
+#include <stddef.h>
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/libxfont2.h>
+
+#include "dix/dix_priv.h"
+#include "dix/gc_priv.h"
+#include "os/auth.h"
+
#include "scrnintstr.h"
#include "resource.h"
#include "dixstruct.h"
@@ -65,7 +73,6 @@ Equipment Corporation.
#include "closestr.h"
#include "dixfont.h"
#include "xace.h"
-#include <X11/fonts/libxfont2.h>
#ifdef XF86BIGFONT
#include "xf86bigfontsrv.h"
@@ -126,7 +133,7 @@ GetGlyphs(FontPtr font, unsigned long count, unsigned char *chars,
}
/*
- * adding RT_FONT prevents conflict with default cursor font
+ * adding RT_FONT / X11_RESTYPE_FONT prevents conflict with default cursor font
*/
Bool
SetDefaultFont(const char *defaultfontname)
@@ -140,7 +147,7 @@ SetDefaultFont(const char *defaultfontname)
(unsigned) strlen(defaultfontname), defaultfontname);
if (err != Success)
return FALSE;
- err = dixLookupResourceByType((void **) &pf, fid, RT_FONT, serverClient,
+ err = dixLookupResourceByType((void **) &pf, fid, X11_RESTYPE_FONT, serverClient,
DixReadAccess);
if (err != Success)
return FALSE;
@@ -293,7 +300,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
err = AllocError;
break;
}
- memmove(newname, alias, newlen);
+ memcpy(newname, alias, newlen);
c->fontname = newname;
c->fnamelen = newlen;
c->current_fpe = 0;
@@ -348,7 +355,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
}
}
}
- if (!AddResource(c->fontid, RT_FONT, (void *) pfont)) {
+ if (!AddResource(c->fontid, X11_RESTYPE_FONT, (void *) pfont)) {
err = AllocError;
goto bail;
}
@@ -401,7 +408,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname);
if (cached && cached->info.cachable) {
- if (!AddResource(fid, RT_FONT, (void *) cached))
+ if (!AddResource(fid, X11_RESTYPE_FONT, (void *) cached))
return BadAlloc;
cached->refcnt++;
return Success;
@@ -427,7 +434,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
free(c);
return BadAlloc;
}
- memmove(c->fontname, pfontname, lenfname);
+ memcpy(c->fontname, pfontname, lenfname);
for (i = 0; i < num_fpes; i++) {
c->fpe_list[i] = font_path_elements[i];
UseFPE(c->fpe_list[i]);
@@ -641,7 +648,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
free(resolved);
resolved = malloc(resolvedlen + 1);
if (resolved)
- memmove(resolved, tmpname, resolvedlen + 1);
+ memcpy(resolved, tmpname, resolvedlen + 1);
}
}
@@ -671,7 +678,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
* is BadFontName, indicating the alias resolution
* is complete.
*/
- memmove(tmp_pattern, resolved, resolvedlen);
+ memcpy(tmp_pattern, resolved, resolvedlen);
if (c->haveSaved) {
char *tmpname;
int tmpnamelen;
@@ -691,11 +698,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
free(c->savedName);
c->savedName = malloc(namelen + 1);
if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
+ memcpy(c->savedName, name, namelen + 1);
c->savedNameLen = namelen;
aliascount = 20;
}
- memmove(c->current.pattern, tmp_pattern, resolvedlen);
+ memcpy(c->current.pattern, tmp_pattern, resolvedlen);
c->current.patlen = resolvedlen;
c->current.max_names = c->names->nnames + 1;
c->current.current_fpe = -1;
@@ -766,7 +773,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
reply.nFonts--;
else {
*bufptr++ = names->length[i];
- memmove(bufptr, names->names[i], names->length[i]);
+ memcpy(bufptr, names->names[i], names->length[i]);
bufptr += names->length[i];
}
}
@@ -931,7 +938,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
free(c->savedName);
c->savedName = malloc(namelen + 1);
if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
+ memcpy(c->savedName, name, namelen + 1);
aliascount = 20;
}
memmove(c->current.pattern, name, namelen);
@@ -1150,7 +1157,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
fid = ((Font) *(c->pElt + 4)) /* big-endian */
|((Font) *(c->pElt + 3)) << 8
| ((Font) *(c->pElt + 2)) << 16 | ((Font) *(c->pElt + 1)) << 24;
- err = dixLookupResourceByType((void **) &pFont, fid, RT_FONT,
+ err = dixLookupResourceByType((void **) &pFont, fid, X11_RESTYPE_FONT,
client, DixUseAccess);
if (err != Success) {
/* restore pFont for step 4 (described below) */
@@ -1242,7 +1249,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
err = BadAlloc;
goto bail;
}
- memmove(new_closure->data, new_closure->pElt, len);
+ memcpy(new_closure->data, new_closure->pElt, len);
new_closure->pElt = new_closure->data;
new_closure->endReq = new_closure->pElt + len;
@@ -1430,7 +1437,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
err = BadAlloc;
goto bail;
}
- memmove(data, c->data, c->nChars * itemSize);
+ memcpy(data, c->data, c->nChars * itemSize);
c->data = data;
pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
@@ -1784,7 +1791,7 @@ GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result)
fpe = font_path_elements[i];
*c = fpe->name_length;
*length += *c++;
- memmove(c, fpe->name, fpe->name_length);
+ memcpy(c, fpe->name, fpe->name_length);
c += fpe->name_length;
}
*count = num_fpes;
@@ -1887,7 +1894,7 @@ find_old_font(XID id)
{
void *pFont;
- dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
+ dixLookupResourceByType(&pFont, id, X11_RESTYPE_NONE, serverClient, DixReadAccess);
return (FontPtr) pFont;
}
@@ -1900,13 +1907,13 @@ get_new_font_client_id(void)
static int
store_font_Client_font(FontPtr pfont, Font id)
{
- return AddResource(id, RT_NONE, (void *) pfont);
+ return AddResource(id, X11_RESTYPE_NONE, (void *) pfont);
}
static void
delete_font_client_id(Font id)
{
- FreeResource(id, RT_NONE);
+ FreeResource(id, X11_RESTYPE_NONE);
}
static int
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 331ccfb96..440b4d08c 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -86,14 +86,16 @@ Author: Adobe Systems Incorporated
#include <X11/X.h>
#include <X11/Xmd.h>
+
+#include "dix/callback_priv.h"
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "windowstr.h"
#include "dixstruct.h"
#include "pixmapstr.h"
#include "gcstruct.h"
#include "scrnintstr.h"
-#define XK_LATIN1
-#include <X11/keysymdef.h>
#include "xace.h"
/*
@@ -141,47 +143,6 @@ ClientTimeToServerTime(CARD32 c)
}
/*
- * ISO Latin-1 case conversion routine
- *
- * this routine always null-terminates the result, so
- * beware of too-small buffers
- */
-
-static unsigned char
-ISOLatin1ToLower(unsigned char source)
-{
- unsigned char dest;
-
- if ((source >= XK_A) && (source <= XK_Z))
- dest = source + (XK_a - XK_A);
- else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
- dest = source + (XK_agrave - XK_Agrave);
- else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
- dest = source + (XK_oslash - XK_Ooblique);
- else
- dest = source;
- return dest;
-}
-
-int
-CompareISOLatin1Lowered(const unsigned char *s1, int s1len,
- const unsigned char *s2, int s2len)
-{
- unsigned char c1, c2;
-
- for (;;) {
- /* note -- compare against zero so that -1 ignores len */
- c1 = s1len-- ? *s1++ : '\0';
- c2 = s2len-- ? *s2++ : '\0';
- if (!c1 ||
- (c1 != c2 &&
- (c1 = ISOLatin1ToLower(c1)) != (c2 = ISOLatin1ToLower(c2))))
- break;
- }
- return (int) c1 - (int) c2;
-}
-
-/*
* dixLookupWindow and dixLookupDrawable:
* Look up the window/drawable taking into account the client doing the
* lookup, the type of drawable desired, and the type of access desired.
@@ -236,7 +197,7 @@ dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
int
dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
{
- return dixLookupResourceByType((void **) pGC, id, RT_GC, client, access);
+ return dixLookupResourceByType((void **) pGC, id, X11_RESTYPE_GC, client, access);
}
int
@@ -246,11 +207,11 @@ dixLookupFontable(FontPtr *pFont, XID id, ClientPtr client, Mask access)
GC *pGC;
client->errorValue = id; /* EITHER font or gc */
- rc = dixLookupResourceByType((void **) pFont, id, RT_FONT, client,
+ rc = dixLookupResourceByType((void **) pFont, id, X11_RESTYPE_FONT, client,
access);
if (rc != BadFont)
return rc;
- rc = dixLookupResourceByType((void **) &pGC, id, RT_GC, client, access);
+ rc = dixLookupResourceByType((void **) &pGC, id, X11_RESTYPE_GC, client, access);
if (rc == BadGC)
return BadFont;
if (rc == Success)
@@ -525,6 +486,10 @@ ProcessWorkQueue(void)
{
WorkQueuePtr q, *p;
+ // don't have a work queue yet
+ if (!workQueue)
+ return;
+
p = &workQueue;
/*
* Scan the work queue once, calling each function. Those
@@ -732,6 +697,8 @@ _DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void *data)
return FALSE;
}
+static void DeleteCallbackList(CallbackListPtr *pcbl);
+
void
_CallCallbacks(CallbackListPtr *pcbl, void *call_data)
{
@@ -864,8 +831,7 @@ DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void *data)
return _DeleteCallback(pcbl, callback, data);
}
-void
-DeleteCallbackList(CallbackListPtr *pcbl)
+static void DeleteCallbackList(CallbackListPtr *pcbl)
{
if (!pcbl || !*pcbl)
return;
diff --git a/dix/enterleave.c b/dix/enterleave.c
index 867ec7436..6d1c24adc 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -32,12 +32,14 @@
#include <X11/extensions/XI2.h>
#include <X11/extensions/XIproto.h>
#include <X11/extensions/XI2proto.h>
+
+#include "dix/eventconvert.h"
+
#include "inputstr.h"
#include "windowstr.h"
#include "scrnintstr.h"
#include "exglobals.h"
#include "enterleave.h"
-#include "eventconvert.h"
#include "xkbsrv.h"
#include "inpututils.h"
@@ -615,9 +617,15 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
ev->type = DeviceValuator;
ev->deviceid = dev->id;
- ev->num_valuators = nval < 3 ? nval : 3;
+ ev->num_valuators = nval < 6 ? nval : 6;
ev->first_valuator = first;
switch (ev->num_valuators) {
+ case 6:
+ ev->valuator5 = v->axisVal[first + 5];
+ case 5:
+ ev->valuator4 = v->axisVal[first + 4];
+ case 4:
+ ev->valuator3 = v->axisVal[first + 3];
case 3:
ev->valuator2 = v->axisVal[first + 2];
case 2:
@@ -626,7 +634,6 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
ev->valuator0 = v->axisVal[first];
break;
}
- first += ev->num_valuators;
}
static void
@@ -646,7 +653,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
ev->num_buttons = b->numButtons;
memcpy((char *) ev->buttons, (char *) b->down, 4);
}
- else if (k) {
+ if (k) {
ev->classes_reported |= (1 << KeyClass);
ev->num_keys = k->xkbInfo->desc->max_key_code -
k->xkbInfo->desc->min_key_code;
@@ -670,14 +677,26 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
}
}
-
+/**
+ * The device state notify event is split across multiple 32-byte events.
+ * The first one contains the first 32 button state bits, the first 32
+ * key state bits, and the first 3 valuator values.
+ *
+ * If a device has more than that, the server sends out:
+ * - one deviceButtonStateNotify for buttons 32 and above
+ * - one deviceKeyStateNotify for keys 32 and above
+ * - one deviceValuator event per 6 valuators above valuator 4
+ *
+ * All events but the last one have the deviceid binary ORed with MORE_EVENTS,
+ */
static void
DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
{
+ /* deviceStateNotify, deviceKeyStateNotify, deviceButtonStateNotify
+ * and one deviceValuator for each 6 valuators */
+ deviceStateNotify sev[3 + (MAX_VALUATORS + 6)/6];
int evcount = 1;
- deviceStateNotify *ev, *sev;
- deviceKeyStateNotify *kev;
- deviceButtonStateNotify *bev;
+ deviceStateNotify *ev = sev;
KeyClassPtr k;
ButtonClassPtr b;
@@ -690,87 +709,53 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
if ((b = dev->button) != NULL) {
nbuttons = b->numButtons;
- if (nbuttons > 32)
+ if (nbuttons > 32) /* first 32 are encoded in deviceStateNotify */
evcount++;
}
if ((k = dev->key) != NULL) {
nkeys = k->xkbInfo->desc->max_key_code - k->xkbInfo->desc->min_key_code;
- if (nkeys > 32)
- evcount++;
- if (nbuttons > 0) {
+ if (nkeys > 32) /* first 32 are encoded in deviceStateNotify */
evcount++;
- }
}
if ((v = dev->valuator) != NULL) {
nval = v->numAxes;
-
- if (nval > 3)
- evcount++;
- if (nval > 6) {
- if (!(k && b))
- evcount++;
- if (nval > 9)
- evcount += ((nval - 7) / 3);
- }
+ /* first three are encoded in deviceStateNotify, then
+ * it's 6 per deviceValuator event */
+ evcount += ((nval - 3) + 6)/6;
}
- sev = ev = xallocarray(evcount, sizeof(xEvent));
- FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
-
- if (b != NULL) {
- FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
- first += 3;
- nval -= 3;
- if (nbuttons > 32) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- bev = (deviceButtonStateNotify *) ev++;
- bev->type = DeviceButtonStateNotify;
- bev->deviceid = dev->id;
- memcpy((char *) &bev->buttons[4], (char *) &b->down[4],
- DOWN_LENGTH - 4);
- }
- if (nval > 0) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
- first += 3;
- nval -= 3;
- }
+ BUG_RETURN(evcount <= ARRAY_SIZE(sev));
+
+ FixDeviceStateNotify(dev, ev, k, b, v, first);
+
+ if (b != NULL && nbuttons > 32) {
+ deviceButtonStateNotify *bev = (deviceButtonStateNotify *) ++ev;
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ bev->type = DeviceButtonStateNotify;
+ bev->deviceid = dev->id;
+ memcpy((char *) &bev->buttons[4], (char *) &b->down[4],
+ DOWN_LENGTH - 4);
}
- if (k != NULL) {
- FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
- first += 3;
- nval -= 3;
- if (nkeys > 32) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- kev = (deviceKeyStateNotify *) ev++;
- kev->type = DeviceKeyStateNotify;
- kev->deviceid = dev->id;
- memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
- }
- if (nval > 0) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
- first += 3;
- nval -= 3;
- }
+ if (k != NULL && nkeys > 32) {
+ deviceKeyStateNotify *kev = (deviceKeyStateNotify *) ++ev;
+ (ev - 1)->deviceid |= MORE_EVENTS;
+ kev->type = DeviceKeyStateNotify;
+ kev->deviceid = dev->id;
+ memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
}
+ first = 3;
+ nval -= 3;
while (nval > 0) {
- FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
- first += 3;
- nval -= 3;
- if (nval > 0) {
- (ev - 1)->deviceid |= MORE_EVENTS;
- FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
- first += 3;
- nval -= 3;
- }
+ ev->deviceid |= MORE_EVENTS;
+ FixDeviceValuator(dev, (deviceValuator *) ++ev, v, first);
+ first += 6;
+ nval -= 6;
}
DeliverEventsToWindow(dev, win, (xEvent *) sev, evcount,
DeviceStateNotifyMask, NullGrab);
- free(sev);
}
void
@@ -784,8 +769,9 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
- /* XI 2 event */
- btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
+ /* XI 2 event contains the logical button map - maps are CARD8
+ * so we need 256 bits for the possibly maximum mapping */
+ btlen = (mouse->button) ? bits_to_bytes(256) : 0;
btlen = bytes_to_int32(btlen);
len = sizeof(xXIFocusInEvent) + btlen * 4;
diff --git a/dix/enterleave.h b/dix/enterleave.h
index 4b833d8a3..e8af924c6 100644
--- a/dix/enterleave.h
+++ b/dix/enterleave.h
@@ -58,8 +58,6 @@ extern void DeviceFocusEvent(DeviceIntPtr dev,
extern void EnterWindow(DeviceIntPtr dev, WindowPtr win, int mode);
-extern void LeaveWindow(DeviceIntPtr dev);
-
extern void CoreFocusEvent(DeviceIntPtr kbd,
int type, int mode, int detail, WindowPtr pWin);
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 53b8c79e3..30cf86f0a 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -39,13 +39,14 @@
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
+#include "dix/eventconvert.h"
+
#include "dix.h"
#include "inputstr.h"
#include "misc.h"
#include "eventstr.h"
#include "exevents.h"
#include "exglobals.h"
-#include "eventconvert.h"
#include "inpututils.h"
#include "xiquerydevice.h"
#include "xkbsrv.h"
diff --git a/include/eventconvert.h b/dix/eventconvert.h
index cf425f7a9..a25eb782d 100644
--- a/include/eventconvert.h
+++ b/dix/eventconvert.h
@@ -22,21 +22,24 @@
*
*/
-#ifndef _EVENTCONVERT_H_
+#ifndef _XSERVER_EVENTCONVERT_H_
+#define _XSERVER_EVENTCONVERT_H_
+
#include <X11/X.h>
#include <X11/extensions/XIproto.h>
+
#include "input.h"
#include "events.h"
#include "eventstr.h"
-_X_EXPORT int EventToCore(InternalEvent *event, xEvent **core, int *count);
-_X_EXPORT int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
-_X_EXPORT int EventToXI2(InternalEvent *ev, xEvent **xi);
-_X_INTERNAL int GetCoreType(enum EventType type);
-_X_INTERNAL int GetXIType(enum EventType type);
-_X_INTERNAL int GetXI2Type(enum EventType type);
+int EventToCore(InternalEvent *event, xEvent **core, int *count);
+int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
+int EventToXI2(InternalEvent *ev, xEvent **xi);
+int GetCoreType(enum EventType type);
+int GetXIType(enum EventType type);
+int GetXI2Type(enum EventType type);
-_X_INTERNAL enum EventType GestureTypeToBegin(enum EventType type);
-_X_INTERNAL enum EventType GestureTypeToEnd(enum EventType type);
+enum EventType GestureTypeToBegin(enum EventType type);
+enum EventType GestureTypeToEnd(enum EventType type);
#endif /* _EVENTCONVERT_H_ */
diff --git a/dix/events.c b/dix/events.c
index 782ed35dc..f5a719a85 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -74,7 +74,7 @@ Equipment Corporation.
******************************************************************/
/*
- * Copyright (c) 2003-2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003-2005, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -106,9 +106,13 @@ Equipment Corporation.
#endif
#include <X11/X.h>
+#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+#include "dix/eventconvert.h"
+
#include "misc.h"
#include "resource.h"
-#include <X11/Xproto.h>
#include "windowstr.h"
#include "inputstr.h"
#include "inpututils.h"
@@ -145,7 +149,6 @@ Equipment Corporation.
#include "eventstr.h"
#include "enterleave.h"
-#include "eventconvert.h"
#include "mi.h"
/* Extension events type numbering starts at EXTENSION_EVENT_BASE. */
@@ -1215,7 +1218,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
qe->pScreen = pSprite->hotPhys.pScreen;
qe->months = currentTime.months;
qe->event = (InternalEvent *) (qe + 1);
- memcpy(qe->event, event, eventlen);
+ CopyPartialInternalEvent(qe->event, (InternalEvent *)event);
xorg_list_append(&qe->next, &syncEvents.pending);
}
@@ -3245,60 +3248,6 @@ WindowsRestructured(void)
}
}
-#ifdef PANORAMIX
-/* This was added to support reconfiguration under Xdmx. The problem is
- * that if the 0th screen (i.e., screenInfo.screens[0]) is moved to an origin
- * other than 0,0, the information in the private sprite structure must
- * be updated accordingly, or XYToWindow (and other routines) will not
- * compute correctly. */
-void
-ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
-{
- GrabPtr grab;
- DeviceIntPtr pDev;
- SpritePtr pSprite;
-
- if (noPanoramiXExtension)
- return;
-
- pDev = inputInfo.devices;
- while (pDev) {
- if (DevHasCursor(pDev)) {
- pSprite = pDev->spriteInfo->sprite;
- pSprite->hot.x -= xoff;
- pSprite->hot.y -= yoff;
-
- pSprite->hotPhys.x -= xoff;
- pSprite->hotPhys.y -= yoff;
-
- pSprite->hotLimits.x1 -= xoff;
- pSprite->hotLimits.y1 -= yoff;
- pSprite->hotLimits.x2 -= xoff;
- pSprite->hotLimits.y2 -= yoff;
-
- if (RegionNotEmpty(&pSprite->Reg1))
- RegionTranslate(&pSprite->Reg1, xoff, yoff);
- if (RegionNotEmpty(&pSprite->Reg2))
- RegionTranslate(&pSprite->Reg2, xoff, yoff);
-
- /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
- if ((grab = pDev->deviceGrab.grab) && grab->confineTo) {
- if (grab->confineTo->drawable.pScreen
- != pSprite->hotPhys.pScreen)
- pSprite->hotPhys.x = pSprite->hotPhys.y = 0;
- ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE);
- }
- else
- ConfineCursorToWindow(pDev,
- pSprite->hotPhys.pScreen->root,
- TRUE, FALSE);
-
- }
- pDev = pDev->next;
- }
-}
-#endif
-
/**
* Initialize a sprite for the given device and set it to some sane values. If
* the device already has a sprite alloc'd, don't realloc but just reset to
@@ -4585,7 +4534,7 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
check = (mask & ManagerMask);
if (check) {
rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
- RT_WINDOW, pWin, RT_NONE, NULL, DixManageAccess);
+ X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixManageAccess);
if (rc != Success)
return rc;
}
@@ -4610,7 +4559,7 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
if (SameClient(others, client)) {
check = others->mask;
if (mask == 0) {
- FreeResource(others->resource, RT_NONE);
+ FreeResource(others->resource, X11_RESTYPE_NONE);
return Success;
}
else
@@ -4628,7 +4577,7 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
others->resource = FakeClientID(client->index);
others->next = pWin->optional->otherClients;
pWin->optional->otherClients = others;
- if (!AddResource(others->resource, RT_OTHERCLIENT, (void *) pWin))
+ if (!AddResource(others->resource, X11_RESTYPE_OTHERCLIENT, (void *) pWin))
return BadAlloc;
}
maskSet:
@@ -5116,7 +5065,7 @@ ProcChangeActivePointerGrab(ClientPtr client)
newCursor = NullCursor;
else {
int rc = dixLookupResourceByType((void **) &newCursor, stuff->cursor,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (rc != Success) {
client->errorValue = stuff->cursor;
@@ -5233,7 +5182,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
if (curs == None)
cursor = NullCursor;
else {
- rc = dixLookupResourceByType((void **) &cursor, curs, RT_CURSOR,
+ rc = dixLookupResourceByType((void **) &cursor, curs, X11_RESTYPE_CURSOR,
client, DixUseAccess);
if (rc != Success) {
client->errorValue = curs;
@@ -5770,7 +5719,7 @@ ProcGrabButton(ClientPtr client)
cursor = NullCursor;
else {
rc = dixLookupResourceByType((void **) &cursor, stuff->cursor,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (rc != Success) {
client->errorValue = stuff->cursor;
return rc;
@@ -5957,9 +5906,9 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
if (pWin->dontPropagate)
DontPropagateRefCnts[pWin->dontPropagate]--;
while ((oc = wOtherClients(pWin)))
- FreeResource(oc->resource, RT_NONE);
+ FreeResource(oc->resource, X11_RESTYPE_NONE);
while ((passive = wPassiveGrabs(pWin)))
- FreeResource(passive->resource, RT_NONE);
+ FreeResource(passive->resource, X11_RESTYPE_NONE);
}
DeleteWindowFromAnyExtEvents(pWin, freeResources);
@@ -6024,7 +5973,7 @@ ProcRecolorCursor(ClientPtr client)
REQUEST(xRecolorCursorReq);
REQUEST_SIZE_MATCH(xRecolorCursorReq);
- rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor, RT_CURSOR,
+ rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor, X11_RESTYPE_CURSOR,
client, DixWriteAccess);
if (rc != Success) {
client->errorValue = stuff->cursor;
diff --git a/dix/extension.c b/dix/extension.c
index 9c158ba93..dbe6c0a97 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -50,6 +50,9 @@ SOFTWARE.
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/registry_priv.h"
+
#include "misc.h"
#include "dixstruct.h"
#include "extnsionst.h"
@@ -57,7 +60,6 @@ SOFTWARE.
#include "scrnintstr.h"
#include "dispatch.h"
#include "privates.h"
-#include "registry.h"
#include "xace.h"
#define LAST_ERROR 255
@@ -293,7 +295,7 @@ ProcListExtensions(ClientPtr client)
continue;
*bufptr++ = len = strlen(extensions[i]->name);
- memmove(bufptr, extensions[i]->name, len);
+ memcpy(bufptr, extensions[i]->name, len);
bufptr += len;
}
}
diff --git a/dix/gc.c b/dix/gc.c
index 4ccbd3b54..24444f49a 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -48,9 +48,13 @@ SOFTWARE.
#include <dix-config.h>
#endif
+#include <assert.h>
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
+
+#include "dix/gc_priv.h"
+
#include "misc.h"
#include "resource.h"
#include "gcstruct.h"
@@ -59,11 +63,9 @@ SOFTWARE.
#include "scrnintstr.h"
#include "region.h"
#include "dixstruct.h"
-
#include "privates.h"
#include "dix.h"
#include "xace.h"
-#include <assert.h>
extern FontPtr defaultFont;
@@ -421,10 +423,10 @@ static const struct {
RESTYPE type;
Mask access_mode;
} xidfields[] = {
- {GCTile, RT_PIXMAP, DixReadAccess},
- {GCStipple, RT_PIXMAP, DixReadAccess},
- {GCFont, RT_FONT, DixUseAccess},
- {GCClipMask, RT_PIXMAP, DixReadAccess},
+ {GCTile, X11_RESTYPE_PIXMAP, DixReadAccess},
+ {GCStipple, X11_RESTYPE_PIXMAP, DixReadAccess},
+ {GCFont, X11_RESTYPE_FONT, DixUseAccess},
+ {GCClipMask, X11_RESTYPE_PIXMAP, DixReadAccess},
};
int
@@ -547,8 +549,8 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
}
/* security creation/labeling check */
- *pStatus = XaceHook(XACE_RESOURCE_ACCESS, client, gcid, RT_GC, pGC,
- RT_NONE, NULL, DixCreateAccess | DixSetAttrAccess);
+ *pStatus = XaceHook(XACE_RESOURCE_ACCESS, client, gcid, X11_RESTYPE_GC, pGC,
+ X11_RESTYPE_NONE, NULL, DixCreateAccess | DixSetAttrAccess);
if (*pStatus != Success)
goto out;
@@ -770,14 +772,16 @@ FreeGC(void *value, XID gid)
GCPtr pGC = (GCPtr) value;
CloseFont(pGC->font, (Font) 0);
- (*pGC->funcs->DestroyClip) (pGC);
+ if (pGC->funcs)
+ (*pGC->funcs->DestroyClip) (pGC);
if (!pGC->tileIsPixel)
(*pGC->pScreen->DestroyPixmap) (pGC->tile.pixmap);
if (pGC->stipple)
(*pGC->pScreen->DestroyPixmap) (pGC->stipple);
- (*pGC->funcs->DestroyGC) (pGC);
+ if (pGC->funcs)
+ (*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash)
free(pGC->dash);
dixFreeObjectWithPrivates(pGC, PRIVATE_GC);
diff --git a/dix/gc_priv.h b/dix/gc_priv.h
new file mode 100644
index 000000000..18d5fefbe
--- /dev/null
+++ b/dix/gc_priv.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ * Copyright © 1987, 1998 The Open Group
+ */
+#ifndef _XSERVER_DIX_GC_PRIV_H
+#define _XSERVER_DIX_GC_PRIV_H
+
+#include "include/gc.h"
+
+int ChangeGCXIDs(ClientPtr client, GCPtr pGC, BITS32 mask, CARD32 * pval);
+
+GCPtr CreateGC(DrawablePtr pDrawable,
+ BITS32 mask,
+ XID *pval,
+ int *pStatus,
+ XID gcid,
+ ClientPtr client);
+
+int CopyGC(GCPtr pgcSrc, GCPtr pgcDst, BITS32 mask);
+
+int FreeGC(void *pGC, XID gid);
+
+void FreeGCperDepth(int screenNum);
+
+Bool CreateGCperDepth(int screenNum);
+
+Bool CreateDefaultStipple(int screenNum);
+
+void FreeDefaultStipple(int screenNum);
+
+int SetDashes(GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pdash);
+
+int VerifyRectOrder(int nrects, xRectangle *prects, int ordering);
+
+int SetClipRects(GCPtr pGC,
+ int xOrigin,
+ int yOrigin,
+ int nrects,
+ xRectangle *prects,
+ int ordering);
+
+#endif /* _XSERVER_DIX_GC_PRIV_H */
diff --git a/dix/gestures.c b/dix/gestures.c
index 593a4a67f..18f7b0f0d 100644
--- a/dix/gestures.c
+++ b/dix/gestures.c
@@ -27,6 +27,8 @@
#include <dix-config.h>
#endif
+#include "dix/eventconvert.h"
+
#include "inputstr.h"
#include "scrnintstr.h"
#include "dixgrabs.h"
@@ -35,7 +37,6 @@
#include "exevents.h"
#include "exglobals.h"
#include "inpututils.h"
-#include "eventconvert.h"
#include "windowstr.h"
#include "mi.h"
@@ -58,6 +59,12 @@ GestureInitGestureInfo(GestureInfoPtr gi)
return TRUE;
}
+void
+GestureFreeGestureInfo(GestureInfoPtr gi)
+{
+ free(gi->sprite.spriteTrace);
+}
+
/**
* Given an event type returns the associated gesture event info.
*/
@@ -194,8 +201,8 @@ GestureAddGrabListener(DeviceIntPtr dev, GestureInfoPtr gi, GrabPtr grab)
BUG_RETURN_MSG(1, "Unsupported grab type\n");
}
- /* grab listeners are always RT_NONE since we keep the grab pointer */
- GestureAddListener(gi, grab->resource, RT_NONE, type, grab->window, grab);
+ /* grab listeners are always X11_RESTYPE_NONE since we keep the grab pointer */
+ GestureAddListener(gi, grab->resource, X11_RESTYPE_NONE, type, grab->window, grab);
}
/**
diff --git a/dix/getevents.c b/dix/getevents.c
index 32bafe285..c39ef3371 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1247,19 +1247,18 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
}
static void
-storeLastValuators(DeviceIntPtr dev, ValuatorMask *mask,
- int xaxis, int yaxis, double devx, double devy)
+storeLastValuators(DeviceIntPtr dev, ValuatorMask *mask, double devx, double devy)
{
int i;
/* store desktop-wide in last.valuators */
- if (valuator_mask_isset(mask, xaxis))
+ if (valuator_mask_isset(mask, 0))
dev->last.valuators[0] = devx;
- if (valuator_mask_isset(mask, yaxis))
+ if (valuator_mask_isset(mask, 1))
dev->last.valuators[1] = devy;
for (i = 0; i < valuator_mask_size(mask); i++) {
- if (i == xaxis || i == yaxis)
+ if (i == 0 || i == 1)
continue;
if (valuator_mask_isset(mask, i))
@@ -1448,7 +1447,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
clipValuators(pDev, &mask);
- storeLastValuators(pDev, &mask, 0, 1, devx, devy);
+ storeLastValuators(pDev, &mask, devx, devy);
/* Update the MD's coordinates, which are always in desktop space. */
if (!IsMaster(pDev) && !IsFloating(pDev)) {
@@ -1501,7 +1500,8 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
* @param type The real type of the event
* @param axis The axis number to generate events for
* @param mask State before this event in absolute coords
- * @param[in,out] last Last scroll state posted in absolute coords (modified
+ * @param last_valuators The device's last valuators value
+ * @param[in,out] lastScroll Last scroll state posted in absolute coords (modified
* in-place)
* @param ms Current time in ms
* @param max_events Max number of events to be generated
@@ -1513,15 +1513,19 @@ emulate_scroll_button_events(InternalEvent *events,
int type,
int axis,
const ValuatorMask *mask,
- ValuatorMask *last, CARD32 ms, int max_events)
+ const ValuatorMask *last_valuators,
+ ValuatorMask *lastScroll, CARD32 ms, int max_events)
{
AxisInfoPtr ax;
double delta;
double incr;
+ int direction = 0; /* -1 for up, 1 for down */
int num_events = 0;
- double total;
int b;
int flags = 0;
+ double last_val, /* abs axis value from previous event */
+ current_val, /* abs axis value for this event */
+ last_scroll_val; /* abs axis value we sent out the last scroll button for */
if (dev->valuator->axes[axis].scroll.type == SCROLL_TYPE_NONE)
return 0;
@@ -1539,25 +1543,73 @@ emulate_scroll_button_events(InternalEvent *events,
if (type != ButtonPress && type != ButtonRelease)
flags |= POINTER_EMULATED;
- if (!valuator_mask_isset(last, axis))
- valuator_mask_set_double(last, axis, 0);
+ if (!valuator_mask_isset(lastScroll, axis))
+ valuator_mask_set_double(lastScroll, axis, 0);
- delta =
- valuator_mask_get_double(mask, axis) - valuator_mask_get_double(last,
- axis);
- total = delta;
- b = (ax->scroll.type == SCROLL_TYPE_VERTICAL) ? 5 : 7;
+ /* The delta between the last value we sent a scroll button event for
+ * and the current event value (which has been applied already in
+ * fill_pointer_events). This tells us the scroll direction. */
+ delta = valuator_mask_get_double(mask, axis) - valuator_mask_get_double(lastScroll, axis);
+ direction = delta * incr > 0 ? 1 : -1;
- if ((incr > 0 && delta < 0) || (incr < 0 && delta > 0))
+ b = (ax->scroll.type == SCROLL_TYPE_VERTICAL) ? 5 : 7;
+ if (direction < 0)
b--; /* we're scrolling up or left → button 4 or 6 */
- while (fabs(delta) >= fabs(incr)) {
- int nev_tmp;
+ /* Note: we emulate scroll on multiples of the increment, regardless of the
+ * current delta, mostly for the benefit of Xwayland which doesn't (cannot)
+ * distinguish between devices, see #1339 and #1414.
+ *
+ * Where a device scrolls a fraction of an increment, a subsequent scroll in
+ * the other direction did not trigger a scroll event. For example, where
+ * the increment is 1.0, the current axis value is 3.0 and a device scrolls
+ * down by 0.7 (a), then up by -1.0 (b), no scroll event was emitted:
+ * -----|------b--|------a--|----
+ * 2.0 3.0 4.0
+ * For both events, the last button was sent at 3.0 and since the delta
+ * from that is never a full increment, no events were generated.
+ * With Xwayland this can happen when we switch between smooth-scroll
+ * devices and discrete devices.
+ *
+ * To avoid this, we now emulate button events whenever we cross a multiple
+ * of the scroll increment. For example, for a scroll increment of 1.0
+ * we expect events at -2.0, -1.0, 0.0, 1.0, 2.0,...
+ *
+ * In the above example, we go from 3.0 to 3.7 (no scroll button event),
+ * then from 3.7 to 2.7 which triggers a scroll button event because we
+ * cross 3.0.
+ *
+ * This trades off one bug for another. Previously, the first scroll button
+ * event after changing direction was always between
+ * [increment, 2 * increment). Above example again: the first event would be
+ * emulated at 2.0 so the full movement before a button event was actually
+ * -1.7.
+ *
+ * Now, the first scroll button event is always between (0.0, increment).
+ * Above example again: the first event would be emulated at 3.0
+ * so the full movement before a button event was actually -0.7.
+ *
+ * This only affects changes of directions. Above example again: the next
+ * button event in-direction would've been emulated at 4.0 so only 0.3
+ * from the current position.
+ */
+ last_val = valuator_mask_get_double(last_valuators, axis);
+ last_scroll_val = valuator_mask_get_double(lastScroll, axis);
+ current_val = valuator_mask_get_double(mask, axis);
+
+ /* We're crossing an increment multiple? */
+ if ((current_val < last_scroll_val && last_scroll_val < last_val) ||
+ (last_val < last_scroll_val && last_scroll_val < current_val)) {
+ last_scroll_val -= direction * incr;
+ }
- if (delta > 0)
- delta -= fabs(incr);
- else if (delta < 0)
- delta += fabs(incr);
+ while (TRUE) {
+ /* The next value we want to send out a button event for */
+ double next_val = last_scroll_val + direction * incr;
+
+ if ((((direction > 0 && incr > 0) || (direction < 0 && incr < 0)) && (next_val > current_val)) ||
+ (((direction > 0 && incr < 0) || (direction < 0 && incr > 0)) && (next_val < current_val)))
+ break;
/* fill_pointer_events() generates four events: one normal and one raw
* event for button press and button release.
@@ -1565,6 +1617,8 @@ emulate_scroll_button_events(InternalEvent *events,
* for. In that case, we keep decreasing delta, but skip events.
*/
if (num_events + 4 < max_events) {
+ int nev_tmp;
+
if (type != ButtonRelease) {
nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms,
flags, NULL);
@@ -1578,14 +1632,11 @@ emulate_scroll_button_events(InternalEvent *events,
num_events += nev_tmp;
}
}
+ /* send out scroll event */
+ last_scroll_val = next_val;
}
- /* We emulated, update last.scroll */
- if (total != delta) {
- total -= delta;
- valuator_mask_set_double(last, axis,
- valuator_mask_get_double(last, axis) + total);
- }
+ valuator_mask_set_double(lastScroll, axis, last_scroll_val);
return num_events;
}
@@ -1615,6 +1666,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
{
CARD32 ms = GetTimeInMillis();
int num_events = 0, nev_tmp;
+ ValuatorMask last_valuators;
ValuatorMask mask;
ValuatorMask scroll;
int i;
@@ -1643,6 +1695,12 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
valuator_mask_copy(&mask, mask_in);
+ /* Back up the current value of last.valuators. fill_pointer_events()
+ * overwrites those but we need them for scroll button emulation */
+ valuator_mask_zero(&last_valuators);
+ for (size_t idx = 0; idx < pDev->last.numValuators; idx++)
+ valuator_mask_set_double(&last_valuators, idx, pDev->last.valuators[idx]);
+
/* Turn a scroll button press into a smooth-scrolling event if
* necessary. This only needs to cater for the XIScrollFlagPreferred
* axis (if more than one scrolling axis is present) */
@@ -1713,7 +1771,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
nev_tmp =
emulate_scroll_button_events(events, pDev, realtype, i, &scroll,
- pDev->last.scroll, ms,
+ &last_valuators, pDev->last.scroll, ms,
GetMaximumEventsNum() - num_events);
events += nev_tmp;
num_events += nev_tmp;
@@ -2008,7 +2066,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
clipValuators(dev, &mask);
if (emulate_pointer)
- storeLastValuators(dev, &mask, 0, 1, devx, devy);
+ storeLastValuators(dev, &mask, devx, devy);
/* Update the MD's coordinates, which are always in desktop space. */
if (emulate_pointer && !IsMaster(dev) && !IsFloating(dev)) {
diff --git a/dix/globals.c b/dix/globals.c
index 4b8b52e29..65edfc11f 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -50,6 +50,9 @@ SOFTWARE.
#include <X11/X.h>
#include <X11/Xmd.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "windowstr.h"
#include "scrnintstr.h"
diff --git a/dix/grabs.c b/dix/grabs.c
index 53ba1d6b9..bc8fd69bb 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -53,6 +53,10 @@ SOFTWARE.
#include "misc.h"
#include <X11/Xproto.h>
#include <X11/extensions/XI2.h>
+
+#include "dix/dix_priv.h"
+#include "os/auth.h"
+
#include "windowstr.h"
#include "inputstr.h"
#include "cursorstr.h"
@@ -563,7 +567,7 @@ AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab)
pGrab->next = pGrab->window->optional->passiveGrabs;
pGrab->window->optional->passiveGrabs = pGrab;
- if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (void *) pGrab))
+ if (AddResource(pGrab->resource, X11_RESTYPE_PASSIVEGRAB, (void *) pGrab))
return Success;
return BadAlloc;
}
@@ -660,7 +664,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
FreeGrab(pNewGrab);
ok = FALSE;
}
- else if (!AddResource(pNewGrab->resource, RT_PASSIVEGRAB,
+ else if (!AddResource(pNewGrab->resource, X11_RESTYPE_PASSIVEGRAB,
(void *) pNewGrab))
ok = FALSE;
else
@@ -677,13 +681,13 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
if (!ok) {
for (i = 0; i < nadds; i++)
- FreeResource(adds[i]->resource, RT_NONE);
+ FreeResource(adds[i]->resource, X11_RESTYPE_NONE);
for (i = 0; i < nups; i++)
free(details[i]);
}
else {
for (i = 0; i < ndels; i++)
- FreeResource(deletes[i]->resource, RT_NONE);
+ FreeResource(deletes[i]->resource, X11_RESTYPE_NONE);
for (i = 0; i < nadds; i++) {
grab = adds[i];
grab->next = grab->window->optional->passiveGrabs;
diff --git a/dix/main.c b/dix/main.c
index bfc8addbe..09341f34e 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -82,6 +82,16 @@ Equipment Corporation.
#include <X11/Xos.h> /* for unistd.h */
#include <X11/Xproto.h>
#include <pixman.h>
+
+#include "dix/callback_priv.h"
+#include "dix/dix_priv.h"
+#include "dix/gc_priv.h"
+#include "dix/registry_priv.h"
+#include "os/audit.h"
+#include "os/auth.h"
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include "scrnintstr.h"
#include "misc.h"
#include "os.h"
@@ -103,7 +113,6 @@ Equipment Corporation.
#include "dixfont.h"
#include "extnsionst.h"
#include "privates.h"
-#include "registry.h"
#include "client.h"
#include "exevents.h"
#ifdef PANORAMIX
@@ -195,8 +204,8 @@ dix_main(int argc, char *argv[], char *envp[])
for (i = 0; i < screenInfo.numGPUScreens; i++) {
ScreenPtr pScreen = screenInfo.gpuscreens[i];
- if (!CreateScratchPixmapsForScreen(pScreen))
- FatalError("failed to create scratch pixmaps");
+ if (!PixmapScreenInit(pScreen))
+ FatalError("failed to create screen pixmap properties");
if (pScreen->CreateScreenResources &&
!(*pScreen->CreateScreenResources) (pScreen))
FatalError("failed to create screen resources");
@@ -205,8 +214,8 @@ dix_main(int argc, char *argv[], char *envp[])
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
- if (!CreateScratchPixmapsForScreen(pScreen))
- FatalError("failed to create scratch pixmaps");
+ if (!PixmapScreenInit(pScreen))
+ FatalError("failed to create screen pixmap properties");
if (pScreen->CreateScreenResources &&
!(*pScreen->CreateScreenResources) (pScreen))
FatalError("failed to create screen resources");
@@ -305,7 +314,6 @@ dix_main(int argc, char *argv[], char *envp[])
for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
ScreenPtr pScreen = screenInfo.gpuscreens[i];
- FreeScratchPixmapsForScreen(pScreen);
dixFreeScreenSpecificPrivates(pScreen);
(*pScreen->CloseScreen) (pScreen);
dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
@@ -314,7 +322,6 @@ dix_main(int argc, char *argv[], char *envp[])
}
for (i = screenInfo.numScreens - 1; i >= 0; i--) {
- FreeScratchPixmapsForScreen(screenInfo.screens[i]);
FreeGCperDepth(i);
FreeDefaultStipple(i);
dixFreeScreenSpecificPrivates(screenInfo.screens[i]);
diff --git a/dix/meson.build b/dix/meson.build
index fbbcf8646..0b5cfbf8f 100644
--- a/dix/meson.build
+++ b/dix/meson.build
@@ -1,6 +1,7 @@
srcs_dix = [
'atom.c',
'colormap.c',
+ 'color.c',
'cursor.c',
'devices.c',
'dispatch.c',
diff --git a/dix/pixmap.c b/dix/pixmap.c
index 5a0146bbb..a58795c78 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -44,8 +44,13 @@ from The Open Group.
#include "picturestr.h"
#include "randrstr.h"
/*
- * Scratch pixmap management and device independent pixmap allocation
- * function.
+ * Scratch pixmap APIs are provided for source and binary compatability. In
+ * older versions, DIX would store a freed scratch pixmap for future use. This
+ * optimization is not really that impactful on modern systems with decent
+ * system heap management and modern CPUs, and it interferes with memory
+ * analysis tools such as ASan, malloc history, etc.
+ *
+ * Now, these entry points just allocte/free pixmaps.
*/
/* callable by ddx */
@@ -53,14 +58,7 @@ PixmapPtr
GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
int bitsPerPixel, int devKind, void *pPixData)
{
- PixmapPtr pPixmap = pScreen->pScratchPixmap;
-
- if (pPixmap)
- pScreen->pScratchPixmap = NULL;
- else
- /* width and height of 0 means don't allocate any pixmap data */
- pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0);
-
+ PixmapPtr pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0);
if (pPixmap) {
if ((*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth,
bitsPerPixel, devKind, pPixData))
@@ -76,17 +74,13 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap)
{
if (pPixmap) {
ScreenPtr pScreen = pPixmap->drawable.pScreen;
-
- pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
- if (pScreen->pScratchPixmap)
- (*pScreen->DestroyPixmap) (pPixmap);
- else
- pScreen->pScratchPixmap = pPixmap;
+ pPixmap->devPrivate.ptr = NULL; /* help catch/avoid heap-use-after-free */
+ (*pScreen->DestroyPixmap)(pPixmap);
}
}
Bool
-CreateScratchPixmapsForScreen(ScreenPtr pScreen)
+PixmapScreenInit(ScreenPtr pScreen)
{
unsigned int pixmap_size;
@@ -94,17 +88,9 @@ CreateScratchPixmapsForScreen(ScreenPtr pScreen)
pScreen->totalPixmapSize =
BitmapBytePad(pixmap_size * 8);
- /* let it be created on first use */
- pScreen->pScratchPixmap = NULL;
return TRUE;
}
-void
-FreeScratchPixmapsForScreen(ScreenPtr pScreen)
-{
- FreeScratchPixmapHeader(pScreen->pScratchPixmap);
-}
-
/* callable by ddx */
PixmapPtr
AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
@@ -262,12 +248,11 @@ PixmapStopDirtyTracking(DrawablePtr src, PixmapPtr secondary_dst)
return TRUE;
}
-static void
-PixmapDirtyCopyArea(PixmapPtr dst,
- PixmapDirtyUpdatePtr dirty,
+void
+PixmapDirtyCopyArea(PixmapPtr dst, DrawablePtr src,
+ int x, int y, int dst_x, int dst_y,
RegionPtr dirty_region)
{
- DrawablePtr src = dirty->src;
ScreenPtr pScreen = src->pScreen;
int n;
BoxPtr b;
@@ -294,9 +279,8 @@ PixmapDirtyCopyArea(PixmapPtr dst,
h = dst_box.y2 - dst_box.y1;
pGC->ops->CopyArea(src, &dst->drawable, pGC,
- dirty->x + dst_box.x1, dirty->y + dst_box.y1, w, h,
- dirty->dst_x + dst_box.x1,
- dirty->dst_y + dst_box.y1);
+ x + dst_box.x1, y + dst_box.y1, w, h,
+ dst_x + dst_box.x1, dst_y + dst_box.y1);
b++;
}
FreeScratchGC(pGC);
@@ -408,7 +392,8 @@ Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty)
RegionTranslate(&pixregion, -dirty->x, -dirty->y);
if (!pScreen->root || dirty->rotation == RR_Rotate_0)
- PixmapDirtyCopyArea(dst, dirty, &pixregion);
+ PixmapDirtyCopyArea(dst, dirty->src, dirty->x, dirty->y,
+ dirty->dst_x, dirty->dst_y, &pixregion);
else
PixmapDirtyCompositeRotate(dst, dirty, &pixregion);
pScreen->SourceValidate = SourceValidate;
diff --git a/dix/privates.c b/dix/privates.c
index 71a72fb22..01686637c 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -257,7 +257,7 @@ fixupDefaultColormaps(FixupFunc fixup, unsigned bytes)
ColormapPtr cmap;
dixLookupResourceByType((void **) &cmap,
- screenInfo.screens[s]->defColormap, RT_COLORMAP,
+ screenInfo.screens[s]->defColormap, X11_RESTYPE_COLORMAP,
serverClient, DixCreateAccess);
if (cmap &&
!fixup(&cmap->devPrivates, screenInfo.screens[s]->screenSpecificPrivates[PRIVATE_COLORMAP].offset, bytes))
@@ -552,7 +552,7 @@ dixFreePrivates(PrivatePtr privates, DevPrivateType type)
/*
* Return size of privates for the specified type
*/
-extern _X_EXPORT int
+int
dixPrivatesSize(DevPrivateType type)
{
assert(type >= PRIVATE_SCREEN);
@@ -564,13 +564,13 @@ dixPrivatesSize(DevPrivateType type)
/* Table of devPrivates offsets */
static const int offsets[] = {
- -1, /* RT_NONE */
- offsetof(WindowRec, devPrivates), /* RT_WINDOW */
- offsetof(PixmapRec, devPrivates), /* RT_PIXMAP */
- offsetof(GC, devPrivates), /* RT_GC */
- -1, /* RT_FONT */
- offsetof(CursorRec, devPrivates), /* RT_CURSOR */
- offsetof(ColormapRec, devPrivates), /* RT_COLORMAP */
+ -1, /* X11_RESTYPE_NONE */
+ offsetof(WindowRec, devPrivates), /* X11_RESTYPE_WINDOW */
+ offsetof(PixmapRec, devPrivates), /* X11_RESTYPE_PIXMAP */
+ offsetof(GC, devPrivates), /* X11_RESTYPE_GC */
+ -1, /* X11_RESTYPE_FONT */
+ offsetof(CursorRec, devPrivates), /* X11_RESTYPE_CURSOR */
+ offsetof(ColormapRec, devPrivates), /* X11_RESTYPE_COLORMAP */
};
int
@@ -581,10 +581,10 @@ dixLookupPrivateOffset(RESTYPE type)
* points at pixmaps (thanks, DBE)
*/
if (type & RC_DRAWABLE) {
- if (type == RT_WINDOW)
- return offsets[RT_WINDOW & TypeMask];
+ if (type == X11_RESTYPE_WINDOW)
+ return offsets[X11_RESTYPE_WINDOW & TypeMask];
else
- return offsets[RT_PIXMAP & TypeMask];
+ return offsets[X11_RESTYPE_PIXMAP & TypeMask];
}
type = type & TypeMask;
if (type < ARRAY_SIZE(offsets))
@@ -596,7 +596,7 @@ dixLookupPrivateOffset(RESTYPE type)
* Screen-specific privates
*/
-extern _X_EXPORT Bool
+Bool
dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key,
DevPrivateType type, unsigned size)
{
diff --git a/dix/property.c b/dix/property.c
index 94ef5a0ec..22f4d1603 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -50,6 +50,9 @@ SOFTWARE.
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+
#include "windowstr.h"
#include "propertyst.h"
#include "dixstruct.h"
@@ -205,7 +208,8 @@ ProcChangeProperty(ClientPtr client)
WindowPtr pWin;
char format, mode;
unsigned long len;
- int sizeInBytes, totalSize, err;
+ int sizeInBytes, err;
+ uint64_t totalSize;
REQUEST(xChangePropertyReq);
diff --git a/dix/protocol.txt b/dix/protocol.txt
index a1bf93652..189ad5d40 100644
--- a/dix/protocol.txt
+++ b/dix/protocol.txt
@@ -51,24 +51,6 @@ R003 DAMAGE:Subtract
R004 DAMAGE:Add
V000 DAMAGE:Notify
E000 DAMAGE:BadDamage
-R000 DMX:DMXQueryVersion
-R001 DMX:DMXGetScreenCount
-R002 DMX:DMXGetScreenInfoDEPRECATED
-R003 DMX:DMXGetWindowAttributes
-R004 DMX:DMXGetInputCount
-R005 DMX:DMXGetInputAttributes
-R006 DMX:DMXForceWindowCreationDEPRECATED
-R007 DMX:DMXReconfigureScreenDEPRECATED
-R008 DMX:DMXSync
-R009 DMX:DMXForceWindowCreation
-R010 DMX:DMXGetScreenAttributes
-R011 DMX:DMXChangeScreensAttributes
-R012 DMX:DMXAddScreen
-R013 DMX:DMXRemoveScreen
-R014 DMX:DMXGetDesktopAttributes
-R015 DMX:DMXChangeDesktopAttributes
-R016 DMX:DMXAddInput
-R017 DMX:DMXRemoveInput
R000 DOUBLE-BUFFER:GetVersion
R001 DOUBLE-BUFFER:AllocateBackBufferName
R002 DOUBLE-BUFFER:DeallocateBackBufferName
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 632971ed9..5166288e8 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -27,6 +27,9 @@
#endif
#include <math.h>
+
+#include "dix/ptrveloc_priv.h"
+
#include <ptrveloc.h>
#include <exevents.h>
#include <X11/Xatom.h>
@@ -89,11 +92,12 @@ DeletePredictableAccelerationProperties(DeviceIntPtr,
/* some int which is not a profile number */
#define PROFILE_UNINITIALIZE (-100)
+static int SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
+
/**
* Init DeviceVelocity struct so it should match the average case
*/
-void
-InitVelocityData(DeviceVelocityPtr vel)
+static void InitVelocityData(DeviceVelocityPtr vel)
{
memset(vel, 0, sizeof(DeviceVelocityRec));
@@ -113,8 +117,7 @@ InitVelocityData(DeviceVelocityPtr vel)
/**
* Clean up DeviceVelocityRec
*/
-void
-FreeVelocityData(DeviceVelocityPtr vel)
+static void FreeVelocityData(DeviceVelocityPtr vel)
{
free(vel->tracker);
SetAccelerationProfile(vel, PROFILE_UNINITIALIZE);
@@ -688,8 +691,7 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t)
* Perform velocity approximation based on 2D 'mickeys' (mouse motion delta).
* return true if non-visible state reset is suggested
*/
-BOOL
-ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time)
+static BOOL ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time)
{
double velocity;
@@ -748,10 +750,11 @@ ApplyConstantDeceleration(DeviceVelocityPtr vel, double *fdx, double *fdy)
/*
* compute the acceleration for given velocity and enforce min_acceleration
*/
-double
-BasicComputeAcceleration(DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- double velocity, double threshold, double acc)
+static double BasicComputeAcceleration(DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ double velocity,
+ double threshold,
+ double acc)
{
double result;
@@ -1011,8 +1014,7 @@ GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num)
*
* returns FALSE if profile number is unavailable, TRUE otherwise.
*/
-int
-SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num)
+static int SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num)
{
PointerAccelerationProfileFunc profile;
diff --git a/dix/ptrveloc_priv.h b/dix/ptrveloc_priv.h
new file mode 100644
index 000000000..a96401b90
--- /dev/null
+++ b/dix/ptrveloc_priv.h
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 2006-2011 Simon Thum simon dot thum at gmx dot de
+ */
+#ifndef _XSERVER_POINTERVELOCITY_PRIV_H
+#define _XSERVER_POINTERVELOCITY_PRIV_H
+
+#include <input.h>
+
+#include "ptrveloc.h"
+
+/* fwd */
+struct _DeviceVelocityRec;
+
+/**
+ * profile
+ * returns actual acceleration depending on velocity, acceleration control,...
+ */
+typedef double (*PointerAccelerationProfileFunc)
+ (DeviceIntPtr dev, struct _DeviceVelocityRec * vel,
+ double velocity, double threshold, double accelCoeff);
+
+/**
+ * a motion history, with just enough information to
+ * calc mean velocity and decide which motion was along
+ * a more or less straight line
+ */
+typedef struct _MotionTracker {
+ double dx, dy; /* accumulated delta for each axis */
+ int time; /* time of creation */
+ int dir; /* initial direction bitfield */
+} MotionTracker, *MotionTrackerPtr;
+
+/**
+ * contains the run-time data for the predictable scheme, that is, a
+ * DeviceVelocityPtr and the property handlers.
+ */
+typedef struct _PredictableAccelSchemeRec {
+ DeviceVelocityPtr vel;
+ long *prop_handlers;
+ int num_prop_handlers;
+} PredictableAccelSchemeRec, *PredictableAccelSchemePtr;
+
+void AccelerationDefaultCleanup(DeviceIntPtr dev);
+
+Bool InitPredictableAccelerationScheme(DeviceIntPtr dev,
+ struct _ValuatorAccelerationRec *protoScheme);
+
+void acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask *val,
+ CARD32 evtime);
+
+void acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask *val,
+ CARD32 evtime);
+
+void InitTrackers(DeviceVelocityPtr vel, int ntracker);
+
+#endif /* _XSERVER_POINTERVELOCITY_PRIV_H */
diff --git a/dix/region.c b/dix/region.c
index 49d823cda..5c83f8a04 100644
--- a/dix/region.c
+++ b/dix/region.c
@@ -402,7 +402,7 @@ RegionRectAlloc(RegionPtr pRgn, int n)
*
*-----------------------------------------------------------------------
*/
-_X_INLINE static int
+static inline int
RegionCoalesce(RegionPtr pReg, /* Region to coalesce */
int prevStart, /* Index of start of previous band */
int curStart)
@@ -487,7 +487,7 @@ RegionCoalesce(RegionPtr pReg, /* Region to coalesce */
*-----------------------------------------------------------------------
*/
-_X_INLINE static Bool
+static inline Bool
RegionAppendNonO(RegionPtr pReg, BoxPtr r, BoxPtr rEnd, int y1, int y2)
{
BoxPtr pNextRect;
diff --git a/dix/registry.c b/dix/registry.c
index 84d48b4e3..e04a26727 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -25,8 +25,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/registry_priv.h"
+
#include "resource.h"
-#include "registry.h"
#define BASE_SIZE 16
@@ -361,15 +363,15 @@ dixResetRegistry(void)
#ifdef X_REGISTRY_RESOURCE
/* Add built-in resources */
- RegisterResourceName(RT_NONE, "NONE");
- RegisterResourceName(RT_WINDOW, "WINDOW");
- RegisterResourceName(RT_PIXMAP, "PIXMAP");
- RegisterResourceName(RT_GC, "GC");
- RegisterResourceName(RT_FONT, "FONT");
- RegisterResourceName(RT_CURSOR, "CURSOR");
- RegisterResourceName(RT_COLORMAP, "COLORMAP");
- RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY");
- RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT");
- RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB");
+ RegisterResourceName(X11_RESTYPE_NONE, "NONE");
+ RegisterResourceName(X11_RESTYPE_WINDOW, "WINDOW");
+ RegisterResourceName(X11_RESTYPE_PIXMAP, "PIXMAP");
+ RegisterResourceName(X11_RESTYPE_GC, "GC");
+ RegisterResourceName(X11_RESTYPE_FONT, "FONT");
+ RegisterResourceName(X11_RESTYPE_CURSOR, "CURSOR");
+ RegisterResourceName(X11_RESTYPE_COLORMAP, "COLORMAP");
+ RegisterResourceName(X11_RESTYPE_CMAPENTRY, "COLORMAP ENTRY");
+ RegisterResourceName(X11_RESTYPE_OTHERCLIENT, "OTHER CLIENT");
+ RegisterResourceName(X11_RESTYPE_PASSIVEGRAB, "PASSIVE GRAB");
#endif
}
diff --git a/dix/registry_priv.h b/dix/registry_priv.h
new file mode 100644
index 000000000..0c6a51b12
--- /dev/null
+++ b/dix/registry_priv.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_DIX_REGISTRY_H
+#define _XSERVER_DIX_REGISTRY_H
+
+#include "include/extnsionst.h"
+#include "include/resource.h"
+
+/*
+ * Result returned from any unsuccessful lookup
+ */
+#define XREGISTRY_UNKNOWN "<unknown>"
+
+/*
+ * Setup and teardown
+ */
+void dixResetRegistry(void);
+void dixFreeRegistry(void);
+void dixCloseRegistry(void);
+
+/* Functions used by the X-Resource extension */
+void RegisterResourceName(RESTYPE type, const char *name);
+const char *LookupResourceName(RESTYPE rtype);
+
+void RegisterExtensionNames(ExtensionEntry * ext);
+
+/*
+ * Lookup functions. The returned string must not be modified or freed.
+ */
+const char *LookupMajorName(int major);
+const char *LookupRequestName(int major, int minor);
+const char *LookupEventName(int event);
+const char *LookupErrorName(int error);
+
+#endif /* _XSERVER_DIX_REGISTRY_H */
diff --git a/dix/resource.c b/dix/resource.c
index 6c0be2e04..f6fa42247 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -72,7 +72,7 @@ Equipment Corporation.
******************************************************************/
/* XSERVER_DTRACE additions:
- * Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005-2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -122,6 +122,10 @@ Equipment Corporation.
#endif
#include <X11/X.h>
+
+#include "dix/gc_priv.h"
+#include "dix/registry_priv.h"
+
#include "misc.h"
#include "os.h"
#include "resource.h"
@@ -140,7 +144,6 @@ Equipment Corporation.
#endif
#include "xace.h"
#include <assert.h>
-#include "registry.h"
#include "gcstruct.h"
#ifdef XSERVER_DTRACE
@@ -296,7 +299,7 @@ GetPixmapBytes(void *value, XID id, ResourceSizePtr size)
static void
GetWindowBytes(void *value, XID id, ResourceSizePtr size)
{
- SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+ SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(X11_RESTYPE_PIXMAP);
ResourceSizeRec pixmapSize = { 0, 0, 0 };
WindowPtr window = value;
@@ -345,12 +348,12 @@ FindWindowSubRes(void *value, FindAllRes func, void *cdata)
if (window->backgroundState == BackgroundPixmap)
{
PixmapPtr pixmap = window->background.pixmap;
- func(window->background.pixmap, pixmap->drawable.id, RT_PIXMAP, cdata);
+ func(window->background.pixmap, pixmap->drawable.id, X11_RESTYPE_PIXMAP, cdata);
}
if (window->border.pixmap && !window->borderIsPixel)
{
PixmapPtr pixmap = window->border.pixmap;
- func(window->background.pixmap, pixmap->drawable.id, RT_PIXMAP, cdata);
+ func(window->background.pixmap, pixmap->drawable.id, X11_RESTYPE_PIXMAP, cdata);
}
}
@@ -369,7 +372,7 @@ FindWindowSubRes(void *value, FindAllRes func, void *cdata)
static void
GetGcBytes(void *value, XID id, ResourceSizePtr size)
{
- SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+ SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(X11_RESTYPE_PIXMAP);
ResourceSizeRec pixmapSize = { 0, 0, 0 };
GCPtr gc = value;
@@ -417,73 +420,73 @@ FindGCSubRes(void *value, FindAllRes func, void *cdata)
if (gc->stipple)
{
PixmapPtr pixmap = gc->stipple;
- func(pixmap, pixmap->drawable.id, RT_PIXMAP, cdata);
+ func(pixmap, pixmap->drawable.id, X11_RESTYPE_PIXMAP, cdata);
}
if (gc->tile.pixmap && !gc->tileIsPixel)
{
PixmapPtr pixmap = gc->tile.pixmap;
- func(pixmap, pixmap->drawable.id, RT_PIXMAP, cdata);
+ func(pixmap, pixmap->drawable.id, X11_RESTYPE_PIXMAP, cdata);
}
}
static struct ResourceType *resourceTypes;
static const struct ResourceType predefTypes[] = {
- [RT_NONE & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_NONE & (RC_LASTPREDEF - 1)] = {
.deleteFunc = (DeleteType) NoopDDA,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadValue,
},
- [RT_WINDOW & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_WINDOW & (RC_LASTPREDEF - 1)] = {
.deleteFunc = DeleteWindow,
.sizeFunc = GetWindowBytes,
.findSubResFunc = FindWindowSubRes,
.errorValue = BadWindow,
},
- [RT_PIXMAP & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_PIXMAP & (RC_LASTPREDEF - 1)] = {
.deleteFunc = dixDestroyPixmap,
.sizeFunc = GetPixmapBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadPixmap,
},
- [RT_GC & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_GC & (RC_LASTPREDEF - 1)] = {
.deleteFunc = FreeGC,
.sizeFunc = GetGcBytes,
.findSubResFunc = FindGCSubRes,
.errorValue = BadGC,
},
- [RT_FONT & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_FONT & (RC_LASTPREDEF - 1)] = {
.deleteFunc = CloseFont,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadFont,
},
- [RT_CURSOR & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_CURSOR & (RC_LASTPREDEF - 1)] = {
.deleteFunc = FreeCursor,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadCursor,
},
- [RT_COLORMAP & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_COLORMAP & (RC_LASTPREDEF - 1)] = {
.deleteFunc = FreeColormap,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadColor,
},
- [RT_CMAPENTRY & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_CMAPENTRY & (RC_LASTPREDEF - 1)] = {
.deleteFunc = FreeClientPixels,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadColor,
},
- [RT_OTHERCLIENT & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_OTHERCLIENT & (RC_LASTPREDEF - 1)] = {
.deleteFunc = OtherClientGone,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
.errorValue = BadValue,
},
- [RT_PASSIVEGRAB & (RC_LASTPREDEF - 1)] = {
+ [X11_RESTYPE_PASSIVEGRAB & (RC_LASTPREDEF - 1)] = {
.deleteFunc = DeletePassiveGrab,
.sizeFunc = GetDefaultBytes,
.findSubResFunc = DefaultFindSubRes,
@@ -493,7 +496,7 @@ static const struct ResourceType predefTypes[] = {
CallbackListPtr ResourceStateCallback;
-static _X_INLINE void
+static inline void
CallResourceStateCallback(ResourceState state, ResourceRec * res)
{
if (ResourceStateCallback) {
@@ -549,7 +552,7 @@ GetResourceTypeSizeFunc(RESTYPE type)
* Override the default function that calculates resource size. For
* example, video driver knows better how to calculate pixmap memory
* usage and can therefore wrap or override size calculation for
- * RT_PIXMAP.
+ * X11_RESTYPE_PIXMAP.
*
* @param[in] type Resource type used in size calculations.
*
@@ -620,12 +623,15 @@ ilog2(int val)
unsigned int
ResourceClientBits(void)
{
- static unsigned int cached = 0;
+ static unsigned int cache_ilog2 = 0;
+ static unsigned int cache_limit = 0;
- if (cached == 0)
- cached = ilog2(LimitClients);
+ if (LimitClients != cache_limit) {
+ cache_limit = LimitClients;
+ cache_ilog2 = ilog2(LimitClients);
+ }
- return cached;
+ return cache_ilog2;
}
/*****************
@@ -640,7 +646,7 @@ InitClientResources(ClientPtr client)
int i, j;
if (client == serverClient) {
- lastResourceType = RT_LASTPREDEF;
+ lastResourceType = X11_RESTYPE_LASTPREDEF;
lastResourceClass = RC_LASTPREDEF;
TypeMask = RC_LASTPREDEF - 1;
free(resourceTypes);
@@ -1218,7 +1224,7 @@ dixLookupResourceByType(void **result, XID id, RESTYPE rtype,
if (client) {
cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
- res->value, RT_NONE, NULL, mode);
+ res->value, X11_RESTYPE_NONE, NULL, mode);
if (cid == BadValue)
return resourceTypes[rtype & TypeMask].errorValue;
if (cid != Success)
@@ -1253,7 +1259,7 @@ dixLookupResourceByClass(void **result, XID id, RESTYPE rclass,
if (client) {
cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
- res->value, RT_NONE, NULL, mode);
+ res->value, X11_RESTYPE_NONE, NULL, mode);
if (cid != Success)
return cid;
}
diff --git a/dix/screenint_priv.h b/dix/screenint_priv.h
new file mode 100644
index 000000000..2d98d9ba9
--- /dev/null
+++ b/dix/screenint_priv.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 1987, 1998 The Open Group
+ */
+#ifndef _XSERVER_DIX_SCREENINT_PRIV_H
+#define _XSERVER_DIX_SCREENINT_PRIV_H
+
+#include <X11/Xdefs.h>
+
+typedef struct _Screen *ScreenPtr;
+
+typedef Bool (*ScreenInitProcPtr)(ScreenPtr pScreen, int argc, char **argv);
+
+int AddScreen(ScreenInitProcPtr pfnInit, int argc, char **argv);
+int AddGPUScreen(ScreenInitProcPtr pfnInit, int argc, char **argv);
+
+void RemoveGPUScreen(ScreenPtr pScreen);
+
+void AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr newScreen);
+void DetachUnboundGPU(ScreenPtr unbound);
+
+void AttachOutputGPU(ScreenPtr pScreen, ScreenPtr newScreen);
+void DetachOutputGPU(ScreenPtr output);
+
+void AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr newScreen);
+void DetachOffloadGPU(ScreenPtr slave);
+
+#endif /* _XSERVER_DIX_SCREENINT_PRIV_H */
diff --git a/dix/selection.c b/dix/selection.c
index d46103f70..a107eb6cf 100644
--- a/dix/selection.c
+++ b/dix/selection.c
@@ -48,6 +48,8 @@ SOFTWARE.
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "windowstr.h"
#include "dixstruct.h"
#include "dispatch.h"
@@ -101,7 +103,7 @@ InitSelections(void)
CurrentSelections = NULL;
}
-static _X_INLINE void
+static inline void
CallSelectionCallback(Selection * pSel, ClientPtr client,
SelectionCallbackKind kind)
{
diff --git a/dix/touch.c b/dix/touch.c
index d0d286f80..a2d65eee6 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -28,6 +28,9 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+#include "dix/eventconvert.h"
+
#include "inputstr.h"
#include "scrnintstr.h"
#include "dixgrabs.h"
@@ -36,7 +39,6 @@
#include "exevents.h"
#include "exglobals.h"
#include "inpututils.h"
-#include "eventconvert.h"
#include "windowstr.h"
#include "mi.h"
@@ -710,8 +712,8 @@ TouchAddGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
type = TOUCH_LISTENER_POINTER_GRAB;
}
- /* grab listeners are always RT_NONE since we keep the grab pointer */
- TouchAddListener(ti, grab->resource, RT_NONE, grab->grabtype,
+ /* grab listeners are always X11_RESTYPE_NONE since we keep the grab pointer */
+ TouchAddListener(ti, grab->resource, X11_RESTYPE_NONE, grab->grabtype,
type, TOUCH_LISTENER_AWAITING_BEGIN, grab->window, grab);
}
@@ -798,7 +800,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
/* window owner */
if (IsMaster(dev) && (win->eventMask & core_filter)) {
TouchEventHistoryAllocate(ti);
- TouchAddListener(ti, win->drawable.id, RT_WINDOW, CORE,
+ TouchAddListener(ti, win->drawable.id, X11_RESTYPE_WINDOW, CORE,
TOUCH_LISTENER_POINTER_REGULAR,
TOUCH_LISTENER_AWAITING_BEGIN,
win, NULL);
@@ -811,7 +813,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
continue;
TouchEventHistoryAllocate(ti);
- TouchAddListener(ti, oclients->resource, RT_OTHERCLIENT, CORE,
+ TouchAddListener(ti, oclients->resource, X11_RESTYPE_OTHERCLIENT, CORE,
type, TOUCH_LISTENER_AWAITING_BEGIN, win, NULL);
return TRUE;
}
diff --git a/dix/window.c b/dix/window.c
index cd917f006..d30aff350 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -100,6 +100,9 @@ Equipment Corporation.
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+#include "os/auth.h"
+
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@@ -393,7 +396,7 @@ PrintPassiveGrabs(void)
FreeLocalClientCreds(lcc);
}
- FindClientResourcesByType(clients[i], RT_PASSIVEGRAB, log_grab_info, NULL);
+ FindClientResourcesByType(clients[i], X11_RESTYPE_PASSIVEGRAB, log_grab_info, NULL);
}
ErrorF("End list of registered passive grabs\n");
}
@@ -637,10 +640,10 @@ CreateRootWindow(ScreenPtr pScreen)
/* security creation/labeling check
*/
if (XaceHook(XACE_RESOURCE_ACCESS, serverClient, pWin->drawable.id,
- RT_WINDOW, pWin, RT_NONE, NULL, DixCreateAccess))
+ X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixCreateAccess))
return FALSE;
- if (!AddResource(pWin->drawable.id, RT_WINDOW, (void *) pWin))
+ if (!AddResource(pWin->drawable.id, X11_RESTYPE_WINDOW, (void *) pWin))
return FALSE;
if (disableBackingStore)
@@ -865,8 +868,8 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
/* security creation/labeling check
*/
- *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin,
- RT_WINDOW, pWin->parent,
+ *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, X11_RESTYPE_WINDOW, pWin,
+ X11_RESTYPE_WINDOW, pWin->parent,
DixCreateAccess | DixSetAttrAccess);
if (*error != Success) {
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
@@ -1040,7 +1043,7 @@ CrushTree(WindowPtr pWin)
event.u.destroyNotify.window = pChild->drawable.id;
DeliverEvents(pChild, &event, 1, NullWindow);
}
- FreeResource(pChild->drawable.id, RT_WINDOW);
+ FreeResource(pChild->drawable.id, X11_RESTYPE_WINDOW);
pSib = pChild->nextSib;
pChild->viewable = FALSE;
if (pChild->realized) {
@@ -1114,12 +1117,12 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client)
UnmapSubwindows(pWin);
while (pWin->lastChild) {
int rc = XaceHook(XACE_RESOURCE_ACCESS, client,
- pWin->lastChild->drawable.id, RT_WINDOW,
- pWin->lastChild, RT_NONE, NULL, DixDestroyAccess);
+ pWin->lastChild->drawable.id, X11_RESTYPE_WINDOW,
+ pWin->lastChild, X11_RESTYPE_NONE, NULL, DixDestroyAccess);
if (rc != Success)
return rc;
- FreeResource(pWin->lastChild->drawable.id, RT_NONE);
+ FreeResource(pWin->lastChild->drawable.id, X11_RESTYPE_NONE);
}
return Success;
}
@@ -1216,7 +1219,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else {
rc = dixLookupResourceByType((void **) &pPixmap, pixID,
- RT_PIXMAP, client, DixReadAccess);
+ X11_RESTYPE_PIXMAP, client, DixReadAccess);
if (rc == Success) {
if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
@@ -1269,7 +1272,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
pixID = pWin->parent->border.pixmap->drawable.id;
}
}
- rc = dixLookupResourceByType((void **) &pPixmap, pixID, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &pPixmap, pixID, X11_RESTYPE_PIXMAP,
client, DixReadAccess);
if (rc == Success) {
if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
@@ -1396,7 +1399,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
if (val == xTrue) {
rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
- RT_WINDOW, pWin, RT_NONE, NULL, DixGrabAccess);
+ X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixGrabAccess);
if (rc != Success) {
error = rc;
client->errorValue = pWin->drawable.id;
@@ -1421,7 +1424,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
error = BadMatch;
goto PatchUp;
}
- rc = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pCmap, cmap, X11_RESTYPE_COLORMAP,
client, DixUseAccess);
if (rc != Success) {
error = rc;
@@ -1492,7 +1495,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else {
rc = dixLookupResourceByType((void **) &pCursor, cursorID,
- RT_CURSOR, client, DixUseAccess);
+ X11_RESTYPE_CURSOR, client, DixUseAccess);
if (rc != Success) {
error = rc;
client->errorValue = cursorID;
@@ -2662,8 +2665,8 @@ MapWindow(WindowPtr pWin, ClientPtr client)
return Success;
/* general check for permission to map window */
- if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, RT_WINDOW,
- pWin, RT_NONE, NULL, DixShowAccess) != Success)
+ if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, X11_RESTYPE_WINDOW,
+ pWin, X11_RESTYPE_NONE, NULL, DixShowAccess) != Success)
return Success;
pScreen = pWin->drawable.pScreen;
@@ -3135,7 +3138,7 @@ dixSaveScreens(ClientPtr client, int on, int mode)
}
else if (HasSaverWindow(pScreen)) {
pScreen->screensaver.pWindow = NullWindow;
- FreeResource(pScreen->screensaver.wid, RT_NONE);
+ FreeResource(pScreen->screensaver.wid, X11_RESTYPE_NONE);
}
break;
case SCREEN_SAVER_CYCLE:
@@ -3263,7 +3266,7 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
&cursor, serverClient, (XID) 0);
if (cursor) {
cursorID = FakeClientID(0);
- if (AddResource(cursorID, RT_CURSOR, (void *) cursor)) {
+ if (AddResource(cursorID, X11_RESTYPE_CURSOR, (void *) cursor)) {
attributes[attri] = cursorID;
mask |= CWCursor;
}
@@ -3286,12 +3289,12 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
wVisual(pScreen->root), &result);
if (cursor)
- FreeResource(cursorID, RT_NONE);
+ FreeResource(cursorID, X11_RESTYPE_NONE);
if (!pWin)
return FALSE;
- if (!AddResource(pWin->drawable.id, RT_WINDOW,
+ if (!AddResource(pWin->drawable.id, X11_RESTYPE_WINDOW,
(void *) pScreen->screensaver.pWindow))
return FALSE;
@@ -3642,7 +3645,7 @@ SetRootClip(ScreenPtr pScreen, int enable)
if (!pWin)
return;
WasViewable = (Bool) (pWin->viewable);
- if (WasViewable) {
+ if (WasViewable && mode != ROOT_CLIP_INPUT_ONLY) {
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
(void) (*pScreen->MarkOverlappedWindows) (pChild,
pChild, &pLayerWin);
@@ -3696,7 +3699,7 @@ SetRootClip(ScreenPtr pScreen, int enable)
ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
- if (WasViewable) {
+ if (WasViewable && mode != ROOT_CLIP_INPUT_ONLY) {
if (pWin->firstChild) {
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild,
pWin->firstChild,
diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml
index 15ecb0fd5..8c3c0fce4 100644
--- a/doc/Xserver-spec.xml
+++ b/doc/Xserver-spec.xml
@@ -440,7 +440,7 @@ To free a resource, use one of the following.
FreeResource frees all resources matching the given id, regardless of
type; the type's deleteFunc will be called on each matching resource,
except that skipDeleteFuncType can be set to a single type for which
-the deleteFunc should not be called (otherwise pass RT_NONE).
+the deleteFunc should not be called (otherwise pass RT_NONE / X11_RESTYPE_NONE).
FreeResourceByType frees a specific resource matching a given id
and type; if skipFree is true, then the deleteFunc is not called.
</para>
@@ -657,14 +657,11 @@ make the server suspend until one or more of the following occurs:
<para>
Before WaitForSomething() computes the masks to pass to select, poll or
similar operating system interface, it needs to
-see if there is anything to do on the work queue; if so, it must call a DIX
-routine called ProcessWorkQueue.
+see if there is anything to do on the work queue; it must call a DIX
+routine called ProcessWorkQueue().
<blockquote>
<programlisting>
- extern WorkQueuePtr workQueue;
-
- if (workQueue)
- ProcessWorkQueue ();
+ ProcessWorkQueue ();
</programlisting>
</blockquote>
</para>
diff --git a/dri3/dri3.c b/dri3/dri3.c
index 191252969..f9c517277 100644
--- a/dri3/dri3.c
+++ b/dri3/dri3.c
@@ -63,6 +63,16 @@ dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info)
return TRUE;
}
+RESTYPE dri3_syncobj_type;
+
+static int dri3_syncobj_free(void *data, XID id)
+{
+ struct dri3_syncobj *syncobj = data;
+ if (--syncobj->refcount == 0)
+ syncobj->free(syncobj);
+ return 0;
+}
+
void
dri3_extension_init(void)
{
@@ -92,6 +102,11 @@ dri3_extension_init(void)
if (!dri3_screen_init(screenInfo.screens[i], NULL))
goto bail;
}
+
+ dri3_syncobj_type = CreateNewResourceType(dri3_syncobj_free, "DRI3Syncobj");
+ if (!dri3_syncobj_type)
+ goto bail;
+
return;
bail:
diff --git a/dri3/dri3.h b/dri3/dri3.h
index 02d3b03ee..14f9a1efa 100644
--- a/dri3/dri3.h
+++ b/dri3/dri3.h
@@ -28,7 +28,35 @@
#include <X11/extensions/dri3proto.h>
#include <randrstr.h>
-#define DRI3_SCREEN_INFO_VERSION 2
+#define DRI3_SCREEN_INFO_VERSION 4
+
+extern RESTYPE dri3_syncobj_type;
+
+struct dri3_syncobj
+{
+ XID id;
+ ScreenPtr screen;
+ uint32_t refcount;
+
+ void (*free)(struct dri3_syncobj *syncobj);
+ Bool (*has_fence)(struct dri3_syncobj *syncobj, uint64_t point);
+ Bool (*is_signaled)(struct dri3_syncobj *syncobj, uint64_t point);
+ int (*export_fence)(struct dri3_syncobj *syncobj, uint64_t point);
+ void (*import_fence)(struct dri3_syncobj *syncobj, uint64_t point, int fd);
+ void (*signal)(struct dri3_syncobj *syncobj, uint64_t point);
+ void (*submitted_eventfd)(struct dri3_syncobj *syncobj, uint64_t point, int efd);
+ void (*signaled_eventfd)(struct dri3_syncobj *syncobj, uint64_t point, int efd);
+};
+
+#define VERIFY_DRI3_SYNCOBJ(id, ptr, a)\
+ do {\
+ int rc = dixLookupResourceByType((void **)&(ptr), id,\
+ dri3_syncobj_type, client, a);\
+ if (rc != Success) {\
+ client->errorValue = id;\
+ return rc;\
+ }\
+ } while (0);
typedef int (*dri3_open_proc)(ScreenPtr screen,
RRProviderPtr provider,
@@ -84,6 +112,11 @@ typedef int (*dri3_get_drawable_modifiers_proc) (DrawablePtr draw,
uint32_t *num_modifiers,
uint64_t **modifiers);
+typedef struct dri3_syncobj *(*dri3_import_syncobj_proc) (ClientPtr client,
+ ScreenPtr screen,
+ XID id,
+ int fd);
+
typedef struct dri3_screen_info {
uint32_t version;
@@ -101,6 +134,9 @@ typedef struct dri3_screen_info {
dri3_get_modifiers_proc get_modifiers;
dri3_get_drawable_modifiers_proc get_drawable_modifiers;
+ /* Version 4 */
+ dri3_import_syncobj_proc import_syncobj;
+
} dri3_screen_info_rec, *dri3_screen_info_ptr;
extern _X_EXPORT Bool
diff --git a/dri3/dri3_priv.h b/dri3/dri3_priv.h
index f319d1770..71d2da957 100644
--- a/dri3/dri3_priv.h
+++ b/dri3/dri3_priv.h
@@ -102,4 +102,7 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
CARD32 *num_screen_modifiers,
CARD64 **screen_modifiers);
+int
+dri3_import_syncobj(ClientPtr client, ScreenPtr screen, XID id, int fd);
+
#endif /* _DRI3PRIV_H_ */
diff --git a/dri3/dri3_request.c b/dri3/dri3_request.c
index 687168930..27d3c73a7 100644
--- a/dri3/dri3_request.c
+++ b/dri3/dri3_request.c
@@ -19,14 +19,30 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
+
+#include <unistd.h>
+
+#include "dix/dix_priv.h"
#include "dri3_priv.h"
#include <syncsrv.h>
-#include <unistd.h>
#include <xace.h>
#include "../Xext/syncsdk.h"
#include <protocol-versions.h>
#include <drm_fourcc.h>
+#include "randrstr_priv.h"
+
+static Bool
+dri3_screen_can_one_point_four(ScreenPtr screen)
+{
+ dri3_screen_priv_ptr dri3 = dri3_screen_priv(screen);
+
+ return dri3 &&
+ dri3->info &&
+ dri3->info->version >= 4 &&
+ dri3->info->import_syncobj;
+}
static Bool
dri3_screen_can_one_point_two(ScreenPtr screen)
@@ -61,6 +77,10 @@ proc_dri3_query_version(ClientPtr client)
rep.minorVersion = 0;
break;
}
+ if (!dri3_screen_can_one_point_four(screenInfo.screens[i])) {
+ rep.minorVersion = 2;
+ break;
+ }
}
for (int i = 0; i < screenInfo.numGPUScreens; i++) {
@@ -68,6 +88,10 @@ proc_dri3_query_version(ClientPtr client)
rep.minorVersion = 0;
break;
}
+ if (!dri3_screen_can_one_point_four(screenInfo.gpuscreens[i])) {
+ rep.minorVersion = 2;
+ break;
+ }
}
/* From DRI3 proto:
@@ -214,14 +238,14 @@ proc_dri3_pixmap_from_buffer(ClientPtr client)
pixmap->drawable.id = stuff->pixmap;
/* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP,
- pixmap, RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, X11_RESTYPE_PIXMAP,
+ pixmap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) {
(*drawable->pScreen->DestroyPixmap) (pixmap);
return rc;
}
- if (!AddResource(stuff->pixmap, RT_PIXMAP, (void *) pixmap))
+ if (!AddResource(stuff->pixmap, X11_RESTYPE_PIXMAP, (void *) pixmap))
return BadAlloc;
return Success;
@@ -242,7 +266,7 @@ proc_dri3_buffer_from_pixmap(ClientPtr client)
PixmapPtr pixmap;
REQUEST_SIZE_MATCH(xDRI3BufferFromPixmapReq);
- rc = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, X11_RESTYPE_PIXMAP,
client, DixWriteAccess);
if (rc != Success) {
client->errorValue = stuff->pixmap;
@@ -478,14 +502,14 @@ proc_dri3_pixmap_from_buffers(ClientPtr client)
pixmap->drawable.id = stuff->pixmap;
/* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP,
- pixmap, RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, X11_RESTYPE_PIXMAP,
+ pixmap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) {
(*screen->DestroyPixmap) (pixmap);
return rc;
}
- if (!AddResource(stuff->pixmap, RT_PIXMAP, (void *) pixmap))
+ if (!AddResource(stuff->pixmap, X11_RESTYPE_PIXMAP, (void *) pixmap))
return BadAlloc;
return Success;
@@ -508,7 +532,7 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
PixmapPtr pixmap;
REQUEST_SIZE_MATCH(xDRI3BuffersFromPixmapReq);
- rc = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, X11_RESTYPE_PIXMAP,
client, DixWriteAccess);
if (rc != Success) {
client->errorValue = stuff->pixmap;
@@ -554,6 +578,72 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
return Success;
}
+static int
+proc_dri3_set_drm_device_in_use(ClientPtr client)
+{
+ REQUEST(xDRI3SetDRMDeviceInUseReq);
+ WindowPtr window;
+ int status;
+
+ REQUEST_SIZE_MATCH(xDRI3SetDRMDeviceInUseReq);
+ status = dixLookupWindow(&window, stuff->window, client,
+ DixGetAttrAccess);
+ if (status != Success)
+ return status;
+
+ /* TODO Eventually we should use this information to have
+ * DRI3GetSupportedModifiers return device-specific modifiers, but for now
+ * we will ignore it until multi-device support is more complete.
+ * Otherwise we can't advertise support for DRI3 1.4.
+ */
+ return Success;
+}
+
+static int
+proc_dri3_import_syncobj(ClientPtr client)
+{
+ REQUEST(xDRI3ImportSyncobjReq);
+ DrawablePtr drawable;
+ ScreenPtr screen;
+ int fd;
+ int status;
+
+ SetReqFds(client, 1);
+ REQUEST_SIZE_MATCH(xDRI3ImportSyncobjReq);
+ LEGAL_NEW_RESOURCE(stuff->syncobj, client);
+
+ status = dixLookupDrawable(&drawable, stuff->drawable, client,
+ M_ANY, DixGetAttrAccess);
+ if (status != Success)
+ return status;
+
+ screen = drawable->pScreen;
+
+ fd = ReadFdFromClient(client);
+ if (fd < 0)
+ return BadValue;
+
+ return dri3_import_syncobj(client, screen, stuff->syncobj, fd);
+}
+
+static int
+proc_dri3_free_syncobj(ClientPtr client)
+{
+ REQUEST(xDRI3FreeSyncobjReq);
+ struct dri3_syncobj *syncobj;
+ int status;
+
+ REQUEST_SIZE_MATCH(xDRI3FreeSyncobjReq);
+
+ status = dixLookupResourceByType((void **) &syncobj, stuff->syncobj,
+ dri3_syncobj_type, client, DixWriteAccess);
+ if (status != Success)
+ return status;
+
+ FreeResource(stuff->syncobj, RT_NONE);
+ return Success;
+}
+
int (*proc_dri3_vector[DRI3NumberRequests]) (ClientPtr) = {
proc_dri3_query_version, /* 0 */
proc_dri3_open, /* 1 */
@@ -564,6 +654,9 @@ int (*proc_dri3_vector[DRI3NumberRequests]) (ClientPtr) = {
proc_dri3_get_supported_modifiers, /* 6 */
proc_dri3_pixmap_from_buffers, /* 7 */
proc_dri3_buffers_from_pixmap, /* 8 */
+ proc_dri3_set_drm_device_in_use, /* 9 */
+ proc_dri3_import_syncobj, /* 10 */
+ proc_dri3_free_syncobj, /* 11 */
};
int
@@ -697,6 +790,40 @@ sproc_dri3_buffers_from_pixmap(ClientPtr client)
return (*proc_dri3_vector[stuff->dri3ReqType]) (client);
}
+static int _X_COLD
+sproc_dri3_set_drm_device_in_use(ClientPtr client)
+{
+ REQUEST(xDRI3SetDRMDeviceInUseReq);
+ REQUEST_SIZE_MATCH(xDRI3SetDRMDeviceInUseReq);
+ swapl(&stuff->window);
+ swapl(&stuff->drmMajor);
+ swapl(&stuff->drmMinor);
+ return (*proc_dri3_vector[stuff->dri3ReqType]) (client);
+}
+
+static int _X_COLD
+sproc_dri3_import_syncobj(ClientPtr client)
+{
+ REQUEST(xDRI3ImportSyncobjReq);
+ REQUEST_SIZE_MATCH(xDRI3ImportSyncobjReq);
+
+ swaps(&stuff->length);
+ swapl(&stuff->syncobj);
+ swapl(&stuff->drawable);
+ return (*proc_dri3_vector[stuff->dri3ReqType]) (client);
+}
+
+static int _X_COLD
+sproc_dri3_free_syncobj(ClientPtr client)
+{
+ REQUEST(xDRI3FreeSyncobjReq);
+ REQUEST_SIZE_MATCH(xDRI3FreeSyncobjReq);
+
+ swaps(&stuff->length);
+ swapl(&stuff->syncobj);
+ return (*proc_dri3_vector[stuff->dri3ReqType]) (client);
+}
+
int (*sproc_dri3_vector[DRI3NumberRequests]) (ClientPtr) = {
sproc_dri3_query_version, /* 0 */
sproc_dri3_open, /* 1 */
@@ -707,6 +834,9 @@ int (*sproc_dri3_vector[DRI3NumberRequests]) (ClientPtr) = {
sproc_dri3_get_supported_modifiers, /* 6 */
sproc_dri3_pixmap_from_buffers, /* 7 */
sproc_dri3_buffers_from_pixmap, /* 8 */
+ sproc_dri3_set_drm_device_in_use, /* 9 */
+ sproc_dri3_import_syncobj, /* 10 */
+ sproc_dri3_free_syncobj, /* 11 */
};
int _X_COLD
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 3c7e5bf60..2430505fb 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -183,8 +183,10 @@ cache_formats_and_modifiers(ScreenPtr screen)
}
ds->formats = calloc(num_formats, sizeof(dri3_dmabuf_format_rec));
- if (!ds->formats)
+ if (!ds->formats) {
+ free(formats);
return BadAlloc;
+ }
for (i = 0; i < num_formats; i++) {
dri3_dmabuf_format_ptr iter = &ds->formats[i];
@@ -205,24 +207,24 @@ cache_formats_and_modifiers(ScreenPtr screen)
ds->num_formats = i;
ds->formats_cached = TRUE;
+ free(formats);
return Success;
}
int
dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
CARD8 depth, CARD8 bpp,
- CARD32 *num_intersect_modifiers,
- CARD64 **intersect_modifiers,
+ CARD32 *num_drawable_modifiers,
+ CARD64 **drawable_modifiers,
CARD32 *num_screen_modifiers,
CARD64 **screen_modifiers)
{
dri3_screen_priv_ptr ds = dri3_screen_priv(screen);
const dri3_screen_info_rec *info = ds->info;
- int i, j;
+ int i;
int ret;
uint32_t num_drawable_mods;
uint64_t *drawable_mods;
- CARD64 *intersect_mods = NULL;
CARD64 *screen_mods = NULL;
CARD32 format;
dri3_dmabuf_format_ptr screen_format = NULL;
@@ -248,10 +250,15 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
if (screen_format->num_modifiers == 0) {
*num_screen_modifiers = 0;
- *num_intersect_modifiers = 0;
+ *num_drawable_modifiers = 0;
return Success;
}
+ /* copy the screen mods so we can return an owned allocation */
+ screen_mods = xnfalloc(screen_format->num_modifiers * sizeof(CARD64));
+ memcpy(screen_mods, screen_format->modifiers,
+ screen_format->num_modifiers * sizeof(CARD64));
+
if (!info->get_drawable_modifiers ||
!info->get_drawable_modifiers(drawable, format,
&num_drawable_mods,
@@ -260,47 +267,31 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
drawable_mods = NULL;
}
- /* We're allocating slightly more memory than necessary but it reduces
- * the complexity of finding the intersection set.
- */
- screen_mods = malloc(screen_format->num_modifiers * sizeof(CARD64));
- if (!screen_mods)
- return BadAlloc;
- if (num_drawable_mods > 0) {
- intersect_mods = malloc(screen_format->num_modifiers * sizeof(CARD64));
- if (!intersect_mods) {
- free(screen_mods);
- return BadAlloc;
- }
- }
+ *num_drawable_modifiers = num_drawable_mods;
+ *drawable_modifiers = drawable_mods;
- *num_screen_modifiers = 0;
- *num_intersect_modifiers = 0;
- for (i = 0; i < screen_format->num_modifiers; i++) {
- CARD64 modifier = screen_format->modifiers[i];
- Bool intersect = FALSE;
-
- for (j = 0; j < num_drawable_mods; j++) {
- if (drawable_mods[j] == modifier) {
- intersect = TRUE;
- break;
- }
- }
+ *num_screen_modifiers = screen_format->num_modifiers;
+ *screen_modifiers = screen_mods;
- if (intersect) {
- intersect_mods[*num_intersect_modifiers] = modifier;
- *num_intersect_modifiers += 1;
- } else {
- screen_mods[*num_screen_modifiers] = modifier;
- *num_screen_modifiers += 1;
- }
- }
+ return Success;
+}
- assert(*num_intersect_modifiers + *num_screen_modifiers == screen_format->num_modifiers);
+int dri3_import_syncobj(ClientPtr client, ScreenPtr screen, XID id, int fd)
+{
+ const dri3_screen_info_rec *info = dri3_screen_priv(screen)->info;
+ struct dri3_syncobj *syncobj = NULL;
- *intersect_modifiers = intersect_mods;
- *screen_modifiers = screen_mods;
- free(drawable_mods);
+ if (info->version < 4 || !info->import_syncobj)
+ return BadImplementation;
+
+ syncobj = info->import_syncobj(client, screen, id, fd);
+ close(fd);
+
+ if (!syncobj)
+ return BadAlloc;
+
+ if (!AddResource(id, dri3_syncobj_type, syncobj))
+ return BadAlloc;
return Success;
}
diff --git a/exa/exa.c b/exa/exa.c
index b16875845..42047fa2d 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -125,7 +125,7 @@ exaGetDrawablePixmap(DrawablePtr pDrawable)
void
exaGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *xp, int *yp)
{
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pDrawable->type == DRAWABLE_WINDOW) {
*xp = -pPixmap->screen_x;
*yp = -pPixmap->screen_y;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index e632331da..2a31bd3c7 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -963,7 +963,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RegionInit(&rgnDst, NullBox, 0);
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pPixmap->screen_x || pPixmap->screen_y)
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
#endif
diff --git a/exa/exa_classic.c b/exa/exa_classic.c
index a6a60e50c..a9460f999 100644
--- a/exa/exa_classic.c
+++ b/exa/exa_classic.c
@@ -33,7 +33,7 @@
/* This file holds the classic exa specific implementation. */
-static _X_INLINE void *
+static inline void *
ExaGetPixmapAddress(PixmapPtr p)
{
ExaPixmapPriv(p);
diff --git a/exa/exa_driver.c b/exa/exa_driver.c
index 45acf152c..7a74c4500 100644
--- a/exa/exa_driver.c
+++ b/exa/exa_driver.c
@@ -33,7 +33,7 @@
/* This file holds the driver allocated pixmaps specific implementation. */
-static _X_INLINE void *
+static inline void *
ExaGetPixmapAddress(PixmapPtr p)
{
ExaPixmapPriv(p);
diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index 192a643cc..6b97a83b1 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -47,7 +47,7 @@
#include <stdlib.h>
#include "exa_priv.h"
-
+#include "glyphstr_priv.h"
#include "mipict.h"
#if DEBUG_GLYPH_CACHE
diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index d926f8033..4c7714657 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -34,7 +34,7 @@
/* This file holds the driver allocated pixmaps + better initial placement code.
*/
-static _X_INLINE void *
+static inline void *
ExaGetPixmapAddress(PixmapPtr p)
{
ExaPixmapPriv(p);
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 4468487e6..f9e166c66 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -236,19 +236,11 @@ extern DevPrivateKeyRec exaScreenPrivateKeyRec;
real->mem = priv->Saved##mem; \
}
-#ifdef HAVE_TYPEOF
#define swap(priv, real, mem) {\
typeof(real->mem) tmp = priv->Saved##mem; \
priv->Saved##mem = real->mem; \
real->mem = tmp; \
}
-#else
-#define swap(priv, real, mem) {\
- const void *tmp = priv->Saved##mem; \
- priv->Saved##mem = real->mem; \
- real->mem = tmp; \
-}
-#endif
#define EXA_PRE_FALLBACK(_screen_) \
ExaScreenPriv(_screen_); \
@@ -452,7 +444,7 @@ ExaCheckAddTraps(PicturePtr pPicture,
/* exa_accel.c */
-static _X_INLINE Bool
+static inline Bool
exaGCReadsDestination(DrawablePtr pDrawable, unsigned long planemask,
unsigned int fillStyle, unsigned char alu,
Bool clientClip)
diff --git a/fb/fb.h b/fb/fb.h
index 8ab050d0f..c2c4cae78 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -441,7 +441,7 @@ typedef struct {
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
#else
@@ -734,6 +734,9 @@ fbResolveColor(unsigned short *pred,
extern _X_EXPORT Bool
fbInitializeColormap(ColormapPtr pmap);
+extern _X_EXPORT Bool
+ mfbCreateColormap(ColormapPtr pmap);
+
extern _X_EXPORT int
fbExpandDirectColors(ColormapPtr pmap,
@@ -1027,7 +1030,6 @@ extern _X_EXPORT Bool
int dpiy, int width, /* pixel width of frame buffer */
int bpp); /* bits per pixel of frame buffer */
-#ifdef FB_ACCESS_WRAPPER
extern _X_EXPORT Bool
wfbFinishScreenInit(ScreenPtr pScreen,
void *pbits,
@@ -1049,7 +1051,6 @@ wfbScreenInit(ScreenPtr pScreen,
int width,
int bpp,
SetupWrapProcPtr setupWrap, FinishWrapProcPtr finishWrap);
-#endif
extern _X_EXPORT Bool
fbFinishScreenInit(ScreenPtr pScreen,
@@ -1098,6 +1099,45 @@ fbSolid(FbBits * dst,
int dstX, int bpp, int width, int height, FbBits and, FbBits xor);
/*
+ * fbtile.c
+ */
+
+extern _X_EXPORT void
+
+fbEvenTile(FbBits * dst,
+ FbStride dstStride,
+ int dstX,
+ int width,
+ int height,
+ FbBits * tile,
+ FbStride tileStride,
+ int tileHeight, int alu, FbBits pm, int xRot, int yRot);
+
+extern _X_EXPORT void
+
+fbOddTile(FbBits * dst,
+ FbStride dstStride,
+ int dstX,
+ int width,
+ int height,
+ FbBits * tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
+
+extern _X_EXPORT void
+
+fbTile(FbBits * dst,
+ FbStride dstStride,
+ int dstX,
+ int width,
+ int height,
+ FbBits * tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
+
+/*
* fbutil.c
*/
extern _X_EXPORT FbBits fbReplicatePixel(Pixel p, int bpp);
diff --git a/fb/fbcmap_mi.c b/fb/fbcmap_mi.c
index d9976ce9f..a71828a11 100644
--- a/fb/fbcmap_mi.c
+++ b/fb/fbcmap_mi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1987, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -66,6 +66,41 @@ fbInitializeColormap(ColormapPtr pmap)
return miInitializeColormap(pmap);
}
+Bool
+mfbCreateColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen;
+ unsigned short red0, green0, blue0;
+ unsigned short red1, green1, blue1;
+ Pixel pix;
+
+ pScreen = pmap->pScreen;
+ if (pScreen->whitePixel == 0)
+ {
+ red0 = green0 = blue0 = ~0;
+ red1 = green1 = blue1 = 0;
+ }
+ else
+ {
+ red0 = green0 = blue0 = 0;
+ red1 = green1 = blue1 = ~0;
+ }
+
+ /* this is a monochrome colormap, it only has two entries, just fill
+ * them in by hand. If it were a more complex static map, it would be
+ * worth writing a for loop or three to initialize it */
+
+ /* this will be pixel 0 */
+ pix = 0;
+ if (AllocColor(pmap, &red0, &green0, &blue0, &pix, 0) != Success)
+ return FALSE;
+
+ /* this will be pixel 1 */
+ if (AllocColor(pmap, &red1, &green1, &blue1, &pix, 0) != Success)
+ return FALSE;
+ return TRUE;
+}
+
int
fbExpandDirectColors(ColormapPtr pmap,
int ndef, xColorItem * indefs, xColorItem * outdefs)
diff --git a/fb/fbfill.c b/fb/fbfill.c
index 05d81ab77..ad09671fa 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -27,44 +27,6 @@
#include "fb.h"
static void
-fbTile(FbBits * dst, FbStride dstStride, int dstX, int width, int height,
- FbBits * tile, FbStride tileStride, int tileWidth, int tileHeight,
- int alu, FbBits pm, int bpp, int xRot, int yRot)
-{
- int tileX, tileY;
- int widthTmp;
- int h, w;
- int x, y;
-
- modulus(-yRot, tileHeight, tileY);
- y = 0;
- while (height) {
- h = tileHeight - tileY;
- if (h > height)
- h = height;
- height -= h;
- widthTmp = width;
- x = dstX;
- modulus(dstX - xRot, tileWidth, tileX);
- while (widthTmp) {
- w = tileWidth - tileX;
- if (w > widthTmp)
- w = widthTmp;
- widthTmp -= w;
- fbBlt(tile + tileY * tileStride,
- tileStride,
- tileX,
- dst + y * dstStride,
- dstStride, x, w, h, alu, pm, bpp, FALSE, FALSE);
- x += w;
- tileX = 0;
- }
- y += h;
- tileY = 0;
- }
-}
-
-static void
fbStipple(FbBits * dst, FbStride dstStride,
int dstX, int dstBpp,
int width, int height,
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 9797447b4..f985198fb 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -30,7 +30,7 @@
#include <string.h>
#include "fb.h"
-
+#include "glyphstr_priv.h"
#include "picturestr.h"
#include "mipict.h"
#include "fbpict.h"
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index af5d7bec0..89e3370a6 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -76,7 +76,7 @@ fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
fbInitializeDrawable(&pPixmap->drawable);
#endif
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
pPixmap->screen_x = 0;
pPixmap->screen_y = 0;
#endif
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 4ab807ab5..42efaa911 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -100,8 +100,10 @@ fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */
if (!fbAllocatePrivates(pScreen))
return FALSE;
pScreen->defColormap = FakeClientID(0);
- /* let CreateDefColormap do whatever it wants for pixels */
- pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ if (bpp > 1) {
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ }
pScreen->QueryBestSize = fbQueryBestSize;
/* SaveScreen */
pScreen->GetImage = fbGetImage;
@@ -118,7 +120,11 @@ fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */
pScreen->RealizeFont = fbRealizeFont;
pScreen->UnrealizeFont = fbUnrealizeFont;
pScreen->CreateGC = fbCreateGC;
- pScreen->CreateColormap = fbInitializeColormap;
+ if (bpp == 1) {
+ pScreen->CreateColormap = mfbCreateColormap;
+ } else {
+ pScreen->CreateColormap = fbInitializeColormap;
+ }
pScreen->DestroyColormap = (void (*)(ColormapPtr)) NoopDDA;
pScreen->InstallColormap = fbInstallColormap;
pScreen->UninstallColormap = fbUninstallColormap;
diff --git a/fb/fbtile.c b/fb/fbtile.c
new file mode 100644
index 000000000..785c5f0e4
--- /dev/null
+++ b/fb/fbtile.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+/*
+ * Accelerated tile fill -- tile width is a power of two not greater
+ * than FB_UNIT
+ */
+
+void
+fbEvenTile(FbBits * dst,
+ FbStride dstStride,
+ int dstX,
+ int width,
+ int height,
+ FbBits * tile,
+ FbStride tileStride,
+ int tileHeight, int alu, FbBits pm, int xRot, int yRot)
+{
+ FbBits *t, *tileEnd, bits;
+ FbBits startmask, endmask;
+ FbBits and, xor;
+ int n, nmiddle;
+ int tileX, tileY;
+ int rot;
+ int startbyte, endbyte;
+
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes(dstX, width, FbDestInvarientRop(alu, pm),
+ startmask, startbyte, nmiddle, endmask, endbyte);
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+
+ /*
+ * Compute tile start scanline and rotation parameters
+ */
+ tileEnd = tile + tileHeight * tileStride;
+ modulus(-yRot, tileHeight, tileY);
+ t = tile + tileY * tileStride;
+ modulus(-xRot, FB_UNIT, tileX);
+ rot = tileX;
+
+ while (height--) {
+
+ /*
+ * Pick up bits for this scanline
+ */
+ bits = READ(t);
+ t += tileStride;
+ if (t >= tileEnd)
+ t = tile;
+ bits = FbRotLeft(bits, rot);
+ and = fbAnd(alu, bits, pm);
+ xor = fbXor(alu, bits, pm);
+
+ if (startmask) {
+ FbDoLeftMaskByteRRop(dst, startbyte, startmask, and, xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ WRITE(dst++, xor);
+ else
+ while (n--) {
+ WRITE(dst, FbDoRRop(READ(dst), and, xor));
+ dst++;
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
+ dst += dstStride;
+ }
+}
+
+void
+fbOddTile(FbBits * dst,
+ FbStride dstStride,
+ int dstX,
+ int width,
+ int height,
+ FbBits * tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot)
+{
+ int tileX, tileY;
+ int widthTmp;
+ int h, w;
+ int x, y;
+
+ modulus(-yRot, tileHeight, tileY);
+ y = 0;
+ while (height) {
+ h = tileHeight - tileY;
+ if (h > height)
+ h = height;
+ height -= h;
+ widthTmp = width;
+ x = dstX;
+ modulus(dstX - xRot, tileWidth, tileX);
+ while (widthTmp) {
+ w = tileWidth - tileX;
+ if (w > widthTmp)
+ w = widthTmp;
+ widthTmp -= w;
+ fbBlt(tile + tileY * tileStride,
+ tileStride,
+ tileX,
+ dst + y * dstStride,
+ dstStride, x, w, h, alu, pm, bpp, FALSE, FALSE);
+ x += w;
+ tileX = 0;
+ }
+ y += h;
+ tileY = 0;
+ }
+}
+
+void
+fbTile(FbBits * dst,
+ FbStride dstStride,
+ int dstX,
+ int width,
+ int height,
+ FbBits * tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot)
+{
+ if (FbEvenTile(tileWidth))
+ fbEvenTile(dst, dstStride, dstX, width, height,
+ tile, tileStride, tileHeight, alu, pm, xRot, yRot);
+ else
+ fbOddTile(dst, dstStride, dstX, width, height,
+ tile, tileStride, tileWidth, tileHeight,
+ alu, pm, bpp, xRot, yRot);
+}
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index fca871d62..df33af948 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -116,7 +116,7 @@ fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pPixmap->screen_x || pPixmap->screen_y)
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
#endif
diff --git a/fb/meson.build b/fb/meson.build
index 1d8d259a1..e4e311ff4 100644
--- a/fb/meson.build
+++ b/fb/meson.build
@@ -23,6 +23,7 @@ srcs_fb = [
'fbseg.c',
'fbsetsp.c',
'fbsolid.c',
+ 'fbtile.c',
'fbtrap.c',
'fbutil.c',
'fbwindow.c',
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index ffdcbed96..4977f2067 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -43,6 +43,7 @@
#define fbDots16 wfbDots16
#define fbDots32 wfbDots32
#define fbDots8 wfbDots8
+#define fbEvenTile wfbEvenTile
#define fbExpandDirectColors wfbExpandDirectColors
#define fbFill wfbFill
#define fbFillRegionSolid wfbFillRegionSolid
@@ -65,6 +66,7 @@
#define fbInitVisuals wfbInitVisuals
#define fbListInstalledColormaps wfbListInstalledColormaps
#define FbMergeRopBits wFbMergeRopBits
+#define fbOddTile wfbOddTile
#define fbOver wfbOver
#define fbOverlayCloseScreen wfbOverlayCloseScreen
#define fbOverlayCopyWindow wfbOverlayCopyWindow
@@ -116,6 +118,7 @@
#define _fbSetWindowPixmap _wfbSetWindowPixmap
#define fbSolid wfbSolid
#define fbSolidBoxClipped wfbSolidBoxClipped
+#define fbTile wfbTile
#define fbTrapezoids wfbTrapezoids
#define fbTriangles wfbTriangles
#define fbUninstallColormap wfbUninstallColormap
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 9dcef5fac..70a34d81b 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -89,7 +89,7 @@ glamor_init_pixmap_private_small(PixmapPtr pixmap, glamor_pixmap_private *pixmap
pixmap_priv->fbo_array = &pixmap_priv->fbo;
}
-_X_EXPORT void
+void
glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
{
glamor_pixmap_private *pixmap_priv;
@@ -99,7 +99,7 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
glamor_init_pixmap_private_small(pixmap, pixmap_priv);
}
-_X_EXPORT Bool
+Bool
glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
{
ScreenPtr screen = pixmap->drawable.pScreen;
@@ -129,7 +129,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
return TRUE;
}
-_X_EXPORT void
+void
glamor_clear_pixmap(PixmapPtr pixmap)
{
ScreenPtr screen = pixmap->drawable.pScreen;
@@ -216,14 +216,16 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
w <= glamor_priv->glyph_max_dim &&
h <= glamor_priv->glyph_max_dim)
|| (w == 0 && h == 0)
- || !glamor_priv->formats[depth].rendering_supported))
+ || !glamor_priv->formats[depth].rendering_supported
+ || (glamor_priv->formats[depth].texture_only &&
+ (usage != GLAMOR_CREATE_FBO_NO_FBO))))
return fbCreatePixmap(screen, w, h, depth, usage);
else
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
pixmap_priv = glamor_get_pixmap_private(pixmap);
- pixmap_priv->is_cbcr = (usage == GLAMOR_CREATE_FORMAT_CBCR);
+ pixmap_priv->is_cbcr = (GLAMOR_CREATE_FORMAT_CBCR & usage) == GLAMOR_CREATE_FORMAT_CBCR;
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
@@ -271,9 +273,7 @@ void
glamor_block_handler(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-
- glamor_make_current(glamor_priv);
- glFlush();
+ glamor_flush(glamor_priv);
}
static void
@@ -281,8 +281,7 @@ _glamor_block_handler(ScreenPtr screen, void *timeout)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- glamor_make_current(glamor_priv);
- glFlush();
+ glamor_flush(glamor_priv);
screen->BlockHandler = glamor_priv->saved_procs.block_handler;
screen->BlockHandler(screen, timeout);
@@ -310,6 +309,10 @@ glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv,
{
unsigned i;
+ /* If there is no quads to draw, just exit */
+ if (count == 0)
+ return;
+
/* For a single quad, don't bother with an index buffer. */
if (count == 1)
goto fallback;
@@ -366,35 +369,6 @@ fallback:
}
-static Bool
-glamor_check_instruction_count(int gl_version)
-{
- GLint max_native_alu_instructions;
-
- /* Avoid using glamor if the reported instructions limit is too low,
- * as this would cause glamor to fallback on sw due to large shaders
- * which ends up being unbearably slow.
- */
- if (gl_version < 30) {
- if (!epoxy_has_gl_extension("GL_ARB_fragment_program")) {
- ErrorF("GL_ARB_fragment_program required\n");
- return FALSE;
- }
-
- glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
- GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB,
- &max_native_alu_instructions);
- if (max_native_alu_instructions < GLAMOR_MIN_ALU_INSTRUCTIONS) {
- LogMessage(X_WARNING,
- "glamor requires at least %d instructions (%d reported)\n",
- GLAMOR_MIN_ALU_INSTRUCTIONS, max_native_alu_instructions);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
static void GLAPIENTRY
glamor_debug_output_callback(GLenum source,
GLenum type,
@@ -466,6 +440,7 @@ glamor_add_format(ScreenPtr screen, int depth, CARD32 render_format,
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
struct glamor_format *f = &glamor_priv->formats[depth];
+ Bool texture_only = FALSE;
/* If we're trying to run on GLES, make sure that we get the read
* formats that we're expecting, since glamor_transfer relies on
@@ -488,6 +463,13 @@ glamor_add_format(ScreenPtr screen, int depth, CARD32 render_format,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 1, 1, 0,
format, type, NULL);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ ErrorF("glamor: Cannot upload texture for depth %d. "
+ "Falling back to software.\n", depth);
+ glDeleteTextures(1, &tex);
+ return;
+ }
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -499,21 +481,23 @@ glamor_add_format(ScreenPtr screen, int depth, CARD32 render_format,
"Falling back to software.\n", depth);
glDeleteTextures(1, &tex);
glDeleteFramebuffers(1, &fbo);
- return;
+ texture_only = TRUE;
}
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &read_format);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &read_type);
+ if (!texture_only) {
+ glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &read_format);
+ glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &read_type);
+ }
glDeleteTextures(1, &tex);
glDeleteFramebuffers(1, &fbo);
- if (format != read_format || type != read_type) {
+ if (!texture_only && (format != read_format || type != read_type)) {
ErrorF("glamor: Implementation returned 0x%x/0x%x read format/type "
"for depth %d, expected 0x%x/0x%x. "
"Falling back to software.\n",
read_format, read_type, depth, format, type);
- return;
+ texture_only = TRUE;
}
}
@@ -523,6 +507,7 @@ glamor_add_format(ScreenPtr screen, int depth, CARD32 render_format,
f->format = format;
f->type = type;
f->rendering_supported = rendering_supported;
+ f->texture_only = texture_only;
}
/* Set up the GL format/types that glamor will use for the various depths
@@ -550,9 +535,10 @@ glamor_setup_formats(ScreenPtr screen)
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
/* Prefer r8 textures since they're required by GLES3 and core,
- * only falling back to a8 if we can't do them.
+ * only falling back to a8 if we can't do them. We cannot do them
+ * on GLES2 due to lack of texture swizzle.
*/
- if (glamor_priv->is_gles || epoxy_has_gl_extension("GL_ARB_texture_rg")) {
+ if (glamor_priv->has_rg && glamor_priv->has_texture_swizzle) {
glamor_add_format(screen, 1, PICT_a1,
GL_R8, GL_RED, GL_UNSIGNED_BYTE, FALSE);
glamor_add_format(screen, 8, PICT_a8,
@@ -586,10 +572,10 @@ glamor_setup_formats(ScreenPtr screen)
if (glamor_priv->is_gles) {
assert(X_BYTE_ORDER == X_LITTLE_ENDIAN);
- glamor_add_format(screen, 24, PICT_x8b8g8r8,
- GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, TRUE);
- glamor_add_format(screen, 32, PICT_a8b8g8r8,
- GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, TRUE);
+ glamor_add_format(screen, 24, PICT_x8r8g8b8,
+ GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE, TRUE);
+ glamor_add_format(screen, 32, PICT_a8r8g8b8,
+ GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE, TRUE);
} else {
glamor_add_format(screen, 24, PICT_x8r8g8b8,
GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, TRUE);
@@ -606,10 +592,16 @@ glamor_setup_formats(ScreenPtr screen)
}
glamor_priv->cbcr_format.depth = 16;
- glamor_priv->cbcr_format.internalformat = GL_RG8;
+ if (glamor_priv->is_gles && glamor_priv->has_rg) {
+ glamor_priv->cbcr_format.internalformat = GL_RG;
+ } else {
+ glamor_priv->cbcr_format.internalformat = GL_RG8;
+ }
glamor_priv->cbcr_format.format = GL_RG;
+ glamor_priv->cbcr_format.render_format = PICT_yuv2;
glamor_priv->cbcr_format.type = GL_UNSIGNED_BYTE;
glamor_priv->cbcr_format.rendering_supported = TRUE;
+ glamor_priv->cbcr_format.texture_only = FALSE;
}
/** Set up glamor for an already-configured GL context. */
@@ -682,17 +674,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->glsl_version = epoxy_glsl_version();
- if (glamor_priv->is_gles) {
- /* Force us back to the base version of our programs on an ES
- * context, anyway. Basically glamor only uses desktop 1.20
- * or 1.30 currently. 1.30's new features are also present in
- * ES 3.0, but our glamor_program.c constructions use a lot of
- * compatibility features (to reduce the diff between 1.20 and
- * 1.30 programs).
- */
- glamor_priv->glsl_version = 120;
- }
-
/* We'd like to require GL_ARB_map_buffer_range or
* GL_OES_map_buffer_range, since it offers more information to
* the driver than plain old glMapBuffer() or glBufferSubData().
@@ -718,14 +699,12 @@ glamor_init(ScreenPtr screen, unsigned int flags)
goto fail;
}
- if (!glamor_check_instruction_count(gl_version))
- goto fail;
-
/* Glamor rendering assumes that platforms with GLSL 130+
* have instanced arrays, but this is not always the case.
* etnaviv offers GLSL 140 with OpenGL 2.1.
*/
if (glamor_glsl_has_ints(glamor_priv) &&
+ !glamor_priv->is_gles &&
!epoxy_has_gl_extension("GL_ARB_instanced_arrays"))
glamor_priv->glsl_version = 120;
} else {
@@ -782,11 +761,18 @@ glamor_init(ScreenPtr screen, unsigned int flags)
epoxy_gl_version() >= 30 ||
epoxy_has_gl_extension("GL_NV_pack_subimage");
glamor_priv->has_dual_blend =
- glamor_glsl_has_ints(glamor_priv) &&
- epoxy_has_gl_extension("GL_ARB_blend_func_extended");
+ (epoxy_has_gl_extension("GL_ARB_blend_func_extended") &&
+ (glamor_glsl_has_ints(glamor_priv) ||
+ epoxy_has_gl_extension("GL_ARB_ES2_compatibility"))) ||
+ epoxy_has_gl_extension("GL_EXT_blend_func_extended");
glamor_priv->has_clear_texture =
epoxy_gl_version() >= 44 ||
epoxy_has_gl_extension("GL_ARB_clear_texture");
+ /* GL_EXT_texture_rg is part of GLES3 core */
+ glamor_priv->has_rg =
+ (glamor_priv->is_gles && epoxy_gl_version() >= 30) ||
+ epoxy_has_gl_extension("GL_EXT_texture_rg") ||
+ epoxy_has_gl_extension("GL_ARB_texture_rg");
glamor_priv->can_copyplane = (gl_version >= 30);
@@ -873,7 +859,16 @@ glamor_init(ScreenPtr screen, unsigned int flags)
ps->Glyphs = glamor_composite_glyphs;
glamor_init_vbo(screen);
- glamor_init_gradient_shader(screen);
+
+ glamor_priv->enable_gradient_shader = TRUE;
+
+ if (!glamor_init_gradient_shader(screen)) {
+ LogMessage(X_WARNING,
+ "glamor%d: Cannot initialize gradient shader, falling back to software rendering for gradients\n",
+ screen->myNum);
+ glamor_priv->enable_gradient_shader = FALSE;
+ }
+
glamor_pixmap_init(screen);
glamor_sync_init(screen);
@@ -915,6 +910,7 @@ glamor_close_screen(ScreenPtr screen)
glamor_priv = glamor_get_screen_private(screen);
glamor_sync_close(screen);
glamor_composite_glyphs_fini(screen);
+ glamor_set_glvnd_vendor(screen, NULL);
screen->CloseScreen = glamor_priv->saved_procs.close_screen;
screen->CreateGC = glamor_priv->saved_procs.create_gc;
@@ -948,6 +944,31 @@ glamor_fini(ScreenPtr screen)
}
void
+glamor_set_glvnd_vendor(ScreenPtr screen, const char *vendor_name)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ if (!glamor_priv)
+ return;
+
+ if (glamor_priv->glvnd_vendor)
+ free(glamor_priv->glvnd_vendor);
+
+ glamor_priv->glvnd_vendor = xnfstrdup(vendor_name);
+}
+
+const char *
+glamor_get_glvnd_vendor(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ if (!glamor_priv)
+ return NULL;
+
+ return glamor_priv->glvnd_vendor;
+}
+
+void
glamor_enable_dri3(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
@@ -963,7 +984,7 @@ glamor_supports_pixmap_import_export(ScreenPtr screen)
return glamor_priv->dri3_enabled;
}
-_X_EXPORT void
+void
glamor_set_drawable_modifiers_func(ScreenPtr screen,
GetDrawableModifiersFuncPtr func)
{
@@ -972,7 +993,7 @@ glamor_set_drawable_modifiers_func(ScreenPtr screen,
glamor_priv->get_drawable_modifiers = func;
}
-_X_EXPORT Bool
+Bool
glamor_get_drawable_modifiers(DrawablePtr draw, uint32_t format,
uint32_t *num_modifiers, uint64_t **modifiers)
{
@@ -993,6 +1014,7 @@ _glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
uint32_t *strides, uint32_t *offsets,
CARD32 *size, uint64_t *modifier)
{
+#ifdef GLAMOR_HAS_GBM
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen);
@@ -1020,10 +1042,11 @@ _glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
default:
break;
}
+#endif /* GLAMOR_HAS_GBM */
return 0;
}
-_X_EXPORT int
+int
glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
uint32_t *strides, uint32_t *offsets,
uint64_t *modifier)
@@ -1032,7 +1055,7 @@ glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
NULL, modifier);
}
-_X_EXPORT int
+int
glamor_fd_from_pixmap(ScreenPtr screen,
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
{
@@ -1049,7 +1072,7 @@ glamor_fd_from_pixmap(ScreenPtr screen,
return fd;
}
-_X_EXPORT int
+int
glamor_shareable_fd_from_pixmap(ScreenPtr screen,
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
{
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 31157471d..f5634b7e7 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -120,6 +120,12 @@ extern _X_EXPORT void glamor_clear_pixmap(PixmapPtr pixmap);
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
+/* This function should be called after glamor_init,
+ * but before adding a glamor GLX provider */
+extern _X_EXPORT void glamor_set_glvnd_vendor(ScreenPtr screen,
+ const char *vendor);
+extern _X_EXPORT const char *glamor_get_glvnd_vendor(ScreenPtr screen);
+
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
int depth, unsigned int usage);
extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index 147e3bb31..428303091 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -25,6 +25,7 @@
#include "glamor_priv.h"
#include "glamor_transform.h"
#include "glamor_transfer.h"
+#include "glyphstr_priv.h"
#include <mipict.h>
@@ -107,7 +108,7 @@ glamor_copy_glyph(PixmapPtr glyph_pixmap,
glyph_draw->height,
0, 0, 0x1);
}
- glamor_upload_boxes((PixmapPtr) atlas_draw,
+ glamor_upload_boxes(atlas_draw,
&box, 1,
0, 0,
x, y,
@@ -180,16 +181,16 @@ glamor_glyph_add(struct glamor_glyph_atlas *atlas, DrawablePtr glyph_draw)
static const glamor_facet glamor_facet_composite_glyphs_130 = {
.name = "composite_glyphs",
.version = 130,
- .vs_vars = ("attribute vec4 primitive;\n"
- "attribute vec2 source;\n"
- "varying vec2 glyph_pos;\n"),
+ .vs_vars = ("in vec4 primitive;\n"
+ "in vec2 source;\n"
+ "out vec2 glyph_pos;\n"),
.vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
GLAMOR_POS(gl_Position, (primitive.xy + pos))
" glyph_pos = (source + pos) * ATLAS_DIM_INV;\n"),
- .fs_vars = ("varying vec2 glyph_pos;\n"
+ .fs_vars = ("in vec2 glyph_pos;\n"
"out vec4 color0;\n"
"out vec4 color1;\n"),
- .fs_exec = (" vec4 mask = texture2D(atlas, glyph_pos);\n"),
+ .fs_exec = (" vec4 mask = texture(atlas, glyph_pos);\n"),
.source_name = "source",
.locations = glamor_program_location_atlas,
};
@@ -208,6 +209,22 @@ static const glamor_facet glamor_facet_composite_glyphs_120 = {
.locations = glamor_program_location_atlas,
};
+static const glamor_facet glamor_facet_composite_glyphs_gles2 = {
+ .name = "composite_glyphs",
+ .version = 100,
+ .fs_extensions = ("#extension GL_EXT_blend_func_extended : enable\n"),
+ .vs_vars = ("attribute vec2 primitive;\n"
+ "attribute vec2 source;\n"
+ "varying vec2 glyph_pos;\n"),
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive.xy)
+ " glyph_pos = source.xy * ATLAS_DIM_INV;\n"),
+ .fs_vars = ("varying vec2 glyph_pos;\n"),
+ .fs_exec = (" vec4 mask = texture2D(atlas, glyph_pos);\n"),
+ .source_name = "source",
+ .locations = glamor_program_location_atlas,
+};
+
static Bool
glamor_glyphs_init_facet(ScreenPtr screen)
{
@@ -442,7 +459,9 @@ glamor_composite_glyphs(CARD8 op,
else
prog = glamor_setup_program_render(op, src, glyph_pict, dst,
glyphs_program,
- &glamor_facet_composite_glyphs_120,
+ glamor_priv->has_dual_blend ?
+ &glamor_facet_composite_glyphs_gles2 :
+ &glamor_facet_composite_glyphs_120,
glamor_priv->glyph_defines);
if (!prog)
goto bail_one;
diff --git a/glamor/glamor_compositerects.c b/glamor/glamor_compositerects.c
index 199e62705..0796fed41 100644
--- a/glamor/glamor_compositerects.c
+++ b/glamor/glamor_compositerects.c
@@ -227,12 +227,10 @@ glamor_composite_rectangles(CARD8 op,
boxes = pixman_region_rectangles(&region, &num_boxes);
if (op == PictOpSrc || op == PictOpClear) {
CARD32 pixel;
- int dst_x, dst_y;
- glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
- pixman_region_translate(&region, dst_x, dst_y);
+ pixman_region_translate(&region, -dst->pDrawable->x, -dst->pDrawable->y);
- DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
+ DEBUGF("%s: drawable extents (%d, %d),(%d, %d)\n",
__FUNCTION__, dst_x, dst_y,
RegionExtents(&region)->x1, RegionExtents(&region)->y1,
RegionExtents(&region)->x2, RegionExtents(&region)->y2);
@@ -241,7 +239,7 @@ glamor_composite_rectangles(CARD8 op,
pixel = 0;
else
miRenderColorToPixel(dst->pFormat, color, &pixel);
- glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
+ glamor_solid_boxes(dst->pDrawable, boxes, num_boxes, pixel);
goto done;
}
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 1ab2be6c0..909565368 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -26,19 +26,19 @@
#include "glamor_transform.h"
struct copy_args {
- PixmapPtr src_pixmap;
+ DrawablePtr src_drawable;
glamor_pixmap_fbo *src;
uint32_t bitplane;
int dx, dy;
};
static Bool
-use_copyarea(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
+use_copyarea(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
struct copy_args *args = arg;
glamor_pixmap_fbo *src = args->src;
- glamor_bind_texture(glamor_get_screen_private(dst->drawable.pScreen),
+ glamor_bind_texture(glamor_get_screen_private(drawable->pScreen),
GL_TEXTURE0, src, TRUE);
glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
@@ -49,10 +49,10 @@ use_copyarea(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
static const glamor_facet glamor_facet_copyarea = {
"copy_area",
- .vs_vars = "attribute vec2 primitive;\n",
+ .vs_vars = "in vec2 primitive;\n",
.vs_exec = (GLAMOR_POS(gl_Position, primitive.xy)
" fill_pos = (fill_offset + primitive.xy) * fill_size_inv;\n"),
- .fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
+ .fs_exec = " frag_color = texture(sampler, fill_pos);\n",
.locations = glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_copyarea,
};
@@ -62,22 +62,22 @@ static const glamor_facet glamor_facet_copyarea = {
*/
static Bool
-use_copyplane(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
+use_copyplane(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
struct copy_args *args = arg;
glamor_pixmap_fbo *src = args->src;
- glamor_bind_texture(glamor_get_screen_private(dst->drawable.pScreen),
+ glamor_bind_texture(glamor_get_screen_private(drawable->pScreen),
GL_TEXTURE0, src, TRUE);
glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
glUniform2f(prog->fill_size_inv_uniform, 1.0f/src->width, 1.0f/src->height);
- glamor_set_color(dst, gc->fgPixel, prog->fg_uniform);
- glamor_set_color(dst, gc->bgPixel, prog->bg_uniform);
+ glamor_set_color(drawable, gc->fgPixel, prog->fg_uniform);
+ glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
/* XXX handle 2 10 10 10 and 1555 formats; presumably the pixmap private knows this? */
- switch (args->src_pixmap->drawable.depth) {
+ switch (glamor_drawable_effective_depth(args->src_drawable)) {
case 30:
glUniform4ui(prog->bitplane_uniform,
(args->bitplane >> 20) & 0x3ff,
@@ -141,14 +141,14 @@ use_copyplane(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
static const glamor_facet glamor_facet_copyplane = {
"copy_plane",
.version = 130,
- .vs_vars = "attribute vec2 primitive;\n",
+ .vs_vars = "in vec2 primitive;\n",
.vs_exec = (GLAMOR_POS(gl_Position, (primitive.xy))
" fill_pos = (fill_offset + primitive.xy) * fill_size_inv;\n"),
- .fs_exec = (" uvec4 bits = uvec4(round(texture2D(sampler, fill_pos) * bitmul));\n"
+ .fs_exec = (" uvec4 bits = uvec4(round(texture(sampler, fill_pos) * bitmul));\n"
" if ((bits & bitplane) != uvec4(0,0,0,0))\n"
- " gl_FragColor = fg;\n"
+ " frag_color = fg;\n"
" else\n"
- " gl_FragColor = bg;\n"),
+ " frag_color = bg;\n"),
.locations = glamor_program_location_fillsamp|glamor_program_location_fillpos|glamor_program_location_fg|glamor_program_location_bg|glamor_program_location_bitplane,
.use = use_copyplane,
};
@@ -235,7 +235,7 @@ glamor_copy_cpu_fbo(DrawablePtr src,
PixmapPtr tmp_pix = fbCreatePixmap(screen, dst_pixmap->drawable.width,
dst_pixmap->drawable.height,
- dst->depth, 0);
+ glamor_drawable_effective_depth(dst), 0);
if (!tmp_pix) {
glamor_finish_access(src);
@@ -255,7 +255,7 @@ glamor_copy_cpu_fbo(DrawablePtr src,
fbCopy1toN(src, &tmp_pix->drawable, gc, box, nbox, dx, dy,
reverse, upsidedown, bitplane, closure);
- glamor_upload_boxes(dst_pixmap, box, nbox, tmp_xoff, tmp_yoff,
+ glamor_upload_boxes(dst, box, nbox, tmp_xoff, tmp_yoff,
dst_xoff, dst_yoff, (uint8_t *) tmp_bits,
tmp_stride * sizeof(FbBits));
fbDestroyPixmap(tmp_pix);
@@ -266,7 +266,7 @@ glamor_copy_cpu_fbo(DrawablePtr src,
int src_xoff, src_yoff;
fbGetDrawable(src, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
- glamor_upload_boxes(dst_pixmap, box, nbox, src_xoff + dx, src_yoff + dy,
+ glamor_upload_boxes(dst, box, nbox, src_xoff + dx, src_yoff + dy,
dst_xoff, dst_yoff,
(uint8_t *) src_bits, src_stride * sizeof (FbBits));
}
@@ -319,7 +319,7 @@ glamor_copy_fbo_cpu(DrawablePtr src,
fbGetDrawable(dst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff);
- glamor_download_boxes(src_pixmap, box, nbox, src_xoff + dx, src_yoff + dy,
+ glamor_download_boxes(src, box, nbox, src_xoff + dx, src_yoff + dy,
dst_xoff, dst_yoff,
(uint8_t *) dst_bits, dst_stride * sizeof (FbBits));
glamor_finish_access(dst);
@@ -378,7 +378,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
if (gc && !glamor_set_planemask(gc->depth, gc->planemask))
goto bail_ctx;
- if (!glamor_set_alu(screen, gc ? gc->alu : GXcopy))
+ if (!glamor_set_alu(dst, gc ? gc->alu : GXcopy))
goto bail_ctx;
if (bitplane && !glamor_priv->can_copyplane)
@@ -401,7 +401,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
goto bail_ctx;
}
- args.src_pixmap = src_pixmap;
+ args.src_drawable = src;
args.bitplane = bitplane;
/* Set up the vertex buffers for the points */
@@ -453,7 +453,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
args.dy = dy + src_off_y - src_box->y1;
args.src = glamor_pixmap_fbo_at(src_priv, src_box_index);
- if (!glamor_use_program(dst_pixmap, gc, prog, &args))
+ if (!glamor_use_program(dst, gc, prog, &args))
goto bail_ctx;
glamor_pixmap_loop(dst_priv, dst_box_index) {
@@ -529,7 +529,7 @@ glamor_copy_fbo_fbo_temp(DrawablePtr src,
if (gc && !glamor_set_planemask(gc->depth, gc->planemask))
goto bail_ctx;
- if (!glamor_set_alu(screen, gc ? gc->alu : GXcopy))
+ if (!glamor_set_alu(dst, gc ? gc->alu : GXcopy))
goto bail_ctx;
/* Find the size of the area to copy
@@ -547,7 +547,7 @@ glamor_copy_fbo_fbo_temp(DrawablePtr src,
tmp_pixmap = glamor_create_pixmap(screen,
bounds.x2 - bounds.x1,
bounds.y2 - bounds.y1,
- src->depth, 0);
+ glamor_drawable_effective_depth(src), 0);
if (!tmp_pixmap)
goto bail;
@@ -757,7 +757,7 @@ glamor_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc,
int srcx, int srcy, int width, int height, int dstx, int dsty,
unsigned long bitplane)
{
- if ((bitplane & FbFullMask(src->depth)) == 0)
+ if ((bitplane & FbFullMask(glamor_drawable_effective_depth(src))) == 0)
return miHandleExposures(src, dst, gc,
srcx, srcy, width, height, dstx, dsty);
return miDoCopy(src, dst, gc,
@@ -781,7 +781,7 @@ glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_regio
RegionIntersect(&dst_region, &window->borderClip, src_region);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pixmap->screen_x || pixmap->screen_y)
RegionTranslate(&dst_region, -pixmap->screen_x, -pixmap->screen_y);
#endif
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index cb315e2d1..9a7510da0 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -78,7 +78,7 @@ glamor_compile_glsl_prog(GLenum type, const char *source)
return prog;
}
-void
+Bool
glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const char *format, ...)
{
GLint ok;
@@ -106,8 +106,9 @@ glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const char *format, ...)
glGetProgramInfoLog(prog, size, NULL, info);
ErrorF("Failed to link: %s\n", info);
- FatalError("GLSL link failure\n");
+ return FALSE;
}
+ return TRUE;
}
diff --git a/glamor/glamor_dash.c b/glamor/glamor_dash.c
index b53ce5c50..828969d91 100644
--- a/glamor/glamor_dash.c
+++ b/glamor/glamor_dash.c
@@ -27,8 +27,8 @@
#include "glamor_prepare.h"
static const char dash_vs_vars[] =
- "attribute vec3 primitive;\n"
- "varying float dash_offset;\n";
+ "in vec3 primitive;\n"
+ "out float dash_offset;\n";
static const char dash_vs_exec[] =
" dash_offset = primitive.z / dash_length;\n"
@@ -36,20 +36,20 @@ static const char dash_vs_exec[] =
GLAMOR_POS(gl_Position, primitive.xy);
static const char dash_fs_vars[] =
- "varying float dash_offset;\n";
+ "in float dash_offset;\n";
static const char on_off_fs_exec[] =
- " float pattern = texture2D(dash, vec2(dash_offset, 0.5)).w;\n"
+ " float pattern = texture(dash, vec2(dash_offset, 0.5)).w;\n"
" if (pattern == 0.0)\n"
" discard;\n";
/* XXX deal with stippled double dashed lines once we have stippling support */
static const char double_fs_exec[] =
- " float pattern = texture2D(dash, vec2(dash_offset, 0.5)).w;\n"
+ " float pattern = texture(dash, vec2(dash_offset, 0.5)).w;\n"
" if (pattern == 0.0)\n"
- " gl_FragColor = bg;\n"
+ " frag_color = bg;\n"
" else\n"
- " gl_FragColor = fg;\n";
+ " frag_color = fg;\n";
static const glamor_facet glamor_facet_on_off_dash_lines = {
@@ -156,7 +156,7 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
switch (gc->lineStyle) {
case LineOnOffDash:
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->on_off_dash_line_progs,
&glamor_facet_on_off_dash_lines);
if (!prog)
@@ -175,11 +175,11 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
goto bail;
}
- if (!glamor_use_program(pixmap, gc, prog, NULL))
+ if (!glamor_use_program(drawable, gc, prog, NULL))
goto bail;
- glamor_set_color(pixmap, gc->fgPixel, prog->fg_uniform);
- glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+ glamor_set_color(drawable, gc->fgPixel, prog->fg_uniform);
+ glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
break;
default:
diff --git a/glamor/glamor_debug.h b/glamor/glamor_debug.h
index f64c44832..68189d484 100644
--- a/glamor/glamor_debug.h
+++ b/glamor/glamor_debug.h
@@ -35,10 +35,6 @@
#define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 2
#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 3
-extern void
-AbortServer(void)
- _X_NORETURN;
-
#define GLAMOR_PANIC(_format_, ...) \
do { \
LogMessageVerb(X_NONE, 0, "Glamor Fatal Error" \
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 60d0df893..918a790de 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -46,6 +46,7 @@
#include "glamor.h"
#include "glamor_priv.h"
+#include "glamor_glx_provider.h"
#include "dri3.h"
struct glamor_egl_screen_private {
@@ -58,6 +59,7 @@ struct glamor_egl_screen_private {
int fd;
struct gbm_device *gbm;
int dmabuf_capable;
+ Bool force_vendor; /* if GLVND vendor is forced from options */
CloseScreenProcPtr saved_close_screen;
DestroyPixmapProcPtr saved_destroy_pixmap;
@@ -403,6 +405,9 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
struct gbm_bo *bo;
int num_fds;
#ifdef GBM_BO_WITH_MODIFIERS
+#ifndef GBM_BO_FD_FOR_PLANE
+ int32_t first_handle;
+#endif
int i;
#endif
@@ -416,7 +421,29 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
#ifdef GBM_BO_WITH_MODIFIERS
num_fds = gbm_bo_get_plane_count(bo);
for (i = 0; i < num_fds; i++) {
- fds[i] = gbm_bo_get_fd(bo);
+#ifdef GBM_BO_FD_FOR_PLANE
+ fds[i] = gbm_bo_get_fd_for_plane(bo, i);
+#else
+ union gbm_bo_handle plane_handle = gbm_bo_get_handle_for_plane(bo, i);
+
+ if (i == 0)
+ first_handle = plane_handle.s32;
+
+ /* If all planes point to the same object as the first plane, i.e. they
+ * all have the same handle, we can fall back to the non-planar
+ * gbm_bo_get_fd without losing information. If they point to different
+ * objects we are out of luck and need to give up.
+ */
+ if (first_handle == plane_handle.s32)
+ fds[i] = gbm_bo_get_fd(bo);
+ else
+ fds[i] = -1;
+#endif
+ if (fds[i] == -1) {
+ while (--i >= 0)
+ close(fds[i]);
+ return 0;
+ }
strides[i] = gbm_bo_get_stride_for_plane(bo, i);
offsets[i] = gbm_bo_get_offset(bo, i);
}
@@ -424,6 +451,8 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
#else
num_fds = 1;
fds[0] = gbm_bo_get_fd(bo);
+ if (fds[0] == -1)
+ return 0;
strides[0] = gbm_bo_get_stride(bo);
offsets[0] = 0;
*modifier = DRM_FORMAT_MOD_INVALID;
@@ -436,7 +465,7 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
#endif
}
-_X_EXPORT int
+int
glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
CARD16 *stride, CARD32 *size)
{
@@ -491,7 +520,7 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
return fd;
}
-_X_EXPORT Bool
+Bool
glamor_back_pixmap_from_fd(PixmapPtr pixmap,
int fd,
CARD16 width,
@@ -546,7 +575,7 @@ gbm_format_for_depth(CARD8 depth)
}
}
-_X_EXPORT PixmapPtr
+PixmapPtr
glamor_pixmap_from_fds(ScreenPtr screen,
CARD8 num_fds, const int *fds,
CARD16 width, CARD16 height,
@@ -600,7 +629,7 @@ glamor_pixmap_from_fds(ScreenPtr screen,
return pixmap;
}
-_X_EXPORT PixmapPtr
+PixmapPtr
glamor_pixmap_from_fd(ScreenPtr screen,
int fd,
CARD16 width,
@@ -622,7 +651,7 @@ glamor_pixmap_from_fd(ScreenPtr screen,
return pixmap;
}
-_X_EXPORT Bool
+Bool
glamor_get_formats(ScreenPtr screen,
CARD32 *num_formats, CARD32 **formats)
{
@@ -662,7 +691,7 @@ glamor_get_formats(ScreenPtr screen,
#endif
}
-_X_EXPORT Bool
+Bool
glamor_get_modifiers(ScreenPtr screen, uint32_t format,
uint32_t *num_modifiers, uint64_t **modifiers)
{
@@ -703,7 +732,7 @@ glamor_get_modifiers(ScreenPtr screen, uint32_t format,
#endif
}
-_X_EXPORT const char *
+const char *
glamor_egl_get_driver_name(ScreenPtr screen)
{
#ifdef GLAMOR_HAS_EGL_QUERY_DRIVER
@@ -744,7 +773,7 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap)
return ret;
}
-_X_EXPORT void
+void
glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
{
EGLImageKHR temp_img;
@@ -860,6 +889,10 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
#ifdef DRI3
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
#endif
+#ifdef GLXEXT
+ static Bool vendor_initialized = FALSE;
+#endif
+ const char *gbm_backend_name;
glamor_egl->saved_close_screen = screen->CloseScreen;
screen->CloseScreen = glamor_egl_close_screen;
@@ -872,6 +905,13 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
glamor_ctx->make_current = glamor_egl_make_current;
+ /* Use dynamic logic only if vendor is not forced via xorg.conf */
+ if (!glamor_egl->force_vendor) {
+ gbm_backend_name = gbm_device_get_backend_name(glamor_egl->gbm);
+ /* Mesa uses "drm" as backend name, in that case, just do nothing */
+ if (gbm_backend_name && strcmp(gbm_backend_name, "drm") != 0)
+ glamor_set_glvnd_vendor(screen, gbm_backend_name);
+ }
#ifdef DRI3
/* Tell the core that we have the interfaces for import/export
* of pixmaps.
@@ -887,7 +927,9 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
/* To do DRI3 device FD generation, we need to open a new fd
* to the same device we were handed in originally.
*/
- glamor_egl->device_path = drmGetDeviceNameFromFd2(glamor_egl->fd);
+ glamor_egl->device_path = drmGetRenderDeviceNameFromFd(glamor_egl->fd);
+ if (!glamor_egl->device_path)
+ glamor_egl->device_path = drmGetDeviceNameFromFd2(glamor_egl->fd);
if (!dri3_screen_init(screen, &glamor_dri3_info)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -895,6 +937,13 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
}
}
#endif
+#ifdef GLXEXT
+ if (!vendor_initialized) {
+ GlxPushProvider(&glamor_provider);
+ xorgGlxCreateVendor();
+ vendor_initialized = TRUE;
+ }
+#endif
}
static void glamor_egl_cleanup(struct glamor_egl_screen_private *glamor_egl)
@@ -928,11 +977,115 @@ glamor_egl_free_screen(ScrnInfoPtr scrn)
}
}
+static Bool
+glamor_egl_try_big_gl_api(ScrnInfoPtr scrn)
+{
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+
+ if (eglBindAPI(EGL_OPENGL_API)) {
+ static const EGLint config_attribs_core[] = {
+ EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+ EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+ EGL_CONTEXT_MAJOR_VERSION_KHR,
+ GLAMOR_GL_CORE_VER_MAJOR,
+ EGL_CONTEXT_MINOR_VERSION_KHR,
+ GLAMOR_GL_CORE_VER_MINOR,
+ EGL_NONE
+ };
+ static const EGLint config_attribs[] = {
+ EGL_NONE
+ };
+
+ glamor_egl->context = eglCreateContext(glamor_egl->display,
+ EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
+ config_attribs_core);
+
+ if (glamor_egl->context == EGL_NO_CONTEXT)
+ glamor_egl->context = eglCreateContext(glamor_egl->display,
+ EGL_NO_CONFIG_KHR,
+ EGL_NO_CONTEXT,
+ config_attribs);
+ }
+
+ if (glamor_egl->context != EGL_NO_CONTEXT) {
+ if (!eglMakeCurrent(glamor_egl->display,
+ EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Failed to make GL context current\n");
+ return FALSE;
+ }
+
+ if (epoxy_gl_version() < 21) {
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "glamor: Ignoring GL < 2.1, falling back to GLES.\n");
+ eglDestroyContext(glamor_egl->display, glamor_egl->context);
+ glamor_egl->context = EGL_NO_CONTEXT;
+ }
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "glamor: Using OpenGL %d.%d context.\n",
+ epoxy_gl_version() / 10,
+ epoxy_gl_version() % 10);
+ }
+ return TRUE;
+}
+
+static Bool
+glamor_egl_try_gles_api(ScrnInfoPtr scrn)
+{
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+
+ static const EGLint config_attribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+ if (!eglBindAPI(EGL_OPENGL_ES_API)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "glamor: Failed to bind GLES API.\n");
+ return FALSE;
+ }
+
+ glamor_egl->context = eglCreateContext(glamor_egl->display,
+ EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
+ config_attribs);
+
+ if (glamor_egl->context != EGL_NO_CONTEXT) {
+ if (!eglMakeCurrent(glamor_egl->display,
+ EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Failed to make GLES context current\n");
+ return FALSE;
+ }
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "glamor: Using OpenGL ES %d.%d context.\n",
+ epoxy_gl_version() / 10,
+ epoxy_gl_version() % 10);
+ }
+ return TRUE;
+}
+
+enum {
+ GLAMOREGLOPT_RENDERING_API,
+ GLAMOREGLOPT_VENDOR_LIBRARY
+};
+
+static const OptionInfoRec GlamorEGLOptions[] = {
+ { GLAMOREGLOPT_RENDERING_API, "RenderingAPI", OPTV_STRING, {0}, FALSE },
+ { GLAMOREGLOPT_VENDOR_LIBRARY, "GlxVendorLibrary", OPTV_STRING, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE },
+};
+
Bool
glamor_egl_init(ScrnInfoPtr scrn, int fd)
{
struct glamor_egl_screen_private *glamor_egl;
const GLubyte *renderer;
+ OptionInfoPtr options;
+ const char *api = NULL;
+ Bool es_allowed = TRUE;
+ Bool force_es = FALSE;
+ const char *glvnd_vendor = NULL;
glamor_egl = calloc(sizeof(*glamor_egl), 1);
if (glamor_egl == NULL)
@@ -940,6 +1093,21 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
if (xf86GlamorEGLPrivateIndex == -1)
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+ options = xnfalloc(sizeof(GlamorEGLOptions));
+ memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions));
+ xf86ProcessOptions(scrn->scrnIndex, scrn->options, options);
+ glvnd_vendor = xf86GetOptValString(options, GLAMOREGLOPT_VENDOR_LIBRARY);
+ if (glvnd_vendor) {
+ glamor_set_glvnd_vendor(xf86ScrnToScreen(scrn), glvnd_vendor);
+ glamor_egl->force_vendor = TRUE;
+ }
+ api = xf86GetOptValString(options, GLAMOREGLOPT_RENDERING_API);
+ if (api && !strncasecmp(api, "es", 2))
+ force_es = TRUE;
+ else if (api && !strncasecmp(api, "gl", 2))
+ es_allowed = FALSE;
+ free(options);
+
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
glamor_egl->fd = fd;
glamor_egl->gbm = gbm_create_device(glamor_egl->fd);
@@ -977,74 +1145,20 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
GLAMOR_CHECK_EGL_EXTENSION(KHR_surfaceless_context);
GLAMOR_CHECK_EGL_EXTENSION(KHR_no_config_context);
- if (eglBindAPI(EGL_OPENGL_API)) {
- static const EGLint config_attribs_core[] = {
- EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
- EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
- EGL_CONTEXT_MAJOR_VERSION_KHR,
- GLAMOR_GL_CORE_VER_MAJOR,
- EGL_CONTEXT_MINOR_VERSION_KHR,
- GLAMOR_GL_CORE_VER_MINOR,
- EGL_NONE
- };
- static const EGLint config_attribs[] = {
- EGL_NONE
- };
-
- glamor_egl->context = eglCreateContext(glamor_egl->display,
- EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
- config_attribs_core);
-
- if (glamor_egl->context == EGL_NO_CONTEXT)
- glamor_egl->context = eglCreateContext(glamor_egl->display,
- EGL_NO_CONFIG_KHR,
- EGL_NO_CONTEXT,
- config_attribs);
+ if (!force_es) {
+ if(!glamor_egl_try_big_gl_api(scrn))
+ goto error;
}
- if (glamor_egl->context != EGL_NO_CONTEXT) {
- if (!eglMakeCurrent(glamor_egl->display,
- EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "Failed to make GL context current\n");
+ if (glamor_egl->context == EGL_NO_CONTEXT && es_allowed) {
+ if(!glamor_egl_try_gles_api(scrn))
goto error;
- }
-
- if (epoxy_gl_version() < 21) {
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "glamor: Ignoring GL < 2.1, falling back to GLES.\n");
- eglDestroyContext(glamor_egl->display, glamor_egl->context);
- glamor_egl->context = EGL_NO_CONTEXT;
- }
}
if (glamor_egl->context == EGL_NO_CONTEXT) {
- static const EGLint config_attribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL_NONE
- };
- if (!eglBindAPI(EGL_OPENGL_ES_API)) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "glamor: Failed to bind either GL or GLES APIs.\n");
- goto error;
- }
-
- glamor_egl->context = eglCreateContext(glamor_egl->display,
- EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
- config_attribs);
-
- if (glamor_egl->context == EGL_NO_CONTEXT) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "glamor: Failed to create GL or GLES2 contexts\n");
- goto error;
- }
-
- if (!eglMakeCurrent(glamor_egl->display,
- EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "Failed to make GLES2 context current\n");
- goto error;
- }
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "glamor: Failed to create GL or GLES2 contexts\n");
+ goto error;
}
renderer = glGetString(GL_RENDERER);
@@ -1053,7 +1167,12 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
"glGetString() returned NULL, your GL is broken\n");
goto error;
}
- if (strstr((const char *)renderer, "llvmpipe")) {
+ if (strstr((const char *)renderer, "softpipe")) {
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Refusing to try glamor on softpipe\n");
+ goto error;
+ }
+ if (!strncmp("llvmpipe", (const char *)renderer, strlen("llvmpipe"))) {
if (scrn->confScreen->num_gpu_devices)
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"Allowing glamor on llvmpipe for PRIME\n");
@@ -1087,6 +1206,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
if (xf86Info.debug != NULL)
glamor_egl->dmabuf_capable = !!strstr(xf86Info.debug,
"dmabuf_capable");
+ else if (strstr((const char *)renderer, "Intel"))
+ glamor_egl->dmabuf_capable = TRUE;
else
glamor_egl->dmabuf_capable = FALSE;
}
diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c
deleted file mode 100644
index 91ab9a7ae..000000000
--- a/glamor/glamor_egl_stubs.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright © 2013 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-/** @file glamor_egl_stubs.c
- *
- * Stubbed out glamor_egl.c functions for servers other than Xorg.
- */
-
-#include "dix-config.h"
-
-#include "glamor.h"
-
-void
-glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
-{
-}
-
-int
-glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
- PixmapPtr pixmap,
- CARD16 *stride, CARD32 *size)
-{
- return -1;
-}
-
-
-int
-glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
- uint32_t *offsets, uint32_t *strides,
- uint64_t *modifier)
-{
- return 0;
-}
-
-int
-glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
- CARD16 *stride, CARD32 *size)
-{
- return -1;
-}
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index e045d247e..0db9d6858 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -355,7 +355,7 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, int flag)
return TRUE;
}
-_X_EXPORT void
+void
glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back)
{
glamor_pixmap_private *front_priv, *back_priv;
diff --git a/hw/xwayland/xwayland-glx.c b/glamor/glamor_glx_provider.c
index a3e85fc2f..77ccc3c8b 100644
--- a/hw/xwayland/xwayland-glx.c
+++ b/glamor/glamor_glx_provider.c
@@ -30,21 +30,18 @@
* can do, which often does not include things like multisample visuals.
*/
-#include <xwayland-config.h>
+#include <dix-config.h>
#define MESA_EGL_NO_X11_HEADERS
#define EGL_NO_X11
-// #include <EGL/egl.h>
#include <epoxy/egl.h>
#include "glxserver.h"
#include "glxutil.h"
#include "compint.h"
#include <X11/extensions/composite.h>
-#include "glamor_context.h"
+#include "glamor_priv.h"
#include "glamor.h"
-#include "xwayland-screen.h"
-
/* Can't get these from <GL/glx.h> since it pulls in client headers */
#define GLX_RGBA_BIT 0x00000001
#define GLX_WINDOW_BIT 0x00000001
@@ -339,7 +336,7 @@ egl_mirror_configs(ScreenPtr pScreen, struct egl_screen *screen)
/* We walk the EGL configs backwards to make building the
* ->next chain easier.
*/
- for (i = nconfigs - 1; i > 0; i--)
+ for (i = nconfigs - 1; i >= 0; i--)
for (j = 0; j < 3; j++) /* direct_color */
for (k = 0; k < 2; k++) /* double_buffer */ {
if (can_srgb)
@@ -364,12 +361,16 @@ static __GLXscreen *
egl_screen_probe(ScreenPtr pScreen)
{
struct egl_screen *screen;
- struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
+ glamor_screen_private *glamor_screen;
__GLXscreen *base;
if (enableIndirectGLX)
return NULL; /* not implemented */
+ glamor_screen = glamor_get_screen_private(pScreen);
+ if (!glamor_screen)
+ return NULL;
+
if (!(screen = calloc(1, sizeof *screen)))
return NULL;
@@ -378,7 +379,7 @@ egl_screen_probe(ScreenPtr pScreen)
base->createDrawable = egl_create_glx_drawable;
/* base.swapInterval = NULL; */
- screen->display = xwl_screen->glamor_ctx->display;
+ screen->display = glamor_screen->ctx.display;
__glXInitExtensionEnableBits(screen->base.glx_enable_bits);
__glXEnableExtension(base->glx_enable_bits, "GLX_ARB_context_flush_control");
@@ -402,8 +403,8 @@ egl_screen_probe(ScreenPtr pScreen)
return NULL;
}
- if (!screen->base.glvnd && xwl_screen->glvnd_vendor)
- screen->base.glvnd = strdup(xwl_screen->glvnd_vendor);
+ if (!screen->base.glvnd && glamor_screen->glvnd_vendor)
+ screen->base.glvnd = strdup(glamor_screen->glvnd_vendor);
if (!screen->base.glvnd)
screen->base.glvnd = strdup("mesa");
diff --git a/hw/xwayland/xwayland-glx.h b/glamor/glamor_glx_provider.h
index 62c9fb7ce..b0db90e47 100644
--- a/hw/xwayland/xwayland-glx.h
+++ b/glamor/glamor_glx_provider.h
@@ -27,11 +27,11 @@
#ifndef XWAYLAND_GLX_H
#define XWAYLAND_GLX_H
-#include <xwayland-config.h>
+#include <dix-config.h>
#ifdef GLXEXT
#include "glx_extinit.h"
-extern __GLXprovider glamor_provider;
+extern _X_EXPORT __GLXprovider glamor_provider;
#endif
#endif /* XWAYLAND_GLX_H */
diff --git a/glamor/glamor_glyphblt.c b/glamor/glamor_glyphblt.c
index 78315ea9b..4ab23b333 100644
--- a/glamor/glamor_glyphblt.c
+++ b/glamor/glamor_glyphblt.c
@@ -32,8 +32,9 @@
static const glamor_facet glamor_facet_poly_glyph_blt = {
.name = "poly_glyph_blt",
- .vs_vars = "attribute vec2 primitive;\n",
+ .vs_vars = "in vec2 primitive;\n",
.vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_DEFAULT_POINT_SIZE
GLAMOR_POS(gl_Position, primitive)),
};
@@ -57,7 +58,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
glamor_make_current(glamor_priv);
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->poly_glyph_blt_progs,
&glamor_facet_poly_glyph_blt);
if (!prog)
@@ -101,7 +102,11 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
int pt_x_i = glyph_x + xx;
int pt_y_i = glyph_y + yy;
+#if BITMAP_BIT_ORDER == MSBFirst
+ if (!(*glyph & (128 >> (xx & 7))))
+#else
if (!(*glyph & (1 << (xx & 7))))
+#endif
continue;
if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL))
@@ -188,7 +193,7 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
glamor_make_current(glamor_priv);
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->poly_glyph_blt_progs,
&glamor_facet_poly_glyph_blt);
if (!prog)
@@ -208,7 +213,11 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
for (yy = 0; yy < h; yy++) {
uint8_t *bitmap_row = bitmap_data + yy * bitmap_stride;
for (xx = 0; xx < w; xx++) {
+#if BITMAP_BIT_ORDER == MSBFirst
+ if (bitmap_row[xx / 8] & (128 >> xx % 8) &&
+#else
if (bitmap_row[xx / 8] & (1 << xx % 8) &&
+#endif
RegionContainsPoint(clip,
x + xx,
y + yy,
diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 7e5d5cca9..558e14311 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -177,7 +177,7 @@ _glamor_create_getcolor_fs_source(ScreenPtr screen, int stops_count,
}
}
-static void
+static Bool
_glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
int dyn_gen)
{
@@ -316,7 +316,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
if ((glamor_priv->radial_max_nstops >= stops_count) && (dyn_gen)) {
/* Very Good, not to generate again. */
- return;
+ return TRUE;
}
glamor_make_current(glamor_priv);
@@ -353,7 +353,10 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
- glamor_link_glsl_prog(screen, gradient_prog, "radial gradient");
+ if (!glamor_link_glsl_prog(screen, gradient_prog, "radial gradient")) {
+ glDeleteProgram(gradient_prog);
+ return FALSE;
+ }
if (dyn_gen) {
index = 2;
@@ -367,9 +370,11 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
}
glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][index] = gradient_prog;
+
+ return TRUE;
}
-static void
+static Bool
_glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
int dyn_gen)
{
@@ -500,7 +505,7 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
if ((glamor_priv->linear_max_nstops >= stops_count) && (dyn_gen)) {
/* Very Good, not to generate again. */
- return;
+ return TRUE;
}
glamor_make_current(glamor_priv);
@@ -533,7 +538,10 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
- glamor_link_glsl_prog(screen, gradient_prog, "linear gradient");
+ if (!glamor_link_glsl_prog(screen, gradient_prog, "linear gradient")) {
+ glDeleteProgram(gradient_prog);
+ return FALSE;
+ }
if (dyn_gen) {
index = 2;
@@ -547,9 +555,11 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
}
glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][index] = gradient_prog;
+
+ return TRUE;
}
-void
+Bool
glamor_init_gradient_shader(ScreenPtr screen)
{
glamor_screen_private *glamor_priv;
@@ -564,11 +574,15 @@ glamor_init_gradient_shader(ScreenPtr screen)
glamor_priv->linear_max_nstops = 0;
glamor_priv->radial_max_nstops = 0;
- _glamor_create_linear_gradient_program(screen, 0, 0);
- _glamor_create_linear_gradient_program(screen, LINEAR_LARGE_STOPS, 0);
+ if (!_glamor_create_linear_gradient_program(screen, 0, 0) ||
+ !_glamor_create_linear_gradient_program(screen, LINEAR_LARGE_STOPS, 0))
+ return FALSE;
+
+ if (!_glamor_create_radial_gradient_program(screen, 0, 0) ||
+ !_glamor_create_radial_gradient_program(screen, RADIAL_LARGE_STOPS, 0))
+ return FALSE;
- _glamor_create_radial_gradient_program(screen, 0, 0);
- _glamor_create_radial_gradient_program(screen, RADIAL_LARGE_STOPS, 0);
+ return TRUE;
}
static void
@@ -605,27 +619,35 @@ _glamor_gradient_convert_trans_matrix(PictTransform *from, float to[3][3],
* T_s = | w*t21/h t22 t23/h|
* | w*t31 h*t32 t33 |
* -- --
+ *
+ * Because GLES2 cannot do trasposed mat by spec, we did transposing inside this function
+ * already, and matrix becoming look like this:
+ * -- --
+ * | t11 w*t21/h t31*w|
+ * T_s = | h*t12/w t22 t32*h|
+ * | t13/w t23/h t33 |
+ * -- --
*/
to[0][0] = (float) pixman_fixed_to_double(from->matrix[0][0]);
- to[0][1] = (float) pixman_fixed_to_double(from->matrix[0][1])
+ to[1][0] = (float) pixman_fixed_to_double(from->matrix[0][1])
* (normalize ? (((float) height) / ((float) width)) : 1.0);
- to[0][2] = (float) pixman_fixed_to_double(from->matrix[0][2])
+ to[2][0] = (float) pixman_fixed_to_double(from->matrix[0][2])
/ (normalize ? ((float) width) : 1.0);
- to[1][0] = (float) pixman_fixed_to_double(from->matrix[1][0])
+ to[0][1] = (float) pixman_fixed_to_double(from->matrix[1][0])
* (normalize ? (((float) width) / ((float) height)) : 1.0);
to[1][1] = (float) pixman_fixed_to_double(from->matrix[1][1]);
- to[1][2] = (float) pixman_fixed_to_double(from->matrix[1][2])
+ to[2][1] = (float) pixman_fixed_to_double(from->matrix[1][2])
/ (normalize ? ((float) height) : 1.0);
- to[2][0] = (float) pixman_fixed_to_double(from->matrix[2][0])
+ to[0][2] = (float) pixman_fixed_to_double(from->matrix[2][0])
* (normalize ? ((float) width) : 1.0);
- to[2][1] = (float) pixman_fixed_to_double(from->matrix[2][1])
+ to[1][2] = (float) pixman_fixed_to_double(from->matrix[2][1])
* (normalize ? ((float) height) : 1.0);
to[2][2] = (float) pixman_fixed_to_double(from->matrix[2][2]);
- DEBUGF("the transform matrix is:\n%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f\n",
+ DEBUGF("the transposed transform matrix is:\n%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f\n",
to[0][0], to[0][1], to[0][2],
to[1][0], to[1][1], to[1][2], to[2][0], to[2][1], to[2][2]);
}
@@ -950,11 +972,12 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
_glamor_gradient_convert_trans_matrix(src_picture->transform,
transform_mat, width, height, 0);
glUniformMatrix3fv(transform_mat_uniform_location,
- 1, 1, &transform_mat[0][0]);
+ 1, GL_FALSE, &transform_mat[0][0]);
}
else {
+ /* identity matrix dont need to be transposed */
glUniformMatrix3fv(transform_mat_uniform_location,
- 1, 1, &identity_mat[0][0]);
+ 1, GL_FALSE, &identity_mat[0][0]);
}
if (!_glamor_gradient_set_pixmap_destination
@@ -962,7 +985,7 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
0))
goto GRADIENT_FAIL;
- glamor_set_alu(screen, GXcopy);
+ glamor_set_alu(&pixmap->drawable, GXcopy);
/* Set all the stops and colors to shader. */
if (stops_count > RADIAL_SMALL_STOPS) {
@@ -1266,11 +1289,12 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
_glamor_gradient_convert_trans_matrix(src_picture->transform,
transform_mat, width, height, 1);
glUniformMatrix3fv(transform_mat_uniform_location,
- 1, 1, &transform_mat[0][0]);
+ 1, GL_FALSE, &transform_mat[0][0]);
}
else {
+ /* identity matrix dont need to be transposed */
glUniformMatrix3fv(transform_mat_uniform_location,
- 1, 1, &identity_mat[0][0]);
+ 1, GL_FALSE, &identity_mat[0][0]);
}
if (!_glamor_gradient_set_pixmap_destination
@@ -1278,7 +1302,7 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
1))
goto GRADIENT_FAIL;
- glamor_set_alu(screen, GXcopy);
+ glamor_set_alu(&pixmap->drawable, GXcopy);
/* Normalize the PTs. */
glamor_set_normalize_pt(xscale, yscale,
diff --git a/glamor/glamor_image.c b/glamor/glamor_image.c
index 453ef79ba..28bdc159f 100644
--- a/glamor/glamor_image.c
+++ b/glamor/glamor_image.c
@@ -76,7 +76,7 @@ glamor_put_image_gl(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glamor_make_current(glamor_priv);
- glamor_upload_region(pixmap, &region, x, y, (uint8_t *) bits, byte_stride);
+ glamor_upload_region(drawable, &region, x, y, (uint8_t *) bits, byte_stride);
RegionUninit(&region);
return TRUE;
@@ -124,12 +124,12 @@ glamor_get_image_gl(DrawablePtr drawable, int x, int y, int w, int h,
box.x2 = x + w;
box.y1 = y;
box.y2 = y + h;
- glamor_download_boxes(pixmap, &box, 1,
+ glamor_download_boxes(drawable, &box, 1,
drawable->x + off_x, drawable->y + off_y,
-x, -y,
(uint8_t *) d, byte_stride);
- if (!glamor_pm_is_solid(drawable->depth, plane_mask)) {
+ if (!glamor_pm_is_solid(glamor_drawable_effective_depth(drawable), plane_mask)) {
FbStip pm = fbReplicatePixel(plane_mask, drawable->bitsPerPixel);
FbStip *dst = (void *)d;
uint32_t dstStride = byte_stride / sizeof(FbStip);
diff --git a/glamor/glamor_lines.c b/glamor/glamor_lines.c
index 5d95333fe..c9b776bb5 100644
--- a/glamor/glamor_lines.c
+++ b/glamor/glamor_lines.c
@@ -27,7 +27,7 @@
static const glamor_facet glamor_facet_poly_lines = {
.name = "poly_lines",
- .vs_vars = "attribute vec2 primitive;\n",
+ .vs_vars = "in vec2 primitive;\n",
.vs_exec = (" vec2 pos = vec2(0.0,0.0);\n"
GLAMOR_POS(gl_Position, primitive.xy)),
};
@@ -61,7 +61,7 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
glamor_make_current(glamor_priv);
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->poly_line_program,
&glamor_facet_poly_lines);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 33b3bebd9..2152b85e1 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -94,7 +94,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr pScreen,
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8;
} else {
- *tex_format = GL_RGBA;
+ *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_BYTE;
swizzle[0] = GL_GREEN;
@@ -113,12 +113,9 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr pScreen,
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
} else {
- *tex_format = GL_RGBA;
+ *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_BYTE;
- swizzle[0] = GL_BLUE;
- swizzle[2] = GL_RED;
-
if (!is_little_endian)
byte_swap_swizzle(swizzle);
break;
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 9aa169cdc..c573e7982 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -39,7 +39,7 @@ void
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
int *x, int *y)
{
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (drawable->type == DRAWABLE_WINDOW) {
*x = -pixmap->screen_x;
*y = -pixmap->screen_y;
@@ -120,8 +120,9 @@ glamor_set_planemask(int depth, unsigned long planemask)
}
Bool
-glamor_set_alu(ScreenPtr screen, unsigned char alu)
+glamor_set_alu(DrawablePtr drawable, unsigned char alu)
{
+ ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
if (glamor_priv->is_gles) {
@@ -135,6 +136,21 @@ glamor_set_alu(ScreenPtr screen, unsigned char alu)
glDisable(GL_COLOR_LOGIC_OP);
return TRUE;
}
+
+ switch (alu) {
+ case GXnoop:
+ case GXor:
+ case GXset:
+ /* These leave the alpha channel at 1.0 */
+ break;
+ default:
+ if (glamor_drawable_effective_depth(drawable) == 24 &&
+ glamor_get_drawable_pixmap(drawable)->drawable.depth == 32) {
+ glamor_fallback("ALU %x not supported with mixed depth\n", alu);
+ return FALSE;
+ }
+ }
+
glEnable(GL_COLOR_LOGIC_OP);
switch (alu) {
case GXclear:
diff --git a/glamor/glamor_points.c b/glamor/glamor_points.c
index faf6f433b..91b5e4789 100644
--- a/glamor/glamor_points.c
+++ b/glamor/glamor_points.c
@@ -31,8 +31,9 @@
static const glamor_facet glamor_facet_point = {
.name = "poly_point",
- .vs_vars = "attribute vec2 primitive;\n",
- .vs_exec = GLAMOR_POS(gl_Position, primitive),
+ .vs_vars = "in vec2 primitive;\n",
+ .vs_exec = (GLAMOR_DEFAULT_POINT_SIZE
+ GLAMOR_POS(gl_Position, primitive)),
};
static Bool
@@ -66,7 +67,7 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
goto bail;
}
- if (!glamor_use_program(pixmap, gc, prog, NULL))
+ if (!glamor_use_program(drawable, gc, prog, NULL))
goto bail;
vbo_ppt = glamor_get_vbo_space(screen, npt * (2 * sizeof (INT16)), &vbo_offset);
diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 835c4ebea..fba875e28 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -25,19 +25,21 @@
#include "glamor_transfer.h"
/*
- * Make a pixmap ready to draw with fb by
+ * Make a drawable ready to draw with fb by
* creating a PBO large enough for the whole object
* and downloading all of the FBOs into it.
*/
static Bool
-glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
+glamor_prep_drawable_box(DrawablePtr drawable, glamor_access_t access, BoxPtr box)
{
- ScreenPtr screen = pixmap->drawable.pScreen;
+ ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int gl_access, gl_usage;
RegionRec region;
+ int off_x, off_y;
if (priv->type == GLAMOR_DRM_ONLY)
return FALSE;
@@ -47,6 +49,11 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
glamor_make_current(glamor_priv);
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+ box->x1 += off_x;
+ box->x2 += off_x;
+ box->y1 += off_y;
+ box->y2 += off_y;
RegionInit(&region, box, 1);
/* See if it's already mapped */
@@ -119,7 +126,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
priv->map_access = access;
}
- glamor_download_boxes(pixmap, RegionRects(&region), RegionNumRects(&region),
+ glamor_download_boxes(drawable, RegionRects(&region), RegionNumRects(&region),
0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
RegionUninit(&region);
@@ -143,9 +150,10 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
* if we were writing to it and then unbind it to release the memory
*/
-static void
-glamor_fini_pixmap(PixmapPtr pixmap)
+void
+glamor_finish_access(DrawablePtr drawable)
{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
@@ -154,14 +162,15 @@ glamor_fini_pixmap(PixmapPtr pixmap)
if (!priv->prepared)
return;
- if (priv->pbo) {
+ if (priv->pbo &&
+ !(glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32)) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, priv->pbo);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
pixmap->devPrivate.ptr = NULL;
}
if (priv->map_access == GLAMOR_ACCESS_RW) {
- glamor_upload_boxes(pixmap,
+ glamor_upload_boxes(drawable,
RegionRects(&priv->prepare_region),
RegionNumRects(&priv->prepare_region),
0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
@@ -170,7 +179,11 @@ glamor_fini_pixmap(PixmapPtr pixmap)
RegionUninit(&priv->prepare_region);
if (priv->pbo) {
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ if (glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32)
+ pixmap->devPrivate.ptr = NULL;
+ else
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+
glDeleteBuffers(1, &priv->pbo);
priv->pbo = 0;
} else {
@@ -184,39 +197,26 @@ glamor_fini_pixmap(PixmapPtr pixmap)
Bool
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
{
- PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
BoxRec box;
- int off_x, off_y;
- glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
-
- box.x1 = drawable->x + off_x;
+ box.x1 = drawable->x;
box.x2 = box.x1 + drawable->width;
- box.y1 = drawable->y + off_y;
+ box.y1 = drawable->y;
box.y2 = box.y1 + drawable->height;
- return glamor_prep_pixmap_box(pixmap, access, &box);
+ return glamor_prep_drawable_box(drawable, access, &box);
}
Bool
glamor_prepare_access_box(DrawablePtr drawable, glamor_access_t access,
int x, int y, int w, int h)
{
- PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
BoxRec box;
- int off_x, off_y;
- glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
- box.x1 = drawable->x + x + off_x;
+ box.x1 = drawable->x + x;
box.x2 = box.x1 + w;
- box.y1 = drawable->y + y + off_y;
+ box.y1 = drawable->y + y;
box.y2 = box.y1 + h;
- return glamor_prep_pixmap_box(pixmap, access, &box);
-}
-
-void
-glamor_finish_access(DrawablePtr drawable)
-{
- glamor_fini_pixmap(glamor_get_drawable_pixmap(drawable));
+ return glamor_prep_drawable_box(drawable, access, &box);
}
/*
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 028a6d374..5a0dc2e2d 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -49,6 +49,24 @@
"precision mediump float;\n" \
"#endif\n"
+#define GLAMOR_DEFAULT_POINT_SIZE \
+ "#ifdef GL_ES\n" \
+ " gl_PointSize = 1.0;\n" \
+ "#endif\n"
+
+#define GLAMOR_COMPAT_DEFINES_VS \
+ "#define in attribute\n" \
+ "#define out varying\n" \
+
+#define GLAMOR_COMPAT_DEFINES_FS \
+ "#if __VERSION__ < 130\n" \
+ "#define in varying\n" \
+ "#define frag_color gl_FragColor\n" \
+ "#define texture texture2D\n" \
+ "#else\n" \
+ "out vec4 frag_color;\n" \
+ "#endif\n"
+
#include "glyphstr.h"
#include "glamor_debug.h"
@@ -111,6 +129,7 @@ enum shader_mask {
enum shader_dest_swizzle {
SHADER_DEST_SWIZZLE_DEFAULT,
SHADER_DEST_SWIZZLE_ALPHA_TO_RED,
+ SHADER_DEST_SWIZZLE_IGNORE_ALPHA,
SHADER_DEST_SWIZZLE_COUNT,
};
@@ -175,6 +194,13 @@ struct glamor_format {
* just before upload)
*/
Bool rendering_supported;
+ /**
+ * Whether image with this depth is framebuffer-complete in GL.
+ * This flag is set on GL ES when rendering is supported without
+ * conversion, but reading from framebuffer can bring some caveats
+ * like different format combination or incomplete framebuffer.
+ */
+ Bool texture_only;
};
struct glamor_saved_procs {
@@ -216,10 +242,12 @@ typedef struct glamor_screen_private {
Bool has_dual_blend;
Bool has_clear_texture;
Bool has_texture_swizzle;
+ Bool has_rg;
Bool is_core_profile;
Bool can_copyplane;
Bool use_gpu_shader4;
int max_fbo_size;
+ Bool enable_gradient_shader;
/**
* Stores information about supported formats. Note, that this list contains all
@@ -309,10 +337,12 @@ typedef struct glamor_screen_private {
int flags;
ScreenPtr screen;
int dri3_enabled;
+ char *glvnd_vendor;
Bool suppress_gl_out_of_memory_logging;
Bool logged_any_fbo_allocation_failure;
Bool logged_any_pbo_allocation_failure;
+ Bool dirty;
/* xv */
glamor_program xv_prog;
@@ -511,6 +541,30 @@ glamor_pixmap_hcnt(glamor_pixmap_private *priv)
for (box_index = 0; box_index < glamor_pixmap_hcnt(priv) * \
glamor_pixmap_wcnt(priv); box_index++) \
+static inline int
+glamor_drawable_effective_depth(DrawablePtr drawable)
+{
+ WindowPtr window;
+
+ if (drawable->type != DRAWABLE_WINDOW ||
+ drawable->depth != 32)
+ return drawable->depth;
+
+ window = (WindowPtr)drawable;
+ window = window->parent;
+ while (window && window->parent) {
+ /* A depth 32 window with any depth 24 ancestors (other than the root
+ * window) effectively behaves like depth 24
+ */
+ if (window->drawable.depth == 24)
+ return 24;
+
+ window = window->parent;
+ }
+
+ return 32;
+}
+
/* GC private structure. Currently holds only any computed dash pixmap */
typedef struct {
@@ -601,7 +655,7 @@ Bool glamor_get_drawable_location(const DrawablePtr drawable);
void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
int *x, int *y);
GLint glamor_compile_glsl_prog(GLenum type, const char *source);
-void glamor_link_glsl_prog(ScreenPtr screen, GLint prog,
+Bool glamor_link_glsl_prog(ScreenPtr screen, GLint prog,
const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
unsigned long fg_pixel, GLfloat *color);
@@ -615,7 +669,7 @@ void glamor_set_destination_pixmap_fbo(glamor_screen_private *glamor_priv, glamo
* */
void glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
-Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
+Bool glamor_set_alu(DrawablePtr drawable, unsigned char alu);
Bool glamor_set_planemask(int depth, unsigned long planemask);
RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
@@ -657,7 +711,7 @@ void glamor_trapezoids(CARD8 op,
int ntrap, xTrapezoid *traps);
/* glamor_gradient.c */
-void glamor_init_gradient_shader(ScreenPtr screen);
+Bool glamor_init_gradient_shader(ScreenPtr screen);
PicturePtr glamor_generate_linear_gradient_picture(ScreenPtr screen,
PicturePtr src_picture,
int x_source, int y_source,
@@ -869,7 +923,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
unsigned long fg_pixel);
void
-glamor_solid_boxes(PixmapPtr pixmap,
+glamor_solid_boxes(DrawablePtr drawable,
BoxPtr box, int nbox, unsigned long fg_pixel);
@@ -892,6 +946,9 @@ typedef struct {
RegionRec clip;
PixmapPtr src_pix[3]; /* y, u, v for planar */
int src_pix_w, src_pix_h;
+ /* Port optimization */
+ int prev_fmt;
+ glamor_program xv_prog;
} glamor_port_private;
extern XvAttributeRec glamor_xv_attributes[];
@@ -931,6 +988,4 @@ void glamor_xv_render(glamor_port_private *port_priv, int id);
#include "glamor_font.h"
-#define GLAMOR_MIN_ALU_INSTRUCTIONS 128 /* Minimum required number of native ALU instructions */
-
#endif /* GLAMOR_PRIV_H */
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index d8ddb4c77..21f8987d9 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -25,36 +25,36 @@
#include "glamor_program.h"
static Bool
-use_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_solid(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
- return glamor_set_solid(pixmap, gc, TRUE, prog->fg_uniform);
+ return glamor_set_solid(drawable, gc, TRUE, prog->fg_uniform);
}
const glamor_facet glamor_fill_solid = {
.name = "solid",
- .fs_exec = " gl_FragColor = fg;\n",
+ .fs_exec = " frag_color = fg;\n",
.locations = glamor_program_location_fg,
.use = use_solid,
};
static Bool
-use_tile(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_tile(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
- return glamor_set_tiled(pixmap, gc, prog->fill_offset_uniform, prog->fill_size_inv_uniform);
+ return glamor_set_tiled(drawable, gc, prog->fill_offset_uniform, prog->fill_size_inv_uniform);
}
static const glamor_facet glamor_fill_tile = {
.name = "tile",
.vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;\n",
- .fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
+ .fs_exec = " frag_color = texture(sampler, fill_pos);\n",
.locations = glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_tile,
};
static Bool
-use_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_stipple(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
- return glamor_set_stippled(pixmap, gc, prog->fg_uniform,
+ return glamor_set_stippled(drawable, gc, prog->fg_uniform,
prog->fill_offset_uniform,
prog->fill_size_inv_uniform);
}
@@ -62,31 +62,31 @@ use_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
static const glamor_facet glamor_fill_stipple = {
.name = "stipple",
.vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;\n",
- .fs_exec = (" float a = texture2D(sampler, fill_pos).w;\n"
+ .fs_exec = (" float a = texture(sampler, fill_pos).w;\n"
" if (a == 0.0)\n"
" discard;\n"
- " gl_FragColor = fg;\n"),
+ " frag_color = fg;\n"),
.locations = glamor_program_location_fg | glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_stipple,
};
static Bool
-use_opaque_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_opaque_stipple(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
- if (!use_stipple(pixmap, gc, prog, arg))
+ if (!use_stipple(drawable, gc, prog, arg))
return FALSE;
- glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+ glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
return TRUE;
}
static const glamor_facet glamor_fill_opaque_stipple = {
.name = "opaque_stipple",
.vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;\n",
- .fs_exec = (" float a = texture2D(sampler, fill_pos).w;\n"
+ .fs_exec = (" float a = texture(sampler, fill_pos).w;\n"
" if (a == 0.0)\n"
- " gl_FragColor = bg;\n"
+ " frag_color = bg;\n"
" else\n"
- " gl_FragColor = fg;\n"),
+ " frag_color = fg;\n"),
.locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_opaque_stipple
};
@@ -121,12 +121,15 @@ static glamor_location_var location_vars[] = {
.location = glamor_program_location_fillpos,
.vs_vars = ("uniform vec2 fill_offset;\n"
"uniform vec2 fill_size_inv;\n"
- "varying vec2 fill_pos;\n"),
- .fs_vars = ("varying vec2 fill_pos;\n")
+ "out vec2 fill_pos;\n"),
+ .fs_vars = ("in vec2 fill_pos;\n")
},
{
.location = glamor_program_location_font,
- .fs_vars = "uniform usampler2D font;\n",
+ .fs_vars = ("#ifdef GL_ES\n"
+ "precision mediump usampler2D;\n"
+ "#endif\n"
+ "uniform usampler2D font;\n"),
},
{
.location = glamor_program_location_bitplane,
@@ -188,6 +191,7 @@ fs_location_vars(glamor_program_location locations)
static const char vs_template[] =
"%s" /* version */
"%s" /* exts */
+ "%s" /* in/out defines */
"%s" /* defines */
"%s" /* prim vs_vars */
"%s" /* fill vs_vars */
@@ -201,7 +205,10 @@ static const char vs_template[] =
static const char fs_template[] =
"%s" /* version */
"%s" /* exts */
+ "%s" /* prim fs_extensions */
+ "%s" /* fill fs_extensions */
GLAMOR_DEFAULT_PRECISION
+ "%s" /* in/out defines */
"%s" /* defines */
"%s" /* prim fs_vars */
"%s" /* fill fs_vars */
@@ -282,6 +289,13 @@ glamor_build_program(ScreenPtr screen,
}
}
+ if (version == 130 && glamor_priv->is_gles && glamor_priv->glsl_version > 110)
+ version = 300;
+ else if (glamor_priv->is_gles)
+ version = 100;
+ else if (!version)
+ version = 120;
+
vs_vars = vs_location_vars(locations);
fs_vars = fs_location_vars(locations);
@@ -291,7 +305,8 @@ glamor_build_program(ScreenPtr screen,
goto fail;
if (version) {
- if (asprintf(&version_string, "#version %d\n", version) < 0)
+ if (asprintf(&version_string, "#version %d %s\n", version,
+ glamor_priv->is_gles && version > 100 ? "es" : "") < 0)
version_string = NULL;
if (!version_string)
goto fail;
@@ -301,6 +316,7 @@ glamor_build_program(ScreenPtr screen,
vs_template,
str(version_string),
gpu_shader4 ? "#extension GL_EXT_gpu_shader4 : require\n" : "",
+ version < 130 ? GLAMOR_COMPAT_DEFINES_VS : "",
str(defines),
str(prim->vs_vars),
str(fill->vs_vars),
@@ -312,7 +328,10 @@ glamor_build_program(ScreenPtr screen,
if (asprintf(&fs_prog_string,
fs_template,
str(version_string),
+ str(prim->fs_extensions),
+ str(fill->fs_extensions),
gpu_shader4 ? "#extension GL_EXT_gpu_shader4 : require\n#define texelFetch texelFetch2D\n#define uint unsigned int\n" : "",
+ GLAMOR_COMPAT_DEFINES_FS,
str(defines),
str(prim->fs_vars),
str(fill->fs_vars),
@@ -359,7 +378,8 @@ glamor_build_program(ScreenPtr screen,
glBindFragDataLocationIndexed(prog->prog, 0, 1, "color1");
}
- glamor_link_glsl_prog(screen, prog->prog, "%s_%s", prim->name, fill->name);
+ if (!glamor_link_glsl_prog(screen, prog->prog, "%s_%s", prim->name, fill->name))
+ goto fail;
prog->matrix_uniform = glamor_get_uniform(prog, glamor_program_location_none, "v_matrix");
prog->fg_uniform = glamor_get_uniform(prog, glamor_program_location_fg, "fg");
@@ -392,29 +412,29 @@ fail:
}
Bool
-glamor_use_program(PixmapPtr pixmap,
+glamor_use_program(DrawablePtr drawable,
GCPtr gc,
glamor_program *prog,
void *arg)
{
glUseProgram(prog->prog);
- if (prog->prim_use && !prog->prim_use(pixmap, gc, prog, arg))
+ if (prog->prim_use && !prog->prim_use(drawable, gc, prog, arg))
return FALSE;
- if (prog->fill_use && !prog->fill_use(pixmap, gc, prog, arg))
+ if (prog->fill_use && !prog->fill_use(drawable, gc, prog, arg))
return FALSE;
return TRUE;
}
glamor_program *
-glamor_use_program_fill(PixmapPtr pixmap,
+glamor_use_program_fill(DrawablePtr drawable,
GCPtr gc,
glamor_program_fill *program_fill,
const glamor_facet *prim)
{
- ScreenPtr screen = pixmap->drawable.pScreen;
+ ScreenPtr screen = drawable->pScreen;
glamor_program *prog = &program_fill->progs[gc->fillStyle];
int fill_style = gc->fillStyle;
@@ -432,7 +452,7 @@ glamor_use_program_fill(PixmapPtr pixmap,
return NULL;
}
- if (!glamor_use_program(pixmap, gc, prog, NULL))
+ if (!glamor_use_program(drawable, gc, prog, NULL))
return NULL;
return prog;
@@ -494,7 +514,8 @@ glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
}
/* Set up the source alpha value for blending in component alpha mode. */
- if (alpha == glamor_program_alpha_dual_blend) {
+ if (alpha == glamor_program_alpha_dual_blend ||
+ alpha == glamor_program_alpha_dual_blend_gles2) {
switch (dst_blend) {
case GL_SRC_ALPHA:
dst_blend = GL_SRC1_COLOR;
@@ -553,7 +574,7 @@ use_source_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *pro
static const glamor_facet glamor_source_picture = {
.name = "render_picture",
.vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;\n",
- .fs_exec = " vec4 source = texture2D(sampler, fill_pos);\n",
+ .fs_exec = " vec4 source = texture(sampler, fill_pos);\n",
.locations = glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use_render = use_source_picture,
};
@@ -569,7 +590,7 @@ use_source_1x1_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program
static const glamor_facet glamor_source_1x1_picture = {
.name = "render_picture",
- .fs_exec = " vec4 source = texture2D(sampler, vec2(0.5));\n",
+ .fs_exec = " vec4 source = texture(sampler, vec2(0.5));\n",
.locations = glamor_program_location_fillsamp,
.use_render = use_source_1x1_picture,
};
@@ -581,11 +602,13 @@ static const glamor_facet *glamor_facet_source[glamor_program_source_count] = {
};
static const char *glamor_combine[] = {
- [glamor_program_alpha_normal] = " gl_FragColor = source * mask.a;\n",
- [glamor_program_alpha_ca_first] = " gl_FragColor = source.a * mask;\n",
- [glamor_program_alpha_ca_second] = " gl_FragColor = source * mask;\n",
+ [glamor_program_alpha_normal] = " frag_color = source * mask.a;\n",
+ [glamor_program_alpha_ca_first] = " frag_color = source.a * mask;\n",
+ [glamor_program_alpha_ca_second] = " frag_color = source * mask;\n",
[glamor_program_alpha_dual_blend] = " color0 = source * mask;\n"
- " color1 = source.a * mask;\n"
+ " color1 = source.a * mask;\n",
+ [glamor_program_alpha_dual_blend_gles2] = " gl_FragColor = source * mask;\n"
+ " gl_SecondaryFragColorEXT = source.a * mask;\n"
};
static Bool
@@ -633,7 +656,9 @@ glamor_setup_program_render(CARD8 op,
if (glamor_is_component_alpha(mask)) {
if (glamor_priv->has_dual_blend) {
- alpha = glamor_program_alpha_dual_blend;
+ alpha = glamor_glsl_has_ints(glamor_priv) ?
+ glamor_program_alpha_dual_blend :
+ glamor_program_alpha_dual_blend_gles2;
} else {
/* This only works for PictOpOver */
if (op != PictOpOver)
diff --git a/glamor/glamor_program.h b/glamor/glamor_program.h
index ab6e46f7b..72bf1fc3f 100644
--- a/glamor/glamor_program.h
+++ b/glamor/glamor_program.h
@@ -44,20 +44,21 @@ typedef enum {
glamor_program_alpha_ca_first,
glamor_program_alpha_ca_second,
glamor_program_alpha_dual_blend,
+ glamor_program_alpha_dual_blend_gles2,
glamor_program_alpha_count
} glamor_program_alpha;
typedef struct _glamor_program glamor_program;
-typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg);
+typedef Bool (*glamor_use) (DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg);
typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog);
typedef struct {
const char *name;
const int version;
- char *vs_defines;
- char *fs_defines;
+ char *vs_extensions;
+ const char *fs_extensions;
const char *vs_vars;
const char *vs_exec;
const char *fs_vars;
@@ -107,13 +108,13 @@ glamor_build_program(ScreenPtr screen,
const char *defines);
Bool
-glamor_use_program(PixmapPtr pixmap,
+glamor_use_program(DrawablePtr drawable,
GCPtr gc,
glamor_program *prog,
void *arg);
glamor_program *
-glamor_use_program_fill(PixmapPtr pixmap,
+glamor_use_program_fill(DrawablePtr drawable,
GCPtr gc,
glamor_program_fill *program_fill,
const glamor_facet *prim);
diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index 8cdad64e4..aa05b8cef 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -28,8 +28,8 @@ static const glamor_facet glamor_facet_polyfillrect_130 = {
.name = "poly_fill_rect",
.version = 130,
.source_name = "size",
- .vs_vars = "attribute vec2 primitive;\n"
- "attribute vec2 size;\n",
+ .vs_vars = "in vec2 primitive;\n"
+ "in vec2 size;\n",
.vs_exec = (" vec2 pos = size * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
GLAMOR_POS(gl_Position, (primitive.xy + pos))),
};
@@ -70,7 +70,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
}
if (glamor_glsl_has_ints(glamor_priv)) {
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->poly_fill_rect_program,
&glamor_facet_polyfillrect_130);
@@ -97,7 +97,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
} else {
int n;
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->poly_fill_rect_program,
&glamor_facet_polyfillrect_120);
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 2af65bf93..1bcf01102 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -61,7 +61,7 @@ static struct blendinfo composite_op_info[] = {
#define RepeatFix 10
static GLuint
-glamor_create_composite_fs(struct shader_key *key)
+glamor_create_composite_fs(glamor_screen_private *glamor_priv, struct shader_key *key, Bool enable_rel_sampler)
{
const char *repeat_define =
"#define RepeatNone 0\n"
@@ -116,7 +116,7 @@ glamor_create_composite_fs(struct shader_key *key)
" tex = (fract(tex) / wh.xy);\n"
" }\n"
" }\n"
- " return texture2D(tex_image, tex);\n"
+ " return texture(tex_image, tex);\n"
"}\n"
" vec4 rel_sampler_rgbx(sampler2D tex_image, vec2 tex, vec4 wh, int repeat)\n"
"{\n"
@@ -129,7 +129,16 @@ glamor_create_composite_fs(struct shader_key *key)
" tex = (fract(tex) / wh.xy);\n"
" }\n"
" }\n"
- " return vec4(texture2D(tex_image, tex).rgb, 1.0);\n"
+ " return vec4(texture(tex_image, tex).rgb, 1.0);\n"
+ "}\n";
+ const char *stub_rel_sampler =
+ " vec4 rel_sampler_rgba(sampler2D tex_image, vec2 tex, vec4 wh, int repeat)\n"
+ "{\n"
+ " return texture(tex_image, tex);\n"
+ "}\n"
+ " vec4 rel_sampler_rgbx(sampler2D tex_image, vec2 tex, vec4 wh, int repeat)\n"
+ "{\n"
+ " return vec4(texture(tex_image, tex).rgb, 1.0);\n"
"}\n";
const char *source_solid_fetch =
@@ -139,7 +148,7 @@ glamor_create_composite_fs(struct shader_key *key)
" return source;\n"
"}\n";
const char *source_alpha_pixmap_fetch =
- "varying vec2 source_texture;\n"
+ "in vec2 source_texture;\n"
"uniform sampler2D source_sampler;\n"
"uniform vec4 source_wh;"
"vec4 get_source()\n"
@@ -148,7 +157,7 @@ glamor_create_composite_fs(struct shader_key *key)
" source_wh, source_repeat_mode);\n"
"}\n";
const char *source_pixmap_fetch =
- "varying vec2 source_texture;\n"
+ "in vec2 source_texture;\n"
"uniform sampler2D source_sampler;\n"
"uniform vec4 source_wh;\n"
"vec4 get_source()\n"
@@ -168,7 +177,7 @@ glamor_create_composite_fs(struct shader_key *key)
" return mask;\n"
"}\n";
const char *mask_alpha_pixmap_fetch =
- "varying vec2 mask_texture;\n"
+ "in vec2 mask_texture;\n"
"uniform sampler2D mask_sampler;\n"
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
@@ -177,7 +186,7 @@ glamor_create_composite_fs(struct shader_key *key)
" mask_wh, mask_repeat_mode);\n"
"}\n";
const char *mask_pixmap_fetch =
- "varying vec2 mask_texture;\n"
+ "in vec2 mask_texture;\n"
"uniform sampler2D mask_sampler;\n"
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
@@ -197,21 +206,26 @@ glamor_create_composite_fs(struct shader_key *key)
" float undef;\n"
" return vec4(color.a, undef, undef, undef);"
"}";
+ const char *dest_swizzle_ignore_alpha =
+ "vec4 dest_swizzle(vec4 color)\n"
+ "{"
+ " return vec4(color.xyz, 1.0);"
+ "}";
const char *in_normal =
"void main()\n"
"{\n"
- " gl_FragColor = dest_swizzle(get_source() * get_mask().a);\n"
+ " frag_color = dest_swizzle(get_source() * get_mask().a);\n"
"}\n";
const char *in_ca_source =
"void main()\n"
"{\n"
- " gl_FragColor = dest_swizzle(get_source() * get_mask());\n"
+ " frag_color = dest_swizzle(get_source() * get_mask());\n"
"}\n";
const char *in_ca_alpha =
"void main()\n"
"{\n"
- " gl_FragColor = dest_swizzle(get_source().a * get_mask());\n"
+ " frag_color = dest_swizzle(get_source().a * get_mask());\n"
"}\n";
const char *in_ca_dual_blend =
"out vec4 color0;\n"
@@ -221,15 +235,28 @@ glamor_create_composite_fs(struct shader_key *key)
" color0 = dest_swizzle(get_source() * get_mask());\n"
" color1 = dest_swizzle(get_source().a * get_mask());\n"
"}\n";
- const char *header_ca_dual_blend =
- "#version 130\n";
+ const char *in_ca_dual_blend_gles2 =
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = dest_swizzle(get_source() * get_mask());\n"
+ " gl_SecondaryFragColorEXT = dest_swizzle(get_source().a * get_mask());\n"
+ "}\n";
+ const char *header_ca_dual_blend_gles2 =
+ "#version 100\n"
+ "#extension GL_EXT_blend_func_extended : require\n"
+ GLAMOR_COMPAT_DEFINES_FS;
char *source;
const char *source_fetch;
const char *mask_fetch = "";
const char *in;
const char *header;
- const char *header_norm = "";
+ const char *header_norm = glamor_priv->glsl_version > 120 ?
+ "#version 130\n" :
+ glamor_priv->use_gpu_shader4 ?
+ "#version 120\n#extension GL_EXT_gpu_shader4 : require\n" GLAMOR_COMPAT_DEFINES_FS :
+ "#version 120\n" GLAMOR_COMPAT_DEFINES_FS;
+ const char *header_es = glamor_priv->glsl_version > 100 ? "#version 300 es\n" : "#version 100\n" GLAMOR_COMPAT_DEFINES_FS;
const char *dest_swizzle;
GLuint prog;
@@ -275,11 +302,14 @@ glamor_create_composite_fs(struct shader_key *key)
case SHADER_DEST_SWIZZLE_ALPHA_TO_RED:
dest_swizzle = dest_swizzle_alpha_to_red;
break;
+ case SHADER_DEST_SWIZZLE_IGNORE_ALPHA:
+ dest_swizzle = dest_swizzle_ignore_alpha;
+ break;
default:
FatalError("Bad composite shader dest swizzle");
}
- header = header_norm;
+ header = glamor_priv->is_gles ? header_es : header_norm;
switch (key->in) {
case glamor_program_alpha_normal:
in = in_normal;
@@ -292,7 +322,10 @@ glamor_create_composite_fs(struct shader_key *key)
break;
case glamor_program_alpha_dual_blend:
in = in_ca_dual_blend;
- header = header_ca_dual_blend;
+ break;
+ case glamor_program_alpha_dual_blend_gles2:
+ in = in_ca_dual_blend_gles2;
+ header = header_ca_dual_blend_gles2;
break;
default:
FatalError("Bad composite IN type");
@@ -301,8 +334,10 @@ glamor_create_composite_fs(struct shader_key *key)
XNFasprintf(&source,
"%s"
GLAMOR_DEFAULT_PRECISION
- "%s%s%s%s%s%s%s", header, repeat_define, relocate_texture,
- rel_sampler, source_fetch, mask_fetch, dest_swizzle, in);
+ "%s%s%s%s%s%s%s%s", header, GLAMOR_COMPAT_DEFINES_FS,
+ repeat_define, relocate_texture,
+ enable_rel_sampler ? rel_sampler : stub_rel_sampler,
+ source_fetch, mask_fetch, dest_swizzle, in);
prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, source);
free(source);
@@ -311,14 +346,14 @@ glamor_create_composite_fs(struct shader_key *key)
}
static GLuint
-glamor_create_composite_vs(struct shader_key *key)
+glamor_create_composite_vs(glamor_screen_private* priv, struct shader_key *key)
{
const char *main_opening =
- "attribute vec4 v_position;\n"
- "attribute vec4 v_texcoord0;\n"
- "attribute vec4 v_texcoord1;\n"
- "varying vec2 source_texture;\n"
- "varying vec2 mask_texture;\n"
+ "in vec4 v_position;\n"
+ "in vec4 v_texcoord0;\n"
+ "in vec4 v_texcoord1;\n"
+ "out vec2 source_texture;\n"
+ "out vec2 mask_texture;\n"
"void main()\n"
"{\n"
" gl_Position = v_position;\n";
@@ -327,6 +362,10 @@ glamor_create_composite_vs(struct shader_key *key)
const char *main_closing = "}\n";
const char *source_coords_setup = "";
const char *mask_coords_setup = "";
+ const char *version_gles2 = "#version 100\n";
+ const char *version_gles3 = "#version 300 es\n";
+ const char *version = priv->glsl_version > 120 ? "#version 130\n" : "#version 120\n";
+ const char *defines = priv->glsl_version > 120 ? "": GLAMOR_COMPAT_DEFINES_VS;
char *source;
GLuint prog;
@@ -336,10 +375,18 @@ glamor_create_composite_vs(struct shader_key *key)
if (key->mask != SHADER_MASK_NONE && key->mask != SHADER_MASK_SOLID)
mask_coords_setup = mask_coords;
+ if (priv->is_gles)
+ version = version_gles2;
+
+ if (priv->is_gles && priv->glsl_version > 120)
+ version = version_gles3;
+
XNFasprintf(&source,
- "%s%s%s%s",
- main_opening,
- source_coords_setup, mask_coords_setup, main_closing);
+ "%s"
+ GLAMOR_DEFAULT_PRECISION
+ "%s%s%s%s%s",
+ version, defines, main_opening, source_coords_setup,
+ mask_coords_setup, main_closing);
prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, source);
free(source);
@@ -354,18 +401,21 @@ glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
GLuint vs, fs, prog;
GLint source_sampler_uniform_location, mask_sampler_uniform_location;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ Bool enable_rel_sampler = TRUE;
glamor_make_current(glamor_priv);
- vs = glamor_create_composite_vs(key);
+ vs = glamor_create_composite_vs(glamor_priv, key);
if (vs == 0)
return;
- fs = glamor_create_composite_fs(key);
+ fs = glamor_create_composite_fs(glamor_priv, key, enable_rel_sampler);
if (fs == 0)
return;
prog = glCreateProgram();
glAttachShader(prog, vs);
glAttachShader(prog, fs);
+ glDeleteShader(vs);
+ glDeleteShader(fs);
glBindAttribLocation(prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
@@ -375,7 +425,22 @@ glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
glBindFragDataLocationIndexed(prog, 0, 0, "color0");
glBindFragDataLocationIndexed(prog, 0, 1, "color1");
}
- glamor_link_glsl_prog(screen, prog, "composite");
+
+ if (!glamor_link_glsl_prog(screen, prog, "composite")) {
+ /* Failed to link the shader, try again without rel_sampler. */
+ enable_rel_sampler = FALSE;
+ glDetachShader(prog, fs);
+ fs = glamor_create_composite_fs(glamor_priv, key, enable_rel_sampler);
+ if (fs == 0)
+ return;
+ glAttachShader(prog, fs);
+ glDeleteShader(fs);
+
+ if (!glamor_link_glsl_prog(screen, prog, "composite")) {
+ glDeleteProgram(prog);
+ return;
+ }
+ }
shader->prog = prog;
@@ -701,6 +766,7 @@ combine_pict_format(PictFormatShort * des, const PictFormatShort src,
mask_type = PICT_FORMAT_TYPE(mask);
break;
case glamor_program_alpha_dual_blend:
+ case glamor_program_alpha_dual_blend_gles2:
src_type = PICT_FORMAT_TYPE(src);
mask_type = PICT_FORMAT_TYPE(mask);
break;
@@ -780,7 +846,7 @@ glamor_render_format_is_supported(PicturePtr picture)
return TRUE;
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
- f = &glamor_priv->formats[picture->pDrawable->depth];
+ f = &glamor_priv->formats[glamor_drawable_effective_depth(picture->pDrawable)];
if (!f->rendering_supported)
return FALSE;
@@ -801,6 +867,20 @@ glamor_render_format_is_supported(PicturePtr picture)
}
static Bool
+render_op_uses_src_alpha(CARD8 op)
+{
+ struct blendinfo *info = &composite_op_info[op];
+
+ switch (info->dest_blend) {
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_SRC_ALPHA:
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static Bool
glamor_composite_choose_shader(CARD8 op,
PicturePtr source,
PicturePtr mask,
@@ -886,8 +966,11 @@ glamor_composite_choose_shader(CARD8 op,
else {
if (op == PictOpClear)
key.mask = SHADER_MASK_NONE;
- else if (glamor_priv->has_dual_blend)
- key.in = glamor_program_alpha_dual_blend;
+ else if (glamor_priv->has_dual_blend) {
+ key.in = glamor_glsl_has_ints(glamor_priv) ?
+ glamor_program_alpha_dual_blend :
+ glamor_program_alpha_dual_blend_gles2;
+ }
else if (op == PictOpSrc || op == PictOpAdd
|| op == PictOpIn || op == PictOpOut
|| op == PictOpOverReverse)
@@ -909,7 +992,12 @@ glamor_composite_choose_shader(CARD8 op,
glamor_priv->formats[8].format == GL_RED) {
key.dest_swizzle = SHADER_DEST_SWIZZLE_ALPHA_TO_RED;
} else {
- key.dest_swizzle = SHADER_DEST_SWIZZLE_DEFAULT;
+ if (dest_pixmap->drawable.depth == 32 &&
+ glamor_drawable_effective_depth(dest->pDrawable) == 24 &&
+ !render_op_uses_src_alpha(op))
+ key.dest_swizzle = SHADER_DEST_SWIZZLE_IGNORE_ALPHA;
+ else
+ key.dest_swizzle = SHADER_DEST_SWIZZLE_DEFAULT;
}
if (source && source->alphaMap) {
@@ -1140,6 +1228,7 @@ glamor_composite_with_shader(CARD8 op,
Bool ret = FALSE;
glamor_composite_shader *shader = NULL, *shader_ca = NULL;
struct blendinfo op_info, op_info_ca;
+ Bool restore_colormask = FALSE;
if (!glamor_composite_choose_shader(op, source, mask, dest,
source_pixmap, mask_pixmap, dest_pixmap,
@@ -1164,9 +1253,17 @@ glamor_composite_with_shader(CARD8 op,
glamor_make_current(glamor_priv);
+ if (ca_state != CA_TWO_PASS &&
+ key.dest_swizzle == SHADER_DEST_SWIZZLE_DEFAULT &&
+ dest_pixmap->drawable.depth == 32 &&
+ glamor_drawable_effective_depth(dest->pDrawable) == 24) {
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
+ restore_colormask = TRUE;
+ }
+
glamor_set_destination_pixmap_priv_nc(glamor_priv, dest_pixmap, dest_pixmap_priv);
glamor_composite_set_shader_blend(glamor_priv, dest_pixmap_priv, &key, shader, &op_info);
- glamor_set_alu(screen, GXcopy);
+ glamor_set_alu(dest->pDrawable, GXcopy);
glamor_priv->has_source_coords = key.source != SHADER_SOURCE_SOLID;
glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
@@ -1306,6 +1403,8 @@ glamor_composite_with_shader(CARD8 op,
glDisable(GL_SCISSOR_TEST);
disable_va:
+ if (restore_colormask)
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
@@ -1336,6 +1435,7 @@ glamor_convert_gradient_picture(ScreenPtr screen,
int error;
PictFormatPtr pFormat;
PictFormatShort format;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
if (source->pDrawable) {
pFormat = source->pFormat;
@@ -1345,7 +1445,7 @@ glamor_convert_gradient_picture(ScreenPtr screen,
pFormat = PictureMatchFormat(screen, 32, format);
}
- if (!source->pDrawable) {
+ if (glamor_priv->enable_gradient_shader && !source->pDrawable) {
if (source->pSourcePict->type == SourcePictTypeLinear) {
dst = glamor_generate_linear_gradient_picture(screen,
source, x_source,
diff --git a/glamor/glamor_segs.c b/glamor/glamor_segs.c
index 4dfa6553b..7b0108f83 100644
--- a/glamor/glamor_segs.c
+++ b/glamor/glamor_segs.c
@@ -27,7 +27,7 @@
static const glamor_facet glamor_facet_poly_segment = {
.name = "poly_segment",
- .vs_vars = "attribute vec2 primitive;\n",
+ .vs_vars = "in vec2 primitive;\n",
.vs_exec = (" vec2 pos = vec2(0.0,0.0);\n"
GLAMOR_POS(gl_Position, primitive.xy)),
};
@@ -58,7 +58,7 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
glamor_make_current(glamor_priv);
- prog = glamor_use_program_fill(pixmap, gc,
+ prog = glamor_use_program_fill(drawable, gc,
&glamor_priv->poly_segment_program,
&glamor_facet_poly_segment);
diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c
index 00a019c7b..93beb61d5 100644
--- a/glamor/glamor_spans.c
+++ b/glamor/glamor_spans.c
@@ -29,7 +29,7 @@ glamor_program fill_spans_progs[4];
static const glamor_facet glamor_facet_fillspans_130 = {
.name = "fill_spans",
.version = 130,
- .vs_vars = "attribute vec3 primitive;\n",
+ .vs_vars = "in vec3 primitive;\n",
.vs_exec = (" vec2 pos = vec2(primitive.z,1) * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
GLAMOR_POS(gl_Position, (primitive.xy + pos))),
};
@@ -65,7 +65,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
glamor_make_current(glamor_priv);
if (glamor_glsl_has_ints(glamor_priv)) {
- prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+ prog = glamor_use_program_fill(drawable, gc, &glamor_priv->fill_spans_program,
&glamor_facet_fillspans_130);
if (!prog)
@@ -90,7 +90,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
glamor_put_vbo_space(screen);
} else {
- prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+ prog = glamor_use_program_fill(drawable, gc, &glamor_priv->fill_spans_program,
&glamor_facet_fillspans_120);
if (!prog)
diff --git a/glamor/glamor_sync.c b/glamor/glamor_sync.c
index 907e0c613..3f98be400 100644
--- a/glamor/glamor_sync.c
+++ b/glamor/glamor_sync.c
@@ -52,8 +52,7 @@ glamor_sync_fence_set_triggered (SyncFence *fence)
struct glamor_sync_fence *glamor_fence = glamor_get_sync_fence(fence);
/* Flush pending rendering operations */
- glamor_make_current(glamor);
- glFlush();
+ glamor_flush(glamor);
fence->funcs.SetTriggered = glamor_fence->set_triggered;
fence->funcs.SetTriggered(fence);
diff --git a/glamor/glamor_text.c b/glamor/glamor_text.c
index cf165cad8..0cabecbd5 100644
--- a/glamor/glamor_text.c
+++ b/glamor/glamor_text.c
@@ -221,9 +221,9 @@ glamor_text(DrawablePtr drawable, GCPtr gc,
}
static const char vs_vars_text[] =
- "attribute vec4 primitive;\n"
- "attribute vec2 source;\n"
- "varying vec2 glyph_pos;\n";
+ "in vec4 primitive;\n"
+ "in vec2 source;\n"
+ "out vec2 glyph_pos;\n";
static const char vs_exec_text[] =
" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
@@ -231,11 +231,15 @@ static const char vs_exec_text[] =
" glyph_pos = source + pos;\n";
static const char fs_vars_text[] =
- "varying vec2 glyph_pos;\n";
+ "in vec2 glyph_pos;\n";
static const char fs_exec_text[] =
" ivec2 itile_texture = ivec2(glyph_pos);\n"
+#if BITMAP_BIT_ORDER == MSBFirst
+ " uint x = uint(7) - uint(itile_texture.x & 7);\n"
+#else
" uint x = uint(itile_texture.x & 7);\n"
+#endif
" itile_texture.x >>= 3;\n"
" uint texel = texelFetch(font, itile_texture, 0).x;\n"
" uint bit = (texel >> x) & uint(1);\n"
@@ -244,14 +248,18 @@ static const char fs_exec_text[] =
static const char fs_exec_te[] =
" ivec2 itile_texture = ivec2(glyph_pos);\n"
+#if BITMAP_BIT_ORDER == MSBFirst
+ " uint x = uint(7) - uint(itile_texture.x & 7);\n"
+#else
" uint x = uint(itile_texture.x & 7);\n"
+#endif
" itile_texture.x >>= 3;\n"
" uint texel = texelFetch(font, itile_texture, 0).x;\n"
" uint bit = (texel >> x) & uint(1);\n"
" if (bit == uint(0))\n"
- " gl_FragColor = bg;\n"
+ " frag_color = bg;\n"
" else\n"
- " gl_FragColor = fg;\n";
+ " frag_color = fg;\n";
static const glamor_facet glamor_facet_poly_text = {
.name = "poly_text",
@@ -288,7 +296,7 @@ glamor_poly_text(DrawablePtr drawable, GCPtr gc,
glamor_make_current(glamor_priv);
- prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
+ prog = glamor_use_program_fill(drawable, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
if (!prog)
goto bail;
@@ -346,24 +354,24 @@ static const glamor_facet glamor_facet_image_text = {
};
static Bool
-use_image_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_image_solid(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
- return glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform);
+ return glamor_set_solid(drawable, gc, FALSE, prog->fg_uniform);
}
static const glamor_facet glamor_facet_image_fill = {
.name = "solid",
- .fs_exec = " gl_FragColor = fg;\n",
+ .fs_exec = " frag_color = fg;\n",
.locations = glamor_program_location_fg,
.use = use_image_solid,
};
static Bool
-glamor_te_text_use(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+glamor_te_text_use(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
{
- if (!glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform))
+ if (!glamor_set_solid(drawable, gc, FALSE, prog->fg_uniform))
return FALSE;
- glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+ glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
return TRUE;
}
@@ -432,7 +440,6 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
int c;
RegionRec region;
BoxRec box;
- int off_x, off_y;
/* Check planemask before drawing background to
* bail early if it's not OK
@@ -443,8 +450,6 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
if (charinfo[c])
width += charinfo[c]->metrics.characterWidth;
- glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
-
if (width >= 0) {
box.x1 = drawable->x + x;
box.x2 = drawable->x + x + width;
@@ -456,12 +461,12 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
box.y2 = drawable->y + y + gc->font->info.fontDescent;
RegionInit(&region, &box, 1);
RegionIntersect(&region, &region, gc->pCompositeClip);
- RegionTranslate(&region, off_x, off_y);
- glamor_solid_boxes(pixmap, RegionRects(&region), RegionNumRects(&region), gc->bgPixel);
+ RegionTranslate(&region, -drawable->x, -drawable->y);
+ glamor_solid_boxes(drawable, RegionRects(&region), RegionNumRects(&region), gc->bgPixel);
RegionUninit(&region);
}
- if (!glamor_use_program(pixmap, gc, prog, NULL))
+ if (!glamor_use_program(drawable, gc, prog, NULL))
goto bail;
(void) glamor_text(drawable, gc, glamor_font, prog,
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index e706e0fb4..9404e899c 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -24,20 +24,25 @@
#include "glamor_transfer.h"
/*
- * Write a region of bits into a pixmap
+ * Write a region of bits into a drawable's backing pixmap
*/
void
-glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
int dx_src, int dy_src,
int dx_dst, int dy_dst,
uint8_t *bits, uint32_t byte_stride)
{
- ScreenPtr screen = pixmap->drawable.pScreen;
+ ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int box_index;
- int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+ int bytes_per_pixel = drawable->bitsPerPixel >> 3;
const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
+ char *tmp_bits = NULL;
+
+ if (glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32)
+ tmp_bits = xnfalloc(byte_stride * pixmap->drawable.height);
glamor_make_current(glamor_priv);
@@ -62,6 +67,7 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
int y1 = MAX(boxes->y1 + dy_dst, box->y1);
int y2 = MIN(boxes->y2 + dy_dst, box->y2);
+ uint32_t *src_line;
size_t ofs = (y1 - dy_dst + dy_src) * byte_stride;
ofs += (x1 - dx_dst + dx_src) * bytes_per_pixel;
@@ -70,24 +76,42 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
if (x2 <= x1 || y2 <= y1)
continue;
+ src_line = (uint32_t *)(bits + ofs);
+
+ if (tmp_bits) {
+ uint32_t *tmp_line = (uint32_t *)(tmp_bits + ofs);
+ int x, y;
+
+ /* Make sure any sampling of the alpha channel will return 1.0 */
+ for (y = y1; y < y2;
+ y++, src_line += byte_stride / 4, tmp_line += byte_stride / 4) {
+ for (x = 0; x < x2 - x1; x++)
+ tmp_line[x] = src_line[x] | 0xff000000;
+ }
+
+ src_line = (uint32_t *)(tmp_bits + ofs);
+ }
+
if (glamor_priv->has_unpack_subimage ||
x2 - x1 == byte_stride / bytes_per_pixel) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
x1 - box->x1, y1 - box->y1,
x2 - x1, y2 - y1,
f->format, f->type,
- bits + ofs);
+ src_line);
} else {
- for (; y1 < y2; y1++, ofs += byte_stride)
+ for (; y1 < y2; y1++, src_line += byte_stride / bytes_per_pixel)
glTexSubImage2D(GL_TEXTURE_2D, 0,
x1 - box->x1, y1 - box->y1,
x2 - x1, 1,
f->format, f->type,
- bits + ofs);
+ src_line);
}
}
}
+ free(tmp_bits);
+
if (glamor_priv->has_unpack_subimage)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
@@ -97,46 +121,31 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
*/
void
-glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+glamor_upload_region(DrawablePtr drawable, RegionPtr region,
int region_x, int region_y,
uint8_t *bits, uint32_t byte_stride)
{
- glamor_upload_boxes(pixmap, RegionRects(region), RegionNumRects(region),
+ glamor_upload_boxes(drawable, RegionRects(region), RegionNumRects(region),
-region_x, -region_y,
0, 0,
bits, byte_stride);
}
/*
- * Take the data in the pixmap and stuff it back into the FBO
+ * Read stuff from the drawable's backing pixmap FBOs and write to memory
*/
void
-glamor_upload_pixmap(PixmapPtr pixmap)
-{
- BoxRec box;
-
- box.x1 = 0;
- box.x2 = pixmap->drawable.width;
- box.y1 = 0;
- box.y2 = pixmap->drawable.height;
- glamor_upload_boxes(pixmap, &box, 1, 0, 0, 0, 0,
- pixmap->devPrivate.ptr, pixmap->devKind);
-}
-
-/*
- * Read stuff from the pixmap FBOs and write to memory
- */
-void
-glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
int dx_src, int dy_src,
int dx_dst, int dy_dst,
uint8_t *bits, uint32_t byte_stride)
{
- ScreenPtr screen = pixmap->drawable.pScreen;
+ ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int box_index;
- int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+ int bytes_per_pixel = drawable->bitsPerPixel >> 3;
const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
glamor_make_current(glamor_priv);
@@ -182,37 +191,3 @@ glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
if (glamor_priv->has_pack_subimage)
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
}
-
-/*
- * Read data from the pixmap FBO
- */
-void
-glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits)
-{
- BoxRec box;
-
- box.x1 = x;
- box.x2 = x + w;
- box.y1 = y;
- box.y2 = y + h;
-
- glamor_download_boxes(pixmap, &box, 1, 0, 0, -x, -y,
- bits, PixmapBytePad(w, pixmap->drawable.depth));
-}
-
-/*
- * Pull the data from the FBO down to the pixmap
- */
-void
-glamor_download_pixmap(PixmapPtr pixmap)
-{
- BoxRec box;
-
- box.x1 = 0;
- box.x2 = pixmap->drawable.width;
- box.y1 = 0;
- box.y2 = pixmap->drawable.height;
-
- glamor_download_boxes(pixmap, &box, 1, 0, 0, 0, 0,
- pixmap->devPrivate.ptr, pixmap->devKind);
-}
diff --git a/glamor/glamor_transfer.h b/glamor/glamor_transfer.h
index a6137b3ff..17d80a2e9 100644
--- a/glamor/glamor_transfer.h
+++ b/glamor/glamor_transfer.h
@@ -24,29 +24,20 @@
#define _GLAMOR_TRANSFER_H_
void
-glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
int dx_src, int dy_src,
int dx_dst, int dy_dst,
uint8_t *bits, uint32_t byte_stride);
void
-glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+glamor_upload_region(DrawablePtr drawable, RegionPtr region,
int region_x, int region_y,
uint8_t *bits, uint32_t byte_stride);
void
-glamor_upload_pixmap(PixmapPtr pixmap);
-
-void
-glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
int dx_src, int dy_src,
int dx_dst, int dy_dst,
uint8_t *bits, uint32_t byte_stride);
-void
-glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits);
-
-void
-glamor_download_pixmap(PixmapPtr pixmap);
-
#endif /* _GLAMOR_TRANSFER_H_ */
diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c
index 11a08f7f6..891f7ee51 100644
--- a/glamor/glamor_transform.c
+++ b/glamor/glamor_transform.c
@@ -130,7 +130,7 @@ glamor_set_color_depth(ScreenPtr pScreen,
}
Bool
-glamor_set_solid(PixmapPtr pixmap,
+glamor_set_solid(DrawablePtr drawable,
GCPtr gc,
Bool use_alu,
GLint uniform)
@@ -143,7 +143,7 @@ glamor_set_solid(PixmapPtr pixmap,
pixel = gc->fgPixel;
- if (!glamor_set_alu(pixmap->drawable.pScreen, alu)) {
+ if (!glamor_set_alu(drawable, alu)) {
switch (gc->alu) {
case GXclear:
pixel = 0;
@@ -158,7 +158,7 @@ glamor_set_solid(PixmapPtr pixmap,
return FALSE;
}
}
- glamor_set_color(pixmap, pixel, uniform);
+ glamor_set_color(drawable, pixel, uniform);
return TRUE;
}
@@ -204,12 +204,12 @@ glamor_set_texture(PixmapPtr texture,
}
Bool
-glamor_set_tiled(PixmapPtr pixmap,
+glamor_set_tiled(DrawablePtr drawable,
GCPtr gc,
GLint offset_uniform,
GLint size_inv_uniform)
{
- if (!glamor_set_alu(pixmap->drawable.pScreen, gc->alu))
+ if (!glamor_set_alu(drawable, gc->alu))
return FALSE;
if (!glamor_set_planemask(gc->depth, gc->planemask))
@@ -282,7 +282,7 @@ bail:
}
Bool
-glamor_set_stippled(PixmapPtr pixmap,
+glamor_set_stippled(DrawablePtr drawable,
GCPtr gc,
GLint fg_uniform,
GLint offset_uniform,
@@ -294,7 +294,7 @@ glamor_set_stippled(PixmapPtr pixmap,
if (!stipple)
return FALSE;
- if (!glamor_set_solid(pixmap, gc, TRUE, fg_uniform))
+ if (!glamor_set_solid(drawable, gc, TRUE, fg_uniform))
return FALSE;
return glamor_set_texture(stipple,
diff --git a/glamor/glamor_transform.h b/glamor/glamor_transform.h
index 28855e3d3..6eef2fc7a 100644
--- a/glamor/glamor_transform.h
+++ b/glamor/glamor_transform.h
@@ -39,12 +39,13 @@ glamor_set_color_depth(ScreenPtr pScreen,
GLint uniform);
static inline void
-glamor_set_color(PixmapPtr pixmap,
+glamor_set_color(DrawablePtr drawable,
CARD32 pixel,
GLint uniform)
{
- glamor_set_color_depth(pixmap->drawable.pScreen,
- pixmap->drawable.depth, pixel, uniform);
+ glamor_set_color_depth(drawable->pScreen,
+ glamor_drawable_effective_depth(drawable),
+ pixel, uniform);
}
Bool
@@ -60,19 +61,19 @@ glamor_set_texture(PixmapPtr texture,
GLint size_uniform);
Bool
-glamor_set_solid(PixmapPtr pixmap,
+glamor_set_solid(DrawablePtr drawable,
GCPtr gc,
Bool use_alu,
GLint uniform);
Bool
-glamor_set_tiled(PixmapPtr pixmap,
+glamor_set_tiled(DrawablePtr drawable,
GCPtr gc,
GLint offset_uniform,
GLint size_uniform);
Bool
-glamor_set_stippled(PixmapPtr pixmap,
+glamor_set_stippled(DrawablePtr drawable,
GCPtr gc,
GLint fg_uniform,
GLint offset_uniform,
diff --git a/glamor/glamor_utils.c b/glamor/glamor_utils.c
index d3e6fd3ff..8f085da3f 100644
--- a/glamor/glamor_utils.c
+++ b/glamor/glamor_utils.c
@@ -23,10 +23,9 @@
#include "glamor_priv.h"
void
-glamor_solid_boxes(PixmapPtr pixmap,
+glamor_solid_boxes(DrawablePtr drawable,
BoxPtr box, int nbox, unsigned long fg_pixel)
{
- DrawablePtr drawable = &pixmap->drawable;
GCPtr gc;
xRectangle *rect;
int n;
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 93a933eed..bee48d989 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -672,6 +672,17 @@ glamor_make_current(glamor_screen_private *glamor_priv)
lastGLContext = glamor_priv->ctx.ctx;
glamor_priv->ctx.make_current(&glamor_priv->ctx);
}
+ glamor_priv->dirty = TRUE;
+}
+
+static inline void
+glamor_flush(glamor_screen_private *glamor_priv)
+{
+ if (glamor_priv->dirty) {
+ glamor_make_current(glamor_priv);
+ glFlush();
+ glamor_priv->dirty = FALSE;
+ }
}
static inline BoxRec
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index dbb490599..40b9ca4ea 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -62,12 +62,10 @@ typedef struct tagREF_TRANSFORM {
static const glamor_facet glamor_facet_xv_planar_2 = {
.name = "xv_planar_2",
- .version = 120,
-
.source_name = "v_texcoord0",
- .vs_vars = ("attribute vec2 position;\n"
- "attribute vec2 v_texcoord0;\n"
- "varying vec2 tcs;\n"),
+ .vs_vars = ("in vec2 position;\n"
+ "in vec2 v_texcoord0;\n"
+ "out vec2 tcs;\n"),
.vs_exec = (GLAMOR_POS(gl_Position, position)
" tcs = v_texcoord0;\n"),
@@ -76,30 +74,28 @@ static const glamor_facet glamor_facet_xv_planar_2 = {
"uniform vec4 offsetyco;\n"
"uniform vec4 ucogamma;\n"
"uniform vec4 vco;\n"
- "varying vec2 tcs;\n"),
+ "in vec2 tcs;\n"),
.fs_exec = (
" float sample;\n"
" vec2 sample_uv;\n"
" vec4 temp1;\n"
- " sample = texture2D(y_sampler, tcs).w;\n"
+ " sample = texture(y_sampler, tcs).w;\n"
" temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n"
- " sample_uv = texture2D(u_sampler, tcs).xy;\n"
+ " sample_uv = texture(u_sampler, tcs).xy;\n"
" temp1.xyz = ucogamma.xyz * vec3(sample_uv.x) + temp1.xyz;\n"
" temp1.xyz = clamp(vco.xyz * vec3(sample_uv.y) + temp1.xyz, 0.0, 1.0);\n"
" temp1.w = 1.0;\n"
- " gl_FragColor = temp1;\n"
+ " frag_color = temp1;\n"
),
};
static const glamor_facet glamor_facet_xv_planar_3 = {
.name = "xv_planar_3",
- .version = 120,
-
.source_name = "v_texcoord0",
- .vs_vars = ("attribute vec2 position;\n"
- "attribute vec2 v_texcoord0;\n"
- "varying vec2 tcs;\n"),
+ .vs_vars = ("in vec2 position;\n"
+ "in vec2 v_texcoord0;\n"
+ "out vec2 tcs;\n"),
.vs_exec = (GLAMOR_POS(gl_Position, position)
" tcs = v_texcoord0;\n"),
@@ -109,18 +105,76 @@ static const glamor_facet glamor_facet_xv_planar_3 = {
"uniform vec4 offsetyco;\n"
"uniform vec4 ucogamma;\n"
"uniform vec4 vco;\n"
- "varying vec2 tcs;\n"),
+ "in vec2 tcs;\n"),
.fs_exec = (
" float sample;\n"
" vec4 temp1;\n"
- " sample = texture2D(y_sampler, tcs).w;\n"
+ " sample = texture(y_sampler, tcs).w;\n"
" temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n"
- " sample = texture2D(u_sampler, tcs).w;\n"
+ " sample = texture(u_sampler, tcs).w;\n"
" temp1.xyz = ucogamma.xyz * vec3(sample) + temp1.xyz;\n"
- " sample = texture2D(v_sampler, tcs).w;\n"
+ " sample = texture(v_sampler, tcs).w;\n"
" temp1.xyz = clamp(vco.xyz * vec3(sample) + temp1.xyz, 0.0, 1.0);\n"
" temp1.w = 1.0;\n"
- " gl_FragColor = temp1;\n"
+ " frag_color = temp1;\n"
+ ),
+};
+
+static const glamor_facet glamor_facet_xv_uyvy = {
+ .name = "xv_uyvy",
+
+ .source_name = "v_texcoord0",
+ .vs_vars = ("in vec2 position;\n"
+ "in vec2 v_texcoord0;\n"
+ "out vec2 tcs;\n"),
+ .vs_exec = (GLAMOR_POS(gl_Position, position)
+ " tcs = v_texcoord0;\n"),
+
+ .fs_vars = ("#ifdef GL_ES\n"
+ "precision highp float;\n"
+ "#endif\n"
+ "uniform sampler2D sampler;\n"
+ "uniform vec2 texelSize;\n"
+ "uniform vec4 offsetyco;\n"
+ "uniform vec4 ucogamma;\n"
+ "uniform vec4 vco;\n"
+ "in vec2 tcs;\n"
+ ),
+ .fs_exec = (
+ " vec3 uyv;\n"
+ " vec4 frameOut = texture2D(sampler, tcs.st);\n"
+ "\n"
+ " vec4 prevPixel = texture2D(sampler, vec2(tcs.s - texelSize.x, tcs.t));\n"
+ " vec4 nextPixel = texture2D(sampler, vec2(tcs.s + texelSize.x, tcs.t));\n"
+ "\n"
+ " float delta = 0.50;\n"
+ "\n"
+ " int even = int(mod(tcs.x / texelSize.x, 2.0));\n"
+ "\n"
+ " uyv.rgb = float(even)*vec3(frameOut.rg, nextPixel.r) + (1.0-float(even))*vec3(prevPixel.r, frameOut.gr);\n"
+ "\n"
+ " frameOut.r = uyv.g + 1.403*(uyv.r - delta);\n"
+ " frameOut.g = uyv.g - 0.714*(uyv.r - delta) - 0.344*(uyv.b - delta);\n"
+ " frameOut.b = uyv.g + 1.773*(uyv.b - delta);\n"
+ " frameOut.a = 1.0;\n"
+ " frag_color = frameOut;\n"
+ ),
+};
+
+static const glamor_facet glamor_facet_xv_rgb_raw = {
+ .name = "xv_rgb",
+
+ .source_name = "v_texcoord0",
+ .vs_vars = ("in vec2 position;\n"
+ "in vec2 v_texcoord0;\n"
+ "out vec2 tcs;\n"),
+ .vs_exec = (GLAMOR_POS(gl_Position, position)
+ " tcs = v_texcoord0;\n"),
+
+ .fs_vars = ("uniform sampler2D sampler;\n"
+ "in vec2 tcs;\n"),
+ .fs_exec = (
+ " frag_color = texture2D(sampler, tcs);\n"
),
};
@@ -142,14 +196,16 @@ Atom glamorBrightness, glamorContrast, glamorSaturation, glamorHue,
XvImageRec glamor_xv_images[] = {
XVIMAGE_YV12,
XVIMAGE_I420,
- XVIMAGE_NV12
+ XVIMAGE_NV12,
+ XVIMAGE_UYVY,
+ XVIMAGE_RGB32,
+ XVIMAGE_RGB565,
};
int glamor_xv_num_images = ARRAY_SIZE(glamor_xv_images);
static void
-glamor_init_xv_shader(ScreenPtr screen, int id)
+glamor_init_xv_shader(ScreenPtr screen, glamor_port_private *port_priv, int id)
{
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
GLint sampler_loc;
const glamor_facet *glamor_facet_xv_planar = NULL;
@@ -161,27 +217,44 @@ glamor_init_xv_shader(ScreenPtr screen, int id)
case FOURCC_NV12:
glamor_facet_xv_planar = &glamor_facet_xv_planar_2;
break;
+ case FOURCC_UYVY:
+ glamor_facet_xv_planar = &glamor_facet_xv_uyvy;
+ break;
+ case FOURCC_RGBA32:
+ case FOURCC_RGB565:
+ glamor_facet_xv_planar = &glamor_facet_xv_rgb_raw;
+ break;
default:
break;
}
glamor_build_program(screen,
- &glamor_priv->xv_prog,
+ &port_priv->xv_prog,
glamor_facet_xv_planar, NULL, NULL, NULL);
- glUseProgram(glamor_priv->xv_prog.prog);
- sampler_loc = glGetUniformLocation(glamor_priv->xv_prog.prog, "y_sampler");
- glUniform1i(sampler_loc, 0);
- sampler_loc = glGetUniformLocation(glamor_priv->xv_prog.prog, "u_sampler");
- glUniform1i(sampler_loc, 1);
+ glUseProgram(port_priv->xv_prog.prog);
switch (id) {
case FOURCC_YV12:
case FOURCC_I420:
- sampler_loc = glGetUniformLocation(glamor_priv->xv_prog.prog, "v_sampler");
+ sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "y_sampler");
+ glUniform1i(sampler_loc, 0);
+ sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "u_sampler");
+ glUniform1i(sampler_loc, 1);
+ sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "v_sampler");
glUniform1i(sampler_loc, 2);
break;
case FOURCC_NV12:
+ sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "y_sampler");
+ glUniform1i(sampler_loc, 0);
+ sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "u_sampler");
+ glUniform1i(sampler_loc, 1);
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_RGBA32:
+ case FOURCC_RGB565:
+ sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "sampler");
+ glUniform1i(sampler_loc, 0);
break;
default:
break;
@@ -291,13 +364,31 @@ glamor_xv_query_image_attributes(int id,
pitches[0] = size;
size *= *h;
if (offsets)
- offsets[1] = offsets[2] = size;
+ offsets[1] = size;
tmp = ALIGN(*w, 4);
if (pitches)
- pitches[1] = pitches[2] = tmp;
+ pitches[1] = tmp;
tmp *= (*h >> 1);
size += tmp;
break;
+ case FOURCC_RGBA32:
+ size = *w * 4;
+ if(pitches)
+ pitches[0] = size;
+ if(offsets)
+ offsets[0] = 0;
+ size *= *h;
+ break;
+ case FOURCC_RGB565:
+ case FOURCC_UYVY:
+ /* UYVU is single-plane really, all tranformation is processed inside a shader */
+ size = *w * 2;
+ if (pitches)
+ pitches[0] = size;
+ if (offsets)
+ offsets[0] = 0;
+ size *= *h;
+ break;
}
return size;
}
@@ -334,8 +425,8 @@ glamor_xv_render(glamor_port_private *port_priv, int id)
char *vbo_offset;
int dst_box_index;
- if (!glamor_priv->xv_prog.prog)
- glamor_init_xv_shader(screen, id);
+ if (!port_priv->xv_prog.prog)
+ glamor_init_xv_shader(screen, port_priv, id);
cont = RTFContrast(port_priv->contrast);
bright = RTFBrightness(port_priv->brightness);
@@ -356,7 +447,7 @@ glamor_xv_render(glamor_port_private *port_priv, int id)
off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
gamma = 1.0;
- glamor_set_alu(screen, GXcopy);
+ glamor_set_alu(&pixmap->drawable, GXcopy);
for (i = 0; i < 3; i++) {
if (port_priv->src_pix[i]) {
@@ -369,32 +460,32 @@ glamor_xv_render(glamor_port_private *port_priv, int id)
}
}
glamor_make_current(glamor_priv);
- glUseProgram(glamor_priv->xv_prog.prog);
+ glUseProgram(port_priv->xv_prog.prog);
- uloc = glGetUniformLocation(glamor_priv->xv_prog.prog, "offsetyco");
+ uloc = glGetUniformLocation(port_priv->xv_prog.prog, "offsetyco");
glUniform4f(uloc, off[0], off[1], off[2], yco);
- uloc = glGetUniformLocation(glamor_priv->xv_prog.prog, "ucogamma");
+ uloc = glGetUniformLocation(port_priv->xv_prog.prog, "ucogamma");
glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
- uloc = glGetUniformLocation(glamor_priv->xv_prog.prog, "vco");
+ uloc = glGetUniformLocation(port_priv->xv_prog.prog, "vco");
glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->fbo->tex);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->fbo->tex);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
switch (id) {
case FOURCC_YV12:
case FOURCC_I420:
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->fbo->tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->fbo->tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->fbo->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -403,6 +494,39 @@ glamor_xv_render(glamor_port_private *port_priv, int id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
break;
case FOURCC_NV12:
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->fbo->tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->fbo->tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ break;
+ case FOURCC_UYVY:
+ uloc = glGetUniformLocation(port_priv->xv_prog.prog, "texelSize");
+ glUniform2f(uloc, 1.0 / port_priv->w, 1.0 / port_priv->h);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->fbo->tex);
+ 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);
+ break;
+ case FOURCC_RGBA32:
+ case FOURCC_RGB565:
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->fbo->tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
break;
default:
break;
@@ -459,7 +583,7 @@ glamor_xv_render(glamor_port_private *port_priv, int id)
glamor_set_destination_drawable(port_priv->pDraw,
dst_box_index,
FALSE, FALSE,
- glamor_priv->xv_prog.matrix_uniform,
+ port_priv->xv_prog.matrix_uniform,
&dst_off_x, &dst_off_y);
for (i = 0; i < nBox; i++) {
@@ -480,8 +604,25 @@ glamor_xv_render(glamor_port_private *port_priv, int id)
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
+}
+
+static Bool
+glamor_xv_can_reuse_port(glamor_port_private *port_priv, int id, short w, short h)
+{
+ int ret = TRUE;
- glamor_xv_free_port_data(port_priv);
+ if (port_priv->prev_fmt != id)
+ ret = FALSE;
+
+ if (w != port_priv->src_pix_w || h != port_priv->src_pix_h)
+ ret = FALSE;
+
+ if (!port_priv->src_pix[0])
+ ret = FALSE;
+
+ port_priv->prev_fmt = id;
+
+ return ret;
}
int
@@ -499,7 +640,6 @@ glamor_xv_put_image(glamor_port_private *port_priv,
RegionPtr clipBoxes)
{
ScreenPtr pScreen = pDrawable->pScreen;
- glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
int srcPitch, srcPitch2;
int top, nlines;
int s2offset, s3offset, tmp;
@@ -507,43 +647,70 @@ glamor_xv_put_image(glamor_port_private *port_priv,
s2offset = s3offset = srcPitch2 = 0;
- if (!port_priv->src_pix[0] ||
- (width != port_priv->src_pix_w || height != port_priv->src_pix_h) ||
- (port_priv->src_pix[2] && id == FOURCC_NV12) ||
- (!port_priv->src_pix[2] && id != FOURCC_NV12)) {
+ if (!glamor_xv_can_reuse_port(port_priv, id, width, height)) {
int i;
- if (glamor_priv->xv_prog.prog) {
- glDeleteProgram(glamor_priv->xv_prog.prog);
- glamor_priv->xv_prog.prog = 0;
+ glamor_xv_free_port_data(port_priv);
+
+ if (port_priv->xv_prog.prog) {
+ glDeleteProgram(port_priv->xv_prog.prog);
+ port_priv->xv_prog.prog = 0;
}
for (i = 0; i < 3; i++)
if (port_priv->src_pix[i])
glamor_destroy_pixmap(port_priv->src_pix[i]);
- port_priv->src_pix[0] =
- glamor_create_pixmap(pScreen, width, height, 8,
- GLAMOR_CREATE_FBO_NO_FBO);
-
switch (id) {
case FOURCC_YV12:
case FOURCC_I420:
+ port_priv->src_pix[0] =
+ glamor_create_pixmap(pScreen, width, height, 8,
+ GLAMOR_CREATE_FBO_NO_FBO);
+
port_priv->src_pix[1] =
glamor_create_pixmap(pScreen, width >> 1, height >> 1, 8,
GLAMOR_CREATE_FBO_NO_FBO);
port_priv->src_pix[2] =
glamor_create_pixmap(pScreen, width >> 1, height >> 1, 8,
GLAMOR_CREATE_FBO_NO_FBO);
- if (!port_priv->src_pix[2])
+ if (!port_priv->src_pix[1] || !port_priv->src_pix[2])
return BadAlloc;
break;
case FOURCC_NV12:
+ port_priv->src_pix[0] =
+ glamor_create_pixmap(pScreen, width, height, 8,
+ GLAMOR_CREATE_FBO_NO_FBO);
port_priv->src_pix[1] =
glamor_create_pixmap(pScreen, width >> 1, height >> 1, 16,
GLAMOR_CREATE_FBO_NO_FBO |
GLAMOR_CREATE_FORMAT_CBCR);
port_priv->src_pix[2] = NULL;
+
+ if (!port_priv->src_pix[1])
+ return BadAlloc;
+ break;
+ case FOURCC_RGBA32:
+ port_priv->src_pix[0] =
+ glamor_create_pixmap(pScreen, width, height, 32,
+ GLAMOR_CREATE_FBO_NO_FBO);
+ port_priv->src_pix[1] = NULL;
+ port_priv->src_pix[2] = NULL;
+ break;
+ case FOURCC_RGB565:
+ port_priv->src_pix[0] =
+ glamor_create_pixmap(pScreen, width, height, 16,
+ GLAMOR_CREATE_FBO_NO_FBO);
+ port_priv->src_pix[1] = NULL;
+ port_priv->src_pix[2] = NULL;
+ break;
+ case FOURCC_UYVY:
+ port_priv->src_pix[0] =
+ glamor_create_pixmap(pScreen, width, height, 32,
+ GLAMOR_CREATE_FBO_NO_FBO |
+ GLAMOR_CREATE_FORMAT_CBCR);
+ port_priv->src_pix[1] = NULL;
+ port_priv->src_pix[2] = NULL;
break;
default:
return BadMatch;
@@ -552,7 +719,7 @@ glamor_xv_put_image(glamor_port_private *port_priv,
port_priv->src_pix_w = width;
port_priv->src_pix_h = height;
- if (!port_priv->src_pix[0] || !port_priv->src_pix[1])
+ if (!port_priv->src_pix[0])
return BadAlloc;
}
@@ -584,15 +751,15 @@ glamor_xv_put_image(glamor_port_private *port_priv,
half_box.x2 = width >> 1;
half_box.y2 = (nlines + 1) >> 1;
- glamor_upload_boxes(port_priv->src_pix[0], &full_box, 1,
+ glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
0, 0, 0, 0,
buf + (top * srcPitch), srcPitch);
- glamor_upload_boxes(port_priv->src_pix[1], &half_box, 1,
+ glamor_upload_boxes(&port_priv->src_pix[1]->drawable, &half_box, 1,
0, 0, 0, 0,
buf + s2offset, srcPitch2);
- glamor_upload_boxes(port_priv->src_pix[2], &half_box, 1,
+ glamor_upload_boxes(&port_priv->src_pix[2]->drawable, &half_box, 1,
0, 0, 0, 0,
buf + s3offset, srcPitch2);
break;
@@ -611,14 +778,35 @@ glamor_xv_put_image(glamor_port_private *port_priv,
half_box.x2 = width;
half_box.y2 = (nlines + 1) >> 1;
- glamor_upload_boxes(port_priv->src_pix[0], &full_box, 1,
+ glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
0, 0, 0, 0,
buf + (top * srcPitch), srcPitch);
- glamor_upload_boxes(port_priv->src_pix[1], &half_box, 1,
+ glamor_upload_boxes(&port_priv->src_pix[1]->drawable, &half_box, 1,
0, 0, 0, 0,
buf + s2offset, srcPitch);
break;
+ case FOURCC_UYVY:
+ case FOURCC_RGB565:
+ srcPitch = width * 2;
+ full_box.x1 = 0;
+ full_box.y1 = 0;
+ full_box.x2 = width;
+ full_box.y2 = height;
+ glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
+ 0, 0, 0, 0,
+ buf, srcPitch);
+ break;
+ case FOURCC_RGBA32:
+ srcPitch = width * 4;
+ full_box.x1 = 0;
+ full_box.y1 = 0;
+ full_box.x2 = width;
+ full_box.y2 = height;
+ glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
+ 0, 0, 0, 0,
+ buf, srcPitch);
+ break;
default:
return BadMatch;
}
diff --git a/glamor/meson.build b/glamor/meson.build
index 4a3f6241a..2ae522aec 100644
--- a/glamor/meson.build
+++ b/glamor/meson.build
@@ -33,6 +33,9 @@ srcs_glamor = [
'glamor_sync.c',
]
+if build_glx
+ srcs_glamor += 'glamor_glx_provider.c'
+endif
if build_xv
srcs_glamor += 'glamor_xv.c'
endif
@@ -41,19 +44,13 @@ epoxy_dep = dependency('epoxy')
glamor = static_library('glamor',
srcs_glamor,
- include_directories: inc,
+ include_directories: [inc, glx_inc],
dependencies: [
common_dep,
epoxy_dep,
],
)
-glamor_egl_stubs = static_library('glamor_egl_stubs',
- 'glamor_egl_stubs.c',
- include_directories: inc,
- dependencies: common_dep,
-)
-
if build_xorg
install_data('glamor.h', install_dir: xorgsdkdir)
endif
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index fc26a2e34..651e8d39b 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -34,10 +34,12 @@
#include <string.h>
#include <assert.h>
-
-#include "glxserver.h"
#include <GL/glxtokens.h>
#include <X11/extensions/presenttokens.h>
+
+#include "dix/dix_priv.h"
+
+#include "glxserver.h"
#include <unpack.h>
#include <pixmapstr.h>
#include <windowstr.h>
@@ -48,6 +50,7 @@
#include "indirect_util.h"
#include "protocol-versions.h"
#include "glxvndabi.h"
+#include "xace.h"
static char GLXServerVendorName[] = "SGI";
@@ -1392,11 +1395,18 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
if (!pPixmap)
return BadAlloc;
+ err = XaceHook(XACE_RESOURCE_ACCESS, client, glxDrawableId, X11_RESTYPE_PIXMAP,
+ pPixmap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
+ if (err != Success) {
+ (*pGlxScreen->pScreen->DestroyPixmap) (pPixmap);
+ return err;
+ }
+
/* Assign the pixmap the same id as the pbuffer and add it as a
* resource so it and the DRI2 drawable will be reclaimed when the
* pbuffer is destroyed. */
pPixmap->drawable.id = glxDrawableId;
- if (!AddResource(pPixmap->drawable.id, RT_PIXMAP, pPixmap))
+ if (!AddResource(pPixmap->drawable.id, X11_RESTYPE_PIXMAP, pPixmap))
return BadAlloc;
return DoCreateGLXDrawable(client, pGlxScreen, config, &pPixmap->drawable,
diff --git a/glx/glxext.c b/glx/glxext.c
index 99f866104..585f64eda 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -36,7 +36,6 @@
#include "glxserver.h"
#include <windowstr.h>
#include <propertyst.h>
-#include <registry.h>
#include "privates.h"
#include <os.h>
#include "extinit.h"
@@ -309,7 +308,7 @@ GetGLXDrawableBytes(void *value, XID id, ResourceSizePtr size)
size->refCnt = 1;
if (draw->type == GLX_DRAWABLE_PIXMAP) {
- SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+ SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(X11_RESTYPE_PIXMAP);
ResourceSizeRec pixmapSize = { 0, };
pixmapSizeFunc((PixmapPtr)draw->pDraw, draw->pDraw->id, &pixmapSize);
size->pixmapRefSize += pixmapSize.pixmapRefSize;
diff --git a/glx/indirect_reqsize.h b/glx/indirect_reqsize.h
index 632a85b1c..809681931 100644
--- a/glx/indirect_reqsize.h
+++ b/glx/indirect_reqsize.h
@@ -30,7 +30,7 @@
#include <X11/Xfuncproto.h>
-#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#if defined(__GNUC__)
#define PURE __attribute__((pure))
#else
#define PURE
diff --git a/glx/indirect_size.h b/glx/indirect_size.h
index 6a3d14cc4..e36c22ab3 100644
--- a/glx/indirect_size.h
+++ b/glx/indirect_size.h
@@ -38,7 +38,7 @@
#include <X11/Xfuncproto.h>
-#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#if defined(__GNUC__)
#define PURE __attribute__((pure))
#else
#define PURE
diff --git a/glx/indirect_size_get.c b/glx/indirect_size_get.c
index 7e81e6288..46d068769 100644
--- a/glx/indirect_size_get.c
+++ b/glx/indirect_size_get.c
@@ -33,7 +33,7 @@
#include "indirect_util.h"
#include "indirect_size.h"
-#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#if defined(__GNUC__)
#define PURE __attribute__((pure))
#else
#define PURE
diff --git a/glx/indirect_size_get.h b/glx/indirect_size_get.h
index 5af11d378..587e4148a 100644
--- a/glx/indirect_size_get.h
+++ b/glx/indirect_size_get.h
@@ -38,7 +38,7 @@
#include <X11/Xfuncproto.h>
-#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#if defined(__GNUC__)
#define PURE __attribute__((pure))
#else
#define PURE
diff --git a/glx/vndcmds.c b/glx/vndcmds.c
index d6d8719e1..cb3732d2a 100644
--- a/glx/vndcmds.c
+++ b/glx/vndcmds.c
@@ -30,7 +30,7 @@
#include <dix-config.h>
#include "hashtable.h"
-#include "vndserver.h"
+#include "vndserver_priv.h"
#include "vndservervendor.h"
/**
@@ -165,9 +165,6 @@ static int CommonLoseCurrent(ClientPtr client, GlxContextTagInfo *tagInfo)
tagInfo->tag, // No old context tag,
None, None, None, 0);
- if (ret == Success) {
- GlxFreeContextTag(tagInfo);
- }
return ret;
}
@@ -259,7 +256,6 @@ static int CommonMakeCurrent(ClientPtr client,
if (ret != Success) {
return ret;
}
- oldTag = NULL;
}
if (newVendor != NULL) {
@@ -270,6 +266,9 @@ static int CommonMakeCurrent(ClientPtr client,
} else {
reply.contextTag = 0;
}
+
+ GlxFreeContextTag(oldTag);
+ oldTag = NULL;
}
reply.contextTag = GlxCheckSwap(client, reply.contextTag);
diff --git a/glx/vndext.c b/glx/vndext.c
index 0513733b6..21ba29269 100644
--- a/glx/vndext.c
+++ b/glx/vndext.c
@@ -27,7 +27,7 @@
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-#include "vndserver.h"
+#include "vndserver_priv.h"
#include <string.h>
#include <scrnintstr.h>
@@ -114,7 +114,7 @@ GlxMappingInit(void)
idResource = CreateNewResourceType(idResourceDeleteCallback,
"GLXServerIDRes");
- if (idResource == RT_NONE)
+ if (idResource == X11_RESTYPE_NONE)
{
GlxMappingReset();
return FALSE;
diff --git a/glx/vndserver.h b/glx/vndserver.h
index 772b458a1..181288cbd 100644
--- a/glx/vndserver.h
+++ b/glx/vndserver.h
@@ -36,95 +36,6 @@
#define GLXContextID CARD32
#define GLXDrawable CARD32
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-typedef struct GlxScreenPrivRec {
- GlxServerVendor *vendor;
-} GlxScreenPriv;
-
-typedef struct GlxContextTagInfoRec {
- GLXContextTag tag;
- ClientPtr client;
- GlxServerVendor *vendor;
- void *data;
- GLXContextID context;
- GLXDrawable drawable;
- GLXDrawable readdrawable;
-} GlxContextTagInfo;
-
-typedef struct GlxClientPrivRec {
- GlxContextTagInfo *contextTags;
- unsigned int contextTagCount;
-
- /**
- * The vendor handles for each screen.
- */
- GlxServerVendor **vendors;
-} GlxClientPriv;
-
-extern int GlxErrorBase;
-extern RESTYPE idResource;
-
-extern ExtensionEntry *GlxExtensionEntry;
-Bool GlxDispatchInit(void);
-void GlxDispatchReset(void);
-
-/**
- * Handles a request from the client.
- *
- * This function will look up the correct handler function and forward the
- * request to it.
- */
-int GlxDispatchRequest(ClientPtr client);
-
-/**
- * Looks up the GlxClientPriv struct for a client. If we don't have a
- * GlxClientPriv struct yet, then allocate one.
- */
-GlxClientPriv *GlxGetClientData(ClientPtr client);
-
-/**
- * Frees any data that's specific to a client. This should be called when a
- * client disconnects.
- */
-void GlxFreeClientData(ClientPtr client);
-
-Bool GlxAddXIDMap(XID id, GlxServerVendor *vendor);
-GlxServerVendor * GlxGetXIDMap(XID id);
-void GlxRemoveXIDMap(XID id);
-
-/**
- * Records the client that sent the current request. This is needed in
- * GlxGetXIDMap to know which client's (screen -> vendor) mapping to use for a
- * regular X window.
- */
-void GlxSetRequestClient(ClientPtr client);
-
-GlxContextTagInfo *GlxAllocContextTag(ClientPtr client, GlxServerVendor *vendor);
-GlxContextTagInfo *GlxLookupContextTag(ClientPtr client, GLXContextTag tag);
-void GlxFreeContextTag(GlxContextTagInfo *tagInfo);
-
-Bool GlxSetScreenVendor(ScreenPtr screen, GlxServerVendor *vendor);
-Bool GlxSetClientScreenVendor(ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor);
-GlxScreenPriv *GlxGetScreen(ScreenPtr pScreen);
-GlxServerVendor *GlxGetVendorForScreen(ClientPtr client, ScreenPtr screen);
-
-static inline CARD32 GlxCheckSwap(ClientPtr client, CARD32 value)
-{
- if (client->swapped)
- {
- value = ((value & 0XFF000000) >> 24) | ((value & 0X00FF0000) >> 8)
- | ((value & 0X0000FF00) << 8) | ((value & 0X000000FF) << 24);
- }
- return value;
-}
-
-#if defined(__cplusplus)
-}
-#endif
-
_X_EXPORT const GlxServerExports *glvndGetExports(void);
#endif // VNDSERVER_H
diff --git a/glx/vndserver_priv.h b/glx/vndserver_priv.h
new file mode 100644
index 000000000..3f5b9a22f
--- /dev/null
+++ b/glx/vndserver_priv.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * unaltered in all copies or substantial portions of the Materials.
+ * Any additions, deletions, or changes to the original source files
+ * must be clearly indicated in accompanying documentation.
+ *
+ * If only executable code is distributed, then the accompanying
+ * documentation must state that "this software is based in part on the
+ * work of the Khronos Group."
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ */
+
+#ifndef _XSERVER_VNDSERVER_PRIV_H
+#define _XSERVER_VNDSERVER_PRIV_H
+
+#include <dix-config.h>
+#include "glxvndabi.h"
+#include "vndserver.h"
+
+typedef struct GlxScreenPrivRec {
+ GlxServerVendor *vendor;
+} GlxScreenPriv;
+
+typedef struct GlxContextTagInfoRec {
+ GLXContextTag tag;
+ ClientPtr client;
+ GlxServerVendor *vendor;
+ void *data;
+ GLXContextID context;
+ GLXDrawable drawable;
+ GLXDrawable readdrawable;
+} GlxContextTagInfo;
+
+typedef struct GlxClientPrivRec {
+ GlxContextTagInfo *contextTags;
+ unsigned int contextTagCount;
+
+ /**
+ * The vendor handles for each screen.
+ */
+ GlxServerVendor **vendors;
+} GlxClientPriv;
+
+extern int GlxErrorBase;
+extern RESTYPE idResource;
+
+extern ExtensionEntry *GlxExtensionEntry;
+Bool GlxDispatchInit(void);
+void GlxDispatchReset(void);
+
+/**
+ * Handles a request from the client.
+ *
+ * This function will look up the correct handler function and forward the
+ * request to it.
+ */
+int GlxDispatchRequest(ClientPtr client);
+
+/**
+ * Looks up the GlxClientPriv struct for a client. If we don't have a
+ * GlxClientPriv struct yet, then allocate one.
+ */
+GlxClientPriv *GlxGetClientData(ClientPtr client);
+
+/**
+ * Frees any data that's specific to a client. This should be called when a
+ * client disconnects.
+ */
+void GlxFreeClientData(ClientPtr client);
+
+Bool GlxAddXIDMap(XID id, GlxServerVendor *vendor);
+GlxServerVendor * GlxGetXIDMap(XID id);
+void GlxRemoveXIDMap(XID id);
+
+/**
+ * Records the client that sent the current request. This is needed in
+ * GlxGetXIDMap to know which client's (screen -> vendor) mapping to use for a
+ * regular X window.
+ */
+void GlxSetRequestClient(ClientPtr client);
+
+GlxContextTagInfo *GlxAllocContextTag(ClientPtr client, GlxServerVendor *vendor);
+GlxContextTagInfo *GlxLookupContextTag(ClientPtr client, GLXContextTag tag);
+void GlxFreeContextTag(GlxContextTagInfo *tagInfo);
+
+Bool GlxSetScreenVendor(ScreenPtr screen, GlxServerVendor *vendor);
+Bool GlxSetClientScreenVendor(ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor);
+GlxScreenPriv *GlxGetScreen(ScreenPtr pScreen);
+GlxServerVendor *GlxGetVendorForScreen(ClientPtr client, ScreenPtr screen);
+
+static inline CARD32 GlxCheckSwap(ClientPtr client, CARD32 value)
+{
+ if (client->swapped)
+ {
+ value = ((value & 0XFF000000) >> 24) | ((value & 0X00FF0000) >> 8)
+ | ((value & 0X0000FF00) << 8) | ((value & 0X000000FF) << 24);
+ }
+ return value;
+}
+
+#endif /* _XSERVER_VNDSERVER_PRIV_H */
diff --git a/glx/vndservermapping.c b/glx/vndservermapping.c
index e5b9e6b2a..1a76e52a8 100644
--- a/glx/vndservermapping.c
+++ b/glx/vndservermapping.c
@@ -27,7 +27,7 @@
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-#include "vndserver.h"
+#include "vndserver_priv.h"
#include <pixmapstr.h>
diff --git a/glx/xfont.c b/glx/xfont.c
index bd2fdae52..bd090cb15 100644
--- a/glx/xfont.c
+++ b/glx/xfont.c
@@ -32,6 +32,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "glxserver.h"
#include "glxutil.h"
#include "unpack.h"
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 9236252b2..3d0dd872b 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -30,8 +30,9 @@
#include <xcb/xcb_keysyms.h>
#include <X11/keysym.h>
-#include "ephyr.h"
+#include "os/osdep.h"
+#include "ephyr.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "ephyrlog.h"
@@ -298,7 +299,7 @@ ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)
* pBuf->pDamage regions
*/
shadowUpdateRotatePacked(pScreen, pBuf);
- hostx_paint_rect(screen, 0, 0, 0, 0, screen->width, screen->height);
+ hostx_paint_rect(screen, 0, 0, 0, 0, screen->width, screen->height, TRUE);
}
static void
@@ -328,7 +329,8 @@ ephyrInternalDamageRedisplay(ScreenPtr pScreen)
hostx_paint_rect(screen,
pbox->x1, pbox->y1,
pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ nbox == 0);
pbox++;
}
}
@@ -566,6 +568,7 @@ ephyrRandRSetConfig(ScreenPtr pScreen,
if (wasEnabled)
KdEnableScreen(pScreen);
+ RRGetInfo(pScreen, TRUE);
RRScreenSizeNotify(pScreen);
return TRUE;
@@ -889,7 +892,8 @@ ephyrProcessExpose(xcb_generic_event_t *xev)
if (scrpriv) {
hostx_paint_rect(scrpriv->screen, 0, 0, 0, 0,
scrpriv->win_width,
- scrpriv->win_height);
+ scrpriv->win_height,
+ TRUE);
} else {
EPHYR_LOG_ERROR("failed to get host screen\n");
}
diff --git a/hw/kdrive/ephyr/ephyr_glamor.c b/hw/kdrive/ephyr/ephyr_glamor.c
index 724611d69..772b73052 100644
--- a/hw/kdrive/ephyr/ephyr_glamor.c
+++ b/hw/kdrive/ephyr/ephyr_glamor.c
@@ -25,14 +25,18 @@
*
* Glamor support and EGL setup.
*/
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_NO_X11
#include <stdlib.h>
#include <stdint.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <pixman.h>
+#include "glamor_context.h"
#include "glamor_egl.h"
#include "glamor_priv.h"
+#include "ephyr.h"
#include "ephyr_glamor.h"
#include "os.h"
@@ -69,6 +73,64 @@ struct ephyr_glamor {
GLuint vao, vbo;
};
+static void
+glamor_egl_make_current(struct glamor_context *glamor_ctx)
+{
+ /* There's only a single global dispatch table in Mesa. EGL, GLX,
+ * and AIGLX's direct dispatch table manipulation don't talk to
+ * each other. We need to set the context to NULL first to avoid
+ * EGL's no-op context change fast path when switching back to
+ * EGL.
+ */
+ eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+ if (!eglMakeCurrent(glamor_ctx->display,
+ glamor_ctx->surface, glamor_ctx->surface,
+ glamor_ctx->ctx)) {
+ FatalError("Failed to make EGL context current\n");
+ }
+}
+
+void
+glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
+{
+ KdScreenPriv(screen);
+ KdScreenInfo *kd_screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = kd_screen->driver;
+ struct ephyr_glamor *ephyr_glamor = scrpriv->glamor;
+
+ glamor_enable_dri3(screen);
+ glamor_ctx->display = ephyr_glamor->dpy;
+ glamor_ctx->ctx = ephyr_glamor->ctx;
+ glamor_ctx->surface = ephyr_glamor->egl_win;
+ glamor_ctx->make_current = glamor_egl_make_current;
+}
+
+int
+glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
+ PixmapPtr pixmap,
+ CARD16 *stride, CARD32 *size)
+{
+ return -1;
+}
+
+
+int
+glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
+ uint32_t *offsets, uint32_t *strides,
+ uint64_t *modifier)
+{
+ return 0;
+}
+
+int
+glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
+ CARD16 *stride, CARD32 *size)
+{
+ return -1;
+}
+
static GLuint
ephyr_glamor_build_glsl_prog(GLuint vs, GLuint fs)
{
diff --git a/hw/kdrive/ephyr/ephyr_glamor_xv.c b/hw/kdrive/ephyr/ephyr_glamor_xv.c
index 4dd15cf41..b5eae48c8 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_xv.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_xv.c
@@ -50,16 +50,16 @@ ephyr_glamor_xv_stop_video(KdScreenInfo *screen, void *data, Bool cleanup)
static int
ephyr_glamor_xv_set_port_attribute(KdScreenInfo *screen,
- Atom attribute, INT32 value, void *data)
+ Atom attribute, int value, void *data)
{
- return glamor_xv_set_port_attribute(data, attribute, value);
+ return glamor_xv_set_port_attribute(data, attribute, (INT32)value);
}
static int
ephyr_glamor_xv_get_port_attribute(KdScreenInfo *screen,
- Atom attribute, INT32 *value, void *data)
+ Atom attribute, int *value, void *data)
{
- return glamor_xv_get_port_attribute(data, attribute, value);
+ return glamor_xv_get_port_attribute(data, attribute, (INT32 *)value);
}
static void
diff --git a/hw/kdrive/ephyr/ephyrcursor.c b/hw/kdrive/ephyr/ephyrcursor.c
index f991899c5..3f192d034 100644
--- a/hw/kdrive/ephyr/ephyrcursor.c
+++ b/hw/kdrive/ephyr/ephyrcursor.c
@@ -246,7 +246,7 @@ miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
Bool
ephyrCursorInit(ScreenPtr screen)
{
- if (!dixRegisterPrivateKey(&ephyrCursorPrivateKey, PRIVATE_CURSOR_BITS,
+ if (!dixRegisterPrivateKey(&ephyrCursorPrivateKey, PRIVATE_CURSOR,
sizeof(ephyrCursorRec)))
return FALSE;
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 09cd28cb3..eb31b55a2 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -26,6 +26,10 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
+
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include "ephyr.h"
#include "ephyrlog.h"
#include "glx_extinit.h"
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index d8ed68bfd..be894bd36 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -43,6 +43,8 @@
#include <sys/time.h>
#include <sys/mman.h>
+#define X_INCLUDE_STRING_H
+#include <X11/Xos_r.h>
#include <X11/keysym.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
@@ -55,8 +57,11 @@
#include <xcb/randr.h>
#include <xcb/xkb.h>
#ifdef GLAMOR
+#include <xcb/glx.h>
+#include <epoxy/common.h>
#include <epoxy/gl.h>
#include "glamor.h"
+#include "glamor_glx_provider.h"
#include "ephyr_glamor.h"
#endif
#include "ephyrlog.h"
@@ -83,6 +88,7 @@ struct EphyrHostXVars {
long damage_debug_msec;
Bool size_set_from_configure;
+ char *glvnd_vendor;
};
/* memset ( missing> ) instead of below */
@@ -414,11 +420,6 @@ hostx_set_title(char *title)
ephyrTitle = title;
}
-#ifdef __SUNPRO_C
-/* prevent "Function has no return statement" error for x_io_error_handler */
-#pragma does_not_return(exit)
-#endif
-
static void
hostx_init_shm(void)
{
@@ -1011,7 +1012,8 @@ static void hostx_paint_debug_rect(KdScreenInfo *screen,
void
hostx_paint_rect(KdScreenInfo *screen,
- int sx, int sy, int dx, int dy, int width, int height)
+ int sx, int sy, int dx, int dy, int width, int height,
+ Bool sync)
{
EphyrScrPriv *scrpriv = screen->driver;
@@ -1100,7 +1102,8 @@ hostx_paint_rect(KdScreenInfo *screen,
HostX.gc, scrpriv->ximg,
scrpriv->shminfo,
sx, sy, dx, dy, width, height, FALSE);
- xcb_aux_sync(HostX.conn);
+ if (sync)
+ xcb_aux_sync(HostX.conn);
}
else {
xcb_image_t *subimg = xcb_image_subimage(scrpriv->ximg, sx, sy,
@@ -1549,12 +1552,50 @@ out:
}
#ifdef GLAMOR
+
+#ifndef GLX_EXTENSIONS
+#define GLX_EXTENSIONS 3
+#endif
+
+#ifndef GLX_VENDOR_NAMES_EXT
+#define GLX_VENDOR_NAMES_EXT 0x20F6
+#endif
+
+/**
+ * Exchange a protocol request for glXQueryServerString.
+ */
+static char *
+__glXQueryServerString(CARD32 name)
+{
+ xcb_glx_query_server_string_cookie_t cookie;
+ xcb_glx_query_server_string_reply_t *reply;
+ uint32_t len;
+ char *str;
+ char *buf;
+
+ cookie = xcb_glx_query_server_string(HostX.conn, HostX.screen, name);
+ reply = xcb_glx_query_server_string_reply(HostX.conn, cookie, NULL);
+ str = xcb_glx_query_server_string_string(reply);
+
+ /* The spec doesn't mention this, but the Xorg server replies with
+ * a string already terminated with '\0'. */
+ len = xcb_glx_query_server_string_string_length(reply);
+ buf = xnfalloc(len);
+ memcpy(buf, str, len);
+ free(reply);
+
+ return buf;
+}
+
Bool
ephyr_glamor_init(ScreenPtr screen)
{
KdScreenPriv(screen);
KdScreenInfo *kd_screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = kd_screen->driver;
+ char *hostx_glx_exts = NULL;
+ char *glvnd_vendors = NULL;
+ _Xstrtokparams saveptr;
scrpriv->glamor = ephyr_glamor_screen_init(scrpriv->win, scrpriv->vid);
ephyr_glamor_set_window_size(scrpriv->glamor,
@@ -1564,6 +1605,18 @@ ephyr_glamor_init(ScreenPtr screen)
FatalError("Failed to initialize glamor\n");
return FALSE;
}
+ hostx_glx_exts = __glXQueryServerString(GLX_EXTENSIONS);
+ if (epoxy_extension_in_string(hostx_glx_exts,"GLX_EXT_libglvnd"))
+ glvnd_vendors = __glXQueryServerString(GLX_VENDOR_NAMES_EXT);
+
+ if (glvnd_vendors) {
+ HostX.glvnd_vendor = _XStrtok(glvnd_vendors, " ", saveptr);
+ glamor_set_glvnd_vendor(screen, HostX.glvnd_vendor);
+ free(glvnd_vendors);
+ }
+ free(hostx_glx_exts);
+
+ GlxPushProvider(&glamor_provider);
return TRUE;
}
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 4b2678e58..8b3caf245 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -146,7 +146,8 @@ void *hostx_screen_init(KdScreenInfo *screen,
void
hostx_paint_rect(KdScreenInfo *screen,
- int sx, int sy, int dx, int dy, int width, int height);
+ int sx, int sy, int dx, int dy, int width, int height,
+ Bool sync);
Bool
hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls);
diff --git a/hw/kdrive/ephyr/meson.build b/hw/kdrive/ephyr/meson.build
index dff1dfb68..148b82cef 100644
--- a/hw/kdrive/ephyr/meson.build
+++ b/hw/kdrive/ephyr/meson.build
@@ -28,8 +28,8 @@ if build_glamor
srcs += 'ephyr_glamor_xv.c'
endif
xephyr_glamor += glamor
- xephyr_glamor += glamor_egl_stubs
xephyr_dep += epoxy_dep
+ xephyr_dep += dependency('xcb-glx')
endif
if build_xv
diff --git a/hw/kdrive/src/kcmap.c b/hw/kdrive/src/kcmap.c
index b8697ca63..2e65bdde4 100644
--- a/hw/kdrive/src/kcmap.c
+++ b/hw/kdrive/src/kcmap.c
@@ -169,7 +169,7 @@ KdUninstallColormap(ColormapPtr pCmap)
return;
/* install default */
- dixLookupResourceByType((void **) &defMap, defMapID, RT_COLORMAP,
+ dixLookupResourceByType((void **) &defMap, defMapID, X11_RESTYPE_COLORMAP,
serverClient, DixInstallAccess);
if (defMap)
(*pCmap->pScreen->InstallColormap) (defMap);
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 0c80752a0..2145f64cb 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -23,6 +23,12 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
+
+#include "dix/screenint_priv.h"
+#include "os/cmdline.h"
+
+#include "os/osdep.h"
+
#include "kdrive.h"
#include <mivalidate.h>
#include <dixstruct.h>
@@ -352,7 +358,7 @@ KdUseMsg(void)
ErrorF
("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
ErrorF
- ("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n");
+ ("-mouse driver [,n,options] Specify the pointer driver and its options (n is the number of buttons)\n");
ErrorF
("-keybd driver [,,options] Specify the keyboard driver and its options\n");
ErrorF("-xkb-rules Set default XkbRules value (can be overridden by -keybd options)\n");
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 185a9a359..5b33eeec0 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -51,6 +51,8 @@
#include "inpututils.h"
#include "optionstr.h"
+#include "os/cmdline.h"
+
#if defined(CONFIG_UDEV) || defined(CONFIG_HAL)
#include <hotplug.h>
#endif
@@ -940,6 +942,8 @@ KdParseKeyboard(const char *arg)
if (!ki)
return NULL;
+ if (ki->name)
+ free(ki->name);
ki->name = strdup("Unknown KDrive Keyboard");
ki->path = NULL;
ki->driver = NULL;
diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index 2c272fad5..21387dee4 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -81,7 +81,7 @@ vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
static int
vfbMouseProc(DeviceIntPtr pDevice, int onoff)
{
-#define NBUTTONS 3
+#define NBUTTONS 13
#define NAXES 2
BYTE map[NBUTTONS + 1];
@@ -91,13 +91,23 @@ vfbMouseProc(DeviceIntPtr pDevice, int onoff)
switch (onoff) {
case DEVICE_INIT:
- map[1] = 1;
- map[2] = 2;
- map[3] = 3;
+ for (int i = 1; i <= NBUTTONS; ++i) {
+ map[i] = i;
+ }
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+ btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+ btn_labels[9] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+ btn_labels[10] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+ btn_labels[11] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+ btn_labels[12] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 48efb61b2..e4b75a796 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -37,6 +37,11 @@ from The Open Group.
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xos.h>
+
+#include "dix/screenint_priv.h"
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include "scrnintstr.h"
#include "servermd.h"
#define PSZ 8
@@ -59,10 +64,10 @@ from The Open Group.
#include <sys/param.h>
#endif
#include <X11/XWDFile.h>
-#ifdef HAS_SHM
+#ifdef MITSHM
#include <sys/ipc.h>
#include <sys/shm.h>
-#endif /* HAS_SHM */
+#endif /* MITSHM */
#include "dix.h"
#include "miline.h"
#include "glx_extinit.h"
@@ -98,7 +103,7 @@ typedef struct {
char mmap_file[MAXPATHLEN];
#endif
-#ifdef HAS_SHM
+#ifdef MITSHM
int shmid;
#endif
} vfbScreenInfo, *vfbScreenInfoPtr;
@@ -173,17 +178,17 @@ freeScreenInfo(vfbScreenInfoPtr pvfb)
break;
#endif /* HAVE_MMAP */
-#ifdef HAS_SHM
+#ifdef MITSHM
case SHARED_MEMORY_FB:
if (-1 == shmdt((char *) pvfb->pXWDHeader)) {
perror("shmdt");
ErrorF("shmdt failed, %s", strerror(errno));
}
break;
-#else /* HAS_SHM */
+#else /* MITSHM */
case SHARED_MEMORY_FB:
break;
-#endif /* HAS_SHM */
+#endif /* MITSHM */
case NORMAL_MEMORY_FB:
free(pvfb->pXWDHeader);
@@ -252,7 +257,7 @@ ddxUseMsg(void)
("-fbdir directory put framebuffers in mmap'ed files in directory\n");
#endif
-#ifdef HAS_SHM
+#ifdef MITSHM
ErrorF("-shmem put framebuffers in shared memory\n");
#endif
}
@@ -368,7 +373,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
}
#endif /* HAVE_MMAP */
-#ifdef HAS_SHM
+#ifdef MITSHM
if (strcmp(argv[i], "-shmem") == 0) { /* -shmem */
fbmemtype = SHARED_MEMORY_FB;
return 1;
@@ -537,7 +542,7 @@ vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb)
}
#endif /* HAVE_MMAP */
-#ifdef HAS_SHM
+#ifdef MITSHM
static void
vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb)
{
@@ -563,7 +568,7 @@ vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb)
ErrorF("screen %d shmid %d\n", (int) (pvfb - vfbScreens), pvfb->shmid);
}
-#endif /* HAS_SHM */
+#endif /* MITSHM */
static char *
vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb)
@@ -606,7 +611,7 @@ vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb)
break;
#endif
-#ifdef HAS_SHM
+#ifdef MITSHM
case SHARED_MEMORY_FB:
vfbAllocateSharedMemoryFramebuffer(pvfb);
break;
@@ -753,6 +758,8 @@ vfbRRScreenSetSize(ScreenPtr pScreen,
CARD32 mmWidth,
CARD32 mmHeight)
{
+ rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen);
+
// Prevent screen updates while we change things around
SetRootClip(pScreen, ROOT_CLIP_NONE);
@@ -767,7 +774,7 @@ vfbRRScreenSetSize(ScreenPtr pScreen,
RRScreenSizeNotify (pScreen);
RRTellChanged(pScreen);
- return TRUE;
+ return RROutputSetPhysicalSize(pScrPriv->outputs[pScreen->myNum], mmWidth, mmHeight);
}
static Bool
@@ -803,6 +810,7 @@ vfbRandRInit(ScreenPtr pScreen)
xRRModeInfo modeInfo;
char name[64];
#endif
+ int mmWidth, mmHeight;
if (!RRScreenInit (pScreen))
return FALSE;
@@ -818,6 +826,9 @@ vfbRandRInit(ScreenPtr pScreen)
pScrPriv->rrOutputValidateMode = vfbRROutputValidateMode;
pScrPriv->rrModeDestroy = NULL;
+ mmWidth = pScreen->width * 25.4 / monitorResolution;
+ mmHeight = pScreen->height * 25.4 / monitorResolution;
+
RRScreenSetSizeRange (pScreen,
1, 1,
pScreen->width, pScreen->height);
@@ -850,6 +861,8 @@ vfbRandRInit(ScreenPtr pScreen)
return FALSE;
if (!RROutputSetConnection (output, RR_Connected))
return FALSE;
+ if (!RROutputSetPhysicalSize (output, mmWidth, mmHeight))
+ return FALSE;
RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, NULL, 1, &output);
#endif
return TRUE;
@@ -958,6 +971,9 @@ InitOutput(ScreenInfo * screen_info, int argc, char **argv)
int i;
int NumFormats = 0;
+ if (!monitorResolution)
+ monitorResolution = 96;
+
/* initialize pixmap formats */
/* must have a pixmap depth to match every screen depth */
diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index eb788d3fd..af2f1490c 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -51,10 +51,6 @@
#define _COMPILER_H
-#if defined(__SUNPRO_C)
-#define DO_PROTOTYPES
-#endif
-
/* Map Sun compiler platform defines to gcc-style used in the code */
#if defined(__amd64) && !defined(__amd64__)
#define __amd64__
@@ -95,45 +91,6 @@
#define __FUNCTION__ __func__ /* C99 */
#endif
-#if defined(DO_PROTOTYPES)
-#if !defined(__arm__)
-#if !defined(__sparc__) && !defined(__arm32__) && !defined(__nds32__) \
- && !(defined(__alpha__) && defined(__linux__)) \
- && !(defined(__ia64__) && defined(__linux__)) \
- && !(defined(__mips64) && defined(__linux__)) \
-
-extern _X_EXPORT void outb(unsigned short, unsigned char);
-extern _X_EXPORT void outw(unsigned short, unsigned short);
-extern _X_EXPORT void outl(unsigned short, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned short);
-extern _X_EXPORT unsigned int inw(unsigned short);
-extern _X_EXPORT unsigned int inl(unsigned short);
-
-#else /* __sparc__, __arm32__, __alpha__, __nds32__ */
-extern _X_EXPORT void outb(unsigned long, unsigned char);
-extern _X_EXPORT void outw(unsigned long, unsigned short);
-extern _X_EXPORT void outl(unsigned long, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned long);
-extern _X_EXPORT unsigned int inw(unsigned long);
-extern _X_EXPORT unsigned int inl(unsigned long);
-
-#ifdef __SUNPRO_C
-extern _X_EXPORT unsigned char xf86ReadMmio8 (void *, unsigned long);
-extern _X_EXPORT unsigned short xf86ReadMmio16Be (void *, unsigned long);
-extern _X_EXPORT unsigned short xf86ReadMmio16Le (void *, unsigned long);
-extern _X_EXPORT unsigned int xf86ReadMmio32Be (void *, unsigned long);
-extern _X_EXPORT unsigned int xf86ReadMmio32Le (void *, unsigned long);
-extern _X_EXPORT void xf86WriteMmio8 (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio16Be (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio16Le (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio32Be (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int);
-#endif /* _SUNPRO_C */
-#endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
-#endif /* __arm__ */
-
-#endif /* NO_INLINE || DO_PROTOTYPES */
-
#ifdef __GNUC__
#ifdef __i386__
@@ -265,8 +222,7 @@ inl(unsigned long port)
#endif /* __linux__ */
-#if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
- && !defined(DO_PROTOTYPES)
+#if (defined(__FreeBSD__) || defined(__OpenBSD__))
/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
/* inx/outx routines */
@@ -280,7 +236,7 @@ extern _X_EXPORT unsigned char inb(unsigned int port);
extern _X_EXPORT unsigned short inw(unsigned int port);
extern _X_EXPORT unsigned int inl(unsigned int port);
-#endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
+#endif /* (__FreeBSD__ || __OpenBSD__ ) */
#if defined(__NetBSD__)
#include <machine/pio.h>
@@ -941,9 +897,7 @@ inl(unsigned PORT_SIZE port)
#define asm __asm
#endif
#endif
-#if !defined(__SUNPRO_C)
#include <sys/inline.h>
-#endif
#endif /* __GNUC__ */
#if !defined(MMIO_IS_BE) && \
diff --git a/hw/xfree86/common/dgaproc.h b/hw/xfree86/common/dgaproc.h
index b9f003056..45b8481a8 100644
--- a/hw/xfree86/common/dgaproc.h
+++ b/hw/xfree86/common/dgaproc.h
@@ -52,16 +52,4 @@ typedef struct {
int reserved2;
} XDGAModeRec, *XDGAModePtr;
-/* DDX interface */
-
-extern Bool DGAScreenAvailable(ScreenPtr pScreen);
-extern Bool DGAActive(int Index);
-
-extern Bool DGAVTSwitch(void);
-extern Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index,
- int button, int is_down);
-extern Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy);
-extern Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index,
- int key_code, int is_down);
-
#endif /* __DGAPROC_H */
diff --git a/hw/xfree86/common/dgaproc_priv.h b/hw/xfree86/common/dgaproc_priv.h
new file mode 100644
index 000000000..05d8f2bee
--- /dev/null
+++ b/hw/xfree86/common/dgaproc_priv.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef __XSERVER_XFREE86_DGAPROC_H
+#define __XSERVER_XFREE86_DGAPROC_H
+
+#include "screenint.h"
+#include "input.h"
+
+Bool DGAScreenAvailable(ScreenPtr pScreen);
+Bool DGAActive(int Index);
+
+Bool DGAVTSwitch(void);
+Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index, int button, int is_down);
+Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy);
+Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index, int key_code, int is_down);
+
+#endif /* __XSERVER_XFREE86_DGAPROC_H */
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 927a7a7f1..8d0cb0532 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -79,6 +79,14 @@ extern _X_EXPORT Bool xf86DRI2Enabled(void);
#define XF86SCRNINFO(p) xf86ScreenToScrn(p)
+#define XF86FLIP_PIXELS() \
+ do { \
+ if (xf86GetFlipPixels()) { \
+ pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
+ pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
+ } \
+ while (0)
+
#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
/* Compatibility functions for pre-input-thread drivers */
@@ -278,6 +286,8 @@ xf86GetWeight(void);
extern _X_EXPORT Gamma
xf86GetGamma(void);
extern _X_EXPORT Bool
+xf86GetFlipPixels(void);
+extern _X_EXPORT Bool
xf86ServerIsExiting(void);
extern _X_EXPORT Bool
xf86ServerIsResetting(void);
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 0f4f05de9..6eb3705c2 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -39,6 +39,7 @@
#include "xf86Config.h"
#include "xf86MatchDrivers.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include "xf86platformBus.h"
#include "xf86pciBus.h"
@@ -294,18 +295,17 @@ listPossibleVideoDrivers(XF86MatchedDrivers *md)
xf86PciMatchDriver(md);
#endif
-#if defined(__linux__)
+#if defined(HAVE_MODESETTING_DRIVER)
xf86AddMatchedDriver(md, "modesetting");
#endif
-#if !defined(__sun)
/* Fallback to platform default frame buffer driver */
-#if !defined(__linux__) && defined(__sparc__)
- xf86AddMatchedDriver(md, "wsfb");
-#else
+#if defined(__linux__)
xf86AddMatchedDriver(md, "fbdev");
#endif
-#endif /* !__sun */
+#if defined(__FreeBSD__)
+ xf86AddMatchedDriver(md, "scfb");
+#endif
/* Fallback to platform default hardware */
#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
@@ -313,6 +313,10 @@ listPossibleVideoDrivers(XF86MatchedDrivers *md)
#elif defined(__sparc__) && !defined(__sun)
xf86AddMatchedDriver(md, "sunffb");
#endif
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ xf86AddMatchedDriver(md, "wsfb");
+#endif
}
/* copy a screen section and enter the desired driver
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index fd144dbe7..6c5c730a1 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -45,7 +45,6 @@
#include "xf86Bus.h"
-#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
#ifdef XSERVER_LIBPCIACCESS
#include "xf86VGAarbiter.h"
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 5d814c148..c3d87fbe2 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -46,6 +46,7 @@
#include <xorg-config.h>
#endif
+#include <sys/stat.h>
#include <sys/types.h>
#include <grp.h>
@@ -646,6 +647,7 @@ typedef enum {
FLAG_MAX_CLIENTS,
FLAG_IGLX,
FLAG_DEBUG,
+ FLAG_ALLOW_BYTE_SWAPPED_CLIENTS,
} FlagValues;
/**
@@ -705,6 +707,8 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE},
{FLAG_DEBUG, "Debug", OPTV_STRING,
{0}, FALSE},
+ {FLAG_ALLOW_BYTE_SWAPPED_CLIENTS, "AllowByteSwappedClients", OPTV_BOOLEAN,
+ {0}, FALSE},
{-1, NULL, OPTV_NONE,
{0}, FALSE},
};
@@ -746,6 +750,11 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
}
+ xf86GetOptValBool(FlagOptions, FLAG_ALLOW_BYTE_SWAPPED_CLIENTS, &AllowByteSwappedClients);
+ if (AllowByteSwappedClients) {
+ xf86Msg(X_CONFIG, "Allowing byte-swapped clients\n");
+ }
+
if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
&xf86Info.autoAddDevices);
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 4347f6d2f..a29c5460e 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -27,6 +27,10 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
+
+#include "os/osdep.h"
+
#include "xf86.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 8bb68a56f..37ae26c9a 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -46,6 +46,7 @@
#ifdef XFreeXDGA
#include "dgaproc.h"
+#include "dgaproc_priv.h"
#endif
typedef struct _xf86EdgeRec {
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index fa70ba2f0..910141755 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -43,10 +43,14 @@
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/eventconvert.h"
+
#include "xf86.h"
#include "xf86str.h"
#include "xf86Priv.h"
#include "dgaproc.h"
+#include "dgaproc_priv.h"
#include <X11/extensions/xf86dgaproto.h>
#include "colormapst.h"
#include "pixmapstr.h"
@@ -59,7 +63,6 @@
#include "exglobals.h"
#include "exevents.h"
#include "eventstr.h"
-#include "eventconvert.h"
#include "xf86Extensions.h"
#include "mi.h"
@@ -366,7 +369,7 @@ xf86SetDGAMode(ScrnInfoPtr pScrn, int num, DGADevicePtr devRet)
if (oldPix) {
if (oldPix->drawable.id)
- FreeResource(oldPix->drawable.id, RT_NONE);
+ FreeResource(oldPix->drawable.id, X11_RESTYPE_NONE);
else
(*pScreen->DestroyPixmap) (oldPix);
}
@@ -428,7 +431,7 @@ xf86SetDGAMode(ScrnInfoPtr pScrn, int num, DGADevicePtr devRet)
if (oldPix) {
if (oldPix->drawable.id)
- FreeResource(oldPix->drawable.id, RT_NONE);
+ FreeResource(oldPix->drawable.id, X11_RESTYPE_NONE);
else
(*pScreen->DestroyPixmap) (oldPix);
}
@@ -1456,7 +1459,7 @@ ProcXDGASetMode(ClientPtr client)
DGA_SETCLIENT(stuff->screen, client);
if (pPix) {
- if (AddResource(stuff->pid, RT_PIXMAP, (void *) (pPix))) {
+ if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) (pPix))) {
pPix->drawable.id = (int) stuff->pid;
rep.flags = DGA_PIXMAP_AVAILABLE;
}
@@ -1534,7 +1537,7 @@ ProcXDGAInstallColormap(ClientPtr client)
if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
- rc = dixLookupResourceByType((void **) &cmap, stuff->cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &cmap, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixInstallAccess);
if (rc != Success)
return rc;
@@ -1970,7 +1973,7 @@ ProcXF86DGAInstallColormap(ClientPtr client)
if (!DGAActive(stuff->screen))
return DGAErrorBase + XF86DGADirectNotActivated;
- rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP,
+ rc = dixLookupResourceByType((void **) &pcmp, stuff->id, X11_RESTYPE_COLORMAP,
client, DixInstallAccess);
if (rc == Success) {
DGAInstallCmap(pcmp);
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 395bbc7b3..23c492915 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -53,18 +53,21 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xatom.h>
+
#include "misc.h"
#include "xf86.h"
#include "xf86Priv.h"
-#define XF86_OS_PRIVS
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include <X11/keysym.h>
#ifdef XFreeXDGA
#include "dgaproc.h"
+#include "dgaproc_priv.h"
#endif
#include <X11/extensions/XI.h>
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 65a3192df..b48b7aada 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -188,6 +188,7 @@ int xf86FbBpp = -1;
int xf86Depth = -1;
rgb xf86Weight = { 0, 0, 0 };
+Bool xf86FlipPixels = FALSE;
Gamma xf86Gamma = { 0.0, 0.0, 0.0 };
Bool xf86AllowMouseOpenFail = FALSE;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 0389945a7..85bd3bb33 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -38,7 +38,9 @@
#include <xorg-config.h>
#endif
+#include <sys/stat.h>
#include <X11/X.h>
+
#include "mi.h"
#include "os.h"
#include "servermd.h"
@@ -952,8 +954,14 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
void
xf86SetBlackWhitePixels(ScreenPtr pScreen)
{
- pScreen->whitePixel = 1;
- pScreen->blackPixel = 0;
+ if (xf86FlipPixels) {
+ pScreen->whitePixel = 0;
+ pScreen->blackPixel = 1;
+ }
+ else {
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
+ }
}
/*
@@ -1395,6 +1403,12 @@ xf86GetGamma(void)
}
Bool
+xf86GetFlipPixels(void)
+{
+ return xf86FlipPixels;
+}
+
+Bool
xf86ServerIsExiting(void)
{
return (dispatchException & DE_TERMINATE) == DE_TERMINATE;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 5695e71ac..93f14318d 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <errno.h>
+#include <sys/stat.h>
#undef HAS_UTSNAME
#if !defined(WIN32)
@@ -47,20 +48,24 @@
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include <X11/Xatom.h>
+
+#include "config/dbus-core.h"
+#include "dix/screenint_priv.h"
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include "input.h"
#include "servermd.h"
#include "windowstr.h"
#include "scrnintstr.h"
#include "mi.h"
-#include "dbus-core.h"
#include "systemd-logind.h"
-
#include "loaderProcs.h"
-#define XF86_OS_PRIVS
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Config.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include "xf86cmap.h"
#include "xorgVersion.h"
@@ -188,12 +193,6 @@ xf86PrintBanner(void)
}
Bool
-xf86PrivsElevated(void)
-{
- return PrivsElevated();
-}
-
-Bool
xf86HasTTYs(void)
{
#ifdef __linux__
@@ -926,7 +925,7 @@ ddxProcessArgument(int argc, char **argv, int i)
/* First the options that are not allowed with elevated privileges */
if (!strcmp(argv[i], "-modulepath")) {
CHECK_FOR_REQUIRED_ARGUMENTS(1);
- if (xf86PrivsElevated())
+ if (PrivsElevated())
FatalError("\nInvalid argument -modulepath "
"with elevated privileges\n");
xf86ModulePath = argv[i + 1];
@@ -935,7 +934,7 @@ ddxProcessArgument(int argc, char **argv, int i)
}
if (!strcmp(argv[i], "-logfile")) {
CHECK_FOR_REQUIRED_ARGUMENTS(1);
- if (xf86PrivsElevated())
+ if (PrivsElevated())
FatalError("\nInvalid argument -logfile "
"with elevated privileges\n");
xf86LogFile = argv[i + 1];
@@ -954,6 +953,10 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86ConfigDir = argv[i + 1];
return 2;
}
+ if (!strcmp(argv[i], "-flipPixels")) {
+ xf86FlipPixels = TRUE;
+ return 1;
+ }
#ifdef XF86VIDMODE
if (!strcmp(argv[i], "-disableVidMode")) {
xf86VidModeDisabled = TRUE;
@@ -1233,6 +1236,7 @@ ddxUseMsg(void)
ErrorF
("-pointer name specify the core pointer InputDevice name\n");
ErrorF("-nosilk disable Silken Mouse\n");
+ ErrorF("-flipPixels swap default black/white Pixel values\n");
#ifdef XF86VIDMODE
ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
ErrorF
diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index 16dd529e3..a28973ead 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -230,6 +230,8 @@ xf86ModeStatusToString(ModeStatus status)
return "monitor doesn't support reduced blanking";
case MODE_BANDWIDTH:
return "mode requires too much memory bandwidth";
+ case MODE_DUPLICATE:
+ return "the same mode has been added";
case MODE_BAD:
return "unknown reason";
case MODE_ERROR:
@@ -507,6 +509,8 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
/* scan through the modes in the sort order above */
if ((p->type & type) != type)
continue;
+ if (p->name == NULL)
+ continue;
if (strcmp(p->name, modep->name) == 0) {
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 33cf0e56a..b6eb80622 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -74,7 +74,7 @@
* mask is 0xFFFF0000.
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(25, 3)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(27, 0)
#define ABI_XINPUT_VERSION SET_ABI_VERSION(24, 4)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(10, 0)
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index d5185d8df..f6c70fa17 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -69,6 +69,7 @@ extern _X_EXPORT char *xf86KeyboardName;
extern _X_EXPORT int xf86FbBpp;
extern _X_EXPORT int xf86Depth;
extern _X_EXPORT rgb xf86Weight;
+extern _X_EXPORT Bool xf86FlipPixels;
extern _X_EXPORT Gamma xf86Gamma;
/* Other parameters */
@@ -157,8 +158,6 @@ xf86SetLogVerbosity(int verb);
extern _X_EXPORT Bool
xf86CallDriverProbe(struct _DriverRec *drv, Bool detect_only);
extern _X_EXPORT Bool
-xf86PrivsElevated(void);
-extern _X_EXPORT Bool
xf86HasTTYs(void);
#endif /* _NO_XF86_PROTOTYPES */
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 8cf3f62f0..8091a2450 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -55,6 +55,9 @@
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include <X11/Xatom.h>
+
+#include "dix/ptrveloc_priv.h"
+
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Config.h"
@@ -98,6 +101,7 @@
#ifdef XFreeXDGA
#include "dgaproc.h"
+#include "dgaproc_priv.h"
#endif
#include "xkbsrv.h"
@@ -347,7 +351,7 @@ ApplyAutoRepeat(DeviceIntPtr dev)
xf86Msg(X_CONFIG, "AutoRepeat: %ld %ld\n", delay, rate);
xkbi->desc->ctrls->repeat_delay = delay;
- xkbi->desc->ctrls->repeat_interval = rate;
+ xkbi->desc->ctrls->repeat_interval = 1000 / rate;
}
/***********************************************************************
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index 8588c9fba..bb639c4f8 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -40,6 +40,8 @@
#include <X11/X.h>
#include "misc.h"
#include <X11/Xproto.h>
+
+#include "dix/colormap_priv.h"
#include "colormapst.h"
#include "scrnintstr.h"
@@ -55,6 +57,7 @@
#ifdef XFreeXDGA
#include <X11/extensions/xf86dgaproto.h>
#include "dgaproc.h"
+#include "dgaproc_priv.h"
#endif
#include "xf86cmap.h"
@@ -218,7 +221,7 @@ xf86HandleColormaps(ScreenPtr pScreen,
/* get the default map */
dixLookupResourceByType((void **) &pDefMap, pScreen->defColormap,
- RT_COLORMAP, serverClient, DixInstallAccess);
+ X11_RESTYPE_COLORMAP, serverClient, DixInstallAccess);
if (!CMapAllocateColormapPrivate(pDefMap)) {
CMapUnwrapScreen(pScreen);
diff --git a/hw/xfree86/common/xf86fbBus.c b/hw/xfree86/common/xf86fbBus.c
index 303b9c2f5..9027e5594 100644
--- a/hw/xfree86/common/xf86fbBus.c
+++ b/hw/xfree86/common/xf86fbBus.c
@@ -42,8 +42,6 @@
#include "xf86Priv.h"
#include "xf86Bus.h"
-
-#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
Bool fbSlotClaimed = FALSE;
diff --git a/hw/xfree86/common/xf86noBus.c b/hw/xfree86/common/xf86noBus.c
index 4f55def7b..e10d2fe09 100644
--- a/hw/xfree86/common/xf86noBus.c
+++ b/hw/xfree86/common/xf86noBus.c
@@ -42,8 +42,6 @@
#include "xf86Priv.h"
#include "xf86Bus.h"
-
-#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
int
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index aeeed8be6..68e3f35fc 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -46,7 +46,6 @@
/* Bus-specific headers */
#include "xf86Bus.h"
-#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
#define PCI_VENDOR_GENERIC 0x00FF
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 071f44b2a..eeeff2b88 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -36,12 +36,16 @@
#include <pciaccess.h>
#include <fcntl.h>
#include <unistd.h>
+
+#include "dix/screenint_priv.h"
+
#include "os.h"
#include "hotplug.h"
#include "systemd-logind.h"
#include "loaderProcs.h"
#include "xf86.h"
+#include "xf86_os_support.h"
#include "xf86_OSproc.h"
#include "xf86Priv.h"
#include "xf86str.h"
@@ -272,6 +276,22 @@ xf86PlatformMatchDriver(XF86MatchedDrivers *md)
}
}
+void xf86PlatformScanPciDev(void)
+{
+ int i;
+
+ if (!xf86scanpci())
+ return;
+
+ xf86Msg(X_CONFIG, "Scanning the platform PCI devices\n");
+ for (i = 0; i < xf86_num_platform_devices; i++) {
+ char *busid = xf86_platform_odev_attributes(i)->busid;
+
+ if (strncmp(busid, "pci:", 4) == 0)
+ platform_find_pci_info(&xf86_platform_devices[i], busid);
+ }
+}
+
int
xf86platformProbe(void)
{
@@ -563,6 +583,9 @@ xf86platformProbeDev(DriverPtr drvp)
/* Accept the device if the driver is hyperv_drm */
if (strcmp(xf86_platform_devices[j].attribs->driver, "hyperv_drm") == 0)
break;
+ /* Accept the device if the driver is ofdrm */
+ if (strcmp(xf86_platform_devices[j].attribs->driver, "ofdrm") == 0)
+ break;
/* Accept the device if the driver is simpledrm */
if (strcmp(xf86_platform_devices[j].attribs->driver, "simpledrm") == 0)
break;
@@ -613,31 +636,58 @@ xf86platformAddGPUDevices(DriverPtr drvp)
return foundScreen;
}
+const char *
+xf86PlatformFindHotplugDriver(int dev_index)
+{
+ XF86ConfOutputClassPtr cl;
+ const char *hp_driver = NULL;
+ struct xf86_platform_device *dev = &xf86_platform_devices[dev_index];
+
+ for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
+ if (!OutputClassMatches(cl, dev) || !cl->option_lst)
+ continue;
+
+ hp_driver = xf86FindOptionValue(cl->option_lst, "HotplugDriver");
+ if (hp_driver)
+ xf86MarkOptionUsed(cl->option_lst);
+ }
+
+ /* Return the first driver from the match list */
+ xf86Msg(X_INFO, "matching hotplug-driver is %s\n",
+ hp_driver ? hp_driver : "none");
+ return hp_driver;
+}
+
int
-xf86platformAddDevice(int index)
+xf86platformAddDevice(const char *driver_name, int index)
{
int i, old_screens, scr_index, scrnum;
DriverPtr drvp = NULL;
screenLayoutPtr layout;
- static const char *hotplug_driver_name = "modesetting";
if (!xf86Info.autoAddGPU)
return -1;
- /* force load the driver for now */
- xf86LoadOneModule(hotplug_driver_name, NULL);
+ /* Load modesetting driver if no driver given, or driver open failed */
+ if (!driver_name || !xf86LoadOneModule(driver_name, NULL)) {
+ driver_name = "modesetting";
+ xf86LoadOneModule(driver_name, NULL);
+ }
for (i = 0; i < xf86NumDrivers; i++) {
if (!xf86DriverList[i])
continue;
- if (!strcmp(xf86DriverList[i]->driverName, hotplug_driver_name)) {
+ if (!strcmp(xf86DriverList[i]->driverName, driver_name)) {
drvp = xf86DriverList[i];
break;
}
}
- if (i == xf86NumDrivers)
+
+ if (i == xf86NumDrivers) {
+ ErrorF("can't find driver %s for hotplugged device\n", driver_name);
return -1;
+ }
old_screens = xf86NumGPUScreens;
doPlatformProbe(&xf86_platform_devices[index], drvp, NULL,
@@ -672,7 +722,7 @@ xf86platformAddDevice(int index)
dixSetPrivate(&xf86GPUScreens[i]->pScreen->devPrivates,
xf86ScreenKey, xf86GPUScreens[i]);
- CreateScratchPixmapsForScreen(xf86GPUScreens[i]->pScreen);
+ PixmapScreenInit(xf86GPUScreens[i]->pScreen);
if (xf86GPUScreens[i]->pScreen->CreateScreenResources &&
!(*xf86GPUScreens[i]->pScreen->CreateScreenResources) (xf86GPUScreens[i]->pScreen)) {
diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h
index 1e75e6352..9979106a1 100644
--- a/hw/xfree86/common/xf86platformBus.h
+++ b/hw/xfree86/common/xf86platformBus.h
@@ -44,6 +44,8 @@ int xf86platformProbe(void);
int xf86platformProbeDev(DriverPtr drvp);
int xf86platformAddGPUDevices(DriverPtr drvp);
void xf86MergeOutputClassOptions(int entityIndex, void **options);
+void xf86PlatformScanPciDev(void);
+const char *xf86PlatformFindHotplugDriver(int dev_index);
extern int xf86_num_platform_devices;
extern struct xf86_platform_device *xf86_platform_devices;
@@ -56,7 +58,7 @@ extern Bool
xf86_get_platform_device_unowned(int index);
extern int
-xf86platformAddDevice(int index);
+xf86platformAddDevice(const char *driver_name, int index);
extern void
xf86platformRemoveDevice(int index);
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 9072932cb..d410e411a 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -249,7 +249,7 @@ typedef struct _DriverRec {
*/
/* Tolerate prior #include <linux/input.h> */
-#if defined(__linux__)
+#if defined(__linux__) || defined(__FreeBSD__)
#undef BUS_NONE
#undef BUS_PCI
#undef BUS_SBUS
diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
index b82dfc185..621ef5336 100644
--- a/hw/xfree86/ddc/ddc.c
+++ b/hw/xfree86/ddc/ddc.c
@@ -14,6 +14,8 @@
#include <xorg-config.h>
#endif
+#include "os/osdep.h"
+
#include "misc.h"
#include "xf86.h"
#include "xf86_OSproc.h"
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index 1eed293fe..b7da50de3 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -1833,6 +1833,7 @@ Some of them are:
xf86Depth -depth from the command line
xf86Weight -weight from the command line
xf86Gamma -{r,g,b,}gamma from the command line
+ xf86FlipPixels -flippixels from the command line
xf86ProbeOnly -probeonly from the command line
defaultColorVisualClass -cc from the command line
</literallayout>
@@ -1893,6 +1894,17 @@ functions:
</para></blockquote>
+ <blockquote><para>
+ <programlisting>
+ Bool xf86GetFlipPixels();
+ </programlisting>
+ <blockquote><para>
+ Returns <constant>TRUE</constant> if <option>-flippixels</option> is
+ present on the command line, and <constant>FALSE</constant> otherwise.
+ </para></blockquote>
+
+ </para></blockquote>
+
</sect2>
<sect2>
@@ -6004,6 +6016,19 @@ strongly encouraged to improve the consistency of driver behaviour.
<blockquote><para>
<programlisting>
+ void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn);
+ </programlisting>
+ <blockquote><para>
+ This functions sets the <structfield>blackPixel</structfield> and
+ <structfield>whitePixel</structfield> fields of the <structname>ScrnInfoRec</structname>
+ according to whether or not the <option>-flipPixels</option> command
+ line options is present.
+ </para>
+
+ </blockquote></para></blockquote>
+
+ <blockquote><para>
+ <programlisting>
const char *xf86GetVisualName(int visual);
</programlisting>
<blockquote><para>
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index d1b092bdb..ea2ac7d21 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -37,16 +37,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <xorg-config.h>
#endif
-#include "xf86.h"
-#include <sys/time.h>
-#include <unistd.h>
-#include <string.h>
+#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <sys/ioctl.h>
-#include <errno.h>
-
+#include <sys/time.h>
+#include <unistd.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+
+#include "xf86.h"
#include "xf86drm.h"
#include "misc.h"
#include "dixstruct.h"
@@ -66,6 +68,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dristruct.h"
#include "mi.h"
#include "mipointer.h"
+#include "xf86_os_support.h"
#include "xf86_OSproc.h"
#include "inputstr.h"
#include "xf86VGAarbiter.h"
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index d356db990..b74544cad 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -39,11 +39,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#include <string.h>
-
-#include "xf86.h"
-
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+
+#include "xf86.h"
#include "misc.h"
#include "dixstruct.h"
#include "extnsionst.h"
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 4f98639aa..c43ce95ca 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -38,6 +38,9 @@
#include <X11/Xproto.h>
#include <X11/extensions/dri2proto.h>
#include <X11/extensions/xfixeswire.h>
+
+#include "dix/dix_priv.h"
+
#include "dixstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 8d1b742ef..8be3810bf 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -36,7 +36,11 @@
#include "dix-config.h"
#endif
+#include <errno.h>
#include <time.h>
+
+#include "dix/dix_priv.h"
+
#include "list.h"
#include "xf86.h"
#include "driver.h"
@@ -483,7 +487,6 @@ ms_dri2_schedule_flip(ms_dri2_frame_event_ptr info)
modesettingPtr ms = modesettingPTR(scrn);
ms_dri2_buffer_private_ptr back_priv = info->back->driverPrivate;
struct ms_dri2_vblank_event *event;
- drmmode_crtc_private_ptr drmmode_crtc = info->crtc->driver_private;
event = calloc(1, sizeof(struct ms_dri2_vblank_event));
if (!event)
@@ -495,7 +498,7 @@ ms_dri2_schedule_flip(ms_dri2_frame_event_ptr info)
event->event_data = info->event_data;
if (ms_do_pageflip(screen, back_priv->pixmap, event,
- drmmode_crtc->vblank_pipe, FALSE,
+ info->crtc, FALSE,
ms_dri2_flip_handler,
ms_dri2_flip_abort,
"DRI2-flip")) {
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index fe3315a9c..f3400a1cd 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -36,8 +36,14 @@
#include "dix-config.h"
#endif
+#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
+#include <X11/extensions/randr.h>
+#include <X11/extensions/Xv.h>
+
+#include "dix/dix_priv.h"
+
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSproc.h"
@@ -46,7 +52,6 @@
#include "mipointer.h"
#include "mipointrst.h"
#include "micmap.h"
-#include <X11/extensions/randr.h>
#include "fb.h"
#include "edid.h"
#include "xf86i2c.h"
@@ -54,7 +59,6 @@
#include "miscstruct.h"
#include "dixstruct.h"
#include "xf86xv.h"
-#include <X11/extensions/Xv.h>
#include <xorg-config.h>
#ifdef XSERVER_PLATFORM_BUS
#include "xf86platformBus.h"
@@ -145,6 +149,7 @@ static const OptionInfoRec Options[] = {
{OPTION_VARIABLE_REFRESH, "VariableRefresh", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_USE_GAMMA_LUT, "UseGammaLUT", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_ASYNC_FLIP_SECONDARIES, "AsyncFlipSecondaries", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_TEARFREE, "TearFree", OPTV_BOOLEAN, {0}, FALSE},
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
@@ -515,76 +520,202 @@ GetRec(ScrnInfoPtr pScrn)
return TRUE;
}
-static void
-rotate_clip(PixmapPtr pixmap, BoxPtr rect, drmModeClip *clip, Rotation rotation)
+static int
+rotate_clip(PixmapPtr pixmap, xf86CrtcPtr crtc, BoxPtr rect, drmModeClip *clip,
+ Rotation rotation, int x, int y)
{
- int w = pixmap->drawable.width;
- int h = pixmap->drawable.height;
-
- if (rotation == RR_Rotate_90) {
- /* Rotate 90 degrees counter clockwise */
- clip->x1 = rect->y1;
- clip->x2 = rect->y2;
- clip->y1 = w - rect->x2;
- clip->y2 = w - rect->x1;
- } else if (rotation == RR_Rotate_180) {
- /* Rotate 180 degrees */
- clip->x1 = w - rect->x2;
- clip->x2 = w - rect->x1;
- clip->y1 = h - rect->y2;
- clip->y2 = h - rect->y1;
- } else if (rotation == RR_Rotate_270) {
- /* Rotate 90 degrees clockwise */
- clip->x1 = h - rect->y2;
- clip->x2 = h - rect->y1;
- clip->y1 = rect->x1;
- clip->y2 = rect->x2;
+ int w, h;
+ int x1, y1, x2, y2;
+
+ if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) {
+ /* width and height are swapped if rotated 90 or 270 degrees */
+ w = pixmap->drawable.height;
+ h = pixmap->drawable.width;
+ } else {
+ w = pixmap->drawable.width;
+ h = pixmap->drawable.height;
+ }
+
+ /* check if the given rect covers any area in FB of the crtc */
+ if (rect->x2 > crtc->x && rect->x1 < crtc->x + w &&
+ rect->y2 > crtc->y && rect->y1 < crtc->y + h) {
+ /* new coordinate of the partial rect on the crtc area
+ * + x/y offsets in the framebuffer */
+ x1 = max(rect->x1 - crtc->x, 0) + x;
+ y1 = max(rect->y1 - crtc->y, 0) + y;
+ x2 = min(rect->x2 - crtc->x, w) + x;
+ y2 = min(rect->y2 - crtc->y, h) + y;
+
+ /* coordinate transposing/inversion and offset adjustment */
+ if (rotation == RR_Rotate_90) {
+ clip->x1 = y1;
+ clip->y1 = w - x2;
+ clip->x2 = y2;
+ clip->y2 = w - x1;
+ } else if (rotation == RR_Rotate_180) {
+ clip->x1 = w - x2;
+ clip->y1 = h - y2;
+ clip->x2 = w - x1;
+ clip->y2 = h - y1;
+ } else if (rotation == RR_Rotate_270) {
+ clip->x1 = h - y2;
+ clip->y1 = x1;
+ clip->x2 = h - y1;;
+ clip->y2 = x2;
+ } else {
+ clip->x1 = x1;
+ clip->y1 = y1;
+ clip->x2 = x2;
+ clip->y2 = y2;
+ }
} else {
- clip->x1 = rect->x1;
- clip->x2 = rect->x2;
- clip->y1 = rect->y1;
- clip->y2 = rect->y2;
+ return -1;
}
+
+ return 0;
}
static int
-dispatch_dirty_region(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
- PixmapPtr pixmap, DamagePtr damage, int fb_id)
+dispatch_damages(ScrnInfoPtr scrn, xf86CrtcPtr crtc, RegionPtr dirty,
+ PixmapPtr pixmap, DamagePtr damage, int fb_id, int x, int y)
{
modesettingPtr ms = modesettingPTR(scrn);
- RegionPtr dirty = DamageRegion(damage);
unsigned num_cliprects = REGION_NUM_RECTS(dirty);
int ret = 0;
+ if (!ms->dirty_enabled)
+ return 0;
+
if (num_cliprects) {
drmModeClip *clip = xallocarray(num_cliprects, sizeof(drmModeClip));
BoxPtr rect = REGION_RECTS(dirty);
int i;
+ int c = 0;
if (!clip)
return -ENOMEM;
- /* Rotate and copy rects into clips */
- for (i = 0; i < num_cliprects; i++, rect++)
- rotate_clip(pixmap, rect, &clip[i], crtc->rotation);
+ /* Create clips for the given rects in case the rect covers any
+ * area in the FB.
+ */
+ for (i = 0; i < num_cliprects; i++, rect++) {
+ if (rotate_clip(pixmap, crtc, rect, &clip[c], crtc->rotation, x, y) < 0)
+ continue;
+
+ c++;
+ }
+
+ if (!c)
+ return 0;
/* TODO query connector property to see if this is needed */
- ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
+ ret = drmModeDirtyFB(ms->fd, fb_id, clip, c);
/* if we're swamping it with work, try one at a time */
if (ret == -EINVAL) {
- for (i = 0; i < num_cliprects; i++) {
+ for (i = 0; i < c; i++) {
if ((ret = drmModeDirtyFB(ms->fd, fb_id, &clip[i], 1)) < 0)
break;
}
}
+ if (ret == -EINVAL || ret == -ENOSYS) {
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Disabling kernel dirty updates, not required.\n");
+ ms->dirty_enabled = FALSE;
+ }
+
free(clip);
- DamageEmpty(damage);
}
return ret;
}
+static int
+dispatch_dirty_region(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
+ PixmapPtr pixmap, DamagePtr damage,
+ int fb_id, int x, int y)
+{
+ return dispatch_damages(scrn, crtc, DamageRegion(damage),
+ pixmap, damage, fb_id, x, y);
+}
+
+static void
+ms_tearfree_update_damages(ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ modesettingPtr ms = modesettingPTR(scrn);
+ RegionPtr dirty = DamageRegion(ms->damage);
+ int c, i;
+
+ if (RegionNil(dirty))
+ return;
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ RegionRec region;
+
+ /* Compute how much of the damage intersects with this CRTC */
+ RegionInit(&region, &crtc->bounds, 0);
+ RegionIntersect(&region, &region, dirty);
+
+ if (trf->buf[0].px) {
+ for (i = 0; i < ARRAY_SIZE(trf->buf); i++)
+ RegionUnion(&trf->buf[i].dmg, &trf->buf[i].dmg, &region);
+ } else {
+ /* Just notify the kernel of the damages if TearFree isn't used */
+ dispatch_damages(scrn, crtc, &region,
+ pScreen->GetScreenPixmap(pScreen),
+ NULL, ms->drmmode.fb_id, 0, 0);
+ }
+ }
+ DamageEmpty(ms->damage);
+}
+
+static void
+ms_tearfree_do_flips(ScreenPtr pScreen)
+{
+#ifdef GLAMOR_HAS_GBM
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ modesettingPtr ms = modesettingPTR(scrn);
+ int c;
+
+ if (!ms->drmmode.tearfree_enable)
+ return;
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ if (!ms_tearfree_is_active_on_crtc(crtc)) {
+ /* Notify any lingering DRI clients waiting for a flip to finish */
+ ms_tearfree_dri_abort_all(crtc);
+ continue;
+ }
+
+ /* Skip if the last flip is still pending, a DRI client is flipping, or
+ * there isn't any damage on the front buffer.
+ */
+ if (trf->flip_seq || ms->drmmode.dri2_flipping ||
+ ms->drmmode.present_flipping ||
+ RegionNil(&trf->buf[trf->back_idx ^ 1].dmg))
+ continue;
+
+ /* Flip. If it fails, notify the kernel of the front buffer damages */
+ if (ms_do_tearfree_flip(pScreen, crtc)) {
+ dispatch_damages(scrn, crtc, &trf->buf[trf->back_idx ^ 1].dmg,
+ trf->buf[trf->back_idx ^ 1].px, NULL,
+ trf->buf[trf->back_idx ^ 1].fb_id, 0, 0);
+ RegionEmpty(&trf->buf[trf->back_idx ^ 1].dmg);
+ }
+ }
+#endif
+}
+
static void
dispatch_dirty(ScreenPtr pScreen)
{
@@ -597,6 +728,8 @@ dispatch_dirty(ScreenPtr pScreen)
for (c = 0; c < xf86_config->num_crtc; c++) {
xf86CrtcPtr crtc = xf86_config->crtc[c];
+ PixmapPtr pmap;
+
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
if (!drmmode_crtc)
@@ -604,14 +737,16 @@ dispatch_dirty(ScreenPtr pScreen)
drmmode_crtc_get_fb_id(crtc, &fb_id, &x, &y);
- ret = dispatch_dirty_region(scrn, crtc, pixmap, ms->damage, fb_id);
+ if (crtc->rotatedPixmap)
+ pmap = crtc->rotatedPixmap;
+ else
+ pmap = pixmap;
+
+ ret = dispatch_dirty_region(scrn, crtc, pmap, ms->damage, fb_id, x, y);
if (ret == -EINVAL || ret == -ENOSYS) {
- ms->dirty_enabled = FALSE;
DamageUnregister(ms->damage);
DamageDestroy(ms->damage);
ms->damage = NULL;
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "Disabling kernel dirty updates, not required.\n");
return;
}
}
@@ -625,7 +760,7 @@ dispatch_dirty_pixmap(ScrnInfoPtr scrn, xf86CrtcPtr crtc, PixmapPtr ppix)
DamagePtr damage = ppriv->secondary_damage;
int fb_id = ppriv->fb_id;
- dispatch_dirty_region(scrn, crtc, ppix, damage, fb_id);
+ dispatch_dirty_region(scrn, crtc, ppix, damage, fb_id, 0, 0);
}
static void
@@ -742,10 +877,13 @@ msBlockHandler(ScreenPtr pScreen, void *timeout)
pScreen->BlockHandler = msBlockHandler;
if (pScreen->isGPU && !ms->drmmode.reverse_prime_offload_mode)
dispatch_secondary_dirty(pScreen);
+ else if (ms->drmmode.tearfree_enable)
+ ms_tearfree_update_damages(pScreen);
else if (ms->dirty_enabled)
dispatch_dirty(pScreen);
ms_dirty_update(pScreen, timeout);
+ ms_tearfree_do_flips(pScreen);
}
static void
@@ -1005,16 +1143,21 @@ msShouldDoubleShadow(ScrnInfoPtr pScrn, modesettingPtr ms)
{
Bool ret = FALSE, asked;
int from;
- drmVersionPtr v = drmGetVersion(ms->fd);
+ drmVersionPtr v;
if (!ms->drmmode.shadow_enable)
return FALSE;
- if (!strcmp(v->name, "mgag200") ||
- !strcmp(v->name, "ast")) /* XXX || rn50 */
- ret = TRUE;
+ if ((v = drmGetVersion(ms->fd))) {
+ if (!strcmp(v->name, "mgag200") ||
+ !strcmp(v->name, "ast")) /* XXX || rn50 */
+ ret = TRUE;
- drmFreeVersion(v);
+ drmFreeVersion(v);
+ }
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to query DRM version.\n");
asked = xf86GetOptValBool(ms->drmmode.Options, OPTION_DOUBLE_SHADOW, &ret);
@@ -1197,15 +1340,15 @@ PreInit(ScrnInfoPtr pScrn, int flags)
ms->drmmode.sw_cursor = TRUE;
}
- ms->cursor_width = 64;
- ms->cursor_height = 64;
+ ms->max_cursor_width = 64;
+ ms->max_cursor_height = 64;
ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
if (!ret) {
- ms->cursor_width = value;
+ ms->max_cursor_width = value;
}
ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_HEIGHT, &value);
if (!ret) {
- ms->cursor_height = value;
+ ms->max_cursor_height = value;
}
try_enable_glamor(pScrn);
@@ -1277,9 +1420,34 @@ PreInit(ScrnInfoPtr pScrn, int flags)
if (xf86ReturnOptValBool(ms->drmmode.Options, OPTION_ATOMIC, FALSE)) {
ret = drmSetClientCap(ms->fd, DRM_CLIENT_CAP_ATOMIC, 1);
ms->atomic_modeset = (ret == 0);
+ if (!ms->atomic_modeset)
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Atomic modesetting not supported\n");
} else {
ms->atomic_modeset = FALSE;
}
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Atomic modesetting %sabled\n", ms->atomic_modeset ? "en" : "dis");
+
+ /* TearFree requires glamor and, if PageFlip is enabled, universal planes */
+ if (xf86ReturnOptValBool(ms->drmmode.Options, OPTION_TEARFREE, TRUE)) {
+ if (pScrn->is_gpu) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "TearFree cannot synchronize PRIME; use 'PRIME Synchronization' instead\n");
+ } else if (ms->drmmode.glamor) {
+ /* Atomic modesetting implicitly enables universal planes */
+ if (!ms->drmmode.pageflip || ms->atomic_modeset ||
+ !drmSetClientCap(ms->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) {
+ ms->drmmode.tearfree_enable = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TearFree: enabled\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "TearFree requires either universal planes, or setting 'Option \"PageFlip\" \"off\"'\n");
+ }
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "TearFree requires Glamor acceleration\n");
+ }
+ }
ms->kms_has_modifiers = FALSE;
ret = drmGetCap(ms->fd, DRM_CAP_ADDFB2_MODIFIERS, &value);
@@ -1443,7 +1611,6 @@ msEnableSharedPixmapFlipping(RRCrtcPtr crtc, PixmapPtr front, PixmapPtr back)
ScreenPtr screen = crtc->pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
- EntityInfoPtr pEnt = ms->pEnt;
xf86CrtcPtr xf86Crtc = crtc->devPrivate;
if (!xf86Crtc)
@@ -1458,9 +1625,9 @@ msEnableSharedPixmapFlipping(RRCrtcPtr crtc, PixmapPtr front, PixmapPtr back)
return FALSE;
#ifdef XSERVER_PLATFORM_BUS
- if (pEnt->location.type == BUS_PLATFORM) {
- char *syspath =
- xf86_platform_device_odev_attributes(pEnt->location.id.plat)->
+ if (ms->pEnt->location.type == BUS_PLATFORM) {
+ const char *syspath =
+ xf86_platform_device_odev_attributes(ms->pEnt->location.id.plat)->
syspath;
/* Not supported for devices using USB transport due to misbehaved
@@ -1628,13 +1795,13 @@ CreateScreenResources(ScreenPtr pScreen)
err = drmModeDirtyFB(ms->fd, ms->drmmode.fb_id, NULL, 0);
- if (err != -EINVAL && err != -ENOSYS) {
+ if ((err != -EINVAL && err != -ENOSYS) || ms->drmmode.tearfree_enable) {
ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
pScreen, rootPixmap);
if (ms->damage) {
DamageRegister(&rootPixmap->drawable, ms->damage);
- ms->dirty_enabled = TRUE;
+ ms->dirty_enabled = err != -EINVAL && err != -ENOSYS;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
}
else {
@@ -1915,7 +2082,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
/* Need to extend HWcursor support to handle mask interleave */
if (!ms->drmmode.sw_cursor)
- xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
+ xf86_cursors_init(pScreen, ms->max_cursor_width, ms->max_cursor_height,
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
HARDWARE_CURSOR_UPDATE_UNHIDDEN |
HARDWARE_CURSOR_ARGB);
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 71aa8730e..74630cac4 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -61,6 +61,7 @@ typedef enum {
OPTION_VARIABLE_REFRESH,
OPTION_USE_GAMMA_LUT,
OPTION_ASYNC_FLIP_SECONDARIES,
+ OPTION_TEARFREE,
} modesettingOpts;
typedef struct
@@ -86,10 +87,13 @@ struct ms_drm_queue {
struct xorg_list list;
xf86CrtcPtr crtc;
uint32_t seq;
+ uint64_t msc;
void *data;
ScrnInfoPtr scrn;
ms_drm_handler_proc handler;
ms_drm_abort_proc abort;
+ Bool kernel_queued;
+ Bool aborted;
};
typedef struct _modesettingRec {
@@ -125,7 +129,8 @@ typedef struct _modesettingRec {
DamagePtr damage;
Bool dirty_enabled;
- uint32_t cursor_width, cursor_height;
+ uint32_t min_cursor_width, min_cursor_height;
+ uint32_t max_cursor_width, max_cursor_height;
Bool has_queue_sequence;
Bool tried_queue_sequence;
@@ -202,6 +207,8 @@ void ms_drm_abort(ScrnInfoPtr scrn,
void *match_data);
void ms_drm_abort_seq(ScrnInfoPtr scrn, uint32_t seq);
+Bool ms_drm_queue_is_empty(void);
+
Bool xf86_crtc_on(xf86CrtcPtr crtc);
xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw);
@@ -232,14 +239,26 @@ typedef void (*ms_pageflip_abort_proc)(modesettingPtr ms, void *data);
Bool ms_do_pageflip(ScreenPtr screen,
PixmapPtr new_front,
void *event,
- int ref_crtc_vblank_pipe,
+ xf86CrtcPtr ref_crtc,
Bool async,
ms_pageflip_handler_proc pageflip_handler,
ms_pageflip_abort_proc pageflip_abort,
const char *log_prefix);
+Bool
+ms_tearfree_dri_abort(xf86CrtcPtr crtc,
+ Bool (*match)(void *data, void *match_data),
+ void *match_data);
+
+void
+ms_tearfree_dri_abort_all(xf86CrtcPtr crtc);
+
+Bool ms_do_tearfree_flip(ScreenPtr screen, xf86CrtcPtr crtc);
+
#endif
int ms_flush_drm_events(ScreenPtr screen);
+void ms_drain_drm_events(ScreenPtr screen);
Bool ms_window_has_variable_refresh(modesettingPtr ms, WindowPtr win);
void ms_present_set_screen_vrr(ScrnInfoPtr scrn, Bool vrr_enabled);
+Bool ms_tearfree_is_active_on_crtc(xf86CrtcPtr crtc);
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 65e8e6335..5c8b47b53 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -632,6 +632,7 @@ drmmode_crtc_get_fb_id(xf86CrtcPtr crtc, uint32_t *fb_id, int *x, int *y)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
int ret;
*fb_id = 0;
@@ -646,6 +647,10 @@ drmmode_crtc_get_fb_id(xf86CrtcPtr crtc, uint32_t *fb_id, int *x, int *y)
*x = drmmode_crtc->prime_pixmap_x;
*y = 0;
}
+ else if (trf->buf[trf->back_idx ^ 1].px) {
+ *fb_id = trf->buf[trf->back_idx ^ 1].fb_id;
+ *x = *y = 0;
+ }
else if (drmmode_crtc->rotate_fb_id) {
*fb_id = drmmode_crtc->rotate_fb_id;
*x = *y = 0;
@@ -922,6 +927,10 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool test_only)
drmmode_ConvertToKMode(crtc->scrn, &kmode, &crtc->mode);
ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
fb_id, x, y, output_ids, output_count, &kmode);
+ if (!ret && !ms->atomic_modeset) {
+ drmmode_crtc->src_x = x;
+ drmmode_crtc->src_y = y;
+ }
drmmode_set_ctm(crtc, ctm);
@@ -930,7 +939,8 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool test_only)
}
int
-drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, uint32_t flags, void *data)
+drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, int x, int y,
+ uint32_t flags, void *data)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
@@ -942,7 +952,7 @@ drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, uint32_t flags, void *data)
if (!req)
return 1;
- ret = plane_add_props(req, crtc, fb_id, crtc->x, crtc->y);
+ ret = plane_add_props(req, crtc, fb_id, x, y);
flags |= DRM_MODE_ATOMIC_NONBLOCK;
if (ret == 0)
ret = drmModeAtomicCommit(ms->fd, req, flags, data);
@@ -950,6 +960,26 @@ drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, uint32_t flags, void *data)
return ret;
}
+ /* The frame buffer source coordinates may change when switching between the
+ * primary frame buffer and a per-CRTC frame buffer. Set the correct source
+ * coordinates if they differ for this flip.
+ */
+ if (drmmode_crtc->src_x != x || drmmode_crtc->src_y != y) {
+ ret = drmModeSetPlane(ms->fd, drmmode_crtc->plane_id,
+ drmmode_crtc->mode_crtc->crtc_id, fb_id, 0,
+ 0, 0, crtc->mode.HDisplay, crtc->mode.VDisplay,
+ x << 16, y << 16, crtc->mode.HDisplay << 16,
+ crtc->mode.VDisplay << 16);
+ if (ret) {
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+ "error changing fb src coordinates for flip: %d\n", ret);
+ return ret;
+ }
+
+ drmmode_crtc->src_x = x;
+ drmmode_crtc->src_y = y;
+ }
+
return drmModePageFlip(ms->fd, drmmode_crtc->mode_crtc->crtc_id,
fb_id, flags, data);
}
@@ -1548,6 +1578,110 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
#endif
}
+void
+drmmode_copy_damage(xf86CrtcPtr crtc, PixmapPtr dst, RegionPtr dmg, Bool empty)
+{
+#ifdef GLAMOR_HAS_GBM
+ ScreenPtr pScreen = xf86ScrnToScreen(crtc->scrn);
+ DrawableRec *src;
+
+ /* Copy the screen's pixmap into the destination pixmap */
+ if (crtc->rotatedPixmap) {
+ src = &crtc->rotatedPixmap->drawable;
+ xf86RotateCrtcRedisplay(crtc, dst, src, dmg, FALSE);
+ } else {
+ src = &pScreen->GetScreenPixmap(pScreen)->drawable;
+ PixmapDirtyCopyArea(dst, src, 0, 0, -crtc->x, -crtc->y, dmg);
+ }
+
+ /* Reset the damages if requested */
+ if (empty)
+ RegionEmpty(dmg);
+
+ /* Wait until the GC operations finish */
+ modesettingPTR(crtc->scrn)->glamor.finish(pScreen);
+#endif
+}
+
+static void
+drmmode_shadow_fb_destroy(xf86CrtcPtr crtc, PixmapPtr pixmap,
+ void *data, drmmode_bo *bo, uint32_t *fb_id);
+static void
+drmmode_destroy_tearfree_shadow(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ int i;
+
+ if (trf->flip_seq)
+ ms_drm_abort_seq(crtc->scrn, trf->flip_seq);
+
+ for (i = 0; i < ARRAY_SIZE(trf->buf); i++) {
+ if (trf->buf[i].px) {
+ drmmode_shadow_fb_destroy(crtc, trf->buf[i].px, (void *)(long)1,
+ &trf->buf[i].bo, &trf->buf[i].fb_id);
+ trf->buf[i].px = NULL;
+ RegionUninit(&trf->buf[i].dmg);
+ }
+ }
+}
+
+static PixmapPtr
+drmmode_shadow_fb_create(xf86CrtcPtr crtc, void *data, int width, int height,
+ drmmode_bo *bo, uint32_t *fb_id);
+static Bool
+drmmode_create_tearfree_shadow(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ uint32_t w = crtc->mode.HDisplay, h = crtc->mode.VDisplay;
+ int i;
+
+ if (!drmmode->tearfree_enable)
+ return TRUE;
+
+ /* Destroy the old mode's buffers and make new ones */
+ drmmode_destroy_tearfree_shadow(crtc);
+ for (i = 0; i < ARRAY_SIZE(trf->buf); i++) {
+ trf->buf[i].px = drmmode_shadow_fb_create(crtc, NULL, w, h,
+ &trf->buf[i].bo,
+ &trf->buf[i].fb_id);
+ if (!trf->buf[i].px) {
+ drmmode_destroy_tearfree_shadow(crtc);
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
+ "shadow creation failed for TearFree buf%d\n", i);
+ return FALSE;
+ }
+ RegionInit(&trf->buf[i].dmg, &crtc->bounds, 0);
+ }
+
+ /* Initialize the front buffer with the current scanout */
+ drmmode_copy_damage(crtc, trf->buf[trf->back_idx ^ 1].px,
+ &trf->buf[trf->back_idx ^ 1].dmg, TRUE);
+ return TRUE;
+}
+
+static void drmmmode_prepare_modeset(ScrnInfoPtr scrn)
+{
+ ScreenPtr pScreen = scrn->pScreen;
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ if (ms->drmmode.pending_modeset)
+ return;
+
+ /*
+ * Force present to unflip everything before we might
+ * try lighting up new displays. This makes sure fancy
+ * modifiers can't cause the modeset to fail.
+ */
+ ms->drmmode.pending_modeset = TRUE;
+ present_check_flips(pScreen->root);
+ ms->drmmode.pending_modeset = FALSE;
+
+ ms_drain_drm_events(pScreen);
+}
+
static Bool
drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
Rotation rotation, int x, int y)
@@ -1563,6 +1697,9 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
Bool can_test;
int i;
+ if (mode)
+ drmmmode_prepare_modeset(crtc->scrn);
+
saved_mode = crtc->mode;
saved_x = crtc->x;
saved_y = crtc->y;
@@ -1581,6 +1718,10 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
crtc->gamma_blue, crtc->gamma_size);
+ ret = drmmode_create_tearfree_shadow(crtc);
+ if (!ret)
+ goto done;
+
can_test = drmmode_crtc_can_test_mode(crtc);
if (drmmode_crtc_set_mode(crtc, can_test)) {
xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
@@ -1626,6 +1767,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
crtc->y = saved_y;
crtc->rotation = saved_rotation;
crtc->mode = saved_mode;
+ drmmode_create_tearfree_shadow(crtc);
} else
crtc->active = TRUE;
@@ -1648,12 +1790,11 @@ drmmode_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
}
static Bool
-drmmode_set_cursor(xf86CrtcPtr crtc)
+drmmode_set_cursor(xf86CrtcPtr crtc, int width, int height)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
uint32_t handle = drmmode_crtc->cursor_bo->handle;
- modesettingPtr ms = modesettingPTR(crtc->scrn);
CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen);
int ret = -EINVAL;
@@ -1661,14 +1802,14 @@ drmmode_set_cursor(xf86CrtcPtr crtc)
return TRUE;
ret = drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
- handle, ms->cursor_width, ms->cursor_height,
+ handle, width, height,
cursor->bits->xhot, cursor->bits->yhot);
/* -EINVAL can mean that an old kernel supports drmModeSetCursor but
* not drmModeSetCursor2, though it can mean other things too. */
if (ret == -EINVAL)
ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
- handle, ms->cursor_width, ms->cursor_height);
+ handle, width, height);
/* -ENXIO normally means that the current drm driver supports neither
* cursor_set nor cursor_set2. Disable hardware cursor support for
@@ -1684,6 +1825,10 @@ drmmode_set_cursor(xf86CrtcPtr crtc)
if (ret)
/* fallback to swcursor */
return FALSE;
+
+ drmmode_crtc->cursor_width = width;
+ drmmode_crtc->cursor_height = height;
+
return TRUE;
}
@@ -1700,31 +1845,55 @@ static Bool
drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
+ CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- int i;
+ int width, height, x, y, i;
uint32_t *ptr;
/* cursor should be mapped already */
ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
- for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
- ptr[i] = image[i]; // cpu_to_le32(image[i]);
+ /* FIXME deal with rotation */
+ if (crtc->rotation == RR_Rotate_0) {
+ for (width = ms->min_cursor_width; width < cursor->bits->width; )
+ width *= 2;
+ for (height = ms->min_cursor_height; height < cursor->bits->height; )
+ height *= 2;
+
+ /* assume only square works for now */
+ width = height = max(width, height);
+
+ /* if the max limits aren't square+POT we may have gone a bit over */
+ width = min(width, ms->max_cursor_width);
+ height = min(height, ms->max_cursor_height);
+ } else {
+ width = ms->max_cursor_width;
+ height = ms->max_cursor_height;
+ }
+
+ i = 0;
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ ptr[i++] = image[y * ms->max_cursor_width + x]; // cpu_to_le32(image[i]);
+ }
+ /* clear the remainder for good measure */
+ for (; i < ms->max_cursor_width * ms->max_cursor_height; i++)
+ ptr[i++] = 0;
if (drmmode_crtc->cursor_up)
- return drmmode_set_cursor(crtc);
+ return drmmode_set_cursor(crtc, width, height);
return TRUE;
}
static void
drmmode_hide_cursor(xf86CrtcPtr crtc)
{
- modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
drmmode_crtc->cursor_up = FALSE;
drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
- ms->cursor_width, ms->cursor_height);
+ drmmode_crtc->cursor_width, drmmode_crtc->cursor_height);
}
static Bool
@@ -1732,7 +1901,7 @@ drmmode_show_cursor(xf86CrtcPtr crtc)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_crtc->cursor_up = TRUE;
- return drmmode_set_cursor(crtc);
+ return drmmode_set_cursor(crtc, drmmode_crtc->cursor_width, drmmode_crtc->cursor_height);
}
static void
@@ -1753,6 +1922,7 @@ drmmode_set_gamma_lut(drmmode_crtc_private_ptr drmmode_crtc,
lut[i].red = red[i];
lut[i].green = green[i];
lut[i].blue = blue[i];
+ lut[i].reserved = 0;
}
if (drmModeCreatePropertyBlob(drmmode->fd, lut, sizeof(lut), &blob_id))
@@ -1931,33 +2101,42 @@ drmmode_clear_pixmap(PixmapPtr pixmap)
}
static void *
-drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
+drmmode_shadow_fb_allocate(xf86CrtcPtr crtc, int width, int height,
+ drmmode_bo *bo, uint32_t *fb_id)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
int ret;
- if (!drmmode_create_bo(drmmode, &drmmode_crtc->rotate_bo,
- width, height, drmmode->kbpp)) {
+ if (!drmmode_create_bo(drmmode, bo, width, height, drmmode->kbpp)) {
xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
"Couldn't allocate shadow memory for rotated CRTC\n");
return NULL;
}
- ret = drmmode_bo_import(drmmode, &drmmode_crtc->rotate_bo,
- &drmmode_crtc->rotate_fb_id);
+ ret = drmmode_bo_import(drmmode, bo, fb_id);
if (ret) {
ErrorF("failed to add rotate fb\n");
- drmmode_bo_destroy(drmmode, &drmmode_crtc->rotate_bo);
+ drmmode_bo_destroy(drmmode, bo);
return NULL;
}
#ifdef GLAMOR_HAS_GBM
if (drmmode->gbm)
- return drmmode_crtc->rotate_bo.gbm;
+ return bo->gbm;
#endif
- return drmmode_crtc->rotate_bo.dumb;
+ return bo->dumb;
+}
+
+static void *
+drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ return drmmode_shadow_fb_allocate(crtc, width, height,
+ &drmmode_crtc->rotate_bo,
+ &drmmode_crtc->rotate_fb_id);
}
static PixmapPtr
@@ -1983,71 +2162,92 @@ static Bool
drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo);
static PixmapPtr
-drmmode_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
+drmmode_shadow_fb_create(xf86CrtcPtr crtc, void *data, int width, int height,
+ drmmode_bo *bo, uint32_t *fb_id)
{
ScrnInfoPtr scrn = crtc->scrn;
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- uint32_t rotate_pitch;
- PixmapPtr rotate_pixmap;
+ uint32_t pitch;
+ PixmapPtr pixmap;
void *pPixData = NULL;
if (!data) {
- data = drmmode_shadow_allocate(crtc, width, height);
+ data = drmmode_shadow_fb_allocate(crtc, width, height, bo, fb_id);
if (!data) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "Couldn't allocate shadow pixmap for rotated CRTC\n");
+ "Couldn't allocate shadow pixmap for CRTC\n");
return NULL;
}
}
- if (!drmmode_bo_has_bo(&drmmode_crtc->rotate_bo)) {
+ if (!drmmode_bo_has_bo(bo)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "Couldn't allocate shadow pixmap for rotated CRTC\n");
+ "Couldn't allocate shadow pixmap for CRTC\n");
return NULL;
}
- pPixData = drmmode_bo_map(drmmode, &drmmode_crtc->rotate_bo);
- rotate_pitch = drmmode_bo_get_pitch(&drmmode_crtc->rotate_bo);
+ pPixData = drmmode_bo_map(drmmode, bo);
+ pitch = drmmode_bo_get_pitch(bo);
- rotate_pixmap = drmmode_create_pixmap_header(scrn->pScreen,
- width, height,
- scrn->depth,
- drmmode->kbpp,
- rotate_pitch,
- pPixData);
+ pixmap = drmmode_create_pixmap_header(scrn->pScreen,
+ width, height,
+ scrn->depth,
+ drmmode->kbpp,
+ pitch,
+ pPixData);
- if (rotate_pixmap == NULL) {
+ if (pixmap == NULL) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "Couldn't allocate shadow pixmap for rotated CRTC\n");
+ "Couldn't allocate shadow pixmap for CRTC\n");
return NULL;
}
- drmmode_set_pixmap_bo(drmmode, rotate_pixmap, &drmmode_crtc->rotate_bo);
+ drmmode_set_pixmap_bo(drmmode, pixmap, bo);
+
+ return pixmap;
+}
+
+static PixmapPtr
+drmmode_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- return rotate_pixmap;
+ return drmmode_shadow_fb_create(crtc, data, width, height,
+ &drmmode_crtc->rotate_bo,
+ &drmmode_crtc->rotate_fb_id);
}
static void
-drmmode_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
+drmmode_shadow_fb_destroy(xf86CrtcPtr crtc, PixmapPtr pixmap,
+ void *data, drmmode_bo *bo, uint32_t *fb_id)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- if (rotate_pixmap) {
- rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap);
+ if (pixmap) {
+ pixmap->drawable.pScreen->DestroyPixmap(pixmap);
}
if (data) {
- drmModeRmFB(drmmode->fd, drmmode_crtc->rotate_fb_id);
- drmmode_crtc->rotate_fb_id = 0;
+ drmModeRmFB(drmmode->fd, *fb_id);
+ *fb_id = 0;
- drmmode_bo_destroy(drmmode, &drmmode_crtc->rotate_bo);
- memset(&drmmode_crtc->rotate_bo, 0, sizeof drmmode_crtc->rotate_bo);
+ drmmode_bo_destroy(drmmode, bo);
+ memset(bo, 0, sizeof(*bo));
}
}
static void
+drmmode_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr pixmap, void *data)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ drmmode_shadow_fb_destroy(crtc, pixmap, data, &drmmode_crtc->rotate_bo,
+ &drmmode_crtc->rotate_fb_id);
+}
+
+static void
drmmode_crtc_destroy(xf86CrtcPtr crtc)
{
drmmode_mode_ptr iterator, next;
@@ -2380,6 +2580,8 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
drmmode_crtc->drmmode = drmmode;
drmmode_crtc->vblank_pipe = drmmode_crtc_vblank_pipe(num);
xorg_list_init(&drmmode_crtc->mode_list);
+ xorg_list_init(&drmmode_crtc->tearfree.dri_flip_list);
+ drmmode_crtc->next_msc = UINT64_MAX;
props = drmModeObjectGetProperties(drmmode->fd, mode_res->crtcs[num],
DRM_MODE_OBJECT_CRTC);
@@ -2641,7 +2843,7 @@ static DisplayModePtr
drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
{
xf86MonPtr mon = output->MonInfo;
- DisplayModePtr i, m, preferred = NULL;
+ DisplayModePtr i, j, m, preferred = NULL;
int max_x = 0, max_y = 0;
float max_vrefresh = 0.0;
@@ -2673,6 +2875,17 @@ drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
i->VDisplay >= preferred->VDisplay &&
xf86ModeVRefresh(i) >= xf86ModeVRefresh(preferred))
i->status = MODE_VSYNC;
+ if (preferred && xf86ModeVRefresh(i) > 0.0) {
+ i->Clock = i->Clock * xf86ModeVRefresh(preferred) / xf86ModeVRefresh(i);
+ i->VRefresh = xf86ModeVRefresh(preferred);
+ }
+ for (j = m; j != i; j = j->next) {
+ if (!strcmp(i->name, j->name) &&
+ xf86ModeVRefresh(i) * (1 + SYNC_TOLERANCE) >= xf86ModeVRefresh(j) &&
+ xf86ModeVRefresh(i) * (1 - SYNC_TOLERANCE) <= xf86ModeVRefresh(j)) {
+ i->status = MODE_DUPLICATE;
+ }
+ }
}
xf86PruneInvalidModes(output->scrn, &m, FALSE);
@@ -3755,6 +3968,8 @@ drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw,
Bool success = TRUE;
int c;
+ drmmmode_prepare_modeset(pScrn);
+
for (c = 0; c < config->num_crtc; c++) {
xf86CrtcPtr crtc = config->crtc[c];
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
@@ -3917,13 +4132,13 @@ drmmode_crtc_upgrade_lut(xf86CrtcPtr crtc, int num)
crtc->gamma_blue = gamma + size * 2;
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG,
- "Gamma ramp set to %ld entries on CRTC %d\n",
- size, num);
+ "Gamma ramp set to %lld entries on CRTC %d\n",
+ (long long)size, num);
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to allocate memory for %ld gamma ramp entries "
+ "Failed to allocate memory for %lld gamma ramp entries "
"on CRTC %d.\n",
- size, num);
+ (long long)size, num);
return FALSE;
}
}
@@ -4154,6 +4369,52 @@ drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
#endif
}
+static void drmmode_probe_cursor_size(xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ uint32_t handle = drmmode_crtc->cursor_bo->handle;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ int width, height, size;
+
+ /* probe square min first */
+ for (size = 1; size <= ms->max_cursor_width &&
+ size <= ms->max_cursor_height; size *= 2) {
+ int ret;
+
+ ret = drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ handle, size, size, 0, 0);
+ if (ret == 0)
+ break;
+ }
+
+ /* check if smaller width works with non-square */
+ for (width = 1; width <= size; width *= 2) {
+ int ret;
+
+ ret = drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ handle, width, size, 0, 0);
+ if (ret == 0) {
+ ms->min_cursor_width = width;
+ break;
+ }
+ }
+
+ /* check if smaller height works with non-square */
+ for (height = 1; height <= size; height *= 2) {
+ int ret;
+
+ ret = drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ handle, size, height, 0, 0);
+ if (ret == 0) {
+ ms->min_cursor_height = height;
+ break;
+ }
+ }
+
+ drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0, 0, 0, 0, 0);
+}
+
/* create front and cursor BOs */
Bool
drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
@@ -4173,8 +4434,8 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
return FALSE;
pScrn->displayWidth = drmmode_bo_get_pitch(&drmmode->front_bo) / cpp;
- width = ms->cursor_width;
- height = ms->cursor_height;
+ width = ms->max_cursor_width;
+ height = ms->max_cursor_height;
bpp = 32;
for (i = 0; i < xf86_config->num_crtc; i++) {
xf86CrtcPtr crtc = xf86_config->crtc[i];
@@ -4183,6 +4444,14 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
drmmode_crtc->cursor_bo =
dumb_bo_create(drmmode->fd, width, height, bpp);
}
+
+ drmmode_probe_cursor_size(xf86_config->crtc[0]);
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG,
+ "Supported cursor sizes %dx%d -> %dx%d\n",
+ ms->min_cursor_width, ms->min_cursor_height,
+ ms->max_cursor_width, ms->max_cursor_height);
+
return TRUE;
}
@@ -4242,6 +4511,7 @@ drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo);
+ drmmode_destroy_tearfree_shadow(crtc);
}
}
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 2a9a91529..a82ae2609 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -135,9 +135,12 @@ typedef struct {
Bool async_flip_secondaries;
Bool dri2_enable;
Bool present_enable;
+ Bool tearfree_enable;
uint32_t vrr_prop_id;
Bool use_ctm;
+
+ Bool pending_modeset;
} drmmode_rec, *drmmode_ptr;
typedef struct {
@@ -167,6 +170,20 @@ typedef struct {
} drmmode_format_rec, *drmmode_format_ptr;
typedef struct {
+ drmmode_bo bo;
+ uint32_t fb_id;
+ PixmapPtr px;
+ RegionRec dmg;
+} drmmode_shadow_fb_rec, *drmmode_shadow_fb_ptr;
+
+typedef struct {
+ drmmode_shadow_fb_rec buf[2];
+ struct xorg_list dri_flip_list;
+ uint32_t back_idx;
+ uint32_t flip_seq;
+} drmmode_tearfree_rec, *drmmode_tearfree_ptr;
+
+typedef struct {
drmmode_ptr drmmode;
drmModeCrtcPtr mode_crtc;
uint32_t vblank_pipe;
@@ -184,11 +201,14 @@ typedef struct {
drmmode_bo rotate_bo;
unsigned rotate_fb_id;
+ drmmode_tearfree_rec tearfree;
PixmapPtr prime_pixmap;
PixmapPtr prime_pixmap_back;
unsigned prime_pixmap_x;
+ int src_x, src_y;
+
/**
* @{ MSC (vblank count) handling for the PRESENT extension.
*
@@ -200,6 +220,10 @@ typedef struct {
uint64_t msc_high;
/** @} */
+ uint64_t next_msc;
+
+ int cursor_width, cursor_height;
+
Bool need_modeset;
struct xorg_list mode_list;
@@ -308,8 +332,11 @@ void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
int *depth, int *bpp);
void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+void drmmode_copy_damage(xf86CrtcPtr crtc, PixmapPtr dst, RegionPtr damage,
+ Bool empty);
-int drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, uint32_t flags, void *data);
+int drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, int x, int y,
+ uint32_t flags, void *data);
Bool drmmode_crtc_get_fb_id(xf86CrtcPtr crtc, uint32_t *fb_id, int *x, int *y);
diff --git a/hw/xfree86/drivers/modesetting/meson.build b/hw/xfree86/drivers/modesetting/meson.build
index 02852a716..acb37b48d 100644
--- a/hw/xfree86/drivers/modesetting/meson.build
+++ b/hw/xfree86/drivers/modesetting/meson.build
@@ -27,7 +27,7 @@ shared_module(
)
# Test that we don't have any unresolved symbols from our module to Xorg.
-xorg_build_root = join_paths(meson.build_root(), 'hw', 'xfree86')
+xorg_build_root = join_paths(meson.project_build_root(), 'hw', 'xfree86')
symbol_test_args = []
symbol_test_args += join_paths(xorg_build_root, 'libxorgserver.so')
symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libshadow.so')
diff --git a/hw/xfree86/drivers/modesetting/modesetting.man b/hw/xfree86/drivers/modesetting/modesetting.man
index 71790011e..4a8af97c8 100644
--- a/hw/xfree86/drivers/modesetting/modesetting.man
+++ b/hw/xfree86/drivers/modesetting/modesetting.man
@@ -109,6 +109,21 @@ When enabled, this option allows the driver to use gamma ramps with more
entries, if supported by the kernel. By default, GAMMA_LUT will be used for
kms drivers which are known to be safe for use of GAMMA_LUT.
.TP
+.BI "Option \*qTearFree\*q \*q" boolean \*q
+Enable tearing prevention using the hardware page flipping mechanism.
+It allocates two extra scanout buffers for each CRTC and utilizes damage
+tracking to minimize buffer copying and skip unnecessary flips when the
+screen's contents have not changed. It works on transformed screens too, such
+as rotated and scaled CRTCs. When PageFlip is enabled, fullscreen DRI
+applications will still have the discretion to not use tearing prevention.
+.br
+The default is
+.B on.
+.TP
+.BI "Option \*qAtomic\*q \*q" boolean \*q
+Enable atomic modesetting when supported. The default is
+.B off.
+.TP
.SH "SEE ALSO"
@xservername@(@appmansuffix@), @xconfigfile@(@filemansuffix@), Xserver(@appmansuffix@),
X(@miscmansuffix@)
diff --git a/hw/xfree86/drivers/modesetting/pageflip.c b/hw/xfree86/drivers/modesetting/pageflip.c
index 23ee95f9a..f0b8d5919 100644
--- a/hw/xfree86/drivers/modesetting/pageflip.c
+++ b/hw/xfree86/drivers/modesetting/pageflip.c
@@ -24,6 +24,8 @@
#include "dix-config.h"
#endif
+#include <errno.h>
+
#include <xserver_poll.h>
#include <xf86drm.h>
@@ -35,8 +37,8 @@
* Returns a negative value on error, 0 if there was nothing to process,
* or 1 if we handled any events.
*/
-int
-ms_flush_drm_events(ScreenPtr screen)
+static int
+ms_flush_drm_events_timeout(ScreenPtr screen, int timeout)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
@@ -45,7 +47,7 @@ ms_flush_drm_events(ScreenPtr screen)
int r;
do {
- r = xserver_poll(&p, 1, 0);
+ r = xserver_poll(&p, 1, timeout);
} while (r == -1 && (errno == EINTR || errno == EAGAIN));
/* If there was an error, r will be < 0. Return that. If there was
@@ -63,6 +65,19 @@ ms_flush_drm_events(ScreenPtr screen)
return 1;
}
+int
+ms_flush_drm_events(ScreenPtr screen)
+{
+ return ms_flush_drm_events_timeout(screen, 0);
+}
+
+void
+ms_drain_drm_events(ScreenPtr screen)
+{
+ while (!ms_drm_queue_is_empty())
+ ms_flush_drm_events_timeout(screen, -1);
+}
+
#ifdef GLAMOR_HAS_GBM
/*
@@ -93,6 +108,8 @@ struct ms_crtc_pageflip {
Bool on_reference_crtc;
/* reference to the ms_flipdata */
struct ms_flipdata *flipdata;
+ struct xorg_list node;
+ uint32_t tearfree_seq;
};
/**
@@ -136,7 +153,8 @@ ms_pageflip_handler(uint64_t msc, uint64_t ust, void *data)
flipdata->fe_usec,
flipdata->event);
- drmModeRmFB(ms->fd, flipdata->old_fb_id);
+ if (flipdata->old_fb_id)
+ drmModeRmFB(ms->fd, flipdata->old_fb_id);
}
ms_pageflip_free(flip);
}
@@ -160,11 +178,32 @@ ms_pageflip_abort(void *data)
}
static Bool
-do_queue_flip_on_crtc(modesettingPtr ms, xf86CrtcPtr crtc,
- uint32_t flags, uint32_t seq)
+do_queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc, uint32_t flags,
+ uint32_t seq, uint32_t fb_id, int x, int y)
{
- return drmmode_crtc_flip(crtc, ms->drmmode.fb_id, flags,
- (void *) (uintptr_t) seq);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ while (drmmode_crtc_flip(crtc, fb_id, x, y, flags, (void *)(long)seq)) {
+ /* We may have failed because the event queue was full. Flush it
+ * and retry. If there was nothing to flush, then we failed for
+ * some other reason and should just return an error.
+ */
+ if (ms_flush_drm_events(screen) <= 0) {
+ /* The failure could be caused by a pending TearFree flip, in which
+ * case we should wait until there's a new event and try again.
+ */
+ if (!trf->flip_seq || ms_flush_drm_events_timeout(screen, -1) < 0) {
+ ms_drm_abort_seq(crtc->scrn, seq);
+ return TRUE;
+ }
+ }
+
+ /* We flushed some events, so try again. */
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING, "flip queue retry\n");
+ }
+
+ return FALSE;
}
enum queue_flip_status {
@@ -177,11 +216,10 @@ enum queue_flip_status {
static int
queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
struct ms_flipdata *flipdata,
- int ref_crtc_vblank_pipe, uint32_t flags)
+ xf86CrtcPtr ref_crtc, uint32_t flags)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
- drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
struct ms_crtc_pageflip *flip;
uint32_t seq;
@@ -193,7 +231,7 @@ queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
/* Only the reference crtc will finally deliver its page flip
* completion event. All other crtc's events will be discarded.
*/
- flip->on_reference_crtc = (drmmode_crtc->vblank_pipe == ref_crtc_vblank_pipe);
+ flip->on_reference_crtc = crtc == ref_crtc;
flip->flipdata = flipdata;
seq = ms_drm_queue_alloc(crtc, flip, ms_pageflip_handler, ms_pageflip_abort);
@@ -205,20 +243,9 @@ queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
/* take a reference on flipdata for use in flip */
flipdata->flip_count++;
- while (do_queue_flip_on_crtc(ms, crtc, flags, seq)) {
- /* We may have failed because the event queue was full. Flush it
- * and retry. If there was nothing to flush, then we failed for
- * some other reason and should just return an error.
- */
- if (ms_flush_drm_events(screen) <= 0) {
- /* Aborting will also decrement flip_count and free(flip). */
- ms_drm_abort_seq(scrn, seq);
- return QUEUE_FLIP_DRM_FLUSH_FAILED;
- }
-
- /* We flushed some events, so try again. */
- xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queue retry\n");
- }
+ if (do_queue_flip_on_crtc(screen, crtc, flags, seq, ms->drmmode.fb_id,
+ crtc->x, crtc->y))
+ return QUEUE_FLIP_DRM_FLUSH_FAILED;
/* The page flip succeeded. */
return QUEUE_FLIP_SUCCESS;
@@ -294,20 +321,75 @@ ms_print_pageflip_error(int screen_index, const char *log_prefix,
}
}
+static Bool
+ms_tearfree_dri_flip(modesettingPtr ms, xf86CrtcPtr crtc, void *event,
+ ms_pageflip_handler_proc pageflip_handler,
+ ms_pageflip_abort_proc pageflip_abort)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ struct ms_crtc_pageflip *flip;
+ struct ms_flipdata *flipdata;
+ RegionRec region;
+ RegionPtr dirty;
+
+ if (!ms_tearfree_is_active_on_crtc(crtc))
+ return FALSE;
+
+ /* Check for damage on the primary scanout to know if TearFree will flip */
+ dirty = DamageRegion(ms->damage);
+ if (RegionNil(dirty))
+ return FALSE;
+
+ /* Compute how much of the current damage intersects with this CRTC */
+ RegionInit(&region, &crtc->bounds, 0);
+ RegionIntersect(&region, &region, dirty);
+
+ /* No damage on this CRTC means no TearFree flip. This means the DRI client
+ * didn't change this CRTC's contents at all with its presentation, possibly
+ * because its window is fully occluded by another window on this CRTC.
+ */
+ if (RegionNil(&region))
+ return FALSE;
+
+ flip = calloc(1, sizeof(*flip));
+ if (!flip)
+ return FALSE;
+
+ flipdata = calloc(1, sizeof(*flipdata));
+ if (!flipdata) {
+ free(flip);
+ return FALSE;
+ }
+
+ /* Only track the DRI client's fake flip on the reference CRTC, which aligns
+ * with the behavior of Present when a client copies its pixmap rather than
+ * directly flipping it onto the display.
+ */
+ flip->on_reference_crtc = TRUE;
+ flip->flipdata = flipdata;
+ flip->tearfree_seq = trf->flip_seq;
+ flipdata->screen = xf86ScrnToScreen(crtc->scrn);
+ flipdata->event = event;
+ flipdata->flip_count = 1;
+ flipdata->event_handler = pageflip_handler;
+ flipdata->abort_handler = pageflip_abort;
+
+ /* Keep the list in FIFO order so that clients are notified in order */
+ xorg_list_append(&flip->node, &trf->dri_flip_list);
+ return TRUE;
+}
Bool
ms_do_pageflip(ScreenPtr screen,
PixmapPtr new_front,
void *event,
- int ref_crtc_vblank_pipe,
+ xf86CrtcPtr ref_crtc,
Bool async,
ms_pageflip_handler_proc pageflip_handler,
ms_pageflip_abort_proc pageflip_abort,
const char *log_prefix)
{
-#ifndef GLAMOR_HAS_GBM
- return FALSE;
-#else
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -315,6 +397,22 @@ ms_do_pageflip(ScreenPtr screen,
uint32_t flags;
int i;
struct ms_flipdata *flipdata;
+
+ /* A NULL pixmap indicates this DRI client's pixmap is to be flipped through
+ * TearFree instead. The pixmap is already copied to the primary scanout at
+ * this point, so all that's left is to wire up this fake flip to TearFree
+ * so that TearFree can send a notification to the DRI client when the
+ * pixmap actually appears on the display. This is the only way to let DRI
+ * clients accurately know when their pixmaps appear on the display when
+ * TearFree is enabled.
+ */
+ if (!new_front) {
+ if (!ms_tearfree_dri_flip(ms, ref_crtc, event, pageflip_handler,
+ pageflip_abort))
+ goto error_free_event;
+ return TRUE;
+ }
+
ms->glamor.block_handler(screen);
new_front_bo.gbm = ms->glamor.gbm_bo_from_pixmap(screen, new_front);
@@ -324,7 +422,7 @@ ms_do_pageflip(ScreenPtr screen,
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"%s: Failed to get GBM BO for flip to new front.\n",
log_prefix);
- return FALSE;
+ goto error_free_event;
}
flipdata = calloc(1, sizeof(struct ms_flipdata));
@@ -332,7 +430,7 @@ ms_do_pageflip(ScreenPtr screen,
drmmode_bo_destroy(&ms->drmmode, &new_front_bo);
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"%s: Failed to allocate flipdata.\n", log_prefix);
- return FALSE;
+ goto error_free_event;
}
flipdata->event = event;
@@ -380,7 +478,6 @@ ms_do_pageflip(ScreenPtr screen,
for (i = 0; i < config->num_crtc; i++) {
enum queue_flip_status flip_status;
xf86CrtcPtr crtc = config->crtc[i];
- drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
if (!xf86_crtc_on(crtc))
continue;
@@ -401,13 +498,11 @@ ms_do_pageflip(ScreenPtr screen,
* outputs in a "clone-mode" or "mirror-mode" configuration.
*/
if (ms->drmmode.can_async_flip && ms->drmmode.async_flip_secondaries &&
- (drmmode_crtc->vblank_pipe != ref_crtc_vblank_pipe) &&
- (ref_crtc_vblank_pipe >= 0))
+ ref_crtc && crtc != ref_crtc)
flags |= DRM_MODE_PAGE_FLIP_ASYNC;
flip_status = queue_flip_on_crtc(screen, crtc, flipdata,
- ref_crtc_vblank_pipe,
- flags);
+ ref_crtc, flags);
switch (flip_status) {
case QUEUE_FLIP_ALLOC_FAILED:
@@ -456,13 +551,150 @@ error_out:
drmmode_bo_destroy(&ms->drmmode, &new_front_bo);
/* if only the local reference - free the structure,
* else drop the local reference and return */
- if (flipdata->flip_count == 1)
+ if (flipdata->flip_count == 1) {
free(flipdata);
- else
+ } else {
flipdata->flip_count--;
+ return FALSE;
+ }
+
+error_free_event:
+ /* Free the event since the caller has no way to know it's safe to free */
+ free(event);
+ return FALSE;
+}
+
+Bool
+ms_tearfree_dri_abort(xf86CrtcPtr crtc,
+ Bool (*match)(void *data, void *match_data),
+ void *match_data)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ struct ms_crtc_pageflip *flip;
+
+ /* The window is getting destroyed; abort without notifying the client */
+ xorg_list_for_each_entry(flip, &trf->dri_flip_list, node) {
+ if (match(flip->flipdata->event, match_data)) {
+ xorg_list_del(&flip->node);
+ ms_pageflip_abort(flip);
+ return TRUE;
+ }
+ }
return FALSE;
-#endif /* GLAMOR_HAS_GBM */
}
+void
+ms_tearfree_dri_abort_all(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ struct ms_crtc_pageflip *flip, *tmp;
+ uint64_t usec = 0, msc = 0;
+
+ /* Nothing to abort if there aren't any DRI clients waiting for a flip */
+ if (xorg_list_is_empty(&trf->dri_flip_list))
+ return;
+
+ /* Even though we're aborting, these clients' pixmaps were actually blitted,
+ * so technically the presentation isn't aborted. That's why the normal
+ * handler is called instead of the abort handler, along with the current
+ * time and MSC for this CRTC.
+ */
+ ms_get_crtc_ust_msc(crtc, &usec, &msc);
+ xorg_list_for_each_entry_safe(flip, tmp, &trf->dri_flip_list, node)
+ ms_pageflip_handler(msc, usec, flip);
+ xorg_list_init(&trf->dri_flip_list);
+}
+
+static void
+ms_tearfree_dri_notify(drmmode_tearfree_ptr trf, uint64_t msc, uint64_t usec)
+{
+ struct ms_crtc_pageflip *flip, *tmp;
+
+ xorg_list_for_each_entry_safe(flip, tmp, &trf->dri_flip_list, node) {
+ /* If a TearFree flip was already pending at the time this DRI client's
+ * pixmap was copied, then the pixmap isn't contained in this TearFree
+ * flip, but will be part of the next TearFree flip instead.
+ */
+ if (flip->tearfree_seq) {
+ flip->tearfree_seq = 0;
+ } else {
+ xorg_list_del(&flip->node);
+ ms_pageflip_handler(msc, usec, flip);
+ }
+ }
+}
+
+static void
+ms_tearfree_flip_abort(void *data)
+{
+ xf86CrtcPtr crtc = data;
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ trf->flip_seq = 0;
+ ms_tearfree_dri_abort_all(crtc);
+}
+
+static void
+ms_tearfree_flip_handler(uint64_t msc, uint64_t usec, void *data)
+{
+ xf86CrtcPtr crtc = data;
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ /* Swap the buffers and complete the flip */
+ trf->back_idx ^= 1;
+ trf->flip_seq = 0;
+
+ /* Notify DRI clients that their pixmaps are now visible on the display */
+ ms_tearfree_dri_notify(trf, msc, usec);
+}
+
+Bool
+ms_do_tearfree_flip(ScreenPtr screen, xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+ uint32_t idx = trf->back_idx, seq;
+
+ seq = ms_drm_queue_alloc(crtc, crtc, ms_tearfree_flip_handler,
+ ms_tearfree_flip_abort);
+ if (!seq) {
+ /* Need to notify the DRI clients if a sequence wasn't allocated. Once a
+ * sequence is allocated, explicitly performing this cleanup isn't
+ * necessary since it's already done as part of aborting the sequence.
+ */
+ ms_tearfree_dri_abort_all(crtc);
+ goto no_flip;
+ }
+
+ /* Copy the damage to the back buffer and then flip it at the vblank */
+ drmmode_copy_damage(crtc, trf->buf[idx].px, &trf->buf[idx].dmg, TRUE);
+ if (do_queue_flip_on_crtc(screen, crtc, DRM_MODE_PAGE_FLIP_EVENT,
+ seq, trf->buf[idx].fb_id, 0, 0))
+ goto no_flip;
+
+ trf->flip_seq = seq;
+ return FALSE;
+
+no_flip:
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+ "TearFree flip failed, rendering frame without TearFree\n");
+ drmmode_copy_damage(crtc, trf->buf[idx ^ 1].px,
+ &trf->buf[idx ^ 1].dmg, FALSE);
+ return TRUE;
+}
#endif
+
+Bool
+ms_tearfree_is_active_on_crtc(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ /* If TearFree is enabled, XServer owns the VT, and the CRTC is active */
+ return trf->buf[0].px && crtc->scrn->vtSema && xf86_crtc_on(crtc);
+}
diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c
index c3266d871..788b500d6 100644
--- a/hw/xfree86/drivers/modesetting/present.c
+++ b/hw/xfree86/drivers/modesetting/present.c
@@ -165,6 +165,13 @@ ms_present_abort_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
{
ScreenPtr screen = crtc->pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+#ifdef GLAMOR_HAS_GBM
+ xf86CrtcPtr xf86_crtc = crtc->devPrivate;
+
+ /* Check if this is a fake flip routed through TearFree and abort it */
+ if (ms_tearfree_dri_abort(xf86_crtc, ms_present_event_match, &event_id))
+ return;
+#endif
ms_drm_abort(scrn, ms_present_event_match, &event_id);
}
@@ -318,14 +325,35 @@ ms_present_check_flip(RRCrtcPtr crtc,
modesettingPtr ms = modesettingPTR(scrn);
if (ms->drmmode.sprites_visible > 0)
- return FALSE;
+ goto no_flip;
+
+ if (ms->drmmode.pending_modeset)
+ goto no_flip;
if(!ms_present_check_unflip(crtc, window, pixmap, sync_flip, reason))
- return FALSE;
+ goto no_flip;
ms->flip_window = window;
return TRUE;
+
+no_flip:
+ /* Export some info about TearFree if Present can't flip anyway */
+ if (reason) {
+ xf86CrtcPtr xf86_crtc = crtc->devPrivate;
+ drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ if (ms_tearfree_is_active_on_crtc(xf86_crtc)) {
+ if (trf->flip_seq)
+ /* The driver has a TearFree flip pending */
+ *reason = PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING;
+ else
+ /* The driver uses TearFree flips and there's no flip pending */
+ *reason = PRESENT_FLIP_REASON_DRIVER_TEARFREE;
+ }
+ }
+ return FALSE;
}
/*
@@ -343,11 +371,12 @@ ms_present_flip(RRCrtcPtr crtc,
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
xf86CrtcPtr xf86_crtc = crtc->devPrivate;
- drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
Bool ret;
struct ms_present_vblank_event *event;
- if (!ms_present_check_flip(crtc, ms->flip_window, pixmap, sync_flip, NULL))
+ /* A NULL pixmap means this is a fake flip to be routed through TearFree */
+ if (pixmap &&
+ !ms_present_check_flip(crtc, ms->flip_window, pixmap, sync_flip, NULL))
return FALSE;
event = calloc(1, sizeof(struct ms_present_vblank_event));
@@ -360,6 +389,12 @@ ms_present_flip(RRCrtcPtr crtc,
event->event_id = event_id;
event->unflip = FALSE;
+ /* Register the fake flip (indicated by a NULL pixmap) with TearFree */
+ if (!pixmap)
+ return ms_do_pageflip(screen, NULL, event, xf86_crtc, FALSE,
+ ms_present_flip_handler, ms_present_flip_abort,
+ "Present-TearFree-flip");
+
/* A window can only flip if it covers the entire X screen.
* Only one window can flip at a time.
*
@@ -371,7 +406,7 @@ ms_present_flip(RRCrtcPtr crtc,
ms_present_set_screen_vrr(scrn, TRUE);
}
- ret = ms_do_pageflip(screen, pixmap, event, drmmode_crtc->vblank_pipe, !sync_flip,
+ ret = ms_do_pageflip(screen, pixmap, event, xf86_crtc, !sync_flip,
ms_present_flip_handler, ms_present_flip_abort,
"Present-flip");
if (ret)
@@ -403,7 +438,7 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id)
event->unflip = TRUE;
if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL) &&
- ms_do_pageflip(screen, pixmap, event, -1, FALSE,
+ ms_do_pageflip(screen, pixmap, event, NULL, FALSE,
ms_present_flip_handler, ms_present_flip_abort,
"Present-unflip")) {
return;
diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
index ea9e7a88c..c89aa3f17 100644
--- a/hw/xfree86/drivers/modesetting/vblank.c
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -29,7 +29,9 @@
#include "dix-config.h"
#endif
+#include <errno.h>
#include <unistd.h>
+
#include <xf86.h>
#include <xf86Crtc.h>
#include "driver.h"
@@ -260,6 +262,51 @@ ms_get_kernel_ust_msc(xf86CrtcPtr crtc,
}
}
+static void
+ms_drm_set_seq_msc(uint32_t seq, uint64_t msc)
+{
+ struct ms_drm_queue *q;
+
+ xorg_list_for_each_entry(q, &ms_drm_queue, list) {
+ if (q->seq == seq) {
+ q->msc = msc;
+ break;
+ }
+ }
+}
+
+static void
+ms_drm_set_seq_queued(uint32_t seq, uint64_t msc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc;
+ struct ms_drm_queue *q;
+
+ xorg_list_for_each_entry(q, &ms_drm_queue, list) {
+ if (q->seq == seq) {
+ drmmode_crtc = q->crtc->driver_private;
+ if (msc < drmmode_crtc->next_msc)
+ drmmode_crtc->next_msc = msc;
+ q->msc = msc;
+ q->kernel_queued = TRUE;
+ break;
+ }
+ }
+}
+
+static Bool
+ms_queue_coalesce(xf86CrtcPtr crtc, uint32_t seq, uint64_t msc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ /* If the next MSC is too late, then this event can't be coalesced */
+ if (msc < drmmode_crtc->next_msc)
+ return FALSE;
+
+ /* Set the target MSC on this sequence number */
+ ms_drm_set_seq_msc(seq, msc);
+ return TRUE;
+}
+
Bool
ms_queue_vblank(xf86CrtcPtr crtc, ms_queue_flag flags,
uint64_t msc, uint64_t *msc_queued, uint32_t seq)
@@ -271,6 +318,10 @@ ms_queue_vblank(xf86CrtcPtr crtc, ms_queue_flag flags,
drmVBlank vbl;
int ret;
+ /* Try coalescing this event into another to avoid event queue exhaustion */
+ if (flags == MS_QUEUE_ABSOLUTE && ms_queue_coalesce(crtc, seq, msc))
+ return TRUE;
+
for (;;) {
/* Queue an event at the specified sequence */
if (ms->has_queue_sequence || !ms->tried_queue_sequence) {
@@ -287,8 +338,10 @@ ms_queue_vblank(xf86CrtcPtr crtc, ms_queue_flag flags,
ret = drmCrtcQueueSequence(ms->fd, drmmode_crtc->mode_crtc->crtc_id,
drm_flags, msc, &kernel_queued, seq);
if (ret == 0) {
+ msc = ms_kernel_msc_to_crtc_msc(crtc, kernel_queued, TRUE);
+ ms_drm_set_seq_queued(seq, msc);
if (msc_queued)
- *msc_queued = ms_kernel_msc_to_crtc_msc(crtc, kernel_queued, TRUE);
+ *msc_queued = msc;
ms->has_queue_sequence = TRUE;
return TRUE;
}
@@ -310,8 +363,10 @@ ms_queue_vblank(xf86CrtcPtr crtc, ms_queue_flag flags,
vbl.request.signal = seq;
ret = drmWaitVBlank(ms->fd, &vbl);
if (ret == 0) {
+ msc = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence, FALSE);
+ ms_drm_set_seq_queued(seq, msc);
if (msc_queued)
- *msc_queued = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence, FALSE);
+ *msc_queued = msc;
return TRUE;
}
check:
@@ -418,13 +473,15 @@ ms_drm_queue_alloc(xf86CrtcPtr crtc,
if (!ms_drm_seq)
++ms_drm_seq;
q->seq = ms_drm_seq++;
+ q->msc = UINT64_MAX;
q->scrn = scrn;
q->crtc = crtc;
q->data = data;
q->handler = handler;
q->abort = abort;
- xorg_list_add(&q->list, &ms_drm_queue);
+ /* Keep the list formatted in ascending order of sequence number */
+ xorg_list_append(&q->list, &ms_drm_queue);
return q->seq;
}
@@ -437,9 +494,18 @@ ms_drm_queue_alloc(xf86CrtcPtr crtc,
static void
ms_drm_abort_one(struct ms_drm_queue *q)
{
+ if (q->aborted)
+ return;
+
+ /* Don't remove vblank events if they were queued in the kernel */
+ if (q->kernel_queued) {
+ q->abort(q->data);
+ q->aborted = TRUE;
+ } else {
xorg_list_del(&q->list);
q->abort(q->data);
free(q);
+ }
}
/**
@@ -500,16 +566,64 @@ ms_drm_sequence_handler(int fd, uint64_t frame, uint64_t ns, Bool is64bit, uint6
{
struct ms_drm_queue *q, *tmp;
uint32_t seq = (uint32_t) user_data;
+ xf86CrtcPtr crtc = NULL;
+ drmmode_crtc_private_ptr drmmode_crtc;
+ uint64_t msc, next_msc = UINT64_MAX;
- xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+ /* Handle the seq for this event first in order to get the CRTC */
+ xorg_list_for_each_entry(q, &ms_drm_queue, list) {
if (q->seq == seq) {
- uint64_t msc;
+ crtc = q->crtc;
+ msc = ms_kernel_msc_to_crtc_msc(crtc, frame, is64bit);
+
+ /* Write the current MSC to this event to ensure its handler runs in
+ * the loop below. This is done because we don't want to run the
+ * handler right now, since we need to ensure all events are handled
+ * in FIFO order with respect to one another. Otherwise, if this
+ * event were handled first just because it was queued to the
+ * kernel, it could run before older events expiring at this MSC.
+ */
+ q->msc = msc;
+ break;
+ }
+ }
+
+ if (!crtc)
+ return;
- msc = ms_kernel_msc_to_crtc_msc(q->crtc, frame, is64bit);
+ /* Now run all of the vblank events for this CRTC with an expired MSC */
+ xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+ if (q->crtc == crtc && q->msc <= msc) {
xorg_list_del(&q->list);
- q->handler(msc, ns / 1000, q->data);
+ if (!q->aborted)
+ q->handler(msc, ns / 1000, q->data);
free(q);
- break;
+ }
+ }
+
+ /* Find this CRTC's next queued MSC and next non-queued MSC to be handled */
+ msc = UINT64_MAX;
+ xorg_list_for_each_entry(q, &ms_drm_queue, list) {
+ if (q->crtc == crtc) {
+ if (q->kernel_queued) {
+ if (q->msc < next_msc)
+ next_msc = q->msc;
+ } else if (q->msc < msc) {
+ msc = q->msc;
+ seq = q->seq;
+ }
+ }
+ }
+
+ /* Queue an event if the next queued MSC isn't soon enough */
+ drmmode_crtc = crtc->driver_private;
+ drmmode_crtc->next_msc = next_msc;
+ if (msc < next_msc && !ms_queue_vblank(crtc, MS_QUEUE_ABSOLUTE, msc, NULL, seq)) {
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
+ "failed to queue next vblank event, aborting lost events\n");
+ xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+ if (q->crtc == crtc && q->msc < next_msc)
+ ms_drm_abort_one(q);
}
}
}
@@ -531,6 +645,12 @@ ms_drm_handler(int fd, uint32_t frame, uint32_t sec, uint32_t usec,
}
Bool
+ms_drm_queue_is_empty(void)
+{
+ return xorg_list_is_empty(&ms_drm_queue);
+}
+
+Bool
ms_vblank_screen_init(ScreenPtr screen)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 3d8b92e66..76bc4809f 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -4,6 +4,7 @@
#endif
#include <string.h>
+#include <sys/mman.h>
#include "xf86.h"
#include "xf86Modes.h"
@@ -304,6 +305,31 @@ fbdev_open_pci(struct pci_device *pPci, char **namep)
return -1;
}
+/* *
+ * Try to resolve a filename as symbolic link. If the file is not a link, the
+ * original filename is returned. NULL is returned if readlink raised an
+ * error.
+ */
+static const char *
+resolve_link(const char *filename, char *resolve_buf, size_t resolve_buf_size)
+{
+ ssize_t len = readlink(filename, resolve_buf, resolve_buf_size - 1);
+ /* if it is a link resolve it */
+ if (len >= 0) {
+ resolve_buf[len] = '\0';
+ return resolve_buf;
+ }
+ else {
+ if (errno == EINVAL) {
+ return filename;
+ }
+ else {
+ // Have caller handle error condition.
+ return NULL;
+ }
+ }
+}
+
static int
fbdev_open(int scrnIndex, const char *dev, char **namep)
{
@@ -331,9 +357,26 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
/* only touch non-PCI devices on this path */
{
+ char device_path_buf[PATH_MAX];
char buf[PATH_MAX] = {0};
char *sysfs_path = NULL;
- char *node = strrchr(dev, '/') + 1;
+ char const *real_dev = resolve_link(dev, device_path_buf,
+ sizeof(device_path_buf));
+ if (real_dev == NULL) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Failed resolving symbolic link for device '%s': %s",
+ dev, strerror(errno));
+ return -1;
+ }
+
+ const char *node = strrchr(real_dev, '/');
+
+ if (node == NULL) {
+ node = real_dev;
+ }
+ else {
+ node++;
+ }
if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 ||
readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 ||
diff --git a/hw/xfree86/glamor_egl/meson.build b/hw/xfree86/glamor_egl/meson.build
index 7eae05812..dd1cafcd9 100644
--- a/hw/xfree86/glamor_egl/meson.build
+++ b/hw/xfree86/glamor_egl/meson.build
@@ -15,7 +15,7 @@ shared_module(
dependency('libdrm', version: '>= 2.4.46'),
gbm_dep,
],
- link_with: glamor,
+ link_with: [glamor, libxserver_glx],
install: true,
install_dir: module_dir,
diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 191571192..9e52305d9 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -7,6 +7,7 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <string.h>
#include <unistd.h>
@@ -92,12 +93,11 @@ int10MemRec genericMem = {
static void MapVRam(xf86Int10InfoPtr pInt);
static void UnmapVRam(xf86Int10InfoPtr pInt);
+static void *sysMem = NULL;
+
#ifdef _PC
#define GET_HIGH_BASE(x) (((V_BIOS + (x) + getpagesize() - 1)/getpagesize()) \
* getpagesize())
-#endif
-
-static void *sysMem = NULL;
static Bool
readIntVec(struct pci_device *dev, unsigned char *buf, int len)
@@ -112,6 +112,7 @@ readIntVec(struct pci_device *dev, unsigned char *buf, int len)
return TRUE;
}
+#endif /* _PC */
xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index 12000bf96..c7c8478e6 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -21,8 +21,10 @@
#define PRINT_PORT 0
#include <unistd.h>
-
#include <X11/Xos.h>
+
+#include "os/osdep.h"
+
#include "xf86.h"
#include "xf86_OSproc.h"
#include "compiler.h"
diff --git a/hw/xfree86/int10/vbe.h b/hw/xfree86/int10/vbe.h
index 8024f5102..ee3a4daf8 100644
--- a/hw/xfree86/int10/vbe.h
+++ b/hw/xfree86/int10/vbe.h
@@ -59,13 +59,10 @@ typedef struct vbeControllerInfoBlock {
CARD8 OemData[256];
} vbeControllerInfoRec, *vbeControllerInfoPtr;
-#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__)
#pragma pack() /* All GCC versions recognise this syntax */
#else
#pragma pack(0)
-#endif
-
-#if !( defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) )
#define __attribute__(a)
#endif
diff --git a/hw/xfree86/man/Xorg.man b/hw/xfree86/man/Xorg.man
index 3ec6e2c25..2084653f8 100644
--- a/hw/xfree86/man/Xorg.man
+++ b/hw/xfree86/man/Xorg.man
@@ -171,6 +171,9 @@ bpp framebuffer rather than the (possibly default) 32 bpp framebuffer
(or vice versa). Legal values are 1, 8, 16, 24, 32. Not all drivers
support all values.
.TP 8
+.B \-flipPixels
+Swap the default values for the black and white pixels.
+.TP 8
.BI \-gamma " value"
Set the gamma correction.
.I value
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index ac88d7e7a..ac214591e 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -677,6 +677,9 @@ Possible values are
or
.BR sync .
Unset by default.
+.TP 7
+.BI "Option \*qAllowByteSwappedClients\*q \*q" boolean \*q
+Allow clients with a different byte-order than the server. Disabled by default.
.SH "MODULE SECTION"
The
.B Module
@@ -1296,7 +1299,20 @@ This option specifies that the matched device should be treated as the
primary GPU, replacing the selection of the GPU used as output by the
firmware. If multiple output devices match an OutputClass section with
the PrimaryGPU option set, the first one enumerated becomes the primary GPU.
-.PP
+.TP 7
+.BI "Option \*qHotplugDriver\*q \*q" driver \*q
+This option specifies that the matched driver should be used to handle a
+hot-plugged GPU device.
+The module specified by
+.I driver
+will be loaded during setup of the GPU device.
+If loading of this module fails or there is no driver by that name, the
+modesetting driver will be used, which is the default behavior.
+If multiple output devices match an
+.B OutputClass
+section with the
+.B HotplugDriver
+option, the first one enumerated becomes the hotplug driver.
A
.B OutputClass
Section may contain
@@ -2081,6 +2097,14 @@ use for the screen. This may be used to select an alternate implementation
for development, debugging, or alternate feature sets.
Default: mesa.
.TP 7
+.BI "Option \*RenderingAPI\*q \*q" string \*q
+This option specifies an rendering API for use in conjunction with Glamor
+accel method. You can specify OpenGL with a value "gl" and OpenGL ES with a
+value "es", and the default is both, when Glamor fallbacks to GLES if GL 2.1 is
+not available. This may be useful for embedded and old cards, where GL ES
+feature set works faster than GL feature set.
+Default: gl.
+.TP 7
.BI "Option \*qInitPrimary\*q \*q" boolean \*q
Use the Int10 module to initialize the primary graphics card.
Normally, only secondary cards are soft-booted using the Int10 module, as the
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index e36adbe00..46f2211b4 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -339,8 +339,8 @@ struct _xf86Crtc {
*/
PictTransform crtc_to_framebuffer;
/* framebuffer_to_crtc was removed in ABI 2 */
- struct pict_f_transform f_crtc_to_framebuffer; /* ABI 2 */
- struct pict_f_transform f_framebuffer_to_crtc; /* ABI 2 */
+ struct pixman_f_transform f_crtc_to_framebuffer; /* ABI 2 */
+ struct pixman_f_transform f_framebuffer_to_crtc; /* ABI 2 */
PictFilterPtr filter; /* ABI 2 */
xFixed *params; /* ABI 2 */
int nparams; /* ABI 2 */
@@ -912,6 +912,11 @@ extern _X_EXPORT void
extern _X_EXPORT Bool
xf86CrtcRotate(xf86CrtcPtr crtc);
+extern _X_EXPORT void
+ xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, PixmapPtr dst_pixmap,
+ DrawableRec *src_drawable, RegionPtr region,
+ Bool transform_src);
+
/*
* Clean up any rotation data, used when a crtc is turned off
* as well as when rotation is disabled.
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index dba5f8877..adeecec06 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -209,12 +209,6 @@ set_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
* *_cursor_*_check
*/
static inline Bool
-xf86_driver_has_show_cursor(xf86CrtcPtr crtc)
-{
- return crtc->funcs->show_cursor_check || crtc->funcs->show_cursor;
-}
-
-static inline Bool
xf86_driver_has_load_cursor_image(xf86CrtcPtr crtc)
{
return crtc->funcs->load_cursor_image_check || crtc->funcs->load_cursor_image;
@@ -301,7 +295,8 @@ xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
CursorPtr cursor = xf86CurrentCursor(screen);
int c;
CARD8 *bits = cursor ?
- dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
+ dixLookupScreenPrivate(&cursor->devPrivates,
+ &xf86ScreenCursorBitsKeyRec, screen)
: NULL;
/* Save ARGB versions of these colors */
diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c
index 368649852..114b6932f 100644
--- a/hw/xfree86/modes/xf86DiDGA.c
+++ b/hw/xfree86/modes/xf86DiDGA.c
@@ -28,6 +28,7 @@
#include "xf86DDC.h"
#include "xf86_OSproc.h"
#include "dgaproc.h"
+#include "dgaproc_priv.h"
#include "xf86Crtc.h"
#include "xf86Modes.h"
#include "gcstruct.h"
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 39a38c741..7943c02b8 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -24,6 +24,8 @@
#include <xorg-config.h>
#endif
+#include "dix/screenint_priv.h"
+
#include "xf86.h"
#include "os.h"
#include "globals.h"
@@ -33,7 +35,7 @@
#include "mipointer.h"
#include "windowstr.h"
#include "inputstr.h"
-#include <randrstr.h>
+#include "randrstr_priv.h"
#include <X11/extensions/render.h>
#include "xf86cmap.h"
@@ -294,7 +296,7 @@ xf86ComputeCrtcPan(Bool transform_in_use,
double r[3];
double q[2], u[2], t[2], v[2], w[2], p[2];
double f;
- struct pict_f_vector d;
+ struct pixman_f_vector d;
int i;
/* Get the un-normalized crtc coordinates again */
@@ -368,7 +370,7 @@ xf86RandR13Pan(xf86CrtcPtr crtc, int x, int y)
(crtc->panningTrackingArea.y2 <= crtc->panningTrackingArea.y1 ||
(y >= crtc->panningTrackingArea.y1 &&
y < crtc->panningTrackingArea.y2))) {
- struct pict_f_vector c;
+ struct pixman_f_vector c;
/*
* Pre-clip the mouse position to the panning area so that we don't
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index ea9c43c0f..68213ab49 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -39,13 +39,13 @@
#include "X11/extensions/dpmsconst.h"
#include "X11/Xatom.h"
-static void
-xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, RegionPtr region)
+void
+xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, PixmapPtr dst_pixmap,
+ DrawableRec *src_drawable, RegionPtr region,
+ Bool transform_src)
{
ScrnInfoPtr scrn = crtc->scrn;
ScreenPtr screen = scrn->pScreen;
- WindowPtr root = screen->root;
- PixmapPtr dst_pixmap = crtc->rotatedPixmap;
PictFormatPtr format = PictureWindowFormat(screen->root);
int error;
PicturePtr src, dst;
@@ -57,7 +57,7 @@ xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, RegionPtr region)
return;
src = CreatePicture(None,
- &root->drawable,
+ src_drawable,
format,
CPSubwindowMode,
&include_inferiors, serverClient, &error);
@@ -70,9 +70,11 @@ xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, RegionPtr region)
if (!dst)
return;
- error = SetPictureTransform(src, &crtc->crtc_to_framebuffer);
- if (error)
- return;
+ if (transform_src) {
+ error = SetPictureTransform(src, &crtc->crtc_to_framebuffer);
+ if (error)
+ return;
+ }
if (crtc->transform_in_use && crtc->filter)
SetPicturePictFilter(src, crtc->filter, crtc->params, crtc->nparams);
@@ -205,7 +207,9 @@ xf86RotateRedisplay(ScreenPtr pScreen)
/* update damaged region */
if (RegionNotEmpty(&crtc_damage))
- xf86RotateCrtcRedisplay(crtc, &crtc_damage);
+ xf86RotateCrtcRedisplay(crtc, crtc->rotatedPixmap,
+ &pScreen->root->drawable,
+ &crtc_damage, TRUE);
RegionUninit(&crtc_damage);
}
@@ -305,7 +309,7 @@ xf86RotateCloseScreen(ScreenPtr screen)
}
static Bool
-xf86CrtcFitsScreen(xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
+xf86CrtcFitsScreen(xf86CrtcPtr crtc, struct pixman_f_transform *crtc_to_fb)
{
ScrnInfoPtr pScrn = crtc->scrn;
BoxRec b;
@@ -346,7 +350,7 @@ xf86CrtcRotate(xf86CrtcPtr crtc)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
PictTransform crtc_to_fb;
- struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
+ struct pixman_f_transform f_crtc_to_fb, f_fb_to_crtc;
xFixed *new_params = NULL;
int new_nparams = 0;
PictFilterPtr new_filter = NULL;
diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index b4038bd2b..279391e42 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -27,17 +27,20 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/param.h>
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
-#include <sys/param.h>
#ifndef __NetBSD__
#include <sys/sysctl.h>
#endif
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
#if defined(__NetBSD__) && !defined(MAP_FILE)
#define MAP_FLAGS MAP_SHARED
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index 180d70543..15b12a86f 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -60,11 +60,14 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
+#include <sys/mman.h>
#include <X11/X.h>
+
#include "xf86.h"
+#include "xf86_os_support."
#include "xf86Priv.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
#include "compiler.h"
#if defined(__NetBSD__) && !defined(MAP_FILE)
diff --git a/hw/xfree86/os-support/bsd/bsd_VTsw.c b/hw/xfree86/os-support/bsd/bsd_VTsw.c
index 0ee51de2f..ed06d944a 100644
--- a/hw/xfree86/os-support/bsd/bsd_VTsw.c
+++ b/hw/xfree86/os-support/bsd/bsd_VTsw.c
@@ -30,6 +30,7 @@
#include <X11/X.h>
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
/*
@@ -53,7 +54,7 @@ xf86VTRequest(int sig)
}
Bool
-xf86VTSwitchPending()
+xf86VTSwitchPending(void)
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
@@ -64,7 +65,7 @@ xf86VTSwitchPending()
}
Bool
-xf86VTSwitchAway()
+xf86VTSwitchAway(void)
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
@@ -79,7 +80,7 @@ xf86VTSwitchAway()
}
Bool
-xf86VTSwitchTo()
+xf86VTSwitchTo(void)
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c
index 19d1f4882..2b0bba2f6 100644
--- a/hw/xfree86/os-support/bsd/bsd_bell.c
+++ b/hw/xfree86/os-support/bsd/bsd_bell.c
@@ -35,6 +35,7 @@
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
void
diff --git a/hw/xfree86/os-support/bsd/bsd_ev56.c b/hw/xfree86/os-support/bsd/bsd_ev56.c
index 95883491b..6a190ab4e 100644
--- a/hw/xfree86/os-support/bsd/bsd_ev56.c
+++ b/hw/xfree86/os-support/bsd/bsd_ev56.c
@@ -4,14 +4,15 @@
#endif
#include <X11/X.h>
+
#include "input.h"
#include "scrnintstr.h"
#include "compiler.h"
#include "xf86.h"
+#include "xf86_os_support.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
#include <machine/bwx.h>
diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c
index 46536f81d..ae6f28b58 100644
--- a/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/hw/xfree86/os-support/bsd/bsd_init.c
@@ -29,10 +29,12 @@
#include <X11/X.h>
-#include "compiler.h"
+#include "os/cmdline.h"
+#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include <sys/utsname.h>
@@ -40,6 +42,8 @@
#include <stdlib.h>
#include <errno.h>
+#include "os/osdep.h"
+
static Bool KeepTty = FALSE;
#ifdef PCCONS_SUPPORT
@@ -86,7 +90,7 @@ static int initialVT = -1;
#define CHECK_DRIVER_MSG \
"Check your kernel's console driver configuration and /dev entries"
-static char *supported_drivers[] = {
+static const char *supported_drivers[] = {
#ifdef PCCONS_SUPPORT
"pccons (with X support)",
#endif
@@ -150,7 +154,7 @@ static xf86ConsOpen_t xf86ConsTab[] = {
};
void
-xf86OpenConsole()
+xf86OpenConsole(void)
{
int i, fd = -1;
xf86ConsOpen_t *driver;
@@ -251,7 +255,9 @@ xf86OpenConsole()
sleep(1);
}
#endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
acquire_vt:
+#endif
if (!xf86Info.ShareVTs) {
/*
* now get the VT
@@ -303,7 +309,7 @@ xf86OpenConsole()
else {
/* serverGeneration != 1 */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!xf86Info.ShareVTs &&
+ if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch &&
(xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)) {
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
@@ -317,7 +323,7 @@ xf86OpenConsole()
#ifdef PCCONS_SUPPORT
static int
-xf86OpenPccons()
+xf86OpenPccons(void)
{
int fd = -1;
@@ -342,7 +348,7 @@ xf86OpenPccons()
#ifdef SYSCONS_SUPPORT
static int
-xf86OpenSyscons()
+xf86OpenSyscons(void)
{
int fd = -1;
vtmode_t vtmode;
@@ -448,13 +454,16 @@ xf86OpenSyscons()
#ifdef PCVT_SUPPORT
static int
-xf86OpenPcvt()
+xf86OpenPcvt(void)
{
/* This looks much like syscons, since pcvt is API compatible */
int fd = -1;
vtmode_t vtmode;
- char vtname[12], *vtprefix;
+ char vtname[12];
+ const char *vtprefix;
+#ifdef __NetBSD__
struct pcvtid pcvt_version;
+#endif
#ifndef __OpenBSD__
vtprefix = "/dev/ttyv";
@@ -470,7 +479,9 @@ xf86OpenPcvt()
}
#endif
if (fd >= 0) {
+#ifdef __NetBSD__
if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0) {
+#endif
if (ioctl(fd, VT_GETMODE, &vtmode) < 0) {
FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
"xf86OpenPcvt",
@@ -521,20 +532,32 @@ xf86OpenPcvt()
}
xf86Info.consType = PCVT;
#ifdef WSCONS_SUPPORT
+#ifdef __NetBSD__
xf86Msg(X_PROBED,
"Using wscons driver on %s in pcvt compatibility mode "
"(version %d.%d)\n", vtname,
pcvt_version.rmajor, pcvt_version.rminor);
#else
+ xf86Msg(X_PROBED,
+ "Using wscons driver on %s in pcvt compatibility mode ",
+ vtname);
+#endif
+#else
+# ifdef __NetBSD__
xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
pcvt_version.rmajor, pcvt_version.rminor);
+# else
+ xf86Msg(X_PROBED, "Using pcvt driver\n");
+# endif
#endif
+#ifdef __NetBSD__
}
else {
/* Not pcvt */
close(fd);
fd = -1;
}
+#endif
}
return fd;
}
@@ -544,7 +567,7 @@ xf86OpenPcvt()
#ifdef WSCONS_SUPPORT
static int
-xf86OpenWScons()
+xf86OpenWScons(void)
{
int fd = -1;
int mode = WSDISPLAYIO_MODE_MAPPED;
@@ -575,7 +598,7 @@ xf86OpenWScons()
#endif /* WSCONS_SUPPORT */
void
-xf86CloseConsole()
+xf86CloseConsole(void)
{
#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
struct vt_mode VT;
@@ -604,7 +627,7 @@ xf86CloseConsole()
strerror(errno));
}
#endif
- if (initialVT != -1)
+ if (xf86Info.autoVTSwitch && initialVT != -1)
ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
break;
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
@@ -652,7 +675,7 @@ xf86ProcessArgument(int argc, char *argv[], int i)
}
void
-xf86UseMsg()
+xf86UseMsg(void)
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
ErrorF("vtXX use the specified VT number (1-12)\n");
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index a38a7de27..403aa08cc 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -27,15 +27,14 @@
#include <xorg-config.h>
#endif
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-
#include <errno.h>
#include <sys/mman.h>
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86_os_support.h"
+#include "xf86Priv.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
#if defined(__NetBSD__) && !defined(MAP_FILE)
#define MAP_FLAGS MAP_SHARED
@@ -167,7 +166,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
static Bool ExtendedEnabled = FALSE;
Bool
-xf86EnableIO()
+xf86EnableIO(void)
{
if (ExtendedEnabled)
return TRUE;
@@ -188,7 +187,7 @@ xf86EnableIO()
}
void
-xf86DisableIO()
+xf86DisableIO(void)
{
if (!ExtendedEnabled)
return;
@@ -202,6 +201,9 @@ xf86DisableIO()
#endif /* USE_I386_IOPL */
#ifdef USE_AMD64_IOPL
+#ifdef __NetBSD__
+#define amd64_iopl(x) x86_64_iopl(x)
+#endif
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
@@ -209,7 +211,7 @@ xf86DisableIO()
static Bool ExtendedEnabled = FALSE;
Bool
-xf86EnableIO()
+xf86EnableIO(void)
{
if (ExtendedEnabled)
return TRUE;
@@ -230,7 +232,7 @@ xf86EnableIO()
}
void
-xf86DisableIO()
+xf86DisableIO(void)
{
if (!ExtendedEnabled)
return;
@@ -250,7 +252,7 @@ xf86DisableIO()
static int IoFd = -1;
Bool
-xf86EnableIO()
+xf86EnableIO(void)
{
if (IoFd >= 0)
return TRUE;
@@ -264,7 +266,7 @@ xf86EnableIO()
}
void
-xf86DisableIO()
+xf86DisableIO(void)
{
if (IoFd < 0)
return;
@@ -304,7 +306,7 @@ xf86SetTVOut(int mode)
}
void
-xf86SetRGBOut()
+xf86SetRGBOut(void)
{
switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index 5a58da19d..7a64f4b83 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -27,12 +27,13 @@
#include <xorg-config.h>
#endif
+#include <sys/mman.h>
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
-
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
#include "bus/Pci.h"
@@ -40,10 +41,6 @@
/* Video Memory Mapping section */
/***************************************************************************/
-#ifdef __OpenBSD__
-#define DEV_MEM "/dev/xf86"
-#endif
-
Bool xf86EnableIO(void);
void xf86DisableIO(void);
@@ -79,7 +76,11 @@ xf86DisableIO()
{
if (ioBase != MAP_FAILED) {
+#if defined(__FreeBSD__)
+ munmap(__DEVOLATILE(unsigned char *, ioBase), 0x10000);
+#else
munmap(__UNVOLATILE(ioBase), 0x10000);
+#endif
ioBase = MAP_FAILED;
}
}
diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c
index 3f8cccd19..c456eaf6a 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -28,11 +28,11 @@
#endif
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
-
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
/***************************************************************************/
/* Video Memory Mapping section */
diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c
index 7a5dbbb01..91b80aab9 100644
--- a/hw/xfree86/os-support/bus/bsd_pci.c
+++ b/hw/xfree86/os-support/bus/bsd_pci.c
@@ -40,9 +40,11 @@
#endif
#include <stdio.h>
+
#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include "Pci.h"
diff --git a/hw/xfree86/os-support/hurd/hurd_bell.c b/hw/xfree86/os-support/hurd/hurd_bell.c
index 33965a44c..0c155dd68 100644
--- a/hw/xfree86/os-support/hurd/hurd_bell.c
+++ b/hw/xfree86/os-support/hurd/hurd_bell.c
@@ -28,6 +28,7 @@
#endif
#include "xf86.h"
+#include "xf86_os_support.h"
#include "xf86Priv.h"
void
diff --git a/hw/xfree86/os-support/hurd/hurd_init.c b/hw/xfree86/os-support/hurd/hurd_init.c
index c1b632f19..e99c3fff4 100644
--- a/hw/xfree86/os-support/hurd/hurd_init.c
+++ b/hw/xfree86/os-support/hurd/hurd_init.c
@@ -34,6 +34,7 @@
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include <stdio.h>
diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index ac24f1950..f39142293 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -29,15 +29,16 @@
#include <device/device.h>
#include <mach/machine/mach_i386.h>
#include <hurd.h>
-
+#include <errno.h>
#include <X11/X.h>
+
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
/**************************************************************************
* Video Memory Mapping section
diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c
index 6ca118f25..42f872dd2 100644
--- a/hw/xfree86/os-support/linux/int10/linux.c
+++ b/hw/xfree86/os-support/linux/int10/linux.c
@@ -55,21 +55,6 @@ typedef struct {
char *alloc;
} linuxInt10Priv;
-#if defined DoSubModules
-
-typedef enum {
- INT10_NOT_LOADED,
- INT10_LOADED_VM86,
- INT10_LOADED_X86EMU,
- INT10_LOAD_FAILED
-} Int10LinuxSubModuleState;
-
-static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED;
-
-static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
-
-#endif /* DoSubModules */
-
static Bool
readLegacy(struct pci_device *dev, unsigned char *buf, int base, int len)
{
@@ -118,14 +103,6 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
return NULL;
}
-#if defined DoSubModules
- if (loadedSubModule == INT10_NOT_LOADED)
- loadedSubModule = int10LinuxLoadSubModule(pScrn);
-
- if (loadedSubModule == INT10_LOAD_FAILED)
- return NULL;
-#endif
-
if ((!vidMem) || (!sysMem)) {
if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
if (!sysMem) {
@@ -518,44 +495,3 @@ xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
else
return (void *) (memType) addr;
}
-
-#if defined DoSubModules
-
-static Bool
-vm86_tst(void)
-{
- int __res;
-
-#ifdef __PIC__
- /* When compiling with -fPIC, we can't use asm constraint "b" because
- %ebx is already taken by gcc. */
- __asm__ __volatile__("pushl %%ebx\n\t"
- "movl %2,%%ebx\n\t"
- "movl %1,%%eax\n\t"
- "int $0x80\n\t" "popl %%ebx":"=a"(__res)
- :"n"((int) 113), "r"(NULL));
-#else
- __asm__ __volatile__("int $0x80\n\t":"=a"(__res):"a"((int) 113),
- "b"((struct vm86_struct *) NULL));
-#endif
-
- if (__res < 0 && __res == -ENOSYS)
- return FALSE;
-
- return TRUE;
-}
-
-static Int10LinuxSubModuleState
-int10LinuxLoadSubModule(ScrnInfoPtr pScrn)
-{
- if (vm86_tst()) {
- if (xf86LoadSubModule(pScrn, "vm86"))
- return INT10_LOADED_VM86;
- }
- if (xf86LoadSubModule(pScrn, "x86emu"))
- return INT10_LOADED_X86EMU;
-
- return INT10_LOAD_FAILED;
-}
-
-#endif /* DoSubModules */
diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c
index dbd5afe90..50825cdfa 100644
--- a/hw/xfree86/os-support/linux/lnx_acpi.c
+++ b/hw/xfree86/os-support/linux/lnx_acpi.c
@@ -2,11 +2,6 @@
#include "xorg-config.h"
#endif
-#include "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSproc.h"
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -15,6 +10,12 @@
#include <fcntl.h>
#include <errno.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_os_support.h"
+#include "xf86_OSproc.h"
+
#define ACPI_SOCKET "/var/run/acpid.socket"
#define ACPI_VIDEO_NOTIFY_SWITCH 0x80
diff --git a/hw/xfree86/os-support/linux/lnx_agp.c b/hw/xfree86/os-support/linux/lnx_agp.c
index 3aec5397c..c1bc6fac7 100644
--- a/hw/xfree86/os-support/linux/lnx_agp.c
+++ b/hw/xfree86/os-support/linux/lnx_agp.c
@@ -11,11 +11,13 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
#if defined(__linux__)
#include <asm/ioctl.h>
@@ -350,23 +352,3 @@ xf86UnbindGARTMemory(int screenNum, int key)
return TRUE;
}
-
-/* XXX Interface may change. */
-Bool
-xf86EnableAGP(int screenNum, CARD32 mode)
-{
- agp_setup setup;
-
- if (!GARTInit(screenNum) || acquiredScreen != screenNum)
- return FALSE;
-
- setup.agp_mode = mode;
- if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
- "AGPIOC_SETUP with mode %ld failed (%s)\n",
- (unsigned long) mode, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/hw/xfree86/os-support/linux/lnx_apm.c b/hw/xfree86/os-support/linux/lnx_apm.c
index b928febf6..4377caa20 100644
--- a/hw/xfree86/os-support/linux/lnx_apm.c
+++ b/hw/xfree86/os-support/linux/lnx_apm.c
@@ -7,7 +7,7 @@
#include "os.h"
#include "xf86.h"
#include "xf86Priv.h"
-#define XF86_OS_PRIVS
+#include "xf86_os_support.h"
#include "xf86_OSproc.h"
#ifdef HAVE_ACPI
diff --git a/hw/xfree86/os-support/linux/lnx_bell.c b/hw/xfree86/os-support/linux/lnx_bell.c
index e1d3cbf17..e58b9ec80 100644
--- a/hw/xfree86/os-support/linux/lnx_bell.c
+++ b/hw/xfree86/os-support/linux/lnx_bell.c
@@ -30,9 +30,8 @@
#include <sys/ioctl.h>
#include <linux/kd.h>
-#include "xf86.h"
#include "xf86Priv.h"
-#include "xf86_OSproc.h"
+#include "xf86_os_support.h"
void
xf86OSRingBell(int loudness, int pitch, int duration)
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 111b3b4e4..16c3dc535 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -27,14 +27,18 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <X11/X.h>
#include <X11/Xmd.h>
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include "compiler.h"
#include "linux.h"
-
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include <sys/stat.h>
@@ -386,7 +390,7 @@ xf86ProcessArgument(int argc, char *argv[], int i)
if (!strcmp(argv[i], "-masterfd")) {
CHECK_FOR_REQUIRED_ARGUMENT();
- if (xf86PrivsElevated())
+ if (PrivsElevated())
FatalError("\nCannot specify -masterfd when server is setuid/setgid\n");
if (sscanf(argv[++i], "%d", &xf86DRMMasterFd) != 1) {
UseMsg();
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index fd83022f6..a74b994ab 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -29,15 +29,16 @@
#include <errno.h>
#include <string.h>
-
+#include <sys/mman.h>
#include <X11/X.h>
+
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
+#include "xf86_os_support.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
static Bool ExtendedEnabled = FALSE;
diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c
index dbb00cd85..c6a24fc7b 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -32,8 +32,9 @@
#include <sys/types.h>
#include <unistd.h>
+#include "config/dbus-core.h"
+
#include "os.h"
-#include "dbus-core.h"
#include "linux.h"
#include "xf86.h"
#include "xf86platformBus.h"
@@ -310,15 +311,19 @@ cleanup:
*/
void systemd_logind_drop_master(void)
{
+ struct systemd_logind_info *info = &logind_info;
int i;
+ /* Our VT_PROCESS usage guarantees we've already given up the vt */
+ info->active = info->vt_active = FALSE;
for (i = 0; i < xf86_num_platform_devices; i++) {
if (xf86_platform_devices[i].flags & XF86_PDEV_SERVER_FD) {
dbus_int32_t major, minor;
- struct systemd_logind_info *info = &logind_info;
xf86_platform_devices[i].flags |= XF86_PDEV_PAUSED;
major = xf86_platform_odev_attributes(i)->major;
minor = xf86_platform_odev_attributes(i)->minor;
+ LogMessage(X_INFO, "systemd-logind: drop master for %u:%u\n",
+ major, minor);
systemd_logind_ack_pause(info, minor, major);
}
}
@@ -440,6 +445,7 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
static void
connect_hook(DBusConnection *connection, void *data)
{
+ const char *session_type = "x11";
struct systemd_logind_info *info = data;
DBusError error;
DBusMessage *msg = NULL;
@@ -506,6 +512,33 @@ connect_hook(DBusConnection *connection, void *data)
error.message);
goto cleanup;
}
+ dbus_message_unref(msg);
+ dbus_message_unref(reply);
+ reply = NULL;
+
+ msg = dbus_message_new_method_call("org.freedesktop.login1",
+ session, "org.freedesktop.login1.Session", "SetType");
+ if (!msg) {
+ LogMessage(X_ERROR, "systemd-logind: out of memory\n");
+ goto cleanup;
+ }
+
+ if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &session_type,
+ DBUS_TYPE_INVALID)) {
+ LogMessage(X_ERROR, "systemd-logind: out of memory\n");
+ goto cleanup;
+ }
+
+ reply = dbus_connection_send_with_reply_and_block(connection, msg,
+ DBUS_TIMEOUT_USE_DEFAULT, &error);
+ /* Requires systemd >= 246, SetType() is not critical for xserver function */
+ if (!reply) {
+ /* unprevileged users get access denied rather than unknown method */
+ if (!dbus_error_has_name(&error, DBUS_ERROR_ACCESS_DENIED) &&
+ !dbus_error_has_name(&error, DBUS_ERROR_UNKNOWN_METHOD))
+ LogMessage(X_WARNING, "systemd-logind: SetType failed: %s\n", error.message);
+ dbus_error_free(&error);
+ }
dbus_bus_add_match(connection,
"type='signal',sender='org.freedesktop.login1',interface='org.freedesktop.login1.Session',member='PauseDevice'",
diff --git a/hw/xfree86/os-support/meson.build b/hw/xfree86/os-support/meson.build
index b6069ee85..bcedf97dc 100644
--- a/hw/xfree86/os-support/meson.build
+++ b/hw/xfree86/os-support/meson.build
@@ -36,10 +36,10 @@ if host_machine.system() == 'linux'
'linux/lnx_bell.c',
'linux/lnx_init.c',
'linux/lnx_kmod.c',
- 'linux/lnx_platform.c',
'linux/lnx_video.c',
'misc/SlowBcopy.c',
'shared/VTsw_usl.c',
+ 'shared/drm_platform.c',
]
if build_agp
srcs_xorg_os_support += 'linux/lnx_agp.c'
@@ -96,6 +96,7 @@ elif host_machine.system().endswith('bsd')
'bsd/bsd_VTsw.c',
'bsd/bsd_bell.c',
'bsd/bsd_init.c',
+ 'shared/drm_platform.c',
'shared/pm_noop.c'
]
@@ -111,9 +112,9 @@ elif host_machine.system().endswith('bsd')
if host_machine.system() == 'netbsd' or host_machine.system() == 'openbsd'
os_dep += cc.find_library('i386')
endif
- elif host_machine.cpu_family() == 'arm'
+ elif host_machine.cpu_family() == 'arm' or host_machine.cpu_family() == 'aarch64'
srcs_xorg_os_support += 'bsd/arm_video.c'
- elif host_machine.cpu_family() == 'powerpc'
+ elif host_machine.cpu_family() == 'ppc' or host_machine.cpu_family() == 'ppc64'
srcs_xorg_os_support += 'bsd/ppc_video.c'
elif host_machine.cpu_family() == 'sparc64'
srcs_xorg_os_support += 'bsd/sparc64_video.c'
diff --git a/hw/xfree86/os-support/misc/SlowBcopy.c b/hw/xfree86/os-support/misc/SlowBcopy.c
index 9d82c71bf..d40bbd7c7 100644
--- a/hw/xfree86/os-support/misc/SlowBcopy.c
+++ b/hw/xfree86/os-support/misc/SlowBcopy.c
@@ -22,35 +22,10 @@
#include "xf86_OSlib.h"
#include "compiler.h"
-static int really_slow_bcopy;
-
-void
-xf86SetReallySlowBcopy(void)
-{
- really_slow_bcopy = 1;
-}
-
-#if defined(__i386__) || defined(__amd64__)
-static void
-xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int len)
-{
- while (len--) {
- *dst++ = *src++;
- outb(0x80, 0x00);
- }
-}
-#endif
-
/* The outb() isn't needed on my machine, but who knows ... -- ost */
void
xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len)
{
-#if defined(__i386__) || defined(__amd64__)
- if (really_slow_bcopy) {
- xf86_really_slow_bcopy(src, dst, len);
- return;
- }
-#endif
while (len--)
*dst++ = *src++;
}
diff --git a/hw/xfree86/os-support/shared/VTsw_noop.c b/hw/xfree86/os-support/shared/VTsw_noop.c
index a75d134b4..f543a5bfa 100644
--- a/hw/xfree86/os-support/shared/VTsw_noop.c
+++ b/hw/xfree86/os-support/shared/VTsw_noop.c
@@ -29,6 +29,7 @@
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
/*
diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c
index 64402616e..a905cce24 100644
--- a/hw/xfree86/os-support/shared/VTsw_usl.c
+++ b/hw/xfree86/os-support/shared/VTsw_usl.c
@@ -27,8 +27,11 @@
#include <X11/X.h>
+#include "os/osdep.h"
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
/*
diff --git a/hw/xfree86/os-support/shared/agp_noop.c b/hw/xfree86/os-support/shared/agp_noop.c
index da486c051..284e0605f 100644
--- a/hw/xfree86/os-support/shared/agp_noop.c
+++ b/hw/xfree86/os-support/shared/agp_noop.c
@@ -35,10 +35,12 @@
#endif
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
+#include "xf86_os_support.h"
Bool
xf86GARTCloseScreen(int screenNum)
@@ -94,9 +96,3 @@ xf86UnbindGARTMemory(int screenNum, int key)
{
return FALSE;
}
-
-Bool
-xf86EnableAGP(int screenNum, CARD32 mode)
-{
- return FALSE;
-}
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/shared/drm_platform.c
index 8a6be97aa..a404aadcc 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/shared/drm_platform.c
@@ -14,6 +14,7 @@
#include "xf86_OSproc.h"
#include "xf86.h"
+#include "xf86_os_support.h"
#include "xf86platformBus.h"
#include "xf86Bus.h"
@@ -125,7 +126,7 @@ xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs)
xf86_remove_platform_device(index);
return;
}
- ret = xf86platformAddDevice(index);
+ ret = xf86platformAddDevice(xf86PlatformFindHotplugDriver(index), index);
if (ret == -1)
xf86_remove_platform_device(index);
}
@@ -173,6 +174,8 @@ void NewGPUDeviceRequest(struct OdevAttributes *attribs)
{
int old_num = xf86_num_platform_devices;
int ret;
+ const char *driver_name;
+
xf86PlatformDeviceProbe(attribs);
if (old_num == xf86_num_platform_devices)
@@ -181,7 +184,11 @@ void NewGPUDeviceRequest(struct OdevAttributes *attribs)
if (xf86_get_platform_device_unowned(xf86_num_platform_devices - 1) == TRUE)
return;
- ret = xf86platformAddDevice(xf86_num_platform_devices-1);
+ /* Scan and update PCI devices before adding new platform device */
+ xf86PlatformScanPciDev();
+ driver_name = xf86PlatformFindHotplugDriver(xf86_num_platform_devices - 1);
+
+ ret = xf86platformAddDevice(driver_name, xf86_num_platform_devices-1);
if (ret == -1)
xf86_remove_platform_device(xf86_num_platform_devices-1);
diff --git a/hw/xfree86/os-support/shared/platform_noop.c b/hw/xfree86/os-support/shared/platform_noop.c
index 199ae5e8e..2ff1deafa 100644
--- a/hw/xfree86/os-support/shared/platform_noop.c
+++ b/hw/xfree86/os-support/shared/platform_noop.c
@@ -8,6 +8,7 @@
#include "xf86_OSproc.h"
#include "xf86.h"
+#include "xf86_os_support.h"
#include "xf86platformBus.h"
Bool
diff --git a/hw/xfree86/os-support/shared/pm_noop.c b/hw/xfree86/os-support/shared/pm_noop.c
index 1d6f0789d..b0ed64e33 100644
--- a/hw/xfree86/os-support/shared/pm_noop.c
+++ b/hw/xfree86/os-support/shared/pm_noop.c
@@ -32,10 +32,11 @@
#endif
#include <X11/X.h>
+
#include "os.h"
#include "xf86.h"
#include "xf86Priv.h"
-#define XF86_OS_PRIVS
+#include "xf86_os_support.h"
#include "xf86_OSproc.h"
PMClose
diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c
index 0cb9788cc..ee2b2154a 100644
--- a/hw/xfree86/os-support/shared/posix_tty.c
+++ b/hw/xfree86/os-support/shared/posix_tty.c
@@ -56,7 +56,9 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <X11/X.h>
+
#include <xserver_poll.h>
#include "xf86.h"
#include "xf86Priv.h"
@@ -412,16 +414,6 @@ xf86WaitForInput(int fd, int timeout)
}
int
-xf86SerialSendBreak(int fd, int duration)
-{
- int r;
-
- SYSCALL(r = tcsendbreak(fd, duration));
- return r;
-
-}
-
-int
xf86FlushInput(int fd)
{
struct pollfd poll_fd;
diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
index ad8af6093..40677ad7a 100644
--- a/hw/xfree86/os-support/shared/sigio.c
+++ b/hw/xfree86/os-support/shared/sigio.c
@@ -56,10 +56,16 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
+#include <sys/stat.h>
#include <X11/X.h>
+
+#include "os/osdep.h"
+
#include <xserver_poll.h>
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include "inputstr.h"
diff --git a/hw/xfree86/os-support/shared/sigiostubs.c b/hw/xfree86/os-support/shared/sigiostubs.c
index d1792e8ac..c56c42fa5 100644
--- a/hw/xfree86/os-support/shared/sigiostubs.c
+++ b/hw/xfree86/os-support/shared/sigiostubs.c
@@ -30,8 +30,10 @@
#endif
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
int
diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index a6bf677f5..26ae587f5 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -35,8 +35,8 @@
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
/*
* This file contains the common part of the video memory mapping functions
diff --git a/hw/xfree86/os-support/solaris/solaris-amd64.S b/hw/xfree86/os-support/solaris/solaris-amd64.S
index 4cc0642dd..830c9c6ee 100644
--- a/hw/xfree86/os-support/solaris/solaris-amd64.S
+++ b/hw/xfree86/os-support/solaris/solaris-amd64.S
@@ -1,4 +1,4 @@
-/ Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+/ Copyright (c) 2005, Oracle and/or its affiliates.
/
/ Permission is hereby granted, free of charge, to any person obtaining a
/ copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/solaris-ia32.S b/hw/xfree86/os-support/solaris/solaris-ia32.S
index 74d787d31..00e8d5fba 100644
--- a/hw/xfree86/os-support/solaris/solaris-ia32.S
+++ b/hw/xfree86/os-support/solaris/solaris-ia32.S
@@ -1,4 +1,4 @@
-/ Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+/ Copyright (c) 2004, Oracle and/or its affiliates.
/
/ Permission is hereby granted, free of charge, to any person obtaining a
/ copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S b/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S
index 0ecafb352..4c448d970 100644
--- a/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S
+++ b/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2004, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/sun_VTsw.c b/hw/xfree86/os-support/solaris/sun_VTsw.c
index 573358b43..d4e076fb3 100644
--- a/hw/xfree86/os-support/solaris/sun_VTsw.c
+++ b/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -29,6 +29,7 @@
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include <door.h>
diff --git a/hw/xfree86/os-support/solaris/sun_agp.c b/hw/xfree86/os-support/solaris/sun_agp.c
index fb58eca81..0e5bdb1c5 100644
--- a/hw/xfree86/os-support/solaris/sun_agp.c
+++ b/hw/xfree86/os-support/solaris/sun_agp.c
@@ -6,7 +6,7 @@
* Copyright © 2000 VA Linux Systems, Inc.
* Copyright © 2001 The XFree86 Project, Inc.
*/
-/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,9 +32,12 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <X11/X.h>
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#include "xf86_OSproc.h"
#include <unistd.h>
@@ -304,23 +307,3 @@ xf86UnbindGARTMemory(int screenNum, int key)
return TRUE;
}
-
-/* XXX Interface may change. */
-Bool
-xf86EnableAGP(int screenNum, CARD32 mode)
-{
- agp_setup_t setup;
-
- if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
- return FALSE;
-
- setup.agps_mode = mode;
- if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
- "AGPIOC_SETUP with mode %x failed (%s)\n",
- (unsigned int) mode, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c
index 368f21eef..24a743f17 100644
--- a/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/hw/xfree86/os-support/solaris/sun_apm.c
@@ -27,7 +27,7 @@
* XFree86 Project.
*/
-/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -53,11 +53,13 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <X11/X.h>
+
#include "os.h"
#include "xf86.h"
#include "xf86Priv.h"
-#define XF86_OS_PRIVS
+#include "xf86_os_support.h"
#include "xf86_OSproc.h"
#include "xf86_OSlib.h"
diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c
index 883728e51..d08474516 100644
--- a/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/hw/xfree86/os-support/solaris/sun_bell.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2005, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2004-2005, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -24,6 +24,7 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
#include <sys/audio.h>
#include <sys/uio.h>
#include <limits.h>
@@ -32,6 +33,7 @@
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#define BELL_RATE 48000 /* Samples per second */
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index d7bf2e54b..2197df6f2 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -26,13 +26,21 @@
#include <xorg-config.h>
#endif
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "../../../../os/cmdline.h"
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
#ifdef HAVE_SYS_KD_H
#include <sys/kd.h>
#endif
+#include "os/osdep.h"
+
/*
* Applications see VT number as consecutive integers starting from 1.
* VT number VT device
@@ -59,7 +67,7 @@ static char consoleDev[PATH_MAX] = "/dev/fb";
/* Set by -dev argument on CLI
Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
-_X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
+char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
#ifdef HAS_USL_VTS
static void
diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c
index 8e94fcced..ac66bdf51 100644
--- a/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/hw/xfree86/os-support/solaris/sun_vid.c
@@ -22,7 +22,7 @@
* OF THIS SOFTWARE.
*
*/
-/* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -51,13 +51,17 @@
#include <sys/types.h> /* get __x86 definition if not set by compiler */
#if defined(__i386__) || defined(__i386) || defined(__x86)
-#define _NEED_SYSI86
-#endif
+#include <sys/tss.h>
+#include <sys/sysi86.h>
+#include <sys/psw.h>
+#endif /* defined(__i386__) || defined(__i386) || defined(__x86) */
+
+#include <sys/mman.h>
+
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-#include <sys/mman.h>
/***************************************************************************/
/* Video Memory Mapping section */
diff --git a/hw/xfree86/os-support/stub/stub_bell.c b/hw/xfree86/os-support/stub/stub_bell.c
index 48625928f..a06aed659 100644
--- a/hw/xfree86/os-support/stub/stub_bell.c
+++ b/hw/xfree86/os-support/stub/stub_bell.c
@@ -2,7 +2,7 @@
#include <xorg-config.h>
#endif
-#include "xf86_OSlib.h"
+#include "xf86_os_support.h"
void
xf86OSRingBell(int loudness, int pitch, int duration)
diff --git a/hw/xfree86/os-support/stub/stub_init.c b/hw/xfree86/os-support/stub/stub_init.c
index f0d9039b9..677401bfa 100644
--- a/hw/xfree86/os-support/stub/stub_init.c
+++ b/hw/xfree86/os-support/stub/stub_init.c
@@ -2,6 +2,7 @@
#include <xorg-config.h>
#endif
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
void
diff --git a/hw/xfree86/os-support/stub/stub_video.c b/hw/xfree86/os-support/stub/stub_video.c
index 9771fcf6e..d52285d29 100644
--- a/hw/xfree86/os-support/stub/stub_video.c
+++ b/hw/xfree86/os-support/stub/stub_video.c
@@ -2,8 +2,8 @@
#include <xorg-config.h>
#endif
+#include "xf86_os_support.h"
#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h
deleted file mode 100644
index ce1ec33a1..000000000
--- a/hw/xfree86/os-support/xf86OSpriv.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1999-2000 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86OSPRIV_H
-#define _XF86OSPRIV_H
-
-typedef struct {
- Bool initialised;
-} VidMemInfo, *VidMemInfoPtr;
-
-void xf86OSInitVidMem(VidMemInfoPtr);
-
-#endif /* _XF86OSPRIV_H */
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 159c8064c..7bdacb9e9 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -88,40 +88,10 @@
#include <sys/ioctl.h>
#include <signal.h>
#include <termio.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
-#if defined(_NEED_SYSI86)
-#if !(defined (__sun) && defined (SVR4))
-#include <sys/immu.h>
-#include <sys/region.h>
-#include <sys/proc.h>
-#endif
-#include <sys/tss.h>
-#include <sys/sysi86.h>
-#if defined(SVR4) && !defined(__sun)
-#include <sys/seg.h>
-#endif /* SVR4 && !__sun */
-/* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */
-#if !defined(V86SC_IOPL) /* Solaris 7 or later? */
-#include <sys/v86.h> /* Nope */
-#endif
-#if defined(__sun) && (defined (__i386__) || defined(__i386) || defined(__x86)) && defined (SVR4)
-#include <sys/psw.h>
-#endif
-#endif /* _NEED_SYSI86 */
-
-#if defined(HAS_SVR3_MMAPDRV)
-#include <sys/sysmacros.h>
-#if !defined(_NEED_SYSI86)
-#include <sys/immu.h>
-#include <sys/region.h>
-#endif
-#include <sys/mmap.h> /* MMAP driver header */
-#endif
-
#if !defined(__sun) || defined(HAVE_SYS_VT_H)
#define HAS_USL_VTS
#endif
@@ -134,15 +104,9 @@
#endif
#include <sys/kd.h>
#include <sys/vt.h>
-
-extern _X_HIDDEN void xf86VTAcquire(int);
-extern _X_HIDDEN void xf86VTRelease(int);
#endif
#if defined(__sun)
-#include <sys/fbio.h>
-extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
-
#include <sys/kbd.h>
#include <sys/kbio.h>
@@ -151,11 +115,6 @@ extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
#undef STRING
#undef LEFTALT
#undef RIGHTALT
-
-#define LED_CAP LED_CAPS_LOCK
-#define LED_NUM LED_NUM_LOCK
-#define LED_SCR LED_SCROLL_LOCK
-#define LED_COMP LED_COMPOSE
#endif /* __sun */
#if !defined(VT_ACKACQ)
@@ -163,12 +122,10 @@ extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
#endif /* !VT_ACKACQ */
#if defined(SVR4)
-#include <sys/mman.h>
#if !(defined(__sun) && defined (SVR4))
#define DEV_MEM "/dev/pmem"
#endif
#define CLEARDTR_SUPPORT
-#define POSIX_TTY
#endif /* SVR4 */
#endif /* (SYSV || SVR4) */
@@ -190,9 +147,6 @@ extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
#include <errno.h>
-#include <sys/stat.h>
-
-#include <sys/mman.h>
#ifdef __linux__
#define HAS_USL_VTS
#include <sys/kd.h>
@@ -203,8 +157,6 @@ extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
#define CLEARDTR_SUPPORT
#endif
-#define POSIX_TTY
-
#endif /* __linux__ || __GLIBC__ */
/**************************************************************************/
@@ -217,13 +169,10 @@ extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
#include <termios.h>
#define termio termios
-#define POSIX_TTY
#include <errno.h>
#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
#endif /* CSRG_BASED */
@@ -320,8 +269,6 @@ struct pcvtid {
/* Generic */
/**************************************************************************/
-#include <sys/wait.h> /* May need to adjust this for other OSs */
-
/* For PATH_MAX */
#include "misc.h"
@@ -349,7 +296,6 @@ struct pcvtid {
#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
-#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
#endif /* _XF86_OSLIB_H */
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 05a7cd820..74b71ea34 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -87,20 +87,6 @@
#define XF86_M_RNG 0x080 /* ring */
#define XF86_M_DSR 0x100 /* data set ready */
-#ifndef NO_OSLIB_PROTOTYPES
-/*
- * This is to prevent re-entrancy to FatalError() when aborting.
- * Anything that can be called as a result of ddxGiveUp() should use this
- * instead of FatalError().
- */
-
-#define xf86FatalError(a, b) \
- if (dispatchException & DE_TERMINATE) { \
- ErrorF(a, b); \
- ErrorF("\n"); \
- return; \
- } else FatalError(a, b)
-
/***************************************************************************/
/* Prototypes */
/***************************************************************************/
@@ -119,8 +105,6 @@ extern _X_EXPORT void xf86DisableIO(void);
extern _X_EXPORT void xf86SetTVOut(int);
extern _X_EXPORT void xf86SetRGBOut(void);
#endif
-extern _X_EXPORT void xf86OSRingBell(int, int, int);
-extern _X_EXPORT void xf86SetReallySlowBcopy(void);
extern _X_EXPORT void xf86SlowBcopy(unsigned char *, unsigned char *, int);
extern _X_EXPORT int xf86OpenSerial(XF86OptionPtr options);
extern _X_EXPORT int xf86SetSerial(int fd, XF86OptionPtr options);
@@ -130,13 +114,11 @@ extern _X_EXPORT int xf86WriteSerial(int fd, const void *buf, int count);
extern _X_EXPORT int xf86CloseSerial(int fd);
extern _X_EXPORT int xf86FlushInput(int fd);
extern _X_EXPORT int xf86WaitForInput(int fd, int timeout);
-extern _X_EXPORT int xf86SerialSendBreak(int fd, int duration);
extern _X_EXPORT int xf86SetSerialModemState(int fd, int state);
extern _X_EXPORT int xf86GetSerialModemState(int fd);
extern _X_EXPORT int xf86SerialModemSetBits(int fd, int bits);
extern _X_EXPORT int xf86SerialModemClearBits(int fd, int bits);
extern _X_EXPORT int xf86LoadKernelModule(const char *pathname);
-extern _X_EXPORT void xf86OSInputThreadInit(void);
/* AGP GART interface */
@@ -156,11 +138,9 @@ extern _X_EXPORT Bool xf86AcquireGART(int screenNum);
extern _X_EXPORT Bool xf86ReleaseGART(int screenNum);
extern _X_EXPORT int xf86AllocateGARTMemory(int screenNum, unsigned long size,
int type, unsigned long *physical);
-extern _X_EXPORT Bool xf86DeallocateGARTMemory(int screenNum, int key);
extern _X_EXPORT Bool xf86BindGARTMemory(int screenNum, int key,
unsigned long offset);
extern _X_EXPORT Bool xf86UnbindGARTMemory(int screenNum, int key);
-extern _X_EXPORT Bool xf86EnableAGP(int screenNum, CARD32 mode);
extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum);
/* These routines are in shared/sigio.c and are not loaded as part of the
@@ -169,34 +149,6 @@ extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum);
wrappers than to wrap each individual function called. */
extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f) (int, void *),
void *);
-extern _X_EXPORT int xf86RemoveSIGIOHandler(int fd);
-
-#ifdef XF86_OS_PRIVS
-typedef void (*PMClose) (void);
-extern _X_EXPORT void xf86OpenConsole(void);
-extern _X_EXPORT void xf86CloseConsole(void);
-extern _X_HIDDEN Bool xf86VTActivate(int vtno);
-extern _X_EXPORT Bool xf86VTSwitchPending(void);
-extern _X_EXPORT Bool xf86VTSwitchAway(void);
-extern _X_EXPORT Bool xf86VTSwitchTo(void);
-extern _X_EXPORT void xf86VTRequest(int sig);
-extern _X_EXPORT int xf86ProcessArgument(int, char **, int);
-extern _X_EXPORT void xf86UseMsg(void);
-extern _X_EXPORT PMClose xf86OSPMOpen(void);
-
-extern _X_EXPORT void xf86InitVidMem(void);
-
-#endif /* XF86_OS_PRIVS */
-
-#ifdef XSERVER_PLATFORM_BUS
-#include "hotplug.h"
-void
-xf86PlatformDeviceProbe(struct OdevAttributes *attribs);
-
-void
-xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs);
-#endif
_XFUNCPROTOEND
-#endif /* NO_OSLIB_PROTOTYPES */
#endif /* _XF86_OSPROC_H */
diff --git a/hw/xfree86/os-support/xf86_os_support.h b/hw/xfree86/os-support/xf86_os_support.h
new file mode 100644
index 000000000..a45716cf4
--- /dev/null
+++ b/hw/xfree86/os-support/xf86_os_support.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+
+/* prototypes for the os-support layer of xfree86 DDX */
+
+#ifndef _XSERVER_XF86_OS_SUPPORT
+#define _XSERVER_XF86_OS_SUPPORT
+
+#include <X11/Xdefs.h>
+
+#include "os.h"
+
+/*
+ * This is to prevent re-entrancy to FatalError() when aborting.
+ * Anything that can be called as a result of ddxGiveUp() should use this
+ * instead of FatalError().
+ */
+
+#define xf86FatalError(a, b) \
+ if (dispatchException & DE_TERMINATE) { \
+ ErrorF(a, b); \
+ ErrorF("\n"); \
+ return; \
+ } else FatalError(a, b)
+
+typedef void (*PMClose) (void);
+
+void xf86OpenConsole(void);
+void xf86CloseConsole(void);
+Bool xf86VTActivate(int vtno);
+Bool xf86VTSwitchPending(void);
+Bool xf86VTSwitchAway(void);
+Bool xf86VTSwitchTo(void);
+void xf86VTRequest(int sig);
+int xf86ProcessArgument(int argc, char **argv, int i);
+void xf86UseMsg(void);
+PMClose xf86OSPMOpen(void);
+void xf86InitVidMem(void);
+
+void xf86OSRingBell(int volume, int pitch, int duration);
+void xf86OSInputThreadInit(void);
+Bool xf86DeallocateGARTMemory(int screenNum, int key);
+int xf86RemoveSIGIOHandler(int fd);
+
+typedef struct {
+ Bool initialised;
+} VidMemInfo, *VidMemInfoPtr;
+
+void xf86OSInitVidMem(VidMemInfoPtr);
+
+#ifdef XSERVER_PLATFORM_BUS
+#include "hotplug.h"
+void
+xf86PlatformDeviceProbe(struct OdevAttributes *attribs);
+
+void
+xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs);
+#endif
+
+#if defined(__sun)
+extern char xf86SolarisFbDev[PATH_MAX];
+
+/* these are only used inside sun-specific os-support */
+void xf86VTAcquire(int);
+void xf86VTRelease(int);
+#endif
+
+#endif /* _XSERVER_XF86_OS_SUPPORT */
diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index 6e96ba053..1c8e33dd0 100644
--- a/hw/xfree86/parser/write.c
+++ b/hw/xfree86/parser/write.c
@@ -65,13 +65,6 @@
#include <sys/wait.h>
#include <errno.h>
-#if defined(HAVE_SETEUID) && defined(_POSIX_SAVED_IDS) && _POSIX_SAVED_IDS > 0
-#define HAS_SAVED_IDS_AND_SETEUID
-#endif
-#if defined(WIN32)
-#define HAS_NO_UIDS
-#endif
-
static int
doWriteConfigFile(const char *filename, XF86ConfigPtr cptr)
{
@@ -129,42 +122,10 @@ doWriteConfigFile(const char *filename, XF86ConfigPtr cptr)
int
xf86writeConfigFile(const char *filename, XF86ConfigPtr cptr)
{
-#ifndef HAS_NO_UIDS
+#ifndef WIN32
int ret;
if (getuid() != geteuid()) {
-
-#if !defined(HAS_SAVED_IDS_AND_SETEUID)
- int pid, p;
- int status;
- void (*csig) (int);
-
- /* Need to fork to change ruid without losing euid */
- csig = OsSignal(SIGCHLD, SIG_DFL);
- switch ((pid = fork())) {
- case -1:
- ErrorF("xf86writeConfigFile(): fork failed (%s)\n",
- strerror(errno));
- return 0;
- case 0: /* child */
- if (setuid(getuid()) == -1)
- FatalError("xf86writeConfigFile(): "
- "setuid failed(%s)\n", strerror(errno));
- ret = doWriteConfigFile(filename, cptr);
- exit(ret);
- break;
- default: /* parent */
- do {
- p = waitpid(pid, &status, 0);
- } while (p == -1 && errno == EINTR);
- }
- OsSignal(SIGCHLD, csig);
- if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0)
- return 1; /* success */
- else
- return 0;
-
-#else /* HAS_SAVED_IDS_AND_SETEUID */
int ruid, euid;
ruid = getuid();
@@ -182,11 +143,8 @@ xf86writeConfigFile(const char *filename, XF86ConfigPtr cptr)
euid, strerror(errno));
}
return ret;
-
-#endif /* HAS_SAVED_IDS_AND_SETEUID */
-
}
else
-#endif /* !HAS_NO_UIDS */
+#endif /* WIN32 */
return doWriteConfigFile(filename, cptr);
}
diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h
index 397d2a14b..cb8669733 100644
--- a/hw/xfree86/ramdac/xf86CursorPriv.h
+++ b/hw/xfree86/ramdac/xf86CursorPriv.h
@@ -48,4 +48,6 @@ extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec;
#define xf86CursorScreenKey (&xf86CursorScreenKeyRec)
+extern DevScreenPrivateKeyRec xf86ScreenCursorBitsKeyRec;
+
#endif /* _XF86CURSORPRIV_H */
diff --git a/hw/xfree86/ramdac/xf86CursorRD.c b/hw/xfree86/ramdac/xf86CursorRD.c
index c8362d169..d423ad204 100644
--- a/hw/xfree86/ramdac/xf86CursorRD.c
+++ b/hw/xfree86/ramdac/xf86CursorRD.c
@@ -18,6 +18,7 @@
#include "inputstr.h"
DevPrivateKeyRec xf86CursorScreenKeyRec;
+DevScreenPrivateKeyRec xf86ScreenCursorBitsKeyRec;
/* sprite functions */
@@ -68,6 +69,10 @@ xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
if (!ScreenPriv)
return FALSE;
+ if (!dixRegisterScreenPrivateKey(&xf86ScreenCursorBitsKeyRec, pScreen,
+ PRIVATE_CURSOR, 0))
+ return FALSE;
+
dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
ScreenPriv->SWCursor = TRUE;
@@ -273,8 +278,8 @@ xf86CursorRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
xf86CursorScreenKey);
if (CursorRefCount(pCurs) <= 1)
- dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
- NULL);
+ dixSetScreenPrivate(&pCurs->devPrivates, &xf86ScreenCursorBitsKeyRec,
+ pScreen, NULL);
return (*ScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCurs);
}
@@ -288,9 +293,9 @@ xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
if (CursorRefCount(pCurs) <= 1) {
free(dixLookupScreenPrivate
- (&pCurs->devPrivates, CursorScreenKey, pScreen));
- dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
- NULL);
+ (&pCurs->devPrivates, &xf86ScreenCursorBitsKeyRec, pScreen));
+ dixSetScreenPrivate(&pCurs->devPrivates, &xf86ScreenCursorBitsKeyRec,
+ pScreen, NULL);
}
return (*ScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCurs);
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index ddba5e6c6..eba503d51 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -197,15 +197,15 @@ xf86ScreenSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
}
/*
- * Hot plugged GPU's do not have a CursorScreenKey, force sw cursor.
+ * Hot plugged GPU's do not have a xf86ScreenCursorBitsKeyRec, force sw cursor.
* This check can be removed once dix/privates.c gets relocation code for
* PRIVATE_CURSOR. Also see the related comment in AddGPUScreen().
*/
- if (!_dixGetScreenPrivateKey(CursorScreenKey, pScreen))
+ if (!_dixGetScreenPrivateKey(&xf86ScreenCursorBitsKeyRec, pScreen))
return FALSE;
- bits =
- dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen);
+ bits = dixLookupScreenPrivate(&pCurs->devPrivates,
+ &xf86ScreenCursorBitsKeyRec, pScreen);
x -= infoPtr->pScrn->frameX0;
y -= infoPtr->pScrn->frameY0;
@@ -213,8 +213,8 @@ xf86ScreenSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
if (!pCurs->bits->argb || !xf86DriverHasLoadCursorARGB(infoPtr))
if (!bits) {
bits = (*infoPtr->RealizeCursor) (infoPtr, pCurs);
- dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
- bits);
+ dixSetScreenPrivate(&pCurs->devPrivates,
+ &xf86ScreenCursorBitsKeyRec, pScreen, bits);
}
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 5fd5b5c2f..c3ed36401 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -199,7 +199,6 @@ cat > sdksyms.c << EOF
#include "mipointrst.h"
#include "mizerarc.h"
#include "micoord.h"
-#include "mifillarc.h"
#include "mistruct.h"
#include "mioverlay.h"
@@ -209,12 +208,6 @@ cat > sdksyms.c << EOF
#include "rrtransform.h"
-/* dbe/Makefile.am -- module */
-#ifdef DBE
-#include "dbestruct.h"
-#endif
-
-
/* exa/Makefile.am -- module */
/*
#include "exa.h"
@@ -231,7 +224,6 @@ cat > sdksyms.c << EOF
/* include/Makefile.am */
#include "XIstubs.h"
#include "Xprintf.h"
-#include "closestr.h"
#include "closure.h"
#include "colormap.h"
#include "colormapst.h"
@@ -271,7 +263,6 @@ cat > sdksyms.c << EOF
#include "ptrveloc.h"
#include "region.h"
#include "regionstr.h"
-#include "registry.h"
#include "resource.h"
#include "rgb.h"
#include "screenint.h"
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index f6888009c..00e30e8c9 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1,4 +1,3 @@
-
/*
*
* Copyright 1991-1999 by The XFree86 Project, Inc.
@@ -8,9 +7,6 @@
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
*/
-
-#define _NEED_SYSI86
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -1314,8 +1310,10 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
if (depth == 1) {
/* Initialise the Mono map according to which bit-plane gets used */
+ Bool flipPixels = xf86GetFlipPixels();
+
for (i = 0; i < 16; i++)
- if ((i & (1 << BIT_PLANE)) != 0)
+ if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
regp->Attribute[i] = WHITE_VALUE;
else
regp->Attribute[i] = BLACK_VALUE;
diff --git a/hw/xfree86/x86emu/prim_ops.c b/hw/xfree86/x86emu/prim_ops.c
index 47877eb26..ff25215e2 100644
--- a/hw/xfree86/x86emu/prim_ops.c
+++ b/hw/xfree86/x86emu/prim_ops.c
@@ -2475,7 +2475,7 @@ div_byte(u8 s)
}
div = dvd / (u8) s;
mod = dvd % (u8) s;
- if (abs(div) > 0xff) {
+ if (div > 0xff) {
x86emu_intr_raise(0);
return;
}
@@ -2499,7 +2499,7 @@ div_word(u16 s)
}
div = dvd / (u16) s;
mod = dvd % (u16) s;
- if (abs(div) > 0xffff) {
+ if (div > 0xffff) {
x86emu_intr_raise(0);
return;
}
diff --git a/hw/xfree86/x86emu/sys.c b/hw/xfree86/x86emu/sys.c
index 6a648bf39..5622c5fc0 100644
--- a/hw/xfree86/x86emu/sys.c
+++ b/hw/xfree86/x86emu/sys.c
@@ -65,14 +65,6 @@ struct __una_u16 {
/* Elemental unaligned loads */
-static __inline__ u64
-ldq_u(u64 * p)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
-
- return ptr->x;
-}
-
static __inline__ u32
ldl_u(u32 * p)
{
@@ -92,14 +84,6 @@ ldw_u(u16 * p)
/* Elemental unaligned stores */
static __inline__ void
-stq_u(u64 val, u64 * p)
-{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
-
- ptr->x = val;
-}
-
-static __inline__ void
stl_u(u32 val, u32 * p)
{
struct __una_u32 *ptr = (struct __una_u32 *) p;
@@ -116,15 +100,6 @@ stw_u(u16 val, u16 * p)
}
#else /* !__GNUC__ */
-static __inline__ u64
-ldq_u(u64 * p)
-{
- u64 ret;
-
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
static __inline__ u32
ldl_u(u32 * p)
{
@@ -144,14 +119,6 @@ ldw_u(u16 * p)
}
static __inline__ void
-stq_u(u64 val, u64 * p)
-{
- u64 tmp = val;
-
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void
stl_u(u32 val, u32 * p)
{
u32 tmp = val;
diff --git a/hw/xfree86/x86emu/x86emu/debug.h b/hw/xfree86/x86emu/x86emu/debug.h
index 8660ebcb6..98d85e9b9 100644
--- a/hw/xfree86/x86emu/x86emu/debug.h
+++ b/hw/xfree86/x86emu/x86emu/debug.h
@@ -39,6 +39,8 @@
#ifndef __X86EMU_DEBUG_H
#define __X86EMU_DEBUG_H
+#include <X11/Xfuncproto.h>
+
/*---------------------- Macros and type definitions ----------------------*/
/* checks to be enabled for "runtime" */
@@ -182,27 +184,18 @@
#define DB(x)
#endif
-/*-------------------------- Function Prototypes --------------------------*/
-
-#ifdef __cplusplus
-extern "C" { /* Use "C" linkage when in C++ mode */
-#endif
+void x86emu_inc_decoded_inst_len(int x);
+void x86emu_decode_printf(const char *x, ...) _X_ATTRIBUTE_PRINTF(1,2);
+void x86emu_just_disassemble(void);
+void x86emu_single_step(void);
+void x86emu_end_instr(void);
+void x86emu_dump_regs(void);
+void x86emu_dump_xregs(void);
+void x86emu_print_int_vect(u16 iv);
+void x86emu_instrument_instruction(void);
+void x86emu_check_ip_access(void);
+void x86emu_check_sp_access(void);
+void x86emu_check_mem_access(u32 p);
+void x86emu_check_data_access(uint s, uint o);
- extern void x86emu_inc_decoded_inst_len(int x);
- extern void x86emu_decode_printf(const char *x, ...) _X_ATTRIBUTE_PRINTF(1,2);
- extern void x86emu_just_disassemble(void);
- extern void x86emu_single_step(void);
- extern void x86emu_end_instr(void);
- extern void x86emu_dump_regs(void);
- extern void x86emu_dump_xregs(void);
- extern void x86emu_print_int_vect(u16 iv);
- extern void x86emu_instrument_instruction(void);
- extern void x86emu_check_ip_access(void);
- extern void x86emu_check_sp_access(void);
- extern void x86emu_check_mem_access(u32 p);
- extern void x86emu_check_data_access(uint s, uint o);
-
-#ifdef __cplusplus
-} /* End of "C" linkage for C++ */
-#endif
#endif /* __X86EMU_DEBUG_H */
diff --git a/hw/xfree86/xkb/xkbPrivate.c b/hw/xfree86/xkb/xkbPrivate.c
index 009610892..506b60bb0 100644
--- a/hw/xfree86/xkb/xkbPrivate.c
+++ b/hw/xfree86/xkb/xkbPrivate.c
@@ -10,7 +10,6 @@
#include <stdio.h>
#include <X11/X.h>
#include "windowstr.h"
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "dixgrabs.h"
diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c
index f54dbd608..76544eb2d 100644
--- a/hw/xnest/Args.c
+++ b/hw/xnest/Args.c
@@ -17,7 +17,9 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "screenint.h"
#include "input.h"
#include "misc.h"
diff --git a/hw/xnest/Args.h b/hw/xnest/Args.h
index 225418d22..2ae2984b4 100644
--- a/hw/xnest/Args.h
+++ b/hw/xnest/Args.h
@@ -15,6 +15,9 @@ is" without express or implied warranty.
#ifndef XNESTARGS_H
#define XNESTARGS_H
+#include <X11/X.h>
+#include <X11/Xdefs.h>
+
extern char *xnestDisplayName;
extern Bool xnestSynchronize;
extern Bool xnestFullGeneration;
diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c
index 3a9e42203..bb829847e 100644
--- a/hw/xnest/Color.c
+++ b/hw/xnest/Color.c
@@ -17,7 +17,9 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "scrnintstr.h"
#include "window.h"
#include "windowstr.h"
@@ -250,11 +252,11 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
if (visual == xnestDefaultVisual(pScreen))
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
- RT_COLORMAP, serverClient,
+ X11_RESTYPE_COLORMAP, serverClient,
DixUseAccess);
else
dixLookupResourceByType((void **) &pCmap,
- pScreen->defColormap, RT_COLORMAP,
+ pScreen->defColormap, X11_RESTYPE_COLORMAP,
serverClient, DixUseAccess);
XSetWindowColormap(xnestDisplay,
@@ -306,7 +308,7 @@ xnestDirectInstallColormaps(ScreenPtr pScreen)
for (i = 0; i < n; i++) {
ColormapPtr pCmap;
- dixLookupResourceByType((void **) &pCmap, pCmapIDs[i], RT_COLORMAP,
+ dixLookupResourceByType((void **) &pCmap, pCmapIDs[i], X11_RESTYPE_COLORMAP,
serverClient, DixInstallAccess);
if (pCmap)
XInstallColormap(xnestDisplay, xnestColormap(pCmap));
@@ -327,7 +329,7 @@ xnestDirectUninstallColormaps(ScreenPtr pScreen)
for (i = 0; i < n; i++) {
ColormapPtr pCmap;
- dixLookupResourceByType((void **) &pCmap, pCmapIDs[i], RT_COLORMAP,
+ dixLookupResourceByType((void **) &pCmap, pCmapIDs[i], X11_RESTYPE_COLORMAP,
serverClient, DixUninstallAccess);
if (pCmap)
XUninstallColormap(xnestDisplay, xnestColormap(pCmap));
@@ -363,7 +365,7 @@ xnestUninstallColormap(ColormapPtr pCmap)
if (pCmap->mid != pCmap->pScreen->defColormap) {
dixLookupResourceByType((void **) &pCurCmap,
pCmap->pScreen->defColormap,
- RT_COLORMAP,
+ X11_RESTYPE_COLORMAP,
serverClient, DixInstallAccess);
(*pCmap->pScreen->InstallColormap) (pCurCmap);
}
diff --git a/hw/xnest/Color.h b/hw/xnest/Color.h
index 2c4e0be2a..23f17540d 100644
--- a/hw/xnest/Color.h
+++ b/hw/xnest/Color.h
@@ -15,6 +15,9 @@ is" without express or implied warranty.
#ifndef XNESTCOLOR_H
#define XNESTCOLOR_H
+#include <X11/X.h>
+#include <X11/Xdefs.h>
+
#define DUMB_WINDOW_MANAGERS
#define MAXCMAPS 1
diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c
index 285e10ebf..fea5a959b 100644
--- a/hw/xnest/Cursor.c
+++ b/hw/xnest/Cursor.c
@@ -17,11 +17,12 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "screenint.h"
#include "input.h"
#include "misc.h"
-#include "cursor.h"
#include "cursorstr.h"
#include "scrnintstr.h"
#include "servermd.h"
@@ -156,7 +157,7 @@ xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
xnestCursorFuncPtr pScreenPriv;
pScreenPriv = (xnestCursorFuncPtr)
- dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey);
+ dixLookupPrivate(&pScreen->devPrivates, &xnestScreenCursorFuncKeyRec);
return pScreenPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
}
@@ -167,7 +168,7 @@ xnestDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
xnestCursorFuncPtr pScreenPriv;
pScreenPriv = (xnestCursorFuncPtr)
- dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey);
+ dixLookupPrivate(&pScreen->devPrivates, &xnestScreenCursorFuncKeyRec);
pScreenPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen);
}
diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index dc59c6b91..0735de772 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -21,6 +21,9 @@ is" without express or implied warranty.
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "os/osdep.h"
+
#include "screenint.h"
#include "input.h"
#include "misc.h"
@@ -41,7 +44,7 @@ XVisualInfo *xnestVisuals;
int xnestNumVisuals;
int xnestDefaultVisualIndex;
Colormap *xnestDefaultColormaps;
-static unsigned int xnestNumDefaultColormaps;
+static uint16_t xnestNumDefaultColormaps;
int *xnestDepths;
int xnestNumDepths;
XPixmapFormatValues *xnestPixmapFormats;
@@ -54,11 +57,6 @@ Pixmap xnestScreenSaverPixmap;
XlibGC xnestBitmapGC;
unsigned long xnestEventMask;
-#ifdef __SUNPRO_C
-/* prevent "Function has no return statement" error for x_io_error_handler */
-#pragma does_not_return(exit)
-#endif
-
static int _X_NORETURN
x_io_error_handler(Display * dpy)
{
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index f727557ba..88db0d18f 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -17,7 +17,9 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "screenint.h"
#include "input.h"
#include "misc.h"
@@ -208,10 +210,11 @@ xnestCollectEvents(void)
case MapNotify:
case ReparentNotify:
case UnmapNotify:
+ case NoExpose:
break;
default:
- ErrorF("xnest warning: unhandled event\n");
+ ErrorF("xnest warning: unhandled event: %d\n", X.type);
break;
}
}
diff --git a/hw/xnest/Font.c b/hw/xnest/Font.c
index 192b80f53..4a8f7d328 100644
--- a/hw/xnest/Font.c
+++ b/hw/xnest/Font.c
@@ -18,11 +18,13 @@ is" without express or implied warranty.
#include <X11/X.h>
#include <X11/Xatom.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
-#include "misc.h"
-#include "regionstr.h"
#include <X11/fonts/font.h>
#include <X11/fonts/fontstruct.h>
+
+#include "misc.h"
+#include "regionstr.h"
#include "dixfontstr.h"
#include "scrnintstr.h"
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index ecfa61e39..df12aee7d 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -17,7 +17,9 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "gcstruct.h"
#include "windowstr.h"
#include "pixmapstr.h"
diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c
index e1cf9d65f..9c35d7410 100644
--- a/hw/xnest/GCOps.c
+++ b/hw/xnest/GCOps.c
@@ -17,9 +17,11 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
-#include "regionstr.h"
#include <X11/fonts/fontstruct.h>
+
+#include "regionstr.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "windowstr.h"
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index cd4ee61f9..58255c22b 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -17,7 +17,13 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+#include <X11/fonts/fontstruct.h>
+
+#include "dix/screenint_priv.h"
+#include "os/osdep.h"
+
#include "screenint.h"
#include "input.h"
#include "misc.h"
@@ -25,7 +31,6 @@ is" without express or implied warranty.
#include "windowstr.h"
#include "servermd.h"
#include "mi.h"
-#include <X11/fonts/fontstruct.h>
#include "dixfontstr.h"
#include "Xnest.h"
diff --git a/hw/xnest/Init.h b/hw/xnest/Init.h
index 7c0291ebf..0dc143904 100644
--- a/hw/xnest/Init.h
+++ b/hw/xnest/Init.h
@@ -15,6 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTINIT_H
#define XNESTINIT_H
+#include <X11/Xdefs.h>
+
extern Bool xnestDoFullGeneration;
#endif /* XNESTINIT_H */
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index 46f257c83..7735b9310 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -21,8 +21,10 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
#include <X11/keysym.h>
+
#include "screenint.h"
#include "inputstr.h"
#include "misc.h"
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index 6514f3b31..804e8a3a3 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -17,7 +17,9 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "regionstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index ac01c248c..6eb767233 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -17,7 +17,11 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
+#include "mi/mi_priv.h"
+
#include "scrnintstr.h"
#include "dix.h"
#include "mi.h"
@@ -44,7 +48,8 @@ is" without express or implied warranty.
Window xnestDefaultWindows[MAXSCREENS];
Window xnestScreenSaverWindows[MAXSCREENS];
-DevPrivateKeyRec xnestCursorScreenKeyRec;
+DevPrivateKeyRec xnestScreenCursorFuncKeyRec;
+DevScreenPrivateKeyRec xnestScreenCursorPrivKeyRec;
ScreenPtr
xnestScreen(Window window)
@@ -155,7 +160,11 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
(&xnestColormapPrivateKeyRec, PRIVATE_COLORMAP,
sizeof(xnestPrivColormap)))
return FALSE;
- if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
+ if (!dixRegisterPrivateKey(&xnestScreenCursorFuncKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterScreenPrivateKey(&xnestScreenCursorPrivKeyRec, pScreen,
+ PRIVATE_CURSOR, 0))
return FALSE;
visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec));
@@ -237,8 +246,9 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
/* myNum */
/* id */
- miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, rootDepth, numDepths, depths, defaultVisual, /* root visual */
- numVisuals, visuals);
+ if (!miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, rootDepth, numDepths, depths, defaultVisual, /* root visual */
+ numVisuals, visuals))
+ return FALSE;
pScreen->defColormap = (Colormap) FakeClientID(0);
pScreen->minInstalledCmaps = MINCMAPS;
@@ -249,7 +259,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
pScreen->blackPixel = xnestBlackPixel;
/* GCperDepth */
/* defaultStipple */
- pScreen->devPrivate = NULL;
/* WindowPrivateLen */
/* WindowPrivateSizes */
/* totalWindowSize */
@@ -312,7 +321,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
miDCInitialize(pScreen, &xnestPointerCursorFuncs); /* init SW rendering */
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
xnestCursorFuncs.spriteFuncs = PointPriv->spriteFuncs;
- dixSetPrivate(&pScreen->devPrivates, xnestCursorScreenKey,
+ dixSetPrivate(&pScreen->devPrivates, &xnestScreenCursorFuncKeyRec,
&xnestCursorFuncs);
PointPriv->spriteFuncs = &xnestPointerSpriteFuncs;
@@ -327,9 +336,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
/* overwrite miCloseScreen with our own */
pScreen->CloseScreen = xnestCloseScreen;
- if (!miScreenDevPrivateInit(pScreen, xnestWidth, NULL))
- return FALSE;
-
/* overwrite miSetShape with our own */
pScreen->SetShape = xnestSetShape;
@@ -414,7 +420,7 @@ xnestCloseScreen(ScreenPtr pScreen)
free(pScreen->allowedDepths[i].vids);
free(pScreen->allowedDepths);
free(pScreen->visuals);
- free(pScreen->devPrivate);
+ miScreenClose(pScreen);
/*
If xnestDoFullGeneration all x resources will be destroyed upon closing
diff --git a/hw/xnest/Screen.h b/hw/xnest/Screen.h
index 17c514af7..d06338f5a 100644
--- a/hw/xnest/Screen.h
+++ b/hw/xnest/Screen.h
@@ -15,6 +15,9 @@ is" without express or implied warranty.
#ifndef XNESTSCREEN_H
#define XNESTSCREEN_H
+#include <X11/X.h>
+#include <X11/Xdefs.h>
+
extern Window xnestDefaultWindows[MAXSCREENS];
extern Window xnestScreenSaverWindows[MAXSCREENS];
diff --git a/hw/xnest/Visual.h b/hw/xnest/Visual.h
index c3ae8a19f..12f19d9ab 100644
--- a/hw/xnest/Visual.h
+++ b/hw/xnest/Visual.h
@@ -15,6 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTVISUAL_H
#define XNESTVISUAL_H
+#include <X11/X.h>
+
Visual *xnestVisual(VisualPtr pVisual);
Visual *xnestVisualFromID(ScreenPtr pScreen, VisualID visual);
Colormap xnestDefaultVisualColormap(Visual * visual);
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index d6f44a25a..932db760c 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -17,7 +17,9 @@ is" without express or implied warranty.
#endif
#include <X11/X.h>
+#include <X11/Xdefs.h>
#include <X11/Xproto.h>
+
#include "gcstruct.h"
#include "window.h"
#include "windowstr.h"
@@ -97,7 +99,7 @@ xnestCreateWindow(WindowPtr pWin)
mask |= CWColormap;
if (pWin->optional->colormap) {
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
- RT_COLORMAP, serverClient,
+ X11_RESTYPE_COLORMAP, serverClient,
DixUseAccess);
attributes.colormap = xnestColormap(pCmap);
}
@@ -110,7 +112,7 @@ xnestCreateWindow(WindowPtr pWin)
else { /* root windows have their own colormaps at creation time */
visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
- RT_COLORMAP, serverClient, DixUseAccess);
+ X11_RESTYPE_COLORMAP, serverClient, DixUseAccess);
mask |= CWColormap;
attributes.colormap = xnestColormap(pCmap);
}
@@ -332,7 +334,7 @@ xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
ColormapPtr pCmap;
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
- RT_COLORMAP, serverClient, DixUseAccess);
+ X11_RESTYPE_COLORMAP, serverClient, DixUseAccess);
attributes.colormap = xnestColormap(pCmap);
diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h
index 1a3c6f44e..727f20989 100644
--- a/hw/xnest/XNCursor.h
+++ b/hw/xnest/XNCursor.h
@@ -15,26 +15,33 @@ is" without express or implied warranty.
#ifndef XNESTCURSOR_H
#define XNESTCURSOR_H
+#include <X11/Xdefs.h>
+
#include "mipointrst.h"
typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} xnestCursorFuncRec, *xnestCursorFuncPtr;
-extern DevPrivateKeyRec xnestCursorScreenKeyRec;
+// stores xnestCursorFuncRec in screen
+extern DevPrivateKeyRec xnestScreenCursorFuncKeyRec;
-#define xnestCursorScreenKey (&xnestCursorScreenKeyRec)
extern xnestCursorFuncRec xnestCursorFuncs;
typedef struct {
Cursor cursor;
} xnestPrivCursor;
+// stores xnestPrivCursor per screen's cursor
+extern DevScreenPrivateKeyRec xnestScreenCursorPrivKeyRec;
+
#define xnestGetCursorPriv(pCursor, pScreen) ((xnestPrivCursor *) \
- dixLookupScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen))
+ dixLookupScreenPrivate(&(pCursor)->devPrivates, \
+ &xnestScreenCursorPrivKeyRec, pScreen))
#define xnestSetCursorPriv(pCursor, pScreen, v) \
- dixSetScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen, v)
+ dixSetScreenPrivate(&(pCursor)->devPrivates, \
+ &xnestScreenCursorPrivKeyRec, pScreen, v)
#define xnestCursor(pCursor, pScreen) \
(xnestGetCursorPriv(pCursor, pScreen)->cursor)
diff --git a/hw/xnest/XNFont.h b/hw/xnest/XNFont.h
index a210b1790..1c10da1ea 100644
--- a/hw/xnest/XNFont.h
+++ b/hw/xnest/XNFont.h
@@ -15,6 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTFONT_H
#define XNESTFONT_H
+#include <X11/Xdefs.h>
+
typedef struct {
XFontStruct *font_struct;
} xnestPrivFont;
diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h
index 974173e50..6a222d073 100644
--- a/hw/xnest/XNGC.h
+++ b/hw/xnest/XNGC.h
@@ -15,6 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTGC_H
#define XNESTGC_H
+#include <X11/Xdefs.h>
+
/* This file uses the GC definition form Xlib.h as XlibGC. */
typedef struct {
diff --git a/hw/xnest/XNPixmap.h b/hw/xnest/XNPixmap.h
index b7b10e907..0bd8214a5 100644
--- a/hw/xnest/XNPixmap.h
+++ b/hw/xnest/XNPixmap.h
@@ -15,6 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTPIXMAP_H
#define XNESTPIXMAP_H
+#include <X11/Xdefs.h>
+
extern DevPrivateKeyRec xnestPixmapPrivateKeyRec;
#define xnestPixmapPrivateKey (&xnestPixmapPrivateKeyRec)
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 6320ede5e..59dba01c0 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -15,6 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTWINDOW_H
#define XNESTWINDOW_H
+#include <X11/Xdefs.h>
+
typedef struct {
Window window;
Window parent;
diff --git a/hw/xquartz/NSUserDefaults+XQuartzDefaults.m b/hw/xquartz/NSUserDefaults+XQuartzDefaults.m
index bd5dd2305..ecc192197 100644
--- a/hw/xquartz/NSUserDefaults+XQuartzDefaults.m
+++ b/hw/xquartz/NSUserDefaults+XQuartzDefaults.m
@@ -96,10 +96,6 @@ NSString * const XQuartzPrefKeySyncPrimaryOnSelect = @"sync_primary_on_select";
defaults = [[[NSUserDefaults alloc] initWithSuiteName:defaultsDomain] retain];
}
- NSArray * const defaultAppsMenu = @[
- @[NSLocalizedString(@"Terminal", @"Terminal"), @"xterm", @"n"],
- ];
-
NSString *defaultWindowItemModifiers = @"command";
NSString * const defaultWindowItemModifiersLocalized = NSLocalizedString(@"window item modifiers", @"window item modifiers");
if (![defaultWindowItemModifiersLocalized isEqualToString:@"window item modifiers"]) {
@@ -107,7 +103,6 @@ NSString * const XQuartzPrefKeySyncPrimaryOnSelect = @"sync_primary_on_select";
}
NSDictionary<NSString *, id> * const defaultDefaultsDict = @{
- XQuartzPrefKeyAppsMenu : defaultAppsMenu,
XQuartzPrefKeyFakeButtons : @(NO),
// XQuartzPrefKeyFakeButton2 nil default
// XQuartzPrefKeyFakeButton3 nil default
@@ -141,6 +136,10 @@ NSString * const XQuartzPrefKeySyncPrimaryOnSelect = @"sync_primary_on_select";
};
[defaults registerDefaults:defaultDefaultsDict];
+
+ NSString * const systemDefaultsPlistPath = [@(XQUARTZ_DATA_DIR) stringByAppendingPathComponent:@"defaults.plist"];
+ NSDictionary <NSString *, id> * const systemDefaultsDict = [NSDictionary dictionaryWithContentsOfFile:systemDefaultsPlistPath];
+ [defaults registerDefaults:systemDefaultsDict];
});
return defaults;
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 3b55bb6a5..e21aed0d3 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -62,8 +62,8 @@ extern char *bundle_id_prefix;
@property (nonatomic, readwrite, strong) NSMenuItem *check_for_updates_item; // Programatically enabled
#endif
-@property (nonatomic, readwrite, strong) NSArray *apps;
-@property (nonatomic, readwrite, strong) NSMutableArray *table_apps;
+@property (nonatomic, readwrite, strong) NSArray <NSArray <NSString *> *> *apps;
+@property (nonatomic, readwrite, strong) NSMutableArray <NSMutableArray <NSString *> *> *table_apps;
@property (nonatomic, readwrite, assign) NSInteger windows_menu_nitems;
@property (nonatomic, readwrite, assign) int checked_window_item;
@property (nonatomic, readwrite, assign) x_list *pending_apps;
@@ -155,10 +155,10 @@ extern char *bundle_id_prefix;
self.apps = nil;
}
-- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
+- (void) prepend_apps_item:(NSArray <NSArray <NSString *> *> *)list index:(int)i menu:(NSMenu *)menu
{
NSString *title, *shortcut = @"";
- NSArray *group;
+ NSArray <NSString *> *group;
NSMenuItem *item;
group = [list objectAtIndex:i];
@@ -182,7 +182,7 @@ extern char *bundle_id_prefix;
[item setTag:i + 1]; /* can't be zero, so add one */
}
-- (void) install_apps_menu:(NSArray *)list
+- (void) install_apps_menu:(NSArray <NSArray <NSString *> *> *)list
{
NSMenu *menu;
int i, count;
@@ -206,7 +206,7 @@ extern char *bundle_id_prefix;
self.apps = list;
}
-- (void) set_window_menu:(NSArray *)list
+- (void) set_window_menu:(NSArray <NSArray <NSString *> *> *)list
{
NSMenu * const menu = X11App.windowsMenu;
NSMenu * const dock_menu = self.dock_menu;
@@ -302,7 +302,7 @@ extern char *bundle_id_prefix;
self.checked_window_item = n;
}
-- (void) set_apps_menu:(NSArray *)list
+- (void) set_apps_menu:(NSArray <NSArray <NSString *> *> *)list
{
[self remove_apps_menu];
[self install_apps_menu:list];
@@ -448,7 +448,7 @@ extern char *bundle_id_prefix;
{
int tag;
NSString *item;
- NSArray * const apps = self.apps;
+ NSArray <NSArray <NSString *> *> * const apps = self.apps;
tag = [sender tag] - 1;
if (apps == nil || tag < 0 || tag >= [apps count])
@@ -462,15 +462,18 @@ extern char *bundle_id_prefix;
- (IBAction) apps_table_show:sender
{
NSArray *columns;
- NSMutableArray *oldapps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const oldapps = self.table_apps;
NSTableView * const apps_table = self.apps_table;
- NSMutableArray * const table_apps = [[NSMutableArray alloc] initWithCapacity:1];
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = [[NSMutableArray alloc] initWithCapacity:1];
self.table_apps = table_apps;
- NSArray * const apps = self.apps;
- if (apps != nil)
- [table_apps addObjectsFromArray:apps];
+ NSArray <NSArray <NSString *> *> * const apps = self.apps;
+ if (apps != nil) {
+ for (NSArray <NSString *> * row in apps) {
+ [table_apps addObject:row.mutableCopy];
+ }
+ }
columns = [apps_table tableColumns];
[[columns objectAtIndex:0] setIdentifier:@"0"];
@@ -489,7 +492,7 @@ extern char *bundle_id_prefix;
- (IBAction) apps_table_done:sender
{
- NSMutableArray * const table_apps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
NSTableView * const apps_table = self.apps_table;
[apps_table deselectAll:sender]; /* flush edits? */
@@ -507,7 +510,7 @@ extern char *bundle_id_prefix;
- (IBAction) apps_table_new:sender
{
NSMutableArray *item;
- NSMutableArray * const table_apps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
NSTableView * const apps_table = self.apps_table;
int row = [apps_table selectedRow], i;
@@ -536,10 +539,10 @@ extern char *bundle_id_prefix;
- (IBAction) apps_table_duplicate:sender
{
- NSMutableArray * const table_apps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
NSTableView * const apps_table = self.apps_table;
int row = [apps_table selectedRow], i;
- NSObject *item;
+ NSMutableArray <NSString *> *item;
if (row < 0) {
[self apps_table_new:sender];
@@ -562,7 +565,7 @@ extern char *bundle_id_prefix;
- (IBAction) apps_table_delete:sender
{
- NSMutableArray * const table_apps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
NSTableView * const apps_table = self.apps_table;
int row = [apps_table selectedRow];
@@ -586,7 +589,7 @@ extern char *bundle_id_prefix;
- (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView
{
- NSMutableArray * const table_apps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
if (table_apps == nil) return 0;
return [table_apps count];
@@ -595,7 +598,7 @@ extern char *bundle_id_prefix;
- (id) tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
- NSMutableArray * const table_apps = self.table_apps;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
NSArray *item;
int col;
@@ -613,8 +616,8 @@ extern char *bundle_id_prefix;
- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
- NSMutableArray * const table_apps = self.table_apps;
- NSMutableArray *item;
+ NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps;
+ NSMutableArray <NSString *> *item;
int col;
if (table_apps == nil) return;
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index e743a861e..e0c7c505d 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -34,6 +34,8 @@
#include <dix-config.h>
#endif
+#include <errno.h>
+
#include "quartz.h"
#include "misc.h"
@@ -269,7 +271,7 @@ ProcAppleWMSelectInput(register ClientPtr client)
pHead = (WMEventPtr *)malloc(sizeof(WMEventPtr));
if (!pHead ||
!AddResource(eventResource, EventType, (void *)pHead)) {
- FreeResource(clientResource, RT_NONE);
+ FreeResource(clientResource, X11_RESTYPE_NONE);
return BadAlloc;
}
*pHead = 0;
diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 7cb59ea77..f576f7eb5 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -64,9 +64,9 @@
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>
- <string>© 2003-2022 Apple Inc.
+ <string>© 2003-2023 Apple Inc.
© 2003 XFree86 Project, Inc.
-© 2003-2022 X.org Foundation, Inc.
+© 2003-2023 X.org Foundation, Inc.
</string>
<key>NSMainNibFile</key>
<string>main</string>
diff --git a/hw/xquartz/bundle/meson.build b/hw/xquartz/bundle/meson.build
index 1305ccf23..22941203b 100644
--- a/hw/xquartz/bundle/meson.build
+++ b/hw/xquartz/bundle/meson.build
@@ -10,11 +10,7 @@ cpp_defs = [
]
if build_sparkle
-cpp_defs += [
- '-DXQUARTZ_SPARKLE',
- '-DXQUARTZ_SPARKLE_FEED_URL=@0@'.format(xquartz_sparkle_feed_url),
- '-DXQUARTZ_SPARKLE_PUBLIC_EDKEY=@0@'.format(xquartz_sparkle_public_edkey),
-]
+cpp_defs += sparkle_defs
endif
# bundle data
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index e34994673..56530ec30 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -32,8 +32,12 @@
#include <dix-config.h>
#endif
+#include <sys/stat.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "os/osdep.h"
+
#include "os.h"
#include "servermd.h"
#include "inputstr.h"
diff --git a/hw/xquartz/defaults.plist b/hw/xquartz/defaults.plist
new file mode 100644
index 000000000..957b1e0c7
--- /dev/null
+++ b/hw/xquartz/defaults.plist
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<!-- This file contains system-wide defaults for XQuartz -->
+
+<plist version="1.0">
+<dict>
+ <key>apps_menu</key>
+ <array>
+ <array>
+ <string>Terminal</string>
+ <string>xterm</string>
+ <string>n</string>
+ </array>
+ </array>
+</dict>
+</plist>
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 363bf5ac1..5c5bc70ac 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -34,6 +34,7 @@
#include <dix-config.h>
#endif
+#include <errno.h>
#include <X11/Xlib.h>
#include <assert.h>
#include <unistd.h>
@@ -72,6 +73,10 @@ FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN;
extern int noPanoramiXExtension;
+#ifdef COMPOSITE
+extern Bool noCompositeExtension;
+#endif
+
#define DEFAULT_CLIENT X11BINDIR "/xterm"
#define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz"
#define DEFAULT_SHELL "/bin/sh"
@@ -626,12 +631,20 @@ main(int argc, char **argv, char **envp)
mach_port_t mp;
kern_return_t kr;
+ /* Ignore SIGPIPE */
+ signal(SIGPIPE, SIG_IGN);
+
/* Setup our environment for our children */
setup_env();
/* The server must not run the PanoramiX operations. */
noPanoramiXExtension = TRUE;
+#ifdef COMPOSITE
+ /* https://gitlab.freedesktop.org/xorg/xserver/-/issues/1409 */
+ noCompositeExtension = TRUE;
+#endif
+
/* Setup the initial crasherporter info */
strlcpy(__crashreporter_info_buff__, __crashreporter_info__base,
sizeof(__crashreporter_info_buff__));
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index f5fef90fb..83252e805 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -52,39 +52,25 @@
#include "launchd_fd.h"
-static char x11_path[PATH_MAX + 1];
+static CFURLRef x11appURL;
+static FSRef x11_appRef;
static pid_t x11app_pid = 0;
aslclient aslc;
static void
set_x11_path(void)
{
- CFURLRef appURL = NULL;
- OSStatus osstatus =
- LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(
- kX11AppBundleId), nil, nil, &appURL);
+ OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId),
+ nil, &x11_appRef, &x11appURL);
switch (osstatus) {
case noErr:
- if (appURL == NULL) {
- asl_log(
- aslc, NULL, ASL_LEVEL_ERR,
- "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
- kX11AppBundleId);
- exit(1);
- }
-
- if (!CFURLGetFileSystemRepresentation(appURL, true,
- (unsigned char *)x11_path,
- sizeof(x11_path))) {
+ if (x11appURL == NULL) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
- "Xquartz: Error resolving URL for %s",
+ "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
kX11AppBundleId);
- exit(3);
+ exit(1);
}
-
- strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
- asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
break;
case kLSApplicationNotFoundErr:
@@ -96,8 +82,7 @@ set_x11_path(void)
default:
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Unable to find application for %s, error code = %d",
- kX11AppBundleId,
- (int)osstatus);
+ kX11AppBundleId, (int)osstatus);
exit(11);
}
}
@@ -122,18 +107,15 @@ connect_to_socket(const char *filename)
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (ret_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
- "Xquartz: Failed to create socket: %s - %s", filename,
- strerror(
- errno));
+ "Xquartz: Failed to create socket: %s - %d - %s",
+ filename, errno, strerror(errno));
return -1;
}
if (connect(ret_fd, servaddr, servaddr_len) < 0) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to connect to socket: %s - %d - %s",
- filename, errno,
- strerror(
- errno));
+ filename, errno, strerror(errno));
close(ret_fd);
return -1;
}
@@ -176,10 +158,9 @@ send_fd_handoff(int connected_fd, int launchd_fd)
*((int *)CMSG_DATA(cmsg)) = launchd_fd;
if (sendmsg(connected_fd, &msg, 0) < 0) {
- asl_log(
- aslc, NULL, ASL_LEVEL_ERR,
- "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s",
- connected_fd, errno, strerror(errno));
+ asl_log(aslc, NULL, ASL_LEVEL_ERR,
+ "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s",
+ connected_fd, errno, strerror(errno));
return;
}
@@ -253,26 +234,25 @@ main(int argc, char **argv, char **envp)
server_bootstrap_name);
set_x11_path();
- /* This forking is ugly and will be cleaned up later */
- child = fork();
- if (child == -1) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s",
- strerror(
- errno));
+ char *listenOnlyArg = "--listenonly";
+ CFStringRef silentLaunchArg = CFStringCreateWithCString(NULL, listenOnlyArg, kCFStringEncodingUTF8);
+ CFStringRef args[] = { silentLaunchArg };
+ CFArrayRef passArgv = CFArrayCreate(NULL, (const void**) args, 1, NULL);
+ LSApplicationParameters params = { 0, /* CFIndex version == 0 */
+ kLSLaunchDefaults, /* LSLaunchFlags flags */
+ &x11_appRef, /* FSRef application */
+ NULL, /* void* asyncLaunchRefCon*/
+ NULL, /* CFDictionaryRef environment */
+ passArgv, /* CFArrayRef arguments */
+ NULL /* AppleEvent* initialEvent */
+ };
+
+ OSStatus status = LSOpenApplication(&params, NULL);
+ if (status != noErr) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to launch: %d", (int)status);
return EXIT_FAILURE;
}
- if (child == 0) {
- char *_argv[3];
- _argv[0] = x11_path;
- _argv[1] = "--listenonly";
- _argv[2] = NULL;
- asl_log(aslc, NULL, ASL_LEVEL_NOTICE,
- "Xquartz: Starting X server: %s --listenonly",
- x11_path);
- return execvp(x11_path, _argv);
- }
-
/* Try connecting for 10 seconds */
for (i = 0; i < 80; i++) {
usleep(250000);
@@ -283,8 +263,7 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
- "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(
- kr));
+ "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr));
return EXIT_FAILURE;
}
}
@@ -298,13 +277,10 @@ main(int argc, char **argv, char **envp)
int handoff_fd = -1;
for (try = 0, try_max = 5; try < try_max; try++) {
- if (request_fd_handoff_socket(mp,
- handoff_socket_filename) !=
- KERN_SUCCESS) {
- asl_log(
- aslc, NULL, ASL_LEVEL_INFO,
- "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)",
- (int)try + 1, (int)try_max);
+ if (request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
+ asl_log(aslc, NULL, ASL_LEVEL_INFO,
+ "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)",
+ (int)try + 1, (int)try_max);
continue;
}
@@ -312,16 +288,13 @@ main(int argc, char **argv, char **envp)
if (handoff_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to connect to socket (try %d of %d)",
- (int)try + 1,
- (int)try_max);
+ (int)try + 1, (int)try_max);
continue;
}
- asl_log(
- aslc, NULL, ASL_LEVEL_INFO,
- "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.",
- (int)try + 1, (int)try_max, handoff_fd,
- handoff_socket_filename);
+ asl_log(aslc, NULL, ASL_LEVEL_INFO,
+ "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.",
+ (int)try + 1, (int)try_max, handoff_fd, handoff_socket_filename);
send_fd_handoff(handoff_fd, launchd_fd);
close(handoff_fd);
break;
@@ -342,8 +315,7 @@ main(int argc, char **argv, char **envp)
free(newargv);
free(newenvp);
- asl_log(aslc, NULL, ASL_LEVEL_ERR,
- "Xquartz: Memory allocation failure");
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Memory allocation failure");
return EXIT_FAILURE;
}
@@ -361,8 +333,7 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s",
- mach_error_string(
- kr));
+ mach_error_string(kr));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
diff --git a/hw/xquartz/meson.build b/hw/xquartz/meson.build
index b0c7a386e..83e79eae8 100644
--- a/hw/xquartz/meson.build
+++ b/hw/xquartz/meson.build
@@ -23,11 +23,20 @@ endif
bundle_id_def = '-DBUNDLE_ID_PREFIX="@0@"'.format(bundle_id_prefix)
bundle_root = join_paths(apple_applications_dir, apple_application_name + '.app')
+xquartz_data_dir = join_paths(get_option('prefix'), get_option('datadir'),'X11', 'XQuartz')
# using sparkle update framework?
build_sparkle = xquartz_sparkle_feed_url != '' and xquartz_sparkle_public_edkey != ''
if build_sparkle
sparkle = dependency('Sparkle', method: 'extraframework')
+
+ sparkle_defs = [
+ '-DXQUARTZ_SPARKLE',
+ '-DXQUARTZ_SPARKLE_FEED_URL=@0@'.format(xquartz_sparkle_feed_url),
+ '-DXQUARTZ_SPARKLE_PUBLIC_EDKEY=@0@'.format(xquartz_sparkle_public_edkey),
+ ]
+else
+ sparkle_defs = []
endif
# libxquartz
@@ -50,12 +59,12 @@ srcs_libxquartz = [
libxquartz_defs = [
'-DUSE_NEW_CLUT',
- '-DX11LIBDIR="@0@"'.format(join_paths(get_option('prefix'),
- get_option('libdir'))),
'-DXFree86Server',
'-DXQUARTZ',
+ '-DXQUARTZ_DATA_DIR="@0@"'.format(xquartz_data_dir),
'-DXSERVER_VERSION="@0@"'.format(meson.project_version()),
bundle_id_def,
+ sparkle_defs,
]
if cc.has_function('dispatch_async')
@@ -86,3 +95,7 @@ xquartz_man = configure_file(
configuration: manpage_config,
)
install_man(xquartz_man)
+
+install_data('defaults.plist',
+ install_dir: xquartz_data_dir,
+ install_mode: 'rw-r--r--')
diff --git a/hw/xquartz/pbproxy/meson.build b/hw/xquartz/pbproxy/meson.build
index eebb9fd70..206cbdca3 100644
--- a/hw/xquartz/pbproxy/meson.build
+++ b/hw/xquartz/pbproxy/meson.build
@@ -1,6 +1,9 @@
build_standalone_pbproxy = get_option('xpbproxy')
-pbproxy_defs = [bundle_id_def]
+pbproxy_defs = [
+ '-DXQUARTZ_DATA_DIR="@0@"'.format(xquartz_data_dir),
+ bundle_id_def
+]
if build_standalone_pbproxy
pbproxy_defs += ['-DSTANDALONE_XPBPROXY']
endif
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 732eba983..77ff84506 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -99,7 +99,7 @@ QuartzInitServer(int argc, char **argv, char **envp)
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
-#ifdef BUSFAULT
+#ifdef HAVE_SIGACTION
sigaddset(&set, SIGBUS);
#endif
pthread_sigmask(SIG_BLOCK, &set, NULL);
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index 77574655b..40422b61a 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -272,6 +272,7 @@ ProcAppleDRICreatePixmap(ClientPtr client)
xAppleDRICreatePixmapReply rep;
int width, height, pitch, bpp;
void *ptr;
+ CARD32 stringLength;
REQUEST_SIZE_MATCH(xAppleDRICreatePixmapReq);
@@ -307,6 +308,7 @@ ProcAppleDRICreatePixmap(ClientPtr client)
if (sizeof(rep) != sz_xAppleDRICreatePixmapReply)
ErrorF("error sizeof(rep) is %zu\n", sizeof(rep));
+ stringLength = rep.stringLength; /* save unswapped value */
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -319,7 +321,7 @@ ProcAppleDRICreatePixmap(ClientPtr client)
}
WriteToClient(client, sizeof(rep), &rep);
- WriteToClient(client, rep.stringLength, path);
+ WriteToClient(client, stringLength, path);
return Success;
}
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index ba84548b5..57d16d42f 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -45,10 +45,6 @@
#include <dispatch/dispatch.h>
-#ifdef DEBUG_XP_LOCK_WINDOW
-#include <execinfo.h>
-#endif
-
#define DEFINE_ATOM_HELPER(func, atom_name) \
static Atom func(void) { \
static int generation; \
@@ -353,15 +349,8 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
xp_error err;
#ifdef DEBUG_XP_LOCK_WINDOW
- void* callstack[128];
- int i, frames = backtrace(callstack, 128);
- char** strs = backtrace_symbols(callstack, frames);
-
ErrorF("=== LOCK %d ===\n", (int)x_cvt_vptr_to_uint(wid));
- for (i = 0; i < frames; ++i) {
- ErrorF(" %s\n", strs[i]);
- }
- free(strs);
+ xorg_backtrace();
#endif
err = xp_lock_window(x_cvt_vptr_to_uint(
@@ -371,6 +360,10 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
(int)x_cvt_vptr_to_uint(
wid), (int)err);
+#ifdef DEBUG_XP_LOCK_WINDOW
+ ErrorF(" bits: %p\n", *data);
+#endif
+
*pixelData = data[0];
*bytesPerRow = rowbytes[0];
}
@@ -384,15 +377,8 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
xp_error err;
#ifdef DEBUG_XP_LOCK_WINDOW
- void* callstack[128];
- int i, frames = backtrace(callstack, 128);
- char** strs = backtrace_symbols(callstack, frames);
-
ErrorF("=== UNLOCK %d ===\n", (int)x_cvt_vptr_to_uint(wid));
- for (i = 0; i < frames; ++i) {
- ErrorF(" %s\n", strs[i]);
- }
- free(strs);
+ xorg_backtrace();
#endif
err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
diff --git a/hw/xwayland/desktop/org.freedesktop.Xwayland.desktop.in b/hw/xwayland/desktop/org.freedesktop.Xwayland.desktop.in
new file mode 100644
index 000000000..106c8bc76
--- /dev/null
+++ b/hw/xwayland/desktop/org.freedesktop.Xwayland.desktop.in
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=Xwayland
+Comment=A rootful instance of the Xwayland X11 server
+Terminal=false
+Type=Application
+Categories=System;
+Exec=@XWAYLAND@ @DECORATE@ -displayfd 1
+NoDisplay=true
diff --git a/hw/xwayland/man/Xwayland.man b/hw/xwayland/man/Xwayland.man
index 2ceec9432..e30799e9a 100644
--- a/hw/xwayland/man/Xwayland.man
+++ b/hw/xwayland/man/Xwayland.man
@@ -46,12 +46,59 @@ Like all of the X servers, \fIXwayland\fP accepts the command line options
described in the \fIXserver\fP(@miscmansuffix@) manual page.
The following additional arguments are supported as well.
.TP 8
-.B \-eglstream
-Use EGLStream backend for NVidia GPUs. If \fIXwayland\fP was compiled with
-EGLStream support, this option will instruct \fIXwayland\fP to try that
-backend first, then fallback to the GBM backend if EGLStream is not supported
-by the Wayland server. Without this option, \fIXwayland\fP tries the GBM
-backend first, and fallback to EGLStream if GBM is not usable.
+.B \-decorate
+Add decorations to the Xwayland root window when running rootful.
+
+This option has no effect when \fIXwayland\fP is built without libdecor
+support (optional).
+
+This option is not compatible with rootless mode (\fI-rootless\fP).
+.TP 8
+.B \-enable-ei-portal
+Enable support for the XDG portal for input emulation.
+
+A Wayland compositor running nested should not use that command line
+option with Xwayland.
+
+This option has no effect if the compositor doesn't support the relevant
+XDG portal or if Xwayland was not compiled with EI and OEFFIS support.
+.TP 8
+.B \-fullscreen
+Set the Xwayland window fullscreen when running rootful.
+
+This option is not compatible with rootless mode (\fI-rootless\fP).
+.TP 8
+.B \-geometry \fIWxH\fP
+Sets the geometry of the \fIXwayland\fP window to \fIWxH\fP when running rootful.
+
+This option is not compatible with rootless mode (\fI-rootless\fP).
+.TP 8
+.B \-glamor " [\fIgl|es|off\fP]"
+Use given rendering API for Glamor acceleration. Possible options are \fIgl\fP and \fIes\fP.
+If \fIXwayland\fP was compiled with Glamor support, this option will instruct \fIXwayland\fP
+to use only requested API for Glamor. If this set to \fIoff\fP, effect is equal to \fI-shm\fP option.
+Without this option and without \fI-shm\fP option, \fIXwayland\fP tries the OpenGL rendering API first,
+and fallback to GL ES if GL version is less than 2.1.
+
+This option is not compatible with \fI-shm\fP option.
+.TP 8
+.B \-hidpi
+Adjust to the scale of the outputs when running rootful in windowing mode.
+
+This option is not compatible with rootless mode (\fI-rootless\fP).
+.TP 8
+.B \-host-grab
+Disable host keyboard shorcuts and confine the pointer when running rootful.
+
+This feature relies on the protocol for inhibiting the compositor keyboard
+shortcuts and on the protocol for pointer locking and confinement and may
+have no effect if the Wayland compositor in use does not support these
+protocols.
+
+Use the keys [CTRL]+[SHIFT] simultaneously to release the keyboard and
+pointer devices.
+
+This option is not compatible with rootless mode (\fI-rootless\fP).
.TP 8
.B \-initfd \fIfd\fP
Add the given \fIfd\fP as a listen socket for initialization of X clients.
@@ -75,6 +122,25 @@ support touch input.
Force additional non-native modes to be exposed when viewporter is not
supported by the Wayland compositor.
.TP 8
+.B \-nokeymap
+Instructs \fIXwayland\fP to ignore the keymap set by the Wayland compositor.
+
+By default, \fIXwayland\fP (as any Wayland client) uses the keymap set by the
+Wayland compositor using the standard Wayland protocol.
+
+This option is meant for some specific use cases where it may be desirable to
+let the X11 clients control the keymap used in Xwayland, ignoring the keymap
+specified by the Wayland compositor.
+.B \-output \fIname\fP
+Specifies on which output \fIXwayland\fP fullscreen rootful should be placed.
+The name must match the name of an existing Wayland output (output names can
+be found using wayland-info).
+
+If no matching output can be found, the Wayland compositor will decide on which
+output the fullscreen rootful \fIXwayland\fP window will be placed.
+
+This option has no effect if \fIXwayland\fP is not running fullscreen rootful.
+.TP 8
.B \-rootless
Run \fIXwayland\fP rootless, so that X clients integrate seamlessly with
Wayland clients in a Wayland desktop. That requires the Wayland server
@@ -83,6 +149,8 @@ to be an X window manager as well.
.BI \-shm
Force the shared memory backend instead of glamor (if available) for passing
buffers to the Wayland server.
+
+This option is not compatible with \fI-glamor\fP option.
.TP 8
.BR \-verbose " [\fIn\fP]"
Sets the verbosity level for information printed on stderr. If the
@@ -108,4 +176,4 @@ the name of the display of the Wayland server.
.B XWAYLAND_NO_GLAMOR
disable glamor and DRI3 support in \fIXwayland\fP, for testing purposes.
.SH "SEE ALSO"
-General information: \fIX\fP(@miscmansuffix@)
+General information: \fIX\fP(@miscmansuffix@), \fIwayland-info\fP(@miscmansuffix@)
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index 37c39497c..458f3c09e 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -7,9 +7,9 @@ srcs = [
'xwayland-drm-lease.h',
'xwayland-drm-lease.c',
'xwayland-glamor.h',
- 'xwayland-glx.h',
'xwayland-pixmap.c',
'xwayland-pixmap.h',
+ 'xwayland-present.c',
'xwayland-present.h',
'xwayland-screen.c',
'xwayland-screen.h',
@@ -31,10 +31,10 @@ srcs = [
]
scanner_dep = dependency('wayland-scanner', native: true)
-scanner = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
+scanner = find_program(scanner_dep.get_variable(pkgconfig : 'wayland_scanner'))
protocols_dep = dependency('wayland-protocols', version: wayland_protocols_req)
-protodir = protocols_dep.get_pkgconfig_variable('pkgdatadir')
+protodir = protocols_dep.get_variable(pkgconfig : 'pkgdatadir')
pointer_xml = join_paths(protodir, 'unstable', 'pointer-constraints', 'pointer-constraints-unstable-v1.xml')
relative_xml = join_paths(protodir, 'unstable', 'relative-pointer', 'relative-pointer-unstable-v1.xml')
@@ -46,6 +46,29 @@ dmabuf_xml = join_paths(protodir, 'unstable', 'linux-dmabuf', 'linux-dmabuf-unst
viewporter_xml = join_paths(protodir, 'stable', 'viewporter', 'viewporter.xml')
xdg_shell_xml = join_paths(protodir, 'stable', 'xdg-shell', 'xdg-shell.xml')
drm_lease_xml = join_paths(protodir, 'staging', 'drm-lease', 'drm-lease-v1.xml')
+shortcuts_inhibit_xml = join_paths(protodir, 'unstable', 'keyboard-shortcuts-inhibit', 'keyboard-shortcuts-inhibit-unstable-v1.xml')
+xwayland_shell_xml = join_paths(protodir, 'staging', 'xwayland-shell', 'xwayland-shell-v1.xml')
+tearing_xml = join_paths(protodir, 'staging', 'tearing-control', 'tearing-control-v1.xml')
+fractional_scale_xml = join_paths(protodir, 'staging', 'fractional-scale', 'fractional-scale-v1.xml')
+syncobj_xml = join_paths(protodir, 'staging', 'linux-drm-syncobj', 'linux-drm-syncobj-v1.xml')
+
+proto_xml = [
+ relative_xml,
+ pointer_xml,
+ gestures_xml,
+ tablet_xml,
+ kbgrab_xml,
+ xdg_output_xml,
+ dmabuf_xml,
+ viewporter_xml,
+ xdg_shell_xml,
+ drm_lease_xml,
+ shortcuts_inhibit_xml,
+ xwayland_shell_xml,
+ tearing_xml,
+ fractional_scale_xml,
+ syncobj_xml,
+]
client_header = generator(scanner,
output : '@BASENAME@-client-protocol.h',
@@ -62,50 +85,31 @@ code = generator(scanner,
output : '@BASENAME@-protocol.c',
arguments : [scanner_argument, '@INPUT@', '@OUTPUT@']
)
-srcs += client_header.process(relative_xml)
-srcs += client_header.process(pointer_xml)
-srcs += client_header.process(gestures_xml)
-srcs += client_header.process(tablet_xml)
-srcs += client_header.process(kbgrab_xml)
-srcs += client_header.process(xdg_output_xml)
-srcs += client_header.process(dmabuf_xml)
-srcs += client_header.process(viewporter_xml)
-srcs += client_header.process(xdg_shell_xml)
-srcs += client_header.process(drm_lease_xml)
-srcs += code.process(relative_xml)
-srcs += code.process(pointer_xml)
-srcs += code.process(gestures_xml)
-srcs += code.process(tablet_xml)
-srcs += code.process(kbgrab_xml)
-srcs += code.process(xdg_output_xml)
-srcs += code.process(dmabuf_xml)
-srcs += code.process(viewporter_xml)
-srcs += code.process(xdg_shell_xml)
-srcs += code.process(drm_lease_xml)
-xwayland_glamor = []
-eglstream_srcs = []
-if build_glamor
- srcs += 'xwayland-glamor.c'
- if build_glx
- srcs += 'xwayland-glx.c'
- endif
- if gbm_dep.found()
- srcs += 'xwayland-glamor-gbm.c'
- endif
- if build_eglstream
- eglstream_protodir = eglstream_dep.get_pkgconfig_variable('pkgdatadir')
- eglstream_xml = join_paths(eglstream_protodir, 'wayland-eglstream.xml')
- eglstream_controller_xml = join_paths(eglstream_protodir, 'wayland-eglstream-controller.xml')
+foreach xml : proto_xml
+ srcs += client_header.process(xml)
+ srcs += code.process(xml)
+endforeach
- srcs += client_header.process(eglstream_xml)
- srcs += client_header.process(eglstream_controller_xml)
- srcs += code.process(eglstream_xml)
- srcs += code.process(eglstream_controller_xml)
+if build_ei
+ xwayland_dep += libei_dep
+ srcs += [ 'xwayland-xtest.c', 'xwayland-xtest.h' ]
- srcs += 'xwayland-glamor-eglstream.c'
+ if build_ei_portal
+ xwayland_dep += liboeffis_dep
endif
- srcs += 'xwayland-present.c'
+endif
+
+xwayland_glamor = []
+if build_xwayland_glamor
+ srcs += [
+ 'xwayland-glamor.c',
+ 'xwayland-dmabuf.h',
+ 'xwayland-dmabuf.c',
+ 'xwayland-glamor-gbm.c',
+ 'xwayland-glamor-gbm.h'
+ ]
+
if build_xv
srcs += 'xwayland-glamor-xv.c'
endif
@@ -125,6 +129,10 @@ if libdrm_dep.found()
xwayland_dep += libdrm_dep
endif
+if have_libdecor
+ xwayland_dep += libdecor_dep
+endif
+
xwayland_server = executable(
'Xwayland',
srcs,
@@ -132,6 +140,7 @@ xwayland_server = executable(
dependencies: [
common_dep,
xwayland_dep,
+ xwaylandproto_dep,
],
link_with: [
libxserver_main,
@@ -148,20 +157,35 @@ xwayland_server = executable(
install_dir: xwayland_path
)
-xwayland_data = configuration_data()
-xwayland_data.set('prefix', get_option('prefix'))
-xwayland_data.set('exec_prefix', '${prefix}')
-xwayland_data.set('PACKAGE_VERSION', meson.project_version())
-xwayland_data.set('xwayland_path', xwayland_path)
-xwayland_data.set('have_glamor', build_glamor ? 'true' : 'false')
-xwayland_data.set('have_eglstream', build_eglstream ? 'true' : 'false')
-configure_file(
- input: 'xwayland.pc.in',
- output: 'xwayland.pc',
- configuration: xwayland_data,
- install_dir: join_paths(get_option('prefix'),
- get_option('libdir'),
- 'pkgconfig'),
+xwayland_vars = [
+ 'have_glamor=' + build_glamor.to_string(),
+ 'have_glamor_api=' + build_glamor.to_string(),
+ 'have_eglstream=false',
+ 'have_initfd=true',
+ 'have_listenfd=true',
+ 'have_verbose=true',
+ 'have_terminate_delay=true',
+ 'have_no_touch_pointer_emulation=true',
+ 'have_force_xrandr_emulation=true',
+ 'have_geometry=true',
+ 'have_fullscreen=true',
+ 'have_host_grab=true',
+ 'have_decorate=' + have_libdecor.to_string(),
+ 'have_enable_ei_portal=' + build_ei_portal.to_string(),
+ 'have_byteswappedclients=true',
+ 'have_hidpi=true',
+]
+
+pkgconfig = import('pkgconfig')
+
+pkgconfig.generate(
+ filebase: 'xwayland',
+ name: 'Xwayland',
+ description: 'X Server for Wayland',
+ variables: [
+ 'exec_prefix=${prefix}',
+ 'xwayland=' + xwayland_path / xwayland_server.name(),
+ ] + xwayland_vars,
)
xwayland_manpage = configure_file(
@@ -170,3 +194,22 @@ xwayland_manpage = configure_file(
configuration: manpage_config,
)
install_man(xwayland_manpage)
+
+desktop_data = configuration_data()
+desktop_data.set('XWAYLAND', xwayland_path / xwayland_server.name())
+desktop_data.set('DECORATE', have_libdecor ? '-decorate' : '')
+desktop_file = configure_file(
+ input: 'desktop/org.freedesktop.Xwayland.desktop.in',
+ output: 'org.freedesktop.Xwayland.desktop',
+ configuration: desktop_data,
+)
+datadir = join_paths(get_option('prefix'), get_option('datadir'))
+desktopdir = join_paths(datadir, 'applications')
+install_data(desktop_file, install_dir : desktopdir)
+
+meson.override_find_program('Xwayland', xwayland_server)
+meson.override_dependency('xwayland', declare_dependency(
+ variables: [
+ 'xwayland=' + xwayland_server.full_path(),
+ ] + xwayland_vars,
+))
diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index e3c1aaa50..9ee427063 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -156,6 +156,7 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
struct xwl_cursor *xwl_cursor, PixmapPtr pixmap)
{
struct wl_buffer *buffer;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
if (!buffer) {
@@ -164,7 +165,8 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
}
wl_surface_attach(xwl_cursor->surface, buffer, 0, 0);
- xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0,
+ wl_surface_set_buffer_scale(xwl_cursor->surface, xwl_screen->global_surface_scale);
+ xwl_surface_damage(xwl_screen, xwl_cursor->surface, 0, 0,
xwl_seat->x_cursor->bits->width,
xwl_seat->x_cursor->bits->height);
@@ -196,8 +198,10 @@ void
xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
{
struct xwl_cursor *xwl_cursor = &xwl_seat->cursor;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
PixmapPtr pixmap;
CursorPtr cursor;
+ int xhot, yhot;
if (!xwl_seat->wl_pointer)
return;
@@ -222,11 +226,14 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
xwl_cursor_copy_bits_to_pixmap(cursor, pixmap);
+ xhot = xwl_seat->x_cursor->bits->xhot / xwl_screen->global_surface_scale;
+ yhot = xwl_seat->x_cursor->bits->yhot / xwl_screen->global_surface_scale;
+
wl_pointer_set_cursor(xwl_seat->wl_pointer,
xwl_seat->pointer_enter_serial,
xwl_cursor->surface,
- xwl_seat->x_cursor->bits->xhot,
- xwl_seat->x_cursor->bits->yhot);
+ xhot,
+ yhot);
xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
}
@@ -235,9 +242,11 @@ void
xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
{
struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_cursor *xwl_cursor = &xwl_tablet_tool->cursor;
PixmapPtr pixmap;
CursorPtr cursor;
+ int xhot, yhot;
if (!xwl_seat->x_cursor) {
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
@@ -260,11 +269,14 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
xwl_cursor_copy_bits_to_pixmap(cursor, pixmap);
+ xhot = xwl_seat->x_cursor->bits->xhot / xwl_screen->global_surface_scale;
+ yhot = xwl_seat->x_cursor->bits->yhot / xwl_screen->global_surface_scale;
+
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
xwl_tablet_tool->proximity_in_serial,
xwl_cursor->surface,
- xwl_seat->x_cursor->bits->xhot,
- xwl_seat->x_cursor->bits->yhot);
+ xhot,
+ yhot);
xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
}
@@ -431,7 +443,7 @@ static miPointerScreenFuncRec xwl_pointer_screen_funcs = {
Bool
xwl_screen_init_cursor(struct xwl_screen *xwl_screen)
{
- if (!dixRegisterPrivateKey(&xwl_cursor_private_key, PRIVATE_CURSOR_BITS, 0))
+ if (!dixRegisterPrivateKey(&xwl_cursor_private_key, PRIVATE_CURSOR, 0))
return FALSE;
return miPointerInitialize(xwl_screen->screen,
diff --git a/hw/xwayland/xwayland-cvt.c b/hw/xwayland/xwayland-cvt.c
index ba8cbc9d1..4248d3869 100644
--- a/hw/xwayland/xwayland-cvt.c
+++ b/hw/xwayland/xwayland-cvt.c
@@ -29,30 +29,48 @@
#include "xwayland-cvt.h"
-RRModePtr
-xwayland_cvt(int hdisplay, int vdisplay, float vrefresh, Bool reduced,
- Bool interlaced)
+static void
+xwayland_modeinfo_from_cvt(xRRModeInfo *modeinfo,
+ int hdisplay, int vdisplay, float vrefresh,
+ Bool reduced, Bool interlaced)
{
struct libxcvt_mode_info *libxcvt_mode_info;
- char name[128];
- xRRModeInfo modeinfo;
libxcvt_mode_info =
libxcvt_gen_mode_info(hdisplay, vdisplay, vrefresh, reduced, interlaced);
- memset(&modeinfo, 0, sizeof modeinfo);
- modeinfo.width = libxcvt_mode_info->hdisplay;
- modeinfo.height = libxcvt_mode_info->vdisplay;
- modeinfo.dotClock = libxcvt_mode_info->dot_clock * 1000.0;
- modeinfo.hSyncStart = libxcvt_mode_info->hsync_start;
- modeinfo.hSyncEnd = libxcvt_mode_info->hsync_end;
- modeinfo.hTotal = libxcvt_mode_info->htotal;
- modeinfo.vSyncStart = libxcvt_mode_info->vsync_start;
- modeinfo.vSyncEnd = libxcvt_mode_info->vsync_end;
- modeinfo.vTotal = libxcvt_mode_info->vtotal;
- modeinfo.modeFlags = libxcvt_mode_info->mode_flags;
+ modeinfo->width = libxcvt_mode_info->hdisplay;
+ modeinfo->height = libxcvt_mode_info->vdisplay;
+ modeinfo->dotClock = libxcvt_mode_info->dot_clock * 1000.0;
+ modeinfo->hSyncStart = libxcvt_mode_info->hsync_start;
+ modeinfo->hSyncEnd = libxcvt_mode_info->hsync_end;
+ modeinfo->hTotal = libxcvt_mode_info->htotal;
+ modeinfo->vSyncStart = libxcvt_mode_info->vsync_start;
+ modeinfo->vSyncEnd = libxcvt_mode_info->vsync_end;
+ modeinfo->vTotal = libxcvt_mode_info->vtotal;
+ modeinfo->modeFlags = libxcvt_mode_info->mode_flags;
free(libxcvt_mode_info);
+}
+
+RRModePtr
+xwayland_cvt(int hdisplay, int vdisplay, float vrefresh, Bool reduced,
+ Bool interlaced)
+{
+ char name[128];
+ xRRModeInfo modeinfo = { 0, };
+
+ xwayland_modeinfo_from_cvt(&modeinfo,
+ hdisplay, vdisplay, vrefresh, reduced, interlaced);
+
+ /* Horizontal granularity in libxcvt is 8, so if our horizontal size is not
+ * divisible by 8, libxcvt will round it up, and we will advertise a wrong
+ * size to our XRandR clients.
+ * Force the width/height (i.e. simply increase blanking which should not
+ * hurt anything), keeping the rest of the CVT mode timings unchanged.
+ */
+ modeinfo.width = hdisplay;
+ modeinfo.height = vdisplay;
snprintf(name, sizeof name, "%dx%d",
modeinfo.width, modeinfo.height);
diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c
new file mode 100644
index 000000000..db7dc44ee
--- /dev/null
+++ b/hw/xwayland/xwayland-dmabuf.c
@@ -0,0 +1,795 @@
+/*
+ * Copyright © 2011-2014 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <xwayland-config.h>
+
+#include <sys/mman.h>
+
+#include <drm_fourcc.h>
+#include <wayland-util.h>
+
+#include "xwayland-dmabuf.h"
+#include "xwayland-glamor-gbm.h"
+#include "xwayland-screen.h"
+#include "xwayland-types.h"
+#include "xwayland-window-buffers.h"
+
+#include "drm-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+void
+xwl_device_formats_destroy(struct xwl_device_formats *dev_formats)
+{
+ for (int j = 0; j < dev_formats->num_formats; j++)
+ free(dev_formats->formats[j].modifiers);
+ free(dev_formats->formats);
+ drmFreeDevice(&dev_formats->drm_dev);
+}
+
+void
+xwl_dmabuf_feedback_clear_dev_formats(struct xwl_dmabuf_feedback *xwl_feedback)
+{
+ if (xwl_feedback->dev_formats_len == 0)
+ return;
+
+ for (int i = 0; i < xwl_feedback->dev_formats_len; i++) {
+ struct xwl_device_formats *dev_format = &xwl_feedback->dev_formats[i];
+ xwl_device_formats_destroy(dev_format);
+ }
+ free(xwl_feedback->dev_formats);
+ xwl_feedback->dev_formats = NULL;
+ xwl_feedback->dev_formats_len = 0;
+}
+
+void
+xwl_dmabuf_feedback_destroy(struct xwl_dmabuf_feedback *xwl_feedback)
+{
+ munmap(xwl_feedback->format_table.entry,
+ xwl_feedback->format_table.len * sizeof(struct xwl_format_table_entry));
+ xwl_dmabuf_feedback_clear_dev_formats(xwl_feedback);
+
+ if (xwl_feedback->dmabuf_feedback)
+ zwp_linux_dmabuf_feedback_v1_destroy(xwl_feedback->dmabuf_feedback);
+
+ xwl_feedback->dmabuf_feedback = NULL;
+ drmFreeDevice(&xwl_feedback->main_dev);
+}
+
+static Bool
+xwl_glamor_is_modifier_supported_in_formats(struct xwl_format *formats, int num_formats,
+ uint32_t format, uint64_t modifier)
+{
+ struct xwl_format *xwl_format = NULL;
+ int i;
+
+ for (i = 0; i < num_formats; i++) {
+ if (formats[i].format == format) {
+ xwl_format = &formats[i];
+ break;
+ }
+ }
+
+ if (xwl_format) {
+ for (i = 0; i < xwl_format->num_modifiers; i++) {
+ if (xwl_format->modifiers[i] == modifier) {
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+static Bool
+xwl_feedback_is_modifier_supported(struct xwl_dmabuf_feedback *xwl_feedback,
+ uint32_t format, uint64_t modifier,
+ int supports_scanout)
+{
+ for (int i = 0; i < xwl_feedback->dev_formats_len; i++) {
+ struct xwl_device_formats *dev_formats = &xwl_feedback->dev_formats[i];
+
+ if (supports_scanout && !dev_formats->supports_scanout)
+ continue;
+
+ if (xwl_glamor_is_modifier_supported_in_formats(dev_formats->formats,
+ dev_formats->num_formats,
+ format, modifier))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+Bool
+xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
+ uint32_t format, uint64_t modifier)
+{
+ struct xwl_window *xwl_window;
+
+ /*
+ * If we are using dmabuf v4, then we need to check in the main
+ * device and per-window format lists. For older protocol
+ * versions we can just check the list returned by the dmabuf.modifier
+ * events in xwl_screen
+ */
+ if (xwl_screen->dmabuf_protocol_version < 4) {
+ return xwl_glamor_is_modifier_supported_in_formats(xwl_screen->formats,
+ xwl_screen->num_formats,
+ format, modifier);
+ }
+
+ if (xwl_feedback_is_modifier_supported(&xwl_screen->default_feedback, format, modifier, FALSE))
+ return TRUE;
+
+ xorg_list_for_each_entry(xwl_window, &xwl_screen->window_list, link_window) {
+ if (xwl_feedback_is_modifier_supported(&xwl_window->feedback, format, modifier, FALSE))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+uint32_t
+wl_drm_format_for_depth(int depth)
+{
+ switch (depth) {
+ case 15:
+ return WL_DRM_FORMAT_XRGB1555;
+ case 16:
+ return WL_DRM_FORMAT_RGB565;
+ case 24:
+ return WL_DRM_FORMAT_XRGB8888;
+ case 30:
+ return WL_DRM_FORMAT_ARGB2101010;
+ default:
+ ErrorF("unexpected depth: %d\n", depth);
+ case 32:
+ return WL_DRM_FORMAT_ARGB8888;
+ }
+}
+
+static Bool
+xwl_dmabuf_get_formats(struct xwl_format *format_array, int format_array_len,
+ CARD32 *num_formats, CARD32 **formats)
+{
+ *num_formats = 0;
+ *formats = NULL;
+
+ if (format_array_len == 0)
+ return TRUE;
+
+ *formats = calloc(format_array_len, sizeof(CARD32));
+ if (*formats == NULL)
+ return FALSE;
+
+ for (int i = 0; i < format_array_len; i++)
+ (*formats)[i] = format_array[i].format;
+ *num_formats = format_array_len;
+
+ return TRUE;
+}
+
+static Bool
+xwl_dmabuf_get_formats_for_device(struct xwl_dmabuf_feedback *xwl_feedback, drmDevice *device,
+ CARD32 *num_formats, CARD32 **formats)
+{
+ CARD32 *ret = NULL;
+ uint32_t count = 0;
+
+ /* go through all matching sets of tranches for the window's device */
+ for (int i = 0; i < xwl_feedback->dev_formats_len; i++) {
+ if (drmDevicesEqual(xwl_feedback->dev_formats[i].drm_dev, device)) {
+ struct xwl_device_formats *dev_formats = &xwl_feedback->dev_formats[i];
+
+ /* Append the formats from this tranche to the list */
+ ret = xnfreallocarray(ret, count + dev_formats->num_formats, sizeof(CARD32));
+
+ for (int j = 0; j < dev_formats->num_formats; j++) {
+ Bool found = FALSE;
+
+ /* Check if this format is already present in the list */
+ for (int k = 0; k < count; k++) {
+ if (ret[k] == dev_formats->formats[j].format) {
+ found = TRUE;
+ break;
+ }
+ }
+
+ /* If this format has not yet been added, do so now */
+ if (!found)
+ ret[count++] = dev_formats->formats[j].format;
+ }
+ }
+ }
+
+ *num_formats = count;
+ *formats = ret;
+
+ return TRUE;
+}
+
+Bool
+xwl_glamor_get_formats(ScreenPtr screen,
+ CARD32 *num_formats, CARD32 **formats)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+
+ /* Explicitly zero the count as the caller may ignore the return value */
+ *num_formats = 0;
+
+ if (!xwl_screen->dmabuf)
+ return FALSE;
+
+ if (xwl_screen->dmabuf_protocol_version >= 4) {
+ drmDevice *main_dev = xwl_gbm_get_main_device(xwl_screen);
+
+ return xwl_dmabuf_get_formats_for_device(&xwl_screen->default_feedback, main_dev,
+ num_formats, formats);
+ }
+
+ return xwl_dmabuf_get_formats(xwl_screen->formats, xwl_screen->num_formats,
+ num_formats, formats);
+}
+
+static Bool
+xwl_dmabuf_get_modifiers_for_format(struct xwl_format *format_array, int num_formats,
+ uint32_t format, uint32_t *num_modifiers,
+ uint64_t **modifiers)
+{
+ struct xwl_format *xwl_format = NULL;
+ int i;
+
+ *num_modifiers = 0;
+ *modifiers = NULL;
+
+ if (num_formats == 0)
+ return TRUE;
+
+ for (i = 0; i < num_formats; i++) {
+ if (format_array[i].format == format) {
+ xwl_format = &format_array[i];
+ break;
+ }
+ }
+
+ if (!xwl_format ||
+ (xwl_format->num_modifiers == 1 &&
+ xwl_format->modifiers[0] == DRM_FORMAT_MOD_INVALID))
+ return FALSE;
+
+ *modifiers = calloc(xwl_format->num_modifiers, sizeof(uint64_t));
+ if (*modifiers == NULL)
+ return FALSE;
+
+ for (i = 0; i < xwl_format->num_modifiers; i++)
+ (*modifiers)[i] = xwl_format->modifiers[i];
+ *num_modifiers = xwl_format->num_modifiers;
+
+ return TRUE;
+}
+
+static Bool
+xwl_dmabuf_get_modifiers_for_device(struct xwl_dmabuf_feedback *feedback,
+ drmDevice *device,
+ uint32_t format, uint32_t *num_modifiers,
+ uint64_t **modifiers,
+ Bool *supports_scanout)
+{
+ /* Now try to find a matching set of tranches for the window's device */
+ for (int i = 0; i < feedback->dev_formats_len; i++) {
+ struct xwl_device_formats *dev_formats = &feedback->dev_formats[i];
+
+ if (drmDevicesEqual(dev_formats->drm_dev, device) &&
+ xwl_dmabuf_get_modifiers_for_format(dev_formats->formats,
+ dev_formats->num_formats,
+ format, num_modifiers, modifiers)) {
+ if (supports_scanout)
+ *supports_scanout = !!dev_formats->supports_scanout;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+Bool
+xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
+ uint32_t *num_modifiers, uint64_t **modifiers)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+ drmDevice *main_dev;
+
+ /* Explicitly zero the count as the caller may ignore the return value */
+ *num_modifiers = 0;
+ *modifiers = NULL;
+
+ if (!xwl_screen->dmabuf)
+ return FALSE;
+
+ if (xwl_screen->dmabuf_protocol_version >= 4) {
+ main_dev = xwl_gbm_get_main_device(xwl_screen);
+
+ return xwl_dmabuf_get_modifiers_for_device(&xwl_screen->default_feedback, main_dev,
+ format, num_modifiers, modifiers, NULL);
+ } else {
+ return xwl_dmabuf_get_modifiers_for_format(xwl_screen->formats, xwl_screen->num_formats,
+ format, num_modifiers, modifiers);
+ }
+}
+
+Bool
+xwl_glamor_get_drawable_modifiers_and_scanout(DrawablePtr drawable,
+ uint32_t format,
+ uint32_t *num_modifiers,
+ uint64_t **modifiers,
+ Bool *supports_scanout)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(drawable->pScreen);
+ struct xwl_window *xwl_window;
+ drmDevice *main_dev;
+
+ *num_modifiers = 0;
+ *modifiers = NULL;
+ if (supports_scanout)
+ *supports_scanout = FALSE;
+
+ /* We can only return per-drawable modifiers if the compositor supports feedback */
+ if (xwl_screen->dmabuf_protocol_version < 4)
+ return TRUE;
+
+ if (drawable->type != DRAWABLE_WINDOW || !xwl_screen->dmabuf)
+ return FALSE;
+
+ xwl_window = xwl_window_from_window((WindowPtr)drawable);
+
+ /* couldn't find drawable for window */
+ if (!xwl_window)
+ return FALSE;
+
+ main_dev = xwl_gbm_get_main_device(xwl_screen);
+
+ return xwl_dmabuf_get_modifiers_for_device(&xwl_window->feedback, main_dev,
+ format, num_modifiers, modifiers,
+ supports_scanout);
+
+}
+
+Bool
+xwl_glamor_get_drawable_modifiers(DrawablePtr drawable, uint32_t format,
+ uint32_t *num_modifiers, uint64_t **modifiers)
+{
+ return xwl_glamor_get_drawable_modifiers_and_scanout(drawable,
+ format, num_modifiers,
+ modifiers, NULL);
+
+}
+
+static void
+xwl_dmabuf_handle_format(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
+ uint32_t format)
+{
+}
+
+static void
+xwl_add_format_and_mod_to_list(struct xwl_format **formats,
+ uint32_t *num_formats,
+ uint32_t format,
+ uint64_t modifier)
+{
+ struct xwl_format *xwl_format = NULL;
+ int i;
+
+ for (i = 0; i < *num_formats; i++) {
+ if ((*formats)[i].format == format) {
+ xwl_format = &(*formats)[i];
+ break;
+ }
+ }
+
+ if (xwl_format == NULL) {
+ (*num_formats)++;
+ *formats = xnfrealloc(*formats, *num_formats * sizeof(*xwl_format));
+ xwl_format = &(*formats)[*num_formats - 1];
+ xwl_format->format = format;
+ xwl_format->num_modifiers = 0;
+ xwl_format->modifiers = NULL;
+ }
+
+ for (i = 0; i < xwl_format->num_modifiers; i++) {
+ /* don't add it if the modifier already exists */
+ if (xwl_format->modifiers[i] == modifier)
+ return;
+ }
+
+ xwl_format->num_modifiers++;
+ xwl_format->modifiers = xnfrealloc(xwl_format->modifiers,
+ xwl_format->num_modifiers * sizeof(uint64_t));
+ xwl_format->modifiers[xwl_format->num_modifiers - 1] = modifier;
+}
+
+static void
+xwl_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
+ uint32_t format, uint32_t modifier_hi,
+ uint32_t modifier_lo)
+{
+ struct xwl_screen *xwl_screen = data;
+
+ xwl_add_format_and_mod_to_list(&xwl_screen->formats, &xwl_screen->num_formats,
+ format,
+ ((uint64_t)modifier_hi << 32 | (uint64_t)modifier_lo));
+}
+
+static const struct zwp_linux_dmabuf_v1_listener xwl_dmabuf_listener = {
+ .format = xwl_dmabuf_handle_format,
+ .modifier = xwl_dmabuf_handle_modifier
+};
+
+/*
+ * We need to check if the compositor is resending all of the tranche
+ * information. Each tranche event will call this method to see
+ * if the existing format info should be cleared before refilling.
+ */
+static void
+xwl_check_reset_tranche_info(struct xwl_dmabuf_feedback *xwl_feedback)
+{
+ if (!xwl_feedback->feedback_done)
+ return;
+
+ xwl_feedback->feedback_done = FALSE;
+
+ xwl_dmabuf_feedback_clear_dev_formats(xwl_feedback);
+}
+
+static void
+xwl_dmabuf_feedback_main_device(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ struct wl_array *dev)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+ dev_t devid;
+
+ xwl_check_reset_tranche_info(xwl_feedback);
+
+ assert(dev->size == sizeof(dev_t));
+ memcpy(&devid, dev->data, sizeof(dev_t));
+
+ drmFreeDevice(&xwl_feedback->main_dev);
+
+ if (drmGetDeviceFromDevId(devid, 0, &xwl_feedback->main_dev) != 0)
+ ErrorF("linux_dmabuf_feedback.main_device: Failed to fetch DRM device\n");
+}
+
+static void
+xwl_dmabuf_feedback_tranche_target_device(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ struct wl_array *dev)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+ dev_t devid;
+
+ xwl_check_reset_tranche_info(xwl_feedback);
+
+ assert(dev->size == sizeof(dev_t));
+ memcpy(&devid, dev->data, sizeof(dev_t));
+
+ if (drmGetDeviceFromDevId(devid, 0, &xwl_feedback->tmp_tranche.drm_dev) != 0)
+ ErrorF("linux_dmabuf_feedback.tranche_target_device: Failed to fetch DRM device\n");
+}
+
+static void
+xwl_dmabuf_feedback_tranche_flags(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ uint32_t flags)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+
+ xwl_check_reset_tranche_info(xwl_feedback);
+
+ if (flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT)
+ xwl_feedback->tmp_tranche.supports_scanout = TRUE;
+}
+
+static void
+xwl_dmabuf_feedback_tranche_formats(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ struct wl_array *indices)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+ struct xwl_device_formats *tranche = &xwl_feedback->tmp_tranche;
+ uint16_t *index;
+
+ xwl_check_reset_tranche_info(xwl_feedback);
+
+ wl_array_for_each(index, indices) {
+ if (*index >= xwl_feedback->format_table.len) {
+ ErrorF("linux_dmabuf_feedback.tranche_formats: Index given to us by the compositor"
+ " is too large to fit in the format table\n");
+ continue;
+ }
+
+ /* Look up this format/mod in the format table */
+ struct xwl_format_table_entry *entry = &xwl_feedback->format_table.entry[*index];
+
+ /* Add it to the in-progress tranche */
+ xwl_add_format_and_mod_to_list(&tranche->formats, &tranche->num_formats,
+ entry->format,
+ entry->modifier);
+ }
+}
+
+static void
+xwl_append_to_tranche(struct xwl_device_formats *dst, struct xwl_device_formats *src)
+{
+ struct xwl_format *format;
+
+ for (int i = 0; i < src->num_formats; i++) {
+ format = &src->formats[i];
+
+ for (int j = 0; j < format->num_modifiers; j++)
+ xwl_add_format_and_mod_to_list(&dst->formats, &dst->num_formats,
+ format->format,
+ format->modifiers[j]);
+ }
+}
+
+static void
+xwl_dmabuf_feedback_tranche_done(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+ struct xwl_device_formats *tranche;
+ int appended = FALSE;
+
+ /*
+ * No need to call xwl_check_reset_tranche_info, the other events should have been
+ * triggered first
+ */
+
+ if (xwl_feedback->tmp_tranche.drm_dev == NULL) {
+ xwl_device_formats_destroy(&xwl_feedback->tmp_tranche);
+ goto out;
+ }
+
+ /*
+ * First check if there is an existing tranche for this device+flags combo. We
+ * will combine it with this tranche, since we can only send one modifier list
+ * in DRI3 but the compositor may report multiple tranches per device (KDE
+ * does this)
+ */
+ for (int i = 0; i < xwl_feedback->dev_formats_len; i++) {
+ tranche = &xwl_feedback->dev_formats[i];
+ if (tranche->supports_scanout == xwl_feedback->tmp_tranche.supports_scanout &&
+ drmDevicesEqual(tranche->drm_dev, xwl_feedback->tmp_tranche.drm_dev)) {
+ appended = TRUE;
+
+ /* Add all format/mods to this tranche */
+ xwl_append_to_tranche(tranche, &xwl_feedback->tmp_tranche);
+
+ /* Now free our temp tranche's allocations */
+ xwl_device_formats_destroy(&xwl_feedback->tmp_tranche);
+
+ break;
+ }
+ }
+
+ if (!appended) {
+ xwl_feedback->dev_formats_len++;
+ xwl_feedback->dev_formats = xnfrealloc(xwl_feedback->dev_formats,
+ sizeof(struct xwl_device_formats) *
+ xwl_feedback->dev_formats_len);
+
+ /* copy the temporary tranche into the official array */
+ memcpy(&xwl_feedback->dev_formats[xwl_feedback->dev_formats_len - 1],
+ &xwl_feedback->tmp_tranche,
+ sizeof(struct xwl_device_formats));
+ }
+
+out:
+ /* reset the tranche */
+ memset(&xwl_feedback->tmp_tranche, 0, sizeof(struct xwl_device_formats));
+}
+
+static void
+xwl_dmabuf_feedback_done(void *data, struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+
+ xwl_feedback->feedback_done = TRUE;
+ xwl_feedback->unprocessed_feedback_pending = TRUE;
+}
+
+static void
+xwl_dmabuf_feedback_format_table(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
+ int32_t fd, uint32_t size)
+{
+ struct xwl_dmabuf_feedback *xwl_feedback = data;
+ /* Unmap the old table */
+ if (xwl_feedback->format_table.entry) {
+ munmap(xwl_feedback->format_table.entry,
+ xwl_feedback->format_table.len * sizeof(struct xwl_format_table_entry));
+ }
+
+ assert(size % sizeof(struct xwl_format_table_entry) == 0);
+ xwl_feedback->format_table.len = size / sizeof(struct xwl_format_table_entry);
+ xwl_feedback->format_table.entry = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
+ close(fd);
+
+ if (xwl_feedback->format_table.entry == MAP_FAILED) {
+ ErrorF("linux_dmabuf_feedback.format_table: Could not map the format"
+ " table: Compositor bug or out of resources\n");
+ xwl_feedback->format_table.len = 0;
+ }
+}
+
+static const struct zwp_linux_dmabuf_feedback_v1_listener xwl_dmabuf_feedback_listener = {
+ .done = xwl_dmabuf_feedback_done,
+ .format_table = xwl_dmabuf_feedback_format_table,
+ .main_device = xwl_dmabuf_feedback_main_device,
+ .tranche_done = xwl_dmabuf_feedback_tranche_done,
+ .tranche_target_device = xwl_dmabuf_feedback_tranche_target_device,
+ .tranche_formats = xwl_dmabuf_feedback_tranche_formats,
+ .tranche_flags = xwl_dmabuf_feedback_tranche_flags,
+};
+
+Bool
+xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
+ uint32_t id, uint32_t version)
+{
+ /* We either support versions 3 or 4. 4 is needed for dmabuf feedback */
+ int supported_version = version >= 4 ? 4 : 3;
+
+ if (version < 3)
+ return FALSE;
+
+ xwl_screen->dmabuf =
+ wl_registry_bind(xwl_screen->registry, id, &zwp_linux_dmabuf_v1_interface, supported_version);
+ xwl_screen->dmabuf_protocol_version = supported_version;
+ zwp_linux_dmabuf_v1_add_listener(xwl_screen->dmabuf, &xwl_dmabuf_listener, xwl_screen);
+
+ /* If the compositor supports it, request the default feedback hints */
+ if (version >= 4) {
+ xwl_screen->default_feedback.dmabuf_feedback =
+ zwp_linux_dmabuf_v1_get_default_feedback(xwl_screen->dmabuf);
+ if (!xwl_screen->default_feedback.dmabuf_feedback)
+ return FALSE;
+
+ zwp_linux_dmabuf_feedback_v1_add_listener(xwl_screen->default_feedback.dmabuf_feedback,
+ &xwl_dmabuf_feedback_listener,
+ &xwl_screen->default_feedback);
+ }
+
+ return TRUE;
+}
+
+static void
+xwl_window_dmabuf_feedback_main_device(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ struct wl_array *dev)
+{
+ struct xwl_window *xwl_window = data;
+
+ xwl_dmabuf_feedback_main_device(&xwl_window->feedback, dmabuf_feedback, dev);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_target_device(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ struct wl_array *dev)
+{
+ struct xwl_window *xwl_window = data;
+
+ xwl_dmabuf_feedback_tranche_target_device(&xwl_window->feedback, dmabuf_feedback, dev);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_flags(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ uint32_t flags)
+{
+ struct xwl_window *xwl_window = data;
+
+ xwl_dmabuf_feedback_tranche_flags(&xwl_window->feedback, dmabuf_feedback, flags);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_formats(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ struct wl_array *indices)
+{
+ struct xwl_window *xwl_window = data;
+
+ xwl_dmabuf_feedback_tranche_formats(&xwl_window->feedback, dmabuf_feedback, indices);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_done(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
+{
+ struct xwl_window *xwl_window = data;
+
+ xwl_dmabuf_feedback_tranche_done(&xwl_window->feedback, dmabuf_feedback);
+}
+
+static void
+xwl_window_dmabuf_feedback_done(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
+{
+ struct xwl_window *xwl_window = data;
+ uint32_t format = wl_drm_format_for_depth(xwl_window->surface_window->drawable.depth);
+
+ xwl_dmabuf_feedback_done(&xwl_window->feedback, dmabuf_feedback);
+
+ xwl_window->has_implicit_scanout_support =
+ xwl_feedback_is_modifier_supported(&xwl_window->feedback, format,
+ DRM_FORMAT_MOD_INVALID, TRUE);
+ DebugF("XWAYLAND: Window 0x%x can%s get implicit scanout support\n",
+ xwl_window->surface_window->drawable.id,
+ xwl_window->has_implicit_scanout_support ? "" : "not");
+
+ /* If the linux-dmabuf v4 per-surface feedback changed, make sure the
+ * window buffers get re-created with appropriate parameters.
+ */
+ xwl_window_buffers_dispose(xwl_window);
+ xwl_window_realloc_pixmap(xwl_window);
+}
+
+static void
+xwl_window_dmabuf_feedback_format_table(void *data,
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+ int32_t fd, uint32_t size)
+{
+ struct xwl_window *xwl_window = data;
+
+ xwl_dmabuf_feedback_format_table(&xwl_window->feedback, dmabuf_feedback, fd, size);
+}
+
+static const struct zwp_linux_dmabuf_feedback_v1_listener xwl_window_dmabuf_feedback_listener = {
+ .done = xwl_window_dmabuf_feedback_done,
+ .format_table = xwl_window_dmabuf_feedback_format_table,
+ .main_device = xwl_window_dmabuf_feedback_main_device,
+ .tranche_done = xwl_window_dmabuf_feedback_tranche_done,
+ .tranche_target_device = xwl_window_dmabuf_feedback_tranche_target_device,
+ .tranche_formats = xwl_window_dmabuf_feedback_tranche_formats,
+ .tranche_flags = xwl_window_dmabuf_feedback_tranche_flags,
+};
+
+Bool
+xwl_dmabuf_setup_feedback_for_window(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+ xwl_window->feedback.dmabuf_feedback =
+ zwp_linux_dmabuf_v1_get_surface_feedback(xwl_screen->dmabuf, xwl_window->surface);
+
+ if (!xwl_window->feedback.dmabuf_feedback)
+ return FALSE;
+
+ zwp_linux_dmabuf_feedback_v1_add_listener(xwl_window->feedback.dmabuf_feedback,
+ &xwl_window_dmabuf_feedback_listener,
+ xwl_window);
+
+ return TRUE;
+}
diff --git a/hw/xwayland/xwayland-dmabuf.h b/hw/xwayland/xwayland-dmabuf.h
new file mode 100644
index 000000000..ca0dcd706
--- /dev/null
+++ b/hw/xwayland/xwayland-dmabuf.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2011-2014 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef XWAYLAND_DMABUF_H
+#define XWAYLAND_DMABUF_H
+
+#include <xwayland-config.h>
+
+#include <X11/X.h>
+#include <dix.h>
+#include <xf86drm.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "xwayland-types.h"
+
+struct xwl_format {
+ uint32_t format;
+ int num_modifiers;
+ uint64_t *modifiers;
+};
+
+struct xwl_format_table_entry {
+ uint32_t format;
+ uint32_t pad;
+ uint64_t modifier;
+};
+
+struct xwl_device_formats {
+ drmDevice *drm_dev;
+ uint32_t num_formats;
+ struct xwl_format *formats;
+ Bool supports_scanout;
+};
+
+struct xwl_format_table {
+ /* This is mmapped from the fd given to us by the compositor */
+ int len;
+ struct xwl_format_table_entry *entry;
+};
+
+/*
+ * Helper struct for sharing dmabuf feedback logic between
+ * a screen and a window. The screen will get the default
+ * feedback, and a window will get a per-surface feedback.
+ */
+struct xwl_dmabuf_feedback {
+ struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback;
+ struct xwl_format_table format_table;
+ drmDevice *main_dev;
+ /*
+ * This will be filled in during wl events and copied to
+ * dev_formats on dmabuf_feedback.tranche_done
+ */
+ struct xwl_device_formats tmp_tranche;
+ int feedback_done;
+ int dev_formats_len;
+ struct xwl_device_formats *dev_formats;
+ /*
+ * This flag is used to identify if the feedback
+ * has been resent. If this is true, then the xwayland
+ * clients need to be sent PresentCompleteModeSuboptimalCopy
+ * to tell them to re-request modifiers.
+ */
+ int unprocessed_feedback_pending;
+};
+
+void xwl_dmabuf_feedback_destroy(struct xwl_dmabuf_feedback *xwl_feedback);
+void xwl_dmabuf_feedback_clear_dev_formats(struct xwl_dmabuf_feedback *xwl_feedback);
+void xwl_device_formats_destroy(struct xwl_device_formats *dev_formats);
+
+Bool xwl_dmabuf_setup_feedback_for_window(struct xwl_window *xwl_window);
+Bool xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
+ uint32_t id, uint32_t version);
+Bool xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
+ uint32_t format, uint64_t modifier);
+uint32_t wl_drm_format_for_depth(int depth);
+Bool xwl_glamor_get_formats(ScreenPtr screen,
+ CARD32 *num_formats, CARD32 **formats);
+Bool xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
+ uint32_t *num_modifiers, uint64_t **modifiers);
+Bool xwl_glamor_get_drawable_modifiers_and_scanout(DrawablePtr drawable,
+ uint32_t format,
+ uint32_t *num_modifiers,
+ uint64_t **modifiers,
+ Bool *supports_scanout);
+Bool xwl_glamor_get_drawable_modifiers(DrawablePtr drawable, uint32_t format,
+ uint32_t *num_modifiers, uint64_t **modifiers);
+
+#endif /* XWAYLAND_DMABUF_H */
diff --git a/hw/xwayland/xwayland-drm-lease.c b/hw/xwayland/xwayland-drm-lease.c
index 8bbb27e70..4f9004d8c 100644
--- a/hw/xwayland/xwayland-drm-lease.c
+++ b/hw/xwayland/xwayland-drm-lease.c
@@ -31,11 +31,24 @@
#include <xf86drmMode.h>
#endif
+#include "randrstr_priv.h"
#include "xwayland-drm-lease.h"
#include "xwayland-screen.h"
#include "xwayland-output.h"
static void
+xwl_randr_lease_cleanup_outputs(RRLeasePtr rrLease)
+{
+ struct xwl_output *output;
+ int i;
+
+ for (i = 0; i < rrLease->numOutputs; ++i) {
+ output = rrLease->outputs[i]->devPrivate;
+ output->lease = NULL;
+ }
+}
+
+static void
drm_lease_handle_lease_fd(void *data,
struct wp_drm_lease_v1 *wp_drm_lease_v1,
int32_t lease_fd)
@@ -51,17 +64,12 @@ drm_lease_handle_finished(void *data,
struct wp_drm_lease_v1 *wp_drm_lease_v1)
{
struct xwl_drm_lease *lease = (struct xwl_drm_lease *)data;
- struct xwl_output *output;
- int i;
if (lease->fd >= 0) {
RRTerminateLease(lease->rrLease);
} else {
AttendClient(lease->client);
- for (i = 0; i < lease->rrLease->numOutputs; ++i) {
- output = lease->rrLease->outputs[i]->devPrivate;
- output->lease = NULL;
- }
+ xwl_randr_lease_cleanup_outputs(lease->rrLease);
}
}
@@ -164,6 +172,7 @@ xwl_randr_terminate_lease(ScreenPtr screen, RRLeasePtr lease)
struct xwl_drm_lease *lease_private = lease->devPrivate;
if (lease_private) {
+ xwl_randr_lease_cleanup_outputs(lease);
xorg_list_del(&lease_private->link);
if (lease_private->fd >= 0)
close(lease_private->fd);
@@ -180,7 +189,11 @@ lease_connector_handle_name(void *data,
struct wp_drm_lease_connector_v1 *wp_drm_lease_connector_v1,
const char *name)
{
- /* This space is deliberately left blank */
+ struct xwl_output *xwl_output = data;
+ char rr_output_name[MAX_OUTPUT_NAME] = { 0 };
+
+ snprintf(rr_output_name, MAX_OUTPUT_NAME, "lease-%s", name);
+ xwl_output_set_name(xwl_output, rr_output_name);
}
static void
@@ -336,8 +349,9 @@ drm_lease_device_handle_connector(void *data,
struct wp_drm_lease_connector_v1 *connector)
{
struct xwl_drm_lease_device *lease_device = data;
+ struct xwl_screen *xwl_screen = lease_device->xwl_screen;
struct xwl_output *xwl_output;
- char name[256];
+ char name[MAX_OUTPUT_NAME] = { 0 };
xwl_output = calloc(1, sizeof *xwl_output);
if (xwl_output == NULL) {
@@ -345,19 +359,21 @@ drm_lease_device_handle_connector(void *data,
return;
}
- snprintf(name, sizeof name, "XWAYLAND%d", xwl_get_next_output_serial());
-
xwl_output->lease_device = lease_device;
- xwl_output->xwl_screen = lease_device->xwl_screen;
+ xwl_output->xwl_screen = xwl_screen;
xwl_output->lease_connector = connector;
- xwl_output->randr_crtc = RRCrtcCreate(lease_device->xwl_screen->screen, xwl_output);
+ xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
if (!xwl_output->randr_crtc) {
ErrorF("Failed creating RandR CRTC\n");
goto err;
}
RRCrtcSetRotations(xwl_output->randr_crtc, ALL_ROTATIONS);
- xwl_output->randr_output = RROutputCreate(lease_device->xwl_screen->screen,
- name, strlen(name), xwl_output);
+ xwl_output->randr_output = RROutputCreate(xwl_screen->screen,
+ name, MAX_OUTPUT_NAME, xwl_output);
+ snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+ xwl_screen_get_next_output_serial(xwl_screen));
+ xwl_output_set_name(xwl_output, name);
+
if (!xwl_output->randr_output) {
ErrorF("Failed creating RandR Output\n");
goto err;
@@ -373,7 +389,7 @@ drm_lease_device_handle_connector(void *data,
&lease_connector_listener,
xwl_output);
- xorg_list_append(&xwl_output->link, &lease_device->xwl_screen->output_list);
+ xorg_list_append(&xwl_output->link, &xwl_screen->output_list);
return;
err:
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
deleted file mode 100644
index 9f95e6c14..000000000
--- a/hw/xwayland/xwayland-glamor-eglstream.c
+++ /dev/null
@@ -1,1123 +0,0 @@
-/*
- * Copyright © 2017 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Lyude Paul <lyude@redhat.com>
- *
- */
-
-#include <xwayland-config.h>
-
-#define MESA_EGL_NO_X11_HEADERS
-#define EGL_NO_X11
-#include <glamor_egl.h>
-#include <glamor.h>
-#include <glamor_priv.h>
-#include <glamor_transform.h>
-#include <glamor_transfer.h>
-
-#include <xf86drm.h>
-#include <dri3.h>
-#include <drm_fourcc.h>
-
-#include <epoxy/egl.h>
-
-#include "xwayland-glamor.h"
-#include "xwayland-pixmap.h"
-#include "xwayland-screen.h"
-#include "xwayland-window.h"
-
-#include "wayland-eglstream-client-protocol.h"
-#include "wayland-eglstream-controller-client-protocol.h"
-#include "linux-dmabuf-unstable-v1-client-protocol.h"
-
-struct xwl_eglstream_private {
- EGLDeviceEXT egl_device;
- struct wl_eglstream_display *display;
- struct wl_eglstream_controller *controller;
- uint32_t display_caps;
-
- EGLConfig config;
-
- Bool have_egl_damage;
- Bool have_egl_stream_flush;
-
- GLint blit_prog;
- GLuint blit_vao;
- GLuint blit_vbo;
- GLuint blit_is_rgba_pos;
-};
-
-enum xwl_pixmap_type {
- XWL_PIXMAP_EGLSTREAM, /* Pixmaps created by glamor. */
- XWL_PIXMAP_DMA_BUF, /* Pixmaps allocated through DRI3. */
-};
-
-struct xwl_pixmap {
- enum xwl_pixmap_type type;
- /* add any new <= 4-byte member here to avoid holes on 64-bit */
- struct xwl_screen *xwl_screen;
- struct wl_buffer *buffer;
- struct wl_callback *pending_cb;
- Bool wait_for_buffer_release;
-
- /* XWL_PIXMAP_EGLSTREAM. */
- EGLStreamKHR stream;
- EGLSurface surface;
-
- /* XWL_PIXMAP_DMA_BUF. */
- EGLImage image;
-};
-
-static DevPrivateKeyRec xwl_eglstream_private_key;
-
-static inline struct xwl_eglstream_private *
-xwl_eglstream_get(struct xwl_screen *xwl_screen)
-{
- return dixLookupPrivate(&xwl_screen->screen->devPrivates,
- &xwl_eglstream_private_key);
-}
-
-static GLuint
-xwl_eglstream_build_glsl_prog(GLuint vs, GLuint fs)
-{
- GLint ok;
- GLuint prog;
-
- prog = glCreateProgram();
- glAttachShader(prog, vs);
- glAttachShader(prog, fs);
-
- glLinkProgram(prog);
- glGetProgramiv(prog, GL_LINK_STATUS, &ok);
- if (!ok) {
- GLchar *info;
- GLint size;
-
- glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
- info = malloc(size);
-
- glGetProgramInfoLog(prog, size, NULL, info);
- ErrorF("Failed to link: %s\n", info);
- FatalError("GLSL link failure\n");
- }
-
- return prog;
-}
-
-static void
-xwl_eglstream_cleanup(struct xwl_screen *xwl_screen)
-{
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
-
- if (xwl_eglstream->display)
- wl_eglstream_display_destroy(xwl_eglstream->display);
- if (xwl_eglstream->controller)
- wl_eglstream_controller_destroy(xwl_eglstream->controller);
- if (xwl_eglstream->blit_prog) {
- glDeleteProgram(xwl_eglstream->blit_prog);
- glDeleteBuffers(1, &xwl_eglstream->blit_vbo);
- }
-
- free(xwl_eglstream);
-}
-
-static Bool
-xwl_glamor_egl_supports_device_probing(void)
-{
- return epoxy_has_egl_extension(NULL, "EGL_EXT_device_base");
-}
-
-static void **
-xwl_glamor_egl_get_devices(int *num_devices)
-{
- EGLDeviceEXT *devices, *tmp;
- Bool ret;
- int drm_dev_count = 0;
- int i;
-
- if (!xwl_glamor_egl_supports_device_probing())
- return NULL;
-
- /* Get the number of devices */
- ret = eglQueryDevicesEXT(0, NULL, num_devices);
- if (!ret || *num_devices < 1)
- return NULL;
-
- devices = calloc(*num_devices, sizeof(EGLDeviceEXT));
- if (!devices)
- return NULL;
-
- ret = eglQueryDevicesEXT(*num_devices, devices, num_devices);
- if (!ret)
- goto error;
-
- /* We're only ever going to care about devices that support
- * EGL_EXT_device_drm, so filter out the ones that don't
- */
- for (i = 0; i < *num_devices; i++) {
- const char *extension_str =
- eglQueryDeviceStringEXT(devices[i], EGL_EXTENSIONS);
-
- if (!epoxy_extension_in_string(extension_str, "EGL_EXT_device_drm"))
- continue;
-
- devices[drm_dev_count++] = devices[i];
- }
- if (!drm_dev_count)
- goto error;
-
- *num_devices = drm_dev_count;
- tmp = realloc(devices, sizeof(EGLDeviceEXT) * drm_dev_count);
- if (!tmp)
- goto error;
-
- devices = tmp;
-
- return devices;
-
-error:
- free(devices);
-
- return NULL;
-}
-
-static Bool
-xwl_glamor_egl_device_has_egl_extensions(void *device,
- const char **ext_list, size_t size)
-{
- EGLDisplay egl_display;
- int i;
- Bool has_exts = TRUE;
-
- egl_display = glamor_egl_get_display(EGL_PLATFORM_DEVICE_EXT, device);
- if (!egl_display || !eglInitialize(egl_display, NULL, NULL))
- return FALSE;
-
- for (i = 0; i < size; i++) {
- if (!epoxy_has_egl_extension(egl_display, ext_list[i])) {
- has_exts = FALSE;
- break;
- }
- }
-
- eglTerminate(egl_display);
- return has_exts;
-}
-
-static void
-xwl_eglstream_destroy_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
-{
- struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
-
- /* If we're using this stream in the current egl context, unbind it so the
- * driver doesn't keep it around until the next eglMakeCurrent()
- * don't have to keep it around until something else changes the surface
- */
- xwl_glamor_egl_make_current(xwl_screen);
- if (eglGetCurrentSurface(EGL_READ) == xwl_pixmap->surface ||
- eglGetCurrentSurface(EGL_DRAW) == xwl_pixmap->surface) {
- eglMakeCurrent(xwl_screen->egl_display,
- EGL_NO_SURFACE, EGL_NO_SURFACE,
- xwl_screen->egl_context);
- }
-
- if (xwl_pixmap->surface != EGL_NO_SURFACE)
- eglDestroySurface(xwl_screen->egl_display, xwl_pixmap->surface);
-
- if (xwl_pixmap->stream != EGL_NO_STREAM_KHR)
- eglDestroyStreamKHR(xwl_screen->egl_display, xwl_pixmap->stream);
-
- if (xwl_pixmap->buffer)
- wl_buffer_destroy(xwl_pixmap->buffer);
-
- if (xwl_pixmap->image != EGL_NO_IMAGE_KHR)
- eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image);
-
- free(xwl_pixmap);
-}
-
-static void
-xwl_eglstream_destroy_pending_cb(PixmapPtr pixmap)
-{
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
- if (xwl_pixmap && xwl_pixmap->pending_cb) {
- wl_callback_destroy(xwl_pixmap->pending_cb);
- xwl_pixmap->pending_cb = NULL;
- }
-}
-
-static Bool
-xwl_glamor_eglstream_destroy_pixmap(PixmapPtr pixmap)
-{
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
- if (xwl_pixmap && pixmap->refcnt == 1) {
- xwl_eglstream_destroy_pending_cb(pixmap);
- xwl_eglstream_destroy_pixmap_stream(xwl_pixmap);
- xwl_pixmap_del_buffer_release_cb(pixmap);
- }
- return glamor_destroy_pixmap(pixmap);
-}
-
-static struct wl_buffer *
-xwl_glamor_eglstream_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
-{
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
- if (!xwl_pixmap)
- return NULL;
-
- return xwl_pixmap->buffer;
-}
-
-static const char *
-xwl_eglstream_get_error_str(EGLint error)
-{
- switch (error) {
- case EGL_BAD_PARAMETER:
- return "EGL_BAD_PARAMETER";
- case EGL_BAD_ATTRIBUTE:
- return "EGL_BAD_ATTRIBUTE";
- case EGL_BAD_MATCH:
- return "EGL_BAD_MATCH";
- case EGL_BAD_ACCESS:
- return "EGL_BAD_ACCESS";
- case EGL_BAD_STATE_KHR:
- return "EGL_BAD_STATE_KHR";
- case EGL_BAD_STREAM_KHR:
- return "EGL_BAD_STREAM_KHR";
- case EGL_BAD_DISPLAY:
- return "EGL_BAD_DISPLAY";
- case EGL_NOT_INITIALIZED:
- return "EGL_NOT_INITIALIZED";
- default:
- return "Unknown error";
- }
-}
-
-static const char *
-xwl_eglstream_get_stream_state_str(EGLint state)
-{
- switch (state) {
- case EGL_STREAM_STATE_CREATED_KHR:
- return "EGL_STREAM_STATE_CREATED_KHR";
- case EGL_STREAM_STATE_CONNECTING_KHR:
- return "EGL_STREAM_STATE_CONNECTING_KHR";
- case EGL_STREAM_STATE_EMPTY_KHR:
- return "EGL_STREAM_STATE_EMPTY_KHR";
- case EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR:
- return "EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR";
- case EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR:
- return "EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR";
- case EGL_STREAM_STATE_DISCONNECTED_KHR:
- return "EGL_STREAM_STATE_DISCONNECTED_KHR";
- default:
- return "Unknown state";
- }
-}
-
-static EGLint
-xwl_eglstream_get_state(EGLDisplay egl_display, EGLStreamKHR egl_stream)
-{
- EGLint state;
-
- eglQueryStreamKHR(egl_display, egl_stream, EGL_STREAM_STATE_KHR, &state);
- if (!eglQueryStreamKHR(egl_display, egl_stream,
- EGL_STREAM_STATE_KHR, &state)) {
- EGLint state_error = eglGetError();
- ErrorF("eglstream: Failed to query state - error 0x%X: %s\n",
- state_error, xwl_eglstream_get_error_str(state_error));
- return EGL_FALSE;
- }
-
- return state;
-}
-
-
-static void
-xwl_eglstream_print_error(EGLDisplay egl_display,
- EGLStreamKHR egl_stream, EGLint error)
-{
- ErrorF("eglstream: error 0x%X: %s\n", error,
- xwl_eglstream_get_error_str(error));
-
- if (error == EGL_BAD_STATE_KHR) {
- EGLint state = xwl_eglstream_get_state(egl_display, egl_stream);
- ErrorF("eglstream: stream state 0x%X: %s\n", state,
- xwl_eglstream_get_stream_state_str(state));
- }
-}
-
-static void
-xwl_eglstream_consumer_ready_callback(void *data,
- struct wl_callback *callback,
- uint32_t time)
-{
- PixmapPtr pixmap = data;
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
- struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
-
- xwl_eglstream_destroy_pending_cb(pixmap);
-
- xwl_glamor_egl_make_current(xwl_screen);
-
- xwl_pixmap->surface = eglCreateStreamProducerSurfaceKHR(
- xwl_screen->egl_display, xwl_eglstream->config,
- xwl_pixmap->stream, (int[]) {
- EGL_WIDTH, pixmap->drawable.width,
- EGL_HEIGHT, pixmap->drawable.height,
- EGL_NONE
- });
-
- if (xwl_pixmap->surface == EGL_NO_SURFACE) {
- ErrorF("eglstream: Failed to create EGLSurface for pixmap\n");
- xwl_eglstream_print_error(xwl_screen->egl_display,
- xwl_pixmap->stream, eglGetError());
- } else {
- DebugF("eglstream: completes eglstream for pixmap %p, congrats!\n",
- pixmap);
- }
-}
-
-static const struct wl_callback_listener consumer_ready_listener = {
- xwl_eglstream_consumer_ready_callback
-};
-
-static void
-xwl_eglstream_buffer_release_callback(void *data)
-{
- PixmapPtr pixmap = data;
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
- assert(xwl_pixmap);
-
- if (xwl_pixmap->wait_for_buffer_release) {
- xwl_pixmap->wait_for_buffer_release = FALSE;
- /* drop the reference we took in the ready callback, freeing if necessary */
- dixDestroyPixmap(pixmap, 0);
- }
-}
-
-static const struct wl_buffer_listener xwl_eglstream_buffer_release_listener = {
- xwl_pixmap_buffer_release_cb,
-};
-
-static void
-xwl_eglstream_create_pixmap_and_stream(struct xwl_screen *xwl_screen,
- WindowPtr window, PixmapPtr pixmap)
-{
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
- struct xwl_pixmap *xwl_pixmap;
- struct xwl_window *xwl_window = xwl_window_from_window(window);
- struct wl_array stream_attribs;
- int stream_fd = -1;
-
- xwl_pixmap = calloc(1, sizeof(*xwl_pixmap));
- if (!xwl_pixmap)
- FatalError("Not enough memory to create pixmap\n");
- xwl_pixmap_set_private(pixmap, xwl_pixmap);
-
- xwl_pixmap->type = XWL_PIXMAP_EGLSTREAM;
- xwl_pixmap->image = EGL_NO_IMAGE;
-
- xwl_glamor_egl_make_current(xwl_screen);
-
- xwl_pixmap->wait_for_buffer_release = FALSE;
- xwl_pixmap->xwl_screen = xwl_screen;
- xwl_pixmap->surface = EGL_NO_SURFACE;
- xwl_pixmap->stream = eglCreateStreamKHR(xwl_screen->egl_display, NULL);
- if (xwl_pixmap->stream == EGL_NO_STREAM_KHR) {
- ErrorF("eglstream: Couldn't create EGL stream.\n");
- goto fail;
- }
- stream_fd = eglGetStreamFileDescriptorKHR(xwl_screen->egl_display,
- xwl_pixmap->stream);
- if (stream_fd == EGL_NO_FILE_DESCRIPTOR_KHR) {
- ErrorF("eglstream: Couldn't get EGL stream file descriptor.\n");
- goto fail;
- }
-
- wl_array_init(&stream_attribs);
- xwl_pixmap->buffer =
- wl_eglstream_display_create_stream(xwl_eglstream->display,
- pixmap->drawable.width,
- pixmap->drawable.height,
- stream_fd,
- WL_EGLSTREAM_HANDLE_TYPE_FD,
- &stream_attribs);
- if (!xwl_pixmap->buffer) {
- ErrorF("eglstream: Failed to create buffer\n");
- goto fail;
- }
-
- wl_buffer_add_listener(xwl_pixmap->buffer,
- &xwl_eglstream_buffer_release_listener,
- pixmap);
-
- xwl_pixmap_set_buffer_release_cb(pixmap,
- xwl_eglstream_buffer_release_callback,
- pixmap);
-
- wl_eglstream_controller_attach_eglstream_consumer(
- xwl_eglstream->controller, xwl_window->surface, xwl_pixmap->buffer);
-
- xwl_pixmap->pending_cb = wl_display_sync(xwl_screen->display);
- wl_callback_add_listener(xwl_pixmap->pending_cb, &consumer_ready_listener,
- pixmap);
-fail:
- if (stream_fd >= 0)
- close(stream_fd);
-}
-
-static Bool
-xwl_glamor_eglstream_allow_commits(struct xwl_window *xwl_window)
-{
- struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
- PixmapPtr pixmap =
- (*xwl_screen->screen->GetWindowPixmap)(xwl_window->window);
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
- if (xwl_pixmap) {
- if (xwl_pixmap->pending_cb) {
- /* Wait for the compositor to finish connecting the consumer for
- * this eglstream */
- return FALSE;
- }
-
- if (xwl_pixmap->surface != EGL_NO_SURFACE ||
- xwl_pixmap->type == XWL_PIXMAP_DMA_BUF) {
- return TRUE;
- }
-
- /* The pending stream got removed, we have a xwl_pixmap and
- * yet we do not have a surface.
- * So something went wrong with the surface creation, retry.
- */
- xwl_eglstream_destroy_pixmap_stream(xwl_pixmap);
- }
-
- /* Glamor pixmap has no backing stream yet; begin making one and disallow
- * commits until then
- */
- xwl_eglstream_create_pixmap_and_stream(xwl_screen, xwl_window->window,
- pixmap);
-
- return FALSE;
-}
-
-static Bool
-xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
- PixmapPtr pixmap, RegionPtr region)
-{
- struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
- struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
- BoxPtr box = RegionExtents(region);
- EGLint egl_damage[] = {
- box->x1, box->y1,
- box->x2 - box->x1, box->y2 - box->y1
- };
- GLint saved_vao;
- int status;
-
- if (xwl_pixmap->type != XWL_PIXMAP_EGLSTREAM)
- /* This can happen if a client does X11 rendering on a
- * flipping OpenGL or Vulkan window. In that case, we don't
- * need to do the copy below.
- */
- return TRUE;
-
- /* Unbind the framebuffer BEFORE binding the EGLSurface, otherwise we
- * won't actually draw to it
- */
- xwl_glamor_egl_make_current(xwl_screen);
- glamor_set_alu(xwl_screen->screen, GXcopy);
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- if (eglGetCurrentSurface(EGL_READ) != xwl_pixmap->surface ||
- eglGetCurrentSurface(EGL_DRAW) != xwl_pixmap->surface)
- eglMakeCurrent(xwl_screen->egl_display,
- xwl_pixmap->surface, xwl_pixmap->surface,
- xwl_screen->egl_context);
-
- /* Save current GL state */
- glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &saved_vao);
-
- /* Setup our GL state */
- glUseProgram(xwl_eglstream->blit_prog);
- glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
- glActiveTexture(GL_TEXTURE0);
- glBindVertexArray(xwl_eglstream->blit_vao);
- glBindTexture(GL_TEXTURE_2D, glamor_get_pixmap_texture(pixmap));
-
- glUniform1i(xwl_eglstream->blit_is_rgba_pos,
- pixmap->drawable.depth >= 32);
-
- status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- ErrorF("eglstream: Framebuffer incomplete 0x%X, not posting damage\n", status);
- status = FALSE;
- goto out;
- }
-
- /* Blit rendered image into EGLStream surface */
- glDrawBuffer(GL_BACK);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- if (xwl_eglstream->have_egl_damage)
- status = eglSwapBuffersWithDamageKHR(xwl_screen->egl_display,
- xwl_pixmap->surface,
- egl_damage, 1);
- else
- status = eglSwapBuffers(xwl_screen->egl_display,
- xwl_pixmap->surface);
-
- if (!status) {
- ErrorF("eglstream: buffer swap failed, not posting damage\n");
- goto out;
- }
-
-#ifdef EGL_NV_stream_flush
- if (xwl_eglstream->have_egl_stream_flush)
- /* block until stream state is updated on the compositor's side */
- eglStreamFlushNV(xwl_screen->egl_display,
- xwl_pixmap->stream);
-#endif
-
- if (!xwl_pixmap->wait_for_buffer_release) {
- /* hang onto the pixmap until the compositor has released it */
- pixmap->refcnt++;
- xwl_pixmap->wait_for_buffer_release = TRUE;
- }
-
-out:
- /* Restore previous state */
- glBindVertexArray(saved_vao);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- return status;
-}
-
-static Bool
-xwl_glamor_eglstream_check_flip(PixmapPtr pixmap)
-{
- return xwl_pixmap_get(pixmap)->type == XWL_PIXMAP_DMA_BUF;
-}
-
-static void
-xwl_eglstream_display_handle_caps(void *data,
- struct wl_eglstream_display *disp,
- int32_t caps)
-{
- xwl_eglstream_get(data)->display_caps = caps;
-}
-
-static void
-xwl_eglstream_display_handle_swapinterval_override(void *data,
- struct wl_eglstream_display *disp,
- int32_t swapinterval,
- struct wl_buffer *stream)
-{
-}
-
-const struct wl_eglstream_display_listener eglstream_display_listener = {
- .caps = xwl_eglstream_display_handle_caps,
- .swapinterval_override = xwl_eglstream_display_handle_swapinterval_override,
-};
-
-static Bool
-xwl_glamor_eglstream_init_wl_registry(struct xwl_screen *xwl_screen,
- struct wl_registry *wl_registry,
- uint32_t id, const char *name,
- uint32_t version)
-{
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
-
- if (strcmp(name, "wl_eglstream_display") == 0) {
- xwl_eglstream->display = wl_registry_bind(
- wl_registry, id, &wl_eglstream_display_interface, version);
-
- wl_eglstream_display_add_listener(xwl_eglstream->display,
- &eglstream_display_listener,
- xwl_screen);
- return TRUE;
- } else if (strcmp(name, "wl_eglstream_controller") == 0) {
- xwl_eglstream->controller = wl_registry_bind(
- wl_registry, id, &wl_eglstream_controller_interface, version);
- return TRUE;
- } else if (strcmp(name, "zwp_linux_dmabuf_v1") == 0) {
- xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
- return TRUE;
- }
-
- /* no match */
- return FALSE;
-}
-
-static Bool
-xwl_glamor_eglstream_has_wl_interfaces(struct xwl_screen *xwl_screen)
-{
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
-
- if (xwl_eglstream->display == NULL) {
- LogMessageVerb(X_INFO, 3,
- "glamor: 'wl_eglstream_display' not supported\n");
- return FALSE;
- }
-
- if (xwl_eglstream->controller == NULL) {
- LogMessageVerb(X_INFO, 3,
- "glamor: 'wl_eglstream_controller' not supported\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static inline void
-xwl_eglstream_init_shaders(struct xwl_screen *xwl_screen)
-{
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
- GLint fs, vs, attrib;
- GLuint vbo;
-
- const char *blit_vs_src =
- "attribute vec2 texcoord;\n"
- "attribute vec2 position;\n"
- "varying vec2 t;\n"
- "void main() {\n"
- " t = texcoord;\n"
- " gl_Position = vec4(position, 0, 1);\n"
- "}";
-
- const char *blit_fs_src =
- "varying vec2 t;\n"
- "uniform sampler2D s;\n"
- "uniform bool is_rgba;\n"
- "void main() {\n"
- " if (is_rgba)\n"
- " gl_FragColor = texture2D(s, t);\n"
- " else\n"
- " gl_FragColor = vec4(texture2D(s, t).rgb, 1.0);\n"
- "}";
-
- static const float position[] = {
- /* position */
- -1, -1,
- 1, -1,
- 1, 1,
- -1, 1,
- /* texcoord */
- 0, 1,
- 1, 1,
- 1, 0,
- 0, 0,
- };
-
- vs = glamor_compile_glsl_prog(GL_VERTEX_SHADER, blit_vs_src);
- fs = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, blit_fs_src);
-
- xwl_eglstream->blit_prog = xwl_eglstream_build_glsl_prog(vs, fs);
- glDeleteShader(vs);
- glDeleteShader(fs);
-
- /* Create the blitter's vao */
- glGenVertexArrays(1, &xwl_eglstream->blit_vao);
- glBindVertexArray(xwl_eglstream->blit_vao);
-
- /* Set the data for both position and texcoord in the vbo */
- glGenBuffers(1, &vbo);
- glBindBuffer(GL_ARRAY_BUFFER, vbo);
- glBufferData(GL_ARRAY_BUFFER, sizeof(position), position, GL_STATIC_DRAW);
- xwl_eglstream->blit_vbo = vbo;
-
- /* Define each shader attribute's data location in our vbo */
- attrib = glGetAttribLocation(xwl_eglstream->blit_prog, "position");
- glVertexAttribPointer(attrib, 2, GL_FLOAT, TRUE, 0, NULL);
- glEnableVertexAttribArray(attrib);
-
- attrib = glGetAttribLocation(xwl_eglstream->blit_prog, "texcoord");
- glVertexAttribPointer(attrib, 2, GL_FLOAT, TRUE, 0,
- (void*)(sizeof(float) * 8));
- glEnableVertexAttribArray(attrib);
-
- /* Save the location of uniforms we'll set later */
- xwl_eglstream->blit_is_rgba_pos =
- glGetUniformLocation(xwl_eglstream->blit_prog, "is_rgba");
-}
-
-static int
-xwl_dri3_open_client(ClientPtr client,
- ScreenPtr screen,
- RRProviderPtr provider,
- int *pfd)
-{
- /* Not supported with this backend. */
- return BadImplementation;
-}
-
-static PixmapPtr
-xwl_dri3_pixmap_from_fds(ScreenPtr screen,
- CARD8 num_fds, const int *fds,
- CARD16 width, CARD16 height,
- const CARD32 *strides, const CARD32 *offsets,
- CARD8 depth, CARD8 bpp,
- uint64_t modifier)
-{
- PixmapPtr pixmap;
- struct xwl_screen *xwl_screen = xwl_screen_get(screen);
- struct xwl_pixmap *xwl_pixmap;
- unsigned int texture;
- EGLint image_attribs[48];
- uint32_t mod_hi = modifier >> 32, mod_lo = modifier & 0xffffffff, format;
- int attrib = 0, i;
- struct zwp_linux_buffer_params_v1 *params;
-
- format = wl_drm_format_for_depth(depth);
- if (!xwl_glamor_is_modifier_supported(xwl_screen, format, modifier)) {
- ErrorF("glamor: unsupported format modifier\n");
- return NULL;
- }
-
- xwl_pixmap = calloc(1, sizeof (*xwl_pixmap));
- if (!xwl_pixmap)
- return NULL;
- xwl_pixmap->type = XWL_PIXMAP_DMA_BUF;
- xwl_pixmap->xwl_screen = xwl_screen;
-
- xwl_pixmap->buffer = NULL;
- xwl_pixmap->stream = EGL_NO_STREAM_KHR;
- xwl_pixmap->surface = EGL_NO_SURFACE;
-
- params = zwp_linux_dmabuf_v1_create_params(xwl_screen->dmabuf);
- for (i = 0; i < num_fds; i++) {
- zwp_linux_buffer_params_v1_add(params, fds[i], i,
- offsets[i], strides[i],
- mod_hi, mod_lo);
- }
- xwl_pixmap->buffer =
- zwp_linux_buffer_params_v1_create_immed(params, width, height,
- format, 0);
- zwp_linux_buffer_params_v1_destroy(params);
-
-
- image_attribs[attrib++] = EGL_WIDTH;
- image_attribs[attrib++] = width;
- image_attribs[attrib++] = EGL_HEIGHT;
- image_attribs[attrib++] = height;
- image_attribs[attrib++] = EGL_LINUX_DRM_FOURCC_EXT;
- image_attribs[attrib++] = drm_format_for_depth(depth, bpp);
-
- if (num_fds > 0) {
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_FD_EXT;
- image_attribs[attrib++] = fds[0];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
- image_attribs[attrib++] = offsets[0];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
- image_attribs[attrib++] = strides[0];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
- image_attribs[attrib++] = mod_hi;
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
- image_attribs[attrib++] = mod_lo;
- }
- if (num_fds > 1) {
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_FD_EXT;
- image_attribs[attrib++] = fds[1];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT;
- image_attribs[attrib++] = offsets[1];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
- image_attribs[attrib++] = strides[1];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
- image_attribs[attrib++] = mod_hi;
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
- image_attribs[attrib++] = mod_lo;
- }
- if (num_fds > 2) {
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_FD_EXT;
- image_attribs[attrib++] = fds[2];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_OFFSET_EXT;
- image_attribs[attrib++] = offsets[2];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
- image_attribs[attrib++] = strides[2];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT;
- image_attribs[attrib++] = mod_hi;
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT;
- image_attribs[attrib++] = mod_lo;
- }
- if (num_fds > 3) {
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_FD_EXT;
- image_attribs[attrib++] = fds[3];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
- image_attribs[attrib++] = offsets[3];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_PITCH_EXT;
- image_attribs[attrib++] = strides[3];
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
- image_attribs[attrib++] = mod_hi;
- image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
- image_attribs[attrib++] = mod_lo;
- }
- image_attribs[attrib++] = EGL_NONE;
-
- xwl_glamor_egl_make_current(xwl_screen);
-
- /* eglCreateImageKHR will close fds */
- xwl_pixmap->image = eglCreateImageKHR(xwl_screen->egl_display,
- EGL_NO_CONTEXT,
- EGL_LINUX_DMA_BUF_EXT,
- NULL, image_attribs);
- if (xwl_pixmap->image == EGL_NO_IMAGE_KHR) {
- ErrorF("eglCreateImageKHR failed!\n");
- if (xwl_pixmap->buffer)
- wl_buffer_destroy(xwl_pixmap->buffer);
- free(xwl_pixmap);
- return NULL;
- }
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- pixmap = glamor_create_pixmap(screen, width, height, depth,
- GLAMOR_CREATE_PIXMAP_NO_TEXTURE);
- glamor_set_pixmap_texture(pixmap, texture);
- glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
- wl_buffer_add_listener(xwl_pixmap->buffer,
- &xwl_eglstream_buffer_release_listener,
- pixmap);
- xwl_pixmap_set_private(pixmap, xwl_pixmap);
-
- return pixmap;
-}
-
-static const dri3_screen_info_rec xwl_dri3_info = {
- .version = 2,
- .open = NULL,
- .pixmap_from_fds = xwl_dri3_pixmap_from_fds,
- .fds_from_pixmap = NULL,
- .open_client = xwl_dri3_open_client,
- .get_formats = xwl_glamor_get_formats,
- .get_modifiers = xwl_glamor_get_modifiers,
- .get_drawable_modifiers = glamor_get_drawable_modifiers,
-};
-
-static Bool
-xwl_glamor_eglstream_init_egl(struct xwl_screen *xwl_screen)
-{
- struct xwl_eglstream_private *xwl_eglstream =
- xwl_eglstream_get(xwl_screen);
- EGLConfig config;
- const EGLint attrib_list[] = {
- EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
- EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
- EGL_CONTEXT_MAJOR_VERSION_KHR,
- GLAMOR_GL_CORE_VER_MAJOR,
- EGL_CONTEXT_MINOR_VERSION_KHR,
- GLAMOR_GL_CORE_VER_MINOR,
- EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
- EGL_NONE
- };
- const EGLint config_attribs[] = {
- EGL_SURFACE_TYPE, EGL_STREAM_BIT_KHR,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_NONE,
- };
- int n;
-
- xwl_screen->egl_display = glamor_egl_get_display(
- EGL_PLATFORM_DEVICE_EXT, xwl_eglstream->egl_device);
- if (!xwl_screen->egl_display)
- goto error;
-
- if (!eglInitialize(xwl_screen->egl_display, NULL, NULL)) {
- xwl_screen->egl_display = NULL;
- goto error;
- }
-
- if (!epoxy_has_egl_extension(xwl_screen->egl_display,
- "EGL_IMG_context_priority")) {
- ErrorF("EGL_IMG_context_priority not available\n");
- goto error;
- }
-
- eglChooseConfig(xwl_screen->egl_display, config_attribs, &config, 1, &n);
- if (!n) {
- ErrorF("No acceptable EGL configs found\n");
- goto error;
- }
-
- xwl_eglstream->config = config;
-#if 0
- xwl_screen->formats =
- XWL_FORMAT_RGB565 | XWL_FORMAT_XRGB8888 | XWL_FORMAT_ARGB8888;
-#endif
-
- eglBindAPI(EGL_OPENGL_API);
- xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
- EGL_NO_CONFIG_KHR,
- EGL_NO_CONTEXT,
- attrib_list);
- if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
- ErrorF("Failed to create main EGL context: 0x%x\n", eglGetError());
- goto error;
- }
-
- if (!eglMakeCurrent(xwl_screen->egl_display,
- EGL_NO_SURFACE, EGL_NO_SURFACE,
- xwl_screen->egl_context)) {
- ErrorF("Failed to make EGL context current\n");
- goto error;
- }
-
- xwl_eglstream->have_egl_damage =
- epoxy_has_egl_extension(xwl_screen->egl_display,
- "EGL_KHR_swap_buffers_with_damage");
- if (!xwl_eglstream->have_egl_damage)
- ErrorF("Driver lacks EGL_KHR_swap_buffers_with_damage, performance "
- "will be affected\n");
-
-#ifdef EGL_NV_stream_flush
- xwl_eglstream->have_egl_stream_flush =
- epoxy_has_egl_extension(xwl_screen->egl_display,
- "EGL_NV_stream_flush");
-#else
- xwl_eglstream->have_egl_stream_flush = FALSE;
-#endif /* EGL_NV_stream_flush */
-
- if (!xwl_eglstream->have_egl_stream_flush)
- ErrorF("EGL_NV_stream_flush not available, "
- "this may cause visible corruption.\n");
-
- xwl_eglstream_init_shaders(xwl_screen);
-
- if (epoxy_has_gl_extension("GL_OES_EGL_image")) {
- if (dri3_screen_init(xwl_screen->screen, &xwl_dri3_info))
- xwl_screen->glvnd_vendor = "nvidia";
- else
- ErrorF("DRI3 initialization failed. Performance will be affected.\n");
- } else {
- ErrorF("Driver lacks GL_OES_EGL_image, performance will be affected.\n");
- }
-
- return TRUE;
-error:
- xwl_eglstream_cleanup(xwl_screen);
- return FALSE;
-}
-
-static Bool
-xwl_glamor_eglstream_init_screen(struct xwl_screen *xwl_screen)
-{
- ScreenPtr screen = xwl_screen->screen;
-
- /* We can just let glamor handle CreatePixmap */
- screen->DestroyPixmap = xwl_glamor_eglstream_destroy_pixmap;
-
- return TRUE;
-}
-
-static EGLDeviceEXT
-xwl_eglstream_get_device(struct xwl_screen *xwl_screen)
-{
- void **devices = NULL;
- const char *exts[] = {
- "EGL_KHR_stream",
- "EGL_KHR_stream_producer_eglsurface",
- };
- int num_devices, i;
- EGLDeviceEXT device = EGL_NO_DEVICE_EXT;
-
- /* No device specified by the user, so find one ourselves */
- devices = xwl_glamor_egl_get_devices(&num_devices);
- if (!devices)
- goto out;
-
- for (i = 0; i < num_devices; i++) {
- if (xwl_glamor_egl_device_has_egl_extensions(devices[i], exts,
- ARRAY_SIZE(exts))) {
- device = devices[i];
- break;
- }
- }
-
- free(devices);
-out:
- if (!device)
- LogMessageVerb(X_INFO, 3, "glamor: No eglstream capable devices found\n");
- return device;
-}
-
-void
-xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
-{
- struct xwl_eglstream_private *xwl_eglstream;
- EGLDeviceEXT egl_device;
-
- xwl_screen->eglstream_backend.is_available = FALSE;
- egl_device = xwl_eglstream_get_device(xwl_screen);
- if (egl_device == EGL_NO_DEVICE_EXT)
- return;
-
- if (!dixRegisterPrivateKey(&xwl_eglstream_private_key, PRIVATE_SCREEN, 0))
- return;
-
- xwl_eglstream = calloc(1, sizeof(*xwl_eglstream));
- if (!xwl_eglstream) {
- ErrorF("Failed to allocate memory required to init EGLStream support\n");
- return;
- }
-
- dixSetPrivate(&xwl_screen->screen->devPrivates,
- &xwl_eglstream_private_key, xwl_eglstream);
-
- xwl_eglstream->egl_device = egl_device;
-
- xwl_screen->eglstream_backend.init_egl = xwl_glamor_eglstream_init_egl;
- xwl_screen->eglstream_backend.init_wl_registry = xwl_glamor_eglstream_init_wl_registry;
- xwl_screen->eglstream_backend.has_wl_interfaces = xwl_glamor_eglstream_has_wl_interfaces;
- xwl_screen->eglstream_backend.init_screen = xwl_glamor_eglstream_init_screen;
- xwl_screen->eglstream_backend.get_wl_buffer_for_pixmap = xwl_glamor_eglstream_get_wl_buffer_for_pixmap;
- xwl_screen->eglstream_backend.post_damage = xwl_glamor_eglstream_post_damage;
- xwl_screen->eglstream_backend.allow_commits = xwl_glamor_eglstream_allow_commits;
- xwl_screen->eglstream_backend.check_flip = xwl_glamor_eglstream_check_flip;
- xwl_screen->eglstream_backend.is_available = TRUE;
- xwl_screen->eglstream_backend.backend_flags = XWL_EGL_BACKEND_NO_FLAG;
-}
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 60c63ba99..570fbc54a 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -35,6 +35,11 @@
#include <sys/stat.h>
#include <xf86drm.h>
#include <drm_fourcc.h>
+#if defined(__linux__)
+#include <linux/dma-buf.h>
+#include <linux/sync_file.h>
+#include <sys/ioctl.h>
+#endif
#define MESA_EGL_NO_X11_HEADERS
#define EGL_NO_X11
@@ -47,20 +52,28 @@
#include "drm-client-protocol.h"
#include "xwayland-glamor.h"
+#include "xwayland-glamor-gbm.h"
#include "xwayland-pixmap.h"
#include "xwayland-screen.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
+#include "linux-drm-syncobj-v1-client-protocol.h"
struct xwl_gbm_private {
+ drmDevice *device;
char *device_name;
struct gbm_device *gbm;
- struct wl_drm *drm;
int drm_fd;
- int fd_render_node;
+ Bool fd_render_node;
Bool drm_authenticated;
+ Bool dmabuf_capable;
+ Bool glamor_gles;
+ Bool implicit_sync;
+ Bool supports_syncobjs;
+
+ /* Set if wl_drm is available */
+ struct wl_drm *drm;
uint32_t capabilities;
- int dmabuf_capable;
};
struct xwl_pixmap {
@@ -68,6 +81,7 @@ struct xwl_pixmap {
EGLImage image;
unsigned int texture;
struct gbm_bo *bo;
+ Bool implicit_modifier;
};
static DevPrivateKeyRec xwl_gbm_private_key;
@@ -80,13 +94,33 @@ xwl_gbm_get(struct xwl_screen *xwl_screen)
&xwl_gbm_private_key);
}
+Bool
+xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen)
+{
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+ return !!(xwl_gbm->drm != NULL);
+}
+
+/* There is a workaround for Mesa behaviour, which will cause black windows
+ * when RGBX formats is using. Why exactly? There is an explanation:
+ * 1. We create GL_RGBA texture with GL_UNSIGNED_BYTE type, all allowed by ES.
+ * 2 .We export these texture to GBM bo with GBM_FORMAT_XRGB8888, and Mesa sets internal
+ * format of these textures as GL_RGB8 (mesa/mesa!5034 (merged))
+ * 3. We import these BO at some point, and use glTexSubImage on it with GL_RGBA format
+ * and with GL_UNSIGNED_BYTE type, as we creates. Mesa checks its internalformat
+ * in glTexSubImage2D and fails due to GLES internal format limitation
+ * (see https://registry.khronos.org/OpenGL/specs/es/2.0/es_full_spec_2.0.pdf, section 3.7.1).
+ */
static uint32_t
-gbm_format_for_depth(int depth)
+gbm_format_for_depth(int depth, int gles)
{
switch (depth) {
case 16:
return GBM_FORMAT_RGB565;
case 24:
+ if (gles)
+ return GBM_FORMAT_ARGB8888;
return GBM_FORMAT_XRGB8888;
case 30:
return GBM_FORMAT_ARGB2101010;
@@ -115,7 +149,8 @@ is_device_path_render_node (const char *device_path)
static PixmapPtr
xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
- int depth)
+ int depth,
+ Bool implicit_modifier)
{
PixmapPtr pixmap;
struct xwl_pixmap *xwl_pixmap;
@@ -187,6 +222,7 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
xwl_glamor_egl_make_current(xwl_screen);
xwl_pixmap->bo = bo;
xwl_pixmap->buffer = NULL;
+ xwl_pixmap->implicit_modifier = implicit_modifier;
#ifdef GBM_BO_FD_FOR_PLANE
if (xwl_gbm->dmabuf_capable) {
@@ -233,7 +269,7 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
#endif
{
xwl_pixmap->image = eglCreateImageKHR(xwl_screen->egl_display,
- xwl_screen->egl_context,
+ EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR,
xwl_pixmap->bo, NULL);
}
@@ -271,40 +307,83 @@ error:
}
static PixmapPtr
-xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
- int width, int height, int depth,
- unsigned int hint)
+xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
+ DrawablePtr drawable,
+ int width, int height, int depth,
+ unsigned int hint,
+ Bool implicit_scanout)
{
- struct xwl_screen *xwl_screen = xwl_screen_get(screen);
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
- struct gbm_bo *bo;
+ struct gbm_bo *bo = NULL;
PixmapPtr pixmap = NULL;
+ uint32_t num_modifiers = 0;
+ uint64_t *modifiers = NULL;
if (width > 0 && height > 0 && depth >= 15 &&
(hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
hint == CREATE_PIXMAP_USAGE_SHARED ||
(xwl_screen->rootless && hint == 0))) {
- uint32_t format = gbm_format_for_depth(depth);
+ uint32_t format = gbm_format_for_depth(depth, xwl_gbm->glamor_gles);
+ Bool implicit = FALSE;
#ifdef GBM_BO_WITH_MODIFIERS
if (xwl_gbm->dmabuf_capable) {
- uint32_t num_modifiers;
- uint64_t *modifiers = NULL;
+ Bool supports_scanout = FALSE;
+
+ if (drawable) {
+ xwl_glamor_get_drawable_modifiers_and_scanout(drawable,
+ format,
+ &num_modifiers,
+ &modifiers,
+ &supports_scanout);
+ }
- xwl_glamor_get_modifiers(screen, format, &num_modifiers, &modifiers);
- bo = gbm_bo_create_with_modifiers(xwl_gbm->gbm, width, height,
- format, modifiers, num_modifiers);
- free(modifiers);
+ if (num_modifiers == 0) {
+ xwl_glamor_get_modifiers(xwl_screen->screen, format,
+ &num_modifiers, &modifiers);
+ }
+
+ if (num_modifiers > 0) {
+#ifdef GBM_BO_WITH_MODIFIERS2
+ uint32_t usage = GBM_BO_USE_RENDERING;
+ if (supports_scanout)
+ usage |= GBM_BO_USE_SCANOUT;
+ bo = gbm_bo_create_with_modifiers2(xwl_gbm->gbm, width, height,
+ format, modifiers, num_modifiers,
+ usage);
+#else
+ bo = gbm_bo_create_with_modifiers(xwl_gbm->gbm, width, height,
+ format, modifiers, num_modifiers);
+#endif
+ }
}
- else
#endif
- {
- bo = gbm_bo_create(xwl_gbm->gbm, width, height, format,
- GBM_BO_USE_RENDERING);
+ if (bo == NULL) {
+ uint32_t usage = GBM_BO_USE_RENDERING;
+ implicit = TRUE;
+ if (implicit_scanout)
+ usage |= GBM_BO_USE_SCANOUT;
+
+ if (num_modifiers > 0) {
+ Bool has_mod_invalid = FALSE, has_mod_linear = FALSE;
+ int i;
+
+ for (i = 0; i < num_modifiers; i++) {
+ if (modifiers[i] == DRM_FORMAT_MOD_INVALID)
+ has_mod_invalid = TRUE;
+ else if (modifiers[i] == DRM_FORMAT_MOD_LINEAR)
+ has_mod_linear = TRUE;
+ }
+
+ if (!has_mod_invalid && has_mod_linear)
+ usage |= GBM_BO_USE_LINEAR;
+ }
+
+ bo = gbm_bo_create(xwl_gbm->gbm, width, height, format, usage);
}
if (bo) {
- pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth);
+ pixmap = xwl_glamor_gbm_create_pixmap_for_bo(xwl_screen->screen, bo, depth, implicit);
if (!pixmap) {
gbm_bo_destroy(bo);
@@ -316,11 +395,40 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
}
if (!pixmap)
- pixmap = glamor_create_pixmap(screen, width, height, depth, hint);
+ pixmap = glamor_create_pixmap(xwl_screen->screen, width, height, depth, hint);
+ free(modifiers);
return pixmap;
}
+static PixmapPtr
+xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
+ int width, int height, int depth,
+ unsigned int hint)
+{
+ return xwl_glamor_gbm_create_pixmap_internal(xwl_screen_get(screen), NULL,
+ width, height, depth, hint, FALSE);
+}
+
+PixmapPtr
+xwl_glamor_create_pixmap_for_window(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ WindowPtr window = xwl_window->surface_window;
+ unsigned border_width = 2 * window->borderWidth;
+
+ if (!xwl_screen->glamor)
+ return NullPixmap;
+
+ return xwl_glamor_gbm_create_pixmap_internal(xwl_screen,
+ &window->drawable,
+ window->drawable.width + border_width,
+ window->drawable.height + border_width,
+ window->drawable.depth,
+ CREATE_PIXMAP_USAGE_BACKING_PIXMAP,
+ xwl_window->has_implicit_scanout_support);
+}
+
static Bool
xwl_glamor_gbm_destroy_pixmap(PixmapPtr pixmap)
{
@@ -345,8 +453,78 @@ static const struct wl_buffer_listener xwl_glamor_gbm_buffer_listener = {
xwl_pixmap_buffer_release_cb,
};
-static struct wl_buffer *
-xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
+#ifdef GBM_BO_WITH_MODIFIERS
+static Bool
+init_buffer_params_with_modifiers(struct xwl_pixmap *xwl_pixmap,
+ uint64_t *modifier,
+ int *num_planes,
+ int *prime_fds,
+ uint32_t *strides,
+ uint32_t *offsets)
+{
+#ifndef GBM_BO_FD_FOR_PLANE
+ int32_t first_handle;
+#endif
+ int i;
+
+ *num_planes = gbm_bo_get_plane_count(xwl_pixmap->bo);
+ *modifier = gbm_bo_get_modifier(xwl_pixmap->bo);
+
+ for (i = 0; i < *num_planes; i++) {
+#ifdef GBM_BO_FD_FOR_PLANE
+ prime_fds[i] = gbm_bo_get_fd_for_plane(xwl_pixmap->bo, i);
+#else
+ union gbm_bo_handle plane_handle;
+
+ plane_handle = gbm_bo_get_handle_for_plane(xwl_pixmap->bo, i);
+ if (i == 0)
+ first_handle = plane_handle.s32;
+
+ /* If all planes point to the same object as the first plane, i.e. they
+ * all have the same handle, we can fall back to the non-planar
+ * gbm_bo_get_fd without losing information. If they point to different
+ * objects we are out of luck and need to give up.
+ */
+ if (first_handle == plane_handle.s32)
+ prime_fds[i] = gbm_bo_get_fd(xwl_pixmap->bo);
+ else
+ prime_fds[i] = -1;
+#endif
+ if (prime_fds[i] == -1) {
+ while (--i >= 0)
+ close(prime_fds[i]);
+ return FALSE;
+ }
+ strides[i] = gbm_bo_get_stride_for_plane(xwl_pixmap->bo, i);
+ offsets[i] = gbm_bo_get_offset(xwl_pixmap->bo, i);
+ }
+
+ return TRUE;
+}
+#endif
+
+static Bool
+init_buffer_params_fallback(struct xwl_pixmap *xwl_pixmap,
+ uint64_t *modifier,
+ int *num_planes,
+ int *prime_fds,
+ uint32_t *strides,
+ uint32_t *offsets)
+{
+ *num_planes = 1;
+ *modifier = DRM_FORMAT_MOD_INVALID;
+ prime_fds[0] = gbm_bo_get_fd(xwl_pixmap->bo);
+ if (prime_fds[0] == -1)
+ return FALSE;
+
+ strides[0] = gbm_bo_get_stride(xwl_pixmap->bo);
+ offsets[0] = 0;
+
+ return TRUE;
+}
+
+struct wl_buffer *
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
@@ -354,8 +532,8 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
unsigned short width = pixmap->drawable.width;
unsigned short height = pixmap->drawable.height;
uint32_t format;
- int prime_fd;
int num_planes;
+ int prime_fds[4];
uint32_t strides[4];
uint32_t offsets[4];
uint64_t modifier;
@@ -374,23 +552,26 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
format = wl_drm_format_for_depth(pixmap->drawable.depth);
- prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
- if (prime_fd == -1)
- return NULL;
-
#ifdef GBM_BO_WITH_MODIFIERS
- num_planes = gbm_bo_get_plane_count(xwl_pixmap->bo);
- modifier = gbm_bo_get_modifier(xwl_pixmap->bo);
- for (i = 0; i < num_planes; i++) {
- strides[i] = gbm_bo_get_stride_for_plane(xwl_pixmap->bo, i);
- offsets[i] = gbm_bo_get_offset(xwl_pixmap->bo, i);
- }
-#else
- num_planes = 1;
- modifier = DRM_FORMAT_MOD_INVALID;
- strides[0] = gbm_bo_get_stride(xwl_pixmap->bo);
- offsets[0] = 0;
+ if (!xwl_pixmap->implicit_modifier) {
+ if (!init_buffer_params_with_modifiers(xwl_pixmap,
+ &modifier,
+ &num_planes,
+ prime_fds,
+ strides,
+ offsets))
+ return NULL;
+ } else
#endif
+ {
+ if (!init_buffer_params_fallback(xwl_pixmap,
+ &modifier,
+ &num_planes,
+ prime_fds,
+ strides,
+ offsets))
+ return NULL;
+ }
if (xwl_screen->dmabuf &&
xwl_glamor_is_modifier_supported(xwl_screen, format, modifier)) {
@@ -398,7 +579,7 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
params = zwp_linux_dmabuf_v1_create_params(xwl_screen->dmabuf);
for (i = 0; i < num_planes; i++) {
- zwp_linux_buffer_params_v1_add(params, prime_fd, i,
+ zwp_linux_buffer_params_v1_add(params, prime_fds[i], i,
offsets[i], strides[i],
modifier >> 32, modifier & 0xffffffff);
}
@@ -407,20 +588,23 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
zwp_linux_buffer_params_v1_create_immed(params, width, height,
format, 0);
zwp_linux_buffer_params_v1_destroy(params);
- } else if (num_planes == 1) {
+ } else if (num_planes == 1 && modifier == DRM_FORMAT_MOD_INVALID &&
+ xwl_gbm->drm) {
xwl_pixmap->buffer =
- wl_drm_create_prime_buffer(xwl_gbm->drm, prime_fd, width, height,
+ wl_drm_create_prime_buffer(xwl_gbm->drm, prime_fds[0], width, height,
format,
0, gbm_bo_get_stride(xwl_pixmap->bo),
0, 0,
0, 0);
}
- close(prime_fd);
+ for (i = 0; i < num_planes; i++)
+ close(prime_fds[i]);
/* Add our listener now */
- wl_buffer_add_listener(xwl_pixmap->buffer,
- &xwl_glamor_gbm_buffer_listener, pixmap);
+ if (xwl_pixmap->buffer)
+ wl_buffer_add_listener(xwl_pixmap->buffer,
+ &xwl_glamor_gbm_buffer_listener, pixmap);
return xwl_pixmap->buffer;
}
@@ -432,12 +616,15 @@ xwl_glamor_gbm_cleanup(struct xwl_screen *xwl_screen)
if (xwl_gbm->device_name)
free(xwl_gbm->device_name);
+ drmFreeDevice(&xwl_gbm->device);
if (xwl_gbm->drm_fd)
close(xwl_gbm->drm_fd);
if (xwl_gbm->drm)
wl_drm_destroy(xwl_gbm->drm);
if (xwl_gbm->gbm)
gbm_device_destroy(xwl_gbm->gbm);
+ if (xwl_screen->explicit_sync)
+ wp_linux_drm_syncobj_manager_v1_destroy(xwl_screen->explicit_sync);
free(xwl_gbm);
}
@@ -540,7 +727,7 @@ xwl_dri3_open_client(ClientPtr client,
return Success;
}
-_X_EXPORT PixmapPtr
+PixmapPtr
glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds,
CARD16 width, CARD16 height,
const CARD32 *strides, const CARD32 *offsets,
@@ -551,6 +738,7 @@ glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds,
struct gbm_bo *bo = NULL;
PixmapPtr pixmap;
int i;
+ Bool implicit = FALSE;
if (width == 0 || height == 0 || num_fds == 0 ||
depth < 15 || bpp != BitsPerPixel(depth) ||
@@ -564,7 +752,7 @@ glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds,
data.width = width;
data.height = height;
data.num_fds = num_fds;
- data.format = gbm_format_for_depth(depth);
+ data.format = gbm_format_for_depth(depth, xwl_gbm->glamor_gles);
data.modifier = modifier;
for (i = 0; i < num_fds; i++) {
data.fds[i] = fds[i];
@@ -581,9 +769,10 @@ glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds,
data.width = width;
data.height = height;
data.stride = strides[0];
- data.format = gbm_format_for_depth(depth);
+ data.format = gbm_format_for_depth(depth, xwl_gbm->glamor_gles);
bo = gbm_bo_import(xwl_gbm->gbm, GBM_BO_IMPORT_FD, &data,
GBM_BO_USE_RENDERING);
+ implicit = TRUE;
} else {
goto error;
}
@@ -591,7 +780,7 @@ glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds,
if (bo == NULL)
goto error;
- pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth);
+ pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth, implicit);
if (pixmap == NULL) {
gbm_bo_destroy(bo);
goto error;
@@ -603,13 +792,16 @@ error:
return NULL;
}
-_X_EXPORT int
+int
glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
uint32_t *strides, uint32_t *offsets,
uint64_t *modifier)
{
struct xwl_pixmap *xwl_pixmap;
#ifdef GBM_BO_WITH_MODIFIERS
+#ifndef GBM_BO_FD_FOR_PLANE
+ int32_t first_handle;
+#endif
uint32_t num_fds;
int i;
#endif
@@ -627,7 +819,30 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
*modifier = gbm_bo_get_modifier(xwl_pixmap->bo);
for (i = 0; i < num_fds; i++) {
- fds[i] = gbm_bo_get_fd(xwl_pixmap->bo);
+#ifdef GBM_BO_FD_FOR_PLANE
+ fds[i] = gbm_bo_get_fd_for_plane(xwl_pixmap->bo, i);
+#else
+ union gbm_bo_handle plane_handle;
+
+ plane_handle = gbm_bo_get_handle_for_plane(xwl_pixmap->bo, i);
+ if (i == 0)
+ first_handle = plane_handle.s32;
+
+ /* If all planes point to the same object as the first plane, i.e. they
+ * all have the same handle, we can fall back to the non-planar
+ * gbm_bo_get_fd without losing information. If they point to different
+ * objects we are out of luck and need to give up.
+ */
+ if (first_handle == plane_handle.s32)
+ fds[i] = gbm_bo_get_fd(xwl_pixmap->bo);
+ else
+ fds[i] = -1;
+#endif
+ if (fds[i] == -1) {
+ while (--i >= 0)
+ close(fds[i]);
+ return 0;
+ }
strides[i] = gbm_bo_get_stride_for_plane(xwl_pixmap->bo, i);
offsets[i] = gbm_bo_get_offset(xwl_pixmap->bo, i);
}
@@ -636,6 +851,8 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
#else
*modifier = DRM_FORMAT_MOD_INVALID;
fds[0] = gbm_bo_get_fd(xwl_pixmap->bo);
+ if (fds[0] == -1)
+ return 0;
strides[0] = gbm_bo_get_stride(xwl_pixmap->bo);
offsets[0] = 0;
return 1;
@@ -645,14 +862,358 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
/* Not actually used, just defined here so there's something for
* _glamor_egl_fds_from_pixmap() to link against
*/
-_X_EXPORT int
+int
glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
CARD16 *stride, CARD32 *size)
{
return -1;
}
-static const dri3_screen_info_rec xwl_dri3_info = {
+int
+xwl_glamor_dmabuf_export_sync_file(PixmapPtr pixmap)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
+ struct xwl_pixmap *xwl_pixmap;
+ int num_planes;
+ int sync_file = -1;
+ int p;
+#ifndef GBM_BO_FD_FOR_PLANE
+ int32_t first_handle;
+#endif
+
+ if (!xwl_screen->glamor)
+ return -1;
+
+#ifdef DMA_BUF_IOCTL_EXPORT_SYNC_FILE
+ xwl_pixmap = xwl_pixmap_get(pixmap);
+ num_planes = gbm_bo_get_plane_count(xwl_pixmap->bo);
+
+ for (p = 0; p < num_planes; ++p) {
+ int plane_fd;
+#ifdef GBM_BO_FD_FOR_PLANE
+ plane_fd = gbm_bo_get_fd_for_plane(xwl_pixmap->bo, p);
+#else
+ union gbm_bo_handle plane_handle =
+ gbm_bo_get_handle_for_plane(xwl_pixmap->bo, p);
+ if (p == 0)
+ first_handle = plane_handle.s32;
+
+ if (plane_handle.s32 == first_handle)
+ plane_fd = gbm_bo_get_fd(xwl_pixmap->bo);
+ else
+ continue;
+#endif /* GBM_BO_FD_FOR_PLANE */
+ struct dma_buf_export_sync_file export_args = { 0 };
+ export_args.fd = -1;
+ export_args.flags = DMA_BUF_SYNC_READ;
+ drmIoctl(plane_fd, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &export_args);
+ close(plane_fd);
+ if (sync_file == -1) {
+ sync_file = export_args.fd;
+ } else {
+ struct sync_merge_data merge_args = { 0 };
+ merge_args.fd2 = export_args.fd;
+ ioctl(sync_file, SYNC_IOC_MERGE, &merge_args);
+ close(export_args.fd);
+ close(sync_file);
+ sync_file = merge_args.fence;
+ }
+ }
+#endif /* DMA_BUF_IOCTL_EXPORT_SYNC_FILE */
+ return sync_file;
+}
+
+void
+xwl_glamor_dmabuf_import_sync_file(PixmapPtr pixmap, int sync_file)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
+ struct xwl_pixmap *xwl_pixmap;
+ int num_planes;
+ int p;
+#ifndef GBM_BO_FD_FOR_PLANE
+ int32_t first_handle;
+#endif
+
+ if (!xwl_screen->glamor)
+ return;
+
+#ifdef DMA_BUF_IOCTL_IMPORT_SYNC_FILE
+ xwl_pixmap = xwl_pixmap_get(pixmap);
+ num_planes = gbm_bo_get_plane_count(xwl_pixmap->bo);
+
+ for (p = 0; p < num_planes; ++p) {
+ int plane_fd;
+#ifdef GBM_BO_FD_FOR_PLANE
+ plane_fd = gbm_bo_get_fd_for_plane(xwl_pixmap->bo, p);
+#else
+ union gbm_bo_handle plane_handle =
+ gbm_bo_get_handle_for_plane(xwl_pixmap->bo, p);
+ if (p == 0)
+ first_handle = plane_handle.s32;
+
+ if (plane_handle.s32 == first_handle)
+ plane_fd = gbm_bo_get_fd(xwl_pixmap->bo);
+ else
+ continue;
+#endif /* GBM_BO_FD_FOR_PLANE */
+ struct dma_buf_import_sync_file import_args = { 0 };
+ import_args.fd = sync_file;
+ import_args.flags = DMA_BUF_SYNC_READ;
+ drmIoctl(plane_fd, DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &import_args);
+ close(plane_fd);
+ }
+#endif /* DMA_BUF_IOCTL_IMPORT_SYNC_FILE */
+ close(sync_file);
+}
+
+struct xwl_dri3_syncobj
+{
+ struct dri3_syncobj base;
+ uint32_t handle;
+ struct wp_linux_drm_syncobj_timeline_v1 *timeline;
+};
+
+void
+xwl_glamor_dri3_syncobj_passthrough(struct xwl_window *xwl_window,
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ struct xwl_dri3_syncobj *xwl_acquire_syncobj = (struct xwl_dri3_syncobj *)acquire_syncobj;
+ struct xwl_dri3_syncobj *xwl_release_syncobj = (struct xwl_dri3_syncobj *)release_syncobj;
+ uint32_t acquire_hi = acquire_point >> 32;
+ uint32_t acquire_lo = acquire_point & 0xffffffff;
+ uint32_t release_hi = release_point >> 32;
+ uint32_t release_lo = release_point & 0xffffffff;
+
+ if (!xwl_window->surface_sync)
+ xwl_window->surface_sync =
+ wp_linux_drm_syncobj_manager_v1_get_surface(xwl_screen->explicit_sync,
+ xwl_window->surface);
+
+ wp_linux_drm_syncobj_surface_v1_set_acquire_point(xwl_window->surface_sync,
+ xwl_acquire_syncobj->timeline,
+ acquire_hi, acquire_lo);
+ wp_linux_drm_syncobj_surface_v1_set_release_point(xwl_window->surface_sync,
+ xwl_release_syncobj->timeline,
+ release_hi, release_lo);
+}
+
+static Bool
+xwl_dri3_check_syncobj(struct dri3_syncobj *syncobj, uint64_t point, Bool check_avail)
+{
+ struct xwl_dri3_syncobj *xwl_syncobj = (struct xwl_dri3_syncobj *)syncobj;
+ struct xwl_screen *xwl_screen = xwl_screen_get(syncobj->screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+ return !drmSyncobjTimelineWait(xwl_gbm->drm_fd,
+ &xwl_syncobj->handle, &point, 1,
+ 0 /* timeout */,
+ check_avail ?
+ DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE :
+ DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
+ NULL /* first_signaled */);
+}
+
+static Bool
+xwl_dri3_syncobj_has_fence(struct dri3_syncobj *syncobj, uint64_t point)
+{
+ return xwl_dri3_check_syncobj(syncobj, point, TRUE /* check_avail */);
+}
+
+static Bool
+xwl_dri3_syncobj_is_signaled(struct dri3_syncobj *syncobj, uint64_t point)
+{
+ return xwl_dri3_check_syncobj(syncobj, point, FALSE /* check_avail */);
+}
+
+static int
+xwl_dri3_syncobj_export_fence(struct dri3_syncobj *syncobj, uint64_t point)
+{
+ struct xwl_dri3_syncobj *xwl_syncobj = (struct xwl_dri3_syncobj *)syncobj;
+ struct xwl_screen *xwl_screen = xwl_screen_get(syncobj->screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ uint32_t temp_syncobj;
+ int fd = -1;
+
+ drmSyncobjCreate(xwl_gbm->drm_fd, 0, &temp_syncobj);
+ drmSyncobjTransfer(xwl_gbm->drm_fd, temp_syncobj, 0,
+ xwl_syncobj->handle, point, 0);
+ drmSyncobjExportSyncFile(xwl_gbm->drm_fd, temp_syncobj, &fd);
+ drmSyncobjDestroy(xwl_gbm->drm_fd, temp_syncobj);
+ return fd;
+}
+
+static void
+xwl_dri3_syncobj_import_fence(struct dri3_syncobj *syncobj,
+ uint64_t point, int fd)
+{
+ struct xwl_dri3_syncobj *xwl_syncobj = (struct xwl_dri3_syncobj *)syncobj;
+ struct xwl_screen *xwl_screen = xwl_screen_get(syncobj->screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ uint32_t temp_syncobj;
+
+ drmSyncobjCreate(xwl_gbm->drm_fd, 0, &temp_syncobj);
+ drmSyncobjImportSyncFile(xwl_gbm->drm_fd, temp_syncobj, fd);
+ drmSyncobjTransfer(xwl_gbm->drm_fd, xwl_syncobj->handle, point,
+ temp_syncobj, 0, 0);
+ drmSyncobjDestroy(xwl_gbm->drm_fd, temp_syncobj);
+ close(fd);
+}
+
+static void
+xwl_dri3_signal_syncobj(struct dri3_syncobj *syncobj, uint64_t point)
+{
+ struct xwl_dri3_syncobj *xwl_syncobj = (struct xwl_dri3_syncobj *)syncobj;
+ struct xwl_screen *xwl_screen = xwl_screen_get(syncobj->screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+ drmSyncobjTimelineSignal(xwl_gbm->drm_fd, &xwl_syncobj->handle, &point, 1);
+}
+
+static void
+xwl_dri3_free_syncobj(struct dri3_syncobj *syncobj)
+{
+ struct xwl_dri3_syncobj *xwl_syncobj = (struct xwl_dri3_syncobj *)syncobj;
+ struct xwl_screen *xwl_screen = xwl_screen_get(syncobj->screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+ if (xwl_syncobj->timeline)
+ wp_linux_drm_syncobj_timeline_v1_destroy(xwl_syncobj->timeline);
+
+ if (xwl_syncobj->handle)
+ drmSyncobjDestroy(xwl_gbm->drm_fd, xwl_syncobj->handle);
+
+ free(xwl_syncobj);
+}
+
+static void
+xwl_dri3_syncobj_eventfd(struct dri3_syncobj *syncobj, uint64_t point,
+ int efd, Bool wait_avail)
+{
+ struct xwl_dri3_syncobj *xwl_syncobj = (struct xwl_dri3_syncobj *)syncobj;
+ struct xwl_screen *xwl_screen = xwl_screen_get(syncobj->screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+ drmSyncobjEventfd(xwl_gbm->drm_fd, xwl_syncobj->handle, point, efd,
+ wait_avail ? DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE : 0);
+}
+
+static void
+xwl_dri3_syncobj_submitted_eventfd(struct dri3_syncobj *syncobj,
+ uint64_t point, int efd)
+{
+ xwl_dri3_syncobj_eventfd(syncobj, point, efd, TRUE /* wait_avail */);
+}
+
+static void
+xwl_dri3_syncobj_signaled_eventfd(struct dri3_syncobj *syncobj,
+ uint64_t point, int efd)
+{
+ xwl_dri3_syncobj_eventfd(syncobj, point, efd, FALSE /* wait_avail */);
+}
+
+static struct dri3_syncobj *
+xwl_dri3_create_syncobj(struct xwl_screen *xwl_screen, uint32_t handle)
+{
+ struct xwl_dri3_syncobj *syncobj = calloc(1, sizeof (*syncobj));
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ Bool create = !handle;
+
+ if (!syncobj)
+ return NULL;
+
+ if (create && drmSyncobjCreate(xwl_gbm->drm_fd, 0, &handle))
+ goto fail;
+
+ if (xwl_screen->explicit_sync) {
+ int syncobj_fd = -1;
+ if (drmSyncobjHandleToFD(xwl_gbm->drm_fd, handle, &syncobj_fd))
+ goto fail;
+
+ syncobj->timeline =
+ wp_linux_drm_syncobj_manager_v1_import_timeline(xwl_screen->explicit_sync,
+ syncobj_fd);
+ close(syncobj_fd);
+ if (!syncobj->timeline)
+ goto fail;
+ }
+
+ syncobj->handle = handle;
+ syncobj->base.screen = xwl_screen->screen;
+ syncobj->base.refcount = 1;
+
+ syncobj->base.free = xwl_dri3_free_syncobj;
+ syncobj->base.has_fence = xwl_dri3_syncobj_has_fence;
+ syncobj->base.is_signaled = xwl_dri3_syncobj_is_signaled;
+ syncobj->base.export_fence = xwl_dri3_syncobj_export_fence;
+ syncobj->base.import_fence = xwl_dri3_syncobj_import_fence;
+ syncobj->base.signal = xwl_dri3_signal_syncobj;
+ syncobj->base.signaled_eventfd = xwl_dri3_syncobj_signaled_eventfd;
+ syncobj->base.submitted_eventfd = xwl_dri3_syncobj_submitted_eventfd;
+ return &syncobj->base;
+
+fail:
+ if (create && handle)
+ drmSyncobjDestroy(xwl_gbm->drm_fd, handle);
+ free(syncobj);
+ return NULL;
+}
+
+struct dri3_syncobj *
+xwl_glamor_dri3_syncobj_create(struct xwl_screen *xwl_screen)
+{
+ return xwl_dri3_create_syncobj(xwl_screen, 0 /* allocate new handle */);
+}
+
+static struct dri3_syncobj *
+xwl_dri3_import_syncobj(ClientPtr client, ScreenPtr screen, XID id, int fd)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ struct xwl_dri3_syncobj *syncobj = NULL;
+ uint32_t handle;
+
+ if (drmSyncobjFDToHandle(xwl_gbm->drm_fd, fd, &handle))
+ return NULL;
+
+ syncobj = (struct xwl_dri3_syncobj *)xwl_dri3_create_syncobj(xwl_screen, handle);
+ if (!syncobj) {
+ drmSyncobjDestroy(xwl_gbm->drm_fd, handle);
+ return NULL;
+ }
+
+ syncobj->base.id = id;
+
+ return &syncobj->base;
+}
+
+static Bool
+xwl_gbm_supports_syncobjs(struct xwl_screen *xwl_screen)
+{
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ uint64_t syncobj_cap = 0;
+
+ if (drmGetCap(xwl_gbm->drm_fd, DRM_CAP_SYNCOBJ_TIMELINE,
+ &syncobj_cap) || !syncobj_cap)
+ return FALSE;
+
+ /* Check if syncobj eventfd is supported. */
+ drmSyncobjEventfd(xwl_gbm->drm_fd, 0, 0, -1, 0);
+ if (errno != ENOENT)
+ return FALSE;
+
+#if !defined(DMA_BUF_IOCTL_EXPORT_SYNC_FILE) || \
+ !defined(DMA_BUF_IOCTL_IMPORT_SYNC_FILE)
+ return FALSE;
+#else
+ return TRUE;
+#endif
+}
+
+static dri3_screen_info_rec xwl_dri3_info = {
.version = 2,
.open = NULL,
.pixmap_from_fds = glamor_pixmap_from_fds,
@@ -660,28 +1221,25 @@ static const dri3_screen_info_rec xwl_dri3_info = {
.open_client = xwl_dri3_open_client,
.get_formats = xwl_glamor_get_formats,
.get_modifiers = xwl_glamor_get_modifiers,
- .get_drawable_modifiers = glamor_get_drawable_modifiers,
+ .get_drawable_modifiers = xwl_glamor_get_drawable_modifiers,
+ .import_syncobj = NULL, /* need to check for kernel support */
};
static const char *
get_render_node_path_for_device(const drmDevicePtr drm_device,
const char *device_path)
{
- char *render_node_path = NULL;
- char device_found = 0;
+ const char *render_node_path;
int i;
- for (i = 0; i < DRM_NODE_MAX; i++) {
- if ((drm_device->available_nodes & (1 << i)) == 0)
- continue;
-
- if (!strcmp (device_path, drm_device->nodes[i]))
- device_found = 1;
-
- if (is_device_path_render_node(drm_device->nodes[i]))
- render_node_path = drm_device->nodes[i];
+ if (!(drm_device->available_nodes & (1 << DRM_NODE_RENDER)))
+ return NULL;
+ render_node_path = drm_device->nodes[DRM_NODE_RENDER];
- if (device_found && render_node_path)
+ for (i = 0; i < DRM_NODE_MAX; i++) {
+ if (!(drm_device->available_nodes & (1 << i)))
+ continue;
+ if (strcmp(device_path, drm_device->nodes[i]) == 0)
return render_node_path;
}
@@ -750,8 +1308,14 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device)
return;
}
+ if (drmGetDevice2(xwl_gbm->drm_fd, 0, &xwl_gbm->device) != 0) {
+ ErrorF("wayland-egl: Could not fetch DRM device %s\n",
+ xwl_gbm->device_name);
+ return;
+ }
+
if (drmGetNodeTypeFromFd(xwl_gbm->drm_fd) == DRM_NODE_RENDER) {
- xwl_gbm->fd_render_node = 1;
+ xwl_gbm->fd_render_node = TRUE;
xwl_screen->expecting_event--;
} else {
drmGetMagic(xwl_gbm->drm_fd, &magic);
@@ -804,22 +1368,15 @@ xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
return TRUE;
}
-static Bool
-xwl_glamor_gbm_init_wl_registry(struct xwl_screen *xwl_screen,
- struct wl_registry *wl_registry,
- uint32_t id, const char *name,
- uint32_t version)
+Bool
+xwl_screen_set_syncobj_interface(struct xwl_screen *xwl_screen,
+ uint32_t id, uint32_t version)
{
- if (strcmp(name, "wl_drm") == 0) {
- xwl_screen_set_drm_interface(xwl_screen, id, version);
- return TRUE;
- } else if (strcmp(name, "zwp_linux_dmabuf_v1") == 0) {
- xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
- return TRUE;
- }
-
- /* no match */
- return FALSE;
+ xwl_screen->explicit_sync =
+ wl_registry_bind(xwl_screen->registry, id,
+ &wp_linux_drm_syncobj_manager_v1_interface,
+ version);
+ return TRUE;
}
static Bool
@@ -829,17 +1386,19 @@ xwl_glamor_gbm_has_egl_extension(void)
epoxy_has_egl_extension(NULL, "EGL_KHR_platform_gbm"));
}
-static Bool
-xwl_glamor_gbm_has_wl_interfaces(struct xwl_screen *xwl_screen)
+Bool
+xwl_glamor_supports_implicit_sync(struct xwl_screen *xwl_screen)
{
- struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
-
- if (xwl_gbm->drm == NULL) {
- LogMessageVerb(X_INFO, 3, "glamor: 'wl_drm' not supported\n");
- return FALSE;
- }
+ /* absent glamor, implicit sync is irrelevant so just return TRUE */
+ return !xwl_screen->glamor ||
+ xwl_gbm_get(xwl_screen)->implicit_sync;
+}
- return TRUE;
+Bool
+xwl_glamor_supports_syncobjs(struct xwl_screen *xwl_screen)
+{
+ return xwl_screen->glamor &&
+ xwl_gbm_get(xwl_screen)->supports_syncobjs;
}
static Bool
@@ -878,6 +1437,9 @@ xwl_glamor_try_big_gl_api(struct xwl_screen *xwl_screen)
};
int gl_version;
+ if (!(xwl_screen->glamor & XWL_GLAMOR_GL))
+ return FALSE;
+
eglBindAPI(EGL_OPENGL_API);
xwl_screen->egl_context =
@@ -918,6 +1480,9 @@ xwl_glamor_try_gles_api(struct xwl_screen *xwl_screen)
EGL_NONE,
};
+ if (!(xwl_screen->glamor & XWL_GLAMOR_GLES))
+ return FALSE;
+
eglBindAPI(EGL_OPENGL_ES_API);
xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
@@ -934,12 +1499,56 @@ xwl_glamor_try_gles_api(struct xwl_screen *xwl_screen)
}
static Bool
+xwl_glamor_gbm_init_main_dev(struct xwl_screen *xwl_screen)
+{
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ drmDevice *main_dev;
+
+ while (!xwl_screen->default_feedback.feedback_done) {
+ if (wl_display_dispatch(xwl_screen->display) < 0) {
+ ErrorF("Failed to dispatch Wayland display\n");
+ return FALSE;
+ }
+ }
+
+ main_dev = xwl_screen->default_feedback.main_dev;
+ if (!(main_dev->available_nodes & (1 << DRM_NODE_RENDER))) {
+ ErrorF("Main linux-dmabuf device has no render node\n");
+ return FALSE;
+ }
+
+ xwl_gbm->device_name = strdup(main_dev->nodes[DRM_NODE_RENDER]);
+ if (!xwl_gbm->device_name) {
+ return FALSE;
+ }
+
+ xwl_gbm->drm_fd = open(xwl_gbm->device_name, O_RDWR | O_CLOEXEC);
+ if (xwl_gbm->drm_fd < 0) {
+ ErrorF("wayland-egl: could not open %s (%s)\n",
+ xwl_gbm->device_name, strerror(errno));
+ return FALSE;
+ }
+
+ if (drmGetDevice2(xwl_gbm->drm_fd, 0, &xwl_gbm->device) != 0) {
+ ErrorF("wayland-egl: Could not fetch DRM device %s\n",
+ xwl_gbm->device_name);
+ return FALSE;
+ }
+
+ xwl_gbm->fd_render_node = TRUE;
+ return TRUE;
+}
+
+Bool
xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
{
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
EGLint major, minor;
const GLubyte *renderer;
- const char *gbm_backend_name;
+ const char *gbm_backend_name, *egl_vendor;
+
+ if (!xwl_gbm->drm && !xwl_glamor_gbm_init_main_dev(xwl_screen))
+ return FALSE;
if (!xwl_gbm->fd_render_node && !xwl_gbm->drm_authenticated) {
ErrorF("Failed to get wl_drm, disabling Glamor and DRI3\n");
@@ -975,7 +1584,11 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
ErrorF("glGetString() returned NULL, your GL is broken\n");
goto error;
}
- if (strstr((const char *)renderer, "llvmpipe")) {
+ if (strstr((const char *)renderer, "softpipe")) {
+ ErrorF("Refusing to try glamor on softpipe\n");
+ goto error;
+ }
+ if (!strncmp("llvmpipe", (const char *)renderer, strlen("llvmpipe"))) {
ErrorF("Refusing to try glamor on llvmpipe\n");
goto error;
}
@@ -995,6 +1608,26 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
/* Mesa uses "drm" as backend name, in that case, just do nothing */
if (gbm_backend_name && strcmp(gbm_backend_name, "drm") != 0)
xwl_screen->glvnd_vendor = gbm_backend_name;
+ xwl_gbm->glamor_gles = !epoxy_is_desktop_gl();
+
+ egl_vendor = eglQueryString(xwl_screen->egl_display, EGL_VENDOR);
+ if (!egl_vendor) {
+ ErrorF("Could not determine EGL vendor\n");
+ goto error;
+ }
+ /* NVIDIA driver does not support implicit sync */
+ xwl_gbm->implicit_sync = !strstr(egl_vendor, "NVIDIA");
+
+ if (xwl_gbm_supports_syncobjs(xwl_screen) &&
+ epoxy_has_egl_extension(xwl_screen->egl_display,
+ "ANDROID_native_fence_sync"))
+ xwl_gbm->supports_syncobjs = TRUE;
+
+ if (!xwl_gbm->supports_syncobjs && xwl_screen->explicit_sync) {
+ /* explicit sync requires syncobj support */
+ wp_linux_drm_syncobj_manager_v1_destroy(xwl_screen->explicit_sync);
+ xwl_screen->explicit_sync = NULL;
+ }
return TRUE;
error:
@@ -1008,11 +1641,16 @@ error:
return FALSE;
}
-static Bool
+Bool
xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen)
{
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+ if (xwl_gbm->supports_syncobjs) {
+ xwl_dri3_info.version = 4;
+ xwl_dri3_info.import_syncobj = xwl_dri3_import_syncobj;
+ }
+
if (!dri3_screen_init(xwl_screen->screen, &xwl_dri3_info)) {
ErrorF("Failed to initialize dri3\n");
goto error;
@@ -1043,35 +1681,32 @@ error:
return FALSE;
}
-void
+drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen)
+{
+ struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+ return xwl_gbm->device;
+}
+
+Bool
xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
{
struct xwl_gbm_private *xwl_gbm;
- xwl_screen->gbm_backend.is_available = FALSE;
-
if (!xwl_glamor_gbm_has_egl_extension())
- return;
+ return FALSE;
if (!dixRegisterPrivateKey(&xwl_gbm_private_key, PRIVATE_SCREEN, 0))
- return;
+ return FALSE;
xwl_gbm = calloc(sizeof(*xwl_gbm), 1);
if (!xwl_gbm) {
ErrorF("glamor: Not enough memory to setup GBM, disabling\n");
- return;
+ return FALSE;
}
dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
xwl_gbm);
- xwl_screen->gbm_backend.init_wl_registry = xwl_glamor_gbm_init_wl_registry;
- xwl_screen->gbm_backend.has_wl_interfaces = xwl_glamor_gbm_has_wl_interfaces;
- xwl_screen->gbm_backend.init_egl = xwl_glamor_gbm_init_egl;
- xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
- xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
- xwl_screen->gbm_backend.check_flip = NULL;
- xwl_screen->gbm_backend.is_available = TRUE;
- xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH |
- XWL_EGL_BACKEND_NEEDS_N_BUFFERING;
+ return TRUE;
}
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
new file mode 100644
index 000000000..9083f2578
--- /dev/null
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2011-2014 Intel Corporation
+ * Copyright © 2024 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including
+ * the next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef XWAYLAND_GLAMOR_GBM_H
+#define XWAYLAND_GLAMOR_GBM_H
+
+#include <xwayland-config.h>
+
+#include <sys/types.h>
+
+#include <xf86drm.h>
+
+#include "xwayland-types.h"
+
+Bool xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen);
+drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen);
+
+#endif /* XWAYLAND_GLAMOR_GBM_H */
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 24620605d..604658284 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -31,18 +31,24 @@
#include <glamor.h>
#include <glamor_context.h>
+#include <glamor_glx_provider.h>
#ifdef GLXEXT
#include "glx_extinit.h"
#endif
-#include "linux-dmabuf-unstable-v1-client-protocol.h"
#include "drm-client-protocol.h"
-#include <drm_fourcc.h>
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+#include "linux-drm-syncobj-v1-client-protocol.h"
+#include "xwayland-dmabuf.h"
#include "xwayland-glamor.h"
-#include "xwayland-glx.h"
+#include "xwayland-glamor-gbm.h"
+#include "xwayland-present.h"
#include "xwayland-screen.h"
#include "xwayland-window.h"
+#include "xwayland-window-buffers.h"
+
+#include <sys/mman.h>
static void
glamor_egl_make_current(struct glamor_context *glamor_ctx)
@@ -72,6 +78,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
{
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+ glamor_set_glvnd_vendor(screen, xwl_screen->glvnd_vendor);
glamor_enable_dri3(screen);
glamor_ctx->ctx = xwl_screen->egl_context;
glamor_ctx->display = xwl_screen->egl_display;
@@ -82,189 +89,18 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
}
Bool
-xwl_glamor_check_flip(PixmapPtr pixmap)
-{
- struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
-
- if (!xwl_glamor_pixmap_get_wl_buffer(pixmap))
- return FALSE;
-
- if (xwl_screen->egl_backend->check_flip)
- return xwl_screen->egl_backend->check_flip(pixmap);
-
- return TRUE;
-}
-
-Bool
-xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
- uint32_t format, uint64_t modifier)
-{
- struct xwl_format *xwl_format = NULL;
- int i;
-
- for (i = 0; i < xwl_screen->num_formats; i++) {
- if (xwl_screen->formats[i].format == format) {
- xwl_format = &xwl_screen->formats[i];
- break;
- }
- }
-
- if (xwl_format) {
- for (i = 0; i < xwl_format->num_modifiers; i++) {
- if (xwl_format->modifiers[i] == modifier) {
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-uint32_t
-wl_drm_format_for_depth(int depth)
-{
- switch (depth) {
- case 15:
- return WL_DRM_FORMAT_XRGB1555;
- case 16:
- return WL_DRM_FORMAT_RGB565;
- case 24:
- return WL_DRM_FORMAT_XRGB8888;
- case 30:
- return WL_DRM_FORMAT_ARGB2101010;
- default:
- ErrorF("unexpected depth: %d\n", depth);
- case 32:
- return WL_DRM_FORMAT_ARGB8888;
- }
-}
-
-Bool
-xwl_glamor_get_formats(ScreenPtr screen,
- CARD32 *num_formats, CARD32 **formats)
-{
- struct xwl_screen *xwl_screen = xwl_screen_get(screen);
- int i;
-
- /* Explicitly zero the count as the caller may ignore the return value */
- *num_formats = 0;
-
- if (!xwl_screen->dmabuf)
- return FALSE;
-
- if (xwl_screen->num_formats == 0)
- return TRUE;
-
- *formats = calloc(xwl_screen->num_formats, sizeof(CARD32));
- if (*formats == NULL)
- return FALSE;
-
- for (i = 0; i < xwl_screen->num_formats; i++)
- (*formats)[i] = xwl_screen->formats[i].format;
- *num_formats = xwl_screen->num_formats;
-
- return TRUE;
-}
-
-Bool
-xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
- uint32_t *num_modifiers, uint64_t **modifiers)
+xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap)
{
- struct xwl_screen *xwl_screen = xwl_screen_get(screen);
- struct xwl_format *xwl_format = NULL;
- int i;
-
- /* Explicitly zero the count as the caller may ignore the return value */
- *num_modifiers = 0;
-
- if (!xwl_screen->dmabuf)
- return FALSE;
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ PixmapPtr backing_pixmap = screen->GetWindowPixmap(present_window);
- if (xwl_screen->num_formats == 0)
- return TRUE;
+ if (pixmap->drawable.depth != backing_pixmap->drawable.depth) {
+ if (pixmap->drawable.depth == 32)
+ return FALSE;
- for (i = 0; i < xwl_screen->num_formats; i++) {
- if (xwl_screen->formats[i].format == format) {
- xwl_format = &xwl_screen->formats[i];
- break;
- }
+ return xwl_present_maybe_redirect_window(present_window, pixmap);
}
- if (!xwl_format ||
- (xwl_format->num_modifiers == 1 &&
- xwl_format->modifiers[0] == DRM_FORMAT_MOD_INVALID))
- return FALSE;
-
- *modifiers = calloc(xwl_format->num_modifiers, sizeof(uint64_t));
- if (*modifiers == NULL)
- return FALSE;
-
- for (i = 0; i < xwl_format->num_modifiers; i++)
- (*modifiers)[i] = xwl_format->modifiers[i];
- *num_modifiers = xwl_format->num_modifiers;
-
- return TRUE;
-}
-
-static void
-xwl_dmabuf_handle_format(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
- uint32_t format)
-{
-}
-
-static void
-xwl_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
- uint32_t format, uint32_t modifier_hi,
- uint32_t modifier_lo)
-{
- struct xwl_screen *xwl_screen = data;
- struct xwl_format *xwl_format = NULL;
- int i;
-
- for (i = 0; i < xwl_screen->num_formats; i++) {
- if (xwl_screen->formats[i].format == format) {
- xwl_format = &xwl_screen->formats[i];
- break;
- }
- }
-
- if (xwl_format == NULL) {
- xwl_screen->num_formats++;
- xwl_screen->formats = realloc(xwl_screen->formats,
- xwl_screen->num_formats * sizeof(*xwl_format));
- if (!xwl_screen->formats)
- return;
- xwl_format = &xwl_screen->formats[xwl_screen->num_formats - 1];
- xwl_format->format = format;
- xwl_format->num_modifiers = 0;
- xwl_format->modifiers = NULL;
- }
-
- xwl_format->num_modifiers++;
- xwl_format->modifiers = realloc(xwl_format->modifiers,
- xwl_format->num_modifiers * sizeof(uint64_t));
- if (!xwl_format->modifiers)
- return;
- xwl_format->modifiers[xwl_format->num_modifiers - 1] = (uint64_t) modifier_lo;
- xwl_format->modifiers[xwl_format->num_modifiers - 1] |= (uint64_t) modifier_hi << 32;
-}
-
-static const struct zwp_linux_dmabuf_v1_listener xwl_dmabuf_listener = {
- .format = xwl_dmabuf_handle_format,
- .modifier = xwl_dmabuf_handle_modifier
-};
-
-Bool
-xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
- uint32_t id, uint32_t version)
-{
- if (version < 3)
- return FALSE;
-
- xwl_screen->dmabuf =
- wl_registry_bind(xwl_screen->registry, id, &zwp_linux_dmabuf_v1_interface, 3);
- zwp_linux_dmabuf_v1_add_listener(xwl_screen->dmabuf, &xwl_dmabuf_listener, xwl_screen);
-
return TRUE;
}
@@ -274,64 +110,26 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
uint32_t id, const char *interface,
uint32_t version)
{
- if (xwl_screen->gbm_backend.is_available &&
- xwl_screen->gbm_backend.init_wl_registry(xwl_screen,
- registry,
- id,
- interface,
- version)) {
- /* no-op */
- } else if (xwl_screen->eglstream_backend.is_available &&
- xwl_screen->eglstream_backend.init_wl_registry(xwl_screen,
- registry,
- id,
- interface,
- version)) {
- /* no-op */
- }
-}
-
-Bool
-xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
- struct xwl_egl_backend *xwl_egl_backend)
-{
- return xwl_egl_backend->has_wl_interfaces(xwl_screen);
-}
-
-struct wl_buffer *
-xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
-{
- struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
-
- if (xwl_screen->egl_backend->get_wl_buffer_for_pixmap)
- return xwl_screen->egl_backend->get_wl_buffer_for_pixmap(pixmap);
-
- return NULL;
+ if (strcmp(interface, wl_drm_interface.name) == 0)
+ xwl_screen_set_drm_interface(xwl_screen, id, version);
+ else if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0)
+ xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
+ else if (strcmp(interface, wp_linux_drm_syncobj_manager_v1_interface.name) == 0)
+ xwl_screen_set_syncobj_interface(xwl_screen, id, version);
}
-Bool
-xwl_glamor_post_damage(struct xwl_window *xwl_window,
- PixmapPtr pixmap, RegionPtr region)
+static Bool
+xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen)
{
- struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-
- if (xwl_screen->egl_backend->post_damage)
- return xwl_screen->egl_backend->post_damage(xwl_window, pixmap, region);
+ if (!xwl_glamor_has_wl_drm(xwl_screen) &&
+ xwl_screen->dmabuf_protocol_version < 4) {
+ LogMessageVerb(X_INFO, 3, "glamor: 'wl_drm' not supported and linux-dmabuf v4 not supported\n");
+ return FALSE;
+ }
return TRUE;
}
-Bool
-xwl_glamor_allow_commits(struct xwl_window *xwl_window)
-{
- struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-
- if (xwl_screen->egl_backend->allow_commits)
- return xwl_screen->egl_backend->allow_commits(xwl_window);
- else
- return TRUE;
-}
-
static Bool
xwl_glamor_create_screen_resources(ScreenPtr screen)
{
@@ -369,84 +167,48 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
return 0;
}
-Bool
-xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen)
-{
- if (!xwl_screen->glamor || !xwl_screen->egl_backend)
- return FALSE;
-
- return (xwl_screen->egl_backend->backend_flags &
- XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH);
-}
-
-Bool
-xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen)
+int
+xwl_glamor_get_fence(struct xwl_screen *xwl_screen)
{
- /* wl_shm benefits from n-buffering */
- if (!xwl_screen->glamor || !xwl_screen->egl_backend)
- return TRUE;
+ EGLint attribs[3];
+ EGLSyncKHR sync;
+ int fence_fd = -1;
+
+ if (!xwl_screen->glamor)
+ return -1;
+
+ xwl_glamor_egl_make_current(xwl_screen);
+
+ attribs[0] = EGL_SYNC_NATIVE_FENCE_FD_ANDROID;
+ attribs[1] = EGL_NO_NATIVE_FENCE_FD_ANDROID;
+ attribs[2] = EGL_NONE;
+ sync = eglCreateSyncKHR(xwl_screen->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
+ if (sync != EGL_NO_SYNC_KHR) {
+ fence_fd = eglDupNativeFenceFDANDROID(xwl_screen->egl_display, sync);
+ eglDestroySyncKHR(xwl_screen->egl_display, sync);
+ }
- return (xwl_screen->egl_backend->backend_flags &
- XWL_EGL_BACKEND_NEEDS_N_BUFFERING);
+ return fence_fd;
}
void
-xwl_glamor_init_backends(struct xwl_screen *xwl_screen, Bool use_eglstream)
+xwl_glamor_wait_fence(struct xwl_screen *xwl_screen, int fence_fd)
{
-#ifdef GLAMOR_HAS_GBM
- xwl_glamor_init_gbm(xwl_screen);
- if (!xwl_screen->gbm_backend.is_available && !use_eglstream)
- ErrorF("xwayland glamor: GBM backend (default) is not available\n");
-#endif
-#ifdef XWL_HAS_EGLSTREAM
- xwl_glamor_init_eglstream(xwl_screen);
- if (!xwl_screen->eglstream_backend.is_available && use_eglstream)
- ErrorF("xwayland glamor: EGLStream backend requested but not available\n");
-#endif
-}
+ EGLint attribs[3];
+ EGLSyncKHR sync;
-static Bool
-xwl_glamor_select_gbm_backend(struct xwl_screen *xwl_screen)
-{
-#ifdef GLAMOR_HAS_GBM
- if (xwl_screen->gbm_backend.is_available &&
- xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->gbm_backend)) {
- xwl_screen->egl_backend = &xwl_screen->gbm_backend;
- LogMessageVerb(X_INFO, 3, "glamor: Using GBM backend\n");
- return TRUE;
- }
- else
- LogMessageVerb(X_INFO, 3,
- "Missing Wayland requirements for glamor GBM backend\n");
-#endif
-
- return FALSE;
-}
-
-static Bool
-xwl_glamor_select_eglstream_backend(struct xwl_screen *xwl_screen)
-{
-#ifdef XWL_HAS_EGLSTREAM
- if (xwl_screen->eglstream_backend.is_available &&
- xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->eglstream_backend)) {
- xwl_screen->egl_backend = &xwl_screen->eglstream_backend;
- LogMessageVerb(X_INFO, 3, "glamor: Using EGLStream backend\n");
- return TRUE;
- }
- else
- LogMessageVerb(X_INFO, 3,
- "Missing Wayland requirements for glamor EGLStream backend\n");
-#endif
+ if (!xwl_screen->glamor)
+ return;
- return FALSE;
-}
+ xwl_glamor_egl_make_current(xwl_screen);
-void
-xwl_glamor_select_backend(struct xwl_screen *xwl_screen, Bool use_eglstream)
-{
- if (!xwl_glamor_select_eglstream_backend(xwl_screen)) {
- if (!use_eglstream)
- xwl_glamor_select_gbm_backend(xwl_screen);
+ attribs[0] = EGL_SYNC_NATIVE_FENCE_FD_ANDROID;
+ attribs[1] = fence_fd;
+ attribs[2] = EGL_NONE;
+ sync = eglCreateSyncKHR(xwl_screen->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
+ if (sync != EGL_NO_SYNC_KHR) {
+ eglWaitSyncKHR(xwl_screen->egl_display, sync, 0);
+ eglDestroySyncKHR(xwl_screen->egl_display, sync);
}
}
@@ -462,7 +224,12 @@ xwl_glamor_init(struct xwl_screen *xwl_screen)
return FALSE;
}
- if (!xwl_screen->egl_backend->init_egl(xwl_screen)) {
+ if (!xwl_glamor_has_wl_interfaces(xwl_screen)) {
+ ErrorF("Xwayland glamor: GBM Wayland interfaces not available\n");
+ return FALSE;
+ }
+
+ if (!xwl_glamor_gbm_init_egl(xwl_screen)) {
ErrorF("EGL setup failed, disabling glamor\n");
return FALSE;
}
@@ -472,7 +239,7 @@ xwl_glamor_init(struct xwl_screen *xwl_screen)
return FALSE;
}
- if (!xwl_screen->egl_backend->init_screen(xwl_screen)) {
+ if (!xwl_glamor_gbm_init_screen(xwl_screen)) {
ErrorF("EGL backend init_screen() failed, disabling glamor\n");
return FALSE;
}
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index cf3c4fba3..ef312a857 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -28,109 +28,50 @@
#include <xwayland-config.h>
+#include <sys/types.h>
+
#include <wayland-client.h>
+#include <xf86drm.h>
#include "xwayland-types.h"
+#include "xwayland-glamor-gbm.h"
+#include "dri3.h"
-typedef enum _xwl_egl_backend_flags {
- XWL_EGL_BACKEND_NO_FLAG = 0,
- XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH = (1 << 0),
- XWL_EGL_BACKEND_NEEDS_N_BUFFERING = (1 << 1),
-} xwl_egl_backend_flags;
-
-struct xwl_egl_backend {
- /* Set by the backend if available */
- Bool is_available;
-
- /* Features and requirements set by the backend */
- xwl_egl_backend_flags backend_flags;
-
- /* Called once for each interface in the global registry. Backends
- * should use this to bind to any wayland interfaces they need.
- */
- Bool (*init_wl_registry)(struct xwl_screen *xwl_screen,
- struct wl_registry *wl_registry,
- uint32_t id, const char *name,
- uint32_t version);
-
- /* Check that the required Wayland interfaces are available.
- */
- Bool (*has_wl_interfaces)(struct xwl_screen *xwl_screen);
-
- /* Called before glamor has been initialized. Backends should setup a
- * valid, glamor compatible EGL context in this hook.
- */
- Bool (*init_egl)(struct xwl_screen *xwl_screen);
-
- /* Called after glamor has been initialized, and after all of the
- * common Xwayland DDX hooks have been connected. Backends should use
- * this to setup any required wraps around X server callbacks like
- * CreatePixmap.
- */
- Bool (*init_screen)(struct xwl_screen *xwl_screen);
-
- /* Called by Xwayland to retrieve a pointer to a valid wl_buffer for
- * the given window/pixmap combo so that damage to the pixmap may be
- * displayed on-screen. Backends should use this to create a new
- * wl_buffer for a currently buffer-less pixmap, or simply return the
- * pixmap they've prepared beforehand.
- */
- struct wl_buffer *(*get_wl_buffer_for_pixmap)(PixmapPtr pixmap);
-
- /* Called by Xwayland to perform any pre-wl_surface damage routines
- * that are required by the backend. If your backend is poorly
- * designed and lacks the ability to render directly to a surface,
- * you should implement blitting from the glamor pixmap to the wayland
- * pixmap here. Otherwise, this callback is optional.
- */
- Bool (*post_damage)(struct xwl_window *xwl_window,
- PixmapPtr pixmap, RegionPtr region);
-
- /* Called by Xwayland to confirm with the egl backend that the given
- * pixmap is completely setup and ready for display on-screen. This
- * callback is optional.
- */
- Bool (*allow_commits)(struct xwl_window *xwl_window);
-
- /* Called by Xwayland to check whether the given pixmap can be
- * presented by xwl_present_flip. If not implemented, assumed TRUE.
- */
- Bool (*check_flip)(PixmapPtr pixmap);
-};
+typedef enum _xwl_glamor_mode_flags{
+ XWL_GLAMOR_NONE = 0,
+ XWL_GLAMOR_GL = (1 << 0),
+ XWL_GLAMOR_GLES = (1 << 1),
+ XWL_GLAMOR_DEFAULT = XWL_GLAMOR_GL | XWL_GLAMOR_GLES,
+} xwl_glamor_mode_flags;
#ifdef XWL_HAS_GLAMOR
-void xwl_glamor_init_backends(struct xwl_screen *xwl_screen,
- Bool use_eglstream);
-void xwl_glamor_select_backend(struct xwl_screen *xwl_screen,
- Bool use_eglstream);
Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
Bool xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
uint32_t id, uint32_t version);
-Bool xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
- uint32_t id, uint32_t version);
+Bool xwl_screen_set_syncobj_interface(struct xwl_screen *xwl_screen,
+ uint32_t id, uint32_t version);
struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
struct wl_registry *registry,
uint32_t id, const char *interface,
uint32_t version);
-Bool xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
- struct xwl_egl_backend *xwl_egl_backend);
-Bool xwl_glamor_post_damage(struct xwl_window *xwl_window,
- PixmapPtr pixmap, RegionPtr region);
-Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
-Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
-Bool xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen);
-Bool xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
- uint32_t format, uint64_t modifier);
-uint32_t wl_drm_format_for_depth(int depth);
-Bool xwl_glamor_get_formats(ScreenPtr screen,
- CARD32 *num_formats, CARD32 **formats);
-Bool xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
- uint32_t *num_modifiers, uint64_t **modifiers);
-Bool xwl_glamor_check_flip(PixmapPtr pixmap);
+Bool xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap);
+PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
+Bool xwl_glamor_supports_implicit_sync(struct xwl_screen *xwl_screen);
+void xwl_glamor_dmabuf_import_sync_file(PixmapPtr pixmap, int sync_file);
+int xwl_glamor_dmabuf_export_sync_file(PixmapPtr pixmap);
+Bool xwl_glamor_supports_syncobjs(struct xwl_screen *xwl_screen);
+int xwl_glamor_get_fence(struct xwl_screen *screen);
+void xwl_glamor_wait_fence(struct xwl_screen *xwl_screen, int fence);
+struct dri3_syncobj *xwl_glamor_dri3_syncobj_create(struct xwl_screen *xwl_screen);
+void xwl_glamor_dri3_syncobj_passthrough(struct xwl_window *xwl_window,
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point);
#ifdef XV
/* glamor Xv Adaptor */
@@ -139,20 +80,4 @@ Bool xwl_glamor_xv_init(ScreenPtr pScreen);
#endif /* XWL_HAS_GLAMOR */
-#ifdef GLAMOR_HAS_GBM
-void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
-#else
-static inline void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
-{
-}
-#endif
-
-#ifdef XWL_HAS_EGLSTREAM
-void xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen);
-#else
-static inline void xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
-{
-}
-#endif
-
#endif /* XWAYLAND_GLAMOR_H */
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index eda69a193..9ad0cc66f 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -29,6 +29,8 @@
#include <linux/input.h>
#include <sys/mman.h>
+#include "dix/dix_priv.h"
+
#include <inputstr.h>
#include <exevents.h>
#include <xkbsrv.h>
@@ -44,17 +46,19 @@
#include "xwayland-window.h"
#include "xwayland-screen.h"
+#ifdef XWL_HAS_EI
+#include "xwayland-xtest.h"
+#endif
+
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "tablet-unstable-v2-client-protocol.h"
#include "pointer-gestures-unstable-v1-client-protocol.h"
#include "xwayland-keyboard-grab-unstable-v1-client-protocol.h"
+#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
-struct axis_discrete_pending {
- struct xorg_list l;
- uint32_t axis;
- int32_t discrete;
-};
+#define SCROLL_AXIS_HORIZ 2
+#define SCROLL_AXIS_VERT 3
struct sync_pending {
struct xorg_list l;
@@ -128,6 +132,57 @@ init_pointer_buttons(DeviceIntPtr device)
return TRUE;
}
+static void
+maybe_fake_grab_devices(struct xwl_seat *xwl_seat)
+{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+ struct xwl_window *xwl_window;
+
+ if (xwl_screen->rootless)
+ return;
+
+ if (!xwl_screen->host_grab)
+ return;
+
+ if (!xwl_screen->has_grab)
+ return;
+
+ if (!xwl_screen->screen->root)
+ return;
+
+ xwl_window = xwl_window_get(xwl_screen->screen->root);
+ if (!xwl_window)
+ return;
+
+ xwl_seat_confine_pointer(xwl_seat, xwl_window);
+
+ if (!xwl_screen->shortcuts_inhibit_manager)
+ return;
+
+ if (xwl_screen->shortcuts_inhibit)
+ return;
+
+ xwl_screen->shortcuts_inhibit =
+ zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts (
+ xwl_screen->shortcuts_inhibit_manager,
+ xwl_window->surface,
+ xwl_seat->seat);
+}
+
+static void
+maybe_fake_ungrab_devices(struct xwl_seat *xwl_seat)
+{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+
+ xwl_seat_unconfine_pointer(xwl_seat);
+
+ if (!xwl_screen->shortcuts_inhibit)
+ return;
+
+ zwp_keyboard_shortcuts_inhibitor_v1_destroy (xwl_screen->shortcuts_inhibit);
+ xwl_screen->shortcuts_inhibit = NULL;
+}
+
static int
xwl_pointer_proc(DeviceIntPtr device, int what)
{
@@ -143,8 +198,8 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
- axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HWHEEL);
- axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_WHEEL);
+ axes_labels[SCROLL_AXIS_HORIZ] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HWHEEL);
+ axes_labels[SCROLL_AXIS_VERT] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_WHEEL);
if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels,
GetMotionHistorySize(), Absolute))
@@ -155,13 +210,13 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
0, 0xFFFF, 10000, 0, 10000, Absolute);
InitValuatorAxisStruct(device, 1, axes_labels[1],
0, 0xFFFF, 10000, 0, 10000, Absolute);
- InitValuatorAxisStruct(device, 2, axes_labels[2],
+ InitValuatorAxisStruct(device, SCROLL_AXIS_HORIZ, axes_labels[2],
NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
- InitValuatorAxisStruct(device, 3, axes_labels[3],
+ InitValuatorAxisStruct(device, SCROLL_AXIS_VERT, axes_labels[3],
NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
- SetScrollValuator(device, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE);
- SetScrollValuator(device, 3, SCROLL_TYPE_VERTICAL, 1.0, SCROLL_FLAG_PREFERRED);
+ SetScrollValuator(device, SCROLL_AXIS_HORIZ, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE);
+ SetScrollValuator(device, SCROLL_AXIS_VERT, SCROLL_TYPE_VERTICAL, 1.0, SCROLL_FLAG_PREFERRED);
if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
return BadValue;
@@ -260,6 +315,13 @@ xwl_pointer_proc_pointer_gestures(DeviceIntPtr device, int what)
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ /*
+ * We'll never send buttons, but XGetPointerMapping might in certain
+ * situations make the client think we have no buttons.
+ */
+ if (!init_pointer_buttons(device))
+ return BadValue;
+
if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels,
GetMotionHistorySize(), Relative))
return BadValue;
@@ -455,13 +517,13 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
wl_fixed_t sx_w, wl_fixed_t sy_w)
{
struct xwl_seat *xwl_seat = data;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
DeviceIntPtr dev = get_pointer_device(xwl_seat);
DeviceIntPtr master;
int i;
- int sx = wl_fixed_to_int(sx_w);
- int sy = wl_fixed_to_int(sy_w);
+ int sx, sy;
int dx, dy;
- ScreenPtr pScreen = xwl_seat->xwl_screen->screen;
+ ScreenPtr pScreen = xwl_screen->screen;
ValuatorMask mask;
/* There's a race here where if we create and then immediately
@@ -473,15 +535,21 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
if (surface == NULL)
return;
+ if (!is_surface_from_xwl_window(surface))
+ return;
+
+ sx = wl_fixed_to_int(sx_w) * xwl_screen->global_surface_scale;
+ sy = wl_fixed_to_int(sy_w) * xwl_screen->global_surface_scale;
+
xwl_seat->xwl_screen->serial = serial;
xwl_seat->pointer_enter_serial = serial;
xwl_seat->focus_window = wl_surface_get_user_data(surface);
- dx = xwl_seat->focus_window->window->drawable.x;
- dy = xwl_seat->focus_window->window->drawable.y;
+ dx = xwl_seat->focus_window->toplevel->drawable.x;
+ dy = xwl_seat->focus_window->toplevel->drawable.y;
/* We just entered a new xwindow, forget about the old last xwindow */
- xwl_seat->last_xwindow = NullWindow;
+ xwl_seat->last_focus_window = NULL;
master = GetMaster(dev, POINTER_OR_FLOAT);
(*pScreen->SetCursorPosition) (dev, pScreen, dx + sx, dy + sy, TRUE);
@@ -520,6 +588,19 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
else {
xwl_seat_maybe_lock_on_hidden_cursor(xwl_seat);
}
+
+ maybe_fake_grab_devices(xwl_seat);
+}
+
+void
+xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost)
+{
+ DeviceIntPtr dev = get_pointer_device(xwl_seat);
+
+ if (focus_lost)
+ CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT));
+
+ maybe_fake_ungrab_devices(xwl_seat);
}
static void
@@ -527,23 +608,28 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface)
{
struct xwl_seat *xwl_seat = data;
- DeviceIntPtr dev = get_pointer_device(xwl_seat);
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+ Bool focus_lost = FALSE;
- xwl_seat->xwl_screen->serial = serial;
+ xwl_screen->serial = serial;
/* The pointer has left a known xwindow, save it for a possible match
* in sprite_check_lost_focus()
*/
if (xwl_seat->focus_window) {
- xwl_seat->last_xwindow = xwl_seat->focus_window->window;
+ xwl_seat->last_focus_window = xwl_seat->focus_window;
xwl_seat->focus_window = NULL;
- CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT));
+ focus_lost = TRUE;
}
+
+ if (xwl_screen->rootless)
+ xwl_seat_leave_ptr(xwl_seat, focus_lost);
}
static void
dispatch_relative_motion_with_warp(struct xwl_seat *xwl_seat)
{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
double dx, dx_unaccel;
double dy, dy_unaccel;
@@ -552,6 +638,16 @@ dispatch_relative_motion_with_warp(struct xwl_seat *xwl_seat)
dx_unaccel = xwl_seat->pending_pointer_event.dx_unaccel;
dy_unaccel = xwl_seat->pending_pointer_event.dy_unaccel;
+ dx *= xwl_screen->global_surface_scale;
+ dy *= xwl_screen->global_surface_scale;
+ dx_unaccel *= xwl_screen->global_surface_scale;
+ dy_unaccel *= xwl_screen->global_surface_scale;
+
+ dx *= xwl_seat->focus_window->viewport_scale_x;
+ dy *= xwl_seat->focus_window->viewport_scale_y;
+ dx_unaccel *= xwl_seat->focus_window->viewport_scale_x;
+ dy_unaccel *= xwl_seat->focus_window->viewport_scale_y;
+
xwl_pointer_warp_emulator_handle_motion(xwl_seat->pointer_warp_emulator,
dx, dy,
dx_unaccel, dy_unaccel);
@@ -560,20 +656,22 @@ dispatch_relative_motion_with_warp(struct xwl_seat *xwl_seat)
static void
dispatch_absolute_motion(struct xwl_seat *xwl_seat)
{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
ValuatorMask mask;
DeviceIntPtr device;
int flags;
int event_x = wl_fixed_to_int(xwl_seat->pending_pointer_event.x);
int event_y = wl_fixed_to_int(xwl_seat->pending_pointer_event.y);
- int drawable_x = xwl_seat->focus_window->window->drawable.x;
- int drawable_y = xwl_seat->focus_window->window->drawable.y;
+ int drawable_x = xwl_seat->focus_window->toplevel->drawable.x;
+ int drawable_y = xwl_seat->focus_window->toplevel->drawable.y;
int x;
int y;
- if (xwl_window_has_viewport_enabled(xwl_seat->focus_window)) {
- event_x *= xwl_seat->focus_window->scale_x;
- event_y *= xwl_seat->focus_window->scale_y;
- }
+ event_x *= xwl_screen->global_surface_scale;
+ event_y *= xwl_screen->global_surface_scale;
+
+ event_x *= xwl_seat->focus_window->viewport_scale_x;
+ event_y *= xwl_seat->focus_window->viewport_scale_y;
x = drawable_x + event_x;
y = drawable_y + event_y;
@@ -596,12 +694,23 @@ dispatch_absolute_motion(struct xwl_seat *xwl_seat)
static void
dispatch_relative_motion(struct xwl_seat *xwl_seat)
{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
ValuatorMask mask;
double event_dx = xwl_seat->pending_pointer_event.dx;
double event_dy = xwl_seat->pending_pointer_event.dy;
double event_dx_unaccel = xwl_seat->pending_pointer_event.dx_unaccel;
double event_dy_unaccel = xwl_seat->pending_pointer_event.dy_unaccel;
+ event_dx *= xwl_screen->global_surface_scale;
+ event_dy *= xwl_screen->global_surface_scale;
+ event_dx_unaccel *= xwl_screen->global_surface_scale;
+ event_dy_unaccel *= xwl_screen->global_surface_scale;
+
+ event_dx *= xwl_seat->focus_window->viewport_scale_x;
+ event_dy *= xwl_seat->focus_window->viewport_scale_y;
+ event_dx_unaccel *= xwl_seat->focus_window->viewport_scale_x;
+ event_dy_unaccel *= xwl_seat->focus_window->viewport_scale_y;
+
valuator_mask_zero(&mask);
valuator_mask_set_unaccelerated(&mask, 0, event_dx, event_dx_unaccel);
valuator_mask_set_unaccelerated(&mask, 1, event_dy, event_dy_unaccel);
@@ -611,6 +720,36 @@ dispatch_relative_motion(struct xwl_seat *xwl_seat)
}
static void
+dispatch_scroll_motion(struct xwl_seat *xwl_seat)
+{
+ ValuatorMask mask;
+ const int divisor = 10;
+ wl_fixed_t dy = xwl_seat->pending_pointer_event.scroll_dy;
+ wl_fixed_t dx = xwl_seat->pending_pointer_event.scroll_dx;
+ int32_t dy_v120 = xwl_seat->pending_pointer_event.scroll_dy_v120;
+ int32_t dx_v120 = xwl_seat->pending_pointer_event.scroll_dx_v120;
+
+ valuator_mask_zero(&mask);
+ if (xwl_seat->pending_pointer_event.has_vertical_scroll_v120)
+ valuator_mask_set_double(&mask, SCROLL_AXIS_VERT, dy_v120 / 120.0);
+ else if (xwl_seat->pending_pointer_event.has_vertical_scroll)
+ valuator_mask_set_double(&mask,
+ SCROLL_AXIS_VERT,
+ wl_fixed_to_double(dy) / divisor);
+
+ if (xwl_seat->pending_pointer_event.has_horizontal_scroll_v120)
+ valuator_mask_set_double(&mask, SCROLL_AXIS_HORIZ, dx_v120 / 120.0);
+ else if (xwl_seat->pending_pointer_event.has_horizontal_scroll)
+ valuator_mask_set_double(&mask,
+ SCROLL_AXIS_HORIZ,
+ wl_fixed_to_double(dx) / divisor);
+
+ QueuePointerEvents(get_pointer_device(xwl_seat),
+ MotionNotify, 0, POINTER_RELATIVE, &mask);
+}
+
+
+static void
dispatch_pointer_motion_event(struct xwl_seat *xwl_seat)
{
Bool has_relative = xwl_seat->pending_pointer_event.has_relative;
@@ -626,8 +765,18 @@ dispatch_pointer_motion_event(struct xwl_seat *xwl_seat)
dispatch_absolute_motion(xwl_seat);
}
+ if (xwl_seat->pending_pointer_event.has_vertical_scroll ||
+ xwl_seat->pending_pointer_event.has_horizontal_scroll ||
+ xwl_seat->pending_pointer_event.has_vertical_scroll_v120 ||
+ xwl_seat->pending_pointer_event.has_horizontal_scroll_v120)
+ dispatch_scroll_motion(xwl_seat);
+
xwl_seat->pending_pointer_event.has_absolute = FALSE;
xwl_seat->pending_pointer_event.has_relative = FALSE;
+ xwl_seat->pending_pointer_event.has_vertical_scroll = FALSE;
+ xwl_seat->pending_pointer_event.has_horizontal_scroll = FALSE;
+ xwl_seat->pending_pointer_event.has_vertical_scroll_v120 = FALSE;
+ xwl_seat->pending_pointer_event.has_horizontal_scroll_v120 = FALSE;
}
static void
@@ -684,42 +833,17 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
struct xwl_seat *xwl_seat = data;
- int index;
- const int divisor = 10;
- ValuatorMask mask;
- struct axis_discrete_pending *pending = NULL;
- struct axis_discrete_pending *iter;
switch (axis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
- index = 3;
+ xwl_seat->pending_pointer_event.has_vertical_scroll = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dy = value;
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
- index = 2;
+ xwl_seat->pending_pointer_event.has_horizontal_scroll = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dx = value;
break;
- default:
- return;
- }
-
- xorg_list_for_each_entry(iter, &xwl_seat->axis_discrete_pending, l) {
- if (iter->axis == axis) {
- pending = iter;
- break;
- }
- }
-
- valuator_mask_zero(&mask);
-
- if (pending) {
- valuator_mask_set(&mask, index, pending->discrete);
- xorg_list_del(&pending->l);
- free(pending);
- } else {
- valuator_mask_set_double(&mask, index, wl_fixed_to_double(value) / divisor);
}
-
- QueuePointerEvents(get_pointer_device(xwl_seat),
- MotionNotify, 0, POINTER_RELATIVE, &mask);
}
static void
@@ -742,6 +866,18 @@ static void
pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis)
{
+ struct xwl_seat *xwl_seat = data;
+
+ switch (axis) {
+ case WL_POINTER_AXIS_VERTICAL_SCROLL:
+ xwl_seat->pending_pointer_event.has_vertical_scroll = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dy = 0;
+ break;
+ case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
+ xwl_seat->pending_pointer_event.has_horizontal_scroll = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dx = 0;
+ break;
+ }
}
static void
@@ -750,14 +886,34 @@ pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer,
{
struct xwl_seat *xwl_seat = data;
- struct axis_discrete_pending *pending = malloc(sizeof *pending);
- if (!pending)
- return;
+ switch (axis) {
+ case WL_POINTER_AXIS_VERTICAL_SCROLL:
+ xwl_seat->pending_pointer_event.has_vertical_scroll_v120 = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dy_v120 = 120 * discrete;
+ break;
+ case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
+ xwl_seat->pending_pointer_event.has_horizontal_scroll_v120 = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dx_v120 = 120 * discrete;
+ break;
+ }
+}
- pending->axis = axis;
- pending->discrete = discrete;
+static void
+pointer_handle_axis_v120(void *data, struct wl_pointer *pointer,
+ uint32_t axis, int32_t v120)
+{
+ struct xwl_seat *xwl_seat = data;
- xorg_list_add(&pending->l, &xwl_seat->axis_discrete_pending);
+ switch (axis) {
+ case WL_POINTER_AXIS_VERTICAL_SCROLL:
+ xwl_seat->pending_pointer_event.has_vertical_scroll_v120 = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dy_v120 = v120;
+ break;
+ case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
+ xwl_seat->pending_pointer_event.has_horizontal_scroll_v120 = TRUE;
+ xwl_seat->pending_pointer_event.scroll_dx_v120 = v120;
+ break;
+ }
}
static const struct wl_pointer_listener pointer_listener = {
@@ -770,6 +926,7 @@ static const struct wl_pointer_listener pointer_listener = {
pointer_handle_axis_source,
pointer_handle_axis_stop,
pointer_handle_axis_discrete,
+ pointer_handle_axis_v120,
};
static void
@@ -811,6 +968,9 @@ pointer_gesture_swipe_handle_begin(void *data,
{
struct xwl_seat *xwl_seat = data;
+ if (surface != NULL && !is_surface_from_xwl_window(surface))
+ return;
+
xwl_seat->pointer_gesture_swipe_fingers = fingers;
QueueGestureSwipeEvents(xwl_seat->pointer_gestures,
XI_GestureSwipeBegin, fingers, 0, 0.0, 0.0, 0.0, 0.0);
@@ -870,6 +1030,9 @@ pointer_gesture_pinch_handle_begin(void *data,
{
struct xwl_seat *xwl_seat = data;
+ if (surface != NULL && !is_surface_from_xwl_window(surface))
+ return;
+
xwl_seat->pointer_gesture_pinch_fingers = fingers;
xwl_seat->pointer_gesture_pinch_last_scale = 1.0;
QueueGesturePinchEvents(xwl_seat->pointer_gestures,
@@ -928,6 +1091,39 @@ static const struct zwp_pointer_gesture_pinch_v1_listener pointer_gesture_pinch_
};
static void
+maybe_toggle_fake_grab(struct xwl_seat *xwl_seat, uint32_t key)
+{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+ struct xwl_window *xwl_window;
+ XkbStateRec state_rec;
+ uint32_t xkb_state;
+
+ if (xwl_screen->rootless)
+ return;
+
+ if (!xwl_screen->host_grab)
+ return;
+
+ state_rec = xwl_seat->keyboard->key->xkbInfo->state;
+ xkb_state = (XkbStateFieldFromRec(&state_rec) & 0xff);
+
+ if (((key == KEY_LEFTSHIFT || key == KEY_RIGHTSHIFT) && (xkb_state & ControlMask)) ||
+ ((key == KEY_LEFTCTRL || key == KEY_RIGHTCTRL) && (xkb_state & ShiftMask))) {
+
+ xwl_screen->has_grab = !xwl_screen->has_grab;
+
+ if (xwl_screen->has_grab)
+ maybe_fake_grab_devices(xwl_seat);
+ else
+ maybe_fake_ungrab_devices(xwl_seat);
+
+ xwl_window = xwl_window_get(xwl_screen->screen->root);
+ if (xwl_window)
+ xwl_window_rootful_update_title(xwl_window);
+ }
+}
+
+static void
keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial,
uint32_t time, uint32_t key, uint32_t state)
{
@@ -949,6 +1145,9 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial,
QueueKeyboardEvents(xwl_seat->keyboard,
state ? KeyPress : KeyRelease, key + 8);
+
+ if (!state)
+ maybe_toggle_fake_grab(xwl_seat, key);
}
static void
@@ -956,15 +1155,19 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
uint32_t format, int fd, uint32_t size)
{
struct xwl_seat *xwl_seat = data;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
DeviceIntPtr master;
XkbDescPtr xkb;
XkbChangesRec changes = { 0 };
+ if (xwl_screen->nokeymap)
+ return;
+
if (xwl_seat->keymap)
munmap(xwl_seat->keymap, xwl_seat->keymap_size);
xwl_seat->keymap_size = size;
- xwl_seat->keymap = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
+ xwl_seat->keymap = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (xwl_seat->keymap == MAP_FAILED) {
xwl_seat->keymap_size = 0;
xwl_seat->keymap = NULL;
@@ -1003,27 +1206,43 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
struct xwl_seat *xwl_seat = data;
uint32_t *k;
+ if (surface != NULL && !is_surface_from_xwl_window(surface))
+ return;
+
xwl_seat->xwl_screen->serial = serial;
xwl_seat->keyboard_focus = surface;
wl_array_copy(&xwl_seat->keys, keys);
wl_array_for_each(k, &xwl_seat->keys)
QueueKeyboardEvents(xwl_seat->keyboard, EnterNotify, *k + 8);
+
+ maybe_fake_grab_devices(xwl_seat);
}
-static void
-keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
- uint32_t serial, struct wl_surface *surface)
+void
+xwl_seat_leave_kbd(struct xwl_seat *xwl_seat)
{
- struct xwl_seat *xwl_seat = data;
uint32_t *k;
- xwl_seat->xwl_screen->serial = serial;
-
wl_array_for_each(k, &xwl_seat->keys)
QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8);
xwl_seat->keyboard_focus = NULL;
+
+ maybe_fake_ungrab_devices(xwl_seat);
+}
+
+static void
+keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
+ uint32_t serial, struct wl_surface *surface)
+{
+ struct xwl_seat *xwl_seat = data;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+
+ xwl_screen->serial = serial;
+
+ if (xwl_screen->rootless)
+ xwl_seat_leave_kbd(xwl_seat);
}
static void
@@ -1194,11 +1413,11 @@ xwl_touch_send_event(struct xwl_touch *xwl_touch,
double dx, dy, x, y;
ValuatorMask mask;
- dx = xwl_touch->window->window->drawable.x;
- dy = xwl_touch->window->window->drawable.y;
+ dx = xwl_touch->window->toplevel->drawable.x;
+ dy = xwl_touch->window->toplevel->drawable.y;
- x = (dx + xwl_touch->x) * 0xFFFF / xwl_seat->xwl_screen->width;
- y = (dy + xwl_touch->y) * 0xFFFF / xwl_seat->xwl_screen->height;
+ x = (dx + xwl_touch->x) * 0xFFFF / xwl_screen_get_width(xwl_seat->xwl_screen);
+ y = (dy + xwl_touch->y) * 0xFFFF / xwl_screen_get_height(xwl_seat->xwl_screen);
valuator_mask_zero(&mask);
valuator_mask_set_double(&mask, 0, x);
@@ -1213,11 +1432,15 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
int32_t id, wl_fixed_t sx_w, wl_fixed_t sy_w)
{
struct xwl_seat *xwl_seat = data;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_touch *xwl_touch;
if (surface == NULL)
return;
+ if (!is_surface_from_xwl_window(surface))
+ return;
+
xwl_touch = calloc(1, sizeof *xwl_touch);
if (xwl_touch == NULL) {
ErrorF("%s: ENOMEM\n", __func__);
@@ -1230,6 +1453,12 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
xwl_touch->y = wl_fixed_to_int(sy_w);
xorg_list_add(&xwl_touch->link_touch, &xwl_seat->touches);
+ xwl_touch->x *= xwl_screen->global_surface_scale;
+ xwl_touch->y *= xwl_screen->global_surface_scale;
+
+ xwl_touch->x *= xwl_touch->window->viewport_scale_x;
+ xwl_touch->y *= xwl_touch->window->viewport_scale_y;
+
xwl_touch_send_event(xwl_touch, xwl_seat, XI_TouchBegin);
}
@@ -1256,6 +1485,7 @@ touch_handle_motion(void *data, struct wl_touch *wl_touch,
wl_fixed_t sx_w, wl_fixed_t sy_w)
{
struct xwl_seat *xwl_seat = data;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_touch *xwl_touch;
xwl_touch = xwl_seat_lookup_touch(xwl_seat, id);
@@ -1265,6 +1495,13 @@ touch_handle_motion(void *data, struct wl_touch *wl_touch,
xwl_touch->x = wl_fixed_to_int(sx_w);
xwl_touch->y = wl_fixed_to_int(sy_w);
+
+ xwl_touch->x *= xwl_screen->global_surface_scale;
+ xwl_touch->y *= xwl_screen->global_surface_scale;
+
+ xwl_touch->x *= xwl_touch->window->viewport_scale_x;
+ xwl_touch->y *= xwl_touch->window->viewport_scale_y;
+
xwl_touch_send_event(xwl_touch, xwl_seat, XI_TouchUpdate);
}
@@ -1355,7 +1592,7 @@ xwl_keyboard_search_window(ClientPtr client)
{
WindowPtr window = NullWindow;
- FindClientResourcesByType(client, RT_WINDOW, find_toplevel_callback, &window);
+ FindClientResourcesByType(client, X11_RESTYPE_WINDOW, find_toplevel_callback, &window);
return window;
}
@@ -1694,6 +1931,7 @@ static void
create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version)
{
struct xwl_seat *xwl_seat;
+ int seat_version = 8;
xwl_seat = calloc(1, sizeof *xwl_seat);
if (xwl_seat == NULL) {
@@ -1706,7 +1944,7 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version
xwl_seat->seat =
wl_registry_bind(xwl_screen->registry, id,
- &wl_seat_interface, min(version, 5));
+ &wl_seat_interface, min(version, seat_version));
xwl_seat->id = id;
xwl_cursor_init(&xwl_seat->cursor, xwl_seat->xwl_screen,
@@ -1718,7 +1956,6 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version
wl_array_init(&xwl_seat->keys);
xorg_list_init(&xwl_seat->touches);
- xorg_list_init(&xwl_seat->axis_discrete_pending);
xorg_list_init(&xwl_seat->sync_pending);
}
@@ -1727,7 +1964,6 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
{
struct xwl_touch *xwl_touch, *next_xwl_touch;
struct sync_pending *p, *npd;
- struct axis_discrete_pending *ad, *ad_next;
xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch,
&xwl_seat->touches, link_touch) {
@@ -1740,11 +1976,6 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
free (p);
}
- xorg_list_for_each_entry_safe(ad, ad_next, &xwl_seat->axis_discrete_pending, l) {
- xorg_list_del(&ad->l);
- free(ad);
- }
-
release_tablet_manager_seat(xwl_seat);
release_grab(xwl_seat);
@@ -1901,6 +2132,9 @@ tablet_tool_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool,
if (wl_surface == NULL)
return;
+ if (!is_surface_from_xwl_window(wl_surface))
+ return;
+
xwl_tablet_tool->proximity_in_serial = serial;
xwl_seat->tablet_focus_window = wl_surface_get_user_data(wl_surface);
@@ -1956,6 +2190,7 @@ tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool,
{
struct xwl_tablet_tool *xwl_tablet_tool = data;
struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
int32_t dx, dy;
double sx = wl_fixed_to_double(x);
double sy = wl_fixed_to_double(y);
@@ -1963,8 +2198,14 @@ tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool,
if (!xwl_seat->tablet_focus_window)
return;
- dx = xwl_seat->tablet_focus_window->window->drawable.x;
- dy = xwl_seat->tablet_focus_window->window->drawable.y;
+ sx *= xwl_screen->global_surface_scale;
+ sy *= xwl_screen->global_surface_scale;
+
+ sx *= xwl_seat->tablet_focus_window->viewport_scale_x;
+ sy *= xwl_seat->tablet_focus_window->viewport_scale_y;
+
+ dx = xwl_seat->tablet_focus_window->toplevel->drawable.x;
+ dy = xwl_seat->tablet_focus_window->toplevel->drawable.y;
xwl_tablet_tool->x = (double) dx + sx;
xwl_tablet_tool->y = (double) dy + sy;
@@ -1996,12 +2237,19 @@ tablet_tool_tilt(void *data, struct zwp_tablet_tool_v2 *tool,
{
struct xwl_tablet_tool *xwl_tablet_tool = data;
struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
if (!xwl_seat->tablet_focus_window)
return;
xwl_tablet_tool->tilt_x = wl_fixed_to_double(tilt_x);
xwl_tablet_tool->tilt_y = wl_fixed_to_double(tilt_y);
+
+ xwl_tablet_tool->tilt_x *= xwl_screen->global_surface_scale;
+ xwl_tablet_tool->tilt_y *= xwl_screen->global_surface_scale;
+
+ xwl_tablet_tool->tilt_x *= xwl_seat->tablet_focus_window->viewport_scale_x;
+ xwl_tablet_tool->tilt_y *= xwl_seat->tablet_focus_window->viewport_scale_y;
}
static void
@@ -2824,6 +3072,16 @@ init_keyboard_grab(struct xwl_screen *xwl_screen,
}
}
+static void
+init_keyboard_shortcuts_inhibit(struct xwl_screen *xwl_screen,
+ uint32_t id, uint32_t version)
+{
+ xwl_screen->shortcuts_inhibit_manager =
+ wl_registry_bind(xwl_screen->registry, id,
+ &zwp_keyboard_shortcuts_inhibit_manager_v1_interface,
+ 1);
+}
+
/* The compositor may send us wl_seat and its capabilities before sending e.g.
relative_pointer_manager or pointer_gesture interfaces. This would result in
devices being created in capabilities handler, but listeners not, because
@@ -2858,21 +3116,23 @@ input_handler(void *data, struct wl_registry *registry, uint32_t id,
{
struct xwl_screen *xwl_screen = data;
- if (strcmp(interface, "wl_seat") == 0 && version >= 3) {
+ if (strcmp(interface, wl_seat_interface.name) == 0 && version >= 3) {
create_input_device(xwl_screen, id, version);
xwl_screen->expecting_event++;
- } else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
+ } else if (strcmp(interface, zwp_relative_pointer_manager_v1_interface.name) == 0) {
init_relative_pointer_manager(xwl_screen, id, version);
maybe_init_relative_pointer_listeners_after_capabilities(xwl_screen);
- } else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
+ } else if (strcmp(interface, zwp_pointer_constraints_v1_interface.name) == 0) {
init_pointer_constraints(xwl_screen, id, version);
- } else if (strcmp(interface, "zwp_pointer_gestures_v1") == 0) {
+ } else if (strcmp(interface, zwp_pointer_gestures_v1_interface.name) == 0) {
init_pointer_gestures(xwl_screen, id, version);
maybe_init_pointer_gesture_listeners_after_capabilities(xwl_screen);
- } else if (strcmp(interface, "zwp_tablet_manager_v2") == 0) {
+ } else if (strcmp(interface, zwp_tablet_manager_v2_interface.name) == 0) {
init_tablet_manager(xwl_screen, id, version);
- } else if (strcmp(interface, "zwp_xwayland_keyboard_grab_manager_v1") == 0) {
+ } else if (strcmp(interface, zwp_xwayland_keyboard_grab_manager_v1_interface.name) == 0) {
init_keyboard_grab(xwl_screen, id, version);
+ } else if (strcmp(interface, zwp_keyboard_shortcuts_inhibit_manager_v1_interface.name) == 0) {
+ init_keyboard_shortcuts_inhibit(xwl_screen, id, version);
}
}
@@ -2934,8 +3194,9 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
return TRUE;
if (xwl_seat->focus_window == NULL &&
- xwl_seat->last_xwindow != NullWindow &&
- (IsParent(xwl_seat->last_xwindow, window) || xwl_seat->last_xwindow == window))
+ xwl_seat->last_focus_window != NULL &&
+ (xwl_seat->last_focus_window->toplevel == window ||
+ IsParent(xwl_seat->last_focus_window->toplevel, window)))
return TRUE;
return FALSE;
@@ -2969,13 +3230,13 @@ xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
}
void
-xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window)
+xwl_seat_clear_touch(struct xwl_seat *xwl_seat, struct xwl_window *xwl_window)
{
struct xwl_touch *xwl_touch, *next_xwl_touch;
xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch,
&xwl_seat->touches, link_touch) {
- if (xwl_touch->window->window == window) {
+ if (xwl_touch->window == xwl_window) {
xorg_list_del(&xwl_touch->link_touch);
free(xwl_touch);
}
@@ -2998,7 +3259,7 @@ xwl_pointer_warp_emulator_set_fake_pos(struct xwl_pointer_warp_emulator *warp_em
if (!warp_emulator->xwl_seat->focus_window)
return;
- window = warp_emulator->xwl_seat->focus_window->window;
+ window = warp_emulator->xwl_seat->focus_window->toplevel;
if (x >= window->drawable.x ||
y >= window->drawable.y ||
x < (window->drawable.x + window->drawable.width) ||
@@ -3067,7 +3328,7 @@ xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator *warp_emul
if (pointer_grab &&
!pointer_grab->ownerEvents &&
sprite &&
- XYToWindow(sprite, x, y) != xwl_seat->focus_window->window)
+ XYToWindow(sprite, x, y) != xwl_seat->focus_window->toplevel)
return;
xwl_pointer_warp_emulator_lock(warp_emulator);
@@ -3105,7 +3366,7 @@ xwl_pointer_warp_emulator_handle_motion(struct xwl_pointer_warp_emulator *warp_e
QueuePointerEvents(xwl_seat->relative_pointer, MotionNotify, 0,
POINTER_RELATIVE, &mask);
- window = xwl_seat->focus_window->window;
+ window = xwl_seat->focus_window->toplevel;
miPointerGetPosition(xwl_seat->pointer, &x, &y);
if (xwl_pointer_warp_emulator_is_locked(warp_emulator) &&
@@ -3202,6 +3463,8 @@ xwl_seat_emulate_pointer_warp(struct xwl_seat *xwl_seat,
static Bool
xwl_seat_maybe_lock_on_hidden_cursor(struct xwl_seat *xwl_seat)
{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+
/* Some clients use hidden cursor+confineTo+relative motion
* to implement infinite panning (eg. 3D views), lock the
* pointer for so the relative pointer is used.
@@ -3212,6 +3475,9 @@ xwl_seat_maybe_lock_on_hidden_cursor(struct xwl_seat *xwl_seat)
if (!xwl_seat->focus_window)
return FALSE;
+ if (!xwl_screen->rootless)
+ return FALSE;
+
if (xwl_seat->cursor_confinement_window != xwl_seat->focus_window)
return FALSE;
@@ -3322,10 +3588,17 @@ InitInput(int argc, char *argv[])
pScreen->XYToWindow = xwl_xy_to_window;
xwl_screen_roundtrip(xwl_screen);
+#ifdef XWL_HAS_EI
+ if (xwl_screen->rootless)
+ xwayland_override_xtest();
+#endif
}
void
CloseInput(void)
{
+#ifdef XWL_HAS_EI
+ xwayland_restore_xtest();
+#endif
mieqFini();
}
diff --git a/hw/xwayland/xwayland-input.h b/hw/xwayland/xwayland-input.h
index dbe215bdb..d40bca08a 100644
--- a/hw/xwayland/xwayland-input.h
+++ b/hw/xwayland/xwayland-input.h
@@ -81,7 +81,7 @@ struct xwl_seat {
OsTimerPtr x_cursor_timer;
CursorPtr pending_x_cursor;
struct xwl_cursor cursor;
- WindowPtr last_xwindow;
+ struct xwl_window *last_focus_window;
uint32_t pointer_gesture_swipe_fingers;
uint32_t pointer_gesture_pinch_fingers;
@@ -93,7 +93,6 @@ struct xwl_seat {
char *keymap;
struct wl_surface *keyboard_focus;
- struct xorg_list axis_discrete_pending;
struct xorg_list sync_pending;
struct xwl_pointer_warp_emulator *pointer_warp_emulator;
@@ -111,6 +110,15 @@ struct xwl_seat {
double dy;
double dx_unaccel;
double dy_unaccel;
+
+ wl_fixed_t scroll_dy;
+ wl_fixed_t scroll_dx;
+ int32_t scroll_dy_v120;
+ int32_t scroll_dx_v120;
+ Bool has_vertical_scroll;
+ Bool has_horizontal_scroll;
+ Bool has_vertical_scroll_v120;
+ Bool has_horizontal_scroll_v120;
} pending_pointer_event;
struct xorg_list tablets;
@@ -182,9 +190,12 @@ struct xwl_tablet_pad {
struct xorg_list pad_group_list;
};
+void xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost);
+void xwl_seat_leave_kbd(struct xwl_seat *xwl_seat);
+
void xwl_seat_destroy(struct xwl_seat *xwl_seat);
-void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window);
+void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, struct xwl_window *xwl_window);
void xwl_seat_emulate_pointer_warp(struct xwl_seat *xwl_seat,
struct xwl_window *xwl_window,
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 58764b7c3..7c8ebd49a 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -25,9 +25,13 @@
#include <xwayland-config.h>
-#include <randrstr.h>
+#include <math.h>
+
#include <X11/Xatom.h>
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
+
#include "xwayland-cvt.h"
#include "xwayland-output.h"
#include "xwayland-screen.h"
@@ -88,10 +92,12 @@ output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
{
struct xwl_output *xwl_output = data;
- RROutputSetPhysicalSize(xwl_output->randr_output,
- physical_width, physical_height);
- RROutputSetSubpixelOrder(xwl_output->randr_output,
- wl_subpixel_to_xrandr(subpixel));
+ if (xwl_output->randr_output) {
+ RROutputSetPhysicalSize(xwl_output->randr_output,
+ physical_width, physical_height);
+ RROutputSetSubpixelOrder(xwl_output->randr_output,
+ wl_subpixel_to_xrandr(subpixel));
+ }
/* Apply the change from wl_output only if xdg-output is not supported */
if (!xwl_output->xdg_output) {
@@ -180,9 +186,13 @@ update_backing_pixmaps(struct xwl_screen *xwl_screen, int width, int height)
}
static void
-update_screen_size(struct xwl_output *xwl_output, int width, int height)
+update_screen_size(struct xwl_screen *xwl_screen, int width, int height)
{
- struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+ if (xwl_screen_get_width(xwl_screen) != width)
+ xwl_screen->width = width;
+
+ if (xwl_screen_get_height(xwl_screen) != height)
+ xwl_screen->height = height;
if (xwl_screen->root_clip_mode == ROOT_CLIP_FULL)
SetRootClip(xwl_screen->screen, ROOT_CLIP_NONE);
@@ -190,8 +200,6 @@ update_screen_size(struct xwl_output *xwl_output, int width, int height)
if (!xwl_screen->rootless && xwl_screen->screen->root)
update_backing_pixmaps (xwl_screen, width, height);
- xwl_screen->width = width;
- xwl_screen->height = height;
xwl_screen->screen->width = width;
xwl_screen->screen->height = height;
xwl_screen->screen->mmWidth = (width * 25.4) / monitorResolution;
@@ -223,6 +231,10 @@ xwl_output_get_emulated_mode_for_client(struct xwl_output *xwl_output,
if (!xwl_output)
return NULL;
+ /* We don't do XRandr emulation when rootful or a fake lease display */
+ if (!xwl_output->xwl_screen->rootless || !xwl_output->output)
+ return NULL;
+
for (i = 0; i < XWL_CLIENT_MAX_EMULATED_MODES; i++) {
if (xwl_client->emulated_modes[i].server_output_id ==
xwl_output->server_output_id)
@@ -266,6 +278,7 @@ xwl_output_add_emulated_mode_for_client(struct xwl_output *xwl_output,
emulated_mode->server_output_id = xwl_output->server_output_id;
emulated_mode->width = mode->mode.width;
emulated_mode->height = mode->mode.height;
+ emulated_mode->id = mode->mode.id;
emulated_mode->from_vidmode = from_vidmode;
}
@@ -462,7 +475,7 @@ xwl_output_set_randr_emu_props(struct xwl_screen *xwl_screen, ClientPtr client)
struct xwl_output_randr_emu_prop prop = {};
xwl_output_randr_emu_prop(xwl_screen, client, &prop);
- FindClientResourcesByType(client, RT_WINDOW,
+ FindClientResourcesByType(client, X11_RESTYPE_WINDOW,
xwl_output_set_randr_emu_prop_callback, &prop);
}
@@ -478,8 +491,8 @@ xwl_output_get_emulated_root_size(struct xwl_output *xwl_output,
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, client);
/* If not an emulated mode, just return the actual screen size */
if (!emulated_mode) {
- *width = xwl_screen->width;
- *height = xwl_screen->height;
+ *width = xwl_screen_get_width(xwl_screen);
+ *height = xwl_screen_get_height(xwl_screen);
return;
}
@@ -590,6 +603,21 @@ xwl_output_set_emulated_mode(struct xwl_output *xwl_output, ClientPtr client,
}
static void
+maybe_update_fullscreen_state(struct xwl_output *xwl_output)
+{
+ struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+ struct xwl_window *xwl_window;
+
+ if (xwl_screen->fullscreen) {
+ /* The root window may not yet be created */
+ if (xwl_screen->screen->root) {
+ xwl_window = xwl_window_get(xwl_screen->screen->root);
+ xwl_window_rootful_update_fullscreen(xwl_window, xwl_output);
+ }
+ }
+}
+
+static void
apply_output_change(struct xwl_output *xwl_output)
{
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
@@ -613,17 +641,18 @@ apply_output_change(struct xwl_output *xwl_output)
mode_width = xwl_output->height;
mode_height = xwl_output->width;
}
-
- /* Build a fresh modes array using the current refresh rate */
- randr_modes = output_get_rr_modes(xwl_output, mode_width, mode_height, &count);
- RROutputSetModes(xwl_output->randr_output, randr_modes, count, 1);
- RRCrtcNotify(xwl_output->randr_crtc, randr_modes[0],
- xwl_output->x, xwl_output->y,
- xwl_output->rotation, NULL, 1, &xwl_output->randr_output);
- /* RROutputSetModes takes ownership of the passed in modes, so we only
- * have to free the pointer array.
- */
- free(randr_modes);
+ if (xwl_output->randr_output) {
+ /* Build a fresh modes array using the current refresh rate */
+ randr_modes = output_get_rr_modes(xwl_output, mode_width, mode_height, &count);
+ RROutputSetModes(xwl_output->randr_output, randr_modes, count, 1);
+ RRCrtcNotify(xwl_output->randr_crtc, randr_modes[0],
+ xwl_output->x, xwl_output->y,
+ xwl_output->rotation, NULL, 1, &xwl_output->randr_output);
+ /* RROutputSetModes takes ownership of the passed in modes, so we only
+ * have to free the pointer array.
+ */
+ free(randr_modes);
+ }
xorg_list_for_each_entry(it, &xwl_screen->output_list, link) {
/* output done event is sent even when some property
@@ -645,15 +674,67 @@ apply_output_change(struct xwl_output *xwl_output)
--xwl_screen->expecting_event;
}
- update_screen_size(xwl_output, width, height);
+ if (xwl_screen->fixed_output == NULL)
+ update_screen_size(xwl_screen, width, height);
+ else
+ RRTellChanged(xwl_screen->screen);
+
+ /* If running rootful and fullscreen, make sure to match the new setup */
+ maybe_update_fullscreen_state(xwl_output);
+}
+
+void
+xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
+{
+ struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+ rrScrPrivPtr pScrPriv;
+ RRLeasePtr lease;
+ int i;
+
+ if (xwl_output->randr_output == NULL)
+ return; /* rootful */
+
+ /* Check whether the compositor is sending us something useful */
+ if (!name || !strlen(name)) {
+ ErrorF("Not using the provided output name, invalid");
+ return;
+ }
+
+ /* Check for duplicate names to be safe */
+ pScrPriv = rrGetScrPriv(xwl_screen->screen);
+ for (i = 0; i < pScrPriv->numOutputs; i++) {
+ if (!strcmp(name, pScrPriv->outputs[i]->name)) {
+ ErrorF("An output named '%s' already exists", name);
+ return;
+ }
+ }
+ /* And leases' names as well */
+ xorg_list_for_each_entry(lease, &pScrPriv->leases, list) {
+ for (i = 0; i < lease->numOutputs; i++) {
+ if (!strcmp(name, pScrPriv->outputs[i]->name)) {
+ ErrorF("A lease output named '%s' already exists", name);
+ return;
+ }
+ }
+ }
+
+ snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name);
+ xwl_output->randr_output->nameLength = strlen(xwl_output->randr_output->name);
+
+ if (xwl_screen->output_name && strcmp(name, xwl_screen->output_name) == 0)
+ maybe_update_fullscreen_state(xwl_output);
}
static void
output_handle_done(void *data, struct wl_output *wl_output)
{
struct xwl_output *xwl_output = data;
+ struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
xwl_output->wl_output_done = TRUE;
+ if (xwl_screen->fixed_output)
+ return;
+
/* Apply the changes from wl_output only if both "done" events are received,
* if xdg-output is not supported or if xdg-output version is high enough.
*/
@@ -665,13 +746,33 @@ output_handle_done(void *data, struct wl_output *wl_output)
static void
output_handle_scale(void *data, struct wl_output *wl_output, int32_t factor)
{
+ struct xwl_output *xwl_output = data;
+
+ xwl_output->scale = factor;
+}
+
+static void
+output_handle_name(void *data, struct wl_output *wl_output,
+ const char *name)
+{
+ struct xwl_output *xwl_output = data;
+
+ xwl_output_set_name(xwl_output, name);
+}
+
+static void
+output_handle_description(void *data, struct wl_output *wl_output,
+ const char *description)
+{
}
static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
- output_handle_scale
+ output_handle_scale,
+ output_handle_name,
+ output_handle_description,
};
static void
@@ -698,8 +799,13 @@ static void
xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
{
struct xwl_output *xwl_output = data;
+ struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
xwl_output->xdg_output_done = TRUE;
+
+ if (xwl_screen->fixed_output)
+ return;
+
if (xwl_output->wl_output_done &&
zxdg_output_v1_get_version(xdg_output) < 3)
apply_output_change(xwl_output);
@@ -709,6 +815,12 @@ static void
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
const char *name)
{
+ struct xwl_output *xwl_output = data;
+
+ if (wl_output_get_version(xwl_output->output) >= 4)
+ return; /* wl_output.name is preferred */
+
+ xwl_output_set_name(xwl_output, name);
}
static void
@@ -746,11 +858,47 @@ xwl_output_set_emulated(struct xwl_output *xwl_output)
&val, FALSE, FALSE);
}
+struct xwl_output*
+xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
+ struct wl_output* wl_output)
+{
+ struct xwl_output *xwl_output;
+
+ xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
+ if (xwl_output->output == wl_output)
+ return xwl_output;
+ }
+
+ return NULL;
+}
+
+
+struct xwl_output *
+xwl_output_get_output_from_name(struct xwl_screen *xwl_screen, const char *name)
+{
+ struct xwl_output *xwl_output;
+
+ if (name == NULL)
+ return NULL;
+
+ xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
+ if (xwl_output->randr_output == NULL)
+ continue;
+
+ if (strcmp(xwl_output->randr_output->name, name) == 0) {
+ return xwl_output;
+ }
+ }
+
+ return NULL;
+}
+
struct xwl_output *
-xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
+xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
+ Bool connected, uint32_t version)
{
struct xwl_output *xwl_output;
- char name[256];
+ char name[MAX_OUTPUT_NAME] = { 0 };
xwl_output = calloc(1, sizeof *xwl_output);
if (xwl_output == NULL) {
@@ -759,7 +907,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
}
xwl_output->output = wl_registry_bind(xwl_screen->registry, id,
- &wl_output_interface, 2);
+ &wl_output_interface, min(version, 4));
if (!xwl_output->output) {
ErrorF("Failed binding wl_output\n");
goto err;
@@ -767,10 +915,10 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
xwl_output->server_output_id = id;
wl_output_add_listener(xwl_output->output, &output_listener, xwl_output);
-
- snprintf(name, sizeof name, "XWAYLAND%d", xwl_get_next_output_serial());
+ xwl_output->xscale = 1.0;
xwl_output->xwl_screen = xwl_screen;
+
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
if (!xwl_output->randr_crtc) {
ErrorF("Failed creating RandR CRTC\n");
@@ -778,18 +926,23 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
}
RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
+ /* Allocate MAX_OUTPUT_NAME data for the output name, all filled with zeros */
xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
- strlen(name), xwl_output);
+ MAX_OUTPUT_NAME, xwl_output);
if (!xwl_output->randr_output) {
ErrorF("Failed creating RandR Output\n");
goto err;
}
+ /* Set the default output name to a sensible value */
+ snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+ xwl_screen_get_next_output_serial(xwl_screen));
+ xwl_output_set_name(xwl_output, name);
xwl_output_set_emulated(xwl_output);
RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
- RROutputSetConnection(xwl_output->randr_output, RR_Connected);
- RRTellChanged(xwl_screen->screen);
+ RROutputSetConnection(xwl_output->randr_output,
+ connected ? RR_Connected : RR_Disconnected);
/* We want the output to be in the list as soon as created so we can
* use it when binding to the xdg-output protocol...
@@ -816,6 +969,8 @@ xwl_output_destroy(struct xwl_output *xwl_output)
{
if (xwl_output->lease_connector)
wp_drm_lease_connector_v1_destroy(xwl_output->lease_connector);
+ if (xwl_output->transform)
+ free(xwl_output->transform);
if (xwl_output->xdg_output)
zxdg_output_v1_destroy(xwl_output->xdg_output);
if (xwl_output->output)
@@ -828,18 +983,30 @@ xwl_output_remove(struct xwl_output *xwl_output)
{
struct xwl_output *it;
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+ struct xwl_window *xwl_window;
int width = 0, height = 0;
+ /* Not all compositors send a "leave" event on output removal */
+ xorg_list_for_each_entry(xwl_window, &xwl_screen->window_list, link_window)
+ xwl_window_leave_output(xwl_window, xwl_output);
+
xorg_list_del(&xwl_output->link);
- xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
- output_get_new_size(it, &width, &height);
- update_screen_size(xwl_output, width, height);
+ if (xwl_output->randr_output)
+ RROutputSetConnection(xwl_output->randr_output, RR_Disconnected);
- RRCrtcDestroy(xwl_output->randr_crtc);
- RROutputDestroy(xwl_output->randr_output);
- RRTellChanged(xwl_screen->screen);
+ if (xwl_screen->fixed_output == NULL) {
+ xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
+ output_get_new_size(it, &width, &height);
+ update_screen_size(xwl_screen, width, height);
+ }
+ if (xwl_output->randr_crtc)
+ RRCrtcDestroy(xwl_output->randr_crtc);
+ if (xwl_output->randr_output) {
+ RROutputDestroy(xwl_output->randr_output);
+ RRTellChanged(xwl_screen->screen);
+ }
xwl_output_destroy(xwl_output);
}
@@ -905,6 +1072,20 @@ xwl_randr_crtc_set(ScreenPtr pScreen,
return TRUE;
}
+static void
+xwl_randr_crtc_get(ScreenPtr pScreen,
+ RRCrtcPtr crtc,
+ xRRGetCrtcInfoReply *rep)
+{
+ struct xwl_output *xwl_output = crtc->devPrivate;
+
+ struct xwl_emulated_mode *mode = xwl_output_get_emulated_mode_for_client(
+ xwl_output, GetCurrentClient());
+
+ if (mode)
+ rep->mode = mode->id;
+}
+
static Bool
xwl_randr_crtc_set_gamma(ScreenPtr pScreen, RRCrtcPtr crtc)
{
@@ -965,6 +1146,7 @@ xwl_screen_init_output(struct xwl_screen *xwl_screen)
#if RANDR_12_INTERFACE
rp->rrScreenSetSize = xwl_randr_screen_set_size;
rp->rrCrtcSet = xwl_randr_crtc_set;
+ rp->rrCrtcGet = xwl_randr_crtc_get;
rp->rrCrtcSetGamma = xwl_randr_crtc_set_gamma;
rp->rrCrtcGetGamma = xwl_randr_crtc_get_gamma;
rp->rrOutputSetProperty = xwl_randr_output_set_property;
@@ -979,6 +1161,205 @@ xwl_screen_init_output(struct xwl_screen *xwl_screen)
return TRUE;
}
+static int
+mode_sort(const void *left, const void *right)
+{
+ const RRModePtr *mode_a = left;
+ const RRModePtr *mode_b = right;
+
+ if ((*mode_b)->mode.width == (*mode_a)->mode.width)
+ return (*mode_b)->mode.height - (*mode_a)->mode.height;
+
+ return (*mode_b)->mode.width - (*mode_a)->mode.width;
+}
+
+static void
+xwl_output_set_transform(struct xwl_output *xwl_output)
+{
+ pixman_fixed_t transform_xscale;
+ RRModePtr mode;
+
+ mode = xwl_output_find_mode(xwl_output, xwl_output->mode_width, xwl_output->mode_height);
+ if (!mode) {
+ ErrorF("XWAYLAND: Failed to find mode for %ix%i\n",
+ xwl_output->mode_width, xwl_output->mode_height);
+ return;
+ }
+
+ if (xwl_output->transform == NULL) {
+ xwl_output->transform = xnfalloc(sizeof(RRTransformRec));
+ RRTransformInit(xwl_output->transform);
+ }
+
+ transform_xscale = pixman_double_to_fixed(xwl_output->xscale);
+ pixman_transform_init_scale(&xwl_output->transform->transform,
+ transform_xscale, transform_xscale);
+ pixman_f_transform_init_scale(&xwl_output->transform->f_transform,
+ xwl_output->xscale, xwl_output->xscale);
+ pixman_f_transform_invert(&xwl_output->transform->f_inverse,
+ &xwl_output->transform->f_transform);
+
+ RRCrtcNotify(xwl_output->randr_crtc, mode, 0, 0, RR_Rotate_0,
+ xwl_output->transform, 1, &xwl_output->randr_output);
+}
+
+void
+xwl_output_set_xscale(struct xwl_output *xwl_output, double xscale)
+{
+ xwl_output->xscale = xscale;
+ xwl_output_set_transform(xwl_output);
+}
+
+Bool
+xwl_randr_add_modes_fixed(struct xwl_output *xwl_output,
+ int current_width, int current_height)
+{
+ RRModePtr *modes = NULL;
+ RRModePtr mode;
+ int i, nmodes, current;
+
+ modes = xallocarray(ARRAY_SIZE(xwl_output_fake_modes) + 1, sizeof(RRModePtr));
+ if (!modes) {
+ ErrorF("Failed to allocated RandR modes\n");
+ return FALSE;
+ }
+
+ xwl_output->mode_width = current_width;
+ xwl_output->mode_height = current_height;
+
+ nmodes = 0;
+ current = 0;
+
+ /* Add fake modes */
+ for (i = 0; i < ARRAY_SIZE(xwl_output_fake_modes); i++) {
+ if (xwl_output_fake_modes[i][0] == current_width &&
+ xwl_output_fake_modes[i][1] == current_height)
+ current = 1;
+
+ mode = xwayland_cvt(xwl_output_fake_modes[i][0],
+ xwl_output_fake_modes[i][1],
+ 60, 0, 0);
+
+ if (mode)
+ modes[nmodes++] = mode;
+ }
+
+ if (!current) {
+ /* Add the current mode as it's not part of the fake modes. */
+ mode = xwayland_cvt(current_width, current_height, 60, 0, 0);
+
+ if (mode)
+ modes[nmodes++] = mode;
+ }
+
+ qsort(modes, nmodes, sizeof(RRModePtr), mode_sort);
+ RROutputSetModes(xwl_output->randr_output, modes, nmodes, 1);
+ free(modes);
+
+ return TRUE;
+}
+
+void
+xwl_output_set_mode_fixed(struct xwl_output *xwl_output, RRModePtr mode)
+{
+ struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+
+ xwl_output->mode_width = mode->mode.width;
+ xwl_output->mode_height = mode->mode.height;
+
+ update_screen_size(xwl_screen,
+ round((double) mode->mode.width * xwl_output->xscale),
+ round((double) mode->mode.height * xwl_output->xscale));
+
+ xwl_output_set_transform(xwl_output);
+}
+
+static Bool
+xwl_randr_set_config_fixed(ScreenPtr pScreen,
+ Rotation randr, int rate, RRScreenSizePtr pSize)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
+
+ update_screen_size(xwl_screen, pSize->width, pSize->height);
+
+ return TRUE;
+}
+
+/* Create a single RR output/mode used with a fixed geometry */
+Bool
+xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen)
+{
+ struct xwl_output *xwl_output;
+ char name[MAX_OUTPUT_NAME] = { 0 };
+ rrScrPrivPtr rp;
+ RRModePtr mode;
+
+ xwl_output = calloc(1, sizeof *xwl_output);
+ if (xwl_output == NULL) {
+ ErrorF("%s ENOMEM\n", __func__);
+ return FALSE;
+ }
+
+ if (!RRScreenInit(xwl_screen->screen))
+ goto err;
+
+ RRScreenSetSizeRange(xwl_screen->screen, 16, 16, 32767, 32767);
+
+ rp = rrGetScrPriv(xwl_screen->screen);
+ rp->rrGetInfo = xwl_randr_get_info;
+ rp->rrSetConfig = xwl_randr_set_config_fixed;
+
+ snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+ xwl_screen_get_next_output_serial(xwl_screen));
+ xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
+ strlen(name), NULL);
+ if (!xwl_output->randr_output) {
+ ErrorF("Failed to create RandR output\n");
+ goto err;
+ }
+
+ xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
+ if (!xwl_output->randr_crtc) {
+ ErrorF("Failed to create RandR CRTC\n");
+ goto err;
+ }
+ RRCrtcSetRotations (xwl_output->randr_crtc, RR_Rotate_0);
+ RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
+ RRCrtcSetTransformSupport(xwl_output->randr_crtc, TRUE);
+ RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
+
+ xwl_randr_add_modes_fixed(xwl_output,
+ xwl_screen_get_width(xwl_screen),
+ xwl_screen_get_height(xwl_screen));
+ /* Current mode */
+ mode = xwl_output_find_mode(xwl_output,
+ xwl_screen_get_width(xwl_screen),
+ xwl_screen_get_height(xwl_screen));
+ RRCrtcNotify(xwl_output->randr_crtc, mode, 0, 0, RR_Rotate_0,
+ NULL, 1, &xwl_output->randr_output);
+
+ RROutputSetPhysicalSize(xwl_output->randr_output,
+ (xwl_screen->width * 25.4) / monitorResolution,
+ (xwl_screen->height * 25.4) / monitorResolution);
+
+ RROutputSetConnection(xwl_output->randr_output, RR_Connected);
+
+ xwl_output->xwl_screen = xwl_screen;
+ xwl_screen->fixed_output = xwl_output;
+ xwl_output->xscale = 1.0;
+
+ return TRUE;
+
+err:
+ if (xwl_output->randr_crtc)
+ RRCrtcDestroy(xwl_output->randr_crtc);
+ if (xwl_output->randr_output)
+ RROutputDestroy(xwl_output->randr_output);
+ free(xwl_output);
+
+ return FALSE;
+}
+
static void
xwl_output_get_xdg_output(struct xwl_output *xwl_output)
{
@@ -1009,10 +1390,3 @@ xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen)
xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
xwl_output_get_xdg_output(it);
}
-
-int
-xwl_get_next_output_serial(void)
-{
- static int output_name_serial = 0;
- return output_name_serial++;
-}
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index 74a46994f..5e070f90d 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -43,17 +43,22 @@
RR_Reflect_X | \
RR_Reflect_Y)
+#define MAX_OUTPUT_NAME 256
+
struct xwl_output {
struct xorg_list link;
struct xwl_screen *xwl_screen;
RROutputPtr randr_output;
RRCrtcPtr randr_crtc;
+ RRTransformPtr transform;
/* only for regular outputs */
struct wl_output *output;
struct zxdg_output_v1 *xdg_output;
uint32_t server_output_id;
- int32_t x, y, width, height, refresh;
+ int32_t x, y, width, height, refresh, scale;
+ int32_t mode_width, mode_height;
+ double xscale; /* Effective scale, can be fractional */
Rotation rotation;
Bool wl_output_done;
Bool xdg_output_done;
@@ -69,13 +74,34 @@ struct xwl_emulated_mode {
uint32_t server_output_id;
int32_t width;
int32_t height;
+ RRMode id;
Bool from_vidmode;
};
Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
+void xwl_output_set_name(struct xwl_output *xwl_output, const char *name);
+
+Bool xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen);
+
+void
+xwl_output_set_xscale(struct xwl_output *xwl_output, double xscale);
+
+Bool
+xwl_randr_add_modes_fixed(struct xwl_output *xwl_output,
+ int current_width, int current_height);
+
+void xwl_output_set_mode_fixed(struct xwl_output *xwl_output,
+ RRModePtr mode);
+
+struct xwl_output *xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
+ struct wl_output* wl_output);
+struct xwl_output *xwl_output_get_output_from_name(struct xwl_screen *xwl_screen,
+ const char *name);
+
struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
- uint32_t id);
+ uint32_t id, Bool connected,
+ uint32_t version);
void xwl_output_destroy(struct xwl_output *xwl_output);
@@ -94,6 +120,4 @@ void xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
-int xwl_get_next_output_serial(void);
-
#endif /* XWAYLAND_OUTPUT_H */
diff --git a/hw/xwayland/xwayland-pixmap.c b/hw/xwayland/xwayland-pixmap.c
index 6e797a34c..8e929f029 100644
--- a/hw/xwayland/xwayland-pixmap.c
+++ b/hw/xwayland/xwayland-pixmap.c
@@ -33,8 +33,13 @@
#include "fb.h"
#include "pixmapstr.h"
+#ifdef XWL_HAS_GLAMOR
+#include "xwayland-glamor.h"
+#endif
#include "xwayland-types.h"
#include "xwayland-pixmap.h"
+#include "xwayland-screen.h"
+#include "xwayland-shm.h"
#include "xwayland-window-buffers.h"
static DevPrivateKeyRec xwl_pixmap_private_key;
@@ -57,6 +62,19 @@ xwl_pixmap_get(PixmapPtr pixmap)
return dixLookupPrivate(&pixmap->devPrivates, &xwl_pixmap_private_key);
}
+struct wl_buffer *
+xwl_pixmap_get_wl_buffer(PixmapPtr pixmap)
+{
+#ifdef XWL_HAS_GLAMOR
+ struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
+
+ if (xwl_screen->glamor)
+ return xwl_glamor_pixmap_get_wl_buffer(pixmap);
+ else
+#endif
+ return xwl_shm_pixmap_get_wl_buffer(pixmap);
+}
+
Bool
xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap,
xwl_buffer_release_cb func, void *data)
diff --git a/hw/xwayland/xwayland-pixmap.h b/hw/xwayland/xwayland-pixmap.h
index 06ee4898a..036b532ef 100644
--- a/hw/xwayland/xwayland-pixmap.h
+++ b/hw/xwayland/xwayland-pixmap.h
@@ -38,10 +38,17 @@ typedef void (*xwl_buffer_release_cb) (void *data);
void xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap);
struct xwl_pixmap *xwl_pixmap_get(PixmapPtr pixmap);
+struct wl_buffer *xwl_pixmap_get_wl_buffer(PixmapPtr pixmap);
Bool xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap,
xwl_buffer_release_cb func, void *data);
void xwl_pixmap_del_buffer_release_cb(PixmapPtr pixmap);
void xwl_pixmap_buffer_release_cb(void *data, struct wl_buffer *wl_buffer);
Bool xwl_pixmap_init(void);
+static inline Bool
+xwl_is_client_pixmap(PixmapPtr pixmap)
+{
+ return clients[CLIENT_ID(pixmap->drawable.id)] != serverClient;
+}
+
#endif /* XWAYLAND_PIXMAP_H */
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 99e476b2f..43f053dfb 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -25,17 +25,25 @@
#include <xwayland-config.h>
+#include <compint.h>
+#ifdef XWL_HAS_GLAMOR
+#include <glamor.h>
+#endif
#include <windowstr.h>
#include <present.h>
+#include <sys/eventfd.h>
#include "xwayland-present.h"
#include "xwayland-screen.h"
+#include "xwayland-shm.h"
#include "xwayland-window.h"
+#include "xwayland-window-buffers.h"
#include "xwayland-pixmap.h"
-#include "glamor.h"
+#include "tearing-control-v1-client-protocol.h"
+#include "linux-drm-syncobj-v1-client-protocol.h"
-#define XWL_PRESENT_CAPS PresentCapabilityAsync
+#define XWL_PRESENT_CAPS PresentCapabilityAsync | PresentCapabilityAsyncMayTear
/*
@@ -74,6 +82,7 @@ xwl_present_window_get_priv(WindowPtr window)
xorg_list_init(&xwl_present_window->wait_list);
xorg_list_init(&xwl_present_window->flip_queue);
xorg_list_init(&xwl_present_window->idle_queue);
+ xorg_list_init(&xwl_present_window->blocked_queue);
dixSetPrivate(&window->devPrivates,
&xwl_present_window_private_key,
@@ -84,9 +93,49 @@ xwl_present_window_get_priv(WindowPtr window)
}
static struct xwl_present_event *
-xwl_present_event_from_id(uint64_t event_id)
+xwl_present_event_from_id(WindowPtr present_window, uint64_t event_id)
+{
+ present_window_priv_ptr window_priv = present_get_window_priv(present_window, TRUE);
+ struct xwl_present_event *event;
+
+ xorg_list_for_each_entry(event, &window_priv->vblank, vblank.window_list) {
+ if (event->vblank.event_id == event_id)
+ return event;
+ }
+ return NULL;
+}
+
+static struct xwl_present_event *
+xwl_present_event_from_vblank(present_vblank_ptr vblank)
+{
+ return container_of(vblank, struct xwl_present_event, vblank);
+}
+
+static Bool entered_for_each_frame_callback;
+
+Bool
+xwl_present_entered_for_each_frame_callback(void)
{
- return (struct xwl_present_event*)(uintptr_t)event_id;
+ return entered_for_each_frame_callback;
+}
+
+void
+xwl_present_for_each_frame_callback(struct xwl_window *xwl_window,
+ void iter_func(struct xwl_present_window *))
+{
+ struct xwl_present_window *xwl_present_window, *tmp;
+
+ if (entered_for_each_frame_callback)
+ FatalError("Nested xwl_present_for_each_frame_callback call");
+
+ entered_for_each_frame_callback = TRUE;
+
+ xorg_list_for_each_entry_safe(xwl_present_window, tmp,
+ &xwl_window->frame_callback_list,
+ frame_callback_list)
+ iter_func(xwl_present_window);
+
+ entered_for_each_frame_callback = FALSE;
}
static void
@@ -125,7 +174,8 @@ xwl_present_has_pending_events(struct xwl_present_window *xwl_present_window)
present_vblank_ptr flip_pending = xwl_present_get_pending_flip(xwl_present_window);
return (flip_pending && flip_pending->sync_flip) ||
- !xorg_list_is_empty(&xwl_present_window->wait_list);
+ !xorg_list_is_empty(&xwl_present_window->wait_list) ||
+ !xorg_list_is_empty(&xwl_present_window->blocked_queue);
}
void
@@ -170,10 +220,18 @@ xwl_present_reset_timer(struct xwl_present_window *xwl_present_window)
static void
xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
+static int
+xwl_present_queue_vblank(ScreenPtr screen,
+ WindowPtr present_window,
+ RRCrtcPtr crtc,
+ uint64_t event_id,
+ uint64_t msc);
+
static uint32_t
xwl_present_query_capabilities(present_screen_priv_ptr screen_priv)
{
- return XWL_PRESENT_CAPS;
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen_priv->pScreen);
+ return xwl_screen->present_capabilities;
}
static int
@@ -192,6 +250,18 @@ xwl_present_get_ust_msc(ScreenPtr screen,
return Success;
}
+static uint64_t
+xwl_present_get_exec_msc(uint32_t options, uint64_t target_msc)
+{
+ /* Synchronous Xwayland presentations always complete (at least) one frame after they
+ * are executed
+ */
+ if (options & PresentOptionAsyncMayTear)
+ return target_msc;
+
+ return target_msc - 1;
+}
+
/*
* When the wait fence or previous flip is completed, it's time
* to re-try the request
@@ -199,9 +269,27 @@ xwl_present_get_ust_msc(ScreenPtr screen,
static void
xwl_present_re_execute(present_vblank_ptr vblank)
{
+ struct xwl_present_event *event = xwl_present_event_from_vblank(vblank);
uint64_t ust = 0, crtc_msc = 0;
(void) xwl_present_get_ust_msc(vblank->screen, vblank->window, &ust, &crtc_msc);
+ /* re-compute target / exec msc */
+ vblank->target_msc = present_get_target_msc(0, crtc_msc,
+ event->divisor,
+ event->remainder,
+ event->options);
+ vblank->exec_msc = xwl_present_get_exec_msc(event->options,
+ vblank->target_msc);
+
+ vblank->queued = TRUE;
+ if (msc_is_after(vblank->exec_msc, crtc_msc) &&
+ xwl_present_queue_vblank(vblank->screen, vblank->window,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->exec_msc) == Success) {
+ return;
+ }
+
xwl_present_execute(vblank, ust, crtc_msc);
}
@@ -240,8 +328,18 @@ xwl_present_free_event(struct xwl_present_event *event)
static void
xwl_present_free_idle_vblank(present_vblank_ptr vblank)
{
- present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
- xwl_present_free_event(xwl_present_event_from_id((uintptr_t)vblank));
+#ifdef XWL_HAS_GLAMOR
+ if (vblank->release_syncobj) {
+ /* transfer implicit fence to release syncobj */
+ int fence_fd = xwl_glamor_dmabuf_export_sync_file(vblank->pixmap);
+ vblank->release_syncobj->import_fence(vblank->release_syncobj,
+ vblank->release_point,
+ fence_fd);
+ } else
+#endif /* XWL_HAS_GLAMOR */
+ present_pixmap_idle(vblank->pixmap, vblank->window,
+ vblank->serial, vblank->idle_fence);
+ xwl_present_free_event(xwl_present_event_from_vblank(vblank));
}
static WindowPtr
@@ -279,7 +377,7 @@ xwl_present_flips_stop(WindowPtr window)
struct xwl_present_event *event;
vblank = xwl_present_window->flip_active;
- event = xwl_present_event_from_id((uintptr_t)vblank);
+ event = xwl_present_event_from_vblank(vblank);
if (event->pixmap)
xwl_present_free_idle_vblank(vblank);
else
@@ -295,7 +393,9 @@ static void
xwl_present_flip_notify_vblank(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
{
WindowPtr window = vblank->window;
+ struct xwl_screen *xwl_screen = xwl_screen_get(window->drawable.pScreen);
struct xwl_present_window *xwl_present_window = xwl_present_window_priv(window);
+ uint8_t mode = PresentCompleteModeFlip;
DebugPresent(("\tn %" PRIu64 " %p %" PRIu64 " %" PRIu64 ": %08" PRIx32 " -> %08" PRIx32 "\n",
vblank->event_id, vblank, vblank->exec_msc, vblank->target_msc,
@@ -308,11 +408,16 @@ xwl_present_flip_notify_vblank(present_vblank_ptr vblank, uint64_t ust, uint64_t
if (xwl_present_window->flip_active) {
struct xwl_present_event *event =
- xwl_present_event_from_id((uintptr_t)xwl_present_window->flip_active);
-
- if (!event->pixmap)
+ xwl_present_event_from_vblank(xwl_present_window->flip_active);
+
+ if (!event->pixmap
+#ifdef DRI3
+ /* If this flip used explicit sync, we won't get a release event */
+ || (xwl_screen->explicit_sync && vblank->release_syncobj)
+#endif /* DRI3 */
+ ) {
xwl_present_free_event(event);
- else
+ } else
/* Put the previous flip in the idle_queue and wait for further notice from
* the Wayland compositor
*/
@@ -321,7 +426,10 @@ xwl_present_flip_notify_vblank(present_vblank_ptr vblank, uint64_t ust, uint64_t
xwl_present_window->flip_active = vblank;
- present_vblank_notify(vblank, PresentCompleteKindPixmap, PresentCompleteModeFlip, ust, crtc_msc);
+ if (vblank->reason == PRESENT_FLIP_REASON_BUFFER_FORMAT)
+ mode = PresentCompleteModeSuboptimalCopy;
+
+ present_vblank_notify(vblank, PresentCompleteKindPixmap, mode, ust, crtc_msc);
if (vblank->abort_flip)
xwl_present_flips_stop(window);
@@ -369,12 +477,15 @@ xwl_present_cleanup(WindowPtr window)
xwl_present_window->sync_callback = NULL;
}
- /* Clear remaining events */
- xorg_list_for_each_entry_safe(event, tmp, &window_priv->vblank, vblank.window_list)
- xwl_present_free_event(event);
+ if (window_priv) {
+ /* Clear remaining events */
+ xorg_list_for_each_entry_safe(event, tmp, &window_priv->vblank, vblank.window_list)
+ xwl_present_free_event(event);
+ }
/* Clear timer */
xwl_present_free_timer(xwl_present_window);
+ TimerFree(xwl_present_window->unredirect_timer);
/* Remove from privates so we don't try to access it later */
dixSetPrivate(&window->devPrivates,
@@ -395,7 +506,17 @@ xwl_present_buffer_release(void *data)
return;
vblank = &event->vblank;
- present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
+
+#ifdef XWL_HAS_GLAMOR
+ if (vblank->release_syncobj) {
+ /* transfer implicit fence to release syncobj */
+ int fence_fd = xwl_glamor_dmabuf_export_sync_file(vblank->pixmap);
+ vblank->release_syncobj->import_fence(vblank->release_syncobj,
+ vblank->release_point,
+ fence_fd);
+ } else
+#endif /* XWL_HAS_GLAMOR */
+ present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
xwl_present_window = xwl_present_window_priv(vblank->window);
if (xwl_present_window->flip_active == vblank ||
@@ -509,7 +630,12 @@ xwl_present_queue_vblank(ScreenPtr screen,
{
struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(present_window);
struct xwl_window *xwl_window = xwl_window_from_window(present_window);
- struct xwl_present_event *event = xwl_present_event_from_id(event_id);
+ struct xwl_present_event *event = xwl_present_event_from_id(present_window, event_id);
+
+ if (!event) {
+ ErrorF("present: Error getting event\n");
+ return BadImplementation;
+ }
event->vblank.exec_msc = msc;
@@ -556,7 +682,46 @@ xwl_present_abort_vblank(ScreenPtr screen,
static void
xwl_present_flush(WindowPtr window)
{
- glamor_block_handler(window->drawable.pScreen);
+#ifdef XWL_HAS_GLAMOR
+ ScreenPtr screen = window->drawable.pScreen;
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+
+ if (xwl_screen->glamor)
+ glamor_block_handler(screen);
+#endif
+}
+
+static void
+xwl_present_maybe_set_reason(struct xwl_window *xwl_window, PresentFlipReason *reason)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+ if (!reason || xwl_screen->dmabuf_protocol_version < 4)
+ return;
+
+ if (xwl_window->feedback.unprocessed_feedback_pending) {
+ xwl_window->feedback.unprocessed_feedback_pending = 0;
+
+ *reason = PRESENT_FLIP_REASON_BUFFER_FORMAT;
+ }
+
+ if (xwl_screen->default_feedback.unprocessed_feedback_pending) {
+ xwl_screen->default_feedback.unprocessed_feedback_pending = 0;
+
+ *reason = PRESENT_FLIP_REASON_BUFFER_FORMAT;
+ }
+}
+
+static int
+xwl_present_flush_fenced(WindowPtr window)
+{
+ int fence = -1;
+#ifdef XWL_HAS_GLAMOR
+ struct xwl_screen *xwl_screen = xwl_screen_get(window->drawable.pScreen);
+ fence = xwl_glamor_get_fence(xwl_screen);
+#endif /* XWL_HAS_GLAMOR */
+ xwl_present_flush(window);
+ return fence;
}
static Bool
@@ -579,6 +744,8 @@ xwl_present_check_flip(RRCrtcPtr crtc,
if (!xwl_window)
return FALSE;
+ xwl_present_maybe_set_reason(xwl_window, reason);
+
if (!crtc)
return FALSE;
@@ -595,6 +762,9 @@ xwl_present_check_flip(RRCrtcPtr crtc,
present_window->drawable.height != pixmap->drawable.height)
return FALSE;
+ if (!xwl_pixmap_get_wl_buffer(pixmap))
+ return FALSE;
+
/* Window must be same region as toplevel window */
if ( !RegionEqual(&present_window->winSize, &toplvl_window->winSize) )
return FALSE;
@@ -603,14 +773,11 @@ xwl_present_check_flip(RRCrtcPtr crtc,
if (!RegionEqual(&present_window->clipList, &present_window->winSize))
return FALSE;
- if (!xwl_glamor_check_flip(pixmap))
- return FALSE;
-
/* Can't flip if the window pixmap doesn't match the xwl_window parent
* window's, e.g. because a client redirected this window or one of its
* parents.
*/
- if (screen->GetWindowPixmap(xwl_window->window) != screen->GetWindowPixmap(present_window))
+ if (screen->GetWindowPixmap(xwl_window->surface_window) != screen->GetWindowPixmap(present_window))
return FALSE;
/*
@@ -618,9 +785,19 @@ xwl_present_check_flip(RRCrtcPtr crtc,
* dimensions as their xwl_window parent window. For the case of
* different sizes subsurfaces are presumably the way forward.
*/
- if (!RegionEqual(&xwl_window->window->winSize, &present_window->winSize))
+ if (!RegionEqual(&xwl_window->toplevel->winSize, &present_window->winSize))
return FALSE;
+#ifdef XWL_HAS_GLAMOR
+ if (!xwl_glamor_supports_implicit_sync(xwl_window->xwl_screen) &&
+ !xwl_window->xwl_screen->explicit_sync)
+ return FALSE;
+
+ if (xwl_window->xwl_screen->glamor &&
+ !xwl_glamor_check_flip(present_window, pixmap))
+ return FALSE;
+#endif /* XWL_HAS_GLAMOR */
+
return TRUE;
}
@@ -678,23 +855,21 @@ xwl_present_clear_window_flip(WindowPtr window)
}
static Bool
-xwl_present_flip(WindowPtr present_window,
- RRCrtcPtr crtc,
- uint64_t event_id,
- PixmapPtr pixmap,
- Bool sync_flip,
- RegionPtr damage)
+xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage)
{
+ WindowPtr present_window = vblank->window;
+ PixmapPtr pixmap = vblank->pixmap;
struct xwl_window *xwl_window = xwl_window_from_window(present_window);
struct xwl_present_window *xwl_present_window = xwl_present_window_priv(present_window);
BoxPtr damage_box;
struct wl_buffer *buffer;
- struct xwl_present_event *event = xwl_present_event_from_id(event_id);
+ struct xwl_present_event *event = xwl_present_event_from_vblank(vblank);
+ Bool implicit_sync = TRUE;
if (!xwl_window)
return FALSE;
- buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
+ buffer = xwl_pixmap_get_wl_buffer(pixmap);
if (!buffer) {
ErrorF("present: Error getting buffer\n");
return FALSE;
@@ -706,7 +881,33 @@ xwl_present_flip(WindowPtr present_window,
event->pixmap = pixmap;
- xwl_pixmap_set_buffer_release_cb(pixmap, xwl_present_buffer_release, event);
+#ifdef XWL_HAS_GLAMOR
+ if (vblank->acquire_syncobj && vblank->release_syncobj) {
+ if (xwl_window->xwl_screen->explicit_sync) {
+ xwl_glamor_dri3_syncobj_passthrough(xwl_window,
+ vblank->acquire_syncobj,
+ vblank->release_syncobj,
+ vblank->acquire_point,
+ vblank->release_point);
+ implicit_sync = FALSE;
+ } else {
+ /* transfer from acquire syncobj to implicit fence */
+ int fence_fd =
+ vblank->acquire_syncobj->export_fence(vblank->acquire_syncobj,
+ vblank->acquire_point);
+ xwl_glamor_dmabuf_import_sync_file(vblank->pixmap, fence_fd);
+ }
+ }
+#endif /* XWL_HAS_GLAMOR */
+
+ if (implicit_sync) {
+ xwl_pixmap_set_buffer_release_cb(pixmap, xwl_present_buffer_release, event);
+
+ if (xwl_window->surface_sync) {
+ wp_linux_drm_syncobj_surface_v1_destroy(xwl_window->surface_sync);
+ xwl_window->surface_sync = NULL;
+ }
+ }
/* We can flip directly to the main surface (full screen window without clips) */
wl_surface_attach(xwl_window->surface, buffer, 0, 0);
@@ -725,9 +926,19 @@ xwl_present_flip(WindowPtr present_window,
damage_box->x2 - damage_box->x1,
damage_box->y2 - damage_box->y1);
+ if (xwl_window->tearing_control) {
+ uint32_t hint;
+ if (event->options & PresentOptionAsyncMayTear)
+ hint = WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
+ else
+ hint = WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC;
+
+ wp_tearing_control_v1_set_presentation_hint(xwl_window->tearing_control, hint);
+ }
+
wl_surface_commit(xwl_window->surface);
- if (!sync_flip) {
+ if (!vblank->sync_flip) {
xwl_present_window->sync_callback =
wl_display_sync(xwl_window->xwl_screen->display);
wl_callback_add_listener(xwl_present_window->sync_callback,
@@ -736,10 +947,73 @@ xwl_present_flip(WindowPtr present_window,
}
wl_display_flush(xwl_window->xwl_screen->display);
- xwl_window->present_flipped = TRUE;
return TRUE;
}
+#ifdef XWL_HAS_GLAMOR
+static void
+xwl_present_acquire_fence_avail(int fd, int xevents, void *data)
+{
+ present_vblank_ptr vblank = data;
+
+ SetNotifyFd(fd, NULL, 0, NULL);
+ close(fd);
+ vblank->efd = -1;
+
+ xwl_present_re_execute(vblank);
+}
+#endif /* XWL_HAS_GLAMOR */
+
+static Bool
+xwl_present_wait_acquire_fence_avail(struct xwl_screen *xwl_screen,
+ present_vblank_ptr vblank)
+{
+#ifdef XWL_HAS_GLAMOR
+ /* If the compositor does not support explicit sync we need to wait for the
+ * acquire fence to be submitted before flipping. */
+ if (vblank->flip && !xwl_screen->explicit_sync &&
+ vblank->pixmap && vblank->acquire_syncobj &&
+ !vblank->acquire_syncobj->has_fence(vblank->acquire_syncobj,
+ vblank->acquire_point)) {
+ vblank->efd = eventfd(0, EFD_CLOEXEC);
+ SetNotifyFd(vblank->efd, xwl_present_acquire_fence_avail, X_NOTIFY_READ, vblank);
+ vblank->acquire_syncobj->submitted_eventfd(vblank->acquire_syncobj,
+ vblank->acquire_point,
+ vblank->efd);
+ return TRUE;
+ }
+#endif /* XWL_HAS_GLAMOR */
+ return FALSE;
+}
+
+static void
+xwl_present_flush_blocked(struct xwl_present_window *xwl_present_window,
+ uint64_t crtc_msc)
+{
+ struct xwl_screen *xwl_screen =
+ xwl_screen_get(xwl_present_window->window->drawable.pScreen);
+ struct xwl_present_event *blocked_event, *tmp;
+
+ if (!xwl_present_window->blocking_event)
+ return;
+
+ xwl_present_window->blocking_event = 0;
+
+ xorg_list_for_each_entry_safe(blocked_event, tmp,
+ &xwl_present_window->blocked_queue,
+ blocked) {
+ present_vblank_ptr blocked_vblank = &blocked_event->vblank;
+ xorg_list_del(&blocked_event->blocked);
+ if (present_execute_wait(blocked_vblank, crtc_msc) ||
+ xwl_present_wait_acquire_fence_avail(xwl_screen, blocked_vblank)) {
+ xwl_present_window->blocking_event = blocked_vblank->event_id;
+ return;
+ }
+
+ xwl_present_re_execute(blocked_vblank);
+ }
+}
+
/*
* Once the required MSC has been reached, execute the pending request.
*
@@ -755,13 +1029,30 @@ xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
WindowPtr window = vblank->window;
struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(window);
present_vblank_ptr flip_pending = xwl_present_get_pending_flip(xwl_present_window);
+ struct xwl_present_event *event = xwl_present_event_from_vblank(vblank);
+ struct xwl_screen *xwl_screen = xwl_screen_get(window->drawable.pScreen);
+ Bool notify_only = !vblank->window || !vblank->pixmap;
xorg_list_del(&vblank->event_queue);
- if (present_execute_wait(vblank, crtc_msc))
+ if (!notify_only && !event->copy_executed &&
+ xwl_present_window->blocking_event &&
+ xwl_present_window->blocking_event != event->vblank.event_id) {
+ /* an earlier request is blocking execution */
+ xorg_list_append(&event->blocked, &xwl_present_window->blocked_queue);
+ return;
+ }
+
+retry:
+ if (present_execute_wait(vblank, crtc_msc) ||
+ xwl_present_wait_acquire_fence_avail(xwl_screen, vblank)) {
+ if (!notify_only)
+ /* block execution of subsequent requests until this request is ready */
+ xwl_present_window->blocking_event = event->vblank.event_id;
return;
+ }
- if (flip_pending && vblank->flip && vblank->pixmap && vblank->window) {
+ if (flip_pending && vblank->flip && !notify_only) {
DebugPresent(("\tr %" PRIu64 " %p (pending %p)\n",
vblank->event_id, vblank, flip_pending));
xorg_list_append(&vblank->event_queue, &xwl_present_window->flip_queue);
@@ -771,8 +1062,9 @@ xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
vblank->queued = FALSE;
- if (vblank->pixmap && vblank->window) {
+ if (!notify_only && !event->copy_executed) {
ScreenPtr screen = window->drawable.pScreen;
+ int ret;
if (vblank->flip) {
RegionPtr damage;
@@ -791,9 +1083,9 @@ xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
} else
damage = RegionDuplicate(&window->clipList);
- if (xwl_present_flip(vblank->window, vblank->crtc, vblank->event_id,
- vblank->pixmap, vblank->sync_flip, damage)) {
+ if (xwl_present_flip(vblank, damage)) {
WindowPtr toplvl_window = xwl_present_toplvl_pixmap_window(vblank->window);
+ struct xwl_window *xwl_window = xwl_window_from_window(window);
PixmapPtr old_pixmap = screen->GetWindowPixmap(window);
/* Replace window pixmap with flip pixmap */
@@ -802,23 +1094,40 @@ xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
vblank->pixmap->screen_y = old_pixmap->screen_y;
#endif
present_set_tree_pixmap(toplvl_window, old_pixmap, vblank->pixmap);
+
+ if (toplvl_window == screen->root &&
+ screen->GetScreenPixmap(screen) == old_pixmap)
+ screen->SetScreenPixmap(vblank->pixmap);
+
vblank->pixmap->refcnt++;
dixDestroyPixmap(old_pixmap, old_pixmap->drawable.id);
- /* Report damage */
+ /* Report damage, let damage_report ignore it though */
+ xwl_screen->ignore_damage = TRUE;
DamageDamageRegion(&vblank->window->drawable, damage);
+ xwl_screen->ignore_damage = FALSE;
RegionDestroy(damage);
+ /* Clear damage region, to ensure damage_report is called before
+ * any drawing to the window
+ */
+ xwl_window_buffer_add_damage_region(xwl_window);
+ RegionEmpty(xwl_window_get_damage_region(xwl_window));
+ xorg_list_del(&xwl_window->link_damage);
+
/* Put pending flip at the flip queue head */
xorg_list_add(&vblank->event_queue, &xwl_present_window->flip_queue);
/* Realign timer */
xwl_present_reset_timer(xwl_present_window);
+ xwl_present_flush_blocked(xwl_present_window, crtc_msc);
return;
}
vblank->flip = FALSE;
+ /* re-execute, falling through to copy */
+ goto retry;
}
DebugPresent(("\tc %p %" PRIu64 ": %08" PRIx32 " -> %08" PRIx32 "\n",
vblank, crtc_msc, vblank->pixmap->drawable.id, vblank->window->drawable.id));
@@ -831,13 +1140,15 @@ xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
present_execute_copy(vblank, crtc_msc);
assert(!vblank->queued);
- /* Clear the pixmap field, so this will fall through to present_execute_post next time */
- dixDestroyPixmap(vblank->pixmap, vblank->pixmap->drawable.id);
- vblank->pixmap = NULL;
+ /* Set the copy_executed field, so this will fall through to present_execute_post next time */
+ event->copy_executed = TRUE;
+
+ ret = xwl_present_queue_vblank(screen, window, vblank->crtc,
+ vblank->event_id, crtc_msc + 1);
+
+ xwl_present_flush_blocked(xwl_present_window, crtc_msc);
- if (xwl_present_queue_vblank(screen, window, vblank->crtc,
- vblank->event_id, crtc_msc + 1)
- == Success)
+ if (ret == Success)
return;
}
@@ -855,6 +1166,12 @@ xwl_present_pixmap(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
uint64_t target_window_msc,
uint64_t divisor,
@@ -862,19 +1179,28 @@ xwl_present_pixmap(WindowPtr window,
present_notify_ptr notifies,
int num_notifies)
{
+ static uint64_t xwl_present_event_id;
uint64_t ust = 0;
uint64_t target_msc;
uint64_t crtc_msc = 0;
int ret;
- present_vblank_ptr vblank, tmp;
+ present_vblank_ptr vblank;
ScreenPtr screen = window->drawable.pScreen;
present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE);
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen_priv->pScreen);
+ uint32_t caps = xwl_screen->present_capabilities;
struct xwl_present_event *event;
if (!window_priv)
return BadAlloc;
+#ifdef DRI3
+ if (!(caps & PresentCapabilitySyncobj) &&
+ (acquire_syncobj || release_syncobj))
+ return BadValue;
+#endif /* DRI3 */
+
target_crtc = xwl_present_get_crtc(screen_priv, window);
ret = xwl_present_get_ust_msc(screen, window, &ust, &crtc_msc);
@@ -893,46 +1219,26 @@ xwl_present_pixmap(WindowPtr window,
remainder,
options);
- /*
- * Look for a matching presentation already on the list...
- */
-
- if (!update && pixmap) {
- xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->vblank, window_list) {
-
- if (!vblank->pixmap)
- continue;
-
- if (!vblank->queued)
- continue;
-
- if (vblank->target_msc != target_msc)
- continue;
-
- present_vblank_scrap(vblank);
- if (vblank->flip_ready)
- xwl_present_re_execute(vblank);
- }
- }
-
event = calloc(1, sizeof(*event));
if (!event)
return BadAlloc;
vblank = &event->vblank;
if (!present_vblank_init(vblank, window, pixmap, serial, valid, update, x_off, y_off,
- target_crtc, wait_fence, idle_fence, options, XWL_PRESENT_CAPS,
- notifies, num_notifies, target_msc, crtc_msc)) {
+ target_crtc, wait_fence, idle_fence,
+#ifdef DRI3
+ acquire_syncobj, release_syncobj, acquire_point, release_point,
+#endif /* DRI3 */
+ options, caps, notifies, num_notifies, target_msc, crtc_msc)) {
present_vblank_destroy(vblank);
return BadAlloc;
}
- vblank->event_id = (uintptr_t)event;
-
- /* Xwayland presentations always complete (at least) one frame after they
- * are executed
- */
- vblank->exec_msc = vblank->target_msc - 1;
+ vblank->event_id = ++xwl_present_event_id;
+ event->options = options;
+ event->divisor = divisor;
+ event->remainder = remainder;
+ vblank->exec_msc = xwl_present_get_exec_msc(options, vblank->target_msc);
vblank->queued = TRUE;
if (crtc_msc < vblank->exec_msc) {
@@ -960,14 +1266,72 @@ xwl_present_unrealize_window(struct xwl_present_window *xwl_present_window)
}
Bool
+xwl_present_maybe_redirect_window(WindowPtr window, PixmapPtr pixmap)
+{
+ struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(window);
+ struct xwl_window *xwl_window = xwl_window_from_window(window);
+
+ if (xwl_present_window->redirect_failed)
+ return FALSE;
+
+ if (compRedirectWindow(serverClient, window, CompositeRedirectManual) != Success) {
+ xwl_present_window->redirect_failed = TRUE;
+ return FALSE;
+ }
+
+ xwl_window_update_surface_window(xwl_window);
+ if (xwl_window->surface_window != window) {
+ compUnredirectWindow(serverClient, window, CompositeRedirectManual);
+ xwl_present_window->redirect_failed = TRUE;
+ return FALSE;
+ }
+
+ if (!xwl_window->surface_window_damage)
+ xwl_window->surface_window_damage = RegionCreate(NullBox, 1);
+
+ xwl_present_window->redirected = TRUE;
+ return TRUE;
+}
+
+static CARD32
+unredirect_window(OsTimerPtr timer, CARD32 time, void *arg)
+{
+ WindowPtr window = arg;
+ struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(window);
+
+ compUnredirectWindow(serverClient, window, CompositeRedirectManual);
+ xwl_present_window->redirected = FALSE;
+
+ xwl_present_window->unredirect_timer = NULL;
+ return 0;
+}
+
+Bool
+xwl_present_maybe_unredirect_window(WindowPtr window)
+{
+ struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(window);
+
+ if (!xwl_present_window || !xwl_present_window->redirected)
+ return FALSE;
+
+ /* This function may get called from composite layer code, in which case
+ * calling compUnredirectWindow would blow up. To avoid this, set up a timer
+ * which will call it "as soon as possible".
+ */
+ if (!xwl_present_window->unredirect_timer) {
+ xwl_present_window->unredirect_timer =
+ TimerSet(NULL, 0, 1, unredirect_window, window);
+ }
+
+ return TRUE;
+}
+
+Bool
xwl_present_init(ScreenPtr screen)
{
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
present_screen_priv_ptr screen_priv;
- if (!xwl_screen->glamor || !xwl_screen->egl_backend)
- return FALSE;
-
if (!present_screen_register_priv_keys())
return FALSE;
@@ -981,6 +1345,13 @@ xwl_present_init(ScreenPtr screen)
if (!dixRegisterPrivateKey(&xwl_present_window_private_key, PRIVATE_WINDOW, 0))
return FALSE;
+ xwl_screen->present_capabilities = XWL_PRESENT_CAPS;
+#ifdef XWL_HAS_GLAMOR
+ if (xwl_glamor_supports_syncobjs(xwl_screen))
+ xwl_screen->present_capabilities |=
+ PresentCapabilitySyncobj;
+#endif /* XWL_HAS_GLAMOR */
+
screen_priv->query_capabilities = xwl_present_query_capabilities;
screen_priv->get_crtc = xwl_present_get_crtc;
@@ -991,6 +1362,7 @@ xwl_present_init(ScreenPtr screen)
screen_priv->present_pixmap = xwl_present_pixmap;
screen_priv->queue_vblank = xwl_present_queue_vblank;
screen_priv->flush = xwl_present_flush;
+ screen_priv->flush_fenced = xwl_present_flush_fenced;
screen_priv->re_execute = xwl_present_re_execute;
screen_priv->abort_vblank = xwl_present_abort_vblank;
diff --git a/hw/xwayland/xwayland-present.h b/hw/xwayland/xwayland-present.h
index ab7f04a3b..808e54182 100644
--- a/hw/xwayland/xwayland-present.h
+++ b/hw/xwayland/xwayland-present.h
@@ -33,7 +33,6 @@
#include "xwayland-types.h"
-#ifdef GLAMOR_HAS_GBM
struct xwl_present_window {
WindowPtr window;
@@ -51,22 +50,38 @@ struct xwl_present_window {
struct xorg_list wait_list;
struct xorg_list flip_queue;
struct xorg_list idle_queue;
+ struct xorg_list blocked_queue;
present_vblank_ptr flip_active;
+ uint64_t blocking_event;
+
+ OsTimerPtr unredirect_timer;
+ Bool redirected;
+ Bool redirect_failed;
};
struct xwl_present_event {
present_vblank_rec vblank;
PixmapPtr pixmap;
+ Bool copy_executed;
+
+ uint32_t options;
+ uint64_t divisor;
+ uint64_t remainder;
+
+ struct xorg_list blocked;
};
+Bool xwl_present_entered_for_each_frame_callback(void);
+void xwl_present_for_each_frame_callback(struct xwl_window *xwl_window,
+ void iter_func(struct xwl_present_window *));
void xwl_present_reset_timer(struct xwl_present_window *xwl_present_window);
void xwl_present_frame_callback(struct xwl_present_window *xwl_present_window);
Bool xwl_present_init(ScreenPtr screen);
void xwl_present_cleanup(WindowPtr window);
void xwl_present_unrealize_window(struct xwl_present_window *xwl_present_window);
-
-#endif /* GLAMOR_HAS_GBM */
+Bool xwl_present_maybe_redirect_window(WindowPtr window, PixmapPtr pixmap);
+Bool xwl_present_maybe_unredirect_window(WindowPtr window);
#endif /* XWAYLAND_PRESENT_H */
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index d6e19282c..a8db081eb 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -25,6 +25,7 @@
#include <xwayland-config.h>
+#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
@@ -34,6 +35,9 @@
#endif
#include <X11/Xatom.h>
+
+#include "os/osdep.h"
+
#include <micmap.h>
#include <misyncshm.h>
#include <os.h>
@@ -41,6 +45,7 @@
#include <dixstruct.h>
#include <propertyst.h>
#include <inputstr.h>
+#include <xacestr.h>
#include <xserver_poll.h>
#include "xwayland-cursor.h"
@@ -51,6 +56,12 @@
#include "xwayland-pixmap.h"
#include "xwayland-present.h"
#include "xwayland-shm.h"
+#ifdef XWL_HAS_EI
+#include "xwayland-xtest.h"
+#endif
+#ifdef XWL_HAS_GLAMOR
+#include "xwayland-glamor.h"
+#endif
#ifdef MITSHM
#include "shmint.h"
@@ -59,6 +70,9 @@
#include "xdg-output-unstable-v1-client-protocol.h"
#include "viewporter-client-protocol.h"
#include "xdg-shell-client-protocol.h"
+#include "xwayland-shell-v1-client-protocol.h"
+#include "tearing-control-v1-client-protocol.h"
+#include "fractional-scale-v1-client-protocol.h"
static DevPrivateKeyRec xwl_screen_private_key;
static DevPrivateKeyRec xwl_client_private_key;
@@ -127,6 +141,27 @@ xwl_screen_get_first_output(struct xwl_screen *xwl_screen)
return xorg_list_first_entry(&xwl_screen->output_list, struct xwl_output, link);
}
+struct xwl_output *
+xwl_screen_get_fixed_or_first_output(struct xwl_screen *xwl_screen)
+{
+ if (xwl_screen->fixed_output)
+ return xwl_screen->fixed_output;
+
+ return xwl_screen_get_first_output(xwl_screen);
+}
+
+int
+xwl_screen_get_width(struct xwl_screen *xwl_screen)
+{
+ return round(xwl_screen->width);
+}
+
+int
+xwl_screen_get_height(struct xwl_screen *xwl_screen)
+{
+ return round(xwl_screen->height);
+}
+
static void
xwl_property_callback(CallbackListPtr *pcbl, void *closure,
void *calldata)
@@ -149,6 +184,33 @@ xwl_property_callback(CallbackListPtr *pcbl, void *closure,
xwl_window_update_property(xwl_window, rec);
}
+#define readOnlyPropertyAccessMask (DixReadAccess |\
+ DixGetAttrAccess |\
+ DixListPropAccess |\
+ DixGetPropAccess)
+
+static void
+xwl_access_property_callback(CallbackListPtr *pcbl, void *closure,
+ void *calldata)
+{
+ XacePropertyAccessRec *rec = calldata;
+ PropertyPtr prop = *rec->ppProp;
+ ClientPtr client = rec->client;
+ Mask access_mode = rec->access_mode;
+ ScreenPtr pScreen = closure;
+ struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
+
+ if (prop->propertyName == xwl_screen->allow_commits_prop) {
+ /* Only the WM and the Xserver itself */
+ if (client != serverClient &&
+ client->index != xwl_screen->wm_client_id &&
+ (access_mode & ~readOnlyPropertyAccessMask) != 0)
+ rec->status = BadAccess;
+ }
+}
+
+#undef readOnlyPropertyAccessMask
+
static void
xwl_root_window_finalized_callback(CallbackListPtr *pcbl,
void *closure,
@@ -173,13 +235,20 @@ xwl_close_screen(ScreenPtr screen)
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
struct xwl_output *xwl_output, *next_xwl_output;
struct xwl_seat *xwl_seat, *next_xwl_seat;
-
+ struct xwl_wl_surface *xwl_wl_surface, *xwl_wl_surface_next;
+#ifdef XWL_HAS_GLAMOR
+ xwl_dmabuf_feedback_destroy(&xwl_screen->default_feedback);
+#endif
DeleteCallback(&PropertyStateCallback, xwl_property_callback, screen);
+ XaceDeleteCallback(XACE_PROPERTY_ACCESS, xwl_access_property_callback, screen);
xorg_list_for_each_entry_safe(xwl_output, next_xwl_output,
&xwl_screen->output_list, link)
xwl_output_destroy(xwl_output);
+ if (xwl_screen->fixed_output)
+ xwl_output_destroy(xwl_screen->fixed_output);
+
xorg_list_for_each_entry_safe(xwl_seat, next_xwl_seat,
&xwl_screen->seat_list, link)
xwl_seat_destroy(xwl_seat);
@@ -192,11 +261,16 @@ xwl_close_screen(ScreenPtr screen)
xwl_screen_destroy_drm_lease_device(xwl_screen,
device_data->drm_lease_device);
+ xorg_list_for_each_entry_safe(xwl_wl_surface, xwl_wl_surface_next,
+ &xwl_screen->pending_wl_surface_destroy, link)
+ xwl_window_surface_do_destroy(xwl_wl_surface);
+
RemoveNotifyFd(xwl_screen->wayland_fd);
wl_display_disconnect(xwl_screen->display);
screen->CloseScreen = xwl_screen->CloseScreen;
+
free(xwl_screen);
return screen->CloseScreen(screen);
@@ -234,7 +308,7 @@ xwl_cursor_warped_to(DeviceIntPtr device,
xwl_window = xwl_window_from_window(window);
if (!xwl_window && xwl_seat->focus_window) {
- focus = xwl_seat->focus_window->window;
+ focus = xwl_seat->focus_window->toplevel;
/* Warps on non wl_surface backed Windows are only allowed
* as long as the pointer stays within the focus window.
@@ -268,15 +342,15 @@ find_matching_input_output_window(struct xwl_screen *xwl_screen,
/* When confining happens on InputOnly windows, work out the InputOutput
* window that would be covered by its geometry.
*/
- if (window->drawable.x < xwl_window->window->drawable.x ||
+ if (window->drawable.x < xwl_window->toplevel->drawable.x ||
window->drawable.x + window->drawable.width >
- xwl_window->window->drawable.x + xwl_window->window->drawable.width ||
- window->drawable.y < xwl_window->window->drawable.y ||
+ xwl_window->toplevel->drawable.x + xwl_window->toplevel->drawable.width ||
+ window->drawable.y < xwl_window->toplevel->drawable.y ||
window->drawable.y + window->drawable.height >
- xwl_window->window->drawable.y + xwl_window->window->drawable.height)
+ xwl_window->toplevel->drawable.y + xwl_window->toplevel->drawable.height)
continue;
- if (xwl_window->window->drawable.class == InputOnly)
+ if (xwl_window->toplevel->drawable.class == InputOnly)
continue;
return xwl_window;
@@ -294,6 +368,12 @@ xwl_cursor_confined_to(DeviceIntPtr device,
struct xwl_seat *xwl_seat = device->public.devicePrivate;
struct xwl_window *xwl_window;
+ /* If running rootful with host grab requested, do not tamper with
+ * pointer confinement.
+ */
+ if (!xwl_screen->rootless && xwl_screen->host_grab && xwl_screen->has_grab)
+ return;
+
if (!xwl_seat)
xwl_seat = xwl_screen_get_default_seat(xwl_screen);
@@ -344,11 +424,6 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
if (!xwl_window->allow_commits)
continue;
-#ifdef XWL_HAS_GLAMOR
- if (xwl_screen->glamor && !xwl_glamor_allow_commits(xwl_window))
- continue;
-#endif
-
xwl_window_post_damage(xwl_window);
xorg_list_del(&xwl_window->link_damage);
xorg_list_append(&xwl_window->link_damage, &commit_window_list);
@@ -358,7 +433,7 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
return;
#ifdef XWL_HAS_GLAMOR
- if (xwl_glamor_needs_buffer_flush(xwl_screen))
+ if (xwl_screen->glamor)
glamor_block_handler(xwl_screen->screen);
#endif
@@ -386,7 +461,7 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
{
struct xwl_screen *xwl_screen = data;
- if (strcmp(interface, "wl_compositor") == 0) {
+ if (strcmp(interface, wl_compositor_interface.name) == 0) {
uint32_t request_version = 1;
if (version >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
@@ -395,28 +470,28 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
xwl_screen->compositor =
wl_registry_bind(registry, id, &wl_compositor_interface, request_version);
}
- else if (strcmp(interface, "wl_shm") == 0) {
+ else if (strcmp(interface, wl_shm_interface.name) == 0) {
xwl_screen->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
}
- else if (strcmp(interface, "xdg_wm_base") == 0) {
+ else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
xwl_screen->xdg_wm_base =
wl_registry_bind(registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(xwl_screen->xdg_wm_base,
&xdg_wm_base_listener,
NULL);
}
- else if (strcmp(interface, "wl_output") == 0 && version >= 2) {
- if (xwl_output_create(xwl_screen, id))
+ else if (strcmp(interface, wl_output_interface.name) == 0 && version >= 2) {
+ if (xwl_output_create(xwl_screen, id, (xwl_screen->fixed_output == NULL), version))
xwl_screen->expecting_event++;
}
- else if (strcmp(interface, "zxdg_output_manager_v1") == 0) {
+ else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
/* We support xdg-output from version 1 to version 3 */
version = min(version, 3);
xwl_screen->xdg_output_manager =
wl_registry_bind(registry, id, &zxdg_output_manager_v1_interface, version);
xwl_screen_init_xdg_output(xwl_screen);
}
- else if (strcmp(interface, "wp_drm_lease_device_v1") == 0) {
+ else if (strcmp(interface, wp_drm_lease_device_v1_interface.name) == 0) {
if (xwl_screen->screen->root == NULL) {
struct xwl_queued_drm_lease_device *queued = malloc(sizeof(struct xwl_queued_drm_lease_device));
queued->id = id;
@@ -425,9 +500,21 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
xwl_screen_add_drm_lease_device(xwl_screen, id);
}
}
- else if (strcmp(interface, "wp_viewporter") == 0) {
+ else if (strcmp(interface, wp_viewporter_interface.name) == 0) {
xwl_screen->viewporter = wl_registry_bind(registry, id, &wp_viewporter_interface, 1);
}
+ else if (strcmp(interface, xwayland_shell_v1_interface.name) == 0 && xwl_screen->rootless) {
+ xwl_screen->xwayland_shell =
+ wl_registry_bind(registry, id, &xwayland_shell_v1_interface, 1);
+ }
+ else if (strcmp(interface, wp_tearing_control_manager_v1_interface.name) == 0) {
+ xwl_screen->tearing_control_manager =
+ wl_registry_bind(registry, id, &wp_tearing_control_manager_v1_interface, 1);
+ }
+ else if (strcmp(interface, wp_fractional_scale_manager_v1_interface.name) == 0) {
+ xwl_screen->fractional_scale_manager =
+ wl_registry_bind(registry, id, &wp_fractional_scale_manager_v1_interface, 1);
+ }
#ifdef XWL_HAS_GLAMOR
else if (xwl_screen->glamor) {
xwl_glamor_init_wl_registry(xwl_screen, registry, id, interface,
@@ -495,6 +582,33 @@ xwl_display_pollout (struct xwl_screen *xwl_screen, int timeout)
return xserver_poll(&poll_fd, 1, timeout);
}
+#ifdef XWL_HAS_LIBDECOR
+static void
+xwl_dispatch_events_with_libdecor(struct xwl_screen *xwl_screen)
+{
+ int ret = 0;
+
+ assert(!xwl_screen->rootless);
+
+ ret = libdecor_dispatch(xwl_screen->libdecor_context, 0);
+ if (ret == -1)
+ xwl_give_up("failed to dispatch Wayland events with libdecor: %s\n",
+ strerror(errno));
+}
+
+static void
+handle_libdecor_error(struct libdecor *context,
+ enum libdecor_error error,
+ const char *message)
+{
+ xwl_give_up("libdecor error (%d): %s\n", error, message);
+}
+
+static struct libdecor_interface libdecor_iface = {
+ .error = handle_libdecor_error,
+};
+#endif
+
static void
xwl_dispatch_events (struct xwl_screen *xwl_screen)
{
@@ -533,6 +647,12 @@ socket_handler(int fd, int ready, void *data)
{
struct xwl_screen *xwl_screen = data;
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_screen->libdecor_context) {
+ xwl_dispatch_events_with_libdecor(xwl_screen);
+ return;
+ }
+#endif
xwl_read_events (xwl_screen);
}
@@ -547,12 +667,24 @@ block_handler(void *data, void *timeout)
struct xwl_screen *xwl_screen = data;
xwl_screen_post_damage(xwl_screen);
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_screen->libdecor_context) {
+ xwl_dispatch_events_with_libdecor(xwl_screen);
+ return;
+ }
+#endif
xwl_dispatch_events (xwl_screen);
}
void
xwl_sync_events (struct xwl_screen *xwl_screen)
{
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_screen->libdecor_context) {
+ xwl_dispatch_events_with_libdecor(xwl_screen);
+ return;
+ }
+#endif
xwl_dispatch_events (xwl_screen);
xwl_read_events (xwl_screen);
}
@@ -572,14 +704,130 @@ xwl_screen_roundtrip(struct xwl_screen *xwl_screen)
{
int ret;
- ret = wl_display_roundtrip(xwl_screen->display);
- while (ret >= 0 && xwl_screen->expecting_event)
+ do {
ret = wl_display_roundtrip(xwl_screen->display);
+ } while (ret >= 0 && xwl_screen->expecting_event);
if (ret < 0)
xwl_give_up("could not connect to wayland server\n");
}
+static int
+xwl_server_grab(ClientPtr client)
+{
+ struct xwl_screen *xwl_screen;
+
+ /* Allow GrabServer for the X11 window manager.
+ * Xwayland only has 1 screen (no Zaphod for Xwayland) so we check
+ * for the first and only screen here.
+ */
+ xwl_screen = xwl_screen_get(screenInfo.screens[0]);
+ if (xwl_screen->wm_client_id == client->index)
+ return xwl_screen->GrabServer(client);
+
+ /* For all other clients, just pretend it works for compatibility,
+ but do nothing */
+ return Success;
+}
+
+static int
+xwl_server_ungrab(ClientPtr client)
+{
+ struct xwl_screen *xwl_screen;
+
+ /* Same as above, allow UngrabServer for the X11 window manager only */
+ xwl_screen = xwl_screen_get(screenInfo.screens[0]);
+ if (xwl_screen->wm_client_id == client->index)
+ return xwl_screen->UngrabServer(client);
+
+ /* For all other clients, just pretend it works for compatibility,
+ but do nothing */
+ return Success;
+}
+
+static void
+xwl_screen_setup_custom_vector(struct xwl_screen *xwl_screen)
+{
+ /* Rootfull Xwayland does not need a custom ProcVector (yet?) */
+ if (!xwl_screen->rootless)
+ return;
+
+ xwl_screen->GrabServer = ProcVector[X_GrabServer];
+ xwl_screen->UngrabServer = ProcVector[X_UngrabServer];
+
+ ProcVector[X_GrabServer] = xwl_server_grab;
+ ProcVector[X_UngrabServer] = xwl_server_ungrab;
+}
+
+int
+xwl_screen_get_next_output_serial(struct xwl_screen *xwl_screen)
+{
+ return xwl_screen->output_name_serial++;
+}
+
+void
+xwl_screen_lost_focus(struct xwl_screen *xwl_screen)
+{
+ struct xwl_seat *xwl_seat;
+
+ xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
+ xwl_seat_leave_ptr(xwl_seat, TRUE);
+ xwl_seat_leave_kbd(xwl_seat);
+ }
+}
+
+Bool
+xwl_screen_should_use_fractional_scale(struct xwl_screen *xwl_screen)
+{
+ /* Fullscreen uses a viewport already */
+ if (xwl_screen->fullscreen)
+ return FALSE;
+
+ if (xwl_screen->rootless)
+ return FALSE;
+
+ /* We need both fractional scale and viewporter protocols */
+ if (!xwl_screen->fractional_scale_manager)
+ return FALSE;
+
+ if (!xwl_screen->viewporter)
+ return FALSE;
+
+ return xwl_screen->hidpi;
+}
+
+Bool
+xwl_screen_update_global_surface_scale(struct xwl_screen *xwl_screen)
+{
+ ScreenPtr screen = xwl_screen->screen;
+ struct xwl_window *xwl_window;
+ int32_t old_scale;
+
+ if (xwl_screen_should_use_fractional_scale(xwl_screen))
+ return FALSE;
+
+ if (xwl_screen->rootless)
+ return FALSE;
+
+ if (xwl_screen->fullscreen)
+ return FALSE;
+
+ if (!xwl_screen->hidpi)
+ return FALSE;
+
+ if (screen->root == NullWindow)
+ return FALSE;
+
+ xwl_window = xwl_window_get(screen->root);
+ if (!xwl_window)
+ return FALSE;
+
+ old_scale = xwl_screen->global_surface_scale;
+ xwl_screen->global_surface_scale = xwl_window_get_max_output_scale(xwl_window);
+
+ return (xwl_screen->global_surface_scale != old_scale);
+}
+
Bool
xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
{
@@ -587,9 +835,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
struct xwl_screen *xwl_screen;
Pixel red_mask, blue_mask, green_mask;
int ret, bpc, green_bpc, i;
-#ifdef XWL_HAS_GLAMOR
- Bool use_eglstreams = FALSE;
-#endif
+ unsigned int xwl_width = 640;
+ unsigned int xwl_height = 480;
+ Bool use_fixed_size = FALSE;
if (!dixRegisterPrivateKey(&xwl_screen_private_key, PRIVATE_SCREEN, 0))
return FALSE;
@@ -612,8 +860,13 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen);
xwl_screen->screen = pScreen;
+#ifdef XWL_HAS_EI
+ if (!xwayland_ei_init())
+ return FALSE;
+#endif
+
#ifdef XWL_HAS_GLAMOR
- xwl_screen->glamor = 1;
+ xwl_screen->glamor = XWL_GLAMOR_DEFAULT;
#endif
for (i = 1; i < argc; i++) {
@@ -634,23 +887,79 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
defaultScreenSaverInterval = 0;
}
else if (strcmp(argv[i], "-shm") == 0) {
- xwl_screen->glamor = 0;
+ xwl_screen->glamor = XWL_GLAMOR_NONE;
}
- else if (strcmp(argv[i], "-eglstream") == 0) {
-#ifdef XWL_HAS_EGLSTREAM
- use_eglstreams = TRUE;
-#else
- ErrorF("xwayland glamor: this build does not have EGLStream support\n");
-#endif
+#ifdef XWL_HAS_GLAMOR
+ else if (strcmp(argv[i], "-glamor") == 0) {
+ if (strncmp(argv[i + 1], "es", 2) == 0)
+ xwl_screen->glamor = XWL_GLAMOR_GLES;
+ else if (strncmp(argv[i + 1], "gl", 2) == 0)
+ xwl_screen->glamor = XWL_GLAMOR_GL;
+ else if (strncmp(argv[i + 1], "off", 3) == 0)
+ xwl_screen->glamor = XWL_GLAMOR_NONE;
+ else
+ ErrorF("Xwayland glamor: unknown rendering API selected\n");
}
+#endif
else if (strcmp(argv[i], "-force-xrandr-emulation") == 0) {
xwl_screen->force_xrandr_emulation = 1;
}
+ else if (strcmp(argv[i], "-geometry") == 0) {
+ sscanf(argv[i + 1], "%ix%i", &xwl_width, &xwl_height);
+ if (xwl_width == 0 || xwl_height == 0) {
+ ErrorF("invalid argument for -geometry %s\n", argv[i + 1]);
+ return FALSE;
+ }
+ use_fixed_size = 1;
+ }
+ else if (strcmp(argv[i], "-fullscreen") == 0) {
+ use_fixed_size = 1;
+ xwl_screen->fullscreen = 1;
+ }
+ else if (strcmp(argv[i], "-output") == 0) {
+ xwl_screen->output_name = argv[i + 1];
+ }
+ else if (strcmp(argv[i], "-host-grab") == 0) {
+ xwl_screen->host_grab = 1;
+ xwl_screen->has_grab = 1;
+ }
+ else if (strcmp(argv[i], "-decorate") == 0) {
+#ifdef XWL_HAS_LIBDECOR
+ xwl_screen->decorate = 1;
+ use_fixed_size = 1;
+#else
+ ErrorF("This build does not have libdecor support\n");
+#endif
+ }
+ else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
+#ifdef XWL_HAS_EI_PORTAL
+ xwl_screen->enable_ei_portal = 1;
+#else
+ ErrorF("This build does not have XDG portal support\n");
+#endif
+ }
+ else if (strcmp(argv[i], "-nokeymap") == 0) {
+ xwl_screen->nokeymap = 1;
+ }
+ else if (strcmp(argv[i], "-hidpi") == 0) {
+ xwl_screen->hidpi = 1;
+ }
+ }
+
+ if (!xwl_screen->rootless) {
+ use_fixed_size = 1;
+ xwl_screen->width = xwl_width;
+ xwl_screen->height = xwl_height;
+ } else if (use_fixed_size) {
+ ErrorF("error, cannot set a geometry when running rootless\n");
+ return FALSE;
}
#ifdef XWL_HAS_GLAMOR
- if (xwl_screen->glamor)
- xwl_glamor_init_backends(xwl_screen, use_eglstreams);
+ if (xwl_screen->glamor && !xwl_glamor_init_gbm(xwl_screen)) {
+ ErrorF("xwayland glamor: failed to setup GBM backend, falling back to sw accel\n");
+ xwl_screen->glamor = 0;
+ }
#endif
/* In rootless mode, we don't have any screen storage, and the only
@@ -667,7 +976,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
xorg_list_init(&xwl_screen->drm_lease_devices);
xorg_list_init(&xwl_screen->queued_drm_lease_devices);
xorg_list_init(&xwl_screen->drm_leases);
+ xorg_list_init(&xwl_screen->pending_wl_surface_destroy);
xwl_screen->depth = 24;
+ xwl_screen->global_surface_scale = 1;
if (!monitorResolution)
monitorResolution = DEFAULT_DPI;
@@ -678,8 +989,13 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
- if (!xwl_screen_init_output(xwl_screen))
- return FALSE;
+ if (use_fixed_size) {
+ if (!xwl_screen_init_randr_fixed(xwl_screen))
+ return FALSE;
+ } else {
+ if (!xwl_screen_init_output(xwl_screen))
+ return FALSE;
+ }
xwl_screen->expecting_event = 0;
xwl_screen->registry = wl_display_get_registry(xwl_screen->display);
@@ -687,6 +1003,27 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
&registry_listener, xwl_screen);
xwl_screen_roundtrip(xwl_screen);
+
+ if (xwl_screen->fullscreen && xwl_screen->rootless) {
+ ErrorF("error, cannot set fullscreen when running rootless\n");
+ return FALSE;
+ }
+
+ if (xwl_screen->fullscreen && xwl_screen->decorate) {
+ ErrorF("error, cannot use the decorate option when running fullscreen\n");
+ return FALSE;
+ }
+
+ if (xwl_screen->fullscreen && !xwl_screen_has_viewport_support(xwl_screen)) {
+ ErrorF("missing viewport support in the compositor, ignoring fullscreen\n");
+ xwl_screen->fullscreen = FALSE;
+ }
+
+ if (xwl_screen->host_grab && xwl_screen->rootless) {
+ ErrorF("error, cannot use host grab when running rootless\n");
+ return FALSE;
+ }
+
if (!xwl_screen->rootless && !xwl_screen->xdg_wm_base) {
ErrorF("missing XDG-WM-Base protocol\n");
return FALSE;
@@ -706,7 +1043,8 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
miSetPixmapDepths();
ret = fbScreenInit(pScreen, NULL,
- xwl_screen->width, xwl_screen->height,
+ xwl_screen_get_width(xwl_screen),
+ xwl_screen_get_height(xwl_screen),
monitorResolution, monitorResolution, 0,
BitsPerPixel(xwl_screen->depth));
if (!ret)
@@ -723,7 +1061,16 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
return FALSE;
#endif
- xwl_screen->wayland_fd = wl_display_get_fd(xwl_screen->display);
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_screen->decorate && !xwl_screen->rootless) {
+ xwl_screen->libdecor_context = libdecor_new(xwl_screen->display, &libdecor_iface);
+ xwl_screen->wayland_fd = libdecor_get_fd(xwl_screen->libdecor_context);
+ }
+ else
+#endif
+ {
+ xwl_screen->wayland_fd = wl_display_get_fd(xwl_screen->display);
+ }
SetNotifyFd(xwl_screen->wayland_fd, socket_handler, X_NOTIFY_READ, xwl_screen);
RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, xwl_screen);
@@ -736,19 +1083,14 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
return FALSE;
#ifdef XWL_HAS_GLAMOR
- if (xwl_screen->glamor) {
- xwl_glamor_select_backend(xwl_screen, use_eglstreams);
-
- if (xwl_screen->egl_backend == NULL || !xwl_glamor_init(xwl_screen)) {
- ErrorF("Failed to initialize glamor, falling back to sw\n");
- xwl_screen->glamor = 0;
- }
+ if (xwl_screen->glamor && !xwl_glamor_init(xwl_screen)) {
+ ErrorF("Failed to initialize glamor, falling back to sw\n");
+ xwl_screen->glamor = XWL_GLAMOR_NONE;
}
-
- if (xwl_screen->glamor && xwl_screen->rootless)
- xwl_screen->present = xwl_present_init(pScreen);
#endif
+ xwl_screen->present = xwl_present_init(pScreen);
+
if (!xwl_screen->glamor) {
xwl_screen->CreateScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = xwl_shm_create_screen_resources;
@@ -771,16 +1113,17 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
xwl_screen->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
pScreen->ChangeWindowAttributes = xwl_change_window_attributes;
- xwl_screen->ResizeWindow = pScreen->ResizeWindow;
- pScreen->ResizeWindow = xwl_resize_window;
+ xwl_screen->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = xwl_clip_notify;
+
+ xwl_screen->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = xwl_config_notify;
xwl_screen->MoveWindow = pScreen->MoveWindow;
pScreen->MoveWindow = xwl_move_window;
- if (xwl_screen->rootless) {
- xwl_screen->SetWindowPixmap = pScreen->SetWindowPixmap;
- pScreen->SetWindowPixmap = xwl_window_set_window_pixmap;
- }
+ xwl_screen->SetWindowPixmap = pScreen->SetWindowPixmap;
+ pScreen->SetWindowPixmap = xwl_window_set_window_pixmap;
pScreen->CursorWarpedTo = xwl_cursor_warped_to;
pScreen->CursorConfinedTo = xwl_cursor_confined_to;
@@ -793,6 +1136,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
AddCallback(&PropertyStateCallback, xwl_property_callback, pScreen);
AddCallback(&RootWindowFinalizeCallback, xwl_root_window_finalized_callback, pScreen);
+ XaceRegisterCallback(XACE_PROPERTY_ACCESS, xwl_access_property_callback, pScreen);
+
+ xwl_screen_setup_custom_vector(xwl_screen);
xwl_screen_roundtrip(xwl_screen);
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index f8aee2bdc..f3949af0a 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -34,45 +34,63 @@
#include <dix.h>
#include "xwayland-types.h"
+#include "xwayland-window.h"
#include "xwayland-output.h"
#include "xwayland-glamor.h"
#include "xwayland-drm-lease.h"
+#include "xwayland-dmabuf.h"
-struct xwl_format {
- uint32_t format;
- int num_modifiers;
- uint64_t *modifiers;
-};
+#ifdef XWL_HAS_LIBDECOR
+#include <libdecor.h>
+#endif
struct xwl_screen {
- int width;
- int height;
+ double width;
+ double height;
int depth;
+ int global_surface_scale;
+ int output_name_serial;
ScreenPtr screen;
int wm_client_id;
int expecting_event;
enum RootClipMode root_clip_mode;
+ Bool active;
int rootless;
- int glamor;
+ xwl_glamor_mode_flags glamor;
int present;
int force_xrandr_emulation;
-
+ int fullscreen;
+ int host_grab;
+ int has_grab;
+ int decorate;
+ int enable_ei_portal;
+ int nokeymap;
+ int hidpi;
+
+ ClipNotifyProcPtr ClipNotify;
CreateScreenResourcesProcPtr CreateScreenResources;
CloseScreenProcPtr CloseScreen;
+ ConfigNotifyProcPtr ConfigNotify;
RealizeWindowProcPtr RealizeWindow;
UnrealizeWindowProcPtr UnrealizeWindow;
DestroyWindowProcPtr DestroyWindow;
XYToWindowProcPtr XYToWindow;
SetWindowPixmapProcPtr SetWindowPixmap;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
- ResizeWindowProcPtr ResizeWindow;
MoveWindowProcPtr MoveWindow;
+ SourceValidateProcPtr SourceValidate;
+
+ int (*GrabServer) (ClientPtr client);
+ int (*UngrabServer) (ClientPtr client);
struct xorg_list output_list;
struct xorg_list seat_list;
struct xorg_list damage_window_list;
struct xorg_list window_list;
+ Bool ignore_damage;
+
+ int need_source_validate;
int wayland_fd;
struct wl_display *display;
@@ -86,12 +104,23 @@ struct xwl_screen {
struct zwp_pointer_constraints_v1 *pointer_constraints;
struct zwp_pointer_gestures_v1 *pointer_gestures;
struct zwp_xwayland_keyboard_grab_manager_v1 *wp_grab;
+ struct zwp_keyboard_shortcuts_inhibit_manager_v1 *shortcuts_inhibit_manager;
+ struct zwp_keyboard_shortcuts_inhibitor_v1 *shortcuts_inhibit;
struct zwp_linux_dmabuf_v1 *dmabuf;
+ int dmabuf_protocol_version;
+ struct xwl_dmabuf_feedback default_feedback;
struct zxdg_output_manager_v1 *xdg_output_manager;
struct wp_viewporter *viewporter;
+ struct xwayland_shell_v1 *xwayland_shell;
+ struct wp_tearing_control_manager_v1 *tearing_control_manager;
+ struct wp_fractional_scale_manager_v1 *fractional_scale_manager;
+ struct wp_linux_drm_syncobj_manager_v1 *explicit_sync;
struct xorg_list drm_lease_devices;
struct xorg_list queued_drm_lease_devices;
struct xorg_list drm_leases;
+ struct xwl_output *fixed_output;
+ struct xorg_list pending_wl_surface_destroy;
+ uint64_t surface_association_serial;
uint32_t serial;
#define XWL_FORMAT_ARGB8888 (1 << 0)
@@ -105,17 +134,19 @@ struct xwl_screen {
struct xwl_format *formats;
void *egl_display, *egl_context;
- struct xwl_egl_backend gbm_backend;
- struct xwl_egl_backend eglstream_backend;
- /* pointer to the current backend for creating pixmaps on wayland */
- struct xwl_egl_backend *egl_backend;
-
struct glamor_context *glamor_ctx;
Atom allow_commits_prop;
/* The preferred GLVND vendor. If NULL, "mesa" is assumed. */
const char *glvnd_vendor;
+#ifdef XWL_HAS_LIBDECOR
+ int libdecor_fd;
+ struct libdecor *libdecor_context;
+#endif
+ const char *output_name;
+
+ uint32_t present_capabilities;
};
/* Apps which use randr/vidmode to change the mode when going fullscreen,
@@ -133,6 +164,10 @@ Bool xwl_screen_has_viewport_support(struct xwl_screen *xwl_screen);
Bool xwl_screen_has_resolution_change_emulation(struct xwl_screen *xwl_screen);
void xwl_screen_check_resolution_change_emulation(struct xwl_screen *xwl_screen);
struct xwl_output *xwl_screen_get_first_output(struct xwl_screen *xwl_screen);
+struct xwl_output *xwl_screen_get_fixed_or_first_output(struct xwl_screen *xwl_screen);
+int xwl_screen_get_width(struct xwl_screen *xwl_screen);
+int xwl_screen_get_height(struct xwl_screen *xwl_screen);
+
Bool xwl_close_screen(ScreenPtr screen);
Bool xwl_screen_init(ScreenPtr pScreen, int argc, char **argv);
void xwl_sync_events (struct xwl_screen *xwl_screen);
@@ -140,5 +175,9 @@ void xwl_screen_roundtrip (struct xwl_screen *xwl_screen);
void xwl_surface_damage(struct xwl_screen *xwl_screen,
struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
+int xwl_screen_get_next_output_serial(struct xwl_screen * xwl_screen);
+void xwl_screen_lost_focus(struct xwl_screen *xwl_screen);
+Bool xwl_screen_update_global_surface_scale(struct xwl_screen *xwl_screen);
+Bool xwl_screen_should_use_fractional_scale(struct xwl_screen *xwl_screen);
#endif /* XWAYLAND_SCREEN_H */
diff --git a/hw/xwayland/xwayland-shm.c b/hw/xwayland/xwayland-shm.c
index ff128316d..faca5224e 100644
--- a/hw/xwayland/xwayland-shm.c
+++ b/hw/xwayland/xwayland-shm.c
@@ -36,6 +36,8 @@
#include <string.h>
#include <stdlib.h>
+#include "os/osdep.h"
+
#include "fb.h"
#include "pixmapstr.h"
@@ -213,6 +215,28 @@ shm_format_for_depth(int depth)
}
}
+static Bool
+dimensions_match_toplevel_window(ScreenPtr screen, int width, int height)
+{
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+ WindowPtr toplevel;
+
+ if (xwl_screen->rootless)
+ toplevel = screen->root->firstChild;
+ else
+ toplevel = screen->root;
+
+ while (toplevel) {
+ if (width == toplevel->drawable.width &&
+ height == toplevel->drawable.height)
+ return TRUE;
+
+ toplevel = toplevel->nextSib;
+ }
+
+ return FALSE;
+}
+
static const struct wl_buffer_listener xwl_shm_buffer_listener = {
xwl_pixmap_buffer_release_cb,
};
@@ -230,8 +254,9 @@ xwl_shm_create_pixmap(ScreenPtr screen,
int fd;
if (hint == CREATE_PIXMAP_USAGE_GLYPH_PICTURE ||
- (!xwl_screen->rootless && hint != CREATE_PIXMAP_USAGE_BACKING_PIXMAP) ||
- (width == 0 && height == 0) || depth < 15)
+ (width == 0 && height == 0) || depth < 15 ||
+ (hint != CREATE_PIXMAP_USAGE_BACKING_PIXMAP &&
+ !dimensions_match_toplevel_window(screen, width, height)))
return fbCreatePixmap(screen, width, height, depth, hint);
stride = PixmapBytePad(width, depth);
@@ -314,7 +339,12 @@ xwl_shm_destroy_pixmap(PixmapPtr pixmap)
struct wl_buffer *
xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap)
{
- return xwl_pixmap_get(pixmap)->buffer;
+ struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
+
+ if (!xwl_pixmap)
+ return NULL;
+
+ return xwl_pixmap->buffer;
}
Bool
diff --git a/hw/xwayland/xwayland-types.h b/hw/xwayland/xwayland-types.h
index e70e56320..73a674633 100644
--- a/hw/xwayland/xwayland-types.h
+++ b/hw/xwayland/xwayland-types.h
@@ -29,7 +29,7 @@
struct xwl_pixmap;
struct xwl_window;
struct xwl_screen;
-struct xwl_egl_backend;
struct xwl_drm_lease;
+struct xwl_output;
#endif /* XWAYLAND_TYPES_H */
diff --git a/hw/xwayland/xwayland-vidmode.c b/hw/xwayland/xwayland-vidmode.c
index 87e9c3d73..77e57b1e4 100644
--- a/hw/xwayland/xwayland-vidmode.c
+++ b/hw/xwayland/xwayland-vidmode.c
@@ -30,6 +30,9 @@
#endif
#include <X11/X.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "os.h"
#include "extinit.h"
@@ -110,8 +113,9 @@ static RRModePtr
xwlVidModeGetRRMode(ScreenPtr pScreen, int32_t width, int32_t height)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
+ struct xwl_output *xwl_output;
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
if (!xwl_output)
return NULL;
@@ -122,9 +126,10 @@ static RRModePtr
xwlVidModeGetCurrentRRMode(ScreenPtr pScreen)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
struct xwl_emulated_mode *emulated_mode;
+ struct xwl_output *xwl_output;
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
if (!xwl_output)
return NULL;
@@ -238,14 +243,18 @@ static Bool
xwlVidModeGetNextModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
+ struct xwl_output *xwl_output;
VidModePtr pVidMode;
DisplayModePtr pMod;
intptr_t index;
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
+ if (xwl_output == NULL)
+ return FALSE;
+
pMod = dixLookupPrivate(&pScreen->devPrivates, xwlVidModePrivateKey);
pVidMode = VidModeGetPtr(pScreen);
- if (xwl_output == NULL || pMod == NULL || pVidMode == NULL)
+ if (pMod == NULL || pVidMode == NULL)
return FALSE;
index = (intptr_t)pVidMode->Next;
@@ -294,9 +303,10 @@ static Bool
xwlVidModeSetViewPort(ScreenPtr pScreen, int x, int y)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
+ struct xwl_output *xwl_output;
- if (!xwl_output)
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
+ if (xwl_output == NULL)
return FALSE;
/* Support only default viewport */
@@ -307,9 +317,10 @@ static Bool
xwlVidModeGetViewPort(ScreenPtr pScreen, int *x, int *y)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
+ struct xwl_output *xwl_output;
- if (!xwl_output)
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
+ if (xwl_output == NULL)
return FALSE;
*x = xwl_output->x;
@@ -322,17 +333,22 @@ static Bool
xwlVidModeSwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
+ struct xwl_output *xwl_output;
RRModePtr rrmode;
- if (!xwl_output)
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
+ if (xwl_output == NULL)
return FALSE;
rrmode = xwl_output_find_mode(xwl_output, mode->HDisplay, mode->VDisplay);
if (rrmode == NULL)
return FALSE;
- xwl_output_set_emulated_mode(xwl_output, GetCurrentClient(), rrmode, TRUE);
+ if (xwl_screen->rootless)
+ xwl_output_set_emulated_mode(xwl_output, GetCurrentClient(), rrmode, TRUE);
+ else if (xwl_screen->fixed_output)
+ xwl_output_set_mode_fixed(xwl_screen->fixed_output, rrmode);
+
return TRUE;
}
@@ -388,7 +404,9 @@ static int
xwlVidModeGetNumOfModes(ScreenPtr pScreen)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
- struct xwl_output *xwl_output = xwl_screen_get_first_output(xwl_screen);
+ struct xwl_output *xwl_output;
+
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
return xwl_output ? xwl_output->randr_output->numModes : 0;
}
diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c
index f04c79a8a..2e8b0859c 100644
--- a/hw/xwayland/xwayland-window-buffers.c
+++ b/hw/xwayland/xwayland-window-buffers.c
@@ -32,6 +32,14 @@
#include "xwayland-pixmap.h"
#include "xwayland-screen.h"
#include "xwayland-window-buffers.h"
+#ifdef XWL_HAS_GLAMOR
+#include "glamor.h"
+#endif
+#include "dri3.h"
+
+#include <poll.h>
+#include <sys/eventfd.h>
+#include "linux-drm-syncobj-v1-client-protocol.h"
#define BUFFER_TIMEOUT 1 * 1000 /* ms */
@@ -39,33 +47,34 @@ struct xwl_window_buffer {
struct xwl_window *xwl_window;
PixmapPtr pixmap;
RegionPtr damage_region;
- Bool recycle_on_release;
+#ifdef XWL_HAS_GLAMOR
+ struct dri3_syncobj *syncobj;
+ uint64_t timeline_point;
+ int efd;
+#endif /* XWL_HAS_GLAMOR */
int refcnt;
uint32_t time;
struct xorg_list link_buffer;
};
-static Bool
+static void
copy_pixmap_area(PixmapPtr src_pixmap, PixmapPtr dst_pixmap,
int x, int y, int width, int height)
{
GCPtr pGC;
pGC = GetScratchGC(dst_pixmap->drawable.depth,
dst_pixmap->drawable.pScreen);
- if (pGC) {
- ValidateGC(&dst_pixmap->drawable, pGC);
- (void) (*pGC->ops->CopyArea) (&src_pixmap->drawable,
- &dst_pixmap->drawable,
- pGC,
- x, y,
- width, height,
- x, y);
- FreeScratchGC(pGC);
-
- return TRUE;
- }
-
- return FALSE;
+ if (!pGC)
+ FatalError("GetScratchGC failed for depth %d", dst_pixmap->drawable.depth);
+
+ ValidateGC(&dst_pixmap->drawable, pGC);
+ (void) (*pGC->ops->CopyArea) (&src_pixmap->drawable,
+ &dst_pixmap->drawable,
+ pGC,
+ x, y,
+ width, height,
+ x, y);
+ FreeScratchGC(pGC);
}
static struct xwl_window_buffer *
@@ -81,9 +90,11 @@ xwl_window_buffer_new(struct xwl_window *xwl_window)
xwl_window_buffer->damage_region = RegionCreate(NullBox, 1);
xwl_window_buffer->pixmap = NullPixmap;
xwl_window_buffer->refcnt = 1;
+#ifdef XWL_HAS_GLAMOR
+ xwl_window_buffer->efd = -1;
+#endif /* XWL_HAS_GLAMOR */
- xorg_list_append(&xwl_window_buffer->link_buffer,
- &xwl_window->window_buffers_available);
+ xorg_list_init(&xwl_window_buffer->link_buffer);
return xwl_window_buffer;
}
@@ -99,7 +110,7 @@ xwl_window_buffer_destroy_pixmap(struct xwl_window_buffer *xwl_window_buffer)
}
static Bool
-xwl_window_buffer_dispose(struct xwl_window_buffer *xwl_window_buffer)
+xwl_window_buffer_maybe_dispose(struct xwl_window_buffer *xwl_window_buffer)
{
assert(xwl_window_buffer->refcnt > 0);
@@ -111,26 +122,26 @@ xwl_window_buffer_dispose(struct xwl_window_buffer *xwl_window_buffer)
if (xwl_window_buffer->pixmap)
xwl_window_buffer_destroy_pixmap (xwl_window_buffer);
+#ifdef XWL_HAS_GLAMOR
+ if (xwl_window_buffer->syncobj)
+ xwl_window_buffer->syncobj->free(xwl_window_buffer->syncobj);
+
+ if (xwl_window_buffer->efd >= 0) {
+ SetNotifyFd(xwl_window_buffer->efd, NULL, 0, NULL);
+ close(xwl_window_buffer->efd);
+ }
+#endif /* XWL_HAS_GLAMOR */
+
xorg_list_del(&xwl_window_buffer->link_buffer);
free(xwl_window_buffer);
return TRUE;
}
-static void
-xwl_window_buffer_recycle(struct xwl_window_buffer *xwl_window_buffer)
-{
- RegionEmpty(xwl_window_buffer->damage_region);
- xwl_window_buffer->recycle_on_release = FALSE;
-
- if (xwl_window_buffer->pixmap)
- xwl_window_buffer_destroy_pixmap (xwl_window_buffer);
-}
-
-static void
-xwl_window_buffer_add_damage_region(struct xwl_window *xwl_window,
- RegionPtr damage_region)
+void
+xwl_window_buffer_add_damage_region(struct xwl_window *xwl_window)
{
+ RegionPtr region = xwl_window_get_damage_region(xwl_window);
struct xwl_window_buffer *xwl_window_buffer;
/* Add damage region to all buffers */
@@ -139,14 +150,14 @@ xwl_window_buffer_add_damage_region(struct xwl_window *xwl_window,
link_buffer) {
RegionUnion(xwl_window_buffer->damage_region,
xwl_window_buffer->damage_region,
- damage_region);
+ region);
}
xorg_list_for_each_entry(xwl_window_buffer,
&xwl_window->window_buffers_unavailable,
link_buffer) {
RegionUnion(xwl_window_buffer->damage_region,
xwl_window_buffer->damage_region,
- damage_region);
+ region);
}
}
@@ -154,7 +165,7 @@ static struct xwl_window_buffer *
xwl_window_buffer_get_available(struct xwl_window *xwl_window)
{
if (xorg_list_is_empty(&xwl_window->window_buffers_available))
- return xwl_window_buffer_new(xwl_window);
+ return NULL;
return xorg_list_last_entry(&xwl_window->window_buffers_available,
struct xwl_window_buffer,
@@ -172,7 +183,7 @@ xwl_window_buffer_timer_callback(OsTimerPtr timer, CARD32 time, void *arg)
&xwl_window->window_buffers_available,
link_buffer) {
if ((int64_t)(time - xwl_window_buffer->time) >= BUFFER_TIMEOUT)
- xwl_window_buffer_dispose(xwl_window_buffer);
+ xwl_window_buffer_maybe_dispose(xwl_window_buffer);
}
/* If there are still available buffers, re-arm the timer */
@@ -199,12 +210,9 @@ xwl_window_buffer_release_callback(void *data)
/* Drop the reference on the buffer we took in get_pixmap. If that
* frees the window buffer, we're done.
*/
- if (xwl_window_buffer_dispose(xwl_window_buffer))
+ if (xwl_window_buffer_maybe_dispose(xwl_window_buffer))
return;
- if (xwl_window_buffer->recycle_on_release)
- xwl_window_buffer_recycle(xwl_window_buffer);
-
/* We append the buffers to the end of the list, as we pick the last
* entry again when looking for new available buffers, that means the
* least used buffers will remain at the beginning of the list so that
@@ -230,34 +238,25 @@ xwl_window_buffer_release_callback(void *data)
xwl_window);
}
-void
-xwl_window_buffers_init(struct xwl_window *xwl_window)
+#ifdef XWL_HAS_GLAMOR
+static void
+xwl_window_buffers_release_fence_avail(int fd, int xevents, void *data)
{
- xorg_list_init(&xwl_window->window_buffers_available);
- xorg_list_init(&xwl_window->window_buffers_unavailable);
+ struct xwl_window_buffer *xwl_window_buffer = data;
+
+ SetNotifyFd(fd, NULL, 0, NULL);
+ close(fd);
+ xwl_window_buffer->efd = -1;
+
+ xwl_window_buffer_release_callback(data);
}
+#endif /* XWL_HAS_GLAMOR */
void
-xwl_window_buffers_recycle(struct xwl_window *xwl_window)
+xwl_window_buffers_init(struct xwl_window *xwl_window)
{
- struct xwl_window_buffer *xwl_window_buffer, *tmp;
-
- /* Dispose available buffers */
- xorg_list_for_each_entry_safe(xwl_window_buffer, tmp,
- &xwl_window->window_buffers_available,
- link_buffer) {
- xwl_window_buffer_dispose(xwl_window_buffer);
- }
-
- if (xwl_window->window_buffers_timer)
- TimerCancel(xwl_window->window_buffers_timer);
-
- /* Mark the others for recycle on release */
- xorg_list_for_each_entry(xwl_window_buffer,
- &xwl_window->window_buffers_unavailable,
- link_buffer) {
- xwl_window_buffer->recycle_on_release = TRUE;
- }
+ xorg_list_init(&xwl_window->window_buffers_available);
+ xorg_list_init(&xwl_window->window_buffers_unavailable);
}
void
@@ -273,90 +272,242 @@ xwl_window_buffers_dispose(struct xwl_window *xwl_window)
&xwl_window->window_buffers_available,
link_buffer) {
xorg_list_del(&xwl_window_buffer->link_buffer);
- xwl_window_buffer_dispose(xwl_window_buffer);
+ xwl_window_buffer_maybe_dispose(xwl_window_buffer);
}
xorg_list_for_each_entry_safe(xwl_window_buffer, tmp,
&xwl_window->window_buffers_unavailable,
link_buffer) {
xorg_list_del(&xwl_window_buffer->link_buffer);
- xwl_window_buffer_dispose(xwl_window_buffer);
+ xwl_window_buffer_maybe_dispose(xwl_window_buffer);
}
- if (xwl_window->window_buffers_timer) {
- TimerFree(xwl_window->window_buffers_timer);
- xwl_window->window_buffers_timer = 0;
+ if (xwl_window->window_buffers_timer)
+ TimerCancel(xwl_window->window_buffers_timer);
+}
+
+struct pixmap_visit {
+ PixmapPtr old;
+ PixmapPtr new;
+};
+
+static int
+xwl_set_pixmap_visit_window(WindowPtr window, void *data)
+{
+ ScreenPtr screen = window->drawable.pScreen;
+ struct pixmap_visit *visit = data;
+
+ if (screen->GetWindowPixmap(window) == visit->old) {
+ screen->SetWindowPixmap(window, visit->new);
+ return WT_WALKCHILDREN;
}
+
+ return WT_DONTWALKCHILDREN;
}
-PixmapPtr
-xwl_window_buffers_get_pixmap(struct xwl_window *xwl_window,
- RegionPtr damage_region)
+static void
+xwl_window_set_pixmap(WindowPtr window, PixmapPtr pixmap)
{
- struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
- struct xwl_window_buffer *xwl_window_buffer;
- PixmapPtr window_pixmap;
- RegionPtr full_damage;
+ ScreenPtr screen = window->drawable.pScreen;
+ struct pixmap_visit visit;
+
+ visit.old = screen->GetWindowPixmap(window);
+ visit.new = pixmap;
- window_pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
+#ifdef COMPOSITE
+ pixmap->screen_x = visit.old->screen_x;
+ pixmap->screen_y = visit.old->screen_y;
+#endif
+
+ TraverseTree(window, xwl_set_pixmap_visit_window, &visit);
+
+ if (window == screen->root &&
+ screen->GetScreenPixmap(screen) == visit.old)
+ screen->SetScreenPixmap(pixmap);
+}
+
+static PixmapPtr
+xwl_window_allocate_pixmap(struct xwl_window *xwl_window)
+{
+ ScreenPtr screen = xwl_window->xwl_screen->screen;
+ PixmapPtr window_pixmap;
#ifdef XWL_HAS_GLAMOR
- if (!xwl_glamor_needs_n_buffering(xwl_screen))
+ /* Try the xwayland/glamor direct hook first */
+ window_pixmap = xwl_glamor_create_pixmap_for_window(xwl_window);
+ if (window_pixmap)
return window_pixmap;
#endif /* XWL_HAS_GLAMOR */
- xwl_window_buffer = xwl_window_buffer_get_available(xwl_window);
- if (!xwl_window_buffer)
- return window_pixmap;
+ window_pixmap = screen->GetWindowPixmap(xwl_window->surface_window);
+ return screen->CreatePixmap(screen,
+ window_pixmap->drawable.width,
+ window_pixmap->drawable.height,
+ window_pixmap->drawable.depth,
+ CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+}
- xwl_window_buffer_add_damage_region(xwl_window, damage_region);
+void
+xwl_window_realloc_pixmap(struct xwl_window *xwl_window)
+{
+ PixmapPtr window_pixmap, new_window_pixmap;
+ WindowPtr window;
+ ScreenPtr screen;
- full_damage = xwl_window_buffer->damage_region;
+ new_window_pixmap = xwl_window_allocate_pixmap(xwl_window);
+ if (!new_window_pixmap)
+ return;
+
+ window = xwl_window->surface_window;
+ screen = window->drawable.pScreen;
+ window_pixmap = screen->GetWindowPixmap(window);
+ copy_pixmap_area(window_pixmap,
+ new_window_pixmap,
+ 0, 0,
+ window_pixmap->drawable.width,
+ window_pixmap->drawable.height);
+ xwl_window_set_pixmap(xwl_window->surface_window, new_window_pixmap);
+ screen->DestroyPixmap(window_pixmap);
+}
+
+#ifdef XWL_HAS_GLAMOR
+static Bool
+xwl_window_buffers_set_syncpts(struct xwl_window_buffer *xwl_window_buffer)
+{
+ struct xwl_window *xwl_window = xwl_window_buffer->xwl_window;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ uint64_t acquire_point = ++xwl_window_buffer->timeline_point;
+ uint64_t release_point = ++xwl_window_buffer->timeline_point;
+
+ if (!xwl_window_buffer->syncobj) {
+ struct dri3_syncobj *syncobj = xwl_glamor_dri3_syncobj_create(xwl_screen);
+ if (!syncobj)
+ goto fail;
+ xwl_window_buffer->syncobj = syncobj;
+ }
+
+ int fence_fd = xwl_glamor_get_fence(xwl_screen);
+ if (fence_fd >= 0)
+ xwl_window_buffer->syncobj->import_fence(xwl_window_buffer->syncobj,
+ acquire_point, fence_fd);
+ else
+ goto fail;
+
+ xwl_glamor_dri3_syncobj_passthrough(xwl_window,
+ xwl_window_buffer->syncobj,
+ xwl_window_buffer->syncobj,
+ acquire_point,
+ release_point);
+ return TRUE;
- if (xwl_window_buffer->pixmap) {
+fail:
+ /* can't use explicit sync, we will do a glFinish() before presenting */
+ if (xwl_window_buffer->syncobj) {
+ xwl_window_buffer->syncobj->free(xwl_window_buffer->syncobj);
+ xwl_window_buffer->syncobj = NULL;
+ }
+ return FALSE;
+}
+#endif /* XWL_HAS_GLAMOR */
+
+PixmapPtr
+xwl_window_swap_pixmap(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ WindowPtr surface_window = xwl_window->surface_window;
+ struct xwl_window_buffer *xwl_window_buffer;
+ PixmapPtr window_pixmap;
+ Bool implicit_sync = TRUE;
+
+ window_pixmap = (*xwl_screen->screen->GetWindowPixmap) (surface_window);
+
+ xwl_window_buffer_add_damage_region(xwl_window);
+
+ xwl_window_buffer = xwl_window_buffer_get_available(xwl_window);
+ if (xwl_window_buffer) {
+ RegionPtr full_damage = xwl_window_buffer->damage_region;
BoxPtr pBox = RegionRects(full_damage);
int nBox = RegionNumRects(full_damage);
+
+#ifdef XWL_HAS_GLAMOR
+ if (xwl_window_buffer->syncobj) {
+ int fence_fd =
+ xwl_window_buffer->syncobj->export_fence(xwl_window_buffer->syncobj,
+ xwl_window_buffer->timeline_point);
+ xwl_glamor_wait_fence(xwl_screen, fence_fd);
+ close(fence_fd);
+ }
+#endif /* XWL_HAS_GLAMOR */
+
while (nBox--) {
- if (!copy_pixmap_area(window_pixmap,
- xwl_window_buffer->pixmap,
- pBox->x1 + xwl_window->window->borderWidth,
- pBox->y1 + xwl_window->window->borderWidth,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1))
- return window_pixmap;
+ copy_pixmap_area(window_pixmap,
+ xwl_window_buffer->pixmap,
+ pBox->x1 + surface_window->borderWidth,
+ pBox->y1 + surface_window->borderWidth,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
pBox++;
}
- } else {
- xwl_window_buffer->pixmap =
- (*xwl_screen->screen->CreatePixmap) (window_pixmap->drawable.pScreen,
- window_pixmap->drawable.width,
- window_pixmap->drawable.height,
- window_pixmap->drawable.depth,
- CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
-
- if (!xwl_window_buffer->pixmap)
- return window_pixmap;
- if (!copy_pixmap_area(window_pixmap,
- xwl_window_buffer->pixmap,
- 0, 0,
- window_pixmap->drawable.width,
- window_pixmap->drawable.height)) {
- xwl_window_buffer_recycle(xwl_window_buffer);
+ RegionEmpty(xwl_window_buffer->damage_region);
+ xorg_list_del(&xwl_window_buffer->link_buffer);
+ xwl_window_set_pixmap(surface_window, xwl_window_buffer->pixmap);
+
+ /* Can't re-use client pixmap as a window buffer */
+ if (xwl_is_client_pixmap(window_pixmap)) {
+ xwl_window_buffer->pixmap = NULL;
+ xwl_window_buffer_maybe_dispose(xwl_window_buffer);
return window_pixmap;
}
+ } else {
+ /* Can't re-use client pixmap as a window buffer */
+ if (!xwl_is_client_pixmap(window_pixmap))
+ xwl_window_buffer = xwl_window_buffer_new(xwl_window);
+
+ window_pixmap->refcnt++;
+ xwl_window_realloc_pixmap(xwl_window);
+
+ if (!xwl_window_buffer)
+ return window_pixmap;
}
- RegionEmpty(xwl_window_buffer->damage_region);
+ xwl_window_buffer->pixmap = window_pixmap;
/* Hold a reference on the buffer until it's released by the compositor */
xwl_window_buffer->refcnt++;
- xwl_pixmap_set_buffer_release_cb(xwl_window_buffer->pixmap,
- xwl_window_buffer_release_callback,
- xwl_window_buffer);
- xorg_list_del(&xwl_window_buffer->link_buffer);
+#ifdef XWL_HAS_GLAMOR
+ if (!xwl_glamor_supports_implicit_sync(xwl_screen)) {
+ if (xwl_screen->explicit_sync && xwl_window_buffers_set_syncpts(xwl_window_buffer)) {
+ implicit_sync = FALSE;
+ /* wait until the release fence is available before re-using this buffer */
+ xwl_window_buffer->efd = eventfd(0, EFD_CLOEXEC);
+ SetNotifyFd(xwl_window_buffer->efd, xwl_window_buffers_release_fence_avail,
+ X_NOTIFY_READ, xwl_window_buffer);
+ xwl_window_buffer->syncobj->submitted_eventfd(xwl_window_buffer->syncobj,
+ xwl_window_buffer->timeline_point,
+ xwl_window_buffer->efd);
+ } else
+ /* If glamor does not support implicit sync and we can't use
+ * explicit sync, wait for the GPU to be idle before presenting.
+ * Note that buffer re-use will still be unsynchronized :(
+ */
+ glamor_finish(xwl_screen->screen);
+ }
+#endif /* XWL_HAS_GLAMOR */
+
+ if (implicit_sync) {
+ xwl_pixmap_set_buffer_release_cb(xwl_window_buffer->pixmap,
+ xwl_window_buffer_release_callback,
+ xwl_window_buffer);
+
+ if (xwl_window->surface_sync) {
+ wp_linux_drm_syncobj_surface_v1_destroy(xwl_window->surface_sync);
+ xwl_window->surface_sync = NULL;
+ }
+ }
+
xorg_list_append(&xwl_window_buffer->link_buffer,
&xwl_window->window_buffers_unavailable);
diff --git a/hw/xwayland/xwayland-window-buffers.h b/hw/xwayland/xwayland-window-buffers.h
index 8031f24d5..8b463e671 100644
--- a/hw/xwayland/xwayland-window-buffers.h
+++ b/hw/xwayland/xwayland-window-buffers.h
@@ -30,12 +30,13 @@
#include <xwayland-config.h>
#include "xwayland-types.h"
-#include "regionstr.h"
+struct xwl_window_buffer;
+
+void xwl_window_buffer_add_damage_region(struct xwl_window *xwl_window);
void xwl_window_buffers_init(struct xwl_window *xwl_window);
-void xwl_window_buffers_recycle(struct xwl_window *xwl_window);
void xwl_window_buffers_dispose(struct xwl_window *xwl_window);
-PixmapPtr xwl_window_buffers_get_pixmap(struct xwl_window *xwl_window,
- RegionPtr damage_region);
+void xwl_window_realloc_pixmap(struct xwl_window *xwl_window);
+PixmapPtr xwl_window_swap_pixmap(struct xwl_window *xwl_window);
#endif /* XWAYLAND_WINDOW_BUFFERS_H */
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 41061e344..b111a1e4a 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -27,6 +27,10 @@
#include <dix-config.h>
#endif
+#include <float.h>
+#include <math.h>
+#include <sys/mman.h>
+
#include <X11/X.h>
#include <X11/Xatom.h>
@@ -37,25 +41,108 @@
#include "xwayland-types.h"
#include "xwayland-input.h"
+#include "xwayland-pixmap.h"
#include "xwayland-present.h"
#include "xwayland-screen.h"
#include "xwayland-window.h"
#include "xwayland-window-buffers.h"
#include "xwayland-shm.h"
+#include "xwayland-dmabuf.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+#include "tearing-control-v1-client-protocol.h"
#include "viewporter-client-protocol.h"
#include "xdg-shell-client-protocol.h"
+#include "xwayland-shell-v1-client-protocol.h"
+#include "fractional-scale-v1-client-protocol.h"
+#include "linux-drm-syncobj-v1-client-protocol.h"
+
+#define DELAYED_WL_SURFACE_DESTROY 1000 /* ms */
+
+#define MAX_ROOTFUL_WIDTH 32767
+#define MAX_ROOTFUL_HEIGHT 32767
+#define MIN_ROOTFUL_WIDTH 320
+#define MIN_ROOTFUL_HEIGHT 200
+
+#define FRACTIONAL_SCALE_DENOMINATOR 120
static DevPrivateKeyRec xwl_window_private_key;
static DevPrivateKeyRec xwl_damage_private_key;
+static const char *xwl_surface_tag = "xwl-surface";
+
+static Bool xwl_window_attach_buffer(struct xwl_window *);
+
+struct xwl_window *
+xwl_window_get(WindowPtr window)
+{
+ return dixLookupPrivate(&window->devPrivates, &xwl_window_private_key);
+}
+
+static DamagePtr
+window_get_damage(WindowPtr window)
+{
+ return dixLookupPrivate(&window->devPrivates, &xwl_damage_private_key);
+}
+
+RegionPtr
+xwl_window_get_damage_region(struct xwl_window *xwl_window)
+{
+ return DamageRegion(window_get_damage(xwl_window->surface_window));
+}
+
+struct xwl_window *
+xwl_window_from_window(WindowPtr window)
+{
+ struct xwl_window *xwl_window;
+
+ while (window) {
+ xwl_window = xwl_window_get(window);
+ if (xwl_window)
+ return xwl_window;
+
+ window = window->parent;
+ }
+
+ return NULL;
+}
+
+static void
+xwl_window_set_xwayland_tag(struct xwl_window *xwl_window)
+{
+ wl_proxy_set_tag((struct wl_proxy *)xwl_window->surface, &xwl_surface_tag);
+}
+
+static void
+xwl_window_clear_xwayland_tag(struct xwl_window *xwl_window)
+{
+ wl_proxy_set_tag((struct wl_proxy *)xwl_window->surface, NULL);
+}
+
+Bool
+is_surface_from_xwl_window(struct wl_surface *surface)
+{
+ return wl_proxy_get_tag((struct wl_proxy *) surface) == &xwl_surface_tag;
+}
static void
xwl_window_set_allow_commits(struct xwl_window *xwl_window, Bool allow,
const char *debug_msg)
{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ DamagePtr damage;
+
xwl_window->allow_commits = allow;
- DebugF("xwayland: win %d allow_commits = %d (%s)\n",
- xwl_window->window->drawable.id, allow, debug_msg);
+ DebugF("XWAYLAND: win %d allow_commits = %d (%s)\n",
+ xwl_window->toplevel->drawable.id, allow, debug_msg);
+
+ damage = window_get_damage(xwl_window->surface_window);
+ if (allow &&
+ xorg_list_is_empty(&xwl_window->link_damage) &&
+ damage &&
+ RegionNotEmpty(DamageRegion(damage))) {
+ xorg_list_add(&xwl_window->link_damage,
+ &xwl_screen->damage_window_list);
+ }
}
static void
@@ -84,34 +171,6 @@ xwl_window_set_allow_commits_from_property(struct xwl_window *xwl_window,
xwl_window_set_allow_commits(xwl_window, !!propdata[0], "from property");
}
-struct xwl_window *
-xwl_window_get(WindowPtr window)
-{
- return dixLookupPrivate(&window->devPrivates, &xwl_window_private_key);
-}
-
-static DamagePtr
-window_get_damage(WindowPtr window)
-{
- return dixLookupPrivate(&window->devPrivates, &xwl_damage_private_key);
-}
-
-struct xwl_window *
-xwl_window_from_window(WindowPtr window)
-{
- struct xwl_window *xwl_window;
-
- while (window) {
- xwl_window = xwl_window_get(window);
- if (xwl_window)
- return xwl_window;
-
- window = window->parent;
- }
-
- return NULL;
-}
-
void
xwl_window_update_property(struct xwl_window *xwl_window,
PropertyStateRec *propstate)
@@ -131,30 +190,133 @@ xwl_window_update_property(struct xwl_window *xwl_window,
}
static void
-damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data)
+need_source_validate_dec(struct xwl_screen *xwl_screen)
{
- WindowPtr window = data;
- struct xwl_window *xwl_window = xwl_window_get(window);
- struct xwl_screen *xwl_screen;
+ xwl_screen->need_source_validate--;
- if (!xwl_window)
- return;
+ if (!xwl_screen->need_source_validate)
+ xwl_screen->screen->SourceValidate = xwl_screen->SourceValidate;
+}
- xwl_screen = xwl_window->xwl_screen;
+static void
+xwl_source_validate(DrawablePtr drawable, int x, int y, int width, int height,
+ unsigned int sub_window_mode)
+{
+ struct xwl_window *xwl_window;
+ WindowPtr window, iterator;
+ RegionRec region;
+ BoxRec box;
-#ifdef GLAMOR_HAS_GBM
- if (xwl_window->present_flipped) {
- /* This damage is from a Present flip, which already committed a new
- * buffer for the surface, so we don't need to do anything in response
- */
- RegionEmpty(DamageRegion(pDamage));
- xorg_list_del(&xwl_window->link_damage);
- xwl_window->present_flipped = FALSE;
+ if (sub_window_mode != IncludeInferiors ||
+ drawable->type != DRAWABLE_WINDOW)
return;
+
+ window = (WindowPtr)drawable;
+ xwl_window = xwl_window_from_window(window);
+ if (!xwl_window || !xwl_window->surface_window_damage ||
+ !RegionNotEmpty(xwl_window->surface_window_damage))
+ return;
+
+ for (iterator = xwl_window->toplevel;
+ ;
+ iterator = iterator->firstChild) {
+ if (iterator == xwl_window->surface_window)
+ return;
+
+ if (iterator == window)
+ break;
}
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + width;
+ box.y2 = y + height;
+ RegionInit(&region, &box, 1);
+ RegionIntersect(&region, &region, xwl_window->surface_window_damage);
+
+ if (RegionNotEmpty(&region)) {
+ ScreenPtr screen = drawable->pScreen;
+ PixmapPtr dst_pix, src_pix;
+ BoxPtr pbox;
+ GCPtr pGC;
+ int nbox;
+
+ dst_pix = screen->GetWindowPixmap(window);
+ pGC = GetScratchGC(dst_pix->drawable.depth, screen);
+ if (!pGC)
+ FatalError("GetScratchGC failed for depth %d", dst_pix->drawable.depth);
+ ValidateGC(&dst_pix->drawable, pGC);
+
+ src_pix = screen->GetWindowPixmap(xwl_window->surface_window);
+
+ RegionSubtract(xwl_window->surface_window_damage,
+ xwl_window->surface_window_damage,
+ &region);
+
+ if (!RegionNotEmpty(xwl_window->surface_window_damage))
+ need_source_validate_dec(xwl_window->xwl_screen);
+
+#if defined(COMPOSITE)
+ if (dst_pix->screen_x || dst_pix->screen_y)
+ RegionTranslate(&region, -dst_pix->screen_x, -dst_pix->screen_y);
#endif
- xorg_list_add(&xwl_window->link_damage, &xwl_screen->damage_window_list);
+ pbox = RegionRects(&region);
+ nbox = RegionNumRects(&region);
+ while (nbox--) {
+ (void) (*pGC->ops->CopyArea) (&src_pix->drawable,
+ &dst_pix->drawable,
+ pGC,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ pbox->x1, pbox->y1);
+ pbox++;
+ }
+ FreeScratchGC(pGC);
+ }
+
+ RegionUninit(&region);
+}
+
+static void
+need_source_validate_inc(struct xwl_screen *xwl_screen)
+{
+ if (!xwl_screen->need_source_validate) {
+ ScreenPtr screen = xwl_screen->screen;
+
+ xwl_screen->SourceValidate = screen->SourceValidate;
+ screen->SourceValidate = xwl_source_validate;
+ }
+
+ xwl_screen->need_source_validate++;
+}
+
+static void
+damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data)
+{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ PixmapPtr window_pixmap;
+
+ if (xwl_window->surface_window_damage &&
+ RegionNotEmpty(pRegion)) {
+ if (!RegionNotEmpty(xwl_window->surface_window_damage))
+ need_source_validate_inc(xwl_screen);
+
+ RegionUnion(xwl_window->surface_window_damage,
+ xwl_window->surface_window_damage,
+ DamageRegion(pDamage));
+ }
+
+ if (xwl_screen->ignore_damage)
+ return;
+
+ if (xorg_list_is_empty(&xwl_window->link_damage))
+ xorg_list_add(&xwl_window->link_damage, &xwl_screen->damage_window_list);
+
+ window_pixmap = xwl_screen->screen->GetWindowPixmap(xwl_window->surface_window);
+ if (xwl_is_client_pixmap(window_pixmap))
+ xwl_screen->screen->DestroyPixmap(xwl_window_swap_pixmap(xwl_window));
}
static void
@@ -163,41 +325,59 @@ damage_destroy(DamagePtr pDamage, void *data)
}
static Bool
-register_damage(WindowPtr window)
+register_damage(struct xwl_window *xwl_window)
{
+ WindowPtr surface_window = xwl_window->surface_window;
DamagePtr damage;
damage = DamageCreate(damage_report, damage_destroy, DamageReportNonEmpty,
- FALSE, window->drawable.pScreen, window);
+ FALSE, surface_window->drawable.pScreen, xwl_window);
if (damage == NULL) {
ErrorF("Failed creating damage\n");
return FALSE;
}
- DamageRegister(&window->drawable, damage);
- DamageSetReportAfterOp(damage, TRUE);
-
- dixSetPrivate(&window->devPrivates, &xwl_damage_private_key, damage);
+ DamageRegister(&surface_window->drawable, damage);
+ dixSetPrivate(&surface_window->devPrivates, &xwl_damage_private_key, damage);
return TRUE;
}
static void
-unregister_damage(WindowPtr window)
+unregister_damage(struct xwl_window *xwl_window)
{
+ WindowPtr surface_window = xwl_window->surface_window;
DamagePtr damage;
- damage = dixLookupPrivate(&window->devPrivates, &xwl_damage_private_key);
+ damage = dixLookupPrivate(&surface_window->devPrivates, &xwl_damage_private_key);
if (!damage)
return;
DamageUnregister(damage);
DamageDestroy(damage);
- dixSetPrivate(&window->devPrivates, &xwl_damage_private_key, NULL);
+ dixSetPrivate(&surface_window->devPrivates, &xwl_damage_private_key, NULL);
}
-Bool
+static Bool
+xwl_window_update_fractional_scale(struct xwl_window *xwl_window,
+ int fractional_scale_numerator)
+{
+ int old_scale_numerator = xwl_window->fractional_scale_numerator;
+
+ xwl_window->fractional_scale_numerator = fractional_scale_numerator;
+
+ return (old_scale_numerator != fractional_scale_numerator);
+}
+
+static double
+xwl_window_get_fractional_scale_factor(struct xwl_window *xwl_window)
+{
+ return (double) xwl_window->fractional_scale_numerator /
+ (double) FRACTIONAL_SCALE_DENOMINATOR;
+}
+
+static Bool
xwl_window_has_viewport_enabled(struct xwl_window *xwl_window)
{
return (xwl_window->viewport != NULL);
@@ -211,13 +391,57 @@ xwl_window_disable_viewport(struct xwl_window *xwl_window)
DebugF("XWAYLAND: disabling viewport\n");
wp_viewport_destroy(xwl_window->viewport);
xwl_window->viewport = NULL;
+ xwl_window->viewport_scale_x = 1.0;
+ xwl_window->viewport_scale_y = 1.0;
}
+/* Enable the viewport for fractional scale support with Xwayland rootful.
+ * Fractional scale support is not used with Xwayland rootful fullscreen (which
+ * sets its own XRandR resolution) so we can use the viewport for either
+ * fullscreen mode or fractional scale.
+ */
+static void
+xwl_window_enable_viewport_for_fractional_scale(struct xwl_window *xwl_window,
+ int width, int height)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ int buffer_width, buffer_height;
+ double scale;
+
+ scale = xwl_window_get_fractional_scale_factor(xwl_window);
+ buffer_width = round((double) width / scale);
+ buffer_height = round((double) height / scale);
+
+ if (!xwl_window_has_viewport_enabled(xwl_window))
+ xwl_window->viewport = wp_viewporter_get_viewport(xwl_screen->viewporter,
+ xwl_window->surface);
+
+ DebugF("XWAYLAND: enabling viewport for fractional scale %dx%d -> %dx%d\n",
+ width, height, buffer_width, buffer_height);
+ wp_viewport_set_source(xwl_window->viewport,
+ wl_fixed_from_int(0),
+ wl_fixed_from_int(0),
+ wl_fixed_from_int(width),
+ wl_fixed_from_int(height));
+ wp_viewport_set_destination(xwl_window->viewport,
+ buffer_width,
+ buffer_height);
+
+ xwl_window->viewport_scale_x = scale;
+ xwl_window->viewport_scale_y = scale;
+}
+
+/* Enable the viewport for Xwayland rootful fullscreen, to match the XRandR
+ * resolution with the actual output size.
+ */
static void
-xwl_window_enable_viewport(struct xwl_window *xwl_window,
- struct xwl_output *xwl_output,
- struct xwl_emulated_mode *emulated_mode)
+xwl_window_enable_viewport_for_output(struct xwl_window *xwl_window,
+ struct xwl_output *xwl_output,
+ struct xwl_emulated_mode *emulated_mode)
{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ int width, height;
+
if (!xwl_window_has_viewport_enabled(xwl_window)) {
DebugF("XWAYLAND: enabling viewport %dx%d -> %dx%d\n",
emulated_mode->width, emulated_mode->height,
@@ -226,17 +450,20 @@ xwl_window_enable_viewport(struct xwl_window *xwl_window,
xwl_window->surface);
}
+ width = emulated_mode->width / xwl_screen->global_surface_scale;
+ height = emulated_mode->height / xwl_screen->global_surface_scale;
+
wp_viewport_set_source(xwl_window->viewport,
wl_fixed_from_int(0),
wl_fixed_from_int(0),
- wl_fixed_from_int(emulated_mode->width),
- wl_fixed_from_int(emulated_mode->height));
+ wl_fixed_from_int(width),
+ wl_fixed_from_int(height));
wp_viewport_set_destination(xwl_window->viewport,
xwl_output->width,
xwl_output->height);
- xwl_window->scale_x = (float)emulated_mode->width / xwl_output->width;
- xwl_window->scale_y = (float)emulated_mode->height / xwl_output->height;
+ xwl_window->viewport_scale_x = (float) width / xwl_output->width;
+ xwl_window->viewport_scale_y = (float) height / xwl_output->height;
}
static Bool
@@ -267,10 +494,48 @@ window_get_client_toplevel(WindowPtr window)
return window;
}
+static struct xwl_output *
+xwl_window_get_output(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ struct xwl_output *xwl_output;
+
+ xwl_output = xwl_output_get_output_from_name(xwl_screen, xwl_screen->output_name);
+ if (xwl_output)
+ return xwl_output;
+
+ xwl_output = xwl_output_from_wl_output(xwl_screen, xwl_window->wl_output);
+ if (xwl_output)
+ return xwl_output;
+
+ return xwl_screen_get_first_output(xwl_screen);
+}
+
+static Bool
+xwl_window_should_enable_viewport_fullscreen(struct xwl_window *xwl_window,
+ struct xwl_output **xwl_output_ret,
+ struct xwl_emulated_mode *emulated_mode_ret)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ struct xwl_output *xwl_output;
+
+ xwl_output = xwl_window_get_output(xwl_window);
+ if (!xwl_output)
+ return FALSE;
+
+ *xwl_output_ret = xwl_output;
+ emulated_mode_ret->server_output_id = 0;
+ emulated_mode_ret->width = xwl_screen_get_width(xwl_screen);
+ emulated_mode_ret->height = xwl_screen_get_height(xwl_screen);
+ emulated_mode_ret->from_vidmode = FALSE;
+
+ return TRUE;
+}
+
static Bool
xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
struct xwl_output **xwl_output_ret,
- struct xwl_emulated_mode **emulated_mode_ret)
+ struct xwl_emulated_mode *emulated_mode_ret)
{
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
struct xwl_emulated_mode *emulated_mode;
@@ -279,10 +544,18 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
WindowPtr window;
DrawablePtr drawable;
- if (!xwl_screen_has_resolution_change_emulation(xwl_screen))
+ if (!xwl_screen_has_viewport_support(xwl_screen))
+ return FALSE;
+
+ if (xwl_screen->fullscreen)
+ return xwl_window_should_enable_viewport_fullscreen(xwl_window,
+ xwl_output_ret,
+ emulated_mode_ret);
+
+ if (!xwl_screen->rootless)
return FALSE;
- window = window_get_client_toplevel(xwl_window->window);
+ window = window_get_client_toplevel(xwl_window->toplevel);
if (!window)
return FALSE;
@@ -302,7 +575,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
drawable->width == emulated_mode->width &&
drawable->height == emulated_mode->height) {
- *emulated_mode_ret = emulated_mode;
+ memcpy(emulated_mode_ret, emulated_mode, sizeof(struct xwl_emulated_mode));
*xwl_output_ret = xwl_output;
return TRUE;
}
@@ -314,13 +587,13 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
*/
xwl_output = xwl_screen_get_first_output(xwl_screen);
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, owner);
- if (xwl_output && xwl_window->window->overrideRedirect &&
+ if (xwl_output && xwl_window->toplevel->overrideRedirect &&
emulated_mode && emulated_mode->from_vidmode &&
drawable->x == 0 && drawable->y == 0 &&
- drawable->width == xwl_screen->width &&
- drawable->height == xwl_screen->height) {
+ drawable->width == xwl_screen_get_width(xwl_screen) &&
+ drawable->height == xwl_screen_get_height(xwl_screen)) {
- *emulated_mode_ret = emulated_mode;
+ memcpy(emulated_mode_ret, emulated_mode, sizeof(struct xwl_emulated_mode));
*xwl_output_ret = xwl_output;
return TRUE;
}
@@ -328,14 +601,45 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
return FALSE;
}
+static Bool
+xwl_window_should_enable_fractional_scale_viewport(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ double scale;
+
+ if (!xwl_screen_should_use_fractional_scale(xwl_screen))
+ return FALSE;
+
+ scale = xwl_window_get_fractional_scale_factor(xwl_window);
+
+ return fabs(scale - 1.00) > FLT_EPSILON;
+}
+
+static void
+xwl_window_check_fractional_scale_viewport(struct xwl_window *xwl_window,
+ int width, int height)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+ if (!xwl_screen_should_use_fractional_scale(xwl_screen))
+ return;
+
+ if (xwl_window_should_enable_fractional_scale_viewport(xwl_window))
+ xwl_window_enable_viewport_for_fractional_scale(xwl_window, width, height);
+ else if (xwl_window_has_viewport_enabled(xwl_window))
+ xwl_window_disable_viewport(xwl_window);
+}
+
void
xwl_window_check_resolution_change_emulation(struct xwl_window *xwl_window)
{
- struct xwl_emulated_mode *emulated_mode;
+ struct xwl_emulated_mode emulated_mode;
struct xwl_output *xwl_output;
if (xwl_window_should_enable_viewport(xwl_window, &xwl_output, &emulated_mode))
- xwl_window_enable_viewport(xwl_window, xwl_output, emulated_mode);
+ xwl_window_enable_viewport_for_output(xwl_window, xwl_output, &emulated_mode);
+ else if (xwl_window_should_enable_fractional_scale_viewport(xwl_window))
+ return;
else if (xwl_window_has_viewport_enabled(xwl_window))
xwl_window_disable_viewport(xwl_window);
}
@@ -348,15 +652,15 @@ xwl_window_check_resolution_change_emulation(struct xwl_window *xwl_window)
Bool
xwl_window_is_toplevel(WindowPtr window)
{
- if (window_is_wm_window(window))
+ if (!window->parent || window_is_wm_window(window))
return FALSE;
/* CSD and override-redirect toplevel windows */
- if (window_get_damage(window))
+ if (!window->parent->parent)
return TRUE;
/* Normal toplevel client windows, reparented to a window-manager window */
- return window->parent && window_is_wm_window(window->parent);
+ return window_is_wm_window(window->parent);
}
static void
@@ -365,7 +669,7 @@ xwl_window_init_allow_commits(struct xwl_window *xwl_window)
PropertyPtr prop = NULL;
int ret;
- ret = dixLookupProperty(&prop, xwl_window->window,
+ ret = dixLookupProperty(&prop, xwl_window->toplevel,
xwl_window->xwl_screen->allow_commits_prop,
serverClient, DixReadAccess);
if (ret == Success && prop)
@@ -374,24 +678,30 @@ xwl_window_init_allow_commits(struct xwl_window *xwl_window)
xwl_window_set_allow_commits(xwl_window, TRUE, "no property");
}
+static uint32_t
+serial_lo(uint64_t value)
+{
+ return value & 0xFFFFFFFFu;
+}
+
+static uint32_t
+serial_hi(uint64_t value)
+{
+ return value >> 32u;
+}
+
static void
-send_surface_id_event(struct xwl_window *xwl_window)
+send_window_client_message(struct xwl_window *xwl_window, Atom type_atom, uint64_t value)
{
- static const char atom_name[] = "WL_SURFACE_ID";
- static Atom type_atom;
DeviceIntPtr dev;
xEvent e;
- if (type_atom == None)
- type_atom = MakeAtom(atom_name, strlen(atom_name), TRUE);
-
e.u.u.type = ClientMessage;
e.u.u.detail = 32;
- e.u.clientMessage.window = xwl_window->window->drawable.id;
+ e.u.clientMessage.window = xwl_window->toplevel->drawable.id;
e.u.clientMessage.u.l.type = type_atom;
- e.u.clientMessage.u.l.longs0 =
- wl_proxy_get_id((struct wl_proxy *) xwl_window->surface);
- e.u.clientMessage.u.l.longs1 = 0;
+ e.u.clientMessage.u.l.longs0 = serial_lo(value);
+ e.u.clientMessage.u.l.longs1 = serial_hi(value);
e.u.clientMessage.u.l.longs2 = 0;
e.u.clientMessage.u.l.longs3 = 0;
e.u.clientMessage.u.l.longs4 = 0;
@@ -402,103 +712,783 @@ send_surface_id_event(struct xwl_window *xwl_window)
}
static void
+send_surface_id_event_serial(struct xwl_window *xwl_window)
+{
+ static const char atom_name[] = "WL_SURFACE_SERIAL";
+ static Atom type_atom;
+ uint64_t serial;
+
+ if (type_atom == None)
+ type_atom = MakeAtom(atom_name, strlen(atom_name), TRUE);
+
+ serial = ++xwl_window->xwl_screen->surface_association_serial;
+
+ send_window_client_message(xwl_window, type_atom, serial);
+ xwayland_surface_v1_set_serial(xwl_window->xwayland_surface,
+ serial_lo(serial), serial_hi(serial));
+ wl_surface_commit(xwl_window->surface);
+
+ /* Flush wayland display *after* commit in the new path. */
+ wl_display_flush(xwl_window->xwl_screen->display);
+}
+
+static void
+send_surface_id_event_legacy(struct xwl_window *xwl_window)
+{
+ static const char atom_name[] = "WL_SURFACE_ID";
+ static Atom type_atom;
+ uint32_t surface_id;
+
+ if (type_atom == None)
+ type_atom = MakeAtom(atom_name, strlen(atom_name), TRUE);
+
+ surface_id = wl_proxy_get_id((struct wl_proxy *) xwl_window->surface);
+
+ /* Flush wayland display *before* setting the atom in the legacy path */
+ wl_display_flush(xwl_window->xwl_screen->display);
+
+ send_window_client_message(xwl_window, type_atom, (uint64_t)surface_id);
+}
+
+static void
+send_surface_id_event(struct xwl_window *xwl_window)
+{
+ return xwl_window->xwayland_surface
+ ? send_surface_id_event_serial(xwl_window)
+ : send_surface_id_event_legacy(xwl_window);
+
+}
+
+static Bool
+xwl_window_set_fullscreen(struct xwl_window *xwl_window)
+{
+ struct xwl_output *xwl_output;
+ struct wl_output *wl_output = NULL;
+
+ if (!xwl_window->xdg_toplevel)
+ return FALSE;
+
+ xwl_output = xwl_window_get_output(xwl_window);
+ if (xwl_output)
+ wl_output = xwl_output->output;
+
+ if (wl_output && xwl_window->wl_output_fullscreen == wl_output)
+ return FALSE;
+
+ xdg_toplevel_set_fullscreen(xwl_window->xdg_toplevel, wl_output);
+ xwl_window_check_resolution_change_emulation(xwl_window);
+ wl_surface_commit(xwl_window->surface);
+
+ xwl_window->wl_output_fullscreen = wl_output;
+
+ return TRUE;
+}
+
+void
+xwl_window_rootful_update_fullscreen(struct xwl_window *xwl_window,
+ struct xwl_output *xwl_output)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+ if (!xwl_screen->fullscreen)
+ return;
+
+ if (xwl_window->toplevel != xwl_screen->screen->root)
+ return;
+
+ if (xwl_window->wl_output_fullscreen != xwl_output->output)
+ return;
+
+ /* The size and position of the output may have changed, clear our
+ * output to make sure the next call to xwl_window_set_fullscreen()
+ * recomputes the size and updates the viewport as needed.
+ */
+ xwl_window->wl_output_fullscreen = NULL;
+ xwl_window_set_fullscreen(xwl_window);
+}
+
+void
+xwl_window_rootful_update_title(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ char title[128];
+ const char *grab_message = "";
+
+ if (xwl_screen->host_grab) {
+ if (xwl_screen->has_grab)
+ grab_message = " - ([ctrl]+[shift] releases mouse and keyboard)";
+ else
+ grab_message = " - ([ctrl]+[shift] grabs mouse and keyboard)";
+ }
+
+ snprintf(title, sizeof(title), "Xwayland on :%s%s", display, grab_message);
+
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_window->libdecor_frame)
+ libdecor_frame_set_title(xwl_window->libdecor_frame, title);
+ else
+#endif
+ if (xwl_window->xdg_toplevel)
+ xdg_toplevel_set_title(xwl_window->xdg_toplevel, title);
+}
+
+static void
+xwl_window_rootful_set_app_id(struct xwl_window *xwl_window)
+{
+ const char *app_id = "org.freedesktop.Xwayland";
+
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_window->libdecor_frame)
+ libdecor_frame_set_app_id(xwl_window->libdecor_frame, app_id);
+ else
+#endif
+ if (xwl_window->xdg_toplevel)
+ xdg_toplevel_set_app_id(xwl_window->xdg_toplevel, app_id);
+}
+
+static void
+xwl_window_maybe_resize(struct xwl_window *xwl_window, double width, double height)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ struct xwl_output *xwl_output;
+ double scale;
+ RRModePtr mode;
+
+ /* Clamp the size */
+ width = min(max(width, MIN_ROOTFUL_WIDTH), MAX_ROOTFUL_WIDTH);
+ height = min(max(height, MIN_ROOTFUL_HEIGHT), MAX_ROOTFUL_HEIGHT);
+
+ /* Make sure the size is a multiple of the scale, it's a protocol error otherwise. */
+ scale = xwl_screen->global_surface_scale;
+ if (scale > 1.0) {
+ width = round(width / scale) * scale;
+ height = round(height / scale) * scale;
+ }
+
+ if (width == xwl_screen->width && height == xwl_screen->height)
+ return;
+
+ xwl_screen->width = width;
+ xwl_screen->height = height;
+
+ /* When fractional scale is used, the global surface scale is 1, and vice
+ * versa, so we can multiply the two here, and have the resulting scale
+ * apply for both cases, the legacy wl_surface buffer scale and fractional
+ * scaling.
+ */
+ scale *= xwl_window_get_fractional_scale_factor(xwl_window);
+
+ xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
+ if (!xwl_randr_add_modes_fixed(xwl_output, round(width / scale), round(height / scale)))
+ return;
+
+ mode = xwl_output_find_mode(xwl_output, round(width / scale), round(height / scale));
+ xwl_output_set_mode_fixed(xwl_output, mode);
+
+ xwl_window_attach_buffer(xwl_window);
+}
+
+#ifdef XWL_HAS_LIBDECOR
+static void
+xwl_window_libdecor_set_size_limits(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+ libdecor_frame_set_min_content_size(xwl_window->libdecor_frame,
+ MIN_ROOTFUL_WIDTH /
+ xwl_screen->global_surface_scale,
+ MIN_ROOTFUL_HEIGHT /
+ xwl_screen->global_surface_scale);
+ libdecor_frame_set_max_content_size(xwl_window->libdecor_frame,
+ MAX_ROOTFUL_WIDTH /
+ xwl_screen->global_surface_scale,
+ MAX_ROOTFUL_HEIGHT /
+ xwl_screen->global_surface_scale);
+}
+
+static void
+xwl_window_update_libdecor_size(struct xwl_window *xwl_window,
+ struct libdecor_configuration *configuration /* nullable */,
+ int width, int height)
+{
+ struct libdecor_state *state;
+ double scale;
+
+ if (xwl_window->libdecor_frame) {
+ scale = xwl_window_get_fractional_scale_factor(xwl_window);
+ state = libdecor_state_new(round((double) width / scale),
+ round((double) height / scale));
+ libdecor_frame_commit(xwl_window->libdecor_frame, state, configuration);
+ libdecor_state_free(state);
+ }
+}
+
+static void
+handle_libdecor_configure(struct libdecor_frame *frame,
+ struct libdecor_configuration *configuration,
+ void *data)
+{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ int width, height;
+ double new_width, new_height;
+ double scale;
+
+ if (libdecor_configuration_get_content_size(configuration, frame, &width, &height)) {
+ new_width = (double) width;
+ new_height = (double) height;
+ }
+ else {
+ new_width = xwl_screen->width / xwl_screen->global_surface_scale;
+ new_height = xwl_screen->height / xwl_screen->global_surface_scale;
+ }
+
+ new_width *= xwl_screen->global_surface_scale;
+ new_height *= xwl_screen->global_surface_scale;
+
+ scale = xwl_window_get_fractional_scale_factor(xwl_window);
+ new_width *= scale;
+ new_height *= scale;
+
+ xwl_window_maybe_resize(xwl_window, new_width, new_height);
+
+ new_width = xwl_screen->width / xwl_screen->global_surface_scale;
+ new_height = xwl_screen->height / xwl_screen->global_surface_scale;
+
+ xwl_window_update_libdecor_size(xwl_window, configuration,
+ round(new_width), round(new_height));
+ wl_surface_commit(xwl_window->surface);
+}
+
+static void
+handle_libdecor_close(struct libdecor_frame *frame,
+ void *data)
+{
+ DebugF("Terminating on compositor request");
+ GiveUp(0);
+}
+
+static void
+handle_libdecor_commit(struct libdecor_frame *frame,
+ void *data)
+{
+ struct xwl_window *xwl_window = data;
+ wl_surface_commit(xwl_window->surface);
+}
+
+static void
+handle_libdecor_dismiss_popup(struct libdecor_frame *frame,
+ const char *seat_name,
+ void *data)
+{
+}
+
+static struct libdecor_frame_interface libdecor_frame_iface = {
+ handle_libdecor_configure,
+ handle_libdecor_close,
+ handle_libdecor_commit,
+ handle_libdecor_dismiss_popup,
+};
+#endif
+
+static void
xdg_surface_handle_configure(void *data,
struct xdg_surface *xdg_surface,
uint32_t serial)
{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+ if (xwl_screen->fullscreen)
+ xwl_window_set_fullscreen(xwl_window);
+
xdg_surface_ack_configure(xdg_surface, serial);
+ wl_surface_commit(xwl_window->surface);
}
static const struct xdg_surface_listener xdg_surface_listener = {
xdg_surface_handle_configure,
};
+static void
+xwl_window_update_surface_scale(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ int previous_scale, new_scale;
+ double new_width, new_height;
+
+ previous_scale = xwl_screen->global_surface_scale;
+ assert(previous_scale != 0);
+ xwl_window->surface_scale = xwl_window_get_max_output_scale(xwl_window);
+
+ if (xwl_screen_update_global_surface_scale(xwl_screen)) {
+ new_scale = xwl_screen->global_surface_scale;
+
+ DebugF("XWAYLAND: Global scale is now %i (was %i)\n",
+ new_scale, previous_scale);
+
+ new_width = xwl_screen->width / previous_scale * new_scale;
+ new_height = xwl_screen->height / previous_scale * new_scale;
+
+ wl_surface_set_buffer_scale(xwl_window->surface, xwl_screen->global_surface_scale);
+ /* Reflect the scale factor using XRandR transform */
+ xwl_output_set_xscale(xwl_screen->fixed_output, new_scale);
+ xwl_window_maybe_resize(xwl_window, new_width, new_height);
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_window->libdecor_frame) {
+ xwl_window_libdecor_set_size_limits(xwl_window);
+ xwl_window_update_libdecor_size(xwl_window,
+ NULL,
+ round(new_width / new_scale),
+ round(new_height / new_scale));
+ }
+ else
+#endif
+ wl_surface_commit(xwl_window->surface);
+ }
+}
+
+static void
+xwl_window_enter_output(struct xwl_window *xwl_window, struct xwl_output *xwl_output)
+{
+ struct xwl_window_output *window_output;
+
+ window_output = xnfcalloc(1, sizeof(struct xwl_window_output));
+ window_output->xwl_output = xwl_output;
+ xorg_list_add(&window_output->link, &xwl_window->xwl_output_list);
+}
+
+void
+xwl_window_leave_output(struct xwl_window *xwl_window, struct xwl_output *xwl_output)
+{
+ struct xwl_window_output *window_output, *tmp;
+
+ xorg_list_for_each_entry_safe(window_output, tmp, &xwl_window->xwl_output_list, link) {
+ if (window_output->xwl_output == xwl_output) {
+ xorg_list_del(&window_output->link);
+ free(window_output);
+ }
+ }
+}
+
+static void
+xwl_window_free_outputs(struct xwl_window *xwl_window)
+{
+ struct xwl_window_output *window_output, *tmp;
+
+ xorg_list_for_each_entry_safe(window_output, tmp, &xwl_window->xwl_output_list, link) {
+ xorg_list_del(&window_output->link);
+ free(window_output);
+ }
+}
+
+int
+xwl_window_get_max_output_scale(struct xwl_window *xwl_window)
+{
+ struct xwl_window_output *window_output;
+ struct xwl_output *xwl_output;
+ int scale = 1;
+
+ xorg_list_for_each_entry(window_output, &xwl_window->xwl_output_list, link) {
+ xwl_output = window_output->xwl_output;
+ if (xwl_output->scale > scale)
+ scale = xwl_output->scale;
+ }
+
+ return scale;
+}
+
+static void
+xwl_window_surface_enter(void *data,
+ struct wl_surface *wl_surface,
+ struct wl_output *wl_output)
+{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ struct xwl_output *xwl_output = xwl_output_from_wl_output(xwl_screen, wl_output);
+
+ if (xwl_output) {
+ xwl_window_enter_output(xwl_window, xwl_output);
+ xwl_window_update_surface_scale(xwl_window);
+ }
+
+ if (xwl_window->wl_output != wl_output) {
+ xwl_window->wl_output = wl_output;
+
+ if (xwl_screen->fullscreen)
+ xwl_window_set_fullscreen(xwl_window);
+ }
+}
+
+static void
+xwl_window_surface_leave(void *data,
+ struct wl_surface *wl_surface,
+ struct wl_output *wl_output)
+{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ struct xwl_output *xwl_output = xwl_output_from_wl_output(xwl_screen, wl_output);
+
+ if (xwl_output) {
+ xwl_window_leave_output(xwl_window, xwl_output);
+ xwl_window_update_surface_scale(xwl_window);
+ }
+
+ if (xwl_window->wl_output == wl_output)
+ xwl_window->wl_output = NULL;
+}
+
+static const struct wl_surface_listener surface_listener = {
+ xwl_window_surface_enter,
+ xwl_window_surface_leave
+};
+
+static void
+xdg_toplevel_handle_configure(void *data,
+ struct xdg_toplevel *xdg_toplevel,
+ int32_t width,
+ int32_t height,
+ struct wl_array *states)
+{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ uint32_t *p;
+ Bool old_active = xwl_screen->active;
+ double scale, new_width, new_height;
+
+ /* Maintain our current size if no dimensions are requested */
+ if (width == 0 && height == 0)
+ return;
+
+ if (!xwl_screen->fullscreen) {
+ new_width = (double) (width * xwl_screen->global_surface_scale);
+ new_height = (double) (height * xwl_screen->global_surface_scale);
+
+ scale = xwl_window_get_fractional_scale_factor(xwl_window);
+ new_width *= scale;
+ new_height *= scale;
+
+ /* This will be committed by the xdg_surface.configure handler */
+ xwl_window_maybe_resize(xwl_window, new_width, new_height);
+ }
+
+ xwl_screen->active = FALSE;
+ wl_array_for_each (p, states) {
+ uint32_t state = *p;
+ if (state == XDG_TOPLEVEL_STATE_ACTIVATED) {
+ xwl_screen->active = TRUE;
+ break;
+ }
+ }
+
+ if (old_active != xwl_screen->active) {
+ if (!xwl_screen->active)
+ xwl_screen_lost_focus(xwl_screen);
+ }
+}
+
+static void
+xdg_toplevel_handle_close(void *data,
+ struct xdg_toplevel *xdg_toplevel)
+{
+ DebugF("Terminating on compositor request");
+ GiveUp(0);
+}
+
+static const struct xdg_toplevel_listener xdg_toplevel_listener = {
+ xdg_toplevel_handle_configure,
+ xdg_toplevel_handle_close,
+};
+
+static void
+xwl_window_update_rootful_scale(struct xwl_window *xwl_window, double previous_scale)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ double new_scale, new_width, new_height;
+
+ new_scale = xwl_window_get_fractional_scale_factor(xwl_window);
+ new_width = xwl_screen->width / previous_scale * new_scale;
+ new_height = xwl_screen->height / previous_scale * new_scale;
+
+ DebugF("XWAYLAND: Fractional scale is now %.2f (was %.2f)\n",
+ new_scale, previous_scale);
+
+ xwl_output_set_xscale(xwl_screen->fixed_output, new_scale);
+ xwl_window_maybe_resize(xwl_window, new_width, new_height);
+ xwl_window_check_fractional_scale_viewport(xwl_window,
+ xwl_screen_get_width(xwl_screen),
+ xwl_screen_get_height(xwl_screen));
+
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_window->libdecor_frame) {
+ xwl_window_libdecor_set_size_limits(xwl_window);
+ xwl_window_update_libdecor_size(xwl_window,
+ NULL,
+ xwl_screen_get_width(xwl_screen),
+ xwl_screen_get_height(xwl_screen));
+ }
+ else
+#endif
+ wl_surface_commit(xwl_window->surface);
+}
+
+static void
+wp_fractional_scale_preferred_scale(void *data,
+ struct wp_fractional_scale_v1 *fractional_scale,
+ uint32_t scale_numerator)
+{
+ struct xwl_window *xwl_window = data;
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ double previous_scale = xwl_window_get_fractional_scale_factor(xwl_window);
+
+ if (xwl_window_update_fractional_scale(xwl_window, scale_numerator)) {
+ if (xwl_screen->fixed_output) { /* We're running rootful */
+ xwl_window_update_rootful_scale(xwl_window, previous_scale);
+ }
+ }
+}
+
+static const struct wp_fractional_scale_v1_listener fractional_scale_listener = {
+ wp_fractional_scale_preferred_scale,
+};
+
static Bool
+xwl_create_root_surface(struct xwl_window *xwl_window)
+{
+ struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ WindowPtr window = xwl_window->toplevel;
+ struct wl_region *region;
+
+
+#ifdef XWL_HAS_LIBDECOR
+ if (xwl_screen->decorate) {
+ xwl_window->libdecor_frame =
+ libdecor_decorate(xwl_screen->libdecor_context,
+ xwl_window->surface,
+ &libdecor_frame_iface,
+ xwl_window);
+ xwl_window_libdecor_set_size_limits(xwl_window);
+ libdecor_frame_map(xwl_window->libdecor_frame);
+ }
+ else
+#endif
+ {
+ xwl_window->xdg_surface =
+ xdg_wm_base_get_xdg_surface(xwl_screen->xdg_wm_base, xwl_window->surface);
+ if (xwl_window->xdg_surface == NULL) {
+ ErrorF("Failed creating xdg_wm_base xdg_surface\n");
+ goto err_surf;
+ }
+
+ xwl_window->xdg_toplevel =
+ xdg_surface_get_toplevel(xwl_window->xdg_surface);
+ if (xwl_window->xdg_surface == NULL) {
+ ErrorF("Failed creating xdg_toplevel\n");
+ goto err_surf;
+ }
+
+ xdg_surface_add_listener(xwl_window->xdg_surface,
+ &xdg_surface_listener, xwl_window);
+
+ xdg_toplevel_add_listener(xwl_window->xdg_toplevel,
+ &xdg_toplevel_listener,
+ xwl_window);
+ }
+
+ wl_surface_add_listener(xwl_window->surface,
+ &surface_listener, xwl_window);
+
+ if (xwl_screen_should_use_fractional_scale(xwl_screen)) {
+ xwl_window->fractional_scale =
+ wp_fractional_scale_manager_v1_get_fractional_scale(xwl_screen->fractional_scale_manager,
+ xwl_window->surface);
+ wp_fractional_scale_v1_add_listener(xwl_window->fractional_scale,
+ &fractional_scale_listener, xwl_window);
+ }
+
+ xwl_window_rootful_update_title(xwl_window);
+ xwl_window_rootful_set_app_id(xwl_window);
+ wl_surface_commit(xwl_window->surface);
+
+ region = wl_compositor_create_region(xwl_screen->compositor);
+ if (region == NULL) {
+ ErrorF("Failed creating region\n");
+ goto err_surf;
+ }
+
+ wl_region_add(region, 0, 0,
+ window->drawable.width, window->drawable.height);
+ wl_surface_set_opaque_region(xwl_window->surface, region);
+ wl_region_destroy(region);
+
+ return TRUE;
+
+err_surf:
+ if (xwl_window->xdg_toplevel)
+ xdg_toplevel_destroy(xwl_window->xdg_toplevel);
+ if (xwl_window->xdg_surface)
+ xdg_surface_destroy(xwl_window->xdg_surface);
+ wl_surface_destroy(xwl_window->surface);
+
+ return FALSE;
+}
+
+void
+xwl_window_update_surface_window(struct xwl_window *xwl_window)
+{
+ WindowPtr surface_window = xwl_window->toplevel;
+ ScreenPtr screen = surface_window->drawable.pScreen;
+ PixmapPtr surface_pixmap;
+ DamagePtr window_damage;
+ RegionRec damage_region;
+ WindowPtr window;
+
+ surface_pixmap = screen->GetWindowPixmap(surface_window);
+
+ for (window = surface_window->firstChild; window; window = window->firstChild) {
+ PixmapPtr window_pixmap;
+
+ if (!RegionEqual(&window->winSize, &surface_window->winSize))
+ break;
+
+ /* The surface window must be top-level for its window pixmap */
+ window_pixmap = screen->GetWindowPixmap(window);
+ if (window_pixmap == surface_pixmap)
+ continue;
+
+ surface_pixmap = window_pixmap;
+
+ /* A descendant with alpha channel cannot be the surface window, since
+ * any non-opaque areas need to take the contents of ancestors into
+ * account.
+ */
+ if (window->drawable.depth == 32)
+ continue;
+
+ surface_window = window;
+ }
+
+ if (xwl_window->surface_window == surface_window)
+ return;
+
+ if (xwl_window->surface_window_damage) {
+ if (xwl_present_maybe_unredirect_window(xwl_window->surface_window) &&
+ screen->SourceValidate == xwl_source_validate) {
+ WindowPtr toplevel = xwl_window->toplevel;
+
+ xwl_source_validate(&toplevel->drawable,
+ toplevel->drawable.x, toplevel->drawable.y,
+ toplevel->drawable.width,
+ toplevel->drawable.height,
+ IncludeInferiors);
+ }
+
+ if (RegionNotEmpty(xwl_window->surface_window_damage))
+ need_source_validate_dec(xwl_window->xwl_screen);
+
+ RegionDestroy(xwl_window->surface_window_damage);
+ xwl_window->surface_window_damage = NULL;
+ }
+
+ window_damage = window_get_damage(xwl_window->surface_window);
+ if (window_damage) {
+ RegionInit(&damage_region, NullBox, 1);
+ RegionCopy(&damage_region, DamageRegion(window_damage));
+ unregister_damage(xwl_window);
+ }
+
+ if (surface_window->drawable.depth != xwl_window->surface_window->drawable.depth)
+ xwl_window_buffers_dispose(xwl_window);
+
+ xwl_window->surface_window = surface_window;
+ register_damage(xwl_window);
+
+ if (window_damage) {
+ RegionPtr new_region = DamageRegion(window_get_damage(surface_window));
+
+ RegionUnion(new_region, new_region, &damage_region);
+ RegionUninit(&damage_region);
+ }
+}
+
+static struct xwl_window *
ensure_surface_for_window(WindowPtr window)
{
ScreenPtr screen = window->drawable.pScreen;
struct xwl_screen *xwl_screen;
struct xwl_window *xwl_window;
- struct wl_region *region;
WindowPtr toplevel;
- if (xwl_window_from_window(window))
- return TRUE;
+ xwl_window = xwl_window_from_window(window);
+ if (xwl_window)
+ return xwl_window;
xwl_screen = xwl_screen_get(screen);
if (xwl_screen->rootless) {
if (window->redirectDraw != RedirectDrawManual)
- return TRUE;
+ return NULL;
}
else {
if (window->parent)
- return TRUE;
+ return NULL;
}
xwl_window = calloc(1, sizeof *xwl_window);
if (xwl_window == NULL)
- return FALSE;
+ return NULL;
xwl_window->xwl_screen = xwl_screen;
- xwl_window->window = window;
+ xwl_window->toplevel = window;
+ xwl_window->surface_window = window;
+ xwl_window->fractional_scale_numerator = FRACTIONAL_SCALE_DENOMINATOR;
+ xwl_window->viewport_scale_x = 1.0;
+ xwl_window->viewport_scale_y = 1.0;
+ xwl_window->surface_scale = 1;
+ xorg_list_init(&xwl_window->xwl_output_list);
xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor);
if (xwl_window->surface == NULL) {
ErrorF("wl_display_create_surface failed\n");
goto err;
}
- if (!xwl_screen->rootless) {
- xwl_window->xdg_surface =
- xdg_wm_base_get_xdg_surface(xwl_screen->xdg_wm_base, xwl_window->surface);
- if (xwl_window->xdg_surface == NULL) {
- ErrorF("Failed creating xdg_wm_base xdg_surface\n");
- goto err_surf;
- }
-
- xdg_surface_add_listener(xwl_window->xdg_surface,
- &xdg_surface_listener, xwl_window);
-
- xdg_surface_get_toplevel(xwl_window->xdg_surface);
-
- wl_surface_commit(xwl_window->surface);
+ if (xwl_screen->xwayland_shell) {
+ xwl_window->xwayland_surface = xwayland_shell_v1_get_xwayland_surface(
+ xwl_screen->xwayland_shell, xwl_window->surface);
+ }
- region = wl_compositor_create_region(xwl_screen->compositor);
- if (region == NULL) {
- ErrorF("Failed creating region\n");
- goto err_surf;
- }
+ if (!xwl_screen->rootless && !xwl_create_root_surface(xwl_window))
+ goto err;
- wl_region_add(region, 0, 0,
- window->drawable.width, window->drawable.height);
- wl_surface_set_opaque_region(xwl_window->surface, region);
- wl_region_destroy(region);
- }
+#ifdef XWL_HAS_GLAMOR
+ if (xwl_screen->dmabuf_protocol_version >= 4)
+ xwl_dmabuf_setup_feedback_for_window(xwl_window);
+#endif
wl_display_flush(xwl_screen->display);
send_surface_id_event(xwl_window);
wl_surface_set_user_data(xwl_window->surface, xwl_window);
+ xwl_window_set_xwayland_tag(xwl_window);
compRedirectWindow(serverClient, window, CompositeRedirectManual);
dixSetPrivate(&window->devPrivates, &xwl_window_private_key, xwl_window);
xorg_list_init(&xwl_window->link_damage);
xorg_list_add(&xwl_window->link_window, &xwl_screen->window_list);
-
-#ifdef GLAMOR_HAS_GBM
xorg_list_init(&xwl_window->frame_callback_list);
-#endif
xwl_window_buffers_init(xwl_window);
+ xwl_window_update_surface_window(xwl_window);
+
xwl_window_init_allow_commits(xwl_window);
/* When a new window-manager window is realized, then the randr emulation
* props may have not been set on the managed client window yet.
*/
- if (window_is_wm_window(window)) {
+ if (!xwl_screen->fullscreen && window_is_wm_window(window)) {
toplevel = window_get_client_toplevel(window);
if (toplevel)
xwl_output_set_window_randr_emu_props(xwl_screen, toplevel);
@@ -507,15 +1497,16 @@ ensure_surface_for_window(WindowPtr window)
xwl_window_check_resolution_change_emulation(xwl_window);
}
- return TRUE;
+ if (xwl_screen->tearing_control_manager) {
+ xwl_window->tearing_control = wp_tearing_control_manager_v1_get_tearing_control(
+ xwl_screen->tearing_control_manager, xwl_window->surface);
+ }
+
+ return xwl_window;
-err_surf:
- if (xwl_window->xdg_surface)
- xdg_surface_destroy(xwl_window->xdg_surface);
- wl_surface_destroy(xwl_window->surface);
err:
free(xwl_window);
- return FALSE;
+ return NULL;
}
Bool
@@ -524,6 +1515,7 @@ xwl_realize_window(WindowPtr window)
ScreenPtr screen = window->drawable.pScreen;
CompScreenPtr comp_screen = GetCompScreen(screen);
struct xwl_screen *xwl_screen;
+ struct xwl_window *xwl_window;
Bool ret;
xwl_screen = xwl_screen_get(screen);
@@ -544,7 +1536,12 @@ xwl_realize_window(WindowPtr window)
}
if (!window->parent) {
- BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height };
+ BoxRec box = {
+ 0,
+ 0,
+ xwl_screen_get_width(xwl_screen),
+ xwl_screen_get_height(xwl_screen)
+ };
RegionReset(&window->winSize, &box);
RegionNull(&window->clipList);
@@ -552,15 +1549,87 @@ xwl_realize_window(WindowPtr window)
}
}
- if (xwl_screen->rootless ?
- (window->drawable.class == InputOutput &&
- window->parent == window->drawable.pScreen->root) :
- !window->parent) {
- if (!register_damage(window))
- return FALSE;
+ xwl_window = ensure_surface_for_window(window);
+ if (!xwl_window)
+ return FALSE;
+
+ if (window == xwl_window->surface_window &&
+ !window_get_damage(window))
+ return register_damage(xwl_window);
+
+ return TRUE;
+}
+
+static void
+xwl_surface_destroy_free_timer(struct xwl_wl_surface *xwl_wl_surface)
+{
+ if (xwl_wl_surface->wl_surface_destroy_timer) {
+ TimerFree(xwl_wl_surface->wl_surface_destroy_timer);
+ xwl_wl_surface->wl_surface_destroy_timer = NULL;
+ }
+}
+
+void
+xwl_window_surface_do_destroy(struct xwl_wl_surface *xwl_wl_surface)
+{
+ wl_surface_destroy(xwl_wl_surface->wl_surface);
+ xorg_list_del(&xwl_wl_surface->link);
+ xwl_surface_destroy_free_timer(xwl_wl_surface);
+ free(xwl_wl_surface);
+}
+
+static CARD32
+xwl_surface_destroy_callback(OsTimerPtr timer, CARD32 now, void *arg)
+{
+ struct xwl_wl_surface *xwl_wl_surface = arg;
+
+ xwl_window_surface_do_destroy(xwl_wl_surface);
+
+ return 0;
+}
+
+static void
+release_wl_surface_for_window_legacy_delay(struct xwl_window *xwl_window)
+{
+ struct xwl_wl_surface *xwl_wl_surface;
+
+ /* If the Xserver is terminating, destroy the surface immediately */
+ if ((dispatchException & DE_TERMINATE) == DE_TERMINATE) {
+ wl_surface_destroy(xwl_window->surface);
+ return;
}
- return ensure_surface_for_window(window);
+ /* Break the wl_surface / xwl_window relationship */
+ wl_surface_set_user_data(xwl_window->surface, NULL);
+ xwl_window_clear_xwayland_tag(xwl_window);
+
+ /* Schedule the destruction later, to mitigate the race between X11
+ * and Wayland processing so that the compositor has the time to
+ * establish the association before the wl_surface is destroyed.
+ */
+ xwl_wl_surface = xnfcalloc(1, sizeof *xwl_wl_surface);
+ xwl_wl_surface->wl_surface = xwl_window->surface;
+ xorg_list_add(&xwl_wl_surface->link,
+ &xwl_window->xwl_screen->pending_wl_surface_destroy);
+ xwl_wl_surface->wl_surface_destroy_timer =
+ TimerSet(NULL, 0, DELAYED_WL_SURFACE_DESTROY,
+ xwl_surface_destroy_callback, xwl_wl_surface);
+}
+
+static void
+release_wl_surface_for_window_shell(struct xwl_window *xwl_window)
+{
+ xwayland_surface_v1_destroy(xwl_window->xwayland_surface);
+ wl_surface_destroy(xwl_window->surface);
+}
+
+static void
+release_wl_surface_for_window(struct xwl_window *xwl_window)
+{
+ if (xwl_window->xwayland_surface)
+ release_wl_surface_for_window_shell(xwl_window);
+ else
+ release_wl_surface_for_window_legacy_delay(xwl_window);
}
Bool
@@ -574,59 +1643,68 @@ xwl_unrealize_window(WindowPtr window)
xwl_screen = xwl_screen_get(screen);
- xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
- if (xwl_seat->focus_window && xwl_seat->focus_window->window == window)
- xwl_seat->focus_window = NULL;
- if (xwl_seat->tablet_focus_window && xwl_seat->tablet_focus_window->window == window)
- xwl_seat->tablet_focus_window = NULL;
- if (xwl_seat->last_xwindow == window)
- xwl_seat->last_xwindow = NullWindow;
- if (xwl_seat->cursor_confinement_window &&
- xwl_seat->cursor_confinement_window->window == window)
- xwl_seat_unconfine_pointer(xwl_seat);
- if (xwl_seat->pointer_warp_emulator &&
- xwl_seat->pointer_warp_emulator->locked_window &&
- xwl_seat->pointer_warp_emulator->locked_window->window == window)
- xwl_seat_destroy_pointer_warp_emulator(xwl_seat);
- xwl_seat_clear_touch(xwl_seat, window);
- }
-
- compUnredirectWindow(serverClient, window, CompositeRedirectManual);
+ xwl_window = xwl_window_get(window);
+ if (xwl_window)
+ compUnredirectWindow(serverClient, window, CompositeRedirectManual);
screen->UnrealizeWindow = xwl_screen->UnrealizeWindow;
ret = (*screen->UnrealizeWindow) (window);
xwl_screen->UnrealizeWindow = screen->UnrealizeWindow;
screen->UnrealizeWindow = xwl_unrealize_window;
- xwl_window = xwl_window_get(window);
if (!xwl_window)
return ret;
+ xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
+ if (xwl_seat->focus_window == xwl_window)
+ xwl_seat->focus_window = NULL;
+ if (xwl_seat->tablet_focus_window == xwl_window)
+ xwl_seat->tablet_focus_window = NULL;
+ if (xwl_seat->last_focus_window == xwl_window)
+ xwl_seat->last_focus_window = NULL;
+ if (xwl_seat->cursor_confinement_window == xwl_window)
+ xwl_seat_unconfine_pointer(xwl_seat);
+ if (xwl_seat->pointer_warp_emulator &&
+ xwl_seat->pointer_warp_emulator->locked_window == xwl_window)
+ xwl_seat_destroy_pointer_warp_emulator(xwl_seat);
+ xwl_seat_clear_touch(xwl_seat, xwl_window);
+ }
+
if (xwl_window_has_viewport_enabled(xwl_window))
xwl_window_disable_viewport(xwl_window);
+#ifdef XWL_HAS_GLAMOR
+ xwl_dmabuf_feedback_destroy(&xwl_window->feedback);
#ifdef GLAMOR_HAS_GBM
- if (xwl_screen->present) {
- struct xwl_present_window *xwl_present_window, *tmp;
+ if (xwl_window->xwl_screen->present)
+ xwl_present_for_each_frame_callback(xwl_window, xwl_present_unrealize_window);
+#endif /* GLAMOR_HAS_GBM */
+#endif /* XWL_HAS_GLAMOR */
- xorg_list_for_each_entry_safe(xwl_present_window, tmp,
- &xwl_window->frame_callback_list,
- frame_callback_list) {
- xwl_present_unrealize_window(xwl_present_window);
- }
- }
-#endif
+ if (xwl_window->tearing_control)
+ wp_tearing_control_v1_destroy(xwl_window->tearing_control);
- wl_surface_destroy(xwl_window->surface);
+ if (xwl_window->fractional_scale)
+ wp_fractional_scale_v1_destroy(xwl_window->fractional_scale);
+
+ if (xwl_window->surface_sync)
+ wp_linux_drm_syncobj_surface_v1_destroy(xwl_window->surface_sync);
+
+ release_wl_surface_for_window(xwl_window);
xorg_list_del(&xwl_window->link_damage);
xorg_list_del(&xwl_window->link_window);
- unregister_damage(window);
+ unregister_damage(xwl_window);
xwl_window_buffers_dispose(xwl_window);
+ if (xwl_window->window_buffers_timer)
+ TimerFree(xwl_window->window_buffers_timer);
+
if (xwl_window->frame_callback)
wl_callback_destroy(xwl_window->frame_callback);
+ xwl_window_free_outputs(xwl_window);
+
free(xwl_window);
dixSetPrivate(&window->devPrivates, &xwl_window_private_key, NULL);
@@ -653,15 +1731,14 @@ xwl_window_set_window_pixmap(WindowPtr window,
if (!RegionNotEmpty(&window->winSize))
return;
- ensure_surface_for_window(window);
+ xwl_window = ensure_surface_for_window(window);
- if (old_pixmap->drawable.width == pixmap->drawable.width &&
- old_pixmap->drawable.height == pixmap->drawable.height)
+ if (!xwl_window ||
+ (old_pixmap->drawable.width == pixmap->drawable.width &&
+ old_pixmap->drawable.height == pixmap->drawable.height))
return;
- xwl_window = xwl_window_get(window);
- if (xwl_window)
- xwl_window_buffers_recycle(xwl_window);
+ xwl_window_buffers_dispose(xwl_window);
}
Bool
@@ -689,25 +1766,66 @@ xwl_change_window_attributes(WindowPtr window, unsigned long mask)
}
void
-xwl_resize_window(WindowPtr window,
+xwl_clip_notify(WindowPtr window, int dx, int dy)
+{
+ ScreenPtr screen = window->drawable.pScreen;
+ struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+ struct xwl_window *xwl_window = xwl_window_from_window(window);
+
+ screen->ClipNotify = xwl_screen->ClipNotify;
+ (*screen->ClipNotify) (window, dx, dy);
+ xwl_screen->ClipNotify = screen->ClipNotify;
+ screen->ClipNotify = xwl_clip_notify;
+
+ if (xwl_window)
+ xwl_window_update_surface_window(xwl_window);
+}
+
+int
+xwl_config_notify(WindowPtr window,
int x, int y,
- unsigned int width, unsigned int height,
+ int width, int height, int bw,
WindowPtr sib)
{
ScreenPtr screen = window->drawable.pScreen;
struct xwl_screen *xwl_screen;
struct xwl_window *xwl_window;
+ Bool size_changed;
+ int ret;
xwl_screen = xwl_screen_get(screen);
xwl_window = xwl_window_from_window(window);
- screen->ResizeWindow = xwl_screen->ResizeWindow;
- (*screen->ResizeWindow) (window, x, y, width, height, sib);
- xwl_screen->ResizeWindow = screen->ResizeWindow;
- screen->ResizeWindow = xwl_resize_window;
+ size_changed = width != window->drawable.width || height != window->drawable.height;
+ if (size_changed && xwl_window && xwl_window->toplevel == window &&
+ screen->SourceValidate == xwl_source_validate) {
+ xwl_source_validate(&window->drawable, window->drawable.x, window->drawable.y,
+ window->drawable.width, window->drawable.height,
+ IncludeInferiors);
+ }
- if (xwl_window && (xwl_window_get(window) || xwl_window_is_toplevel(window)))
- xwl_window_check_resolution_change_emulation(xwl_window);
+ screen->ConfigNotify = xwl_screen->ConfigNotify;
+ ret = screen->ConfigNotify(window, x, y, width, height, bw, sib);
+ xwl_screen->ConfigNotify = screen->ConfigNotify;
+ screen->ConfigNotify = xwl_config_notify;
+
+ if (size_changed && xwl_window) {
+ if (xwl_window_get(window) || xwl_window_is_toplevel(window))
+ xwl_window_check_resolution_change_emulation(xwl_window);
+ if (window == screen->root) {
+#ifdef XWL_HAS_LIBDECOR
+ unsigned int decor_width, decor_height;
+
+ decor_width = width / xwl_screen->global_surface_scale;
+ decor_height = height / xwl_screen->global_surface_scale;
+ xwl_window_update_libdecor_size(xwl_window, NULL,
+ decor_width, decor_height);
+#endif
+ xwl_window_check_fractional_scale_viewport(xwl_window, width, height);
+ }
+ }
+
+ return ret;
}
void
@@ -742,17 +1860,16 @@ frame_callback(void *data,
wl_callback_destroy (xwl_window->frame_callback);
xwl_window->frame_callback = NULL;
-#ifdef GLAMOR_HAS_GBM
if (xwl_window->xwl_screen->present) {
- struct xwl_present_window *xwl_present_window, *tmp;
+ xwl_present_for_each_frame_callback(xwl_window, xwl_present_frame_callback);
- xorg_list_for_each_entry_safe(xwl_present_window, tmp,
- &xwl_window->frame_callback_list,
- frame_callback_list) {
- xwl_present_frame_callback(xwl_present_window);
- }
+ /* If xwl_window_create_frame_callback was called from
+ * xwl_present_frame_callback, need to make sure all fallback timers
+ * are adjusted correspondingly.
+ */
+ if (xwl_window->frame_callback)
+ xwl_present_for_each_frame_callback(xwl_window, xwl_present_reset_timer);
}
-#endif
}
static const struct wl_callback_listener frame_listener = {
@@ -766,17 +1883,12 @@ xwl_window_create_frame_callback(struct xwl_window *xwl_window)
wl_callback_add_listener(xwl_window->frame_callback, &frame_listener,
xwl_window);
-#ifdef GLAMOR_HAS_GBM
- if (xwl_window->xwl_screen->present) {
- struct xwl_present_window *xwl_present_window, *tmp;
-
- xorg_list_for_each_entry_safe(xwl_present_window, tmp,
- &xwl_window->frame_callback_list,
- frame_callback_list) {
- xwl_present_reset_timer(xwl_present_window);
- }
- }
-#endif
+ /* If we get called from frame_callback, it will take care of calling
+ * xwl_present_reset_timer.
+ */
+ if (xwl_window->xwl_screen->present &&
+ !xwl_present_entered_for_each_frame_callback())
+ xwl_present_for_each_frame_callback(xwl_window, xwl_present_reset_timer);
}
Bool
@@ -786,10 +1898,8 @@ xwl_destroy_window(WindowPtr window)
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
Bool ret;
-#ifdef GLAMOR_HAS_GBM
if (xwl_screen->present)
xwl_present_cleanup(window);
-#endif
screen->DestroyWindow = xwl_screen->DestroyWindow;
@@ -804,41 +1914,24 @@ xwl_destroy_window(WindowPtr window)
return ret;
}
-void
-xwl_window_post_damage(struct xwl_window *xwl_window)
+static Bool
+xwl_window_attach_buffer(struct xwl_window *xwl_window)
{
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+ WindowPtr surface_window = xwl_window->surface_window;
RegionPtr region;
BoxPtr box;
struct wl_buffer *buffer;
PixmapPtr pixmap;
int i;
- assert(!xwl_window->frame_callback);
-
- region = DamageRegion(window_get_damage(xwl_window->window));
- pixmap = xwl_window_buffers_get_pixmap(xwl_window, region);
-
-#ifdef XWL_HAS_GLAMOR
- if (xwl_screen->glamor)
- buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
- else
-#endif
- buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
+ pixmap = xwl_window_swap_pixmap(xwl_window);
+ buffer = xwl_pixmap_get_wl_buffer(pixmap);
if (!buffer) {
ErrorF("Error getting buffer\n");
- return;
- }
-
-#ifdef XWL_HAS_GLAMOR
- if (xwl_screen->glamor) {
- if (!xwl_glamor_post_damage(xwl_window, pixmap, region)) {
- ErrorF("glamor: Failed to post damage\n");
- return;
- }
+ return FALSE;
}
-#endif
wl_surface_attach(xwl_window->surface, buffer, 0, 0);
@@ -846,24 +1939,36 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
* connection. If we flood it too much anyway, this could
* abort in libwayland-client.
*/
+ region = xwl_window_get_damage_region(xwl_window);
if (RegionNumRects(region) > 256) {
box = RegionExtents(region);
xwl_surface_damage(xwl_screen, xwl_window->surface,
- box->x1 + xwl_window->window->borderWidth,
- box->y1 + xwl_window->window->borderWidth,
+ box->x1 + surface_window->borderWidth,
+ box->y1 + surface_window->borderWidth,
box->x2 - box->x1, box->y2 - box->y1);
} else {
box = RegionRects(region);
for (i = 0; i < RegionNumRects(region); i++, box++) {
xwl_surface_damage(xwl_screen, xwl_window->surface,
- box->x1 + xwl_window->window->borderWidth,
- box->y1 + xwl_window->window->borderWidth,
+ box->x1 + surface_window->borderWidth,
+ box->y1 + surface_window->borderWidth,
box->x2 - box->x1, box->y2 - box->y1);
}
}
+ return TRUE;
+}
+
+void
+xwl_window_post_damage(struct xwl_window *xwl_window)
+{
+ assert(!xwl_window->frame_callback);
+
+ if (!xwl_window_attach_buffer(xwl_window))
+ return;
+
xwl_window_create_frame_callback(xwl_window);
- DamageEmpty(window_get_damage(xwl_window->window));
+ DamageEmpty(window_get_damage(xwl_window->surface_window));
}
Bool
diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h
index d94f07204..836f654a3 100644
--- a/hw/xwayland/xwayland-window.h
+++ b/hw/xwayland/xwayland-window.h
@@ -28,22 +28,62 @@
#include <xwayland-config.h>
+#include <sys/types.h>
+
#include <stdio.h>
#include <unistd.h>
+
#include <X11/X.h>
#include <dix.h>
#include <propertyst.h>
#include <validate.h>
+#include <wayland-util.h>
+#include <xf86drm.h>
#include "xwayland-types.h"
+#include "xwayland-dmabuf.h"
+
+struct xwl_wl_surface {
+ OsTimerPtr wl_surface_destroy_timer;
+ struct wl_surface *wl_surface;
+ struct xorg_list link;
+};
+
+struct xwl_window_output {
+ struct xorg_list link;
+ struct xwl_output *xwl_output;
+};
struct xwl_window {
struct xwl_screen *xwl_screen;
struct wl_surface *surface;
struct wp_viewport *viewport;
- float scale_x, scale_y;
+ float viewport_scale_x, viewport_scale_y;
+ int surface_scale;
struct xdg_surface *xdg_surface;
- WindowPtr window;
+ struct xdg_toplevel *xdg_toplevel;
+
+ /* Top-level window for the Wayland surface:
+ * - With rootful, the root window itself
+ * - With rootless, a direct child of the root window
+ * Mainly useful when the top-level window is needed, can also be used for
+ * the X dimensions of the Wayland surface though.
+ */
+ WindowPtr toplevel;
+
+ /* The window associated with the Wayland surface:
+ * - If the top-level window has descendants which:
+ * - Cover it completely
+ * - Have no alpha channel
+ * - Use a different window pixmap than their parent for storage
+ * then the surface window is the lowest-level such descendant.
+ * - Otherwise it's the top-level window itself.
+ * Mainly useful for code dealing with (buffers for) the Wayland surface,
+ * can also be used for the X dimensions of the Wayland surface though.
+ */
+ WindowPtr surface_window;
+ RegionPtr surface_window_damage;
+
struct xorg_list link_damage;
struct xorg_list link_window;
struct wl_callback *frame_callback;
@@ -51,29 +91,50 @@ struct xwl_window {
struct xorg_list window_buffers_available;
struct xorg_list window_buffers_unavailable;
OsTimerPtr window_buffers_timer;
-#ifdef GLAMOR_HAS_GBM
+ struct wl_output *wl_output;
+ struct wl_output *wl_output_fullscreen;
+ struct xorg_list xwl_output_list;
struct xorg_list frame_callback_list;
- Bool present_flipped;
+#ifdef XWL_HAS_LIBDECOR
+ struct libdecor_frame *libdecor_frame;
#endif
+ struct xwayland_surface_v1 *xwayland_surface;
+ struct xwl_dmabuf_feedback feedback;
+ /* If TRUE, the window buffer format supports scanout with implicit modifier */
+ Bool has_implicit_scanout_support;
+ struct wp_tearing_control_v1 *tearing_control;
+ struct wp_fractional_scale_v1 *fractional_scale;
+ int fractional_scale_numerator;
+ struct wp_linux_drm_syncobj_surface_v1 *surface_sync;
};
struct xwl_window *xwl_window_get(WindowPtr window);
+RegionPtr xwl_window_get_damage_region(struct xwl_window *xwl_window);
struct xwl_window *xwl_window_from_window(WindowPtr window);
+Bool is_surface_from_xwl_window(struct wl_surface *surface);
+
void xwl_window_update_property(struct xwl_window *xwl_window,
PropertyStateRec *propstate);
-Bool xwl_window_has_viewport_enabled(struct xwl_window *xwl_window);
Bool xwl_window_is_toplevel(WindowPtr window);
void xwl_window_check_resolution_change_emulation(struct xwl_window *xwl_window);
-
+void xwl_window_rootful_update_title(struct xwl_window *xwl_window);
+void xwl_window_rootful_update_fullscreen(struct xwl_window *xwl_window,
+ struct xwl_output *xwl_output);
void xwl_window_set_window_pixmap(WindowPtr window, PixmapPtr pixmap);
+void xwl_window_update_surface_window(struct xwl_window *xwl_window);
+
+void xwl_window_leave_output(struct xwl_window *xwl_window,
+ struct xwl_output *xwl_output);
+int xwl_window_get_max_output_scale(struct xwl_window *xwl_window);
Bool xwl_realize_window(WindowPtr window);
Bool xwl_unrealize_window(WindowPtr window);
Bool xwl_change_window_attributes(WindowPtr window, unsigned long mask);
-void xwl_resize_window(WindowPtr window,
- int x, int y,
- unsigned int width, unsigned int height,
- WindowPtr sib);
+void xwl_clip_notify(WindowPtr window, int dx, int dy);
+int xwl_config_notify(WindowPtr window,
+ int x, int y,
+ int width, int height, int bw,
+ WindowPtr sib);
void xwl_move_window(WindowPtr window,
int x, int y,
WindowPtr next_sib,
@@ -81,6 +142,8 @@ void xwl_move_window(WindowPtr window,
Bool xwl_destroy_window(WindowPtr window);
void xwl_window_post_damage(struct xwl_window *xwl_window);
void xwl_window_create_frame_callback(struct xwl_window *xwl_window);
+void xwl_window_surface_do_destroy(struct xwl_wl_surface *xwl_wl_surface);
+
Bool xwl_window_init(void);
#endif /* XWAYLAND_WINDOW_H */
diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
new file mode 100644
index 000000000..756a6d8f7
--- /dev/null
+++ b/hw/xwayland/xwayland-xtest.c
@@ -0,0 +1,936 @@
+/*
+ * Copyright © 2020 Red Hat
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <xwayland-config.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <libei.h>
+
+#include "dix/dix_priv.h"
+
+#include <inputstr.h>
+#include <inpututils.h>
+
+#ifdef XWL_HAS_EI_PORTAL
+#include "liboeffis.h"
+#endif
+
+#include "xwayland-screen.h"
+#include "xwayland-xtest.h"
+
+#define debug_ei(...) DebugF("[xwayland ei] " __VA_ARGS__)
+#define error_ei(...) ErrorF("[xwayland ei] " __VA_ARGS__)
+
+#define SCROLL_STEP 120 /* libei's definition of a logical scroll step */
+
+static struct xorg_list clients_for_reuse;
+
+static DevPrivateKeyRec xwl_ei_private_key;
+static DevPrivateKeyRec xwl_device_data_private_key;
+
+struct xwl_device_data {
+ DeviceSendEventsProc sendEventsProc;
+};
+
+struct xwl_emulated_event {
+ DeviceIntPtr dev;
+ int type;
+ int detail;
+ int flags;
+ ValuatorMask mask;
+ struct xorg_list link;
+};
+
+struct xwl_abs_device {
+ struct xorg_list link;
+ struct ei_device *device;
+};
+
+struct xwl_ei_client {
+ struct xorg_list link; /* in clients_for_reuse */
+ ClientPtr client; /* can be NULL if the X11 client is gone */
+ char *cmdline;
+ bool accept_pointer, accept_keyboard, accept_abs;
+ struct ei *ei;
+ int ei_fd;
+#ifdef XWL_HAS_EI_PORTAL
+ struct oeffis *oeffis;
+ int oeffis_fd;
+#endif
+ struct ei_seat *ei_seat;
+ struct ei_device *ei_pointer;
+ struct ei_device *ei_keyboard;
+ struct xorg_list abs_devices;
+ struct xorg_list pending_emulated_events;
+
+ OsTimerPtr disconnect_timer;
+};
+
+static void xwl_handle_ei_event(int fd, int ready, void *data);
+static bool xwl_dequeue_emulated_events(struct xwl_ei_client *xwl_ei_client);
+
+static struct xwl_device_data *
+xwl_device_data_get(DeviceIntPtr dev)
+{
+ return dixLookupPrivate(&dev->devPrivates, &xwl_device_data_private_key);
+}
+
+static struct xwl_ei_client *
+get_xwl_ei_client(ClientPtr client)
+{
+ return dixLookupPrivate(&client->devPrivates, &xwl_ei_private_key);
+}
+
+static void
+xwl_queue_emulated_event(struct xwl_ei_client *xwl_ei_client, DeviceIntPtr dev,
+ int type, int detail, int flags, const ValuatorMask *mask)
+{
+ struct xwl_emulated_event *xwl_emulated_event;
+
+ xwl_emulated_event = calloc(1, sizeof *xwl_emulated_event);
+ if (!xwl_emulated_event) {
+ error_ei("OOM, cannot queue event\n");
+ return;
+ }
+
+ xwl_emulated_event->dev = dev;
+ xwl_emulated_event->type = type;
+ xwl_emulated_event->detail = detail;
+ xwl_emulated_event->flags = flags;
+ valuator_mask_copy(&xwl_emulated_event->mask, mask);
+
+ xorg_list_append(&xwl_emulated_event->link,
+ &xwl_ei_client->pending_emulated_events);
+}
+
+static void
+xwl_clear_emulated_events(struct xwl_ei_client *xwl_ei_client)
+{
+ struct xwl_emulated_event *xwl_emulated_event, *next_xwl_emulated_event;
+
+ xorg_list_for_each_entry_safe(xwl_emulated_event, next_xwl_emulated_event,
+ &xwl_ei_client->pending_emulated_events, link) {
+ xorg_list_del(&xwl_emulated_event->link);
+ free(xwl_emulated_event);
+ }
+}
+
+static void
+add_ei_device(struct xwl_ei_client *xwl_ei_client, struct ei_device *device)
+{
+ bool used = true;
+
+ /* Note: pointers in libei are split across four capabilities:
+ pointer/pointer-absolute/button/scroll. We expect any decent
+ compositor to give pointers the button + scroll interfaces too,
+ if that's not the case we can look into *why* and fix this as needed.
+ Meanwhile, we ignore any device that doesn't have button + scroll
+ in addition to pointer caps.
+ */
+
+ if (ei_device_has_capability(device, EI_DEVICE_CAP_POINTER) &&
+ ei_device_has_capability(device, EI_DEVICE_CAP_BUTTON) &&
+ ei_device_has_capability(device, EI_DEVICE_CAP_SCROLL) &&
+ xwl_ei_client->ei_pointer == NULL) {
+
+ xwl_ei_client->ei_pointer = ei_device_ref(device);
+ used = true;
+ }
+
+ if (ei_device_has_capability(device, EI_DEVICE_CAP_KEYBOARD) &&
+ xwl_ei_client->ei_keyboard == NULL) {
+ xwl_ei_client->ei_keyboard = ei_device_ref(device);
+ used = true;
+ }
+
+ if (ei_device_has_capability(device, EI_DEVICE_CAP_POINTER_ABSOLUTE) &&
+ ei_device_has_capability(device, EI_DEVICE_CAP_BUTTON) &&
+ ei_device_has_capability(device, EI_DEVICE_CAP_SCROLL)) {
+ struct xwl_abs_device *abs = calloc(1, sizeof(*abs));
+
+ if (abs) {
+ xorg_list_add(&abs->link, &xwl_ei_client->abs_devices);
+ abs->device = ei_device_ref(device);
+ used = true;
+ }
+ }
+
+ if (!used)
+ ei_device_close(device);
+}
+
+static void
+free_oeffis(struct xwl_ei_client *xwl_ei_client)
+{
+#ifdef XWL_HAS_EI_PORTAL
+ if (xwl_ei_client->oeffis) {
+ debug_ei("Removing OEFFIS fd=%d\n", xwl_ei_client->oeffis_fd);
+ if (xwl_ei_client->oeffis_fd >= 0)
+ RemoveNotifyFd(xwl_ei_client->oeffis_fd);
+ xwl_ei_client->oeffis = oeffis_unref(xwl_ei_client->oeffis);
+ }
+#endif
+}
+
+static void
+free_ei(struct xwl_ei_client *xwl_ei_client)
+{
+ struct ei *ei = xwl_ei_client->ei;
+ struct xwl_abs_device *abs, *tmp;
+ ClientPtr client = xwl_ei_client->client;
+
+ TimerCancel(xwl_ei_client->disconnect_timer);
+ xorg_list_del(&xwl_ei_client->link);
+
+ debug_ei("Removing EI fd=%d\n", xwl_ei_client->ei_fd);
+ if (xwl_ei_client->ei_fd >= 0)
+ RemoveNotifyFd(xwl_ei_client->ei_fd);
+ ei_device_unref(xwl_ei_client->ei_pointer);
+ ei_device_unref(xwl_ei_client->ei_keyboard);
+ xorg_list_for_each_entry_safe(abs, tmp, &xwl_ei_client->abs_devices, link) {
+ xorg_list_del(&abs->link);
+ ei_device_unref(abs->device);
+ free(abs);
+ }
+
+ xwl_clear_emulated_events(xwl_ei_client);
+ if (client)
+ dixSetPrivate(&client->devPrivates, &xwl_ei_private_key, NULL);
+
+ free_oeffis(xwl_ei_client);
+
+ ei_seat_unref(xwl_ei_client->ei_seat);
+ ei_unref(ei);
+
+ free(xwl_ei_client->cmdline);
+ free(xwl_ei_client);
+}
+
+#ifdef XWL_HAS_EI_PORTAL
+static void
+setup_ei_from_oeffis(struct xwl_ei_client *xwl_ei_client)
+{
+ struct oeffis *oeffis = xwl_ei_client->oeffis;
+
+ xwl_ei_client->ei_fd = oeffis_get_eis_fd(oeffis);
+ if (xwl_ei_client->ei_fd < 0) {
+ error_ei("Failed to setup EI file descriptor from oeffis\n");
+ return;
+ }
+ ei_setup_backend_fd(xwl_ei_client->ei, xwl_ei_client->ei_fd);
+ SetNotifyFd(xwl_ei_client->ei_fd, xwl_handle_ei_event,
+ X_NOTIFY_READ, xwl_ei_client);
+}
+
+static void
+xwl_handle_oeffis_event(int fd, int ready, void *data)
+{
+ struct xwl_ei_client *xwl_ei_client = data;
+ struct oeffis *oeffis = xwl_ei_client->oeffis;
+ enum oeffis_event_type event_type;
+ bool done = false;
+
+ oeffis_dispatch(oeffis);
+
+ do {
+ event_type = oeffis_get_event(oeffis);
+ switch (event_type) {
+ case OEFFIS_EVENT_NONE:
+ debug_ei("OEFFIS event none\n");
+ done = true;
+ break;
+ case OEFFIS_EVENT_CONNECTED_TO_EIS:
+ debug_ei("OEFFIS connected to EIS\n");
+ setup_ei_from_oeffis(xwl_ei_client);
+ break;
+ case OEFFIS_EVENT_DISCONNECTED:
+ debug_ei("OEFFIS disconnected: %s\n",
+ oeffis_get_error_message(oeffis));
+ xwl_dequeue_emulated_events(xwl_ei_client);
+ free_ei(xwl_ei_client);
+ done = true;
+ break;
+ case OEFFIS_EVENT_CLOSED:
+ debug_ei("OEFFIS closed\n");
+ free_ei(xwl_ei_client);
+ done = true;
+ break;
+ }
+ }
+ while (!done);
+}
+#endif
+
+static bool
+setup_oeffis(struct xwl_ei_client *xwl_ei_client)
+{
+#ifdef XWL_HAS_EI_PORTAL
+ xwl_ei_client->oeffis_fd = -1;
+ xwl_ei_client->oeffis = oeffis_new(NULL);
+ if (!xwl_ei_client->oeffis)
+ return false;
+
+ xwl_ei_client->oeffis_fd = oeffis_get_fd(xwl_ei_client->oeffis);
+ if (xwl_ei_client->oeffis_fd < 0) {
+ error_ei("Failed to setup OEFFIS file descriptor\n");
+ return false;
+ }
+
+ SetNotifyFd(xwl_ei_client->oeffis_fd, xwl_handle_oeffis_event,
+ X_NOTIFY_READ, xwl_ei_client);
+
+ oeffis_create_session(xwl_ei_client->oeffis,
+ OEFFIS_DEVICE_KEYBOARD | OEFFIS_DEVICE_POINTER);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+static bool
+setup_ei_from_socket(struct xwl_ei_client *xwl_ei_client)
+{
+ int rc;
+
+ rc = ei_setup_backend_socket(xwl_ei_client->ei, NULL);
+
+ if (rc != 0) {
+ error_ei("Setup failed: %s\n", strerror(-rc));
+ return false;
+ }
+
+ xwl_ei_client->ei_fd = ei_get_fd(xwl_ei_client->ei);
+ if (xwl_ei_client->ei_fd < 0) {
+ error_ei("Failed to setup EI file descriptor from socket\n");
+ return false;
+ }
+
+ SetNotifyFd(xwl_ei_client->ei_fd, xwl_handle_ei_event,
+ X_NOTIFY_READ, xwl_ei_client);
+
+ return true;
+}
+
+static struct xwl_ei_client *
+setup_ei(ClientPtr client)
+{
+ ScreenPtr pScreen = screenInfo.screens[0];
+ struct xwl_ei_client *xwl_ei_client = NULL;
+ struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
+ struct ei *ei = NULL;
+ char buffer[PATH_MAX];
+ const char *cmdname;
+ char *client_name = NULL;
+ bool status = false;
+
+ cmdname = GetClientCmdName(client);
+ if (cmdname) {
+ snprintf(buffer, sizeof(buffer) - 1, "%s", cmdname);
+ client_name = basename(buffer);
+ }
+
+ if (!client_name) {
+ error_ei("Failed to retrieve the client command line name\n");
+ goto out;
+ }
+
+ xwl_ei_client = calloc(1, sizeof *xwl_ei_client);
+ xwl_ei_client->cmdline = xstrdup(cmdname);
+ if (!xwl_ei_client) {
+ error_ei("OOM, cannot setup EI\n");
+ goto out;
+ }
+ xorg_list_init(&xwl_ei_client->link);
+
+ ei = ei_new(NULL);
+ ei_configure_name(ei, basename(client_name));
+
+ /* We can't send events to EIS until we have a device and the device
+ * is resumed.
+ */
+ xwl_ei_client->accept_pointer = false;
+ xwl_ei_client->accept_keyboard = false;
+ xwl_ei_client->accept_abs = false;
+ xwl_ei_client->ei = ei;
+ xwl_ei_client->ei_fd = -1;
+ xwl_ei_client->client = client;
+ xorg_list_init(&xwl_ei_client->pending_emulated_events);
+ xorg_list_init(&xwl_ei_client->abs_devices);
+
+ if (xwl_screen->enable_ei_portal)
+ status = setup_oeffis(xwl_ei_client);
+ if (!status)
+ status = setup_ei_from_socket(xwl_ei_client);
+
+ if (!status) {
+ free(xwl_ei_client);
+ xwl_ei_client = NULL;
+ ei_unref(ei);
+ error_ei("EI setup failed\n");
+ /* We failed to setup EI using either backends, give up on EI. */
+ xwayland_restore_xtest();
+ }
+
+ out:
+ return xwl_ei_client;
+}
+
+static CARD32
+disconnect_timer_cb(OsTimerPtr timer, CARD32 time, void *arg)
+{
+ struct xwl_ei_client *xwl_ei_client = arg;
+
+ free_ei(xwl_ei_client);
+
+ return 0;
+}
+
+static void
+xwl_ei_start_emulating(struct xwl_ei_client *xwl_ei_client)
+{
+ static uint32_t sequence = 0;
+ struct xwl_abs_device *abs;
+
+ sequence++;
+ if (xwl_ei_client->ei_pointer)
+ ei_device_start_emulating(xwl_ei_client->ei_pointer, sequence);
+ if (xwl_ei_client->ei_keyboard)
+ ei_device_start_emulating(xwl_ei_client->ei_keyboard, sequence);
+ xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, link) {
+ ei_device_start_emulating(abs->device, sequence);
+ }
+}
+
+static void
+xwl_ei_stop_emulating(struct xwl_ei_client *xwl_ei_client)
+{
+ struct xwl_abs_device *abs;
+
+ if (xwl_ei_client->ei_pointer)
+ ei_device_stop_emulating(xwl_ei_client->ei_pointer);
+ if (xwl_ei_client->ei_keyboard)
+ ei_device_stop_emulating(xwl_ei_client->ei_keyboard);
+ xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, link) {
+ ei_device_stop_emulating(abs->device);
+ }
+}
+
+static void
+xwl_ei_handle_client_gone(struct xwl_ei_client *xwl_ei_client)
+{
+ ClientPtr client = xwl_ei_client->client;
+
+ /* Make this EI client struct re-usable. xdotool only exists for a
+ * fraction of a second, so let's make it re-use the same client every
+ * time - this makes it easier to e.g. pause it */
+ xorg_list_add(&xwl_ei_client->link, &clients_for_reuse);
+
+ if (xorg_list_is_empty(&xwl_ei_client->pending_emulated_events))
+ xwl_ei_stop_emulating(xwl_ei_client);
+
+ debug_ei("Client %s is now reusable\n", xwl_ei_client->cmdline);
+
+ /* Otherwise, we keep the EI part but break up with the X11 client */
+ assert(client);
+ dixSetPrivate(&client->devPrivates, &xwl_ei_private_key, NULL);
+ xwl_ei_client->client = NULL;
+
+ /* Set a timer for 10 minutes. If the same client doesn't reconnect,
+ * free it properly */
+ xwl_ei_client->disconnect_timer =
+ TimerSet(xwl_ei_client->disconnect_timer, 0,
+ 10 * 60 * 1000, disconnect_timer_cb, xwl_ei_client);
+}
+
+static void
+xwl_ei_state_client_callback(CallbackListPtr *pcbl, void *unused, void *data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr client = clientinfo->client;
+ struct xwl_ei_client *xwl_ei_client = get_xwl_ei_client(client);
+
+ switch (client->clientState) {
+ case ClientStateGone:
+ case ClientStateRetained:
+ if (xwl_ei_client)
+ xwl_ei_handle_client_gone(xwl_ei_client);
+ break;
+ default:
+ break;
+ }
+}
+
+static inline unsigned int
+buttonmap(unsigned int b)
+{
+ unsigned int button;
+
+ switch (b) {
+ case 0:
+ button = 0;
+ break;
+ case 1:
+ button = 0x110; /* BTN_LEFT */
+ break;
+ case 2:
+ button = 0x112; /* BTN_MIDDLE */
+ break;
+ case 3:
+ button = 0x111; /* BTN_RIGHT */
+ break;
+ default:
+ button = b - 8 + 0x113; /* BTN_SIDE */
+ break;
+ }
+
+ return button;
+}
+
+static void
+xwl_send_abs_event_to_ei(struct xwl_ei_client *xwl_ei_client, int sx, int sy)
+{
+ struct xwl_abs_device *abs;
+ struct ei *ei = xwl_ei_client->ei;
+
+ xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, link) {
+ struct ei_region *r;
+ size_t idx = 0;
+
+ while ((r = ei_device_get_region(abs->device, idx++))) {
+ double x = sx, y = sy;
+
+ if (ei_region_contains(r, x, y)) {
+ ei_device_pointer_motion_absolute(abs->device, sx, sy);
+ ei_device_frame(abs->device, ei_now(ei));
+ return;
+ }
+ }
+ }
+}
+
+static bool
+xwl_send_event_to_ei(struct xwl_ei_client *xwl_ei_client,
+ int type, int detail, int flags, const ValuatorMask *mask)
+{
+ struct ei *ei = xwl_ei_client->ei;
+ struct ei_device *ei_device = NULL;
+ int x = 0, y = 0;
+
+ debug_ei("Sending event type %d to EIS\n", type);
+
+ switch (type) {
+ case MotionNotify:
+ valuator_mask_fetch(mask, 0, &x);
+ valuator_mask_fetch(mask, 1, &y);
+
+ if (flags & POINTER_ABSOLUTE) {
+ if (!xwl_ei_client->accept_abs)
+ return false;
+
+ xwl_send_abs_event_to_ei(xwl_ei_client, x, y);
+ }
+ else if (x || y) {
+ if (!xwl_ei_client->accept_pointer)
+ return false;
+
+ ei_device = xwl_ei_client->ei_pointer;
+ ei_device_pointer_motion(ei_device, x, y);
+ ei_device_frame(ei_device, ei_now(ei));
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ if (!xwl_ei_client->accept_pointer)
+ return false;
+
+ ei_device = xwl_ei_client->ei_pointer;
+ if (detail < 4 || detail > 7) {
+ ei_device_button_button(ei_device,
+ buttonmap(detail), type == ButtonPress);
+ ei_device_frame(ei_device, ei_now(ei));
+ /* Scroll only on release */
+ } else if (type == ButtonRelease) {
+ if (detail == 4) {
+ ei_device_scroll_discrete(ei_device, 0, -SCROLL_STEP);
+ } else if (detail == 5) {
+ ei_device_scroll_discrete(ei_device, 0, SCROLL_STEP);
+ } else if (detail == 6) {
+ ei_device_scroll_discrete(ei_device, -SCROLL_STEP, 0);
+ } else if (detail == 7) {
+ ei_device_scroll_discrete(ei_device, SCROLL_STEP, 0);
+ }
+ }
+ break;
+ case KeyPress:
+ case KeyRelease:
+ if (!xwl_ei_client->accept_keyboard)
+ return false;
+
+ ei_device = xwl_ei_client->ei_keyboard;
+ ei_device_keyboard_key(ei_device, detail - 8, type == KeyPress);
+ ei_device_frame(ei_device, ei_now(ei));
+ break;
+ default:
+ error_ei("XTEST event type %d is not implemented\n", type);
+ break;
+ }
+
+ return true;
+}
+
+static struct xwl_ei_client *
+reuse_client(ClientPtr client)
+{
+ struct xwl_ei_client *xwl_ei_client = NULL;
+ const char *cmdname = GetClientCmdName(client);
+
+ if (!cmdname)
+ return NULL;
+
+ debug_ei("Client maybe up for re-use: %s\n", cmdname);
+ xorg_list_for_each_entry(xwl_ei_client, &clients_for_reuse, link) {
+ debug_ei("Checking if we can re-use %s\n", xwl_ei_client->cmdline);
+ if (xwl_ei_client->cmdline &&
+ strcmp(xwl_ei_client->cmdline, cmdname) == 0) {
+ debug_ei("Re-using client for %s\n", cmdname);
+ xorg_list_del(&xwl_ei_client->link);
+ xorg_list_init(&xwl_ei_client->link);
+ TimerCancel(xwl_ei_client->disconnect_timer);
+ xwl_ei_start_emulating(xwl_ei_client);
+ return xwl_ei_client;
+ }
+ }
+
+ return NULL;
+}
+
+static void
+xwayland_xtest_fallback(DeviceIntPtr dev,
+ int type, int detail, int flags, const ValuatorMask *mask)
+{
+ struct xwl_device_data *xwl_device_data = xwl_device_data_get(dev);
+
+ if (xwl_device_data->sendEventsProc != NULL) {
+ debug_ei("EI failed, using XTEST as fallback for sending events\n");
+ (xwl_device_data->sendEventsProc)(dev, type, detail, flags, mask);
+ }
+}
+
+
+static void
+xwayland_xtest_send_events(DeviceIntPtr dev,
+ int type, int detail, int flags, const ValuatorMask *mask)
+{
+ ClientPtr client;
+ struct xwl_ei_client *xwl_ei_client;
+ bool accept = false;
+
+ if (!IsXTestDevice(dev, NULL))
+ return;
+
+ client = GetCurrentClient();
+ xwl_ei_client = get_xwl_ei_client(client);
+ if (!xwl_ei_client) {
+ xwl_ei_client = reuse_client(client);
+ if (xwl_ei_client)
+ xwl_ei_client->client = client;
+ }
+
+ if (!xwl_ei_client) {
+ if (!(xwl_ei_client = setup_ei(client))) {
+ xwayland_xtest_fallback(dev, type, detail, flags, mask);
+ return;
+ }
+ }
+ dixSetPrivate(&client->devPrivates, &xwl_ei_private_key, xwl_ei_client);
+
+ switch (type) {
+ case MotionNotify:
+ if (flags & POINTER_ABSOLUTE)
+ accept = xwl_ei_client->accept_abs;
+ else
+ accept = xwl_ei_client->accept_pointer;
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ accept = xwl_ei_client->accept_pointer;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ accept = xwl_ei_client->accept_keyboard;
+ break;
+ default:
+ return;
+ }
+
+ if (accept) {
+ xwl_send_event_to_ei(xwl_ei_client, type, detail, flags, mask);
+ }
+ else {
+ debug_ei("Not yet connected to EIS, queueing events\n");
+ xwl_queue_emulated_event(xwl_ei_client, dev, type, detail, flags, mask);
+ }
+
+}
+
+static bool
+xwl_dequeue_emulated_events(struct xwl_ei_client *xwl_ei_client)
+{
+ struct xwl_emulated_event *xwl_emulated_event, *next_xwl_emulated_event;
+ bool sent;
+
+ xorg_list_for_each_entry_safe(xwl_emulated_event, next_xwl_emulated_event,
+ &xwl_ei_client->pending_emulated_events, link) {
+ sent = xwl_send_event_to_ei(xwl_ei_client,
+ xwl_emulated_event->type,
+ xwl_emulated_event->detail,
+ xwl_emulated_event->flags,
+ &xwl_emulated_event->mask);
+ if (!sent)
+ xwayland_xtest_fallback(xwl_emulated_event->dev,
+ xwl_emulated_event->type,
+ xwl_emulated_event->detail,
+ xwl_emulated_event->flags,
+ &xwl_emulated_event->mask);
+
+ xorg_list_del(&xwl_emulated_event->link);
+ free(xwl_emulated_event);
+ }
+ return true;
+}
+
+static void
+xwl_handle_ei_event(int fd, int ready, void *data)
+{
+ struct xwl_ei_client *xwl_ei_client = data;
+ struct ei *ei;
+ bool done = false;
+
+ ei = xwl_ei_client->ei;
+
+ ei_dispatch(ei);
+ do {
+ enum ei_event_type type;
+ struct ei_event *e = ei_get_event(ei);
+ struct ei_device *ei_device;
+
+ if (!e)
+ break;
+
+ ei_device = ei_event_get_device(e);
+ type = ei_event_get_type(e);
+ switch (type) {
+ case EI_EVENT_CONNECT:
+ debug_ei("Connected\n");
+ break;
+ case EI_EVENT_SEAT_ADDED:
+ /* We take the first seat that comes along and
+ * add our device there */
+ if (!xwl_ei_client->ei_seat) {
+ struct ei_seat *seat = ei_event_get_seat(e);
+
+ xwl_ei_client->ei_seat = ei_seat_ref(seat);
+ debug_ei("Using seat: %s (caps: %s%s%s%s%s)\n",
+ ei_seat_get_name(seat), ei_seat_has_capability(seat,
+ EI_DEVICE_CAP_KEYBOARD) ? "k" : "",
+ ei_seat_has_capability(seat,
+ EI_DEVICE_CAP_POINTER) ? "p" : "",
+ ei_seat_has_capability(seat,
+ EI_DEVICE_CAP_POINTER_ABSOLUTE) ? "a" : "",
+ ei_seat_has_capability(seat,
+ EI_DEVICE_CAP_BUTTON) ? "b" : "",
+ ei_seat_has_capability(seat,
+ EI_DEVICE_CAP_SCROLL) ? "s" : "");
+ ei_seat_bind_capabilities(seat,
+ EI_DEVICE_CAP_POINTER,
+ EI_DEVICE_CAP_POINTER_ABSOLUTE,
+ EI_DEVICE_CAP_BUTTON,
+ EI_DEVICE_CAP_SCROLL,
+ EI_DEVICE_CAP_KEYBOARD, NULL);
+ }
+ break;
+ case EI_EVENT_SEAT_REMOVED:
+ if (ei_event_get_seat(e) == xwl_ei_client->ei_seat) {
+ debug_ei("Seat was removed\n");
+ xwl_ei_client->ei_seat =
+ ei_seat_unref(xwl_ei_client->ei_seat);
+ }
+ break;
+ case EI_EVENT_DEVICE_ADDED:
+ debug_ei("New device: %s\n", ei_device_get_name(ei_device));
+ add_ei_device(xwl_ei_client, ei_device);
+ break;
+ case EI_EVENT_DEVICE_REMOVED:
+ debug_ei("Device removed: %s\n", ei_device_get_name(ei_device));
+ {
+ struct xwl_abs_device *abs, *tmp;
+
+ xorg_list_for_each_entry_safe(abs, tmp,
+ &xwl_ei_client->abs_devices, link) {
+ if (abs->device != ei_device)
+ continue;
+ ei_device_unref(abs->device);
+ xorg_list_del(&abs->link);
+ free(abs);
+ }
+ }
+ if (xwl_ei_client->ei_pointer == ei_device)
+ xwl_ei_client->ei_pointer =
+ ei_device_unref(xwl_ei_client->ei_pointer);
+ if (xwl_ei_client->ei_keyboard == ei_device)
+ xwl_ei_client->ei_keyboard =
+ ei_device_unref(xwl_ei_client->ei_keyboard);
+ break;
+ case EI_EVENT_DISCONNECT:
+ debug_ei("Disconnected\n");
+ free_ei(xwl_ei_client);
+ done = true;
+ break;
+ case EI_EVENT_DEVICE_PAUSED:
+ debug_ei("Device paused\n");
+ if (ei_device == xwl_ei_client->ei_pointer)
+ xwl_ei_client->accept_pointer = false;
+ if (ei_device == xwl_ei_client->ei_keyboard)
+ xwl_ei_client->accept_keyboard = false;
+ {
+ struct xwl_abs_device *abs;
+
+ xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices,
+ link) {
+ if (ei_device == abs->device)
+ xwl_ei_client->accept_abs = false;
+ }
+ }
+ break;
+ case EI_EVENT_DEVICE_RESUMED:
+ debug_ei("Device resumed\n");
+ if (ei_device == xwl_ei_client->ei_pointer)
+ xwl_ei_client->accept_pointer = true;
+ if (ei_device == xwl_ei_client->ei_keyboard)
+ xwl_ei_client->accept_keyboard = true;
+ {
+ struct xwl_abs_device *abs;
+
+ xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices,
+ link) {
+ if (ei_device == abs->device)
+ xwl_ei_client->accept_abs = true;
+ }
+ }
+
+ /* Server has accepted our device (or resumed them),
+ * we can now start sending events */
+ /* FIXME: Maybe add a timestamp and discard old events? */
+ xwl_ei_start_emulating(xwl_ei_client);
+ xwl_dequeue_emulated_events(xwl_ei_client);
+ if (!xwl_ei_client->client &&
+ xorg_list_is_empty(&xwl_ei_client->pending_emulated_events))
+ /* All events dequeued and client has disconnected in the meantime */
+ xwl_ei_stop_emulating(xwl_ei_client);
+ break;
+ default:
+ error_ei("Unhandled event %d\n", type);
+ break;
+ }
+ ei_event_unref(e);
+ } while (!done);
+}
+
+Bool
+xwayland_ei_init(void)
+{
+ xorg_list_init(&clients_for_reuse);
+
+ if (!dixRegisterPrivateKey(&xwl_ei_private_key, PRIVATE_CLIENT, 0)) {
+ ErrorF("Failed to register EI private key\n");
+ return FALSE;
+ }
+
+ if (!AddCallback(&ClientStateCallback, xwl_ei_state_client_callback, NULL)) {
+ ErrorF("Failed to add client state callback\n");
+ return FALSE;
+ }
+
+ if (!dixRegisterPrivateKey(&xwl_device_data_private_key, PRIVATE_DEVICE,
+ sizeof(struct xwl_device_data))) {
+ ErrorF("Failed to register private key for XTEST override\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+xwayland_override_events_proc(DeviceIntPtr dev)
+{
+ struct xwl_device_data *xwl_device_data = xwl_device_data_get(dev);
+
+ if (xwl_device_data->sendEventsProc != NULL)
+ return;
+
+ /* Save original sendEventsProc handler in case */
+ xwl_device_data->sendEventsProc = dev->sendEventsProc;
+
+ /* Set up our own sendEventsProc to forward events to EI */
+ debug_ei("Overriding XTEST for %s\n", dev->name);
+ dev->sendEventsProc = xwayland_xtest_send_events;
+}
+
+static void
+xwayland_restore_events_proc(DeviceIntPtr dev)
+{
+ struct xwl_device_data *xwl_device_data = xwl_device_data_get(dev);
+
+ if (xwl_device_data->sendEventsProc == NULL)
+ return;
+
+ /* Restore original sendEventsProc handler */
+ debug_ei("Restoring XTEST for %s\n", dev->name);
+ dev->sendEventsProc = xwl_device_data->sendEventsProc;
+ xwl_device_data->sendEventsProc = NULL;
+}
+
+void
+xwayland_override_xtest(void)
+{
+ DeviceIntPtr d;
+
+ nt_list_for_each_entry(d, inputInfo.devices, next) {
+ xwayland_override_events_proc(d);
+ }
+}
+
+void
+xwayland_restore_xtest(void)
+{
+ DeviceIntPtr d;
+
+ nt_list_for_each_entry(d, inputInfo.devices, next) {
+ xwayland_restore_events_proc(d);
+ }
+}
diff --git a/hw/xwayland/xwayland-xtest.h b/hw/xwayland/xwayland-xtest.h
new file mode 100644
index 000000000..996fdcc27
--- /dev/null
+++ b/hw/xwayland/xwayland-xtest.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2020 Red Hat
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef XWAYLAND_XTEST_H
+#define XWAYLAND_XTEST_H
+
+#include <xwayland-config.h>
+
+Bool xwayland_ei_init(void);
+void xwayland_override_xtest(void);
+void xwayland_restore_xtest(void);
+
+#endif
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 6cc5f8e0f..499c2cc1f 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -33,6 +33,12 @@
#include <errno.h>
#include <X11/Xatom.h>
+
+#include "dix/dix_priv.h"
+#include "dix/screenint_priv.h"
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include <selection.h>
#include <micmap.h>
#include <misyncshm.h>
@@ -45,6 +51,8 @@
#include <propertyst.h>
#include <version-config.h>
+#include "os/auth.h"
+
#include "xwayland-screen.h"
#include "xwayland-vidmode.h"
@@ -91,18 +99,30 @@ void
ddxUseMsg(void)
{
ErrorF("-rootless run rootless, requires wm support\n");
+ ErrorF("-fullscreen run fullscreen when rootful\n");
+ ErrorF("-geometry WxH set Xwayland window size when rootful\n");
+ ErrorF("-hidpi adjust to output scale when rootful\n");
+ ErrorF("-host-grab disable host keyboard shortcuts when rootful\n");
+ ErrorF("-nokeymap ignore keymap from the Wayland compositor\n");
+ ErrorF("-output specify which output to use for fullscreen when rootful\n");
ErrorF("-wm fd create X client for wm on given fd\n");
ErrorF("-initfd fd add given fd as a listen socket for initialization clients\n");
ErrorF("-listenfd fd add given fd as a listen socket\n");
ErrorF("-listen fd deprecated, use \"-listenfd\" instead\n");
-#ifdef XWL_HAS_EGLSTREAM
- ErrorF("-eglstream use eglstream backend for nvidia GPUs\n");
-#endif
ErrorF("-shm use shared memory for passing buffers\n");
+#ifdef XWL_HAS_GLAMOR
+ ErrorF("-glamor [gl|es|off] use given API for Glamor acceleration. Incompatible with -shm option\n");
+#endif
ErrorF("-verbose [n] verbose startup messages\n");
ErrorF("-version show the server version and exit\n");
ErrorF("-noTouchPointerEmulation disable touch pointer emulation\n");
ErrorF("-force-xrandr-emulation force non-native modes to be exposed when viewporter is not exposed by the compositor\n");
+#ifdef XWL_HAS_LIBDECOR
+ ErrorF("-decorate add decorations to Xwayland when rootful\n");
+#endif
+#ifdef XWL_HAS_EI_PORTAL
+ ErrorF("-enable-ei-portal use the XDG portal for input emulation\n");
+#endif
}
static int init_fd = -1;
@@ -144,9 +164,9 @@ try_raising_nofile_limit(void)
return;
}
- LogMessageVerb(X_INFO, 3, "Raising the file descriptors limit to %li\n",
- rlim.rlim_max);
-#endif
+ LogMessageVerb(X_INFO, 3, "Raising the file descriptors limit to %llu\n",
+ (long long unsigned int) rlim.rlim_max);
+#endif /* RLIMIT_NOFILE */
}
static void
@@ -198,6 +218,13 @@ ddxProcessArgument(int argc, char *argv[], int i)
else if (strcmp(argv[i], "-shm") == 0) {
return 1;
}
+#ifdef XWL_HAS_GLAMOR
+ else if (strcmp(argv[i], "-glamor") == 0) {
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
+ /* Only check here, actual work inside xwayland-screen.c */
+ return 2;
+ }
+#endif
else if (strcmp(argv[i], "-verbose") == 0) {
if (++i < argc && argv[i]) {
char *end;
@@ -213,9 +240,6 @@ ddxProcessArgument(int argc, char *argv[], int i)
LogSetParameter(XLOG_VERBOSITY, ++verbosity);
return 1;
}
- else if (strcmp(argv[i], "-eglstream") == 0) {
- return 1;
- }
else if (strcmp(argv[i], "-version") == 0) {
xwl_show_version();
exit(0);
@@ -224,6 +248,35 @@ ddxProcessArgument(int argc, char *argv[], int i)
touchEmulatePointer = FALSE;
return 1;
}
+ else if (strcmp(argv[i], "-force-xrandr-emulation") == 0) {
+ return 1;
+ }
+ else if (strcmp(argv[i], "-geometry") == 0) {
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
+ return 2;
+ }
+ else if (strcmp(argv[i], "-fullscreen") == 0) {
+ return 1;
+ }
+ else if (strcmp(argv[i], "-host-grab") == 0) {
+ return 1;
+ }
+ else if (strcmp(argv[i], "-decorate") == 0) {
+ return 1;
+ }
+ else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
+ return 1;
+ }
+ else if (strcmp(argv[i], "-output") == 0) {
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
+ return 2;
+ }
+ else if (strcmp(argv[i], "-nokeymap") == 0) {
+ return 1;
+ }
+ else if (strcmp(argv[i], "-hidpi") == 0) {
+ return 1;
+ }
return 0;
}
@@ -267,20 +320,113 @@ wm_selection_callback(CallbackListPtr *p, void *data, void *arg)
DeleteCallback(&SelectionCallback, wm_selection_callback, xwl_screen);
}
-_X_NORETURN
static void _X_ATTRIBUTE_PRINTF(1, 0)
xwl_log_handler(const char *format, va_list args)
{
char msg[256];
vsnprintf(msg, sizeof msg, format, args);
- FatalError("%s", msg);
+ ErrorF("XWAYLAND: %s", msg);
+}
+
+#ifdef XWL_HAS_XWAYLAND_EXTENSION
+#include <X11/extensions/xwaylandproto.h>
+
+Bool noXwaylandExtension = FALSE;
+
+static int
+ProcXwlQueryVersion(ClientPtr client)
+{
+ xXwlQueryVersionReply reply;
+ int major, minor;
+
+ REQUEST(xXwlQueryVersionReq);
+ REQUEST_SIZE_MATCH(xXwlQueryVersionReq);
+
+ if (version_compare(stuff->majorVersion, stuff->minorVersion,
+ XWAYLAND_EXTENSION_MAJOR,
+ XWAYLAND_EXTENSION_MINOR) < 0) {
+ major = stuff->majorVersion;
+ minor = stuff->minorVersion;
+ } else {
+ major = XWAYLAND_EXTENSION_MAJOR;
+ minor = XWAYLAND_EXTENSION_MINOR;
+ }
+
+ reply = (xXwlQueryVersionReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = major,
+ .minorVersion = minor,
+ };
+
+ if (client->swapped) {
+ swaps(&reply.sequenceNumber);
+ swapl(&reply.length);
+ swaps(&reply.majorVersion);
+ swaps(&reply.minorVersion);
+ }
+
+ WriteReplyToClient(client, sizeof(reply), &reply);
+ return Success;
+}
+
+static int _X_COLD
+SProcXwlQueryVersion(ClientPtr client)
+{
+ REQUEST(xXwlQueryVersionReq);
+
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXwlQueryVersionReq);
+ swaps(&stuff->majorVersion);
+ swaps(&stuff->minorVersion);
+
+ return ProcXwlQueryVersion(client);
+}
+
+static int
+ProcXwaylandDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_XwlQueryVersion:
+ return ProcXwlQueryVersion(client);
+ }
+ return BadRequest;
+}
+
+static int
+SProcXwaylandDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_XwlQueryVersion:
+ return SProcXwlQueryVersion(client);
+ }
+ return BadRequest;
+}
+
+static void
+xwlExtensionInit(void)
+{
+ AddExtension(XWAYLAND_EXTENSION_NAME,
+ XwlNumberEvents, XwlNumberErrors,
+ ProcXwaylandDispatch, SProcXwaylandDispatch,
+ NULL, StandardMinorOpcode);
}
+#endif
+
static const ExtensionModule xwayland_extensions[] = {
#ifdef XF86VIDMODE
{ xwlVidModeExtensionInit, XF86VIDMODENAME, &noXFree86VidModeExtension },
#endif
+#ifdef XWL_HAS_XWAYLAND_EXTENSION
+ { xwlExtensionInit, XWAYLAND_EXTENSION_NAME, &noXwaylandExtension },
+#endif
};
void
diff --git a/hw/xwayland/xwayland.pc.in b/hw/xwayland/xwayland.pc.in
deleted file mode 100644
index e2c06b801..000000000
--- a/hw/xwayland/xwayland.pc.in
+++ /dev/null
@@ -1,15 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-
-Name: Xwayland
-Description: X Server for Wayland
-Version: @PACKAGE_VERSION@
-xwayland=@xwayland_path@/Xwayland
-have_glamor=@have_glamor@
-have_eglstream=@have_eglstream@
-have_initfd=true
-have_listenfd=true
-have_verbose=true
-have_terminate_delay=true
-have_no_touch_pointer_emulation=true
-have_force_xrandr_emulation=true
diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c
index 04cd514ab..1b7068dba 100644
--- a/hw/xwin/InitInput.c
+++ b/hw/xwin/InitInput.c
@@ -88,7 +88,7 @@ xwinDevWindowsHandlerNotify(int fd, int ready, void *data)
void
InitInput(int argc, char *argv[])
{
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("InitInput\n");
#endif
@@ -126,7 +126,7 @@ InitInput(int argc, char *argv[])
}
#endif
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("InitInput - returning\n");
#endif
}
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 7a03bfb91..bc4293d0f 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -31,6 +31,9 @@ from The Open Group.
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
+
+#include "os/osdep.h"
+
#include "win.h"
#include "winmsg.h"
#include "winconfig.h"
@@ -56,6 +59,9 @@ typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner,
DWORD dwFlags, LPTSTR pszPath);
#endif
+#include "dix/screenint_priv.h"
+#include "os/osdep.h"
+
#include "winmonitors.h"
#include "nonsdk_extinit.h"
#include "pseudoramiX/pseudoramiX.h"
@@ -111,7 +117,11 @@ static PixmapFormatRec g_PixmapFormats[] = {
{32, 32, BITMAP_SCANLINE_PAD}
};
+#ifdef GLXEXT
+#ifdef XWIN_WINDOWS_DRI
static Bool noDriExtension;
+#endif
+#endif
static const ExtensionModule xwinExtensions[] = {
#ifdef GLXEXT
@@ -187,7 +197,7 @@ ddxGiveUp(enum ExitCode error)
{
int i;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("ddxGiveUp\n");
#endif
@@ -573,9 +583,9 @@ winFixupPaths(void)
putenv(buffer);
}
if (getenv("HOME") == NULL) {
- char buffer[MAX_PATH + 5];
+ char buffer[MAX_PATH + 5] = {0};
- strncpy(buffer, "HOME=", 5);
+ strncpy(buffer, "HOME=", 6);
/* query appdata directory */
if (SHGetFolderPathA
@@ -619,10 +629,8 @@ OsVendorInit(void)
winFixupPaths();
-#ifdef DDXOSVERRORF
if (!OsVendorVErrorFProc)
OsVendorVErrorFProc = OsVendorVErrorF;
-#endif
if (!g_fLogInited) {
/* keep this order. If LogInit fails it calls Abort which then calls
@@ -902,7 +910,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
/* Log the command line */
winLogCommandLine(argc, argv);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("InitOutput\n");
#endif
@@ -1020,7 +1028,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
winGenerateAuthorization();
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("InitOutput - Returning.\n");
#endif
}
diff --git a/hw/xwin/glx/meson.build b/hw/xwin/glx/meson.build
index 95f248953..70f426ff1 100644
--- a/hw/xwin/glx/meson.build
+++ b/hw/xwin/glx/meson.build
@@ -2,11 +2,11 @@ python3 = import('python3')
# XWin requires OpenGL spec files in order to generate wrapper code for native GL functions
py3 = python3.find_python()
-if run_command(py3, '-c', 'import lxml;').returncode() != 0
+if run_command(py3, '-c', 'import lxml;', check: false).returncode() != 0
error('python3 lxml module not found')
endif
-khronos_spec_dir = dependency('khronos-opengl-registry').get_pkgconfig_variable('specdir')
+khronos_spec_dir = dependency('khronos-opengl-registry').get_variable(pkgconfig : 'specdir')
gen_gl_wrappers_opts= ['-nodebug']
gen_gl_wrappers_cmd = ['env', 'PYTHONPATH=' + khronos_spec_dir, py3, files('./gen_gl_wrappers.py'), gen_gl_wrappers_opts]
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 48795a8b5..1c4af37e1 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -48,8 +48,8 @@
#endif
/* Turn debug messages on or off */
-#ifndef CYGDEBUG
-#define CYGDEBUG NO
+#ifndef ENABLE_DEBUG
+#define ENABLE_DEBUG NO
#endif
#define WIN_DEFAULT_BPP 0
@@ -193,7 +193,7 @@
* Debugging macros
*/
-#if CYGDEBUG
+#if ENABLE_DEBUG
#define DEBUG_MSG(str,...) \
if (fDebugProcMsg) \
{ \
@@ -208,19 +208,19 @@ if (fDebugProcMsg) \
#define DEBUG_MSG(str,...)
#endif
-#if CYGDEBUG
+#if ENABLE_DEBUG
#define DEBUG_FN_NAME(str) PTSTR szFunctionName = str
#else
#define DEBUG_FN_NAME(str)
#endif
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
#define DEBUGVARS BOOL fDebugProcMsg = FALSE
#else
#define DEBUGVARS
#endif
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
#define DEBUGPROC_MSG fDebugProcMsg = TRUE
#else
#define DEBUGPROC_MSG
@@ -740,11 +740,9 @@ void
* winerror.c
*/
-#ifdef DDXOSVERRORF
void
OsVendorVErrorF(const char *pszFormat, va_list va_args)
_X_ATTRIBUTE_PRINTF(1, 0);
-#endif
void
winMessageBoxF(const char *pszError, UINT uType, ...)
@@ -1038,6 +1036,9 @@ winCreateMsgWindowThread(void);
void
winOS(void);
+Bool
+winValidateArgs(void);
+
/*
* END DDX and DIX Function Prototypes
*/
diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c
index 818805cb1..1212cbba9 100644
--- a/hw/xwin/winallpriv.c
+++ b/hw/xwin/winallpriv.c
@@ -47,7 +47,7 @@ winAllocatePrivates(ScreenPtr pScreen)
{
winPrivScreenPtr pScreenPriv;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateScreenPrivates - g_ulServerGeneration: %lu "
"serverGeneration: %lu\n", g_ulServerGeneration, serverGeneration);
#endif
@@ -58,15 +58,12 @@ winAllocatePrivates(ScreenPtr pScreen)
}
/* Allocate memory for the screen private structure */
- pScreenPriv = malloc(sizeof(winPrivScreenRec));
+ pScreenPriv = calloc(sizeof(winPrivScreenRec), 1);
if (!pScreenPriv) {
ErrorF("winAllocateScreenPrivates - malloc () failed\n");
return FALSE;
}
- /* Initialize the memory of the private structure */
- ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec));
-
/* Initialize private structure members */
pScreenPriv->fActive = TRUE;
@@ -105,7 +102,7 @@ winAllocatePrivates(ScreenPtr pScreen)
Bool
winInitCmapPrivates(ColormapPtr pcmap, int i)
{
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winInitCmapPrivates\n");
#endif
@@ -132,7 +129,7 @@ winAllocateCmapPrivates(ColormapPtr pCmap)
winPrivCmapPtr pCmapPriv;
static unsigned long s_ulPrivateGeneration = 0;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateCmapPrivates\n");
#endif
@@ -143,15 +140,12 @@ winAllocateCmapPrivates(ColormapPtr pCmap)
}
/* Allocate memory for our private structure */
- pCmapPriv = malloc(sizeof(winPrivCmapRec));
+ pCmapPriv = calloc(sizeof(winPrivCmapRec), 1);
if (!pCmapPriv) {
ErrorF("winAllocateCmapPrivates - malloc () failed\n");
return FALSE;
}
- /* Initialize the memory of the private structure */
- ZeroMemory(pCmapPriv, sizeof(winPrivCmapRec));
-
/* Register our colourmap private */
if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0)) {
ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
@@ -161,7 +155,7 @@ winAllocateCmapPrivates(ColormapPtr pCmap)
/* Save the cmap private pointer */
winSetCmapPriv(pCmap, pCmapPriv);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateCmapPrivates - Returning\n");
#endif
diff --git a/hw/xwin/winauth.c b/hw/xwin/winauth.c
index 4e1b26d13..5bc5a7316 100644
--- a/hw/xwin/winauth.c
+++ b/hw/xwin/winauth.c
@@ -38,6 +38,7 @@
/* Includes for authorization */
#include "securitysrv.h"
#include "os/osdep.h"
+#include "os/mitauth.h"
#include <xcb/xcb.h>
@@ -61,7 +62,7 @@ static xcb_auth_info_t auth_info;
*/
#ifndef XCSECURITY
-static XID
+XID
GenerateAuthorization(unsigned name_length,
const char *name,
unsigned data_length,
diff --git a/hw/xwin/winclipboard/debug.c b/hw/xwin/winclipboard/debug.c
index 78ab6d902..ef8adc11f 100644
--- a/hw/xwin/winclipboard/debug.c
+++ b/hw/xwin/winclipboard/debug.c
@@ -26,27 +26,21 @@
#include <stdarg.h>
#include <stdio.h>
-#if 1
-int
-winDebug(const char *format, ...)
+#include "internal.h"
+
+void winDebug(const char *format, ...)
{
- int count;
va_list ap;
va_start(ap, format);
- count = fprintf(stderr, "xwinclip: ");
- count += vfprintf(stderr, format, ap);
+ fprintf(stderr, "xwinclip: ");
+ vfprintf(stderr, format, ap);
va_end(ap);
- return count;
}
-#endif
-int
-ErrorF(const char *format, ...)
+void ErrorF(const char *format, ...)
{
- int count;
va_list ap;
va_start(ap, format);
- count = vfprintf(stderr, format, ap);
+ vfprintf(stderr, format, ap);
va_end(ap);
- return count;
}
diff --git a/hw/xwin/wincmap.c b/hw/xwin/wincmap.c
index 000334ce3..df69ba78b 100644
--- a/hw/xwin/wincmap.c
+++ b/hw/xwin/wincmap.c
@@ -116,13 +116,13 @@ winInstallColormap(ColormapPtr pColormap)
winScreenPriv(pScreen);
ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winInstallColormap\n");
#endif
/* Did the colormap actually change? */
if (pColormap != oldpmap) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winInstallColormap - Colormap has changed, attempt "
"to install.\n");
#endif
@@ -157,7 +157,7 @@ winUninstallColormap(ColormapPtr pmap)
winScreenPriv(pmap->pScreen);
ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winUninstallColormap\n");
#endif
@@ -178,7 +178,7 @@ winUninstallColormap(ColormapPtr pmap)
/* Install the default cmap in place of the cmap to be uninstalled */
if (pmap->mid != pmap->pScreen->defColormap) {
dixLookupResourceByType((void *) &curpmap, pmap->pScreen->defColormap,
- RT_COLORMAP, NullClient, DixUnknownAccess);
+ X11_RESTYPE_COLORMAP, NullClient, DixUnknownAccess);
(*pmap->pScreen->InstallColormap) (curpmap);
}
}
@@ -194,7 +194,7 @@ winStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
int i;
unsigned short nRed, nGreen, nBlue;
-#if CYGDEBUG
+#if ENABLE_DEBUG
if (ndef != 1)
winDebug("winStoreColors - ndef: %d\n", ndef);
#endif
@@ -216,7 +216,7 @@ winStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winStoreColors - nRed %d nGreen %d nBlue %d\n",
nRed, nGreen, nBlue);
#endif
@@ -237,7 +237,7 @@ winResolveColor(unsigned short *pred,
unsigned short *pgreen,
unsigned short *pblue, VisualPtr pVisual)
{
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winResolveColor ()\n");
#endif
@@ -253,7 +253,7 @@ winCreateColormap(ColormapPtr pmap)
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateColormap\n");
#endif
@@ -311,7 +311,7 @@ winDestroyColormap(ColormapPtr pColormap)
free(pCmapPriv);
winSetCmapPriv(pColormap, NULL);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winDestroyColormap - Returning\n");
#endif
}
@@ -338,7 +338,7 @@ winGetPaletteDIB(ScreenPtr pScreen, ColormapPtr pcmap)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winGetPaletteDIB - Retrieved %d colors from DIB\n",
uiColorsRetrieved);
#endif
@@ -359,7 +359,7 @@ winGetPaletteDIB(ScreenPtr pScreen, ColormapPtr pcmap)
nGreen = rgbColors[i].rgbGreen << 8;
nBlue = rgbColors[i].rgbBlue << 8;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winGetPaletteDIB - Allocating a color: %u; "
"%d %d %d\n", (unsigned int)pixel, nRed, nGreen, nBlue);
#endif
@@ -421,7 +421,7 @@ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winGetPaletteDD - uiSystemPaletteEntries %d\n",
uiSystemPaletteEntries);
#endif
@@ -444,7 +444,7 @@ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
nRed = ppeColors[i].peRed << 8;
nGreen = ppeColors[i].peGreen << 8;
nBlue = ppeColors[i].peBlue << 8;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winGetPaletteDD - Allocating a color: %u; "
"%d %d %d\n", (unsigned int)pixel, nRed, nGreen, nBlue);
#endif
@@ -493,7 +493,7 @@ winCreateDefColormap(ScreenPtr pScreen)
ColormapPtr pcmap = NULL;
Pixel wp, bp;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateDefColormap\n");
#endif
@@ -514,7 +514,7 @@ winCreateDefColormap(ScreenPtr pScreen)
* to be changed by clients.
*/
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateDefColormap - defColormap: %lu\n", pScreen->defColormap);
#endif
@@ -533,7 +533,7 @@ winCreateDefColormap(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateDefColormap - Created a colormap\n");
#endif
@@ -594,7 +594,7 @@ winCreateDefColormap(ScreenPtr pScreen)
/* Install the created colormap */
(*pScreen->InstallColormap) (pcmap);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateDefColormap - Returning\n");
#endif
diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c
index 444e843ec..e3238ae76 100644
--- a/hw/xwin/wincreatewnd.c
+++ b/hw/xwin/wincreatewnd.c
@@ -61,7 +61,7 @@ winCreateBoundingWindowFullScreen(ScreenPtr pScreen)
WNDCLASSEX wc;
char szTitle[256];
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateBoundingWindowFullScreen\n");
#endif
@@ -210,7 +210,7 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
/* Did the user specify a height and width? */
if (pScreenInfo->fUserGaveHeightAndWidth) {
/* User gave a desired height and width, try to accommodate */
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateBoundingWindowWindowed - User gave height "
"and width\n");
#endif
@@ -220,14 +220,14 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
&& !pScreenInfo->fRootless
&& !pScreenInfo->fMultiWindow
) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug
("winCreateBoundingWindowWindowed - Window has decoration\n");
#endif
/* Are we resizable */
if (pScreenInfo->iResizeMode != resizeNotAllowed) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug
("winCreateBoundingWindowWindowed - Window is resizable\n");
#endif
@@ -237,7 +237,7 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
+ GetSystemMetrics(SM_CYCAPTION);
}
else {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug
("winCreateBoundingWindowWindowed - Window is not resizable\n");
#endif
@@ -250,7 +250,7 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
}
else {
/* By default, we are creating a window that is as large as possible */
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateBoundingWindowWindowed - User did not give "
"height and width\n");
#endif
@@ -273,7 +273,7 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
iHeight = rcWorkArea.bottom - rcWorkArea.top;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateBoundingWindowWindowed - Adjusted width: %d "
"height: %d\n", iWidth, iHeight);
#endif
@@ -307,7 +307,7 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n");
#endif
@@ -512,14 +512,12 @@ winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
static Bool
winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
{
- APPBARDATA abd;
- HWND hwndAutoHide;
+ APPBARDATA abd = (APPBARDATA) {
+ .cbSize = sizeof(APPBARDATA),
+ .uEdge = uEdge
+ };
- ZeroMemory(&abd, sizeof(abd));
- abd.cbSize = sizeof(abd);
- abd.uEdge = uEdge;
-
- hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
+ HWND hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
if (hwndAutoHide != NULL) {
/*
Found an autohide taskbar on that edge, but is it on the
@@ -541,15 +539,15 @@ winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
static Bool
winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
{
- APPBARDATA abd;
+ APPBARDATA abd = (APPBARDATA) {
+ .cbSize = sizeof(APPBARDATA)
+ };
winDebug("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
(int) prcWorkArea->top, (int) prcWorkArea->left,
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
/* Find out if the Windows taskbar is set to auto-hide */
- ZeroMemory(&abd, sizeof(abd));
- abd.cbSize = sizeof(abd);
if (SHAppBarMessage(ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
winDebug("winAdjustForAutoHide - Taskbar is auto hide\n");
diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index 26b2ebd2c..91222f5a2 100644
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -413,14 +413,14 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
static winPrivScreenPtr s_pScreenPriv = NULL;
static winScreenInfo *s_pScreenInfo = NULL;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winChangeDepthDlgProc\n");
#endif
/* Branch on message type */
switch (message) {
case WM_INITDIALOG:
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winChangeDepthDlgProc - WM_INITDIALOG\n");
#endif
@@ -428,13 +428,13 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
s_pScreenPriv = (winPrivScreenPtr) lParam;
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %p, "
"s_pScreenInfo: %p\n",
s_pScreenPriv, s_pScreenInfo);
#endif
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %u, "
"current bpp: %d\n",
(unsigned int)s_pScreenInfo->dwBPP,
@@ -446,7 +446,7 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
return TRUE;
case WM_DISPLAYCHANGE:
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %u, "
"new bpp: %d\n",
(unsigned int)s_pScreenInfo->dwBPP,
@@ -542,14 +542,14 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam)
{
static winPrivScreenPtr s_pScreenPriv = NULL;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAboutDlgProc\n");
#endif
/* Branch on message type */
switch (message) {
case WM_INITDIALOG:
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAboutDlgProc - WM_INITDIALOG\n");
#endif
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index 784772f5f..ed505e47d 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -32,10 +32,11 @@
#include <xwin-config.h>
#endif
+#include "os/osdep.h"
+
#include <../xfree86/common/xorgVersion.h>
#include "win.h"
-#ifdef DDXOSVERRORF
void
OsVendorVErrorF(const char *pszFormat, va_list va_args)
{
@@ -52,7 +53,6 @@ OsVendorVErrorF(const char *pszFormat, va_list va_args)
/* Unlock the printing mutex */
pthread_mutex_unlock(&s_pmPrinting);
}
-#endif
/*
* os/log.c:FatalError () calls our vendor ErrorF, so the message
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index aad99d9ad..52166a850 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -231,7 +231,7 @@ winMouseButtonsSendEvent(int iEventType, int iButton)
QueuePointerEvents(g_pwinPointer, iEventType, iButton,
POINTER_RELATIVE, &mask);
-#if CYGDEBUG
+#if ENABLE_DEBUG
ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
iEventType, iButton);
#endif
diff --git a/hw/xwin/winmsg.c b/hw/xwin/winmsg.c
index 2ee48ce5a..8629875c3 100644
--- a/hw/xwin/winmsg.c
+++ b/hw/xwin/winmsg.c
@@ -33,7 +33,7 @@
#endif
#include "win.h"
#include "winmsg.h"
-#if CYGDEBUG
+#if ENABLE_DEBUG
#include "winmessages.h"
#endif
#include <stdarg.h>
@@ -117,7 +117,7 @@ winW32ErrorEx(int verb, const char *msg, DWORD errorcode)
}
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
void
winDebugWin32Message(const char *function, HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
diff --git a/hw/xwin/winmsgwindow.c b/hw/xwin/winmsgwindow.c
index f5649b722..8792d779c 100644
--- a/hw/xwin/winmsgwindow.c
+++ b/hw/xwin/winmsgwindow.c
@@ -41,7 +41,7 @@ static
LRESULT CALLBACK
winMsgWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebugWin32Message("winMsgWindowProc", hwnd, message, wParam, lParam);
#endif
@@ -153,7 +153,7 @@ winMsgWindowThreadProc(void *arg)
/* Pump the msg window message queue */
while (GetMessage(&msg, hwndMsg, 0, 0) > 0) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebugWin32Message("winMsgWindowThread", msg.hwnd, msg.message,
msg.wParam, msg.lParam);
#endif
diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index 0ef666d89..e5b09e48d 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -44,6 +44,8 @@
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_image.h>
+#include <winsock2.h>
+
#include "winresource.h"
#include "winprefs.h"
#include "winmsg.h"
diff --git a/hw/xwin/winmultiwindowshape.c b/hw/xwin/winmultiwindowshape.c
index 73afaea55..dba3202d2 100644
--- a/hw/xwin/winmultiwindowshape.c
+++ b/hw/xwin/winmultiwindowshape.c
@@ -46,7 +46,7 @@ winSetShapeMultiWindow(WindowPtr pWin, int kind)
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winSetShapeMultiWindow - pWin: %p kind: %i\n", pWin, kind);
#endif
@@ -89,7 +89,7 @@ winReshapeMultiWindow(WindowPtr pWin)
winWindowPriv(pWin);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winReshape ()\n");
#endif
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 5b9b74e3d..4aca28930 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -84,7 +84,7 @@ winInitMultiWindowClass(void)
wcx.lpszClassName = WINDOW_CLASS_X;
wcx.hIconSm = hIconSmall;
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X);
#endif
@@ -105,7 +105,7 @@ winCreateWindowMultiWindow(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
winTrace("winCreateWindowMultiWindow - pWin: %p\n", pWin);
#endif
@@ -138,7 +138,7 @@ winDestroyWindowMultiWindow(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winDestroyWindowMultiWindow - pWin: %p\n", pWin);
#endif
@@ -177,14 +177,14 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
RECT rcNew;
RECT rcOld;
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
RECT rcClient;
RECT *lpRc;
#endif
DWORD dwExStyle;
DWORD dwStyle;
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
winTrace("winPositionWindowMultiWindow - pWin: %p\n", pWin);
#endif
@@ -192,13 +192,13 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
fResult = (*pScreen->PositionWindow) (pWin, x, y);
WIN_WRAP(PositionWindow, winPositionWindowMultiWindow);
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n", x, y);
#endif
/* Bail out if the Windows window handle is bad */
if (!hWnd) {
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("\timmediately return since hWnd is NULL\n");
#endif
return fResult;
@@ -219,7 +219,7 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
/* Store the origin, height, and width in a rectangle structure */
SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
lpRc = &rcNew;
ErrorF("winPositionWindowMultiWindow - drawable (%d, %d)-(%d, %d)\n",
(int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom);
@@ -234,7 +234,7 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
/* Get a rectangle describing the old Windows window */
GetWindowRect(hWnd, &rcOld);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
/* Get a rectangle describing the Windows window client area */
GetClientRect(hWnd, &rcClient);
@@ -253,11 +253,11 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
/* Check if the old rectangle and new rectangle are the same */
if (!EqualRect(&rcNew, &rcOld)) {
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winPositionWindowMultiWindow - Need to move\n");
#endif
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("\tMoveWindow to (%d, %d) - %dx%d\n", (int)rcNew.left, (int)rcNew.top,
(int)(rcNew.right - rcNew.left), (int)(rcNew.bottom - rcNew.top));
#endif
@@ -267,7 +267,7 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, TRUE);
}
else {
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winPositionWindowMultiWindow - Not need to move\n");
#endif
}
@@ -287,7 +287,7 @@ winChangeWindowAttributesMultiWindow(WindowPtr pWin, unsigned long mask)
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winChangeWindowAttributesMultiWindow - pWin: %p\n", pWin);
#endif
@@ -316,7 +316,7 @@ winUnmapWindowMultiWindow(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winUnmapWindowMultiWindow - pWin: %p\n", pWin);
#endif
@@ -347,7 +347,7 @@ winMapWindowMultiWindow(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winMapWindowMultiWindow - pWin: %p\n", pWin);
#endif
@@ -411,7 +411,7 @@ winRestackWindowMultiWindow(WindowPtr pWin, WindowPtr pOldNextSib)
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG || ENABLE_DEBUG
winTrace("winRestackMultiWindow - %p\n", pWin);
#endif
@@ -676,7 +676,7 @@ winUpdateWindowsWindow(WindowPtr pWin)
winWindowPriv(pWin);
HWND hWnd = pWinPriv->hWnd;
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winUpdateWindowsWindow\n");
#endif
@@ -701,7 +701,7 @@ winUpdateWindowsWindow(WindowPtr pWin)
assert(pWinPriv->hWnd == NULL);
}
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("-winUpdateWindowsWindow\n");
#endif
}
@@ -717,9 +717,9 @@ winGetWindowID(WindowPtr pWin)
ClientPtr c = wClient(pWin);
/* */
- FindClientResourcesByType(c, RT_WINDOW, winFindWindow, &wi);
+ FindClientResourcesByType(c, X11_RESTYPE_WINDOW, winFindWindow, &wi);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winGetWindowID - Window ID: %u\n", (unsigned int)wi.id);
#endif
@@ -755,13 +755,13 @@ winReorderWindowsMultiWindow(void)
DWORD dwCurrentProcessID = GetCurrentProcessId();
DWORD dwWindowProcessID = 0;
-#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG || ENABLE_DEBUG
winTrace("winReorderWindowsMultiWindow\n");
#endif
if (fRestacking) {
/* It is a recursive call so immediately exit */
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("winReorderWindowsMultiWindow - "
"exit because fRestacking == TRUE\n");
#endif
@@ -809,7 +809,7 @@ winCopyWindowMultiWindow(WindowPtr pWin, DDXPointRec oldpt, RegionPtr oldRegion)
winScreenPriv(pScreen);
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("CopyWindowMultiWindow\n");
#endif
WIN_UNWRAP(CopyWindow);
@@ -828,7 +828,7 @@ winMoveWindowMultiWindow(WindowPtr pWin, int x, int y,
winScreenPriv(pScreen);
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("MoveWindowMultiWindow to (%d, %d)\n", x, y);
#endif
@@ -848,7 +848,7 @@ winResizeWindowMultiWindow(WindowPtr pWin, int x, int y, unsigned int w,
winScreenPriv(pScreen);
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h);
#endif
WIN_UNWRAP(ResizeWindow);
@@ -879,12 +879,12 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
#define WIDTH(rc) (rc.right - rc.left)
#define HEIGHT(rc) (rc.bottom - rc.top)
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("winAdjustXWindow\n");
#endif
if (IsIconic(hwnd)) {
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("\timmediately return because the window is iconized\n");
#endif
/*
@@ -902,21 +902,21 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
x = pDraw->x + GetSystemMetrics(SM_XVIRTUALSCREEN);
y = pDraw->y + GetSystemMetrics(SM_YVIRTUALSCREEN);
SetRect(&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
-#ifdef CYGMULTIWINDOW_DEBUG
+#ifdef ENABLE_DEBUG
winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
(int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom,
(int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top));
#endif
dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
-#ifdef CYGMULTIWINDOW_DEBUG
+#ifdef ENABLE_DEBUG
winDebug("\tWindowStyle: %08x %08x\n", (unsigned int)dwStyle, (unsigned int)dwExStyle);
#endif
AdjustWindowRectEx(&rcDraw, dwStyle, FALSE, dwExStyle);
/* The source of adjust */
GetWindowRect(hwnd, &rcWin);
-#ifdef CYGMULTIWINDOW_DEBUG
+#ifdef ENABLE_DEBUG
winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
(int)rcWin.left, (int)rcWin.top, (int)rcWin.right, (int)rcWin.bottom,
(int)(rcWin.right - rcWin.left), (int)(rcWin.bottom - rcWin.top));
@@ -927,7 +927,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
if (EqualRect(&rcDraw, &rcWin)) {
/* Bail if no adjust is needed */
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("\treturn because already adjusted\n");
#endif
return 0;
@@ -949,7 +949,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
vlist[2] = pDraw->width + dW;
vlist[3] = pDraw->height + dH;
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("\tConfigureWindow to (%u, %u) - %ux%u\n",
(unsigned int)vlist[0], (unsigned int)vlist[1],
(unsigned int)vlist[2], (unsigned int)vlist[3]);
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 37f1a7a02..a50d96bfd 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -77,8 +77,8 @@ extern void winDebug(const char *format, ...);
extern void winReshapeMultiWindow(WindowPtr pWin);
extern void winUpdateRgnMultiWindow(WindowPtr pWin);
-#ifndef CYGDEBUG
-#define CYGDEBUG NO
+#ifndef ENABLE_DEBUG
+#define ENABLE_DEBUG NO
#endif
/*
@@ -189,7 +189,7 @@ static Bool g_shutdown = FALSE;
* Translate msg id to text, for debug purposes
*/
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
static const char *
MessageName(winWMMessagePtr msg)
{
@@ -386,7 +386,7 @@ GetWindowName(WMInfoPtr pWMInfo, xcb_window_t iWin, char **ppWindowName)
xcb_connection_t *conn = pWMInfo->conn;
char *pszWindowName = NULL;
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("GetWindowName\n");
#endif
@@ -791,7 +791,7 @@ winMultiWindowWMProc(void *pArg)
/* Initialize the Window Manager */
winInitMultiWindowWM(pWMInfo, pProcArg);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winMultiWindowWMProc ()\n");
#endif
@@ -808,7 +808,7 @@ winMultiWindowWMProc(void *pArg)
pthread_exit(NULL);
}
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winMultiWindowWMProc - MSG: %s (%d) ID: %d\n",
MessageName(&(pNode->msg)), (int)pNode->msg.msg, (int)pNode->msg.dwID);
#endif
@@ -1002,7 +1002,7 @@ winMultiWindowWMProc(void *pArg)
/* Free the passed-in argument */
free(pProcArg);
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("-winMultiWindowWMProc ()\n");
#endif
return NULL;
@@ -1395,9 +1395,9 @@ winInitWM(void **ppWMInfo,
pthread_mutex_t * ppmServerStarted,
int dwScreen, HWND hwndScreen, Bool compositeWM)
{
- WMProcArgPtr pArg = malloc(sizeof(WMProcArgRec));
- WMInfoPtr pWMInfo = malloc(sizeof(WMInfoRec));
- XMsgProcArgPtr pXMsgArg = malloc(sizeof(XMsgProcArgRec));
+ WMProcArgPtr pArg = calloc(sizeof(WMProcArgRec), 1);
+ WMInfoPtr pWMInfo = calloc(sizeof(WMInfoRec), 1);
+ XMsgProcArgPtr pXMsgArg = calloc(sizeof(XMsgProcArgRec), 1);
/* Bail if the input parameters are bad */
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
@@ -1408,11 +1408,6 @@ winInitWM(void **ppWMInfo,
return FALSE;
}
- /* Zero the allocated memory */
- ZeroMemory(pArg, sizeof(WMProcArgRec));
- ZeroMemory(pWMInfo, sizeof(WMInfoRec));
- ZeroMemory(pXMsgArg, sizeof(XMsgProcArgRec));
-
/* Set a return pointer to the Window Manager info structure */
*ppWMInfo = pWMInfo;
pWMInfo->fCompositeWM = compositeWM;
@@ -1446,7 +1441,7 @@ winInitWM(void **ppWMInfo,
return FALSE;
}
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winInitWM - Returning.\n");
#endif
@@ -1636,7 +1631,7 @@ winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
{
WMMsgNodePtr pNode;
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winSendMessageToWM %s\n", MessageName(pMsg));
#endif
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 31b5d6307..2b64b724c 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -415,7 +415,6 @@ LRESULT CALLBACK
winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
POINT ptMouse;
- PAINTSTRUCT ps;
WindowPtr pWin = NULL;
winPrivWinPtr pWinPriv = NULL;
ScreenPtr s_pScreen = NULL;
@@ -430,7 +429,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT ret;
static Bool hasEnteredSizeMove = FALSE;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam,
lParam);
#endif
@@ -578,6 +577,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#ifdef XWIN_GLX_WINDOWS
if (pWinPriv->fWglUsed) {
+ PAINTSTRUCT ps;
/*
For regions which are being drawn by GL, the shadow framebuffer doesn't have the
correct bits, so don't bitblt from the shadow framebuffer
@@ -621,13 +621,11 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Are we tracking yet? */
if (!s_fTracking) {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory(&tme, sizeof(tme));
- tme.cbSize = sizeof(tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
+ TRACKMOUSEEVENT tme = (TRACKMOUSEEVENT) {
+ .cbSize = sizeof(TRACKMOUSEEVENT),
+ .dwFlags = TME_LEAVE,
+ .hwndTrack = hwnd,
+ };
/* Call the tracking function */
if (!TrackMouseEvent(&tme))
@@ -844,7 +842,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000))
break;
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
if (wParam == VK_ESCAPE) {
/* Place for debug: put any tests and dumps here */
WINDOWPLACEMENT windPlace;
@@ -1011,7 +1009,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
HWND forHwnd = GetForegroundWindow();
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
ErrorF("overridden window is shown\n");
#endif
if (forHwnd != NULL) {
@@ -1046,13 +1044,13 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam;
if (!(pWinPos->flags & SWP_NOZORDER)) {
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
winDebug("\twindow z order was changed\n");
#endif
if (pWinPos->hwndInsertAfter == HWND_TOP
|| pWinPos->hwndInsertAfter == HWND_TOPMOST
|| pWinPos->hwndInsertAfter == HWND_NOTOPMOST) {
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
winDebug("\traise to top\n");
#endif
/* Raise the window to the top in Z order */
@@ -1081,7 +1079,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* If this is top of X windows in Windows stack,
raise it in X stack. */
if (hWndAbove == NULL) {
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
winDebug("\traise to top\n");
#endif
winRaiseWindow(pWin);
@@ -1107,7 +1105,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SIZE:
/* see dix/window.c */
-#if CYGWINDOWING_DEBUG
+#if ENABLE_DEBUG
{
char buf[64];
@@ -1211,7 +1209,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Check if this window needs to be made active when clicked */
if (!GetProp(pWinPriv->hWnd, WIN_NEEDMANAGE_PROP)) {
-#if CYGMULTIWINDOW_DEBUG
+#if ENABLE_DEBUG
ErrorF("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
"MA_NOACTIVATE\n");
#endif
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index d0b2ef2e7..8cf45fd51 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -542,7 +542,9 @@ LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags)
}
else {
char *file = malloc(PATH_MAX + NAME_MAX + 2);
+#ifdef __CYGWIN__
Bool convert = FALSE;
+#endif
if (!file)
return NULL;
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 66023f335..9142cc5d0 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -35,6 +35,9 @@ from The Open Group.
#include <sys/utsname.h>
#endif
+#include "os/cmdline.h"
+#include "os/osdep.h"
+
#include <../xfree86/common/xorgVersion.h>
#include "win.h"
#include "winconfig.h"
@@ -221,13 +224,11 @@ ddxProcessArgument(int argc, char *argv[], int i)
/* Initialize once */
if (!s_fBeenHere) {
-#ifdef DDXOSVERRORF
/*
* This initialises our hook into VErrorF () for catching log messages
* that are generated before OsInit () is called.
*/
OsVendorVErrorFProc = OsVendorVErrorF;
-#endif
s_fBeenHere = TRUE;
@@ -252,7 +253,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
}
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("ddxProcessArgument - arg: %s\n", argv[i]);
#endif
@@ -285,7 +286,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
int iWidth, iHeight, iX, iY;
int iMonitor;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc, i);
#endif
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index ae6bc12a6..48d3e7a26 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -52,7 +52,7 @@ winScreenInit(ScreenPtr pScreen, int argc, char **argv)
HDC hdc;
DWORD dwInitialBPP;
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winScreenInit - dwWidth: %u dwHeight: %u\n",
(unsigned int)pScreenInfo->dwWidth, (unsigned int)pScreenInfo->dwHeight);
#endif
@@ -194,7 +194,7 @@ winScreenInit(ScreenPtr pScreen, int argc, char **argv)
pScreen->myNum, pScreen->x, pScreen->y);
}
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winScreenInit - returning\n");
#endif
@@ -333,14 +333,14 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
#endif
/* Setup the cursor routines */
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winFinishScreenInitFB - Calling miDCInitialize ()\n");
#endif
miDCInitialize(pScreen, &g_winPointerCursorFuncs);
/* KDrive does winCreateDefColormap right after miDCInitialize */
/* Create a default colormap */
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
#endif
if (!winCreateDefColormap(pScreen)) {
@@ -351,7 +351,7 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
/* Initialize the shadow framebuffer layer */
if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
|| pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winFinishScreenInitFB - Calling shadowSetup ()\n");
#endif
if (!shadowSetup(pScreen)) {
@@ -473,7 +473,7 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
if (pScreenInfo->fMultiWindow) {
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winFinishScreenInitFB - Calling winInitWM.\n");
#endif
@@ -496,7 +496,7 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
/* Tell the server that we have a valid depth */
pScreenPriv->fBadDepth = FALSE;
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winFinishScreenInitFB - returning\n");
#endif
diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c
index 290176920..2884134b4 100644
--- a/hw/xwin/winshadddnl.c
+++ b/hw/xwin/winshadddnl.c
@@ -98,16 +98,14 @@ winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen)
{
winScreenPriv(pScreen);
HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsd;
+ DDSURFACEDESC2 ddsd = (DDSURFACEDESC2) {
+ .dwSize = sizeof(DDSURFACEDESC2),
+ .dwFlags = DDSD_CAPS,
+ .ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE
+ };
winDebug("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
- /* Describe the primary surface */
- ZeroMemory(&ddsd, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
/* Create the primary surface */
ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
&ddsd,
@@ -195,11 +193,12 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsdShadow;
char *lpSurface = NULL;
- DDPIXELFORMAT ddpfPrimary;
+ DDPIXELFORMAT ddpfPrimary = (DDPIXELFORMAT) {
+ .dwSize = sizeof(DDPIXELFORMAT)
+ };
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowDDNL - w %u h %u d %u\n",
(unsigned int)pScreenInfo->dwWidth,
(unsigned int)pScreenInfo->dwHeight,
@@ -211,18 +210,12 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
pScreenInfo->dwBPP);
/* Allocate memory for our shadow surface */
- lpSurface = malloc(pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+ lpSurface = calloc(pScreenInfo->dwPaddedWidth, pScreenInfo->dwHeight);
if (lpSurface == NULL) {
ErrorF("winAllocateFBShadowDDNL - Could not allocate bits\n");
return FALSE;
}
- /*
- * Initialize the framebuffer memory so we don't get a
- * strange display at startup
- */
- ZeroMemory(lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
-
/* Create a clipper */
ddrval = (*g_fpDirectDrawCreateClipper) (0,
&pScreenPriv->pddcPrimary, NULL);
@@ -232,7 +225,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowDDNL - Created a clipper\n");
#endif
@@ -245,7 +238,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowDDNL - Attached clipper to window\n");
#endif
@@ -259,7 +252,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowDDNL - Created and initialized DD\n");
#endif
@@ -275,7 +268,6 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
/* Are we full screen? */
if (pScreenInfo->fFullScreen) {
- DDSURFACEDESC2 ddsdCurrent;
DWORD dwRefreshRateCurrent = 0;
HDC hdc = NULL;
@@ -295,8 +287,9 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
* if a refresh rate has been passed on the command line.
*/
if (pScreenInfo->dwRefreshRate != 0) {
- ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent));
- ddsdCurrent.dwSize = sizeof(ddsdCurrent);
+ DDSURFACEDESC2 ddsdCurrent = (DDSURFACEDESC2) {
+ .dwSize = sizeof(DDSURFACEDESC2)
+ };
/* Get information about current display settings */
ddrval = IDirectDraw4_GetDisplayMode(pScreenPriv->pdd4,
@@ -390,8 +383,6 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
}
/* Get primary surface's pixel format */
- ZeroMemory(&ddpfPrimary, sizeof(ddpfPrimary));
- ddpfPrimary.dwSize = sizeof(ddpfPrimary);
ddrval = IDirectDrawSurface4_GetPixelFormat(pScreenPriv->pddsPrimary4,
&ddpfPrimary);
if (FAILED(ddrval)) {
@@ -400,7 +391,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
"dwRGBBitCount: %u\n",
(unsigned int)ddpfPrimary.u2.dwRBitMask,
@@ -418,16 +409,17 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
* so you shouldn't be allocating video memory when
* you have the option of using system memory instead.
*/
- ZeroMemory(&ddsdShadow, sizeof(ddsdShadow));
- ddsdShadow.dwSize = sizeof(ddsdShadow);
- ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
- | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
- ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsdShadow.dwHeight = pScreenInfo->dwHeight;
- ddsdShadow.dwWidth = pScreenInfo->dwWidth;
- ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
- ddsdShadow.lpSurface = lpSurface;
- ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
+ DDSURFACEDESC2 ddsdShadow = (DDSURFACEDESC2) {
+ .dwSize = sizeof(ddsdShadow),
+ .dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
+ | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT,
+ .ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
+ .dwHeight = pScreenInfo->dwHeight,
+ .dwWidth = pScreenInfo->dwWidth,
+ .u1.lPitch = pScreenInfo->dwPaddedWidth,
+ .lpSurface = lpSurface,
+ .u4.ddpfPixelFormat = ddpfPrimary
+ };
winDebug("winAllocateFBShadowDDNL - lPitch: %d\n",
(int) pScreenInfo->dwPaddedWidth);
@@ -442,7 +434,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
(int) ddsdShadow.u1.lPitch);
#endif
@@ -451,7 +443,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
/ pScreenInfo->dwBPP;
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
(int) pScreenInfo->dwStride);
#endif
@@ -464,7 +456,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowDDNL - Returning\n");
#endif
@@ -607,7 +599,7 @@ winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf)
DeleteObject(hrgnCombined);
hrgnCombined = NULL;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
pBoxExtents->x1, pBoxExtents->y1,
pBoxExtents->x2, pBoxExtents->y2);
@@ -660,7 +652,7 @@ winCloseScreenShadowDDNL(ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn = TRUE;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCloseScreenShadowDDNL - Freeing screen resources\n");
#endif
@@ -799,7 +791,7 @@ winInitVisualsShadowDDNL(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winInitVisualsShadowDDNL - Returning\n");
#endif
@@ -1144,7 +1136,7 @@ winDestroyColormapShadowDDNL(ColormapPtr pColormap)
* we need to handle the default colormap in a special way.
*/
if (pColormap->flags & IsDefault) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug
("winDestroyColormapShadowDDNL - Destroying default colormap\n");
#endif
diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c
index 25e16bf76..6b61d85e3 100644
--- a/hw/xwin/winshadgdi.c
+++ b/hw/xwin/winshadgdi.c
@@ -94,7 +94,7 @@ winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
winScreenPriv(pScreen);
HBITMAP hbmp;
-#if CYGDEBUG
+#if ENABLE_DEBUG
LPDWORD pdw = NULL;
#endif
@@ -106,7 +106,7 @@ winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
}
/* Initialize our bitmap info header */
- ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+ memset(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD), 1);
pbmih->biSize = sizeof(BITMAPINFOHEADER);
/* Get the biBitCount */
@@ -117,7 +117,7 @@ winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
/* Get a pointer to bitfields */
pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
@@ -196,7 +196,7 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen)
/* Get a pointer to bitfields */
pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
(unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
winDebug("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
@@ -342,7 +342,7 @@ winAllocateFBShadowGDI(ScreenPtr pScreen)
return FALSE;
}
else {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowGDI - Shadow buffer allocated\n");
#endif
}
@@ -350,7 +350,7 @@ winAllocateFBShadowGDI(ScreenPtr pScreen)
/* Get information about the bitmap that was allocated */
GetObject(pScreenPriv->hbmpShadow, sizeof(dibsection), &dibsection);
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
/* Print information about bitmap allocated */
winDebug("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
"depth: %d size image: %d\n",
@@ -361,7 +361,7 @@ winAllocateFBShadowGDI(ScreenPtr pScreen)
/* Select the shadow bitmap into the shadow DC */
SelectObject(pScreenPriv->hdcShadow, pScreenPriv->hbmpShadow);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowGDI - Attempting a shadow blit\n");
#endif
@@ -371,7 +371,7 @@ winAllocateFBShadowGDI(ScreenPtr pScreen)
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
if (fReturn) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAllocateFBShadowGDI - Shadow blit success\n");
#endif
}
@@ -397,7 +397,7 @@ winAllocateFBShadowGDI(ScreenPtr pScreen)
/ dibsection.dsBmih.biHeight)
* 8) / pScreenInfo->dwBPP;
-#if CYGDEBUG || YES
+#if ENABLE_DEBUG || YES
winDebug("winAllocateFBShadowGDI - Created shadow stride: %d\n",
(int) pScreenInfo->dwStride);
#endif
@@ -573,7 +573,7 @@ winCloseScreenShadowGDI(ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn = TRUE;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winCloseScreenShadowGDI - Freeing screen resources\n");
#endif
@@ -698,7 +698,7 @@ winInitVisualsShadowGDI(ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winInitVisualsShadowGDI - Returning\n");
#endif
@@ -1002,13 +1002,13 @@ winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen)
winScreenPriv(pScreen);
winPrivCmapPtr pCmapPriv = NULL;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winRealizeInstalledPaletteShadowGDI\n");
#endif
/* Don't do anything if there is not a colormap */
if (pScreenPriv->pcmapInstalled == NULL) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winRealizeInstalledPaletteShadowGDI - No colormap "
"installed\n");
#endif
@@ -1162,18 +1162,14 @@ winCreateColormapShadowGDI(ColormapPtr pColormap)
dwEntriesMax = pVisual->ColormapEntries;
/* Allocate a Windows logical color palette with max entries */
- lpPaletteNew = malloc(sizeof(LOGPALETTE)
- + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
+ lpPaletteNew = calloc(sizeof(LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof(PALETTEENTRY), 1);
if (lpPaletteNew == NULL) {
ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
"with %d entries\n", (int) dwEntriesMax);
return FALSE;
}
- /* Zero out the colormap */
- ZeroMemory(lpPaletteNew, sizeof(LOGPALETTE)
- + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
-
/* Set the logical palette structure */
lpPaletteNew->palVersion = 0x0300;
lpPaletteNew->palNumEntries = dwEntriesMax;
@@ -1214,7 +1210,7 @@ winDestroyColormapShadowGDI(ColormapPtr pColormap)
* we need to handle the default colormap in a special way.
*/
if (pColormap->flags & IsDefault) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winDestroyColormapShadowGDI - Destroying default "
"colormap\n");
#endif
diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c
index 934f6d845..60be32da4 100644
--- a/hw/xwin/winwindow.c
+++ b/hw/xwin/winwindow.c
@@ -61,7 +61,7 @@ winCreateWindowRootless(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winCreateWindowRootless (%p)\n", pWin);
#endif
@@ -86,7 +86,7 @@ winDestroyWindowRootless(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winDestroyWindowRootless (%p)\n", pWin);
#endif
@@ -115,7 +115,7 @@ winPositionWindowRootless(WindowPtr pWin, int x, int y)
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winPositionWindowRootless (%p)\n", pWin);
#endif
@@ -139,7 +139,7 @@ winChangeWindowAttributesRootless(WindowPtr pWin, unsigned long mask)
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winChangeWindowAttributesRootless (%p)\n", pWin);
#endif
@@ -165,7 +165,7 @@ winUnmapWindowRootless(WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winUnmapWindowRootless (%p)\n", pWin);
#endif
@@ -195,7 +195,7 @@ winMapWindowRootless(WindowPtr pWin)
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winMapWindowRootless (%p)\n", pWin);
#endif
@@ -217,7 +217,7 @@ winSetShapeRootless(WindowPtr pWin, int kind)
winScreenPriv(pScreen);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winTrace("winSetShapeRootless (%p, %i)\n", pWin, kind);
#endif
@@ -247,7 +247,7 @@ winAddRgn(WindowPtr pWin, void *data)
/* If pWin is not Root */
if (pWin->parent != NULL) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winAddRgn ()\n");
#endif
if (pWin->mapped) {
@@ -320,7 +320,7 @@ winReshapeRootless(WindowPtr pWin)
winWindowPriv(pWin);
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winReshapeRootless ()\n");
#endif
diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index 92a839c4d..2ad4b475e 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -57,12 +57,6 @@
#endif
#define WIN_WID_PROP "cyg_wid_prop_rl"
#define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl"
-#ifndef CYGMULTIWINDOW_DEBUG
-#define CYGMULTIWINDOW_DEBUG NO
-#endif
-#ifndef CYGWINDOWING_DEBUG
-#define CYGWINDOWING_DEBUG NO
-#endif
#define XMING_SIGNATURE 0x12345678L
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index c7950880f..2509018b6 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -69,7 +69,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
int iScanCode;
int i;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
#endif
@@ -82,7 +82,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Only retrieve new privates pointers if window handle is null or changed */
if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
&& (s_pScreenPriv = GetProp(hwnd, WIN_SCR_PROP)) != NULL) {
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - Setting privates handle\n");
#endif
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
@@ -103,7 +103,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
s_pScreenPriv);
case WM_CREATE:
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_CREATE\n");
#endif
@@ -299,7 +299,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
RECT rcWindow;
int iWidth, iHeight;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_SIZE\n");
#endif
@@ -437,7 +437,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SCROLLINFO si;
int iVertPos;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_VSCROLL\n");
#endif
@@ -516,7 +516,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SCROLLINFO si;
int iHorzPos;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_HSCROLL\n");
#endif
@@ -595,7 +595,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
int iCaptionHeight;
int iBorderHeight, iBorderWidth;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %p\n",
s_pScreenInfo);
#endif
@@ -634,7 +634,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
case WM_ERASEBKGND:
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_ERASEBKGND\n");
#endif
/*
@@ -645,7 +645,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
case WM_PAINT:
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_PAINT\n");
#endif
/* Only paint if we have privates and the server is enabled */
@@ -667,7 +667,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_PALETTECHANGED:
{
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_PALETTECHANGED\n");
#endif
/*
@@ -711,13 +711,11 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Are we tracking yet? */
if (!s_fTracking) {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory(&tme, sizeof(tme));
- tme.cbSize = sizeof(tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
+ TRACKMOUSEEVENT tme = (TRACKMOUSEEVENT) {
+ tme.cbSize = sizeof(tme),
+ tme.dwFlags = TME_LEAVE,
+ tme.hwndTrack = hwnd
+ };
/* Call the tracking function */
if (!TrackMouseEvent(&tme))
@@ -906,7 +904,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_MOUSEWHEEL\n");
#endif
/* Button4 = WheelUp */
@@ -917,7 +915,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEHWHEEL:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_MOUSEHWHEEL\n");
#endif
/* Button7 = TiltRight */
@@ -1073,7 +1071,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
-#if CYGDEBUG
+#if ENABLE_DEBUG
winDebug("winWindowProc - WM_ACTIVATE\n");
#endif
@@ -1099,7 +1097,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
-#if CYGDEBUG || TRUE
+#if ENABLE_DEBUG || TRUE
winDebug("winWindowProc - WM_ACTIVATEAPP\n");
#endif
diff --git a/include/Xprintf.h b/include/Xprintf.h
index 9e8cdc5dc..ede615dd6 100644
--- a/include/Xprintf.h
+++ b/include/Xprintf.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/include/Xserver.d b/include/Xserver.d
index 4a233e1f6..cca33efa6 100644
--- a/include/Xserver.d
+++ b/include/Xserver.d
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005-2006, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/include/callback.h b/include/callback.h
index fe7015ee7..a1f9f15c0 100644
--- a/include/callback.h
+++ b/include/callback.h
@@ -83,9 +83,4 @@ CallCallbacks(CallbackListPtr *pcbl, void *call_data)
_CallCallbacks(pcbl, call_data);
}
-extern _X_EXPORT void DeleteCallbackList(CallbackListPtr *pcbl);
-
-extern _X_EXPORT void InitCallbackManager(void);
-extern _X_EXPORT void DeleteCallbackManager(void);
-
#endif /* CALLBACK_H */
diff --git a/include/colormap.h b/include/colormap.h
index f3b18a613..dabfbd92c 100644
--- a/include/colormap.h
+++ b/include/colormap.h
@@ -70,7 +70,6 @@ SOFTWARE.
#define BeingCreated 4
typedef CARD32 Pixel;
-typedef struct _CMEntry *EntryPtr;
/* moved to screenint.h: typedef struct _ColormapRec *ColormapPtr */
typedef struct _colorResource *colorResourcePtr;
diff --git a/include/cursor.h b/include/cursor.h
index 281d88ba0..d198f711d 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -62,10 +62,6 @@ struct _DeviceIntRec;
typedef struct _Cursor *CursorPtr;
typedef struct _CursorMetric *CursorMetricPtr;
-extern _X_EXPORT DevScreenPrivateKeyRec cursorScreenDevPriv;
-
-#define CursorScreenKey (&cursorScreenDevPriv)
-
extern _X_EXPORT CursorPtr rootCursor;
extern _X_EXPORT int FreeCursor(void *pCurs,
diff --git a/include/displaymode.h b/include/displaymode.h
index ad01b87ec..561087717 100644
--- a/include/displaymode.h
+++ b/include/displaymode.h
@@ -47,6 +47,7 @@ typedef enum {
MODE_ONE_SIZE, /* only one resolution is supported */
MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
+ MODE_DUPLICATE, /* mode is duplicated */
MODE_BAD = -2, /* unspecified reason */
MODE_ERROR = -1 /* error condition */
} ModeStatus;
diff --git a/include/dix.h b/include/dix.h
index 0dcd09b65..f4f17ff29 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -101,20 +101,6 @@ SOFTWARE.
} \
} while (0)
-#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, mode) \
- do { \
- int tmprc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY, mode); \
- if (tmprc != Success) \
- return tmprc; \
- tmprc = dixLookupGC(&(pGC), stuff->gc, client, DixUseAccess); \
- if (tmprc != Success) \
- return tmprc; \
- if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen)) \
- return BadMatch; \
- if (pGC->serialNumber != pDraw->serialNumber) \
- ValidateGC(pDraw, pGC); \
- } while (0)
-
#define WriteReplyToClient(pClient, size, pReply) \
do { \
if ((pClient)->swapped) \
@@ -145,34 +131,19 @@ typedef struct _WorkQueue *WorkQueuePtr;
extern _X_EXPORT ClientPtr clients[MAXCLIENTS];
extern _X_EXPORT ClientPtr serverClient;
extern _X_EXPORT int currentMaxClients;
-extern _X_EXPORT char dispatchExceptionAtReset;
-extern _X_EXPORT int terminateDelay;
-extern _X_EXPORT Bool touchEmulatePointer;
-
-typedef int HWEventQueueType;
-typedef HWEventQueueType *HWEventQueuePtr;
-
-extern _X_EXPORT HWEventQueuePtr checkForInput[2];
-
-static inline _X_NOTSAN Bool
-InputCheckPending(void)
-{
- return (*checkForInput[0] != *checkForInput[1]);
-}
typedef struct _TimeStamp {
CARD32 months; /* really ~49.7 days */
CARD32 milliseconds;
} TimeStamp;
-/* dispatch.c */
-extern _X_EXPORT ClientPtr GetCurrentClient(void);
+typedef int HWEventQueueType;
+typedef HWEventQueueType *HWEventQueuePtr;
+/* dispatch.c */
extern _X_EXPORT void SetInputCheck(HWEventQueuePtr /*c0 */ ,
HWEventQueuePtr /*c1 */ );
-extern _X_EXPORT void CloseDownClient(ClientPtr /*client */ );
-
extern _X_EXPORT void UpdateCurrentTime(void);
extern _X_EXPORT void UpdateCurrentTimeIf(void);
@@ -180,10 +151,6 @@ extern _X_EXPORT void UpdateCurrentTimeIf(void);
extern _X_EXPORT int dixDestroyPixmap(void *value,
XID pid);
-extern _X_EXPORT void InitClient(ClientPtr client,
- int i,
- void *ospriv);
-
extern _X_EXPORT ClientPtr NextAvailableClient(void *ospriv);
extern _X_EXPORT void SendErrorToClient(ClientPtr /*client */ ,
@@ -198,11 +165,6 @@ extern _X_HIDDEN Bool CreateConnectionBlock(void);
/* dixutils.c */
-extern _X_EXPORT int CompareISOLatin1Lowered(const unsigned char * /*a */ ,
- int alen,
- const unsigned char * /*b */ ,
- int blen);
-
extern _X_EXPORT int dixLookupWindow(WindowPtr *result,
XID id,
ClientPtr client, Mask access_mode);
@@ -212,17 +174,10 @@ extern _X_EXPORT int dixLookupDrawable(DrawablePtr *result,
ClientPtr client,
Mask type_mask, Mask access_mode);
-extern _X_EXPORT int dixLookupGC(GCPtr *result,
- XID id, ClientPtr client, Mask access_mode);
-
extern _X_EXPORT int dixLookupFontable(FontPtr *result,
XID id,
ClientPtr client, Mask access_mode);
-extern _X_EXPORT int dixLookupClient(ClientPtr *result,
- XID id,
- ClientPtr client, Mask access_mode);
-
extern _X_EXPORT void NoopDDA(void);
extern _X_EXPORT int AlterSaveSetForClient(ClientPtr /*client */ ,
@@ -231,8 +186,6 @@ extern _X_EXPORT int AlterSaveSetForClient(ClientPtr /*client */ ,
Bool /*toRoot */ ,
Bool /*map */ );
-extern _X_EXPORT void DeleteWindowFromAnySaveSet(WindowPtr /*pWin */ );
-
extern _X_EXPORT void BlockHandler(void *timeout);
extern _X_EXPORT void WakeupHandler(int result);
@@ -259,12 +212,6 @@ extern _X_EXPORT void RemoveBlockAndWakeupHandlers(ServerBlockHandlerProcPtr blo
extern _X_EXPORT void InitBlockAndWakeupHandlers(void);
-extern _X_EXPORT void ClearWorkQueue(void);
-
-extern _X_EXPORT void ProcessWorkQueue(void);
-
-extern _X_EXPORT void ProcessWorkQueueZombies(void);
-
extern _X_EXPORT Bool QueueWorkProc(Bool (*function)(ClientPtr clientUnused,
void *closure),
ClientPtr client,
@@ -570,11 +517,6 @@ IsInterferingGrab(ClientPtr /* client */ ,
DeviceIntPtr /* dev */ ,
xEvent * /* events */ );
-#ifdef PANORAMIX
-extern _X_EXPORT void
-ReinitializeRootWindow(WindowPtr win, int xoff, int yoff);
-#endif
-
#ifdef RANDR
extern _X_EXPORT void
ScreenRestructured(ScreenPtr pScreen);
diff --git a/include/dixfont.h b/include/dixfont.h
index 65b5d2075..50f2ca0ae 100644
--- a/include/dixfont.h
+++ b/include/dixfont.h
@@ -26,7 +26,6 @@ SOFTWARE.
#include "dix.h"
#include <X11/fonts/font.h>
-#include "closure.h"
#include <X11/fonts/fontstruct.h>
#define NullDIXFontProp ((DIXFontPropPtr)0)
diff --git a/include/dixfontstr.h b/include/dixfontstr.h
index 7deb84ac5..eae1a3b58 100644
--- a/include/dixfontstr.h
+++ b/include/dixfontstr.h
@@ -28,7 +28,6 @@ SOFTWARE.
#include "dixfont.h"
#include <X11/fonts/fontstruct.h>
#include <X11/fonts/libxfont2.h>
-#include "closure.h"
#include <X11/Xproto.h> /* for xQueryFontReply */
#define FONTCHARSET(font) (font)
diff --git a/include/eventstr.h b/include/eventstr.h
index 93308f9b2..a9926eaee 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -335,4 +335,7 @@ union _InternalEvent {
GestureEvent gesture_event;
};
+extern void
+LeaveWindow(DeviceIntPtr dev);
+
#endif
diff --git a/include/exevents.h b/include/exevents.h
index c900c7b2c..7e3029fc9 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -305,4 +305,11 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
extern int
XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len);
+void
+XTestDeviceSendEvents(DeviceIntPtr dev,
+ int type,
+ int detail,
+ int flags,
+ const ValuatorMask *mask);
+
#endif /* EXEVENTS_H */
diff --git a/include/extinit.h b/include/extinit.h
index 46081ad30..59d18962f 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -108,6 +108,7 @@ extern _X_EXPORT Bool noScreenSaverExtension;
extern void ScreenSaverExtensionInit(void);
#endif
+extern _X_EXPORT Bool noShapeExtension;
extern void ShapeExtensionInit(void);
#ifdef MITSHM
diff --git a/include/fourcc.h b/include/fourcc.h
index a19e6869e..83e51a888 100644
--- a/include/fourcc.h
+++ b/include/fourcc.h
@@ -176,4 +176,43 @@
XvTopToBottom \
}
+#define FOURCC_RGBA32 0x34325241
+#define XVIMAGE_RGB32 \
+ { \
+ FOURCC_RGBA32, \
+ XvRGB, \
+ LSBFirst, \
+ {'R','A','2','4', \
+ 0x00, 0x00, 0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 32, \
+ XvPacked, \
+ 1, \
+ 32, 0xff0000, 0xff00, 0xff, \
+ 0, 0, 0, \
+ 0, 0, 0, \
+ 0, 0, 0, \
+ {0,0,0,0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ 0 \
+ }
+
+#define FOURCC_RGB565 0x36314752
+#define XVIMAGE_RGB565 \
+ { \
+ FOURCC_RGB565, \
+ XvRGB, \
+ LSBFirst, \
+ {'R','G','1','6', \
+ 0x00, 0x00, 0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 16, \
+ XvPacked, \
+ 1, \
+ 16, 0xf800, 0x7e0, 0x1f, \
+ 0, 0, 0, \
+ 0, 0, 0, \
+ 0, 0, 0, \
+ {0,0,0,0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ 0 \
+ }
#endif /* _XF86_FOURCC_H_ */
diff --git a/include/gc.h b/include/gc.h
index 53f9c29e1..66e27bcea 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -62,15 +62,7 @@ SOFTWARE.
#define CT_YXSORTED 14
#define CT_YXBANDED 18
-#define GCQREASON_VALIDATE 1
-#define GCQREASON_CHANGE 2
-#define GCQREASON_COPY_SRC 3
-#define GCQREASON_COPY_DST 4
-#define GCQREASON_DESTROY 5
-
#define GC_CHANGE_SERIAL_BIT (((unsigned long)1)<<31)
-#define GC_CALL_VALIDATE_BIT (1L<<30)
-#define GCExtensionInterest (1L<<29)
#define DRAWABLE_SERIAL_BITS (~(GC_CHANGE_SERIAL_BIT))
@@ -91,54 +83,11 @@ typedef union {
void *ptr;
} ChangeGCVal, *ChangeGCValPtr;
-extern int ChangeGCXIDs(ClientPtr /*client */ ,
- GCPtr /*pGC */ ,
- BITS32 /*mask */ ,
- CARD32 * /*pval */ );
-
extern _X_EXPORT int ChangeGC(ClientPtr /*client */ ,
GCPtr /*pGC */ ,
BITS32 /*mask */ ,
ChangeGCValPtr /*pCGCV */ );
-extern _X_EXPORT GCPtr CreateGC(DrawablePtr /*pDrawable */ ,
- BITS32 /*mask */ ,
- XID * /*pval */ ,
- int * /*pStatus */ ,
- XID /*gcid */ ,
- ClientPtr /*client */ );
-
-extern _X_EXPORT int CopyGC(GCPtr /*pgcSrc */ ,
- GCPtr /*pgcDst */ ,
- BITS32 /*mask */ );
-
-extern _X_EXPORT int FreeGC(void *pGC,
- XID gid);
-
-extern _X_EXPORT void FreeGCperDepth(int /*screenNum */ );
-
-extern _X_EXPORT Bool CreateGCperDepth(int /*screenNum */ );
-
-extern _X_EXPORT Bool CreateDefaultStipple(int /*screenNum */ );
-
-extern _X_EXPORT void FreeDefaultStipple(int /*screenNum */ );
-
-extern _X_EXPORT int SetDashes(GCPtr /*pGC */ ,
- unsigned /*offset */ ,
- unsigned /*ndash */ ,
- unsigned char * /*pdash */ );
-
-extern _X_EXPORT int VerifyRectOrder(int /*nrects */ ,
- xRectangle * /*prects */ ,
- int /*ordering */ );
-
-extern _X_EXPORT int SetClipRects(GCPtr /*pGC */ ,
- int /*xOrigin */ ,
- int /*yOrigin */ ,
- int /*nrects */ ,
- xRectangle * /*prects */ ,
- int /*ordering */ );
-
extern _X_EXPORT GCPtr GetScratchGC(unsigned /*depth */ ,
ScreenPtr /*pScreen */ );
diff --git a/include/globals.h b/include/globals.h
index 341ce832c..887e788c8 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -34,12 +34,4 @@ extern _X_EXPORT sig_atomic_t inSignalContext;
extern _X_EXPORT Bool PanoramiXExtensionDisabledHack;
#endif
-#ifdef XSELINUX
-#define SELINUX_MODE_DEFAULT 0
-#define SELINUX_MODE_DISABLED 1
-#define SELINUX_MODE_PERMISSIVE 2
-#define SELINUX_MODE_ENFORCING 3
-extern _X_EXPORT int selinuxEnforcingState;
-#endif
-
#endif /* !_XSERV_GLOBAL_H_ */
diff --git a/include/input.h b/include/input.h
index cdb5d5a90..fd5b7c4df 100644
--- a/include/input.h
+++ b/include/input.h
@@ -191,6 +191,12 @@ typedef Bool (*PointerAccelSchemeInitProc) (DeviceIntPtr /*dev */ ,
struct _ValuatorAccelerationRec *
/*protoScheme */ );
+typedef void (*DeviceSendEventsProc) (DeviceIntPtr /*dev */ ,
+ int /* event type */ ,
+ int /* detail, buttons or keycode */ ,
+ int /* flags */ ,
+ const ValuatorMask * /* valuators */ );
+
typedef struct _DeviceRec {
void *devicePrivate;
ProcessInputProc processInputProc; /* current */
@@ -325,6 +331,8 @@ extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ ,
extern _X_INTERNAL ValuatorClassPtr AllocValuatorClass(ValuatorClassPtr src,
int numAxes);
+extern _X_INTERNAL void FreeDeviceClass(int type, void **class);
+
extern _X_EXPORT Bool InitValuatorClassDeviceStruct(DeviceIntPtr /*device */ ,
int /*numAxes */ ,
@@ -660,6 +668,7 @@ extern void TouchEmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags,
extern void TouchAcceptAndEnd(DeviceIntPtr dev, int touchid);
extern Bool GestureInitGestureInfo(GestureInfoPtr gesture);
+extern void GestureFreeGestureInfo(GestureInfoPtr gesture);
extern GestureInfoPtr GestureBeginGesture(DeviceIntPtr dev, InternalEvent *ev);
extern GestureInfoPtr GestureFindActiveByEventType(DeviceIntPtr dev, int type);
extern void GestureEndGesture(GestureInfoPtr gi);
diff --git a/include/inputstr.h b/include/inputstr.h
index ec11b39bb..24dd48841 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -628,6 +628,7 @@ typedef struct _DeviceIntRec {
/* XTest related master device id */
int xtest_master_id;
+ DeviceSendEventsProc sendEventsProc;
struct _SyncCounter *idle_counter;
} DeviceIntRec;
diff --git a/include/list.h b/include/list.h
index f81d97fc1..f585b8f10 100644
--- a/include/list.h
+++ b/include/list.h
@@ -274,19 +274,8 @@ xorg_list_is_empty(struct xorg_list *head)
#define xorg_list_last_entry(ptr, type, member) \
xorg_list_entry((ptr)->prev, type, member)
-#ifdef HAVE_TYPEOF
#define __container_of(ptr, sample, member) \
container_of(ptr, typeof(*sample), member)
-#else
-/* This implementation of __container_of has undefined behavior according
- * to the C standard, but it works in many cases. If your compiler doesn't
- * support typeof() and fails with this implementation, please try a newer
- * compiler.
- */
-#define __container_of(ptr, sample, member) \
- (void *)((char *)(ptr) \
- - ((char *)&(sample)->member - (char *)(sample)))
-#endif
/**
* Loop through the list given by head and set pos to struct in the list.
diff --git a/include/meson.build b/include/meson.build
index 7f1e4fd8f..9f84f2b95 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -11,11 +11,6 @@ dri_dep = dependency('dri', required: build_glx)
conf_data = configuration_data()
conf_data.set('_DIX_CONFIG_H_', '1')
-conf_data.set('HAVE_TYPEOF', cc.compiles('''
- int foo(int bar) { typeof(bar) baz = 1; return baz; }
-''',
- name: 'typeof()') ? '1' : false)
-
# For feature macros we're using either false (boolean) or '1', which correspond to the macro being
# not defined at all and defined to 1. This is to match autotools behavior and thus preserve
# backwards compatibility with all the existing code that uses #ifdef to check if feature is
@@ -44,6 +39,10 @@ else
conf_data.set('X_BYTE_ORDER', 'X_BIG_ENDIAN')
endif
+# Defining _XSERVER64 on 64bit builds is VITAL, since otherwise Xlib headers
+# would define lots X types (eg. Atom, XID, etc) as 64 bit, but inside the
+# Xserver we really need them to be 32 bit (CARD32). When _SERVER64 is defined
+# the xlib headers will typedef them exactly to CARD32.
glx_align64 = []
if cc.sizeof('unsigned long') == 8
conf_data.set('_XSERVER64', '1')
@@ -91,14 +90,14 @@ endif
conf_data.set('HAVE_LIBBSD', libbsd_dep.found() ? '1' : false)
# Note: this symbol is used by libXtrans.
-conf_data.set('HAVE_SYSTEMD_DAEMON', libsystemd_daemon_dep.found() ? '1' : false)
+conf_data.set('HAVE_SYSTEMD_DAEMON', build_systemd ? '1' : false)
conf_data.set('CONFIG_UDEV', build_udev ? '1' : false)
conf_data.set('CONFIG_UDEV_KMS', build_udev_kms ? '1' : false)
conf_data.set('HAVE_DBUS', build_dbus ? '1' : false)
conf_data.set('CONFIG_HAL', build_hal ? '1' : false)
conf_data.set('SYSTEMD_LOGIND', build_systemd_logind ? '1' : false)
conf_data.set('NEED_DBUS', build_systemd_logind or build_hal ? '1' : false)
-conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd' ? '1' : false)
+conf_data.set('CONFIG_WSCONS', host_machine.system() in ['openbsd', 'netbsd'] ? '1' : false)
conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found() ? '1' : false)
conf_data.set('WITH_LIBDRM', libdrm_required ? '1' : false)
@@ -115,6 +114,8 @@ conf_data.set('GBM_BO_WITH_MODIFIERS',
build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 17.1') ? '1' : false)
conf_data.set('GBM_BO_FD_FOR_PLANE',
build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 21.1') ? '1' : false)
+conf_data.set('GBM_BO_WITH_MODIFIERS2',
+ build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 21.3') ? '1' : false)
conf_data.set_quoted('SERVER_MISC_CONFIG_PATH', serverconfigdir)
conf_data.set_quoted('PROJECTROOT', get_option('prefix'))
@@ -125,7 +126,6 @@ conf_data.set_quoted('COMPILEDDEFAULTFONTPATH', default_font_path)
conf_data.set('XORG_VERSION_CURRENT', release)
conf_data.set('HASXDMAUTH', has_xdm_auth ? '1' : false)
-conf_data.set('SECURE_RPC', get_option('secure-rpc') ? '1' : false)
conf_data.set('HAVE_DLFCN_H', cc.has_header('dlfcn.h') ? '1' : false)
conf_data.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h') ? '1' : false)
@@ -133,6 +133,8 @@ conf_data.set('HAVE_FNMATCH_H', cc.has_header('fnmatch.h') ? '1' : false)
conf_data.set('HAVE_LINUX_AGPGART_H', cc.has_header('linux/agpgart.h') ? '1' : false)
conf_data.set('HAVE_STRINGS_H', cc.has_header('strings.h') ? '1' : false)
conf_data.set('HAVE_SYS_AGPGART_H', cc.has_header('sys/agpgart.h') ? '1' : false)
+conf_data.set('HAVE_SYS_UCRED_H', cc.has_header('sys/ucred.h') ? '1' : false)
+conf_data.set('HAVE_SYS_UN_H', cc.has_header('sys/un.h') ? '1' : false)
conf_data.set('HAVE_SYS_UTSNAME_H', cc.has_header('sys/utsname.h') ? '1' : false)
conf_data.set('HAVE_SYS_SYSMACROS_H', cc.has_header('sys/sysmacros.h') ? '1' : false)
@@ -173,8 +175,7 @@ conf_data.set('HAVE_TIMINGSAFE_MEMCMP', cc.has_function('timingsafe_memcmp') ? '
conf_data.set('HAVE_VASPRINTF', cc.has_function('vasprintf') ? '1' : false)
conf_data.set('HAVE_VSNPRINTF', cc.has_function('vsnprintf') ? '1' : false)
conf_data.set('HAVE_WALKCONTEXT', cc.has_function('walkcontext') ? '1' : false)
-
-conf_data.set('BUSFAULT', conf_data.get('HAVE_SIGACTION'))
+conf_data.set('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include <sys/ucred.h>') ? '1' : false)
# Don't let X dependencies typedef 'pointer'
conf_data.set('_XTYPEDEF_POINTER', '1')
@@ -189,7 +190,7 @@ if cc.has_header_symbol('sys/socket.h', 'SCM_RIGHTS')
endif
if conf_data.get('HAVE_GETPEEREID').to_int() == 0 and conf_data.get('HAVE_GETPEERUCRED').to_int() == 0
- if not cc.has_header_symbol('sys/socket.h', 'SO_PEERCRED')
+ if not cc.has_header_symbol('sys/socket.h', 'SO_PEERCRED', args: '-D_GNU_SOURCE')
conf_data.set('NO_LOCAL_CLIENT_CRED', 1)
endif
endif
@@ -207,9 +208,8 @@ conf_data.set('DPMSExtension', build_dpms ? '1' : false)
conf_data.set('DRI2', build_dri2 ? '1' : false)
conf_data.set('DRI3', build_dri3 ? '1' : false)
if build_glx
- conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_pkgconfig_variable('dridriverdir'))
+ conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_variable(pkgconfig : 'dridriverdir'))
endif
-conf_data.set('HAS_SHM', build_mitshm ? '1' : false)
conf_data.set('MITSHM', build_mitshm ? '1' : false)
conf_data.set('PANORAMIX', build_xinerama ? '1' : false)
conf_data.set('PRESENT', '1')
@@ -237,13 +237,18 @@ conf_data.set('XV', build_xv ? '1' : false)
conf_data.set('XvExtension', build_xv ? '1' : false)
conf_data.set('XvMCExtension', build_xvmc ? '1' : false)
+# needed by several extensions
+build_registry_resource = (build_xselinux or build_res)
+conf_data.set('X_REGISTRY_RESOURCE', build_registry_resource ? '1' : false)
+build_registry_request = (build_xselinux or build_xsecurity or with_dtrace)
+conf_data.set('X_REGISTRY_REQUEST', build_registry_request ? '1' : false)
+
conf_data.set('HAVE_SHA1_IN_' + sha1.to_upper(), '1', description: 'Use @0@ SHA1 functions'.format(sha1))
conf_data.set('HAVE_LIBUNWIND', get_option('libunwind'))
conf_data.set('HAVE_APM', (build_apm or build_acpi) ? '1' : false)
conf_data.set('HAVE_ACPI', build_acpi ? '1' : false)
-conf_data.set('DDXOSVERRORF', build_xwin ? '1' : false)
conf_data.set('DDXBEFORERESET', build_xwin ? '1' : false)
enable_debugging = get_option('buildtype') == 'debug'
conf_data.set('DEBUG', enable_debugging ? '1' : false)
@@ -373,16 +378,13 @@ xorg_data.set('WSCONS_SUPPORT',
xorg_data.set('HAVE_STROPTS_H', cc.has_header('stropts.h') ? '1' : false)
xorg_data.set('HAVE_SYS_KD_H', cc.has_header('sys/kd.h') ? '1' : false)
xorg_data.set('HAVE_SYS_VT_H', cc.has_header('sys/vt.h') ? '1' : false)
+xorg_data.set('HAVE_MODESETTING_DRIVER', build_modesetting ? '1' : false)
if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonfly'
- if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
+ if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64'
xorg_data.set('USE_DEV_IO', '1')
endif
-elif host_machine.system() == 'netbsd'
- if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
- xorg_data.set('USE_I386_IOPL', '1')
- endif
-elif host_machine.system() == 'openbsd'
+elif host_machine.system() == 'netbsd' or host_machine.system() == 'openbsd'
if host_machine.cpu_family() == 'x86'
xorg_data.set('USE_I386_IOPL', '1')
endif
@@ -403,18 +405,20 @@ xwin_data.set('HAS_DEVWINDOWS', host_machine.system() == 'cygwin' ? '1' : false,
description: 'Has /dev/windows for signaling new win32 messages')
xwin_data.set('RELOCATE_PROJECTROOT', host_machine.system() == 'windows' ? '1' : false,
description: 'Make paths relative to the xserver installation location')
-# XXX: these three are all the same as DEBUG so we should just change to that
-xwin_data.set10('CYGDEBUG', enable_debugging)
-xwin_data.set10('CYGWINDOWING_DEBUG',enable_debugging)
-xwin_data.set10('CYGMULTIWINDOW_DEBUG', enable_debugging)
+xwin_data.set10('ENABLE_DEBUG', enable_debugging)
configure_file(output : 'xwin-config.h',
input : 'xwin-config.h.meson.in',
configuration : xwin_data)
+build_xwayland_glamor = build_glamor and gbm_dep.found()
+
xwayland_data = configuration_data()
-xwayland_data.set('XWL_HAS_GLAMOR', build_glamor and (gbm_dep.found() or build_eglstream) ? '1' : false)
-xwayland_data.set('XWL_HAS_EGLSTREAM', build_eglstream ? '1' : false)
+xwayland_data.set('XWL_HAS_GLAMOR', build_xwayland_glamor ? '1' : false)
+xwayland_data.set('XWL_HAS_LIBDECOR', have_libdecor ? '1' : false)
+xwayland_data.set('XWL_HAS_XWAYLAND_EXTENSION', xwaylandproto_dep.found() ? '1' : false)
+xwayland_data.set('XWL_HAS_EI', build_ei)
+xwayland_data.set('XWL_HAS_EI_PORTAL', build_ei_portal)
configure_file(output : 'xwayland-config.h',
input : 'xwayland-config.h.meson.in',
@@ -438,7 +442,6 @@ if build_xorg
'Xprintf.h',
'callback.h',
'client.h',
- 'closestr.h',
'closure.h',
'colormap.h',
'colormapst.h',
@@ -461,7 +464,6 @@ if build_xorg
'gc.h',
'gcstruct.h',
'globals.h',
- 'glx_extinit.h',
'glxvndabi.h',
'input.h',
'inputstr.h',
@@ -480,7 +482,6 @@ if build_xorg
'ptrveloc.h',
'region.h',
'regionstr.h',
- 'registry.h',
'resource.h',
'rgb.h',
'screenint.h',
@@ -496,7 +497,6 @@ if build_xorg
'xkbstr.h',
'xkbrules.h',
'Xprintf.h',
- 'xserver_poll.h',
'xserver-properties.h',
],
install_dir: xorgsdkdir,
diff --git a/include/misc.h b/include/misc.h
index 4b632098b..795cf1890 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -236,10 +236,6 @@ padding_for_int32(const int bytes)
extern _X_EXPORT char **xstrtokenize(const char *str, const char *separators);
-extern void FormatInt64(int64_t num, char *string);
-extern void FormatUInt64(uint64_t num, char *string);
-extern void FormatUInt64Hex(uint64_t num, char *string);
-extern void FormatDouble(double dbl, char *string);
/**
* Compare the two version numbers comprising of major.minor.
@@ -290,7 +286,7 @@ wrong_size(void)
}
#endif
-#if !(defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)))
+#if !(defined(__GNUC__))
static inline int
__builtin_constant_p(int x)
{
diff --git a/include/opaque.h b/include/opaque.h
index 256261c2a..b17380915 100644
--- a/include/opaque.h
+++ b/include/opaque.h
@@ -66,12 +66,14 @@ extern _X_EXPORT int limitStackSpace;
extern _X_EXPORT int limitNoFile;
#endif
extern _X_EXPORT Bool defeatAccessControl;
-extern _X_EXPORT long maxBigRequestSize;
-extern _X_EXPORT Bool party_like_its_1989;
extern _X_EXPORT Bool whiteRoot;
extern _X_EXPORT Bool bgNoneRoot;
extern _X_EXPORT Bool CoreDump;
extern _X_EXPORT Bool NoListenAll;
+extern _X_EXPORT Bool AllowByteSwappedClients;
+
+extern Bool party_like_its_1989; /* -retro mode */
+
#endif /* OPAQUE_H */
diff --git a/include/os.h b/include/os.h
index bb3348b18..a07aedf1a 100644
--- a/include/os.h
+++ b/include/os.h
@@ -50,16 +50,13 @@ SOFTWARE.
#include "misc.h"
#include <stdarg.h>
#include <stdint.h>
+#if defined(HAVE_REALLOCARRAY)
+#include <stdlib.h> /* for reallocarray */
+#endif
#include <string.h>
#ifdef MONOTONIC_CLOCK
#include <time.h>
#endif
-#if defined(HAVE_LIBBSD) && defined(HAVE_REALLOCARRAY)
-#include <bsd/stdlib.h> /* for reallocarray */
-#endif
-#if defined(HAVE_LIBBSD) && defined(HAVE_STRLCPY)
-#include <bsd/string.h> /* for strlcpy, strlcat */
-#endif
#define SCREEN_SAVER_ON 0
#define SCREEN_SAVER_OFF 1
@@ -69,9 +66,6 @@ SOFTWARE.
#ifndef MAX_REQUEST_SIZE
#define MAX_REQUEST_SIZE 65535
#endif
-#ifndef MAX_BIG_REQUEST_SIZE
-#define MAX_BIG_REQUEST_SIZE 4194303
-#endif
typedef struct _FontPathRec *FontPathPtr;
typedef struct _NewClientRec *NewClientPtr;
@@ -96,12 +90,6 @@ typedef struct _NewClientRec *NewClientPtr;
extern void ddxBeforeReset(void);
#endif
-#ifdef DDXOSVERRORF
-extern _X_EXPORT void (*OsVendorVErrorFProc) (const char *,
- va_list args)
-_X_ATTRIBUTE_PRINTF(1, 0);
-#endif
-
extern _X_EXPORT Bool WaitForSomething(Bool clients_are_ready);
extern _X_EXPORT int ReadRequestFromClient(ClientPtr /*client */ );
@@ -159,26 +147,14 @@ static inline void RemoveNotifyFd(int fd)
(void) SetNotifyFd(fd, NULL, X_NOTIFY_NONE, NULL);
}
-extern _X_EXPORT int OnlyListenToOneClient(ClientPtr /*client */ );
-
-extern _X_EXPORT void ListenToAllClients(void);
-
extern _X_EXPORT void IgnoreClient(ClientPtr /*client */ );
extern _X_EXPORT void AttendClient(ClientPtr /*client */ );
-extern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client */ );
-
-extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client */ );
-
extern _X_EXPORT void ListenOnOpenFD(int /* fd */ , int /* noxauth */ );
extern _X_EXPORT Bool AddClientOnOpenFD(int /* fd */ );
-#ifdef MONOTONIC_CLOCK
-extern void ForceClockId(clockid_t /* forced_clockid */);
-#endif
-
extern _X_EXPORT CARD32 GetTimeInMillis(void);
extern _X_EXPORT CARD64 GetTimeInMicros(void);
@@ -190,10 +166,6 @@ typedef CARD32 (*OsTimerCallback) (OsTimerPtr timer,
CARD32 time,
void *arg);
-extern _X_EXPORT void TimerInit(void);
-
-extern _X_EXPORT Bool TimerForce(OsTimerPtr /* timer */ );
-
#define TimerAbsolute (1<<0)
#define TimerForceOld (1<<1)
@@ -210,18 +182,8 @@ extern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */ );
extern _X_EXPORT void SetScreenSaverTimer(void);
extern _X_EXPORT void FreeScreenSaverTimer(void);
-extern _X_EXPORT void AutoResetServer(int /*sig */ );
-
extern _X_EXPORT void GiveUp(int /*sig */ );
-extern _X_EXPORT void UseMsg(void);
-
-extern _X_EXPORT void ProcessCommandLine(int /*argc */ , char * /*argv */ []);
-
-extern _X_EXPORT int set_font_authorizations(char **authorizations,
- int *authlen,
- void *client);
-
/*
* This function malloc(3)s buffer, terminating the server if there is not
* enough memory.
@@ -292,141 +254,19 @@ XNFvprintf(const char *fmt, va_list va)
_X_ATTRIBUTE_PRINTF(1, 0)
_X_DEPRECATED;
-typedef void (*OsSigHandlerPtr) (int /* sig */ );
typedef int (*OsSigWrapperPtr) (int /* sig */ );
-extern _X_EXPORT OsSigHandlerPtr
-OsSignal(int /* sig */ , OsSigHandlerPtr /* handler */ );
extern _X_EXPORT OsSigWrapperPtr
OsRegisterSigWrapper(OsSigWrapperPtr newWrap);
-extern _X_EXPORT int auditTrailLevel;
-
extern _X_EXPORT void
LockServer(void);
extern _X_EXPORT void
UnlockServer(void);
-extern _X_EXPORT int
-OsLookupColor(int /*screen */ ,
- char * /*name */ ,
- unsigned /*len */ ,
- unsigned short * /*pred */ ,
- unsigned short * /*pgreen */ ,
- unsigned short * /*pblue */ );
-
-extern _X_EXPORT void
-OsInit(void);
-
-extern _X_EXPORT void
-OsCleanup(Bool);
-
-extern _X_EXPORT void
-OsVendorFatalError(const char *f, va_list args)
-_X_ATTRIBUTE_PRINTF(1, 0);
-
-extern _X_EXPORT void
-OsVendorInit(void);
-
-extern _X_EXPORT void
-OsBlockSignals(void);
-
-extern _X_EXPORT void
-OsReleaseSignals(void);
-
-extern void
-OsResetSignals(void);
-
-extern _X_EXPORT void
-OsAbort(void)
- _X_NORETURN;
-
-#if !defined(WIN32)
-extern _X_EXPORT int
-System(const char *);
-extern _X_EXPORT void *
-Popen(const char *, const char *);
-extern _X_EXPORT int
-Pclose(void *);
-extern _X_EXPORT void *
-Fopen(const char *, const char *);
-extern _X_EXPORT int
-Fclose(void *);
-#else
-
-extern const char *
-Win32TempDir(void);
-
-extern int
-System(const char *cmdline);
-
-#define Fopen(a,b) fopen(a,b)
-#define Fclose(a) fclose(a)
-#endif
-
extern _X_EXPORT Bool
PrivsElevated(void);
-extern _X_EXPORT void
-CheckUserParameters(int argc, char **argv, char **envp);
-extern _X_EXPORT void
-CheckUserAuthorization(void);
-
-extern _X_EXPORT int
-AddHost(ClientPtr /*client */ ,
- int /*family */ ,
- unsigned /*length */ ,
- const void * /*pAddr */ );
-
-extern _X_EXPORT Bool
-ForEachHostInFamily(int family,
- Bool (*func)(
- unsigned char *addr,
- short len,
- void *closure),
- void *closure);
-
-extern _X_EXPORT int
-RemoveHost(ClientPtr client,
- int family,
- unsigned length,
- void *pAddr);
-
-extern _X_EXPORT int
-GetHosts(void ** /*data */ ,
- int * /*pnHosts */ ,
- int * /*pLen */ ,
- BOOL * /*pEnabled */ );
-
-typedef struct sockaddr *sockaddrPtr;
-
-extern _X_EXPORT int
-InvalidHost(sockaddrPtr /*saddr */ , int /*len */ , ClientPtr client);
-
-#define LCC_UID_SET (1 << 0)
-#define LCC_GID_SET (1 << 1)
-#define LCC_PID_SET (1 << 2)
-#define LCC_ZID_SET (1 << 3)
-
-typedef struct {
- int fieldsSet; /* Bit mask of fields set */
- int euid; /* Effective uid */
- int egid; /* Primary effective group id */
- int nSuppGids; /* Number of supplementary group ids */
- int *pSuppGids; /* Array of supplementary group ids */
- int pid; /* Process id */
- int zoneid; /* Only set on Solaris 10 & later */
-} LocalClientCredRec;
-
-extern _X_EXPORT int
-GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
-
-extern _X_EXPORT void
-FreeLocalClientCreds(LocalClientCredRec *);
-
-extern _X_EXPORT int
-ChangeAccessControl(ClientPtr /*client */ , int /*fEnabled */ );
-
extern _X_EXPORT int
GetClientFd(ClientPtr);
@@ -434,105 +274,8 @@ extern _X_EXPORT Bool
ClientIsLocal(ClientPtr client);
extern _X_EXPORT int
-GetAccessControl(void);
-
-extern _X_EXPORT void
-AddLocalHosts(void);
-
-extern _X_EXPORT void
-ResetHosts(const char *display);
-
-extern _X_EXPORT void
-EnableLocalAccess(void);
-
-extern _X_EXPORT void
-DisableLocalAccess(void);
-
-extern _X_EXPORT void
-EnableLocalHost(void);
-
-extern _X_EXPORT void
-DisableLocalHost(void);
-
-#ifndef NO_LOCAL_CLIENT_CRED
-extern _X_EXPORT void
-EnableLocalUser(void);
-
-extern _X_EXPORT void
-DisableLocalUser(void);
-
-extern _X_EXPORT void
-LocalAccessScopeUser(void);
-#endif
-
-extern _X_EXPORT void
-AccessUsingXdmcp(void);
-
-extern _X_EXPORT void
-DefineSelf(int /*fd */ );
-
-#ifdef XDMCP
-extern _X_EXPORT void
-AugmentSelf(void *from, int len);
-
-extern _X_EXPORT void
-RegisterAuthorizations(void);
-#endif
-
-extern _X_EXPORT void
-InitAuthorization(const char * /*filename */ );
-
-/* extern int LoadAuthorization(void); */
-
-extern _X_EXPORT int
-AuthorizationFromID(XID id,
- unsigned short *name_lenp,
- const char **namep,
- unsigned short *data_lenp, char **datap);
-
-extern _X_EXPORT XID
-CheckAuthorization(unsigned int /*namelength */ ,
- const char * /*name */ ,
- unsigned int /*datalength */ ,
- const char * /*data */ ,
- ClientPtr /*client */ ,
- const char ** /*reason */
- );
-
-extern _X_EXPORT void
-ResetAuthorization(void);
-
-extern _X_EXPORT int
-RemoveAuthorization(unsigned short name_length,
- const char *name,
- unsigned short data_length, const char *data);
-
-extern _X_EXPORT int
-AddAuthorization(unsigned int /*name_length */ ,
- const char * /*name */ ,
- unsigned int /*data_length */ ,
- char * /*data */ );
-
-#ifdef XCSECURITY
-extern _X_EXPORT XID
-GenerateAuthorization(unsigned int /* name_length */ ,
- const char * /* name */ ,
- unsigned int /* data_length */ ,
- const char * /* data */ ,
- unsigned int * /* data_length_return */ ,
- char ** /* data_return */ );
-#endif
-
-extern _X_EXPORT int
ddxProcessArgument(int /*argc */ , char * /*argv */ [], int /*i */ );
-#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \
- do if (((i + num) >= argc) || (!argv[i + num])) { \
- UseMsg(); \
- FatalError("Required argument to %s not specified\n", argv[i]); \
- } while (0)
-
-
extern _X_EXPORT void
ddxUseMsg(void);
@@ -680,14 +423,6 @@ _X_ATTRIBUTE_PRINTF(2, 0)
_X_ATTRIBUTE_PRINTF(4, 5);
extern _X_EXPORT void
-FreeAuditTimer(void);
-extern _X_EXPORT void
-AuditF(const char *f, ...)
-_X_ATTRIBUTE_PRINTF(1, 2);
-extern _X_EXPORT void
-VAuditF(const char *f, va_list args)
-_X_ATTRIBUTE_PRINTF(1, 0);
-extern _X_EXPORT void
FatalError(const char *f, ...)
_X_ATTRIBUTE_PRINTF(1, 2)
_X_NORETURN;
@@ -716,16 +451,10 @@ LogPrintMarkers(void);
extern _X_EXPORT void
xorg_backtrace(void);
-extern _X_EXPORT int
-os_move_fd(int fd);
-
#include <signal.h>
#if defined(WIN32) && !defined(__CYGWIN__)
typedef _sigset_t sigset_t;
#endif
-extern _X_EXPORT int
-xthread_sigmask(int how, const sigset_t *set, sigset_t *oldest);
-
#endif /* OS_H */
diff --git a/include/pixmap.h b/include/pixmap.h
index 7144bfb30..be6df9890 100644
--- a/include/pixmap.h
+++ b/include/pixmap.h
@@ -103,9 +103,7 @@ extern _X_EXPORT PixmapPtr GetScratchPixmapHeader(ScreenPtr pScreen,
extern _X_EXPORT void FreeScratchPixmapHeader(PixmapPtr /*pPixmap */ );
-extern _X_EXPORT Bool CreateScratchPixmapsForScreen(ScreenPtr /*pScreen */ );
-
-extern _X_EXPORT void FreeScratchPixmapsForScreen(ScreenPtr /*pScreen */ );
+extern _X_EXPORT Bool PixmapScreenInit(ScreenPtr /*pScreen */ );
extern _X_EXPORT PixmapPtr AllocatePixmap(ScreenPtr /*pScreen */ ,
int /*pixDataSize */ );
@@ -134,4 +132,9 @@ PixmapStopDirtyTracking(DrawablePtr src, PixmapPtr slave_dst);
extern _X_EXPORT Bool
PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty);
+extern _X_EXPORT void
+PixmapDirtyCopyArea(PixmapPtr dst, DrawablePtr src,
+ int x, int y, int dst_x, int dst_y,
+ RegionPtr dirty_region);
+
#endif /* PIXMAP_H */
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index faf54fa4d..54fc26508 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -78,7 +78,7 @@ typedef struct _Pixmap {
int refcnt;
int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */
DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
short screen_x;
short screen_y;
#endif
diff --git a/include/probes.h b/include/probes.h
index f2ed40fe3..b7d69f57c 100644
--- a/include/probes.h
+++ b/include/probes.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index d7bfc6dca..677b02ab7 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -46,14 +46,13 @@
#define SERVER_DAMAGE_MAJOR_VERSION 1
#define SERVER_DAMAGE_MINOR_VERSION 1
+/* DPMS */
+#define SERVER_DPMS_MAJOR_VERSION 1
+#define SERVER_DPMS_MINOR_VERSION 2
+
/* DRI3 */
#define SERVER_DRI3_MAJOR_VERSION 1
-#define SERVER_DRI3_MINOR_VERSION 2
-
-/* DMX */
-#define SERVER_DMX_MAJOR_VERSION 2
-#define SERVER_DMX_MINOR_VERSION 2
-#define SERVER_DMX_PATCH_VERSION 20040604
+#define SERVER_DRI3_MINOR_VERSION 4
/* Generic event extension */
#define SERVER_GE_MAJOR_VERSION 1
@@ -69,7 +68,11 @@
/* Present */
#define SERVER_PRESENT_MAJOR_VERSION 1
-#define SERVER_PRESENT_MINOR_VERSION 2
+#ifdef DRI3
+#define SERVER_PRESENT_MINOR_VERSION 4
+#else
+#define SERVER_PRESENT_MINOR_VERSION 3
+#endif
/* RandR */
#define SERVER_RANDR_MAJOR_VERSION 1
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 3bd982a90..6a22581b1 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -51,16 +51,7 @@ typedef double (*PointerAccelerationProfileFunc)
(DeviceIntPtr dev, struct _DeviceVelocityRec * vel,
double velocity, double threshold, double accelCoeff);
-/**
- * a motion history, with just enough information to
- * calc mean velocity and decide which motion was along
- * a more or less straight line
- */
-typedef struct _MotionTracker {
- double dx, dy; /* accumulated delta for each axis */
- int time; /* time of creation */
- int dir; /* initial direction bitfield */
-} MotionTracker, *MotionTrackerPtr;
+typedef struct _MotionTracker MotionTracker, *MotionTrackerPtr;
/**
* Contains all data needed to implement mouse ballistics
@@ -90,35 +81,6 @@ typedef struct _DeviceVelocityRec {
} statistics;
} DeviceVelocityRec, *DeviceVelocityPtr;
-/**
- * contains the run-time data for the predictable scheme, that is, a
- * DeviceVelocityPtr and the property handlers.
- */
-typedef struct _PredictableAccelSchemeRec {
- DeviceVelocityPtr vel;
- long *prop_handlers;
- int num_prop_handlers;
-} PredictableAccelSchemeRec, *PredictableAccelSchemePtr;
-
-extern _X_EXPORT void
-InitVelocityData(DeviceVelocityPtr vel);
-
-extern _X_EXPORT void
-InitTrackers(DeviceVelocityPtr vel, int ntracker);
-
-extern _X_EXPORT BOOL
-ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time);
-
-extern _X_EXPORT double
-BasicComputeAcceleration(DeviceIntPtr dev, DeviceVelocityPtr vel,
- double velocity, double threshold, double acc);
-
-extern _X_EXPORT void
-FreeVelocityData(DeviceVelocityPtr vel);
-
-extern _X_EXPORT int
-SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
-
extern _X_EXPORT DeviceVelocityPtr
GetDevicePredictableAccelData(DeviceIntPtr dev);
@@ -126,19 +88,4 @@ extern _X_EXPORT void
SetDeviceSpecificAccelerationProfile(DeviceVelocityPtr vel,
PointerAccelerationProfileFunc profile);
-extern _X_INTERNAL void
-AccelerationDefaultCleanup(DeviceIntPtr dev);
-
-extern _X_INTERNAL Bool
-InitPredictableAccelerationScheme(DeviceIntPtr dev,
- struct _ValuatorAccelerationRec *protoScheme);
-
-extern _X_INTERNAL void
-acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask *val,
- CARD32 evtime);
-
-extern _X_INTERNAL void
-acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask *val,
- CARD32 evtime);
-
#endif /* POINTERVELOCITY_H */
diff --git a/include/registry.h b/include/registry.h
deleted file mode 100644
index f50fa7622..000000000
--- a/include/registry.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/***********************************************************
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-******************************************************************/
-
-#ifndef DIX_REGISTRY_H
-#define DIX_REGISTRY_H
-
-/*
- * Result returned from any unsuccessful lookup
- */
-#define XREGISTRY_UNKNOWN "<unknown>"
-
-#include "resource.h"
-#include "extnsionst.h"
-
-#if defined(XSELINUX) || defined(RES)
-#define X_REGISTRY_RESOURCE 1
-#endif
-
-#if defined(XSELINUX) || defined(XCSECURITY) || defined(XSERVER_DTRACE)
-#define X_REGISTRY_REQUEST 1
-#endif
-
-/* Internal string registry - for auditing, debugging, security, etc. */
-
-#ifdef X_REGISTRY_RESOURCE
-/* Functions used by the X-Resource extension */
-extern _X_EXPORT void RegisterResourceName(RESTYPE type, const char *name);
-extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
-#endif
-
-#ifdef X_REGISTRY_REQUEST
-extern _X_EXPORT void RegisterExtensionNames(ExtensionEntry * ext);
-
-/*
- * Lookup functions. The returned string must not be modified or freed.
- */
-extern _X_EXPORT const char *LookupMajorName(int major);
-extern _X_EXPORT const char *LookupRequestName(int major, int minor);
-extern _X_EXPORT const char *LookupEventName(int event);
-extern _X_EXPORT const char *LookupErrorName(int error);
-#endif
-
-/*
- * Setup and teardown
- */
-extern _X_EXPORT void dixResetRegistry(void);
-extern _X_EXPORT void dixFreeRegistry(void);
-extern _X_EXPORT void dixCloseRegistry(void);
-
-#endif /* DIX_REGISTRY_H */
diff --git a/include/resource.h b/include/resource.h
index 6caf846c4..a48735ba0 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -71,19 +71,33 @@ typedef uint32_t RESTYPE;
/* types for Resource routines */
-#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
-#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
-#define RT_GC ((RESTYPE)3)
+// prevent namespace clash with Windows
+#define X11_RESTYPE_NONE ((RESTYPE)0)
+#define X11_RESTYPE_WINDOW ((RESTYPE)1|RC_DRAWABLE)
+#define X11_RESTYPE_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
+#define X11_RESTYPE_GC ((RESTYPE)3)
+#define X11_RESTYPE_FONT ((RESTYPE)4)
+#define X11_RESTYPE_CURSOR ((RESTYPE)5)
+#define X11_RESTYPE_COLORMAP ((RESTYPE)6)
+#define X11_RESTYPE_CMAPENTRY ((RESTYPE)7)
+#define X11_RESTYPE_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
+#define X11_RESTYPE_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
+#define X11_RESTYPE_LASTPREDEF ((RESTYPE)9)
+
+#define RT_WINDOW X11_RESTYPE_WINDOW
+#define RT_PIXMAP X11_RESTYPE_PIXMAP
+#define RT_GC X11_RESTYPE_GC
#undef RT_FONT
#undef RT_CURSOR
-#define RT_FONT ((RESTYPE)4)
-#define RT_CURSOR ((RESTYPE)5)
-#define RT_COLORMAP ((RESTYPE)6)
-#define RT_CMAPENTRY ((RESTYPE)7)
-#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
-#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
-#define RT_LASTPREDEF ((RESTYPE)9)
-#define RT_NONE ((RESTYPE)0)
+#define RT_FONT X11_RESTYPE_FONT
+#define RT_CURSOR X11_RESTYPE_CURSOR
+#define RT_COLORMAP X11_RESTYPE_COLORMAP
+#define RT_CMAPENTRY X11_RESTYPE_CMAPENTRY
+#define RT_OTHERCLIENT X11_RESTYPE_OTHERCLIENT
+#define RT_PASSIVEGRAB X11_RESTYPE_PASSIVEGRAB
+#define RT_LASTPREDEF X11_RESTYPE_LASTPREDEF
+#define RT_NONE X11_RESTYPE_NONE
+
extern _X_EXPORT unsigned int ResourceClientBits(void);
/* bits and fields within a resource id */
diff --git a/include/screenint.h b/include/screenint.h
index 0a4527832..e136f31cf 100644
--- a/include/screenint.h
+++ b/include/screenint.h
@@ -53,30 +53,6 @@ typedef struct _PixmapFormat *PixmapFormatPtr;
typedef struct _Visual *VisualPtr;
typedef struct _Depth *DepthPtr;
typedef struct _Screen *ScreenPtr;
-
-typedef Bool (*ScreenInitProcPtr)(ScreenPtr pScreen, int argc, char **argv);
-extern _X_EXPORT int AddScreen(ScreenInitProcPtr pfnInit, int argc, char **argv);
-extern _X_EXPORT int AddGPUScreen(ScreenInitProcPtr pfnInit, int argc, char **argv);
-
-extern _X_EXPORT void RemoveGPUScreen(ScreenPtr pScreen);
-
-extern _X_EXPORT void
-AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr newScreen);
-extern _X_EXPORT void
-DetachUnboundGPU(ScreenPtr unbound);
-
-extern _X_EXPORT void
-AttachOutputGPU(ScreenPtr pScreen, ScreenPtr newScreen);
-
-extern _X_EXPORT void
-DetachOutputGPU(ScreenPtr output);
-
-extern _X_EXPORT void
-AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr newScreen);
-
-extern _X_EXPORT void
-DetachOffloadGPU(ScreenPtr slave);
-
typedef struct _ColormapRec *ColormapPtr;
#endif /* SCREENINT_H */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 24ca423f2..98f47bf51 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -604,8 +604,6 @@ typedef struct _Screen {
SetScreenPixmapProcPtr SetScreenPixmap;
NameWindowPixmapProcPtr NameWindowPixmap;
- PixmapPtr pScratchPixmap; /* scratch pixmap "pool" */
-
unsigned int totalPixmapSize;
MarkWindowProcPtr MarkWindow;
diff --git a/include/xkbfile.h b/include/xkbfile.h
index f93d31ab0..2bd43683a 100644
--- a/include/xkbfile.h
+++ b/include/xkbfile.h
@@ -207,10 +207,6 @@ extern _X_EXPORT unsigned XkbConvertGetByNameComponents(Bool /* toXkm */ ,
unsigned /* orig */
);
-extern _X_EXPORT Bool XkbNameMatchesPattern(char * /* name */ ,
- char * /* pattern */
- );
-
/***====================================================================***/
extern _X_EXPORT Bool XkbWriteXKBKeycodes(FILE * /* file */ ,
@@ -263,9 +259,6 @@ extern _X_EXPORT Bool XkbWriteXKBKeymapForNames(FILE * /* file */ ,
/***====================================================================***/
-extern _X_EXPORT Bool XkmProbe(FILE * /* file */
- );
-
extern _X_EXPORT unsigned XkmReadFile(FILE * /* file */ ,
unsigned /* need */ ,
unsigned /* want */ ,
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index fbb5427e1..45564e2f4 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -104,12 +104,6 @@ typedef struct _XkbEventCause {
#define XkbSetCauseXkbReq(c,e,cl) XkbSetCauseReq(c,XkbReqCode,e,cl)
#define XkbSetCauseUnknown(c) XkbSetCauseKey(c,0,0)
-#define _OFF_TIMER 0
-#define _KRG_WARN_TIMER 1
-#define _KRG_TIMER 2
-#define _SK_TIMEOUT_TIMER 3
-#define _ALL_TIMEOUT_TIMER 4
-
#define _BEEP_NONE 0
#define _BEEP_FEATURE_ON 1
#define _BEEP_FEATURE_OFF 2
@@ -460,13 +454,6 @@ extern _X_EXPORT XkbAction *XkbResizeKeyActions(XkbDescPtr /* xkb */ ,
int /* needed */
);
-extern _X_EXPORT void XkbUpdateKeyTypesFromCore(DeviceIntPtr /* pXDev */ ,
- KeySymsPtr /* syms */ ,
- KeyCode /* first */ ,
- CARD8 /* num */ ,
- XkbChangesPtr /* pChanges */
- );
-
extern _X_EXPORT void XkbUpdateDescActions(XkbDescPtr /* xkb */ ,
KeyCode /* first */ ,
CARD8 /* num */ ,
@@ -505,6 +492,8 @@ extern _X_EXPORT void XkbUpdateIndicators(DeviceIntPtr /* keybd */ ,
XkbEventCausePtr /* cause */
);
+extern void XkbForceUpdateDeviceLEDs(DeviceIntPtr /* keybd */);
+
extern _X_EXPORT void XkbUpdateAllDeviceIndicators(XkbChangesPtr /* changes */,
XkbEventCausePtr /* cause */
);
@@ -779,9 +768,6 @@ extern _X_EXPORT void XkbDeleteRulesDflts(void
extern _X_EXPORT void XkbDeleteRulesUsed(void
);
-extern _X_EXPORT int SProcXkbDispatch(ClientPtr /* client */
- );
-
extern _X_EXPORT XkbGeometryPtr XkbLookupNamedGeometry(DeviceIntPtr /* dev */ ,
Atom /* name */ ,
Bool * /* shouldFree */
@@ -863,13 +849,6 @@ extern _X_EXPORT void XkbCopyControls(XkbDescPtr /* dst */ ,
#include "xkbfile.h"
#include "xkbrules.h"
-#define _XkbListKeycodes 0
-#define _XkbListTypes 1
-#define _XkbListCompat 2
-#define _XkbListSymbols 3
-#define _XkbListGeometry 4
-#define _XkbListNumComponents 5
-
extern _X_EXPORT unsigned int XkbDDXLoadKeymapByNames(DeviceIntPtr /* keybd */ ,
XkbComponentNamesPtr
/* names */ ,
diff --git a/include/xkbstr.h b/include/xkbstr.h
index 8a9f01c68..749f1f26e 100644
--- a/include/xkbstr.h
+++ b/include/xkbstr.h
@@ -27,6 +27,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef _XKBSTR_H_
#define _XKBSTR_H_
+#include <X11/Xdefs.h>
#include <X11/extensions/XKB.h>
#define XkbCharToInt(v) ((int) ((v) & 0x80 ? ((v) | (~0xff)) : ((v) & 0x7f)))
diff --git a/include/xorg-config.h.meson.in b/include/xorg-config.h.meson.in
index 59f1c2a8d..192c340dc 100644
--- a/include/xorg-config.h.meson.in
+++ b/include/xorg-config.h.meson.in
@@ -145,4 +145,7 @@
/* Fallback input driver if the assigned driver fails */
#mesondefine FALLBACK_INPUT_DRIVER
+/* Define if building the modesetting driver */
+#mesondefine HAVE_MODESETTING_DRIVER
+
#endif /* _XORG_CONFIG_H_ */
diff --git a/include/xorg-server.h.meson.in b/include/xorg-server.h.meson.in
index 093801cad..1ffc58548 100644
--- a/include/xorg-server.h.meson.in
+++ b/include/xorg-server.h.meson.in
@@ -41,9 +41,6 @@
/* Support XDM-AUTH*-1 */
#mesondefine HASXDMAUTH
-/* Support SHM */
-#mesondefine HAS_SHM
-
/* Define to 1 if you have the `reallocarray' function. */
#mesondefine HAVE_REALLOCARRAY
diff --git a/include/xwayland-config.h.meson.in b/include/xwayland-config.h.meson.in
index 0943ff57d..17ca8fcb0 100644
--- a/include/xwayland-config.h.meson.in
+++ b/include/xwayland-config.h.meson.in
@@ -7,5 +7,14 @@
/* Build glamor support for Xwayland */
#mesondefine XWL_HAS_GLAMOR
-/* Build eglstream support for Xwayland */
-#mesondefine XWL_HAS_EGLSTREAM
+/* Build Xwayland with libdecor support*/
+#mesondefine XWL_HAS_LIBDECOR
+
+/* Build Xwayland with XWAYLAND extension */
+#mesondefine XWL_HAS_XWAYLAND_EXTENSION
+
+/* Enable EI */
+#mesondefine XWL_HAS_EI
+
+/* Enable XDG portal integration */
+#mesondefine XWL_HAS_EI_PORTAL
diff --git a/include/xwin-config.h.meson.in b/include/xwin-config.h.meson.in
index 993227398..e2f4ada61 100644
--- a/include/xwin-config.h.meson.in
+++ b/include/xwin-config.h.meson.in
@@ -13,9 +13,7 @@
#mesondefine HAS_DEVWINDOWS
/* Switch on debug messages */
-#mesondefine CYGDEBUG
-#mesondefine CYGWINDOWING_DEBUG
-#mesondefine CYGMULTIWINDOW_DEBUG
+#mesondefine ENABLE_DEBUG
/* Default log location */
#mesondefine DEFAULT_LOGDIR
diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4
deleted file mode 100644
index db42d3eb0..000000000
--- a/m4/ac_define_dir.m4
+++ /dev/null
@@ -1,49 +0,0 @@
-# ===========================================================================
-# http://autoconf-archive.cryp.to/ac_define_dir.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
-#
-# DESCRIPTION
-#
-# This macro sets VARNAME to the expansion of the DIR variable, taking
-# care of fixing up ${prefix} and such.
-#
-# VARNAME is then offered as both an output variable and a C preprocessor
-# symbol.
-#
-# Example:
-#
-# AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
-#
-# LAST MODIFICATION
-#
-# 2008-04-12
-#
-# COPYLEFT
-#
-# Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz>
-# Copyright (c) 2008 Andreas Schwab <schwab@suse.de>
-# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
-# Copyright (c) 2008 Alexandre Oliva
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
-
-AC_DEFUN([AC_DEFINE_DIR], [
- prefix_NONE=
- exec_prefix_NONE=
- test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
- test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
-dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
-dnl refers to ${prefix}. Thus we have to use `eval' twice.
- eval ac_define_dir="\"[$]$2\""
- eval ac_define_dir="\"$ac_define_dir\""
- AC_SUBST($1, "$ac_define_dir")
- AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
- test "$prefix_NONE" && prefix=NONE
- test "$exec_prefix_NONE" && exec_prefix=NONE
-])
diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
deleted file mode 100644
index e77541cea..000000000
--- a/m4/ax_pthread.m4
+++ /dev/null
@@ -1,337 +0,0 @@
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
-#
-# DESCRIPTION
-#
-# This macro figures out how to build C programs using POSIX threads. It
-# sets the PTHREAD_LIBS output variable to the threads library and linker
-# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
-# flags that are needed. (The user can also force certain compiler
-# flags/libs to be tested by setting these environment variables.)
-#
-# Also sets PTHREAD_CC to any special C compiler that is needed for
-# multi-threaded programs (defaults to the value of CC otherwise). (This
-# is necessary on AIX to use the special cc_r compiler alias.)
-#
-# NOTE: You are assumed to not only compile your program with these flags,
-# but also link it with them as well. e.g. you should link with
-# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
-#
-# If you are only building threads programs, you may wish to use these
-# variables in your default LIBS, CFLAGS, and CC:
-#
-# LIBS="$PTHREAD_LIBS $LIBS"
-# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-# CC="$PTHREAD_CC"
-#
-# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
-# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
-# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
-#
-# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
-# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
-# PTHREAD_CFLAGS.
-#
-# ACTION-IF-FOUND is a list of shell commands to run if a threads library
-# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
-# is not found. If ACTION-IF-FOUND is not specified, the default action
-# will define HAVE_PTHREAD.
-#
-# Please let the authors know if this macro fails on any platform, or if
-# you have any other suggestions or comments. This macro was based on work
-# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
-# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
-# Alejandro Forero Cuervo to the autoconf macro repository. We are also
-# grateful for the helpful feedback of numerous users.
-#
-# Updated for Autoconf 2.68 by Daniel Richard G.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
-# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
-
-#serial 21
-
-AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
-AC_DEFUN([AX_PTHREAD], [
-AC_REQUIRE([AC_CANONICAL_HOST])
-AC_LANG_PUSH([C])
-ax_pthread_ok=no
-
-# We used to check for pthread.h first, but this fails if pthread.h
-# requires special compiler flags (e.g. on True64 or Sequent).
-# It gets checked for in the link test anyway.
-
-# First of all, check if the user has set any of the PTHREAD_LIBS,
-# etcetera environment variables, and if threads linking works using
-# them:
-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
- AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
- AC_MSG_RESULT([$ax_pthread_ok])
- if test x"$ax_pthread_ok" = xno; then
- PTHREAD_LIBS=""
- PTHREAD_CFLAGS=""
- fi
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-fi
-
-# We must check for the threads library under a number of different
-# names; the ordering is very important because some systems
-# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
-# libraries is broken (non-POSIX).
-
-# Create a list of thread flags to try. Items starting with a "-" are
-# C compiler flags, and other items are library names, except for "none"
-# which indicates that we try without any flags at all, and "pthread-config"
-# which is a program returning the flags for the Pth emulation library.
-
-ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
-
-# The ordering *is* (sometimes) important. Some notes on the
-# individual items follow:
-
-# pthreads: AIX (must check this before -lpthread)
-# none: in case threads are in libc; should be tried before -Kthread and
-# other compiler flags to prevent continual compiler warnings
-# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
-# -pthreads: Solaris/gcc
-# -mthreads: Mingw32/gcc, Lynx/gcc
-# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
-# doesn't hurt to check since this sometimes defines pthreads too;
-# also defines -D_REENTRANT)
-# ... -mt is also the pthreads flag for HP/aCC
-# pthread: Linux, etcetera
-# --thread-safe: KAI C++
-# pthread-config: use pthread-config program (for GNU Pth library)
-
-case ${host_os} in
- solaris*)
-
- # On Solaris (at least, for some versions), libc contains stubbed
- # (non-functional) versions of the pthreads routines, so link-based
- # tests will erroneously succeed. (We need to link with -pthreads/-mt/
- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
- # a function called by this macro, so we could check for that, but
- # who knows whether they'll stub that too in a future libc.) So,
- # we'll just look for -pthreads and -lpthread first:
-
- ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
- ;;
-
- darwin*)
- ax_pthread_flags="-pthread $ax_pthread_flags"
- ;;
- netbsd*)
- # use libc stubs, don't link against libpthread, to allow
- # dynamic loading
- ax_pthread_flags=""
- ;;
-esac
-
-# Clang doesn't consider unrecognized options an error unless we specify
-# -Werror. We throw in some extra Clang-specific options to ensure that
-# this doesn't happen for GCC, which also accepts -Werror.
-
-AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
-save_CFLAGS="$CFLAGS"
-ax_pthread_extra_flags="-Werror"
-CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
- [AC_MSG_RESULT([yes])],
- [ax_pthread_extra_flags=
- AC_MSG_RESULT([no])])
-CFLAGS="$save_CFLAGS"
-
-if test x"$ax_pthread_ok" = xno; then
-for flag in $ax_pthread_flags; do
-
- case $flag in
- none)
- AC_MSG_CHECKING([whether pthreads work without any flags])
- ;;
-
- -*)
- AC_MSG_CHECKING([whether pthreads work with $flag])
- PTHREAD_CFLAGS="$flag"
- ;;
-
- pthread-config)
- AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
- if test x"$ax_pthread_config" = xno; then continue; fi
- PTHREAD_CFLAGS="`pthread-config --cflags`"
- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
- ;;
-
- *)
- AC_MSG_CHECKING([for the pthreads library -l$flag])
- PTHREAD_LIBS="-l$flag"
- ;;
- esac
-
- save_LIBS="$LIBS"
- save_CFLAGS="$CFLAGS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
-
- # Check for various functions. We must include pthread.h,
- # since some functions may be macros. (On the Sequent, we
- # need a special flag -Kthread to make this header compile.)
- # We check for pthread_join because it is in -lpthread on IRIX
- # while pthread_create is in libc. We check for pthread_attr_init
- # due to DEC craziness with -lpthreads. We check for
- # pthread_cleanup_push because it is one of the few pthread
- # functions on Solaris that doesn't have a non-functional libc stub.
- # We try pthread_create on general principles.
- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
- static void routine(void *a) { a = 0; }
- static void *start_routine(void *a) { return a; }],
- [pthread_t th; pthread_attr_t attr;
- pthread_create(&th, 0, start_routine, 0);
- pthread_join(th, 0);
- pthread_attr_init(&attr);
- pthread_cleanup_push(routine, 0);
- pthread_cleanup_pop(0) /* ; */])],
- [ax_pthread_ok=yes],
- [])
-
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-
- AC_MSG_RESULT([$ax_pthread_ok])
- if test "x$ax_pthread_ok" = xyes; then
- break;
- fi
-
- PTHREAD_LIBS=""
- PTHREAD_CFLAGS=""
-done
-fi
-
-# Various other checks:
-if test "x$ax_pthread_ok" = xyes; then
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
- # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
- AC_MSG_CHECKING([for joinable pthread attribute])
- attr_name=unknown
- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
- [int attr = $attr; return attr /* ; */])],
- [attr_name=$attr; break],
- [])
- done
- AC_MSG_RESULT([$attr_name])
- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
- AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
- [Define to necessary symbol if this constant
- uses a non-standard name on your system.])
- fi
-
- AC_MSG_CHECKING([if more special flags are required for pthreads])
- flag=no
- case ${host_os} in
- aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
- osf* | hpux*) flag="-D_REENTRANT";;
- solaris*)
- if test "$GCC" = "yes"; then
- flag="-D_REENTRANT"
- else
- # TODO: What about Clang on Solaris?
- flag="-mt -D_REENTRANT"
- fi
- ;;
- esac
- AC_MSG_RESULT([$flag])
- if test "x$flag" != xno; then
- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
- fi
-
- AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
- [ax_cv_PTHREAD_PRIO_INHERIT], [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
- [[int i = PTHREAD_PRIO_INHERIT;]])],
- [ax_cv_PTHREAD_PRIO_INHERIT=yes],
- [ax_cv_PTHREAD_PRIO_INHERIT=no])
- ])
- AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
- [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
-
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-
- # More AIX lossage: compile with *_r variant
- if test "x$GCC" != xyes; then
- case $host_os in
- aix*)
- AS_CASE(["x/$CC"],
- [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
- [#handle absolute path differently from PATH based program lookup
- AS_CASE(["x$CC"],
- [x/*],
- [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
- [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
- ;;
- esac
- fi
-fi
-
-test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
-
-AC_SUBST([PTHREAD_LIBS])
-AC_SUBST([PTHREAD_CFLAGS])
-AC_SUBST([PTHREAD_CC])
-
-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-if test x"$ax_pthread_ok" = xyes; then
- ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
- :
-else
- ax_pthread_ok=no
- $2
-fi
-AC_LANG_POP
-])dnl AX_PTHREAD
diff --git a/man/Xserver.man b/man/Xserver.man
index 764bd1d90..a9aad463b 100644
--- a/man/Xserver.man
+++ b/man/Xserver.man
@@ -114,6 +114,13 @@ pattern. This is the default unless -retro or -wr is specified.
.B \-bs
disables backing store support on all screens.
.TP 8
+.B \+byteswappedclients
+Allow connections from clients with an endianess different to that of the server.
+.TP 8
+.B \-byteswappedclients
+Prohibit connections from clients with an endianess different to that of the server.
+This is the default unless \fB\+byteswappedclients\fP is specified.
+.TP 8
.B \-c
turns off key-click.
.TP 8
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 000000000..2961469c5
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,36 @@
+manpage_config = configuration_data()
+manpage_config.set('vendorversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
+manpage_config.set('xorgversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
+manpage_config.set('xservername', 'Xorg')
+manpage_config.set('xconfigfile', 'xorg.conf')
+manpage_config.set('projectroot', get_option('prefix'))
+manpage_config.set('apploaddir', '$(appdefaultdir)')
+manpage_config.set('appmansuffix', '1')
+manpage_config.set('drivermansuffix', '4')
+manpage_config.set('adminmansuffix', '8')
+manpage_config.set('libmansuffix', '3')
+manpage_config.set('miscmansuffix', '7')
+manpage_config.set('filemansuffix', '5')
+manpage_config.set('logdir', log_dir)
+manpage_config.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
+manpage_config.set('mandir', join_paths(get_option('prefix'), get_option('mandir')))
+manpage_config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir')))
+manpage_config.set('xconfigdir', 'xorg.conf.d')
+manpage_config.set('xkbdir', xkb_dir)
+manpage_config.set('XKB_DFLT_RULES', get_option('xkb_default_rules'))
+manpage_config.set('XKB_DFLT_MODEL', get_option('xkb_default_model'))
+manpage_config.set('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
+manpage_config.set('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
+manpage_config.set('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
+manpage_config.set('bundle_id_prefix', '...')
+manpage_config.set('modulepath', module_dir)
+# wtf doesn't this work
+# manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), libexecdir))
+manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec'))
+manpage_config.set('default_font_path', default_font_path)
+
+install_man(configure_file(
+ input: 'Xserver.man',
+ output: 'Xserver.1',
+ configuration: manpage_config,
+))
diff --git a/meson.build b/meson.build
index 0793f0e54..94dea6970 100644
--- a/meson.build
+++ b/meson.build
@@ -4,7 +4,7 @@ project('xserver', 'c',
'c_std=gnu99',
],
version: '21.1.99.1',
- meson_version: '>= 0.47.0',
+ meson_version: '>= 0.56.0',
)
release_date = '2021-07-05'
@@ -60,14 +60,16 @@ endforeach
add_project_arguments(common_wflags, language : ['c', 'objc'])
-libdrm_req = '>= 2.4.89'
+libdrm_req = '>= 2.4.116'
libselinux_req = '>= 2.0.86'
xext_req = '>= 1.0.99.4'
-wayland_req = '>= 1.5.0'
-wayland_protocols_req = '>= 1.22'
+wayland_req = '>= 1.21.0'
+wayland_protocols_req = '>= 1.34'
gbm_req = '>= 10.2'
xf86dgaproto_req = '>= 2.0.99.1'
+xshmfence_req = '>= 1.1'
+x11_dep = dependency('x11')
xproto_dep = dependency('xproto', version: '>= 7.0.31', fallback: ['xorgproto', 'ext_xorgproto'])
randrproto_dep = dependency('randrproto', version: '>= 1.6.0', fallback: ['xorgproto', 'ext_xorgproto'])
renderproto_dep = dependency('renderproto', version: '>= 0.11', fallback: ['xorgproto', 'ext_xorgproto'])
@@ -79,6 +81,7 @@ fixesproto_dep = dependency('fixesproto', version: '>= 6.0', fallback: ['xorgpro
damageproto_dep = dependency('damageproto', version: '>= 1.1', fallback: ['xorgproto', 'ext_xorgproto'])
xcmiscproto_dep = dependency('xcmiscproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'])
bigreqsproto_dep = dependency('bigreqsproto', version: '>= 1.1.0', fallback: ['xorgproto', 'ext_xorgproto'])
+presentproto_dep = dependency('presentproto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'])
xtrans_dep = dependency('xtrans', version: '>= 1.3.5')
videoproto_dep = dependency('videoproto', fallback: ['xorgproto', 'ext_xorgproto'])
@@ -88,15 +91,17 @@ scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1', fallback: [
resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'])
xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri1') == 'true')
dri2proto_dep = dependency('dri2proto', version: '>= 2.8', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri2') == 'true')
-dri3proto_dep = dependency('dri3proto', version: '>= 1.2', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri3') == 'true')
+dri3proto_dep = dependency('dri3proto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri3') == 'true')
xineramaproto_dep = dependency('xineramaproto', fallback: ['xorgproto', 'ext_xorgproto'])
xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('xf86bigfont'))
xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
applewmproto_dep = dependency('applewmproto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'], required: false)
-xshmfence_dep = dependency('xshmfence', version: '>= 1.1', required: false)
+xshmfence_dep = dependency('xshmfence', version: xshmfence_req, required: false)
+xwaylandproto_dep = dependency('xwaylandproto', version: '>= 1.0', fallback: ['xorgproto', 'ext_xorgproto'], required: false)
+dpmsproto_dep = dependency('dpmsproto', version: '>= 1.2', required: get_option('dpms'))
pixman_dep = dependency('pixman-1')
-libbsd_dep = dependency('libbsd', required: false)
+libbsd_dep = dependency('libbsd-overlay', required: false)
xkbcomp_dep = dependency('xkbcomp', required: false)
xkbfile_dep = dependency('xkbfile')
xfont2_dep = dependency('xfont2', version: '>= 2.0')
@@ -104,6 +109,7 @@ xfont2_dep = dependency('xfont2', version: '>= 2.0')
dbus_required = get_option('systemd_logind') == 'true'
dbus_dep = dependency('dbus-1', version: '>= 1.0', required: dbus_required)
+build_systemd = get_option('systemd_notify') == 'true'
# libsystemd-daemon was moved into libsystemd in version 209
libsystemd_daemon_dep = dependency('libsystemd', version: '>= 209', required: false)
if not libsystemd_daemon_dep.found()
@@ -116,7 +122,7 @@ build_hashtable = false
xkb_dir = get_option('xkb_dir')
if xkb_dir == ''
if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
- xkb_dir = xkbcomp_dep.get_pkgconfig_variable('xkbconfigdir')
+ xkb_dir = xkbcomp_dep.get_variable(pkgconfig : 'xkbconfigdir')
endif
if xkb_dir == ''
xkb_dir = join_paths(get_option('prefix'), 'share/X11/xkb')
@@ -131,7 +137,7 @@ endif
xkb_bin_dir = get_option('xkb_bin_dir')
if xkb_bin_dir == ''
if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
- xkb_bin_dir = xkbcomp_dep.get_pkgconfig_variable('bindir')
+ xkb_bin_dir = xkbcomp_dep.get_variable(pkgconfig : 'bindir')
endif
if xkb_bin_dir == ''
xkb_bin_dir = join_paths(get_option('prefix'), get_option('bindir'))
@@ -140,8 +146,15 @@ endif
dfp = get_option('default_font_path')
if dfp == ''
- fontutil_dep = dependency('fontutil')
- fontrootdir = fontutil_dep.get_pkgconfig_variable('fontrootdir')
+ fontrootdir = get_option('fontrootdir')
+ if fontrootdir == ''
+ fontutil_dep = dependency('fontutil', required: false)
+ if fontutil_dep.found()
+ fontrootdir = fontutil_dep.get_variable(pkgconfig : 'fontrootdir')
+ else
+ fontrootdir = join_paths(get_option('prefix'), get_option('datadir'), 'fonts', 'X11')
+ endif
+ endif
dfp_elements = [
join_paths(fontrootdir, 'misc'),
join_paths(fontrootdir, 'TTF'),
@@ -197,35 +210,35 @@ libxcvt_dep = dependency('libxcvt', fallback: ['libxcvt', 'libxcvt_dep'], requir
build_xwayland = false
if (host_machine.system() != 'darwin' and
- host_machine.system() != 'windows')
- if get_option('xwayland') != 'false'
- xwayland_required = get_option('xwayland') == 'true'
- build_glamor = glamor_option == 'true' or glamor_option == 'auto'
-
- xwayland_path = get_option('xwayland-path')
- if (xwayland_path == '')
- xwayland_path = join_paths(get_option('prefix'), get_option('bindir'))
- endif
-
- xwayland_dep = [
- dependency('wayland-client', version: wayland_req, required: xwayland_required),
- dependency('wayland-protocols', version: wayland_protocols_req, required: xwayland_required),
- dependency('libxcvt', fallback: ['libxcvt', 'libxcvt_dep'], required: xwayland_required),
- ]
+ host_machine.system() != 'windows' and
+ get_option('xwayland') != 'false')
+ xwayland_required = get_option('xwayland') == 'true'
+ build_glamor = glamor_option == 'true' or glamor_option == 'auto'
+
+ xwayland_path = get_option('xwayland-path')
+ if (xwayland_path == '')
+ xwayland_path = join_paths(get_option('prefix'), get_option('bindir'))
+ endif
- if build_glamor
- xwayland_dep += dependency('libdrm', version: libdrm_req, required: xwayland_required)
- xwayland_dep += dependency('epoxy', required: xwayland_required)
- endif
+ xwayland_dep = [
+ dependency('wayland-client', version: wayland_req, required: xwayland_required),
+ dependency('wayland-protocols', version: wayland_protocols_req, required: xwayland_required),
+ dependency('libxcvt', fallback: ['libxcvt', 'libxcvt_dep'], required: xwayland_required),
+ ]
- build_xwayland = true
- # check for all the deps being found, to handle 'auto' mode.
- foreach d: xwayland_dep
- if not d.found()
- build_xwayland = false
- endif
- endforeach
+ if build_glamor
+ xwayland_dep += dependency('xshmfence', version: xshmfence_req, required: xwayland_required)
+ xwayland_dep += dependency('libdrm', version: libdrm_req, required: xwayland_required)
+ xwayland_dep += dependency('epoxy', required: xwayland_required)
endif
+
+ build_xwayland = true
+ # check for all the deps being found, to handle 'auto' mode.
+ foreach d: xwayland_dep
+ if not d.found()
+ build_xwayland = false
+ endif
+ endforeach
endif
build_xnest = false
@@ -282,7 +295,7 @@ endif
int10 = get_option('int10')
if int10 == 'auto'
int10 = 'x86emu'
- if host_machine.cpu() == 'powerpc' and host_machine.system() == 'freebsd'
+ if host_machine.cpu() == 'ppc' and host_machine.system() == 'freebsd'
int10 = 'stub'
endif
if host_machine.cpu() == 'arm'
@@ -336,19 +349,30 @@ if build_glamor
epoxy_dep = dependency('epoxy', required: false)
endif
-eglstream_option = get_option('xwayland_eglstream')
-if build_xwayland and build_glamor
- eglstream_dep = dependency('wayland-eglstream-protocols', required:false)
- if eglstream_option == 'auto'
- build_eglstream = eglstream_dep.found()
+if build_xwayland
+ libdecor_dep = dependency('libdecor-0', required: false)
+ libdecor_option = get_option('libdecor')
+ if libdecor_option == 'auto'
+ have_libdecor = libdecor_dep.found()
else
- build_eglstream = eglstream_option == 'true'
- if build_eglstream and not eglstream_dep.found()
- error('glamor EGLStream support requested, but wayland-eglstream-protocols not found')
+ have_libdecor = libdecor_option == 'true'
+ if have_libdecor and not libdecor_dep.found()
+ error('libdecor support requested but not found')
endif
endif
else
- build_eglstream = false
+ have_libdecor = false
+endif
+
+if build_xwayland
+ libei_dep = dependency('libei-1.0', version: '>= 1.0.0', required: get_option('xwayland_ei') in ['portal', 'socket'])
+ liboeffis_dep = dependency('liboeffis-1.0', version: '>= 1.0.0', required: get_option('xwayland_ei') == 'portal')
+
+ build_ei = libei_dep.found() and get_option('xwayland_ei') != 'false'
+ build_ei_portal = liboeffis_dep.found() and get_option('xwayland_ei') in ['portal', 'auto']
+else
+ build_ei = false
+ build_ei_portal = false
endif
# Lots of sha1 options, because Linux is about choice :)
@@ -580,6 +604,7 @@ common_dep = [
damageproto_dep,
xcmiscproto_dep,
bigreqsproto_dep,
+ presentproto_dep,
xtrans_dep,
libsystemd_daemon_dep,
@@ -596,6 +621,7 @@ common_dep = [
xf86dgaproto_dep,
xf86vidmodeproto_dep,
applewmproto_dep,
+ dpmsproto_dep,
pixman_dep,
libbsd_dep,
@@ -605,6 +631,7 @@ common_dep = [
]
inc = include_directories(
+ '.',
'Xext',
'Xi',
'composite',
@@ -617,6 +644,7 @@ inc = include_directories(
'miext/shadow',
'miext/sync',
'dbe',
+ 'dix',
'dri3',
'include',
'present',
@@ -656,38 +684,12 @@ glx_inc = include_directories('glx')
top_dir_inc = include_directories('.')
-serverconfigdir = join_paths(get_option('prefix'), get_option('libdir'), 'xorg')
-
-manpage_config = configuration_data()
-manpage_config.set('vendorversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
-manpage_config.set('xorgversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
-manpage_config.set('xservername', 'Xorg')
-manpage_config.set('xconfigfile', 'xorg.conf')
-manpage_config.set('projectroot', get_option('prefix'))
-manpage_config.set('apploaddir', '$(appdefaultdir)')
-manpage_config.set('appmansuffix', '1')
-manpage_config.set('drivermansuffix', '4')
-manpage_config.set('adminmansuffix', '8')
-manpage_config.set('libmansuffix', '3')
-manpage_config.set('miscmansuffix', '7')
-manpage_config.set('filemansuffix', '5')
-manpage_config.set('logdir', log_dir)
-manpage_config.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
-manpage_config.set('mandir', join_paths(get_option('prefix'), get_option('mandir')))
-manpage_config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir')))
-manpage_config.set('xconfigdir', 'xorg.conf.d')
-manpage_config.set('xkbdir', xkb_dir)
-manpage_config.set('XKB_DFLT_RULES', get_option('xkb_default_rules'))
-manpage_config.set('XKB_DFLT_MODEL', get_option('xkb_default_model'))
-manpage_config.set('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
-manpage_config.set('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
-manpage_config.set('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
-manpage_config.set('bundle_id_prefix', '...')
-manpage_config.set('modulepath', module_dir)
-# wtf doesn't this work
-# manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), libexecdir))
-manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec'))
-manpage_config.set('default_font_path', default_font_path)
+serverconfigdir = get_option('serverconfigdir')
+if serverconfigdir == ''
+ serverconfigdir = join_paths(get_option('prefix'), get_option('libdir'), 'xorg')
+endif
+
+subdir('man')
require_docs = get_option('docs') == 'true'
require_devel_docs = get_option('devel-docs') == 'true'
@@ -712,24 +714,21 @@ build_docs_pdf = (get_option('docs-pdf') != 'false' and
fop.found())
if build_docs or build_docs_devel
- doc_sgml_path = sgml_doctools_dep.get_pkgconfig_variable('sgmlrootdir')
+ doc_sgml_path = sgml_doctools_dep.get_variable(pkgconfig : 'sgmlrootdir')
doc_stylesheet_srcdir = join_paths(doc_sgml_path, 'X11')
- # once we bump meson dependency to 0.56.0 we can use
- # meson.project_build_root() instead of meson.build_root()
-
# Meson does not and will not support functions so we are copy-pasting
# documentation build code around which is unfortunate
# See https://mesonbuild.com/FAQ.html#why-doesnt-meson-have-user-defined-functionsmacros
docs_xmlto_search_flags = [
'--searchpath', doc_stylesheet_srcdir,
- '--searchpath', meson.build_root(),
+ '--searchpath', meson.project_build_root(),
]
docs_xslt_search_flags = [
'--path', doc_stylesheet_srcdir,
- '--path', meson.build_root(),
+ '--path', meson.project_build_root(),
]
endif
@@ -804,12 +803,6 @@ if host_machine.system() != 'windows'
subdir('test')
endif
-install_man(configure_file(
- input: 'man/Xserver.man',
- output: 'Xserver.1',
- configuration: manpage_config,
-))
-
if build_xorg
sdkconfig = configuration_data()
awk = find_program('awk')
@@ -826,25 +819,29 @@ if build_xorg
sdkconfig.set('abi_ansic',
run_command(awk, '-F', '[(,)]',
'/^#define ABI_ANSIC.*SET/ { printf "%d.%d", $2, $3 }',
- files('hw/xfree86/common/xf86Module.h')
+ files('hw/xfree86/common/xf86Module.h'),
+ check: false
).stdout()
)
sdkconfig.set('abi_videodrv',
run_command(awk, '-F', '[(,)]',
'/^#define ABI_VIDEODRV.*SET/ { printf "%d.%d", $2, $3 }',
- files('hw/xfree86/common/xf86Module.h')
+ files('hw/xfree86/common/xf86Module.h'),
+ check: false
).stdout()
)
sdkconfig.set('abi_xinput',
run_command(awk, '-F', '[(,)]',
'/^#define ABI_XINPUT.*SET/ { printf "%d.%d", $2, $3 }',
- files('hw/xfree86/common/xf86Module.h')
+ files('hw/xfree86/common/xf86Module.h'),
+ check: false
).stdout()
)
sdkconfig.set('abi_extension',
run_command(awk, '-F', '[(,)]',
'/^#define ABI_EXTENSION.*SET/ { printf "%d.%d", $2, $3 }',
- files('hw/xfree86/common/xf86Module.h')
+ files('hw/xfree86/common/xf86Module.h'),
+ check: false
).stdout()
)
diff --git a/meson_options.txt b/meson_options.txt
index 3a494478e..e831d1dc9 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,8 +6,8 @@ option('xwayland', type: 'combo', choices: ['true', 'false', 'auto'], value: 'au
description: 'Enable Xwayland X server')
option('glamor', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
description: 'Enable glamor (default yes for Xorg/Xwayland builds)')
-option('xwayland_eglstream', type: 'combo', choices: ['true', 'false', 'auto'],
- value: 'auto', description: 'Enable EGLStream support for glamor on Xwayland')
+option('xwayland_ei', type: 'combo', choices: ['socket', 'portal', 'false', 'auto'],
+ value: 'auto', description: 'Enable emulated input support on Xwayland')
option('xnest', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
description: 'Enable Xnest nested X server')
option('xvfb', type: 'boolean', value: true,
@@ -25,11 +25,16 @@ option('log_dir', type: 'string')
option('module_dir', type: 'string', value: 'xorg/modules',
description: 'X.Org modules directory (absolute or relative to the directory specified by the libdir option)')
option('default_font_path', type: 'string')
+option('fontrootdir', type: 'string',
+ description: 'Root directory for legacy fonts. Default: from font-utils.pc or $datadir/fonts/X11')
+option('serverconfigdir', type: 'string',
+ description: 'Miscellaneous server configuration files path. Default: $libdir/xorg')
option('glx', type: 'boolean', value: true)
option('xdmcp', type: 'boolean', value: true)
option('xdm-auth-1', type: 'boolean', value: true)
-option('secure-rpc', type: 'boolean', value: true)
+option('secure-rpc', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
+ description: 'Enable Secure-RPC (DES) authentication')
option('ipv6', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto')
option('input_thread', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto')
@@ -61,14 +66,16 @@ option('listen_local', type: 'boolean', value: true,
option('int10', type: 'combo', choices: ['stub', 'x86emu', 'vm86', 'auto', 'false'],
value: 'auto',
description: 'Xorg int10 backend (default: usually x86emu)')
-option('suid_wrapper', type: 'boolean', value: 'false',
+option('suid_wrapper', type: 'boolean', value: false,
description: 'SUID wrapper for legacy driver support')
-option('pciaccess', type: 'boolean', value: 'true',
+option('pciaccess', type: 'boolean', value: true,
description: 'Xorg pciaccess support')
-option('udev', type: 'boolean', value: 'true')
-option('udev_kms', type: 'boolean', value: 'true')
+option('udev', type: 'boolean', value: true)
+option('udev_kms', type: 'boolean', value: true)
option('hal', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
description: 'Enable HAL integration')
+option('systemd_notify', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
+ description: 'Enable systemd-notify support')
option('systemd_logind', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
description: 'Enable systemd-logind integration')
option('vgahw', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
@@ -111,7 +118,7 @@ option('xf86-input-inputtest', type: 'boolean', value: true,
option('dri1', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Build DRI1 extension (default: auto)')
option('dri2', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Build DRI2 extension (default: auto)')
option('dri3', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Build DRI3 extension (default: auto)')
-option('drm', type: 'boolean', value: 'true',
+option('drm', type: 'boolean', value: true,
description: 'Build Xorg with libdrm support')
option('apple-applications-dir', type: 'string', value: '/Applications/Utilities',
@@ -135,6 +142,8 @@ option('libunwind', type: 'boolean', value: false,
description: 'Use libunwind for backtrace reporting')
option('xwayland-path', type: 'string', description: 'Directory containing Xwayland executable')
+option('libdecor', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
+ description: 'Whether Xwayland should use libdecor when running rootful.')
option('docs', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
description: 'Build documentation')
diff --git a/mi/mi.h b/mi/mi.h
index 8b0a231ca..2d1cd782c 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -382,11 +382,6 @@ extern _X_EXPORT Bool miModifyPixmapHeader(PixmapPtr pPixmap,
extern _X_EXPORT Bool miCreateScreenResources(ScreenPtr /*pScreen */
);
-extern _X_EXPORT Bool miScreenDevPrivateInit(ScreenPtr pScreen,
- int width,
- void *pbits
- );
-
extern _X_EXPORT Bool miScreenInit(ScreenPtr pScreen,
void *pbits,
int xsize,
diff --git a/mi/mi_priv.h b/mi/mi_priv.h
new file mode 100644
index 000000000..26c9d158f
--- /dev/null
+++ b/mi/mi_priv.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_MI_PRIV_H
+#define _XSERVER_MI_PRIV_H
+
+#include "screenint.h"
+
+void miScreenClose(ScreenPtr pScreen);
+
+#endif /* _XSERVER_MI_PRIV_H */
diff --git a/mi/miarc.c b/mi/miarc.c
index 3936f6c27..3a0ecc446 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -3151,10 +3151,10 @@ realFindSpan(int y)
else
newMaxy = finalMaxy + change;
if (finalSpans) {
- memmove(((char *) newSpans) +
+ memcpy(((char *) newSpans) +
(finalMiny - newMiny) * sizeof(struct finalSpan *),
- (char *) finalSpans,
- finalSize * sizeof(struct finalSpan *));
+ finalSpans,
+ finalSize * sizeof(struct finalSpan *));
free(finalSpans);
}
if ((i = finalMiny - newMiny) > 0)
diff --git a/mi/micmap.c b/mi/micmap.c
index 7003a5326..b4fbbe712 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1987, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -77,7 +77,7 @@ miUninstallColormap(ColormapPtr pmap)
if (pmap->mid != pmap->pScreen->defColormap) {
dixLookupResourceByType((void **) &curpmap,
pmap->pScreen->defColormap,
- RT_COLORMAP, serverClient, DixUseAccess);
+ X11_RESTYPE_COLORMAP, serverClient, DixUseAccess);
(*pmap->pScreen->InstallColormap) (curpmap);
}
}
diff --git a/mi/midispcur.c b/mi/midispcur.c
index d1da0fd58..b2984a0bb 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -34,6 +34,9 @@ in this Software without prior written authorization from The Open Group.
#endif
#include <X11/X.h>
+
+#include "dix/gc_priv.h"
+
#include "misc.h"
#include "input.h"
#include "cursorstr.h"
diff --git a/mi/miexpose.c b/mi/miexpose.c
index e54b18b30..29ac46486 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -79,6 +79,8 @@ Equipment Corporation.
#include <X11/Xproto.h>
#include <X11/Xprotostr.h>
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "regionstr.h"
#include "scrnintstr.h"
@@ -405,6 +407,9 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
BoxPtr pbox;
xRectangle *prect;
int numRects, regionnumrects;
+#ifdef COMPOSITE
+ WindowPtr orig_pWin = pWin;
+#endif
/*
* Distance from screen to destination drawable, use this
@@ -461,7 +466,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
tile_x_off = pWin->drawable.x;
tile_y_off = pWin->drawable.y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
draw_x_off = pixmap->screen_x;
draw_y_off = pixmap->screen_y;
tile_x_off -= draw_x_off;
@@ -488,6 +493,27 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
gcval[1].val =
fill.pixel | RootlessAlphaMask(pWin->drawable.bitsPerPixel);
#else
+#ifdef COMPOSITE
+ /* Make sure alpha will sample as 1.0 for opaque windows */
+ if (drawable->depth == 32) {
+ int effective_depth = orig_pWin->drawable.depth;
+
+ if (effective_depth == 32) {
+ orig_pWin = orig_pWin->parent;
+ while (orig_pWin && orig_pWin->parent) {
+ if (orig_pWin->drawable.depth == 24) {
+ effective_depth = 24;
+ break;
+ }
+
+ orig_pWin = orig_pWin->parent;
+ }
+ }
+
+ if (effective_depth == 24)
+ fill.pixel |= 0xff000000;
+ }
+#endif
gcval[1].val = fill.pixel;
#endif
gcval[2].val = FillSolid;
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 2e4aba534..1ddcd7fda 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -80,17 +80,6 @@ SOFTWARE.
#include "xf86Extensions.h"
#endif
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#undef XV
-#undef DBE
-#undef SCREENSAVER
-#undef RANDR
-#undef DAMAGE
-#undef COMPOSITE
-#undef MITSHM
-#endif
-
#ifdef HAVE_XNEST_CONFIG_H
#include <xnest-config.h>
#undef COMPOSITE
@@ -109,7 +98,7 @@ SOFTWARE.
/* List of built-in (statically linked) extensions */
static const ExtensionModule staticExtensions[] = {
{GEExtensionInit, "Generic Event Extension", &noGEExtension},
- {ShapeExtensionInit, "SHAPE", NULL},
+ {ShapeExtensionInit, "SHAPE", &noShapeExtension},
#ifdef MITSHM
{ShmExtensionInit, "MIT-SHM", &noMITShmExtension},
#endif
diff --git a/mi/mipointer.c b/mi/mipointer.c
index a638f25d4..652726f3b 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -251,7 +251,7 @@ miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
*
* This function is called from:
* - sprite init code to place onto initial position
- * - the various WarpPointer implementations (core, XI, Xinerama, dmx,…)
+ * - the various WarpPointer implementations (core, XI, Xinerama,…)
* - during the cursor update path in CheckMotion
* - in the Xinerama part of NewCurrentScreen
* - when a RandR/RandR1.2 mode was applied (it may have moved the pointer, so
@@ -397,8 +397,21 @@ miPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
#ifdef PANORAMIX
&& noPanoramiXExtension
#endif
- )
- UpdateSpriteForScreen(pDev, pScreen);
+ ) {
+ DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER);
+ /* Hack for CVE-2023-5380: if we're moving
+ * screens PointerWindows[] keeps referring to the
+ * old window. If that gets destroyed we have a UAF
+ * bug later. Only happens when jumping from a window
+ * to the root window on the other screen.
+ * Enter/Leave events are incorrect for that case but
+ * too niche to fix.
+ */
+ LeaveWindow(pDev);
+ if (master)
+ LeaveWindow(master);
+ UpdateSpriteForScreen(pDev, pScreen);
+ }
}
/**
@@ -609,8 +622,8 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
pPointer = MIPOINTER(pDev);
pScreen = pPointer->pScreen;
- x = trunc(*screenx);
- y = trunc(*screeny);
+ x = floor(*screenx);
+ y = floor(*screeny);
switch_screen = !point_on_screen(pScreen, x, y);
@@ -688,9 +701,9 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
* drop the float component on the floor
* FIXME: only drop remainder for ConstrainCursorHarder, not for screen
* crossings */
- if (x != trunc(*screenx))
+ if (x != floor(*screenx))
*screenx = x;
- if (y != trunc(*screeny))
+ if (y != floor(*screeny))
*screeny = y;
return pScreen;
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index 3bb52b1bc..57571b9ab 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -31,6 +31,9 @@ from The Open Group.
#endif
#include <X11/X.h>
+
+#include "mi/mi_priv.h"
+
#include "servermd.h"
#include "misc.h"
#include "mi.h"
@@ -55,6 +58,8 @@ from The Open Group.
typedef struct {
void *pbits; /* pointer to framebuffer */
int width; /* delta to add to a framebuffer addr to move one row down */
+ int xsize;
+ int ysize;
} miScreenInitParmsRec, *miScreenInitParmsPtr;
/* this plugs into pScreen->ModifyPixmapHeader */
@@ -166,8 +171,8 @@ miCreateScreenResources(ScreenPtr pScreen)
if (!pPixmap)
return FALSE;
- if (!(*pScreen->ModifyPixmapHeader) (pPixmap, pScreen->width,
- pScreen->height,
+ if (!(*pScreen->ModifyPixmapHeader) (pPixmap, pScrInitParms->xsize,
+ pScrInitParms->ysize,
pScreen->rootDepth,
BitsPerPixel(pScreen->rootDepth),
PixmapBytePad(pScrInitParms->width,
@@ -184,8 +189,8 @@ miCreateScreenResources(ScreenPtr pScreen)
return TRUE;
}
-Bool
-miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits)
+static Bool
+miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits, int xsize, int ysize)
{
miScreenInitParmsPtr pScrInitParms;
@@ -198,6 +203,8 @@ miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits)
return FALSE;
pScrInitParms->pbits = pbits;
pScrInitParms->width = width;
+ pScrInitParms->xsize = xsize;
+ pScrInitParms->ysize = ysize;
pScreen->devPrivate = (void *) pScrInitParms;
return TRUE;
}
@@ -291,7 +298,7 @@ miScreenInit(ScreenPtr pScreen, void *pbits, /* pointer to screen bits */
miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS);
- return miScreenDevPrivateInit(pScreen, width, pbits);
+ return miScreenDevPrivateInit(pScreen, width, pbits, xsize, ysize);
}
DevPrivateKeyRec miZeroLineScreenKeyRec;
@@ -305,3 +312,11 @@ miSetZeroLineBias(ScreenPtr pScreen, unsigned int bias)
dixSetPrivate(&pScreen->devPrivates, miZeroLineScreenKey,
(unsigned long *) (unsigned long) bias);
}
+
+void miScreenClose(ScreenPtr pScreen)
+{
+ if (pScreen->devPrivate) {
+ free(pScreen->devPrivate);
+ pScreen->devPrivate = NULL;
+ }
+}
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 54de1d3e6..6e02d70cb 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -71,16 +71,6 @@ SOFTWARE.
#include "miwideline.h"
#include "mi.h"
-#if 0
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "misc.h"
-#include "pixmapstr.h"
-#include "gcstruct.h"
-#endif
-
typedef struct {
int count; /* number of spans */
DDXPointPtr points; /* pointer to list of start points */
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index f3ae4ebbc..0ed392ca2 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
+#include "os/osdep.h"
+
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
@@ -40,6 +42,7 @@
#include "gcstruct.h"
#include "damage.h"
#include "damagestr.h"
+#include "glyphstr_priv.h"
#define wrap(priv, real, mem, func) {\
priv->mem = real->mem; \
@@ -142,7 +145,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
RegionRec pixClip;
int draw_x, draw_y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
int screen_x = 0, screen_y = 0;
#endif
@@ -150,7 +153,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
if (!RegionNotEmpty(pRegion))
return;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
/*
* When drawing to a pixmap which is storing window contents,
* the region presented is in pixmap relative coordinates which
@@ -201,7 +204,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
draw_x = pDamage->pDrawable->x;
draw_y = pDamage->pDrawable->y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
/*
* Need to move everyone to screen coordinates
* XXX what about off-screen pixmaps with non-zero x/y?
@@ -274,7 +277,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
if (pDamageRegion == pRegion && (draw_x || draw_y))
RegionTranslate(pDamageRegion, draw_x, draw_y);
}
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (screen_x || screen_y)
RegionTranslate(pRegion, -screen_x, -screen_y);
#endif
diff --git a/miext/rootless/README.txt b/miext/rootless/README.txt
index 754715d33..8a3b2bedf 100644
--- a/miext/rootless/README.txt
+++ b/miext/rootless/README.txt
@@ -88,14 +88,6 @@ rootlessConfig.h:
the underlying window server. Most operations will be buffered until
this time has expired.
- o ROOTLESS_RESIZE_GRAVITY: If the underlying window system supports it,
- some frame resizes can be optimized by relying on the frame contents
- maintaining a particular gravity during the resize. In this way less
- of the frame contents need to be preserved by the generic rootless
- layer. If true, the generic rootless layer will pass gravity hints
- during resizing and rely on the frame contents being preserved
- accordingly.
-
The following runtime options are defined in rootless.h:
o rootlessGlobalOffsetX, rootlessGlobalOffsetY: These specify the global
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index ed3b6c489..b375731bf 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -140,8 +140,7 @@ typedef void (*RootlessMoveFrameProc)
* pScreen Screen to move the new frame to
* newX, newY New position of the frame
* newW, newH New size of the frame
- * gravity Gravity for window contents (rl_gravity_enum). This is always
- * RL_GRAVITY_NONE unless ROOTLESS_RESIZE_GRAVITY is set.
+ * gravity Gravity for window contents (rl_gravity_enum).
*/
typedef void (*RootlessResizeFrameProc)
(RootlessFrameID wid, ScreenPtr pScreen,
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 504362790..44c2c3789 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -134,6 +134,23 @@ RootlessResolveColormap(ScreenPtr pScreen, int first_color,
return TRUE;
}
+unsigned long RootlessWID(WindowPtr pWindow) {
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ WindowPtr top = TopLevelParent(pWindow);
+ RootlessWindowRec *winRec;
+ PixmapPtr curPixmap;
+
+ if (top == NULL) {
+ return 0;
+ }
+ winRec = WINREC(top);
+ if (winRec == NULL) {
+ return 0;
+ }
+
+ return (unsigned long)(uintptr_t)winRec->wid;
+}
+
/*
* RootlessStartDrawing
* Prepare a window for direct access to its backing buffer.
@@ -148,11 +165,15 @@ RootlessStartDrawing(WindowPtr pWindow)
RootlessWindowRec *winRec;
PixmapPtr curPixmap;
- if (top == NULL)
+ if (top == NULL) {
+ RL_DEBUG_MSG("RootlessStartDrawing is a no-op because top == NULL.\n");
return;
+ }
winRec = WINREC(top);
- if (winRec == NULL)
+ if (winRec == NULL) {
+ RL_DEBUG_MSG("RootlessStartDrawing is a no-op because winRec == NULL.\n");
return;
+ }
// Make sure the window's top-level parent is prepared for drawing.
if (!winRec->is_drawing) {
@@ -166,10 +187,23 @@ RootlessStartDrawing(WindowPtr pWindow)
top->drawable.depth,
top->drawable.bitsPerPixel,
winRec->bytesPerRow, winRec->pixelData);
+
+ RL_DEBUG_MSG("GetScratchPixmapHeader gave us %p %p (%d,%d %dx%d %d) for wid=%lu\n",
+ winRec->pixmap, winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x,
+ winRec->pixmap->drawable.y, winRec->pixmap->drawable.width, winRec->pixmap->drawable.height,
+ winRec->pixmap->drawable.bitsPerPixel, RootlessWID(pWindow));
+
SetPixmapBaseToScreen(winRec->pixmap,
top->drawable.x - bw, top->drawable.y - bw);
+ RL_DEBUG_MSG("After SetPixmapBaseToScreen(%d %d %d): %p (%d,%d %dx%d %d) for wid=%lu\n",
+ top->drawable.x, top->drawable.y, bw, winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x,
+ winRec->pixmap->drawable.y, winRec->pixmap->drawable.width, winRec->pixmap->drawable.height,
+ winRec->pixmap->drawable.bitsPerPixel, RootlessWID(pWindow));
+
winRec->is_drawing = TRUE;
+ } else {
+ RL_DEBUG_MSG("Skipped call to xprStartDrawing (wid: %lu) because winRec->is_drawing says we already did.\n", RootlessWID(pWindow));
}
curPixmap = pScreen->GetWindowPixmap(pWindow);
@@ -181,6 +215,10 @@ RootlessStartDrawing(WindowPtr pWindow)
PixmapPtr oldPixmap =
dixLookupPrivate(&pWindow->devPrivates,
rootlessWindowOldPixmapPrivateKey);
+
+ RL_DEBUG_MSG("curPixmap is %p %p for wid=%lu\n", curPixmap, curPixmap ? curPixmap->devPrivate.ptr : NULL, RootlessWID(pWindow));
+ RL_DEBUG_MSG("oldPixmap is %p %p for wid=%lu\n", oldPixmap, oldPixmap ? oldPixmap->devPrivate.ptr : NULL, RootlessWID(pWindow));
+
if (oldPixmap != NULL) {
if (oldPixmap == curPixmap)
RL_DEBUG_MSG
@@ -277,7 +315,7 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion)
WindowPtr pTop;
BoxPtr b1, b2;
- RL_DEBUG_MSG("Damaged win 0x%x ", pWindow);
+ RL_DEBUG_MSG("Damaged win %p\n", pWindow);
pTop = TopLevelParent(pWindow);
if (pTop == NULL)
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 83dec3bb7..40400b395 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -226,20 +226,10 @@ extern RegionRec rootlessHugeRoot;
* Can't access the bits before the first word of the drawable's data in
* rootless mode, so make sure our base address is always 32-bit aligned.
*/
-#define SetPixmapBaseToScreen(pix, _x, _y) { \
- PixmapPtr _pPix = (PixmapPtr) (pix); \
- _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
- ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
- (int)(_y) * _pPix->devKind); \
- if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
- size_t _diff = ((size_t) _pPix->devPrivate.ptr) & \
- (FB_UNIT / CHAR_BIT - 1); \
- _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
- _diff; \
- _pPix->drawable.x = _diff / \
- (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
- } \
-}
+#define SetPixmapBaseToScreen(pix, _x, _y) do { \
+ pix->screen_x = _x; \
+ pix->screen_y = _y; \
+} while(0)
// Returns TRUE if this window is visible inside a frame
// (e.g. it is visible and has a top-level or root parent)
@@ -282,4 +272,5 @@ void RootlessDisableRoot(ScreenPtr pScreen);
void RootlessSetPixmapOfAncestors(WindowPtr pWin);
+unsigned long RootlessWID(WindowPtr pWindow);
#endif /* _ROOTLESSCOMMON_H */
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index 4c464b9f5..80c2f6d8a 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -34,10 +34,6 @@
#ifndef _ROOTLESSCONFIG_H
#define _ROOTLESSCONFIG_H
-#ifdef __APPLE__
-#define ROOTLESS_RESIZE_GRAVITY TRUE
-#endif
-
/*# define ROOTLESSDEBUG*/
#define ROOTLESS_PROTECT_ALPHA TRUE
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index 52d9df9ce..5af18a4a0 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -549,7 +549,7 @@ RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);
+ RL_DEBUG_MSG("copy area start (src %p, dst %p)", pSrc, dst);
if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr) pSrc)) {
/* If both source and dest are windows, and we're doing
@@ -800,7 +800,7 @@ static void
RootlessPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment * pSeg)
{
GCOP_UNWRAP(pGC);
- RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);
+ RL_DEBUG_MSG("poly segment start (dst %p)", dst);
RootlessStartDrawing((WindowPtr) dst);
pGC->ops->PolySegment(dst, pGC, nseg, pSeg);
@@ -998,7 +998,7 @@ RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
+ RL_DEBUG_MSG("fill poly start (dst %p, fillStyle 0x%x)", dst,
pGC->fillStyle);
if (count <= 2) {
@@ -1072,7 +1072,7 @@ RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
+ RL_DEBUG_MSG("fill rect start (dst %p, fillStyle 0x%x)", dst,
pGC->fillStyle);
if (nRectsInit <= 0) {
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 106d4320e..643dedff6 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -325,7 +325,7 @@ RootlessPositionWindow(WindowPtr pWin, int x, int y)
RootlessWindowRec *winRec = WINREC(pWin);
Bool result;
- RL_DEBUG_MSG("positionwindow start (win 0x%x @ %i, %i)\n", pWin, x, y);
+ RL_DEBUG_MSG("positionwindow start (win %p (%lu) @ %i, %i)\n", pWin, RootlessWID(pWin), x, y);
if (winRec) {
if (winRec->is_drawing) {
@@ -441,7 +441,7 @@ RootlessRealizeWindow(WindowPtr pWin)
RegionRec saveRoot;
ScreenPtr pScreen = pWin->drawable.pScreen;
- RL_DEBUG_MSG("realizewindow start (win 0x%x) ", pWin);
+ RL_DEBUG_MSG("realizewindow start (win %p (%lu)) ", pWin, RootlessWID(pWin));
if ((IsTopLevel(pWin) && pWin->drawable.class == InputOutput)) {
RootlessWindowRec *winRec;
@@ -625,11 +625,6 @@ RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
*/
// Globals needed during window resize and move.
-static void *gResizeDeathBits = NULL;
-static int gResizeDeathCount = 0;
-static PixmapPtr gResizeDeathPix[2] = { NULL, NULL };
-
-static BoxRec gResizeDeathBounds[2];
static CopyWindowProcPtr gResizeOldCopyWindowProc = NULL;
/*
@@ -650,74 +645,6 @@ RootlessNoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
}
/*
- * RootlessResizeCopyWindow
- * CopyWindow used during ResizeWindow for gravity moves. Based on
- * fbCopyWindow. The original always draws on the root pixmap, which
- * we don't have. Instead, draw on the parent window's pixmap.
- * Resize version: the old location's pixels are in gResizeCopyWindowSource.
- */
-static void
-RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
- RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- RegionRec rgnDst;
- int dx, dy;
-
- RL_DEBUG_MSG("resizecopywindowFB start (win 0x%x) ", pWin);
-
- /* Don't unwrap pScreen->CopyWindow.
- The bogus rewrap with RootlessCopyWindow causes a crash if
- CopyWindow is called again during the same resize. */
-
- if (gResizeDeathCount == 0)
- return;
-
- RootlessStartDrawing(pWin);
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
- RegionNull(&rgnDst);
- RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-
- if (gResizeDeathCount == 1) {
- /* Simple case, we only have a single source pixmap. */
-
- miCopyRegion(&gResizeDeathPix[0]->drawable,
- &pScreen->GetWindowPixmap(pWin)->drawable, 0,
- &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
- }
- else {
- int i;
- RegionRec clip, clipped;
-
- /* More complex case, N source pixmaps (usually two). So we
- intersect the destination with each source and copy those bits. */
-
- for (i = 0; i < gResizeDeathCount; i++) {
- RegionInit(&clip, gResizeDeathBounds + 0, 1);
- RegionNull(&clipped);
- RegionIntersect(&rgnDst, &clip, &clipped);
-
- miCopyRegion(&gResizeDeathPix[i]->drawable,
- &pScreen->GetWindowPixmap(pWin)->drawable, 0,
- &clipped, dx, dy, fbCopyWindowProc, 0, 0);
-
- RegionUninit(&clipped);
- RegionUninit(&clip);
- }
- }
-
- /* Don't update - resize will update everything */
- RegionUninit(&rgnDst);
-
- fbValidateDrawable(&pWin->drawable);
-
- RL_DEBUG_MSG("resizecopywindowFB end\n");
-}
-
-/*
* RootlessCopyWindow
* Update *new* location of window. Old location is redrawn with
* PaintWindow. Cloned from fbCopyWindow.
@@ -733,7 +660,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
BoxPtr extents;
int area;
- RL_DEBUG_MSG("copywindowFB start (win 0x%x) ", pWin);
+ RL_DEBUG_MSG("copywindowFB start (win %p (%lu)) ", pWin, RootlessWID(pWin));
SCREEN_UNWRAP(pScreen, CopyWindow);
@@ -778,11 +705,17 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
else {
RootlessStartDrawing(pWin);
- miCopyRegion((DrawablePtr) pWin, (DrawablePtr) pWin,
+ PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
+ DrawablePtr pDrawable = &pPixmap->drawable;
+
+ if (pPixmap->screen_x || pPixmap->screen_y) {
+ RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
+ }
+
+ miCopyRegion(pDrawable, pDrawable,
0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
- /* prgnSrc has been translated to dst position */
- RootlessDamageRegion(pWin, prgnSrc);
+ RootlessDamageRegion(pWin, &rgnDst);
}
out:
@@ -833,7 +766,6 @@ static inline unsigned int
ResizeWeighting(int oldX1, int oldY1, int oldX2, int oldY2, int oldBW,
int newX1, int newY1, int newX2, int newY2, int newBW)
{
-#ifdef ROOTLESS_RESIZE_GRAVITY
if (newBW != oldBW)
return RL_GRAVITY_NONE;
@@ -846,10 +778,7 @@ ResizeWeighting(int oldX1, int oldY1, int oldX2, int oldY2, int oldBW,
else if (newX2 == oldX2 && newY1 == oldY1)
return RL_GRAVITY_NORTH_EAST;
else
- return RL_GRAVITY_NONE;
-#else
- return RL_GRAVITY_NONE;
-#endif
+ return RL_GRAVITY_NORTH_WEST;
}
/*
@@ -858,14 +787,13 @@ ResizeWeighting(int oldX1, int oldY1, int oldX2, int oldY2, int oldBW,
* saved and the implementation is told to change the window size.
* (x,y,w,h) is outer frame of window (outside border)
*/
-static Bool
+static void
StartFrameResize(WindowPtr pWin, Bool gravity,
int oldX, int oldY, int oldW, int oldH, int oldBW,
int newX, int newY, int newW, int newH, int newBW)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
RootlessWindowRec *winRec = WINREC(pWin);
- Bool need_window_source = FALSE, resize_after = FALSE;
BoxRec rect;
int oldX2, newX2;
@@ -891,279 +819,44 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
RootlessRedisplay(pWin);
- /* If gravity is true, then we need to have a way of recovering all
- the original bits in the window for when X rearranges the contents
- based on the various gravity settings. The obvious way is to just
- snapshot the entire backing store before resizing it, but that
- it slow on large windows.
-
- So the optimization here is to use the implementation's resize
- weighting options (if available) to allow us to reason about what
- is left in the backing store after the resize. We can then only
- copy what won't be there after the resize, and do a two-stage copy
- operation.
-
- Most of these optimizations are only applied when the top-left
- corner of the window is fixed, since that's the common case. They
- could probably be extended with some thought. */
-
- gResizeDeathCount = 0;
-
- if (gravity && weight == RL_GRAVITY_NORTH_WEST) {
- unsigned int code = 0;
-
- /* Top left corner is anchored. We never need to copy the
- entire window. */
-
- need_window_source = TRUE;
-
- /* These comparisons were chosen to avoid setting bits when the sizes
- are the same. (So the fastest case automatically gets taken when
- dimensions are unchanging.) */
-
- if (newW < oldW)
- code |= WIDTH_SMALLER;
- if (newH < oldH)
- code |= HEIGHT_SMALLER;
-
- if (((code ^ (code >> 1)) & 1) == 0) {
- /* Both dimensions are either getting larger, or both
- are getting smaller. No need to copy anything. */
-
- if (code == (WIDTH_SMALLER | HEIGHT_SMALLER)) {
- /* Since the window is getting smaller, we can do gravity
- repair on it with its current size, then resize it
- afterwards. */
-
- resize_after = TRUE;
- }
-
- gResizeDeathCount = 1;
- }
- else {
- unsigned int copy_rowbytes, Bpp;
- unsigned int copy_rect_width, copy_rect_height;
- BoxRec copy_rect;
-
- /* We can get away with a partial copy. 'rect' is the
- intersection between old and new bounds, so copy
- everything to the right of or below the intersection. */
-
- RootlessStartDrawing(pWin);
-
- if (code == WIDTH_SMALLER) {
- copy_rect.x1 = rect.x2;
- copy_rect.y1 = rect.y1;
- copy_rect.x2 = oldX2;
- copy_rect.y2 = oldY2;
- }
- else if (code == HEIGHT_SMALLER) {
- copy_rect.x1 = rect.x1;
- copy_rect.y1 = rect.y2;
- copy_rect.x2 = oldX2;
- copy_rect.y2 = oldY2;
- }
- else
- OsAbort();
-
- Bpp = winRec->win->drawable.bitsPerPixel / 8;
- copy_rect_width = copy_rect.x2 - copy_rect.x1;
- copy_rect_height = copy_rect.y2 - copy_rect.y1;
- copy_rowbytes = ((copy_rect_width * Bpp) + 31) & ~31;
- gResizeDeathBits = xallocarray(copy_rowbytes, copy_rect_height);
-
- if (copy_rect_width * copy_rect_height >
- rootless_CopyBytes_threshold &&
- SCREENREC(pScreen)->imp->CopyBytes) {
- SCREENREC(pScreen)->imp->CopyBytes(copy_rect_width * Bpp,
- copy_rect_height,
- ((char *) winRec->pixelData)
- +
- ((copy_rect.y1 -
- oldY) *
- winRec->bytesPerRow)
- + (copy_rect.x1 -
- oldX) * Bpp,
- winRec->bytesPerRow,
- gResizeDeathBits,
- copy_rowbytes);
- }
- else {
- fbBlt((FbBits *) (winRec->pixelData
- +
- ((copy_rect.y1 - oldY) * winRec->bytesPerRow)
- + (copy_rect.x1 - oldX) * Bpp),
- winRec->bytesPerRow / sizeof(FbBits), 0,
- (FbBits *) gResizeDeathBits,
- copy_rowbytes / sizeof(FbBits), 0, copy_rect_width * Bpp,
- copy_rect_height, GXcopy, FB_ALLONES, Bpp, 0, 0);
- }
-
- gResizeDeathBounds[1] = copy_rect;
- gResizeDeathPix[1]
- = GetScratchPixmapHeader(pScreen, copy_rect_width,
- copy_rect_height,
- winRec->win->drawable.depth,
- winRec->win->drawable.bitsPerPixel,
- winRec->bytesPerRow,
- (void *) gResizeDeathBits);
-
- SetPixmapBaseToScreen(gResizeDeathPix[1],
- copy_rect.x1, copy_rect.y1);
-
- gResizeDeathCount = 2;
- }
- }
- else if (gravity) {
- /* The general case. Just copy everything. */
-
- RootlessStartDrawing(pWin);
-
- gResizeDeathBits = xallocarray(winRec->bytesPerRow, winRec->height);
-
- memcpy(gResizeDeathBits, winRec->pixelData,
- winRec->bytesPerRow * winRec->height);
-
- gResizeDeathBounds[0] = (BoxRec) {
- oldX, oldY, oldX2, oldY2};
- gResizeDeathPix[0]
- = GetScratchPixmapHeader(pScreen, winRec->width,
- winRec->height,
- winRec->win->drawable.depth,
- winRec->win->drawable.bitsPerPixel,
- winRec->bytesPerRow,
- (void *) gResizeDeathBits);
-
- SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY);
- gResizeDeathCount = 1;
- }
-
- RootlessStopDrawing(pWin, FALSE);
-
winRec->x = newX;
winRec->y = newY;
winRec->width = newW;
winRec->height = newH;
winRec->borderWidth = newBW;
- /* Unless both dimensions are getting smaller, Resize the frame
- before doing gravity repair */
-
- if (!resize_after) {
- SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen,
- newX + SCREEN_TO_GLOBAL_X,
- newY + SCREEN_TO_GLOBAL_Y,
- newW, newH, weight);
- }
+ SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen,
+ newX + SCREEN_TO_GLOBAL_X,
+ newY + SCREEN_TO_GLOBAL_Y,
+ newW, newH, weight);
RootlessStartDrawing(pWin);
- /* If necessary, create a source pixmap pointing at the current
- window bits. */
-
- if (need_window_source) {
- gResizeDeathBounds[0] = (BoxRec) {
- oldX, oldY, oldX2, oldY2};
- gResizeDeathPix[0]
- = GetScratchPixmapHeader(pScreen, oldW, oldH,
- winRec->win->drawable.depth,
- winRec->win->drawable.bitsPerPixel,
- winRec->bytesPerRow, winRec->pixelData);
-
- SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY);
- }
-
/* Use custom CopyWindow when moving gravity bits around
ResizeWindow assumes the old window contents are in the same
pixmap, but here they're in deathPix instead. */
if (gravity) {
gResizeOldCopyWindowProc = pScreen->CopyWindow;
- pScreen->CopyWindow = RootlessResizeCopyWindow;
- }
-
- /* If we can't rely on the window server preserving the bits we
- need in the position we need, copy the pixels in the
- intersection from src to dst. ResizeWindow assumes these pixels
- are already present when making gravity adjustments. pWin
- currently has new-sized pixmap but is in old position.
-
- FIXME: border width change! (?) */
-
- if (gravity && weight == RL_GRAVITY_NONE) {
- PixmapPtr src, dst;
-
- assert(gResizeDeathCount == 1);
-
- src = gResizeDeathPix[0];
- dst = pScreen->GetWindowPixmap(pWin);
-
- RL_DEBUG_MSG("Resize copy rect %d %d %d %d\n",
- rect.x1, rect.y1, rect.x2, rect.y2);
-
- /* rect is the intersection of the old location and new location */
- if (BOX_NOT_EMPTY(rect) && src != NULL && dst != NULL) {
- /* The window drawable still has the old frame position, which
- means that DST doesn't actually point at the origin of our
- physical backing store when adjusted by the drawable.x,y
- position. So sneakily adjust it temporarily while copying.. */
-
- ((PixmapPtr) dst)->devPrivate.ptr = winRec->pixelData;
- SetPixmapBaseToScreen(dst, newX, newY);
-
- fbCopyWindowProc(&src->drawable, &dst->drawable, NULL,
- &rect, 1, 0, 0, FALSE, FALSE, 0, 0);
-
- ((PixmapPtr) dst)->devPrivate.ptr = winRec->pixelData;
- SetPixmapBaseToScreen(dst, oldX, oldY);
- }
+ pScreen->CopyWindow = RootlessNoCopyWindow;
}
-
- return resize_after;
}
static void
FinishFrameResize(WindowPtr pWin, Bool gravity, int oldX, int oldY,
unsigned int oldW, unsigned int oldH, unsigned int oldBW,
int newX, int newY, unsigned int newW, unsigned int newH,
- unsigned int newBW, Bool resize_now)
+ unsigned int newBW)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
RootlessWindowRec *winRec = WINREC(pWin);
int i;
- RootlessStopDrawing(pWin, FALSE);
-
- if (resize_now) {
- unsigned int weight;
-
- /* We didn't resize anything earlier, so do it now, now that
- we've finished gravitating the bits. */
-
- weight = ResizeWeighting(oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW);
-
- SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen,
- newX + SCREEN_TO_GLOBAL_X,
- newY + SCREEN_TO_GLOBAL_Y,
- newW, newH, weight);
- }
-
/* Redraw everything. FIXME: there must be times when we don't need
to do this. Perhaps when top-left weighting and no gravity? */
RootlessDamageRect(pWin, -newBW, -newBW, newW, newH);
- for (i = 0; i < 2; i++) {
- if (gResizeDeathPix[i] != NULL) {
- FreeScratchPixmapHeader(gResizeDeathPix[i]);
- gResizeDeathPix[i] = NULL;
- }
- }
-
- free(gResizeDeathBits);
- gResizeDeathBits = NULL;
-
if (gravity) {
pScreen->CopyWindow = gResizeOldCopyWindowProc;
}
@@ -1183,7 +876,6 @@ RootlessMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
int oldX = 0, oldY = 0, newX = 0, newY = 0;
unsigned int oldW = 0, oldH = 0, oldBW = 0;
unsigned int newW = 0, newH = 0, newBW = 0;
- Bool resize_after = FALSE;
RegionRec saveRoot;
RL_DEBUG_MSG("movewindow start \n");
@@ -1210,9 +902,9 @@ RootlessMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
newW = pWin->drawable.width + 2 * newBW;
newH = pWin->drawable.height + 2 * newBW;
- resize_after = StartFrameResize(pWin, FALSE,
- oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW);
+ StartFrameResize(pWin, FALSE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
}
}
@@ -1241,8 +933,9 @@ RootlessMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
y + SCREEN_TO_GLOBAL_Y);
}
else {
- FinishFrameResize(pWin, FALSE, oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW, resize_after);
+ FinishFrameResize(pWin, FALSE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
}
}
@@ -1265,10 +958,9 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
ScreenPtr pScreen = pWin->drawable.pScreen;
int oldX = 0, oldY = 0, newX = 0, newY = 0;
unsigned int oldW = 0, oldH = 0, oldBW = 0, newW = 0, newH = 0, newBW = 0;
- Bool resize_after = FALSE;
RegionRec saveRoot;
- RL_DEBUG_MSG("resizewindow start (win 0x%x) ", pWin);
+ RL_DEBUG_MSG("resizewindow start (win %p (%lu)) ", pWin, RootlessWID(pWin));
if (pWin->parent) {
if (winRec) {
@@ -1284,9 +976,9 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
newW = w + 2 * newBW;
newH = h + 2 * newBW;
- resize_after = StartFrameResize(pWin, TRUE,
- oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW);
+ StartFrameResize(pWin, TRUE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
}
HUGE_ROOT(pWin);
@@ -1296,8 +988,9 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
NORMAL_ROOT(pWin);
if (winRec) {
- FinishFrameResize(pWin, TRUE, oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW, resize_after);
+ FinishFrameResize(pWin, TRUE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
}
}
else {
@@ -1454,7 +1147,6 @@ void
RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width)
{
RegionRec saveRoot;
- Bool resize_after = FALSE;
RL_DEBUG_MSG("change border width ");
@@ -1477,9 +1169,9 @@ RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width)
newW = pWin->drawable.width + 2 * newBW;
newH = pWin->drawable.height + 2 * newBW;
- resize_after = StartFrameResize(pWin, FALSE,
- oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW);
+ StartFrameResize(pWin, FALSE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
}
HUGE_ROOT(pWin);
@@ -1489,8 +1181,9 @@ RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width)
NORMAL_ROOT(pWin);
if (winRec) {
- FinishFrameResize(pWin, FALSE, oldX, oldY, oldW, oldH, oldBW,
- newX, newY, newW, newH, newBW, resize_after);
+ FinishFrameResize(pWin, FALSE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
}
}
@@ -1649,7 +1342,7 @@ RootlessSetPixmapOfAncestors(WindowPtr pWin)
XID pixel = 0;
ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient);
- RL_DEBUG_MSG("Cleared ParentRelative on 0x%x.\n", pWin);
+ RL_DEBUG_MSG("Cleared ParentRelative on %p (%lu).\n", pWin, RootlessWID(pWin));
break;
}
diff --git a/miext/sync/misync.c b/miext/sync/misync.c
index 0931803f6..48234ef8a 100644
--- a/miext/sync/misync.c
+++ b/miext/sync/misync.c
@@ -26,7 +26,7 @@
#endif
#include "scrnintstr.h"
-#include "misync.h"
+#include "misync_priv.h"
#include "misyncstr.h"
DevPrivateKeyRec miSyncScreenPrivateKey;
diff --git a/miext/sync/misync.h b/miext/sync/misync.h
index f7082d5ea..4748fa4ae 100644
--- a/miext/sync/misync.h
+++ b/miext/sync/misync.h
@@ -43,7 +43,6 @@ typedef struct _syncScreenFuncs {
SyncScreenDestroyFenceFunc DestroyFence;
} SyncScreenFuncsRec, *SyncScreenFuncsPtr;
-
extern _X_EXPORT void
miSyncScreenCreateFence(ScreenPtr pScreen, SyncFence * pFence,
Bool initially_triggered);
@@ -65,11 +64,12 @@ typedef struct _syncFenceFuncs {
} SyncFenceFuncsRec, *SyncFenceFuncsPtr;
extern _X_EXPORT void
-
miSyncInitFence(ScreenPtr pScreen, SyncFence * pFence,
Bool initially_triggered);
+
extern _X_EXPORT void
miSyncDestroyFence(SyncFence * pFence);
+
extern _X_EXPORT void
miSyncTriggerFence(SyncFence * pFence);
@@ -77,25 +77,4 @@ extern _X_EXPORT SyncScreenFuncsPtr miSyncGetScreenFuncs(ScreenPtr pScreen);
extern _X_EXPORT Bool
miSyncSetup(ScreenPtr pScreen);
-Bool
-miSyncFenceCheckTriggered(SyncFence * pFence);
-
-void
-miSyncFenceSetTriggered(SyncFence * pFence);
-
-void
-miSyncFenceReset(SyncFence * pFence);
-
-void
-miSyncFenceAddTrigger(SyncTrigger * pTrigger);
-
-void
-miSyncFenceDeleteTrigger(SyncTrigger * pTrigger);
-
-int
-miSyncInitFenceFromFD(DrawablePtr pDraw, SyncFence *pFence, int fd, BOOL initially_triggered);
-
-int
-miSyncFDFromFence(DrawablePtr pDraw, SyncFence *pFence);
-
#endif /* _MISYNC_H_ */
diff --git a/miext/sync/misync_priv.h b/miext/sync/misync_priv.h
new file mode 100644
index 000000000..76ac40d9a
--- /dev/null
+++ b/miext/sync/misync_priv.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 2010 NVIDIA Corporation
+ */
+#ifndef _XSERVER_MISYNC_PRIV_H
+#define _XSERVER_MISYNC_PRIV_H
+
+#include "misync.h"
+
+extern DevPrivateKeyRec miSyncScreenPrivateKey;
+
+typedef struct _syncScreenPriv {
+ /* Wrappable sync-specific screen functions */
+ SyncScreenFuncsRec funcs;
+
+ /* Wrapped screen functions */
+ CloseScreenProcPtr CloseScreen;
+} SyncScreenPrivRec, *SyncScreenPrivPtr;
+
+#define SYNC_SCREEN_PRIV(pScreen) \
+ (SyncScreenPrivPtr) dixLookupPrivate(&pScreen->devPrivates, \
+ &miSyncScreenPrivateKey)
+
+Bool miSyncFenceCheckTriggered(SyncFence * pFence);
+void miSyncFenceSetTriggered(SyncFence * pFence);
+void miSyncFenceReset(SyncFence * pFence);
+void miSyncFenceAddTrigger(SyncTrigger * pTrigger);
+void miSyncFenceDeleteTrigger(SyncTrigger * pTrigger);
+int miSyncInitFenceFromFD(DrawablePtr pDraw, SyncFence *pFence, int fd, BOOL initially_triggered);
+int miSyncFDFromFence(DrawablePtr pDraw, SyncFence *pFence);
+
+#endif /* _XSERVER_MISYNC_PRIV_H */
diff --git a/miext/sync/misyncfd.c b/miext/sync/misyncfd.c
index 92f3b2294..42a75024d 100644
--- a/miext/sync/misyncfd.c
+++ b/miext/sync/misyncfd.c
@@ -25,7 +25,7 @@
#endif
#include "scrnintstr.h"
-#include "misync.h"
+#include "misync_priv.h"
#include "misyncstr.h"
#include "misyncfd.h"
#include "pixmapstr.h"
@@ -66,7 +66,7 @@ miSyncFDFromFence(DrawablePtr pDraw, SyncFence *pFence)
return (*priv->funcs.GetFenceFd)(pDraw->pScreen, pFence);
}
-_X_EXPORT Bool miSyncFdScreenInit(ScreenPtr pScreen,
+Bool miSyncFdScreenInit(ScreenPtr pScreen,
const SyncFdScreenFuncsRec *funcs)
{
SyncFdScreenPrivatePtr priv;
diff --git a/miext/sync/misyncshm.c b/miext/sync/misyncshm.c
index 01f82fc00..1e8865e89 100644
--- a/miext/sync/misyncshm.c
+++ b/miext/sync/misyncshm.c
@@ -24,16 +24,19 @@
#include <dix-config.h>
#endif
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <X11/xshmfence.h>
+
+#include "os/osdep.h"
+
#include "scrnintstr.h"
-#include "misync.h"
+#include "misync_priv.h"
#include "misyncstr.h"
#include "misyncshm.h"
#include "misyncfd.h"
#include "pixmapstr.h"
-#include <sys/mman.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <X11/xshmfence.h>
static DevPrivateKeyRec syncShmFencePrivateKey;
@@ -163,7 +166,7 @@ static const SyncFdScreenFuncsRec miSyncShmScreenFuncs = {
.GetFenceFd = miSyncShmGetFenceFd
};
-_X_EXPORT Bool miSyncShmScreenInit(ScreenPtr pScreen)
+Bool miSyncShmScreenInit(ScreenPtr pScreen)
{
SyncScreenFuncsPtr funcs;
diff --git a/miext/sync/misyncstr.h b/miext/sync/misyncstr.h
index 490cf6194..21cb0b257 100644
--- a/miext/sync/misyncstr.h
+++ b/miext/sync/misyncstr.h
@@ -78,18 +78,4 @@ typedef struct _SyncTriggerList {
struct _SyncTriggerList *next;
} SyncTriggerList;
-extern DevPrivateKeyRec miSyncScreenPrivateKey;
-
-#define SYNC_SCREEN_PRIV(pScreen) \
- (SyncScreenPrivPtr) dixLookupPrivate(&pScreen->devPrivates, \
- &miSyncScreenPrivateKey)
-
-typedef struct _syncScreenPriv {
- /* Wrappable sync-specific screen functions */
- SyncScreenFuncsRec funcs;
-
- /* Wrapped screen functions */
- CloseScreenProcPtr CloseScreen;
-} SyncScreenPrivRec, *SyncScreenPrivPtr;
-
#endif /* _MISYNCSTR_H_ */
diff --git a/os/WaitFor.c b/os/WaitFor.c
index ff1d376e9..b08b44040 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -56,22 +56,24 @@ SOFTWARE.
#include <dix-config.h>
#endif
+#include <errno.h>
+#include <stdio.h>
#ifdef WIN32
#include <X11/Xwinsock.h>
#endif
#include <X11/Xos.h> /* for strings, fcntl, time */
-#include <errno.h>
-#include <stdio.h>
#include <X11/X.h>
-#include "misc.h"
+#include "dix/dix_priv.h"
+#include "os/busfault.h"
+
+#include "misc.h"
#include "osdep.h"
#include "dixstruct.h"
#include "opaque.h"
#ifdef DPMSExtension
#include "dpmsproc.h"
#endif
-#include "busfault.h"
#ifdef WIN32
/* Error codes from windows sockets differ from fileio error codes */
@@ -180,17 +182,13 @@ WaitForSomething(Bool are_ready)
were_ready = FALSE;
-#ifdef BUSFAULT
busfault_check();
-#endif
/* We need a while loop here to handle
crashed connections and the screen saver timeout */
while (1) {
/* deal with any blocked jobs */
- if (workQueue) {
- ProcessWorkQueue();
- }
+ ProcessWorkQueue();
timeout = check_timers();
are_ready = clients_are_ready();
diff --git a/os/access.c b/os/access.c
index b1703048d..352506bec 100644
--- a/os/access.c
+++ b/os/access.c
@@ -54,7 +54,7 @@ SOFTWARE.
******************************************************************/
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -116,6 +116,14 @@ SOFTWARE.
#endif
#endif
+#ifdef HAVE_SYS_UCRED_H
+#include <sys/ucred.h>
+#endif
+
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+
#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
#include <sys/utsname.h>
#endif
@@ -179,10 +187,14 @@ SOFTWARE.
#define X_INCLUDE_NETDB_H
#include <X11/Xos_r.h>
+#include "os/auth.h"
+
#include "dixstruct.h"
#include "osdep.h"
#include "xace.h"
+#include "rpcauth.h"
+#include "xdmcp.h"
Bool defeatAccessControl = FALSE;
@@ -245,6 +257,14 @@ static Bool siAddrMatch(int family, void *addr, int len, HOST * host,
static int siCheckAddr(const char *addrString, int length);
static void siTypesInitialize(void);
+static void EnableLocalHost(void);
+static void DisableLocalHost(void);
+
+#ifndef NO_LOCAL_CLIENT_CRED
+static void EnableLocalUser(void);
+static void DisableLocalUser(void);
+#endif
+
/*
* called when authorization is not enabled to add the
* local host to the access list
@@ -265,8 +285,7 @@ EnableLocalAccess(void)
}
}
-void
-EnableLocalHost(void)
+static void EnableLocalHost(void)
{
if (!UsingXdmcp) {
LocalHostEnabled = TRUE;
@@ -292,8 +311,7 @@ DisableLocalAccess(void)
}
}
-void
-DisableLocalHost(void)
+static void DisableLocalHost(void)
{
HOST *self;
@@ -335,8 +353,7 @@ out:
return length;
}
-void
-EnableLocalUser(void)
+static void EnableLocalUser(void)
{
char *addr = NULL;
int length = -1;
@@ -351,8 +368,7 @@ EnableLocalUser(void)
free(addr);
}
-void
-DisableLocalUser(void)
+static void DisableLocalUser(void)
{
char *addr = NULL;
int length = -1;
@@ -432,20 +448,11 @@ DefineSelf(int fd)
#if !defined(TCPCONN) && !defined(UNIXCONN)
return;
#else
- register int n;
int len;
caddr_t addr;
int family;
register HOST *host;
-
-#ifndef WIN32
struct utsname name;
-#else
- struct {
- char nodename[512];
- } name;
-#endif
-
register struct hostent *hp;
union {
@@ -457,7 +464,9 @@ DefineSelf(int fd)
} saddr;
struct sockaddr_in *inetaddr;
+#if defined(IPv6) && defined(AF_INET6)
struct sockaddr_in6 *inet6addr;
+#endif
struct sockaddr_in broad_addr;
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
@@ -469,11 +478,7 @@ DefineSelf(int fd)
* uname() lets me access to the whole string (it smashes release, you
* see), whereas gethostname() kindly truncates it for me.
*/
-#ifndef WIN32
uname(&name);
-#else
- gethostname(name.nodename, sizeof(name.nodename));
-#endif
hp = _XGethostbyname(name.nodename, hparams);
if (hp != NULL) {
@@ -1162,20 +1167,31 @@ ComputeLocalClient(ClientPtr client)
int
GetLocalClientCreds(ClientPtr client, LocalClientCredRec ** lccp)
{
-#if defined(HAVE_GETPEEREID) || defined(HAVE_GETPEERUCRED) || defined(SO_PEERCRED)
+#if defined(HAVE_GETPEEREID) || defined(HAVE_GETPEERUCRED) || defined(SO_PEERCRED) || defined(LOCAL_PEERCRED)
int fd;
XtransConnInfo ci;
LocalClientCredRec *lcc;
-#ifdef HAVE_GETPEEREID
- uid_t uid;
- gid_t gid;
-#elif defined(HAVE_GETPEERUCRED)
+#if defined(HAVE_GETPEERUCRED)
ucred_t *peercred = NULL;
const gid_t *gids;
#elif defined(SO_PEERCRED)
+#ifndef __OpenBSD__
struct ucred peercred;
+#else
+ struct sockpeercred peercred;
+#endif
+ socklen_t so_len = sizeof(peercred);
+#elif defined(LOCAL_PEERCRED) && defined(HAVE_XUCRED_CR_PID)
+ struct xucred peercred;
socklen_t so_len = sizeof(peercred);
+#elif defined(HAVE_GETPEEREID)
+ uid_t uid;
+ gid_t gid;
+#if defined(LOCAL_PEERPID)
+ pid_t pid;
+ socklen_t so_len = sizeof(pid);
+#endif
#endif
if (client == NULL)
@@ -1197,16 +1213,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec ** lccp)
lcc = *lccp;
fd = _XSERVTransGetConnectionNumber(ci);
-#ifdef HAVE_GETPEEREID
- if (getpeereid(fd, &uid, &gid) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = uid;
- lcc->egid = gid;
- lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET;
- return 0;
-#elif defined(HAVE_GETPEERUCRED)
+#if defined(HAVE_GETPEERUCRED)
if (getpeerucred(fd, &peercred) < 0) {
FreeLocalClientCreds(lcc);
return -1;
@@ -1254,6 +1261,36 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec ** lccp)
lcc->pid = peercred.pid;
lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET;
return 0;
+#elif defined(LOCAL_PEERCRED) && defined(HAVE_XUCRED_CR_PID)
+ if (getsockopt(fd, SOL_LOCAL, LOCAL_PEERCRED, &peercred, &so_len) != 0 ||
+ peercred.cr_version != XUCRED_VERSION) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+ lcc->euid = peercred.cr_uid;
+ lcc->egid = peercred.cr_gid;
+ lcc->pid = peercred.cr_pid;
+ lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET;
+ return 0;
+#elif defined(HAVE_GETPEEREID)
+ if (getpeereid(fd, &uid, &gid) == -1) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+ lcc->euid = uid;
+ lcc->egid = gid;
+ lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET;
+
+#if defined(LOCAL_PEERPID)
+ if (getsockopt(fd, SOL_LOCAL, LOCAL_PEERPID, &pid, &so_len) != 0) {
+ ErrorF("getsockopt failed to determine pid of socket %d: %s\n", fd, strerror(errno));
+ } else {
+ lcc->pid = pid;
+ lcc->fieldsSet |= LCC_PID_SET;
+ }
+#endif
+
+ return 0;
#endif
#else
/* No system call available to get the credentials of the peer */
@@ -1603,13 +1640,6 @@ ChangeAccessControl(ClientPtr client, int fEnabled)
return Success;
}
-/* returns FALSE if xhost + in effect, else TRUE */
-int
-GetAccessControl(void)
-{
- return AccessEnabled;
-}
-
int
GetClientFd(ClientPtr client)
{
diff --git a/os/alloc.c b/os/alloc.c
new file mode 100644
index 000000000..d808b0fe8
--- /dev/null
+++ b/os/alloc.c
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 1987, 1998 The Open Group
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#include <dix-config.h>
+
+#include <stdlib.h>
+
+#include "os.h"
+
+void *
+XNFalloc(unsigned long amount)
+{
+ void *ptr = malloc(amount);
+
+ if (!ptr)
+ FatalError("Out of memory");
+ return ptr;
+}
+
+/* The original XNFcalloc was used with the xnfcalloc macro which multiplied
+ * the arguments at the call site without allowing calloc to check for overflow.
+ * XNFcallocarray was added to fix that without breaking ABI.
+ */
+void *
+XNFcalloc(unsigned long amount)
+{
+ return XNFcallocarray(1, amount);
+}
+
+void *
+XNFcallocarray(size_t nmemb, size_t size)
+{
+ void *ret = calloc(nmemb, size);
+
+ if (!ret)
+ FatalError("XNFcalloc: Out of memory");
+ return ret;
+}
+
+void *
+XNFrealloc(void *ptr, unsigned long amount)
+{
+ void *ret = realloc(ptr, amount);
+
+ if (!ret)
+ FatalError("XNFrealloc: Out of memory");
+ return ret;
+}
+
+void *
+XNFreallocarray(void *ptr, size_t nmemb, size_t size)
+{
+ void *ret = reallocarray(ptr, nmemb, size);
+
+ if (!ret)
+ FatalError("XNFreallocarray: Out of memory");
+ return ret;
+}
diff --git a/os/audit.h b/os/audit.h
new file mode 100644
index 000000000..205109489
--- /dev/null
+++ b/os/audit.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_OS_AUDIT_H
+#define _XSERVER_OS_AUDIT_H
+
+#include <stdarg.h>
+#include <X11/Xfuncproto.h>
+
+extern int auditTrailLevel;
+
+void FreeAuditTimer(void);
+
+void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2);
+void VAuditF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1, 0);
+
+#endif /* _XSERVER_OS_AUDIT_H */
diff --git a/os/auth.c b/os/auth.c
index 611e4efb1..20752eeb5 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -46,9 +46,14 @@ from The Open Group.
#ifdef WIN32
#include <X11/Xw32defs.h>
#endif
-#ifdef HAVE_LIBBSD
-#include <bsd/stdlib.h> /* for arc4random_buf() */
-#endif
+#include <stdlib.h> /* for arc4random_buf() */
+
+#include "os/auth.h"
+
+#include "rpcauth.h"
+#include "xdmcp.h"
+#include "xdmauth.h"
+#include "mitauth.h"
struct protocol {
unsigned short name_length;
diff --git a/os/auth.h b/os/auth.h
new file mode 100644
index 000000000..e03144f11
--- /dev/null
+++ b/os/auth.h
@@ -0,0 +1,114 @@
+#ifndef _XSERVER_OS_AUTH_H
+#define _XSERVER_OS_AUTH_H
+
+#include <X11/X.h>
+
+#include "dix.h"
+
+#define AuthInitArgs void
+typedef void (*AuthInitFunc) (AuthInitArgs);
+
+#define AuthAddCArgs unsigned short data_length, const char *data, XID id
+typedef int (*AuthAddCFunc) (AuthAddCArgs);
+
+#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason
+typedef XID (*AuthCheckFunc) (AuthCheckArgs);
+
+#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
+typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
+
+#define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return
+typedef XID (*AuthGenCFunc) (AuthGenCArgs);
+
+#define AuthRemCArgs unsigned short data_length, const char *data
+typedef int (*AuthRemCFunc) (AuthRemCArgs);
+
+#define AuthRstCArgs void
+typedef int (*AuthRstCFunc) (AuthRstCArgs);
+
+int set_font_authorizations(char **authorizations,
+ int *authlen,
+ void *client);
+
+#define LCC_UID_SET (1 << 0)
+#define LCC_GID_SET (1 << 1)
+#define LCC_PID_SET (1 << 2)
+#define LCC_ZID_SET (1 << 3)
+
+typedef struct {
+ int fieldsSet; /* Bit mask of fields set */
+ int euid; /* Effective uid */
+ int egid; /* Primary effective group id */
+ int nSuppGids; /* Number of supplementary group ids */
+ int *pSuppGids; /* Array of supplementary group ids */
+ int pid; /* Process id */
+ int zoneid; /* Only set on Solaris 10 & later */
+} LocalClientCredRec;
+
+int GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
+void FreeLocalClientCreds(LocalClientCredRec *);
+
+void EnableLocalAccess(void);
+void DisableLocalAccess(void);
+
+void LocalAccessScopeUser(void);
+
+void InitAuthorization(const char *filename);
+
+int AuthorizationFromID(XID id,
+ unsigned short *name_lenp,
+ const char **namep,
+ unsigned short *data_lenp, char **datap);
+
+XID CheckAuthorization(unsigned int namelength,
+ const char *name,
+ unsigned int datalength,
+ const char *data,
+ ClientPtr client,
+ const char **reason);
+
+void ResetAuthorization(void);
+
+int RemoveAuthorization(unsigned short name_length,
+ const char *name,
+ unsigned short data_length, const char *data);
+
+int AddAuthorization(unsigned int name_length,
+ const char *name,
+ unsigned int data_length,
+ char *data);
+
+XID GenerateAuthorization(unsigned int name_length,
+ const char *name,
+ unsigned int data_length,
+ const char *data,
+ unsigned int *data_length_return,
+ char **data_return);
+
+void RegisterAuthorizations(void);
+
+void CheckUserAuthorization(void);
+
+typedef struct sockaddr *sockaddrPtr;
+
+int AddHost(ClientPtr client, int family, unsigned length, const void *pAddr);
+Bool ForEachHostInFamily(int family,
+ Bool (*func)(unsigned char *addr, short len, void *closure),
+ void *closure);
+int RemoveHost(ClientPtr client, int family, unsigned length, void *pAddr);
+int GetHosts(void **data, int *pnHosts, int *pLen, BOOL *pEnabled);
+int InvalidHost(sockaddrPtr saddr, int len, ClientPtr client);
+void AddLocalHosts(void);
+void ResetHosts(const char *display);
+
+/* register local hosts entries for outself, based on listening fd */
+void DefineSelf(int fd);
+
+/* check whether given addr belongs to ourself */
+void AugmentSelf(void *from, int len);
+
+int ChangeAccessControl(ClientPtr client, int fEnabled);
+
+void AccessUsingXdmcp(void);
+
+#endif /* _XSERVER_OS_AUTH_H */
diff --git a/os/backtrace.c b/os/backtrace.c
index 8025bffae..e4cb91b1c 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -27,9 +27,14 @@
#include "os.h"
#include "misc.h"
+
#include <errno.h>
#include <string.h>
+#ifndef WIN32
+#include <sys/wait.h>
+#endif
+
#ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY
diff --git a/os/busfault.c b/os/busfault.c
index a2d433a2e..7e6d4612e 100644
--- a/os/busfault.c
+++ b/os/busfault.c
@@ -26,8 +26,10 @@
#include <X11/Xos.h>
#include <X11/Xdefs.h>
+
+#include "os/busfault.h"
+
#include "misc.h"
-#include <busfault.h>
#include <list.h>
#include <stddef.h>
#include <stdlib.h>
diff --git a/include/busfault.h b/os/busfault.h
index 3b668818d..0cc5a6d80 100644
--- a/include/busfault.h
+++ b/os/busfault.h
@@ -25,7 +25,11 @@
#include <dix-config.h>
-#ifdef BUSFAULT
+#include <X11/Xdefs.h>
+
+#include "misc.h" /* for TRUE/FALSE */
+
+#ifdef HAVE_SIGACTION
#include <sys/types.h>
@@ -43,6 +47,11 @@ busfault_check(void);
Bool
busfault_init(void);
+#else
+
+static inline void busfault_check(void) {}
+static inline Bool busfault_init(void) { return FALSE; }
+
#endif
#endif /* _BUSFAULT_H_ */
diff --git a/os/client.c b/os/client.c
index 89a92d5b5..6a119afc1 100644
--- a/os/client.c
+++ b/os/client.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All
* rights reserved.
- * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1993, 2010, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -73,6 +73,19 @@
#include <limits.h>
#endif
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+#include <sys/sysctl.h>
+#include <errno.h>
+#endif
+
+#ifdef __APPLE__
+#include <dispatch/dispatch.h>
+#include <errno.h>
+#include <sys/sysctl.h>
+#endif
+
+#include "os/auth.h"
+
/**
* Try to determine a PID for a client from its connection
* information. This should be called only once when new client has
@@ -130,9 +143,11 @@ DetermineClientPid(struct _Client * client)
void
DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
{
+#if !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__)
char path[PATH_MAX + 1];
int totsize = 0;
int fd = 0;
+#endif
if (cmdname)
*cmdname = NULL;
@@ -142,7 +157,157 @@ DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
if (pid == -1)
return;
-#if defined(__OpenBSD__)
+#if defined (__APPLE__)
+ {
+ static dispatch_once_t once;
+ static int argmax;
+ dispatch_once(&once, ^{
+ int mib[2];
+ size_t len;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_ARGMAX;
+
+ len = sizeof(argmax);
+ if (sysctl(mib, 2, &argmax, &len, NULL, 0) == -1) {
+ ErrorF("Unable to dynamically determine kern.argmax, using ARG_MAX (%d)\n", ARG_MAX);
+ argmax = ARG_MAX;
+ }
+ });
+
+ int mib[3];
+ size_t len = argmax;
+ int32_t argc = -1;
+
+ char * const procargs = malloc(len);
+ if (!procargs) {
+ ErrorF("Failed to allocate memory (%lu bytes) for KERN_PROCARGS2 result for pid %d: %s\n", len, pid, strerror(errno));
+ return;
+ }
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROCARGS2;
+ mib[2] = pid;
+
+ if (sysctl(mib, 3, procargs, &len, NULL, 0) == -1) {
+ ErrorF("Failed to determine KERN_PROCARGS2 for pid %d: %s\n", pid, strerror(errno));
+ free(procargs);
+ return;
+ }
+
+ if (len < sizeof(argc) || len > argmax) {
+ ErrorF("Erroneous length returned when querying KERN_PROCARGS2 for pid %d: %zu\n", pid, len);
+ free(procargs);
+ return;
+ }
+
+ /* Ensure we have a failsafe NUL termination just in case the last entry
+ * was not actually NUL terminated.
+ */
+ procargs[len-1] = '\0';
+
+ /* Setup our iterator */
+ char *is = procargs;
+
+ /* The first element in the buffer is argc as a 32bit int. When using
+ * the older KERN_PROCARGS, this is omitted, and one needs to guess
+ * (usually by checking for an `=` character) when we start seeing
+ * envvars instead of arguments.
+ */
+ argc = *(int32_t *)is;
+ is += sizeof(argc);
+
+ /* The very next string is the executable path. Skip over it since
+ * this function wants to return argv[0] and argv[1...n].
+ */
+ is += strlen(is) + 1;
+
+ /* Skip over extra NUL characters to get to the start of argv[0] */
+ for (; (is < &procargs[len]) && !(*is); is++);
+
+ if (! (is < &procargs[len])) {
+ ErrorF("Arguments were not returned when querying KERN_PROCARGS2 for pid %d: %zu\n", pid, len);
+ free(procargs);
+ return;
+ }
+
+ if (cmdname) {
+ *cmdname = strdup(is);
+ }
+
+ /* Jump over argv[0] and point to argv[1] */
+ is += strlen(is) + 1;
+
+ if (cmdargs && is < &procargs[len]) {
+ char *args = is;
+
+ /* Remove the NUL terminators except the last one */
+ for (int i = 1; i < argc - 1; i++) {
+ /* Advance to the NUL terminator */
+ is += strlen(is);
+
+ /* Change the NUL to a space, ensuring we don't accidentally remove the terminal NUL */
+ if (is < &procargs[len-1]) {
+ *is = ' ';
+ }
+ }
+
+ *cmdargs = strdup(args);
+ }
+
+ free(procargs);
+ }
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ /* on DragonFly and FreeBSD use KERN_PROC_ARGS */
+ {
+ int mib[] = {
+ CTL_KERN,
+ KERN_PROC,
+ KERN_PROC_ARGS,
+ pid,
+ };
+
+ /* Determine exact size instead of relying on kern.argmax */
+ size_t len;
+ if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) != 0) {
+ ErrorF("Failed to query KERN_PROC_ARGS length for PID %d: %s\n", pid, strerror(errno));
+ return;
+ }
+
+ /* Read KERN_PROC_ARGS contents. Similar to /proc/pid/cmdline
+ * the process name and each argument are separated by NUL byte. */
+ char *const procargs = malloc(len);
+ if (sysctl(mib, ARRAY_SIZE(mib), procargs, &len, NULL, 0) != 0) {
+ ErrorF("Failed to get KERN_PROC_ARGS for PID %d: %s\n", pid, strerror(errno));
+ free(procargs);
+ return;
+ }
+
+ /* Construct the process name without arguments. */
+ if (cmdname) {
+ *cmdname = strdup(procargs);
+ }
+
+ /* Construct the arguments for client process. */
+ if (cmdargs) {
+ size_t cmdsize = strlen(procargs) + 1;
+ size_t argsize = len - cmdsize;
+ char *args = NULL;
+
+ if (argsize > 0)
+ args = procargs + cmdsize;
+ if (args) {
+ /* Replace NUL with space except terminating NUL */
+ for (size_t i = 0; i < (argsize - 1); i++) {
+ if (args[i] == '\0')
+ args[i] = ' ';
+ }
+ *cmdargs = strdup(args);
+ }
+ }
+ free(procargs);
+ }
+#elif defined(__OpenBSD__)
/* on OpenBSD use kvm_getargv() */
{
kvm_t *kd;
diff --git a/os/cmdline.h b/os/cmdline.h
new file mode 100644
index 000000000..9a4a19467
--- /dev/null
+++ b/os/cmdline.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_OS_CMDLINE_H
+#define _XSERVER_OS_CMDLINE_H
+
+#include "include/os.h"
+
+#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \
+ do if (((i + num) >= argc) || (!argv[i + num])) { \
+ UseMsg(); \
+ FatalError("Required argument to %s not specified\n", argv[i]); \
+ } while (0)
+
+void UseMsg(void);
+void ProcessCommandLine(int argc, char * argv[]);
+void CheckUserParameters(int argc, char **argv, char **envp);
+
+#endif /* _XSERVER_OS_CMELINE_H */
diff --git a/os/connection.c b/os/connection.c
index 55f1cd32e..bd46ae68b 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -87,30 +87,25 @@ SOFTWARE.
#if defined(TCPCONN)
#include <netinet/in.h>
#include <arpa/inet.h>
-#ifdef apollo
-#ifndef NO_TCP_H
-#include <netinet/tcp.h>
-#endif
-#else
#ifdef CSRG_BASED
#include <sys/param.h>
#endif
#include <netinet/tcp.h>
-#endif
#include <arpa/inet.h>
#endif
-
#include <sys/uio.h>
-
#endif /* WIN32 */
+
+#include "dix/dix_priv.h"
+#include "os/audit.h"
+#include "os/auth.h"
+#include "os/osdep.h"
+
#include "misc.h" /* for typedef of pointer */
-#include "osdep.h"
#include "opaque.h"
#include "dixstruct.h"
#include "xace.h"
-#define Pid_t pid_t
-
#ifdef HAVE_GETPEERUCRED
#include <ucred.h>
#include <zone.h>
@@ -123,18 +118,21 @@ SOFTWARE.
#endif
#include "probes.h"
+#include "xdmcp.h"
struct ospoll *server_poll;
Bool NewOutputPending; /* not yet attempted to write some new output */
Bool NoListenAll; /* Don't establish any listening sockets */
-static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
equivalent) will send SIGCONT back. */
static char dynamic_display[7]; /* display name */
Bool PartialNetwork; /* continue even if unable to bind all addrs */
-static Pid_t ParentProcess;
+#if !defined(WIN32)
+static pid_t ParentProcess;
+static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+#endif
int GrabInProgress = 0;
@@ -637,8 +635,8 @@ AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time)
set_poll_client(client);
#ifdef DEBUG
- ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n",
- client->index, fd);
+ ErrorF("AllocNewConnection: client index = %d, socket fd = %d, local = %d\n",
+ client->index, fd, client->local);
#endif
#ifdef XSERVER_DTRACE
XSERVER_CLIENT_CONNECT(client->index, fd);
@@ -1018,7 +1016,7 @@ ListenOnOpenFD(int fd, int noxauth)
}
}
- if (!display_env) {
+ if (!display_env || display_env[0] != '/') {
/* Just some default so things don't break and die. */
snprintf(port, sizeof(port), ":%d", atoi(display));
}
diff --git a/os/fmt.c b/os/fmt.c
new file mode 100644
index 000000000..c5c61bdba
--- /dev/null
+++ b/os/fmt.c
@@ -0,0 +1,101 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 1987, 1998 The Open Group
+ * Copyright © 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+ * Copyright © 1994 Quarterdeck Office Systems.
+ */
+
+#include <stdint.h>
+
+#include "os/fmt.h"
+
+/* Format a signed number into a string in a signal safe manner. The string
+ * should be at least 21 characters in order to handle all int64_t values.
+ */
+void
+FormatInt64(int64_t num, char *string)
+{
+ if (num < 0) {
+ string[0] = '-';
+ num *= -1;
+ string++;
+ }
+ FormatUInt64(num, string);
+}
+
+/* Format a number into a string in a signal safe manner. The string should be
+ * at least 21 characters in order to handle all uint64_t values. */
+void
+FormatUInt64(uint64_t num, char *string)
+{
+ uint64_t divisor;
+ int len;
+ int i;
+
+ for (len = 1, divisor = 10;
+ len < 20 && num / divisor;
+ len++, divisor *= 10);
+
+ for (i = len, divisor = 1; i > 0; i--, divisor *= 10)
+ string[i - 1] = '0' + ((num / divisor) % 10);
+
+ string[len] = '\0';
+}
+
+/**
+ * Format a double number as %.2f.
+ */
+void
+FormatDouble(double dbl, char *string)
+{
+ int slen = 0;
+ uint64_t frac;
+
+ frac = (dbl > 0 ? dbl : -dbl) * 100.0 + 0.5;
+ frac %= 100;
+
+ /* write decimal part to string */
+ if (dbl < 0 && dbl > -1)
+ string[slen++] = '-';
+ FormatInt64((int64_t)dbl, &string[slen]);
+
+ while(string[slen] != '\0')
+ slen++;
+
+ /* append fractional part, but only if we have enough characters. We
+ * expect string to be 21 chars (incl trailing \0) */
+ if (slen <= 17) {
+ string[slen++] = '.';
+ if (frac < 10)
+ string[slen++] = '0';
+
+ FormatUInt64(frac, &string[slen]);
+ }
+}
+
+
+/* Format a number into a hexadecimal string in a signal safe manner. The string
+ * should be at least 17 characters in order to handle all uint64_t values. */
+void
+FormatUInt64Hex(uint64_t num, char *string)
+{
+ uint64_t divisor;
+ int len;
+ int i;
+
+ for (len = 1, divisor = 0x10;
+ len < 16 && num / divisor;
+ len++, divisor *= 0x10);
+
+ for (i = len, divisor = 1; i > 0; i--, divisor *= 0x10) {
+ int val = (num / divisor) % 0x10;
+
+ if (val < 10)
+ string[i - 1] = '0' + val;
+ else
+ string[i - 1] = 'a' + val - 10;
+ }
+
+ string[len] = '\0';
+}
diff --git a/os/fmt.h b/os/fmt.h
new file mode 100644
index 000000000..63cdfe99f
--- /dev/null
+++ b/os/fmt.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#ifndef _XSERVER_OS_FMT_H
+#define _XSERVER_OS_FMT_H
+
+#include <stdint.h>
+
+void FormatInt64(int64_t num, char *string);
+void FormatUInt64(uint64_t num, char *string);
+void FormatUInt64Hex(uint64_t num, char *string);
+void FormatDouble(double dbl, char *string);
+
+#endif /* _XSERVER_OS_FMT_H */
diff --git a/os/io.c b/os/io.c
index 5b7fac349..1e9258cd0 100644
--- a/os/io.c
+++ b/os/io.c
@@ -72,6 +72,9 @@ SOFTWARE.
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
+
+#include "dix/dix_priv.h"
+
#include "os.h"
#include "osdep.h"
#include "opaque.h"
@@ -790,7 +793,7 @@ WriteToClient(ClientPtr who, int count, const void *__buf)
}
}
#endif
- if (oco->count == 0 || oco->count + count + padBytes > oco->size) {
+ if ((oco->count == 0 && who->local) || oco->count + count + padBytes > oco->size) {
output_pending_clear(who);
if (!any_output_pending()) {
CriticalOutputPending = FALSE;
@@ -890,9 +893,6 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
todo = notWritten;
}
else if (ETEST(errno)
-#ifdef SUNSYSV /* check for another brain-damaged OS bug */
- || (errno == 0)
-#endif
#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
|| ((errno == EMSGSIZE) && (todo == 1))
#endif
diff --git a/os/log.c b/os/log.c
index 4bd6b7e9a..c6869bdbb 100644
--- a/os/log.c
+++ b/os/log.c
@@ -79,13 +79,18 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include <dix-config.h>
#endif
-#include <X11/Xos.h>
+#include <errno.h>
#include <stdio.h>
-#include <time.h>
-#include <sys/stat.h>
#include <stdarg.h>
#include <stdlib.h> /* for malloc() */
-#include <errno.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <X11/Xos.h>
+
+#include "os/osdep.h"
+
+#include "os/audit.h"
+#include "os/fmt.h"
#include "input.h"
#include "opaque.h"
@@ -103,9 +108,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
-#ifdef DDXOSVERRORF
void (*OsVendorVErrorFProc) (const char *, va_list args) = NULL;
-#endif
/* Default logging parameters. */
#ifndef DEFAULT_LOG_VERBOSITY
@@ -612,8 +615,20 @@ LogSWrite(int verb, const char *buf, size_t len, Bool end_line)
#endif
}
else if (!inSignalContext && logFile) {
- if (newline)
- fprintf(logFile, "[%10.3f] ", GetTimeInMillis() / 1000.0);
+ if (newline) {
+ time_t t = time(NULL);
+ struct tm tm;
+ char fmt_tm[32];
+
+#ifdef WIN32
+ localtime_s(&tm, &t);
+#else
+ localtime_r(&t, &tm);
+#endif
+ strftime(fmt_tm, sizeof(fmt_tm) - 1, "%Y-%m-%d %H:%M:%S", &tm);
+
+ fprintf(logFile, "[%s] ", fmt_tm);
+ }
newline = end_line;
fwrite(buf, len, 1, logFile);
if (logFlush) {
@@ -889,6 +904,8 @@ static int nrepeat = 0;
static int oldlen = -1;
static OsTimerPtr auditTimer = NULL;
+int auditTrailLevel = 1;
+
void
FreeAuditTimer(void)
{
@@ -1023,14 +1040,10 @@ FatalError(const char *f, ...)
void
VErrorF(const char *f, va_list args)
{
-#ifdef DDXOSVERRORF
if (OsVendorVErrorFProc)
OsVendorVErrorFProc(f, args);
else
LogVWrite(-1, f, args);
-#else
- LogVWrite(-1, f, args);
-#endif
}
void
diff --git a/os/meson.build b/os/meson.build
index ab28fc4ed..25a00af90 100644
--- a/os/meson.build
+++ b/os/meson.build
@@ -1,16 +1,18 @@
srcs_os = [
'WaitFor.c',
'access.c',
+ 'alloc.c',
'auth.c',
'backtrace.c',
'client.c',
'connection.c',
+ 'fmt.c',
'inputthread.c',
'io.c',
'mitauth.c',
- 'oscolor.c',
'osinit.c',
'ospoll.c',
+ 'string.c',
'utils.c',
'xdmauth.c',
'xsha1.c',
@@ -46,7 +48,7 @@ if conf_data.get('HAVE_POLL').to_int() == 0
srcs_os += 'xserver_poll.c'
endif
-if conf_data.get('BUSFAULT').to_int() != 0
+if conf_data.get('HAVE_SIGACTION').to_int() != 0
srcs_os += 'busfault.c'
endif
@@ -54,20 +56,44 @@ if get_option('xdmcp')
srcs_os += 'xdmcp.c'
endif
+os_dep = []
+os_c_args = []
+
rpc_dep = []
-if get_option('secure-rpc')
+opt_secure_rpc = get_option('secure-rpc')
+if opt_secure_rpc != 'false'
+ build_secure_rpc = true
+
# prefer libtirpc (if available), otherwise ensure RPC functions are
# provided by libc.
- rpc_dep = dependency('libtirpc', required: false)
+ rpc_dep = dependency('libtirpc', required: false, include_type: 'system')
if not (rpc_dep.found() or cc.has_header('rpc/rpc.h'))
- error('secure-rpc requested, but neither libtirpc or libc RPC support were found')
+ if opt_secure_rpc == 'true'
+ error('secure-rpc requested, but neither libtirpc or libc RPC support were found')
+ else
+ message('secure-rpc disabled since neither libtirpc or libc RPC support were found')
+ build_secure_rpc = false
+ endif
endif
# XXX: also check if RPC library provides xdr_opaque_auth, authdes_(sec)create ???
- srcs_os += 'rpcauth.c'
+
+ if not (cc.has_member('struct authdes_cred', 'adc_fullname',
+ prefix : '#include <rpc/rpc.h>',
+ dependencies: rpc_dep))
+ if opt_secure_rpc == 'true'
+ error('secure-rpc requested, but RPC implementation lacking struct authdes_cred')
+ else
+ message('secure-rpc disable since RPC implementation lacking struct authdes_cred')
+ build_secure_rpc = false
+ endif
+ endif
+
+ if build_secure_rpc
+ os_c_args += '-DSECURE_RPC'
+ srcs_os += 'rpcauth.c'
+ endif
endif
-os_dep = []
-os_c_args = []
if get_option('xres')
# Only the XRes extension cares about the client ID.
os_c_args += '-DCLIENTIDS'
diff --git a/os/mitauth.c b/os/mitauth.c
index a268f62f9..44e3329c2 100644
--- a/os/mitauth.c
+++ b/os/mitauth.c
@@ -38,6 +38,7 @@ from The Open Group.
#include <X11/X.h>
#include "os.h"
#include "osdep.h"
+#include "mitauth.h"
#include "dixstruct.h"
static struct auth {
@@ -62,7 +63,7 @@ MitAddCookie(unsigned short data_length, const char *data, XID id)
}
new->next = mit_auth;
mit_auth = new;
- memmove(new->data, data, (int) data_length);
+ memcpy(new->data, data, (size_t) data_length);
new->len = data_length;
new->id = id;
return 1;
diff --git a/os/mitauth.h b/os/mitauth.h
new file mode 100644
index 000000000..143fa46bc
--- /dev/null
+++ b/os/mitauth.h
@@ -0,0 +1,13 @@
+#ifndef _XSERVER_OS_MITAUTH_H
+#define _XSERVER_OS_MITAUTH_H
+
+#include "auth.h"
+
+XID MitCheckCookie(AuthCheckArgs);
+XID MitGenerateCookie(AuthGenCArgs);
+int MitAddCookie(AuthAddCArgs);
+int MitFromID(AuthFromIDArgs);
+int MitRemoveCookie(AuthRemCArgs);
+int MitResetCookie(AuthRstCArgs);
+
+#endif /* _XSERVER_OS_MITAUTH_H */
diff --git a/os/oscolor.c b/os/oscolor.c
deleted file mode 100644
index af83c6ada..000000000
--- a/os/oscolor.c
+++ /dev/null
@@ -1,1661 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/keysym.h>
-#include "dix.h"
-#include "os.h"
-
-typedef struct _builtinColor {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned short name;
-} BuiltinColor;
-
-static const char BuiltinColorNames[] = {
- "alice blue\0"
- "AliceBlue\0"
- "antique white\0"
- "AntiqueWhite\0"
- "AntiqueWhite1\0"
- "AntiqueWhite2\0"
- "AntiqueWhite3\0"
- "AntiqueWhite4\0"
- "aqua\0"
- "aquamarine\0"
- "aquamarine1\0"
- "aquamarine2\0"
- "aquamarine3\0"
- "aquamarine4\0"
- "azure\0"
- "azure1\0"
- "azure2\0"
- "azure3\0"
- "azure4\0"
- "beige\0"
- "bisque\0"
- "bisque1\0"
- "bisque2\0"
- "bisque3\0"
- "bisque4\0"
- "black\0"
- "blanched almond\0"
- "BlanchedAlmond\0"
- "blue\0"
- "blue violet\0"
- "blue1\0"
- "blue2\0"
- "blue3\0"
- "blue4\0"
- "BlueViolet\0"
- "brown\0"
- "brown1\0"
- "brown2\0"
- "brown3\0"
- "brown4\0"
- "burlywood\0"
- "burlywood1\0"
- "burlywood2\0"
- "burlywood3\0"
- "burlywood4\0"
- "cadet blue\0"
- "CadetBlue\0"
- "CadetBlue1\0"
- "CadetBlue2\0"
- "CadetBlue3\0"
- "CadetBlue4\0"
- "chartreuse\0"
- "chartreuse1\0"
- "chartreuse2\0"
- "chartreuse3\0"
- "chartreuse4\0"
- "chocolate\0"
- "chocolate1\0"
- "chocolate2\0"
- "chocolate3\0"
- "chocolate4\0"
- "coral\0"
- "coral1\0"
- "coral2\0"
- "coral3\0"
- "coral4\0"
- "cornflower blue\0"
- "CornflowerBlue\0"
- "cornsilk\0"
- "cornsilk1\0"
- "cornsilk2\0"
- "cornsilk3\0"
- "cornsilk4\0"
- "crimson\0"
- "cyan\0"
- "cyan1\0"
- "cyan2\0"
- "cyan3\0"
- "cyan4\0"
- "dark blue\0"
- "dark cyan\0"
- "dark goldenrod\0"
- "dark gray\0"
- "dark green\0"
- "dark grey\0"
- "dark khaki\0"
- "dark magenta\0"
- "dark olive green\0"
- "dark orange\0"
- "dark orchid\0"
- "dark red\0"
- "dark salmon\0"
- "dark sea green\0"
- "dark slate blue\0"
- "dark slate gray\0"
- "dark slate grey\0"
- "dark turquoise\0"
- "dark violet\0"
- "DarkBlue\0"
- "DarkCyan\0"
- "DarkGoldenrod\0"
- "DarkGoldenrod1\0"
- "DarkGoldenrod2\0"
- "DarkGoldenrod3\0"
- "DarkGoldenrod4\0"
- "DarkGray\0"
- "DarkGreen\0"
- "DarkGrey\0"
- "DarkKhaki\0"
- "DarkMagenta\0"
- "DarkOliveGreen\0"
- "DarkOliveGreen1\0"
- "DarkOliveGreen2\0"
- "DarkOliveGreen3\0"
- "DarkOliveGreen4\0"
- "DarkOrange\0"
- "DarkOrange1\0"
- "DarkOrange2\0"
- "DarkOrange3\0"
- "DarkOrange4\0"
- "DarkOrchid\0"
- "DarkOrchid1\0"
- "DarkOrchid2\0"
- "DarkOrchid3\0"
- "DarkOrchid4\0"
- "DarkRed\0"
- "DarkSalmon\0"
- "DarkSeaGreen\0"
- "DarkSeaGreen1\0"
- "DarkSeaGreen2\0"
- "DarkSeaGreen3\0"
- "DarkSeaGreen4\0"
- "DarkSlateBlue\0"
- "DarkSlateGray\0"
- "DarkSlateGray1\0"
- "DarkSlateGray2\0"
- "DarkSlateGray3\0"
- "DarkSlateGray4\0"
- "DarkSlateGrey\0"
- "DarkTurquoise\0"
- "DarkViolet\0"
- "deep pink\0"
- "deep sky blue\0"
- "DeepPink\0"
- "DeepPink1\0"
- "DeepPink2\0"
- "DeepPink3\0"
- "DeepPink4\0"
- "DeepSkyBlue\0"
- "DeepSkyBlue1\0"
- "DeepSkyBlue2\0"
- "DeepSkyBlue3\0"
- "DeepSkyBlue4\0"
- "dim gray\0"
- "dim grey\0"
- "DimGray\0"
- "DimGrey\0"
- "dodger blue\0"
- "DodgerBlue\0"
- "DodgerBlue1\0"
- "DodgerBlue2\0"
- "DodgerBlue3\0"
- "DodgerBlue4\0"
- "firebrick\0"
- "firebrick1\0"
- "firebrick2\0"
- "firebrick3\0"
- "firebrick4\0"
- "floral white\0"
- "FloralWhite\0"
- "forest green\0"
- "ForestGreen\0"
- "fuchsia\0"
- "gainsboro\0"
- "ghost white\0"
- "GhostWhite\0"
- "gold\0"
- "gold1\0"
- "gold2\0"
- "gold3\0"
- "gold4\0"
- "goldenrod\0"
- "goldenrod1\0"
- "goldenrod2\0"
- "goldenrod3\0"
- "goldenrod4\0"
- "gray\0"
- "gray0\0"
- "gray1\0"
- "gray10\0"
- "gray100\0"
- "gray11\0"
- "gray12\0"
- "gray13\0"
- "gray14\0"
- "gray15\0"
- "gray16\0"
- "gray17\0"
- "gray18\0"
- "gray19\0"
- "gray2\0"
- "gray20\0"
- "gray21\0"
- "gray22\0"
- "gray23\0"
- "gray24\0"
- "gray25\0"
- "gray26\0"
- "gray27\0"
- "gray28\0"
- "gray29\0"
- "gray3\0"
- "gray30\0"
- "gray31\0"
- "gray32\0"
- "gray33\0"
- "gray34\0"
- "gray35\0"
- "gray36\0"
- "gray37\0"
- "gray38\0"
- "gray39\0"
- "gray4\0"
- "gray40\0"
- "gray41\0"
- "gray42\0"
- "gray43\0"
- "gray44\0"
- "gray45\0"
- "gray46\0"
- "gray47\0"
- "gray48\0"
- "gray49\0"
- "gray5\0"
- "gray50\0"
- "gray51\0"
- "gray52\0"
- "gray53\0"
- "gray54\0"
- "gray55\0"
- "gray56\0"
- "gray57\0"
- "gray58\0"
- "gray59\0"
- "gray6\0"
- "gray60\0"
- "gray61\0"
- "gray62\0"
- "gray63\0"
- "gray64\0"
- "gray65\0"
- "gray66\0"
- "gray67\0"
- "gray68\0"
- "gray69\0"
- "gray7\0"
- "gray70\0"
- "gray71\0"
- "gray72\0"
- "gray73\0"
- "gray74\0"
- "gray75\0"
- "gray76\0"
- "gray77\0"
- "gray78\0"
- "gray79\0"
- "gray8\0"
- "gray80\0"
- "gray81\0"
- "gray82\0"
- "gray83\0"
- "gray84\0"
- "gray85\0"
- "gray86\0"
- "gray87\0"
- "gray88\0"
- "gray89\0"
- "gray9\0"
- "gray90\0"
- "gray91\0"
- "gray92\0"
- "gray93\0"
- "gray94\0"
- "gray95\0"
- "gray96\0"
- "gray97\0"
- "gray98\0"
- "gray99\0"
- "green\0"
- "green yellow\0"
- "green1\0"
- "green2\0"
- "green3\0"
- "green4\0"
- "GreenYellow\0"
- "grey\0"
- "grey0\0"
- "grey1\0"
- "grey10\0"
- "grey100\0"
- "grey11\0"
- "grey12\0"
- "grey13\0"
- "grey14\0"
- "grey15\0"
- "grey16\0"
- "grey17\0"
- "grey18\0"
- "grey19\0"
- "grey2\0"
- "grey20\0"
- "grey21\0"
- "grey22\0"
- "grey23\0"
- "grey24\0"
- "grey25\0"
- "grey26\0"
- "grey27\0"
- "grey28\0"
- "grey29\0"
- "grey3\0"
- "grey30\0"
- "grey31\0"
- "grey32\0"
- "grey33\0"
- "grey34\0"
- "grey35\0"
- "grey36\0"
- "grey37\0"
- "grey38\0"
- "grey39\0"
- "grey4\0"
- "grey40\0"
- "grey41\0"
- "grey42\0"
- "grey43\0"
- "grey44\0"
- "grey45\0"
- "grey46\0"
- "grey47\0"
- "grey48\0"
- "grey49\0"
- "grey5\0"
- "grey50\0"
- "grey51\0"
- "grey52\0"
- "grey53\0"
- "grey54\0"
- "grey55\0"
- "grey56\0"
- "grey57\0"
- "grey58\0"
- "grey59\0"
- "grey6\0"
- "grey60\0"
- "grey61\0"
- "grey62\0"
- "grey63\0"
- "grey64\0"
- "grey65\0"
- "grey66\0"
- "grey67\0"
- "grey68\0"
- "grey69\0"
- "grey7\0"
- "grey70\0"
- "grey71\0"
- "grey72\0"
- "grey73\0"
- "grey74\0"
- "grey75\0"
- "grey76\0"
- "grey77\0"
- "grey78\0"
- "grey79\0"
- "grey8\0"
- "grey80\0"
- "grey81\0"
- "grey82\0"
- "grey83\0"
- "grey84\0"
- "grey85\0"
- "grey86\0"
- "grey87\0"
- "grey88\0"
- "grey89\0"
- "grey9\0"
- "grey90\0"
- "grey91\0"
- "grey92\0"
- "grey93\0"
- "grey94\0"
- "grey95\0"
- "grey96\0"
- "grey97\0"
- "grey98\0"
- "grey99\0"
- "honeydew\0"
- "honeydew1\0"
- "honeydew2\0"
- "honeydew3\0"
- "honeydew4\0"
- "hot pink\0"
- "HotPink\0"
- "HotPink1\0"
- "HotPink2\0"
- "HotPink3\0"
- "HotPink4\0"
- "indian red\0"
- "IndianRed\0"
- "IndianRed1\0"
- "IndianRed2\0"
- "IndianRed3\0"
- "IndianRed4\0"
- "indigo\0"
- "ivory\0"
- "ivory1\0"
- "ivory2\0"
- "ivory3\0"
- "ivory4\0"
- "khaki\0"
- "khaki1\0"
- "khaki2\0"
- "khaki3\0"
- "khaki4\0"
- "lavender\0"
- "lavender blush\0"
- "LavenderBlush\0"
- "LavenderBlush1\0"
- "LavenderBlush2\0"
- "LavenderBlush3\0"
- "LavenderBlush4\0"
- "lawn green\0"
- "LawnGreen\0"
- "lemon chiffon\0"
- "LemonChiffon\0"
- "LemonChiffon1\0"
- "LemonChiffon2\0"
- "LemonChiffon3\0"
- "LemonChiffon4\0"
- "light blue\0"
- "light coral\0"
- "light cyan\0"
- "light goldenrod\0"
- "light goldenrod yellow\0"
- "light gray\0"
- "light green\0"
- "light grey\0"
- "light pink\0"
- "light salmon\0"
- "light sea green\0"
- "light sky blue\0"
- "light slate blue\0"
- "light slate gray\0"
- "light slate grey\0"
- "light steel blue\0"
- "light yellow\0"
- "LightBlue\0"
- "LightBlue1\0"
- "LightBlue2\0"
- "LightBlue3\0"
- "LightBlue4\0"
- "LightCoral\0"
- "LightCyan\0"
- "LightCyan1\0"
- "LightCyan2\0"
- "LightCyan3\0"
- "LightCyan4\0"
- "LightGoldenrod\0"
- "LightGoldenrod1\0"
- "LightGoldenrod2\0"
- "LightGoldenrod3\0"
- "LightGoldenrod4\0"
- "LightGoldenrodYellow\0"
- "LightGray\0"
- "LightGreen\0"
- "LightGrey\0"
- "LightPink\0"
- "LightPink1\0"
- "LightPink2\0"
- "LightPink3\0"
- "LightPink4\0"
- "LightSalmon\0"
- "LightSalmon1\0"
- "LightSalmon2\0"
- "LightSalmon3\0"
- "LightSalmon4\0"
- "LightSeaGreen\0"
- "LightSkyBlue\0"
- "LightSkyBlue1\0"
- "LightSkyBlue2\0"
- "LightSkyBlue3\0"
- "LightSkyBlue4\0"
- "LightSlateBlue\0"
- "LightSlateGray\0"
- "LightSlateGrey\0"
- "LightSteelBlue\0"
- "LightSteelBlue1\0"
- "LightSteelBlue2\0"
- "LightSteelBlue3\0"
- "LightSteelBlue4\0"
- "LightYellow\0"
- "LightYellow1\0"
- "LightYellow2\0"
- "LightYellow3\0"
- "LightYellow4\0"
- "lime\0"
- "lime green\0"
- "LimeGreen\0"
- "linen\0"
- "magenta\0"
- "magenta1\0"
- "magenta2\0"
- "magenta3\0"
- "magenta4\0"
- "maroon\0"
- "maroon1\0"
- "maroon2\0"
- "maroon3\0"
- "maroon4\0"
- "medium aquamarine\0"
- "medium blue\0"
- "medium orchid\0"
- "medium purple\0"
- "medium sea green\0"
- "medium slate blue\0"
- "medium spring green\0"
- "medium turquoise\0"
- "medium violet red\0"
- "MediumAquamarine\0"
- "MediumBlue\0"
- "MediumOrchid\0"
- "MediumOrchid1\0"
- "MediumOrchid2\0"
- "MediumOrchid3\0"
- "MediumOrchid4\0"
- "MediumPurple\0"
- "MediumPurple1\0"
- "MediumPurple2\0"
- "MediumPurple3\0"
- "MediumPurple4\0"
- "MediumSeaGreen\0"
- "MediumSlateBlue\0"
- "MediumSpringGreen\0"
- "MediumTurquoise\0"
- "MediumVioletRed\0"
- "midnight blue\0"
- "MidnightBlue\0"
- "mint cream\0"
- "MintCream\0"
- "misty rose\0"
- "MistyRose\0"
- "MistyRose1\0"
- "MistyRose2\0"
- "MistyRose3\0"
- "MistyRose4\0"
- "moccasin\0"
- "navajo white\0"
- "NavajoWhite\0"
- "NavajoWhite1\0"
- "NavajoWhite2\0"
- "NavajoWhite3\0"
- "NavajoWhite4\0"
- "navy\0"
- "navy blue\0"
- "NavyBlue\0"
- "old lace\0"
- "OldLace\0"
- "olive\0"
- "olive drab\0"
- "OliveDrab\0"
- "OliveDrab1\0"
- "OliveDrab2\0"
- "OliveDrab3\0"
- "OliveDrab4\0"
- "orange\0"
- "orange red\0"
- "orange1\0"
- "orange2\0"
- "orange3\0"
- "orange4\0"
- "OrangeRed\0"
- "OrangeRed1\0"
- "OrangeRed2\0"
- "OrangeRed3\0"
- "OrangeRed4\0"
- "orchid\0"
- "orchid1\0"
- "orchid2\0"
- "orchid3\0"
- "orchid4\0"
- "pale goldenrod\0"
- "pale green\0"
- "pale turquoise\0"
- "pale violet red\0"
- "PaleGoldenrod\0"
- "PaleGreen\0"
- "PaleGreen1\0"
- "PaleGreen2\0"
- "PaleGreen3\0"
- "PaleGreen4\0"
- "PaleTurquoise\0"
- "PaleTurquoise1\0"
- "PaleTurquoise2\0"
- "PaleTurquoise3\0"
- "PaleTurquoise4\0"
- "PaleVioletRed\0"
- "PaleVioletRed1\0"
- "PaleVioletRed2\0"
- "PaleVioletRed3\0"
- "PaleVioletRed4\0"
- "papaya whip\0"
- "PapayaWhip\0"
- "peach puff\0"
- "PeachPuff\0"
- "PeachPuff1\0"
- "PeachPuff2\0"
- "PeachPuff3\0"
- "PeachPuff4\0"
- "peru\0"
- "pink\0"
- "pink1\0"
- "pink2\0"
- "pink3\0"
- "pink4\0"
- "plum\0"
- "plum1\0"
- "plum2\0"
- "plum3\0"
- "plum4\0"
- "powder blue\0"
- "PowderBlue\0"
- "purple\0"
- "purple1\0"
- "purple2\0"
- "purple3\0"
- "purple4\0"
- "rebecca purple\0"
- "RebeccaPurple\0"
- "red\0"
- "red1\0"
- "red2\0"
- "red3\0"
- "red4\0"
- "rosy brown\0"
- "RosyBrown\0"
- "RosyBrown1\0"
- "RosyBrown2\0"
- "RosyBrown3\0"
- "RosyBrown4\0"
- "royal blue\0"
- "RoyalBlue\0"
- "RoyalBlue1\0"
- "RoyalBlue2\0"
- "RoyalBlue3\0"
- "RoyalBlue4\0"
- "saddle brown\0"
- "SaddleBrown\0"
- "salmon\0"
- "salmon1\0"
- "salmon2\0"
- "salmon3\0"
- "salmon4\0"
- "sandy brown\0"
- "SandyBrown\0"
- "sea green\0"
- "SeaGreen\0"
- "SeaGreen1\0"
- "SeaGreen2\0"
- "SeaGreen3\0"
- "SeaGreen4\0"
- "seashell\0"
- "seashell1\0"
- "seashell2\0"
- "seashell3\0"
- "seashell4\0"
- "sienna\0"
- "sienna1\0"
- "sienna2\0"
- "sienna3\0"
- "sienna4\0"
- "silver\0"
- "sky blue\0"
- "SkyBlue\0"
- "SkyBlue1\0"
- "SkyBlue2\0"
- "SkyBlue3\0"
- "SkyBlue4\0"
- "slate blue\0"
- "slate gray\0"
- "slate grey\0"
- "SlateBlue\0"
- "SlateBlue1\0"
- "SlateBlue2\0"
- "SlateBlue3\0"
- "SlateBlue4\0"
- "SlateGray\0"
- "SlateGray1\0"
- "SlateGray2\0"
- "SlateGray3\0"
- "SlateGray4\0"
- "SlateGrey\0"
- "snow\0"
- "snow1\0"
- "snow2\0"
- "snow3\0"
- "snow4\0"
- "spring green\0"
- "SpringGreen\0"
- "SpringGreen1\0"
- "SpringGreen2\0"
- "SpringGreen3\0"
- "SpringGreen4\0"
- "steel blue\0"
- "SteelBlue\0"
- "SteelBlue1\0"
- "SteelBlue2\0"
- "SteelBlue3\0"
- "SteelBlue4\0"
- "tan\0"
- "tan1\0"
- "tan2\0"
- "tan3\0"
- "tan4\0"
- "teal\0"
- "thistle\0"
- "thistle1\0"
- "thistle2\0"
- "thistle3\0"
- "thistle4\0"
- "tomato\0"
- "tomato1\0"
- "tomato2\0"
- "tomato3\0"
- "tomato4\0"
- "turquoise\0"
- "turquoise1\0"
- "turquoise2\0"
- "turquoise3\0"
- "turquoise4\0"
- "violet\0"
- "violet red\0"
- "VioletRed\0"
- "VioletRed1\0"
- "VioletRed2\0"
- "VioletRed3\0"
- "VioletRed4\0"
- "web gray\0"
- "web green\0"
- "web grey\0"
- "web maroon\0"
- "web purple\0"
- "WebGray\0"
- "WebGreen\0"
- "WebGrey\0"
- "WebMaroon\0"
- "WebPurple\0"
- "wheat\0"
- "wheat1\0"
- "wheat2\0"
- "wheat3\0"
- "wheat4\0"
- "white\0"
- "white smoke\0"
- "WhiteSmoke\0"
- "x11 gray\0"
- "x11 green\0"
- "x11 grey\0"
- "x11 maroon\0"
- "x11 purple\0"
- "X11Gray\0"
- "X11Green\0"
- "X11Grey\0"
- "X11Maroon\0"
- "X11Purple\0"
- "yellow\0"
- "yellow green\0"
- "yellow1\0"
- "yellow2\0"
- "yellow3\0"
- "yellow4\0"
- "YellowGreen\0"
-};
-
-static const BuiltinColor BuiltinColors[] = {
- {240, 248, 255, 0}, /* alice blue */
- {240, 248, 255, 11}, /* AliceBlue */
- {250, 235, 215, 21}, /* antique white */
- {250, 235, 215, 35}, /* AntiqueWhite */
- {255, 239, 219, 48}, /* AntiqueWhite1 */
- {238, 223, 204, 62}, /* AntiqueWhite2 */
- {205, 192, 176, 76}, /* AntiqueWhite3 */
- {139, 131, 120, 90}, /* AntiqueWhite4 */
- {0, 255, 255, 104}, /* aqua */
- {127, 255, 212, 109}, /* aquamarine */
- {127, 255, 212, 120}, /* aquamarine1 */
- {118, 238, 198, 132}, /* aquamarine2 */
- {102, 205, 170, 144}, /* aquamarine3 */
- {69, 139, 116, 156}, /* aquamarine4 */
- {240, 255, 255, 168}, /* azure */
- {240, 255, 255, 174}, /* azure1 */
- {224, 238, 238, 181}, /* azure2 */
- {193, 205, 205, 188}, /* azure3 */
- {131, 139, 139, 195}, /* azure4 */
- {245, 245, 220, 202}, /* beige */
- {255, 228, 196, 208}, /* bisque */
- {255, 228, 196, 215}, /* bisque1 */
- {238, 213, 183, 223}, /* bisque2 */
- {205, 183, 158, 231}, /* bisque3 */
- {139, 125, 107, 239}, /* bisque4 */
- {0, 0, 0, 247}, /* black */
- {255, 235, 205, 253}, /* blanched almond */
- {255, 235, 205, 269}, /* BlanchedAlmond */
- {0, 0, 255, 284}, /* blue */
- {138, 43, 226, 289}, /* blue violet */
- {0, 0, 255, 301}, /* blue1 */
- {0, 0, 238, 307}, /* blue2 */
- {0, 0, 205, 313}, /* blue3 */
- {0, 0, 139, 319}, /* blue4 */
- {138, 43, 226, 325}, /* BlueViolet */
- {165, 42, 42, 336}, /* brown */
- {255, 64, 64, 342}, /* brown1 */
- {238, 59, 59, 349}, /* brown2 */
- {205, 51, 51, 356}, /* brown3 */
- {139, 35, 35, 363}, /* brown4 */
- {222, 184, 135, 370}, /* burlywood */
- {255, 211, 155, 380}, /* burlywood1 */
- {238, 197, 145, 391}, /* burlywood2 */
- {205, 170, 125, 402}, /* burlywood3 */
- {139, 115, 85, 413}, /* burlywood4 */
- {95, 158, 160, 424}, /* cadet blue */
- {95, 158, 160, 435}, /* CadetBlue */
- {152, 245, 255, 445}, /* CadetBlue1 */
- {142, 229, 238, 456}, /* CadetBlue2 */
- {122, 197, 205, 467}, /* CadetBlue3 */
- {83, 134, 139, 478}, /* CadetBlue4 */
- {127, 255, 0, 489}, /* chartreuse */
- {127, 255, 0, 500}, /* chartreuse1 */
- {118, 238, 0, 512}, /* chartreuse2 */
- {102, 205, 0, 524}, /* chartreuse3 */
- {69, 139, 0, 536}, /* chartreuse4 */
- {210, 105, 30, 548}, /* chocolate */
- {255, 127, 36, 558}, /* chocolate1 */
- {238, 118, 33, 569}, /* chocolate2 */
- {205, 102, 29, 580}, /* chocolate3 */
- {139, 69, 19, 591}, /* chocolate4 */
- {255, 127, 80, 602}, /* coral */
- {255, 114, 86, 608}, /* coral1 */
- {238, 106, 80, 615}, /* coral2 */
- {205, 91, 69, 622}, /* coral3 */
- {139, 62, 47, 629}, /* coral4 */
- {100, 149, 237, 636}, /* cornflower blue */
- {100, 149, 237, 652}, /* CornflowerBlue */
- {255, 248, 220, 667}, /* cornsilk */
- {255, 248, 220, 676}, /* cornsilk1 */
- {238, 232, 205, 686}, /* cornsilk2 */
- {205, 200, 177, 696}, /* cornsilk3 */
- {139, 136, 120, 706}, /* cornsilk4 */
- {220, 20, 60, 716}, /* crimson */
- {0, 255, 255, 724}, /* cyan */
- {0, 255, 255, 729}, /* cyan1 */
- {0, 238, 238, 735}, /* cyan2 */
- {0, 205, 205, 741}, /* cyan3 */
- {0, 139, 139, 747}, /* cyan4 */
- {0, 0, 139, 753}, /* dark blue */
- {0, 139, 139, 763}, /* dark cyan */
- {184, 134, 11, 773}, /* dark goldenrod */
- {169, 169, 169, 788}, /* dark gray */
- {0, 100, 0, 798}, /* dark green */
- {169, 169, 169, 809}, /* dark grey */
- {189, 183, 107, 819}, /* dark khaki */
- {139, 0, 139, 830}, /* dark magenta */
- {85, 107, 47, 843}, /* dark olive green */
- {255, 140, 0, 860}, /* dark orange */
- {153, 50, 204, 872}, /* dark orchid */
- {139, 0, 0, 884}, /* dark red */
- {233, 150, 122, 893}, /* dark salmon */
- {143, 188, 143, 905}, /* dark sea green */
- {72, 61, 139, 920}, /* dark slate blue */
- {47, 79, 79, 936}, /* dark slate gray */
- {47, 79, 79, 952}, /* dark slate grey */
- {0, 206, 209, 968}, /* dark turquoise */
- {148, 0, 211, 983}, /* dark violet */
- {0, 0, 139, 995}, /* DarkBlue */
- {0, 139, 139, 1004}, /* DarkCyan */
- {184, 134, 11, 1013}, /* DarkGoldenrod */
- {255, 185, 15, 1027}, /* DarkGoldenrod1 */
- {238, 173, 14, 1042}, /* DarkGoldenrod2 */
- {205, 149, 12, 1057}, /* DarkGoldenrod3 */
- {139, 101, 8, 1072}, /* DarkGoldenrod4 */
- {169, 169, 169, 1087}, /* DarkGray */
- {0, 100, 0, 1096}, /* DarkGreen */
- {169, 169, 169, 1106}, /* DarkGrey */
- {189, 183, 107, 1115}, /* DarkKhaki */
- {139, 0, 139, 1125}, /* DarkMagenta */
- {85, 107, 47, 1137}, /* DarkOliveGreen */
- {202, 255, 112, 1152}, /* DarkOliveGreen1 */
- {188, 238, 104, 1168}, /* DarkOliveGreen2 */
- {162, 205, 90, 1184}, /* DarkOliveGreen3 */
- {110, 139, 61, 1200}, /* DarkOliveGreen4 */
- {255, 140, 0, 1216}, /* DarkOrange */
- {255, 127, 0, 1227}, /* DarkOrange1 */
- {238, 118, 0, 1239}, /* DarkOrange2 */
- {205, 102, 0, 1251}, /* DarkOrange3 */
- {139, 69, 0, 1263}, /* DarkOrange4 */
- {153, 50, 204, 1275}, /* DarkOrchid */
- {191, 62, 255, 1286}, /* DarkOrchid1 */
- {178, 58, 238, 1298}, /* DarkOrchid2 */
- {154, 50, 205, 1310}, /* DarkOrchid3 */
- {104, 34, 139, 1322}, /* DarkOrchid4 */
- {139, 0, 0, 1334}, /* DarkRed */
- {233, 150, 122, 1342}, /* DarkSalmon */
- {143, 188, 143, 1353}, /* DarkSeaGreen */
- {193, 255, 193, 1366}, /* DarkSeaGreen1 */
- {180, 238, 180, 1380}, /* DarkSeaGreen2 */
- {155, 205, 155, 1394}, /* DarkSeaGreen3 */
- {105, 139, 105, 1408}, /* DarkSeaGreen4 */
- {72, 61, 139, 1422}, /* DarkSlateBlue */
- {47, 79, 79, 1436}, /* DarkSlateGray */
- {151, 255, 255, 1450}, /* DarkSlateGray1 */
- {141, 238, 238, 1465}, /* DarkSlateGray2 */
- {121, 205, 205, 1480}, /* DarkSlateGray3 */
- {82, 139, 139, 1495}, /* DarkSlateGray4 */
- {47, 79, 79, 1510}, /* DarkSlateGrey */
- {0, 206, 209, 1524}, /* DarkTurquoise */
- {148, 0, 211, 1538}, /* DarkViolet */
- {255, 20, 147, 1549}, /* deep pink */
- {0, 191, 255, 1559}, /* deep sky blue */
- {255, 20, 147, 1573}, /* DeepPink */
- {255, 20, 147, 1582}, /* DeepPink1 */
- {238, 18, 137, 1592}, /* DeepPink2 */
- {205, 16, 118, 1602}, /* DeepPink3 */
- {139, 10, 80, 1612}, /* DeepPink4 */
- {0, 191, 255, 1622}, /* DeepSkyBlue */
- {0, 191, 255, 1634}, /* DeepSkyBlue1 */
- {0, 178, 238, 1647}, /* DeepSkyBlue2 */
- {0, 154, 205, 1660}, /* DeepSkyBlue3 */
- {0, 104, 139, 1673}, /* DeepSkyBlue4 */
- {105, 105, 105, 1686}, /* dim gray */
- {105, 105, 105, 1695}, /* dim grey */
- {105, 105, 105, 1704}, /* DimGray */
- {105, 105, 105, 1712}, /* DimGrey */
- {30, 144, 255, 1720}, /* dodger blue */
- {30, 144, 255, 1732}, /* DodgerBlue */
- {30, 144, 255, 1743}, /* DodgerBlue1 */
- {28, 134, 238, 1755}, /* DodgerBlue2 */
- {24, 116, 205, 1767}, /* DodgerBlue3 */
- {16, 78, 139, 1779}, /* DodgerBlue4 */
- {178, 34, 34, 1791}, /* firebrick */
- {255, 48, 48, 1801}, /* firebrick1 */
- {238, 44, 44, 1812}, /* firebrick2 */
- {205, 38, 38, 1823}, /* firebrick3 */
- {139, 26, 26, 1834}, /* firebrick4 */
- {255, 250, 240, 1845}, /* floral white */
- {255, 250, 240, 1858}, /* FloralWhite */
- {34, 139, 34, 1870}, /* forest green */
- {34, 139, 34, 1883}, /* ForestGreen */
- {255, 0, 255, 1895}, /* fuchsia */
- {220, 220, 220, 1903}, /* gainsboro */
- {248, 248, 255, 1913}, /* ghost white */
- {248, 248, 255, 1925}, /* GhostWhite */
- {255, 215, 0, 1936}, /* gold */
- {255, 215, 0, 1941}, /* gold1 */
- {238, 201, 0, 1947}, /* gold2 */
- {205, 173, 0, 1953}, /* gold3 */
- {139, 117, 0, 1959}, /* gold4 */
- {218, 165, 32, 1965}, /* goldenrod */
- {255, 193, 37, 1975}, /* goldenrod1 */
- {238, 180, 34, 1986}, /* goldenrod2 */
- {205, 155, 29, 1997}, /* goldenrod3 */
- {139, 105, 20, 2008}, /* goldenrod4 */
- {190, 190, 190, 2019}, /* gray */
- {0, 0, 0, 2024}, /* gray0 */
- {3, 3, 3, 2030}, /* gray1 */
- {26, 26, 26, 2036}, /* gray10 */
- {255, 255, 255, 2043}, /* gray100 */
- {28, 28, 28, 2051}, /* gray11 */
- {31, 31, 31, 2058}, /* gray12 */
- {33, 33, 33, 2065}, /* gray13 */
- {36, 36, 36, 2072}, /* gray14 */
- {38, 38, 38, 2079}, /* gray15 */
- {41, 41, 41, 2086}, /* gray16 */
- {43, 43, 43, 2093}, /* gray17 */
- {46, 46, 46, 2100}, /* gray18 */
- {48, 48, 48, 2107}, /* gray19 */
- {5, 5, 5, 2114}, /* gray2 */
- {51, 51, 51, 2120}, /* gray20 */
- {54, 54, 54, 2127}, /* gray21 */
- {56, 56, 56, 2134}, /* gray22 */
- {59, 59, 59, 2141}, /* gray23 */
- {61, 61, 61, 2148}, /* gray24 */
- {64, 64, 64, 2155}, /* gray25 */
- {66, 66, 66, 2162}, /* gray26 */
- {69, 69, 69, 2169}, /* gray27 */
- {71, 71, 71, 2176}, /* gray28 */
- {74, 74, 74, 2183}, /* gray29 */
- {8, 8, 8, 2190}, /* gray3 */
- {77, 77, 77, 2196}, /* gray30 */
- {79, 79, 79, 2203}, /* gray31 */
- {82, 82, 82, 2210}, /* gray32 */
- {84, 84, 84, 2217}, /* gray33 */
- {87, 87, 87, 2224}, /* gray34 */
- {89, 89, 89, 2231}, /* gray35 */
- {92, 92, 92, 2238}, /* gray36 */
- {94, 94, 94, 2245}, /* gray37 */
- {97, 97, 97, 2252}, /* gray38 */
- {99, 99, 99, 2259}, /* gray39 */
- {10, 10, 10, 2266}, /* gray4 */
- {102, 102, 102, 2272}, /* gray40 */
- {105, 105, 105, 2279}, /* gray41 */
- {107, 107, 107, 2286}, /* gray42 */
- {110, 110, 110, 2293}, /* gray43 */
- {112, 112, 112, 2300}, /* gray44 */
- {115, 115, 115, 2307}, /* gray45 */
- {117, 117, 117, 2314}, /* gray46 */
- {120, 120, 120, 2321}, /* gray47 */
- {122, 122, 122, 2328}, /* gray48 */
- {125, 125, 125, 2335}, /* gray49 */
- {13, 13, 13, 2342}, /* gray5 */
- {127, 127, 127, 2348}, /* gray50 */
- {130, 130, 130, 2355}, /* gray51 */
- {133, 133, 133, 2362}, /* gray52 */
- {135, 135, 135, 2369}, /* gray53 */
- {138, 138, 138, 2376}, /* gray54 */
- {140, 140, 140, 2383}, /* gray55 */
- {143, 143, 143, 2390}, /* gray56 */
- {145, 145, 145, 2397}, /* gray57 */
- {148, 148, 148, 2404}, /* gray58 */
- {150, 150, 150, 2411}, /* gray59 */
- {15, 15, 15, 2418}, /* gray6 */
- {153, 153, 153, 2424}, /* gray60 */
- {156, 156, 156, 2431}, /* gray61 */
- {158, 158, 158, 2438}, /* gray62 */
- {161, 161, 161, 2445}, /* gray63 */
- {163, 163, 163, 2452}, /* gray64 */
- {166, 166, 166, 2459}, /* gray65 */
- {168, 168, 168, 2466}, /* gray66 */
- {171, 171, 171, 2473}, /* gray67 */
- {173, 173, 173, 2480}, /* gray68 */
- {176, 176, 176, 2487}, /* gray69 */
- {18, 18, 18, 2494}, /* gray7 */
- {179, 179, 179, 2500}, /* gray70 */
- {181, 181, 181, 2507}, /* gray71 */
- {184, 184, 184, 2514}, /* gray72 */
- {186, 186, 186, 2521}, /* gray73 */
- {189, 189, 189, 2528}, /* gray74 */
- {191, 191, 191, 2535}, /* gray75 */
- {194, 194, 194, 2542}, /* gray76 */
- {196, 196, 196, 2549}, /* gray77 */
- {199, 199, 199, 2556}, /* gray78 */
- {201, 201, 201, 2563}, /* gray79 */
- {20, 20, 20, 2570}, /* gray8 */
- {204, 204, 204, 2576}, /* gray80 */
- {207, 207, 207, 2583}, /* gray81 */
- {209, 209, 209, 2590}, /* gray82 */
- {212, 212, 212, 2597}, /* gray83 */
- {214, 214, 214, 2604}, /* gray84 */
- {217, 217, 217, 2611}, /* gray85 */
- {219, 219, 219, 2618}, /* gray86 */
- {222, 222, 222, 2625}, /* gray87 */
- {224, 224, 224, 2632}, /* gray88 */
- {227, 227, 227, 2639}, /* gray89 */
- {23, 23, 23, 2646}, /* gray9 */
- {229, 229, 229, 2652}, /* gray90 */
- {232, 232, 232, 2659}, /* gray91 */
- {235, 235, 235, 2666}, /* gray92 */
- {237, 237, 237, 2673}, /* gray93 */
- {240, 240, 240, 2680}, /* gray94 */
- {242, 242, 242, 2687}, /* gray95 */
- {245, 245, 245, 2694}, /* gray96 */
- {247, 247, 247, 2701}, /* gray97 */
- {250, 250, 250, 2708}, /* gray98 */
- {252, 252, 252, 2715}, /* gray99 */
- {0, 255, 0, 2722}, /* green */
- {173, 255, 47, 2728}, /* green yellow */
- {0, 255, 0, 2741}, /* green1 */
- {0, 238, 0, 2748}, /* green2 */
- {0, 205, 0, 2755}, /* green3 */
- {0, 139, 0, 2762}, /* green4 */
- {173, 255, 47, 2769}, /* GreenYellow */
- {190, 190, 190, 2781}, /* grey */
- {0, 0, 0, 2786}, /* grey0 */
- {3, 3, 3, 2792}, /* grey1 */
- {26, 26, 26, 2798}, /* grey10 */
- {255, 255, 255, 2805}, /* grey100 */
- {28, 28, 28, 2813}, /* grey11 */
- {31, 31, 31, 2820}, /* grey12 */
- {33, 33, 33, 2827}, /* grey13 */
- {36, 36, 36, 2834}, /* grey14 */
- {38, 38, 38, 2841}, /* grey15 */
- {41, 41, 41, 2848}, /* grey16 */
- {43, 43, 43, 2855}, /* grey17 */
- {46, 46, 46, 2862}, /* grey18 */
- {48, 48, 48, 2869}, /* grey19 */
- {5, 5, 5, 2876}, /* grey2 */
- {51, 51, 51, 2882}, /* grey20 */
- {54, 54, 54, 2889}, /* grey21 */
- {56, 56, 56, 2896}, /* grey22 */
- {59, 59, 59, 2903}, /* grey23 */
- {61, 61, 61, 2910}, /* grey24 */
- {64, 64, 64, 2917}, /* grey25 */
- {66, 66, 66, 2924}, /* grey26 */
- {69, 69, 69, 2931}, /* grey27 */
- {71, 71, 71, 2938}, /* grey28 */
- {74, 74, 74, 2945}, /* grey29 */
- {8, 8, 8, 2952}, /* grey3 */
- {77, 77, 77, 2958}, /* grey30 */
- {79, 79, 79, 2965}, /* grey31 */
- {82, 82, 82, 2972}, /* grey32 */
- {84, 84, 84, 2979}, /* grey33 */
- {87, 87, 87, 2986}, /* grey34 */
- {89, 89, 89, 2993}, /* grey35 */
- {92, 92, 92, 3000}, /* grey36 */
- {94, 94, 94, 3007}, /* grey37 */
- {97, 97, 97, 3014}, /* grey38 */
- {99, 99, 99, 3021}, /* grey39 */
- {10, 10, 10, 3028}, /* grey4 */
- {102, 102, 102, 3034}, /* grey40 */
- {105, 105, 105, 3041}, /* grey41 */
- {107, 107, 107, 3048}, /* grey42 */
- {110, 110, 110, 3055}, /* grey43 */
- {112, 112, 112, 3062}, /* grey44 */
- {115, 115, 115, 3069}, /* grey45 */
- {117, 117, 117, 3076}, /* grey46 */
- {120, 120, 120, 3083}, /* grey47 */
- {122, 122, 122, 3090}, /* grey48 */
- {125, 125, 125, 3097}, /* grey49 */
- {13, 13, 13, 3104}, /* grey5 */
- {127, 127, 127, 3110}, /* grey50 */
- {130, 130, 130, 3117}, /* grey51 */
- {133, 133, 133, 3124}, /* grey52 */
- {135, 135, 135, 3131}, /* grey53 */
- {138, 138, 138, 3138}, /* grey54 */
- {140, 140, 140, 3145}, /* grey55 */
- {143, 143, 143, 3152}, /* grey56 */
- {145, 145, 145, 3159}, /* grey57 */
- {148, 148, 148, 3166}, /* grey58 */
- {150, 150, 150, 3173}, /* grey59 */
- {15, 15, 15, 3180}, /* grey6 */
- {153, 153, 153, 3186}, /* grey60 */
- {156, 156, 156, 3193}, /* grey61 */
- {158, 158, 158, 3200}, /* grey62 */
- {161, 161, 161, 3207}, /* grey63 */
- {163, 163, 163, 3214}, /* grey64 */
- {166, 166, 166, 3221}, /* grey65 */
- {168, 168, 168, 3228}, /* grey66 */
- {171, 171, 171, 3235}, /* grey67 */
- {173, 173, 173, 3242}, /* grey68 */
- {176, 176, 176, 3249}, /* grey69 */
- {18, 18, 18, 3256}, /* grey7 */
- {179, 179, 179, 3262}, /* grey70 */
- {181, 181, 181, 3269}, /* grey71 */
- {184, 184, 184, 3276}, /* grey72 */
- {186, 186, 186, 3283}, /* grey73 */
- {189, 189, 189, 3290}, /* grey74 */
- {191, 191, 191, 3297}, /* grey75 */
- {194, 194, 194, 3304}, /* grey76 */
- {196, 196, 196, 3311}, /* grey77 */
- {199, 199, 199, 3318}, /* grey78 */
- {201, 201, 201, 3325}, /* grey79 */
- {20, 20, 20, 3332}, /* grey8 */
- {204, 204, 204, 3338}, /* grey80 */
- {207, 207, 207, 3345}, /* grey81 */
- {209, 209, 209, 3352}, /* grey82 */
- {212, 212, 212, 3359}, /* grey83 */
- {214, 214, 214, 3366}, /* grey84 */
- {217, 217, 217, 3373}, /* grey85 */
- {219, 219, 219, 3380}, /* grey86 */
- {222, 222, 222, 3387}, /* grey87 */
- {224, 224, 224, 3394}, /* grey88 */
- {227, 227, 227, 3401}, /* grey89 */
- {23, 23, 23, 3408}, /* grey9 */
- {229, 229, 229, 3414}, /* grey90 */
- {232, 232, 232, 3421}, /* grey91 */
- {235, 235, 235, 3428}, /* grey92 */
- {237, 237, 237, 3435}, /* grey93 */
- {240, 240, 240, 3442}, /* grey94 */
- {242, 242, 242, 3449}, /* grey95 */
- {245, 245, 245, 3456}, /* grey96 */
- {247, 247, 247, 3463}, /* grey97 */
- {250, 250, 250, 3470}, /* grey98 */
- {252, 252, 252, 3477}, /* grey99 */
- {240, 255, 240, 3484}, /* honeydew */
- {240, 255, 240, 3493}, /* honeydew1 */
- {224, 238, 224, 3503}, /* honeydew2 */
- {193, 205, 193, 3513}, /* honeydew3 */
- {131, 139, 131, 3523}, /* honeydew4 */
- {255, 105, 180, 3533}, /* hot pink */
- {255, 105, 180, 3542}, /* HotPink */
- {255, 110, 180, 3550}, /* HotPink1 */
- {238, 106, 167, 3559}, /* HotPink2 */
- {205, 96, 144, 3568}, /* HotPink3 */
- {139, 58, 98, 3577}, /* HotPink4 */
- {205, 92, 92, 3586}, /* indian red */
- {205, 92, 92, 3597}, /* IndianRed */
- {255, 106, 106, 3607}, /* IndianRed1 */
- {238, 99, 99, 3618}, /* IndianRed2 */
- {205, 85, 85, 3629}, /* IndianRed3 */
- {139, 58, 58, 3640}, /* IndianRed4 */
- {75, 0, 130, 3651}, /* indigo */
- {255, 255, 240, 3658}, /* ivory */
- {255, 255, 240, 3664}, /* ivory1 */
- {238, 238, 224, 3671}, /* ivory2 */
- {205, 205, 193, 3678}, /* ivory3 */
- {139, 139, 131, 3685}, /* ivory4 */
- {240, 230, 140, 3692}, /* khaki */
- {255, 246, 143, 3698}, /* khaki1 */
- {238, 230, 133, 3705}, /* khaki2 */
- {205, 198, 115, 3712}, /* khaki3 */
- {139, 134, 78, 3719}, /* khaki4 */
- {230, 230, 250, 3726}, /* lavender */
- {255, 240, 245, 3735}, /* lavender blush */
- {255, 240, 245, 3750}, /* LavenderBlush */
- {255, 240, 245, 3764}, /* LavenderBlush1 */
- {238, 224, 229, 3779}, /* LavenderBlush2 */
- {205, 193, 197, 3794}, /* LavenderBlush3 */
- {139, 131, 134, 3809}, /* LavenderBlush4 */
- {124, 252, 0, 3824}, /* lawn green */
- {124, 252, 0, 3835}, /* LawnGreen */
- {255, 250, 205, 3845}, /* lemon chiffon */
- {255, 250, 205, 3859}, /* LemonChiffon */
- {255, 250, 205, 3872}, /* LemonChiffon1 */
- {238, 233, 191, 3886}, /* LemonChiffon2 */
- {205, 201, 165, 3900}, /* LemonChiffon3 */
- {139, 137, 112, 3914}, /* LemonChiffon4 */
- {173, 216, 230, 3928}, /* light blue */
- {240, 128, 128, 3939}, /* light coral */
- {224, 255, 255, 3951}, /* light cyan */
- {238, 221, 130, 3962}, /* light goldenrod */
- {250, 250, 210, 3978}, /* light goldenrod yellow */
- {211, 211, 211, 4001}, /* light gray */
- {144, 238, 144, 4012}, /* light green */
- {211, 211, 211, 4024}, /* light grey */
- {255, 182, 193, 4035}, /* light pink */
- {255, 160, 122, 4046}, /* light salmon */
- {32, 178, 170, 4059}, /* light sea green */
- {135, 206, 250, 4075}, /* light sky blue */
- {132, 112, 255, 4090}, /* light slate blue */
- {119, 136, 153, 4107}, /* light slate gray */
- {119, 136, 153, 4124}, /* light slate grey */
- {176, 196, 222, 4141}, /* light steel blue */
- {255, 255, 224, 4158}, /* light yellow */
- {173, 216, 230, 4171}, /* LightBlue */
- {191, 239, 255, 4181}, /* LightBlue1 */
- {178, 223, 238, 4192}, /* LightBlue2 */
- {154, 192, 205, 4203}, /* LightBlue3 */
- {104, 131, 139, 4214}, /* LightBlue4 */
- {240, 128, 128, 4225}, /* LightCoral */
- {224, 255, 255, 4236}, /* LightCyan */
- {224, 255, 255, 4246}, /* LightCyan1 */
- {209, 238, 238, 4257}, /* LightCyan2 */
- {180, 205, 205, 4268}, /* LightCyan3 */
- {122, 139, 139, 4279}, /* LightCyan4 */
- {238, 221, 130, 4290}, /* LightGoldenrod */
- {255, 236, 139, 4305}, /* LightGoldenrod1 */
- {238, 220, 130, 4321}, /* LightGoldenrod2 */
- {205, 190, 112, 4337}, /* LightGoldenrod3 */
- {139, 129, 76, 4353}, /* LightGoldenrod4 */
- {250, 250, 210, 4369}, /* LightGoldenrodYellow */
- {211, 211, 211, 4390}, /* LightGray */
- {144, 238, 144, 4400}, /* LightGreen */
- {211, 211, 211, 4411}, /* LightGrey */
- {255, 182, 193, 4421}, /* LightPink */
- {255, 174, 185, 4431}, /* LightPink1 */
- {238, 162, 173, 4442}, /* LightPink2 */
- {205, 140, 149, 4453}, /* LightPink3 */
- {139, 95, 101, 4464}, /* LightPink4 */
- {255, 160, 122, 4475}, /* LightSalmon */
- {255, 160, 122, 4487}, /* LightSalmon1 */
- {238, 149, 114, 4500}, /* LightSalmon2 */
- {205, 129, 98, 4513}, /* LightSalmon3 */
- {139, 87, 66, 4526}, /* LightSalmon4 */
- {32, 178, 170, 4539}, /* LightSeaGreen */
- {135, 206, 250, 4553}, /* LightSkyBlue */
- {176, 226, 255, 4566}, /* LightSkyBlue1 */
- {164, 211, 238, 4580}, /* LightSkyBlue2 */
- {141, 182, 205, 4594}, /* LightSkyBlue3 */
- {96, 123, 139, 4608}, /* LightSkyBlue4 */
- {132, 112, 255, 4622}, /* LightSlateBlue */
- {119, 136, 153, 4637}, /* LightSlateGray */
- {119, 136, 153, 4652}, /* LightSlateGrey */
- {176, 196, 222, 4667}, /* LightSteelBlue */
- {202, 225, 255, 4682}, /* LightSteelBlue1 */
- {188, 210, 238, 4698}, /* LightSteelBlue2 */
- {162, 181, 205, 4714}, /* LightSteelBlue3 */
- {110, 123, 139, 4730}, /* LightSteelBlue4 */
- {255, 255, 224, 4746}, /* LightYellow */
- {255, 255, 224, 4758}, /* LightYellow1 */
- {238, 238, 209, 4771}, /* LightYellow2 */
- {205, 205, 180, 4784}, /* LightYellow3 */
- {139, 139, 122, 4797}, /* LightYellow4 */
- {0, 255, 0, 4810}, /* lime */
- {50, 205, 50, 4815}, /* lime green */
- {50, 205, 50, 4826}, /* LimeGreen */
- {250, 240, 230, 4836}, /* linen */
- {255, 0, 255, 4842}, /* magenta */
- {255, 0, 255, 4850}, /* magenta1 */
- {238, 0, 238, 4859}, /* magenta2 */
- {205, 0, 205, 4868}, /* magenta3 */
- {139, 0, 139, 4877}, /* magenta4 */
- {176, 48, 96, 4886}, /* maroon */
- {255, 52, 179, 4893}, /* maroon1 */
- {238, 48, 167, 4901}, /* maroon2 */
- {205, 41, 144, 4909}, /* maroon3 */
- {139, 28, 98, 4917}, /* maroon4 */
- {102, 205, 170, 4925}, /* medium aquamarine */
- {0, 0, 205, 4943}, /* medium blue */
- {186, 85, 211, 4955}, /* medium orchid */
- {147, 112, 219, 4969}, /* medium purple */
- {60, 179, 113, 4983}, /* medium sea green */
- {123, 104, 238, 5000}, /* medium slate blue */
- {0, 250, 154, 5018}, /* medium spring green */
- {72, 209, 204, 5038}, /* medium turquoise */
- {199, 21, 133, 5055}, /* medium violet red */
- {102, 205, 170, 5073}, /* MediumAquamarine */
- {0, 0, 205, 5090}, /* MediumBlue */
- {186, 85, 211, 5101}, /* MediumOrchid */
- {224, 102, 255, 5114}, /* MediumOrchid1 */
- {209, 95, 238, 5128}, /* MediumOrchid2 */
- {180, 82, 205, 5142}, /* MediumOrchid3 */
- {122, 55, 139, 5156}, /* MediumOrchid4 */
- {147, 112, 219, 5170}, /* MediumPurple */
- {171, 130, 255, 5183}, /* MediumPurple1 */
- {159, 121, 238, 5197}, /* MediumPurple2 */
- {137, 104, 205, 5211}, /* MediumPurple3 */
- {93, 71, 139, 5225}, /* MediumPurple4 */
- {60, 179, 113, 5239}, /* MediumSeaGreen */
- {123, 104, 238, 5254}, /* MediumSlateBlue */
- {0, 250, 154, 5270}, /* MediumSpringGreen */
- {72, 209, 204, 5288}, /* MediumTurquoise */
- {199, 21, 133, 5304}, /* MediumVioletRed */
- {25, 25, 112, 5320}, /* midnight blue */
- {25, 25, 112, 5334}, /* MidnightBlue */
- {245, 255, 250, 5347}, /* mint cream */
- {245, 255, 250, 5358}, /* MintCream */
- {255, 228, 225, 5368}, /* misty rose */
- {255, 228, 225, 5379}, /* MistyRose */
- {255, 228, 225, 5389}, /* MistyRose1 */
- {238, 213, 210, 5400}, /* MistyRose2 */
- {205, 183, 181, 5411}, /* MistyRose3 */
- {139, 125, 123, 5422}, /* MistyRose4 */
- {255, 228, 181, 5433}, /* moccasin */
- {255, 222, 173, 5442}, /* navajo white */
- {255, 222, 173, 5455}, /* NavajoWhite */
- {255, 222, 173, 5467}, /* NavajoWhite1 */
- {238, 207, 161, 5480}, /* NavajoWhite2 */
- {205, 179, 139, 5493}, /* NavajoWhite3 */
- {139, 121, 94, 5506}, /* NavajoWhite4 */
- {0, 0, 128, 5519}, /* navy */
- {0, 0, 128, 5524}, /* navy blue */
- {0, 0, 128, 5534}, /* NavyBlue */
- {253, 245, 230, 5543}, /* old lace */
- {253, 245, 230, 5552}, /* OldLace */
- {128, 128, 0, 5560}, /* olive */
- {107, 142, 35, 5566}, /* olive drab */
- {107, 142, 35, 5577}, /* OliveDrab */
- {192, 255, 62, 5587}, /* OliveDrab1 */
- {179, 238, 58, 5598}, /* OliveDrab2 */
- {154, 205, 50, 5609}, /* OliveDrab3 */
- {105, 139, 34, 5620}, /* OliveDrab4 */
- {255, 165, 0, 5631}, /* orange */
- {255, 69, 0, 5638}, /* orange red */
- {255, 165, 0, 5649}, /* orange1 */
- {238, 154, 0, 5657}, /* orange2 */
- {205, 133, 0, 5665}, /* orange3 */
- {139, 90, 0, 5673}, /* orange4 */
- {255, 69, 0, 5681}, /* OrangeRed */
- {255, 69, 0, 5691}, /* OrangeRed1 */
- {238, 64, 0, 5702}, /* OrangeRed2 */
- {205, 55, 0, 5713}, /* OrangeRed3 */
- {139, 37, 0, 5724}, /* OrangeRed4 */
- {218, 112, 214, 5735}, /* orchid */
- {255, 131, 250, 5742}, /* orchid1 */
- {238, 122, 233, 5750}, /* orchid2 */
- {205, 105, 201, 5758}, /* orchid3 */
- {139, 71, 137, 5766}, /* orchid4 */
- {238, 232, 170, 5774}, /* pale goldenrod */
- {152, 251, 152, 5789}, /* pale green */
- {175, 238, 238, 5800}, /* pale turquoise */
- {219, 112, 147, 5815}, /* pale violet red */
- {238, 232, 170, 5831}, /* PaleGoldenrod */
- {152, 251, 152, 5845}, /* PaleGreen */
- {154, 255, 154, 5855}, /* PaleGreen1 */
- {144, 238, 144, 5866}, /* PaleGreen2 */
- {124, 205, 124, 5877}, /* PaleGreen3 */
- {84, 139, 84, 5888}, /* PaleGreen4 */
- {175, 238, 238, 5899}, /* PaleTurquoise */
- {187, 255, 255, 5913}, /* PaleTurquoise1 */
- {174, 238, 238, 5928}, /* PaleTurquoise2 */
- {150, 205, 205, 5943}, /* PaleTurquoise3 */
- {102, 139, 139, 5958}, /* PaleTurquoise4 */
- {219, 112, 147, 5973}, /* PaleVioletRed */
- {255, 130, 171, 5987}, /* PaleVioletRed1 */
- {238, 121, 159, 6002}, /* PaleVioletRed2 */
- {205, 104, 137, 6017}, /* PaleVioletRed3 */
- {139, 71, 93, 6032}, /* PaleVioletRed4 */
- {255, 239, 213, 6047}, /* papaya whip */
- {255, 239, 213, 6059}, /* PapayaWhip */
- {255, 218, 185, 6070}, /* peach puff */
- {255, 218, 185, 6081}, /* PeachPuff */
- {255, 218, 185, 6091}, /* PeachPuff1 */
- {238, 203, 173, 6102}, /* PeachPuff2 */
- {205, 175, 149, 6113}, /* PeachPuff3 */
- {139, 119, 101, 6124}, /* PeachPuff4 */
- {205, 133, 63, 6135}, /* peru */
- {255, 192, 203, 6140}, /* pink */
- {255, 181, 197, 6145}, /* pink1 */
- {238, 169, 184, 6151}, /* pink2 */
- {205, 145, 158, 6157}, /* pink3 */
- {139, 99, 108, 6163}, /* pink4 */
- {221, 160, 221, 6169}, /* plum */
- {255, 187, 255, 6174}, /* plum1 */
- {238, 174, 238, 6180}, /* plum2 */
- {205, 150, 205, 6186}, /* plum3 */
- {139, 102, 139, 6192}, /* plum4 */
- {176, 224, 230, 6198}, /* powder blue */
- {176, 224, 230, 6210}, /* PowderBlue */
- {160, 32, 240, 6221}, /* purple */
- {155, 48, 255, 6228}, /* purple1 */
- {145, 44, 238, 6236}, /* purple2 */
- {125, 38, 205, 6244}, /* purple3 */
- {85, 26, 139, 6252}, /* purple4 */
- {102, 51, 153, 6260}, /* rebecca purple */
- {102, 51, 153, 6275}, /* RebeccaPurple */
- {255, 0, 0, 6289}, /* red */
- {255, 0, 0, 6293}, /* red1 */
- {238, 0, 0, 6298}, /* red2 */
- {205, 0, 0, 6303}, /* red3 */
- {139, 0, 0, 6308}, /* red4 */
- {188, 143, 143, 6313}, /* rosy brown */
- {188, 143, 143, 6324}, /* RosyBrown */
- {255, 193, 193, 6334}, /* RosyBrown1 */
- {238, 180, 180, 6345}, /* RosyBrown2 */
- {205, 155, 155, 6356}, /* RosyBrown3 */
- {139, 105, 105, 6367}, /* RosyBrown4 */
- {65, 105, 225, 6378}, /* royal blue */
- {65, 105, 225, 6389}, /* RoyalBlue */
- {72, 118, 255, 6399}, /* RoyalBlue1 */
- {67, 110, 238, 6410}, /* RoyalBlue2 */
- {58, 95, 205, 6421}, /* RoyalBlue3 */
- {39, 64, 139, 6432}, /* RoyalBlue4 */
- {139, 69, 19, 6443}, /* saddle brown */
- {139, 69, 19, 6456}, /* SaddleBrown */
- {250, 128, 114, 6468}, /* salmon */
- {255, 140, 105, 6475}, /* salmon1 */
- {238, 130, 98, 6483}, /* salmon2 */
- {205, 112, 84, 6491}, /* salmon3 */
- {139, 76, 57, 6499}, /* salmon4 */
- {244, 164, 96, 6507}, /* sandy brown */
- {244, 164, 96, 6519}, /* SandyBrown */
- {46, 139, 87, 6530}, /* sea green */
- {46, 139, 87, 6540}, /* SeaGreen */
- {84, 255, 159, 6549}, /* SeaGreen1 */
- {78, 238, 148, 6559}, /* SeaGreen2 */
- {67, 205, 128, 6569}, /* SeaGreen3 */
- {46, 139, 87, 6579}, /* SeaGreen4 */
- {255, 245, 238, 6589}, /* seashell */
- {255, 245, 238, 6598}, /* seashell1 */
- {238, 229, 222, 6608}, /* seashell2 */
- {205, 197, 191, 6618}, /* seashell3 */
- {139, 134, 130, 6628}, /* seashell4 */
- {160, 82, 45, 6638}, /* sienna */
- {255, 130, 71, 6645}, /* sienna1 */
- {238, 121, 66, 6653}, /* sienna2 */
- {205, 104, 57, 6661}, /* sienna3 */
- {139, 71, 38, 6669}, /* sienna4 */
- {192, 192, 192, 6677}, /* silver */
- {135, 206, 235, 6684}, /* sky blue */
- {135, 206, 235, 6693}, /* SkyBlue */
- {135, 206, 255, 6701}, /* SkyBlue1 */
- {126, 192, 238, 6710}, /* SkyBlue2 */
- {108, 166, 205, 6719}, /* SkyBlue3 */
- {74, 112, 139, 6728}, /* SkyBlue4 */
- {106, 90, 205, 6737}, /* slate blue */
- {112, 128, 144, 6748}, /* slate gray */
- {112, 128, 144, 6759}, /* slate grey */
- {106, 90, 205, 6770}, /* SlateBlue */
- {131, 111, 255, 6780}, /* SlateBlue1 */
- {122, 103, 238, 6791}, /* SlateBlue2 */
- {105, 89, 205, 6802}, /* SlateBlue3 */
- {71, 60, 139, 6813}, /* SlateBlue4 */
- {112, 128, 144, 6824}, /* SlateGray */
- {198, 226, 255, 6834}, /* SlateGray1 */
- {185, 211, 238, 6845}, /* SlateGray2 */
- {159, 182, 205, 6856}, /* SlateGray3 */
- {108, 123, 139, 6867}, /* SlateGray4 */
- {112, 128, 144, 6878}, /* SlateGrey */
- {255, 250, 250, 6888}, /* snow */
- {255, 250, 250, 6893}, /* snow1 */
- {238, 233, 233, 6899}, /* snow2 */
- {205, 201, 201, 6905}, /* snow3 */
- {139, 137, 137, 6911}, /* snow4 */
- {0, 255, 127, 6917}, /* spring green */
- {0, 255, 127, 6930}, /* SpringGreen */
- {0, 255, 127, 6942}, /* SpringGreen1 */
- {0, 238, 118, 6955}, /* SpringGreen2 */
- {0, 205, 102, 6968}, /* SpringGreen3 */
- {0, 139, 69, 6981}, /* SpringGreen4 */
- {70, 130, 180, 6994}, /* steel blue */
- {70, 130, 180, 7005}, /* SteelBlue */
- {99, 184, 255, 7015}, /* SteelBlue1 */
- {92, 172, 238, 7026}, /* SteelBlue2 */
- {79, 148, 205, 7037}, /* SteelBlue3 */
- {54, 100, 139, 7048}, /* SteelBlue4 */
- {210, 180, 140, 7059}, /* tan */
- {255, 165, 79, 7063}, /* tan1 */
- {238, 154, 73, 7068}, /* tan2 */
- {205, 133, 63, 7073}, /* tan3 */
- {139, 90, 43, 7078}, /* tan4 */
- {0, 128, 128, 7083}, /* teal */
- {216, 191, 216, 7088}, /* thistle */
- {255, 225, 255, 7096}, /* thistle1 */
- {238, 210, 238, 7105}, /* thistle2 */
- {205, 181, 205, 7114}, /* thistle3 */
- {139, 123, 139, 7123}, /* thistle4 */
- {255, 99, 71, 7132}, /* tomato */
- {255, 99, 71, 7139}, /* tomato1 */
- {238, 92, 66, 7147}, /* tomato2 */
- {205, 79, 57, 7155}, /* tomato3 */
- {139, 54, 38, 7163}, /* tomato4 */
- {64, 224, 208, 7171}, /* turquoise */
- {0, 245, 255, 7181}, /* turquoise1 */
- {0, 229, 238, 7192}, /* turquoise2 */
- {0, 197, 205, 7203}, /* turquoise3 */
- {0, 134, 139, 7214}, /* turquoise4 */
- {238, 130, 238, 7225}, /* violet */
- {208, 32, 144, 7232}, /* violet red */
- {208, 32, 144, 7243}, /* VioletRed */
- {255, 62, 150, 7253}, /* VioletRed1 */
- {238, 58, 140, 7264}, /* VioletRed2 */
- {205, 50, 120, 7275}, /* VioletRed3 */
- {139, 34, 82, 7286}, /* VioletRed4 */
- {128, 128, 128, 7297}, /* web gray */
- {0, 128, 0, 7306}, /* web green */
- {128, 128, 128, 7316}, /* web grey */
- {128, 0, 0, 7325}, /* web maroon */
- {128, 0, 128, 7336}, /* web purple */
- {128, 128, 128, 7347}, /* WebGray */
- {0, 128, 0, 7355}, /* WebGreen */
- {128, 128, 128, 7364}, /* WebGrey */
- {128, 0, 0, 7372}, /* WebMaroon */
- {128, 0, 128, 7382}, /* WebPurple */
- {245, 222, 179, 7392}, /* wheat */
- {255, 231, 186, 7398}, /* wheat1 */
- {238, 216, 174, 7405}, /* wheat2 */
- {205, 186, 150, 7412}, /* wheat3 */
- {139, 126, 102, 7419}, /* wheat4 */
- {255, 255, 255, 7426}, /* white */
- {245, 245, 245, 7432}, /* white smoke */
- {245, 245, 245, 7444}, /* WhiteSmoke */
- {190, 190, 190, 7455}, /* x11 gray */
- {0, 255, 0, 7464}, /* x11 green */
- {190, 190, 190, 7474}, /* x11 grey */
- {176, 48, 96, 7483}, /* x11 maroon */
- {160, 32, 240, 7494}, /* x11 purple */
- {190, 190, 190, 7505}, /* X11Gray */
- {0, 255, 0, 7513}, /* X11Green */
- {190, 190, 190, 7522}, /* X11Grey */
- {176, 48, 96, 7530}, /* X11Maroon */
- {160, 32, 240, 7540}, /* X11Purple */
- {255, 255, 0, 7550}, /* yellow */
- {154, 205, 50, 7557}, /* yellow green */
- {255, 255, 0, 7570}, /* yellow1 */
- {238, 238, 0, 7578}, /* yellow2 */
- {205, 205, 0, 7586}, /* yellow3 */
- {139, 139, 0, 7594}, /* yellow4 */
- {154, 205, 50, 7602}, /* YellowGreen */
-};
-
-Bool
-OsLookupColor(int screen,
- char *name,
- unsigned int len,
- unsigned short *pred,
- unsigned short *pgreen, unsigned short *pblue)
-{
- const BuiltinColor *c;
- int low, mid, high;
- int r;
-
- low = 0;
- high = ARRAY_SIZE(BuiltinColors) - 1;
- while (high >= low) {
- mid = (low + high) / 2;
- c = &BuiltinColors[mid];
- r = strncasecmp(&BuiltinColorNames[c->name], name, len);
- if (r == 0 && len == strlen(&BuiltinColorNames[c->name])) {
- *pred = c->red * 0x101;
- *pgreen = c->green * 0x101;
- *pblue = c->blue * 0x101;
- return TRUE;
- }
- if (r < 0)
- low = mid + 1;
- else
- high = mid - 1;
- }
- return FALSE;
-}
diff --git a/os/osdep.h b/os/osdep.h
index 67958fd77..0687f568d 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -51,6 +51,8 @@ SOFTWARE.
#ifndef _OSDEP_H_
#define _OSDEP_H_ 1
+#include <X11/Xdefs.h>
+
#if defined(XDMCP) || defined(HASXDMAUTH)
#include <X11/Xdmcp.h>
#endif
@@ -85,29 +87,6 @@ typedef struct _connectionOutput *ConnectionOutputPtr;
struct _osComm;
-#define AuthInitArgs void
-typedef void (*AuthInitFunc) (AuthInitArgs);
-
-#define AuthAddCArgs unsigned short data_length, const char *data, XID id
-typedef int (*AuthAddCFunc) (AuthAddCArgs);
-
-#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason
-typedef XID (*AuthCheckFunc) (AuthCheckArgs);
-
-#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
-typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
-
-#define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return
-typedef XID (*AuthGenCFunc) (AuthGenCArgs);
-
-#define AuthRemCArgs unsigned short data_length, const char *data
-typedef int (*AuthRemCFunc) (AuthRemCArgs);
-
-#define AuthRstCArgs void
-typedef int (*AuthRstCFunc) (AuthRstCArgs);
-
-typedef void (*OsCloseFunc) (ClientPtr);
-
typedef int (*OsFlushFunc) (ClientPtr who, struct _osComm * oc, char *extraBuf,
int extraCount);
@@ -146,66 +125,77 @@ listen_to_client(ClientPtr client);
extern Bool NewOutputPending;
-extern WorkQueuePtr workQueue;
-
/* in access.c */
extern Bool ComputeLocalClient(ClientPtr client);
/* in auth.c */
extern void GenerateRandomData(int len, char *buf);
-/* in mitauth.c */
-extern XID MitCheckCookie(AuthCheckArgs);
-extern XID MitGenerateCookie(AuthGenCArgs);
-extern int MitAddCookie(AuthAddCArgs);
-extern int MitFromID(AuthFromIDArgs);
-extern int MitRemoveCookie(AuthRemCArgs);
-extern int MitResetCookie(AuthRstCArgs);
-
-/* in xdmauth.c */
-#ifdef HASXDMAUTH
-extern XID XdmCheckCookie(AuthCheckArgs);
-extern int XdmAddCookie(AuthAddCArgs);
-extern int XdmFromID(AuthFromIDArgs);
-extern int XdmRemoveCookie(AuthRemCArgs);
-extern int XdmResetCookie(AuthRstCArgs);
-#endif
+/* OsTimer functions */
+void TimerInit(void);
+Bool TimerForce(OsTimerPtr timer);
-/* in rpcauth.c */
-#ifdef SECURE_RPC
-extern void SecureRPCInit(AuthInitArgs);
-extern XID SecureRPCCheck(AuthCheckArgs);
-extern int SecureRPCAdd(AuthAddCArgs);
-extern int SecureRPCFromID(AuthFromIDArgs);
-extern int SecureRPCRemove(AuthRemCArgs);
-extern int SecureRPCReset(AuthRstCArgs);
-#endif
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+struct utsname {
+ char nodename[512];
+};
-#ifdef XDMCP
-/* in xdmcp.c */
-extern void XdmcpUseMsg(void);
-extern int XdmcpOptions(int argc, char **argv, int i);
-extern void XdmcpRegisterConnection(int type, const char *address, int addrlen);
-extern void XdmcpRegisterAuthorizations(void);
-extern void XdmcpRegisterAuthorization(const char *name, int namelen);
-extern void XdmcpInit(void);
-extern void XdmcpReset(void);
-extern void XdmcpOpenDisplay(int sock);
-extern void XdmcpCloseDisplay(int sock);
-extern void XdmcpRegisterAuthentication(const char *name,
- int namelen,
- const char *data,
- int datalen,
- ValidatorFunc Validator,
- GeneratorFunc Generator,
- AddAuthorFunc AddAuth);
-
-struct sockaddr_in;
-extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr);
-#endif
+static inline void uname(struct utsname *uts) {
+ gethostname(uts->nodename, sizeof(uts->nodename));
+}
-#ifdef HASXDMAUTH
-extern void XdmAuthenticationInit(const char *cookie, int cookie_length);
-#endif
+const char *Win32TempDir(void);
+
+int System(const char *cmdline);
+static inline void Fclose(void *f) { fclose(f); }
+static inline void *Fopen(const char *a, const char *b) { return fopen(a,b); }
+
+#else /* WIN32 */
+
+int System(const char *);
+void *Popen(const char *, const char *);
+void *Fopen(const char *, const char *);
+int Fclose(void *f);
+int Pclose(void *f);
+
+#endif /* WIN32 */
+
+void AutoResetServer(int sig);
+
+/* clone fd so it gets out of our select mask */
+int os_move_fd(int fd);
+
+/* set signal mask - either on current thread or whole process,
+ depending on whether multithreading is used */
+int xthread_sigmask(int how, const sigset_t *set, sigset_t *oldest);
+
+/* callback for DDX specific error printing, if any (may be NULL) */
+extern void (*OsVendorVErrorFProc) (const char *, va_list args)
+ _X_ATTRIBUTE_PRINTF(1, 0);
+
+typedef void (*OsSigHandlerPtr) (int sig);
+
+/* install signal handler */
+OsSigHandlerPtr OsSignal(int sig, OsSigHandlerPtr handler);
+
+void OsInit(void);
+void OsCleanup(Bool);
+void OsVendorFatalError(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1, 0);
+void OsVendorInit(void);
+void OsBlockSignals(void);
+void OsReleaseSignals(void);
+void OsResetSignals(void);
+void OsAbort(void) _X_NORETURN;
+
+void MakeClientGrabPervious(ClientPtr client);
+void MakeClientGrabImpervious(ClientPtr client);
+
+int OnlyListenToOneClient(ClientPtr client);
+
+void ListenToAllClients(void);
+
+/* allow DDX to force using another clock */
+void ForceClockId(clockid_t forced_clockid);
#endif /* _OSDEP_H_ */
diff --git a/os/osinit.c b/os/osinit.c
index 8575319ff..465b3df14 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -48,14 +48,11 @@ SOFTWARE.
#include <dix-config.h>
#endif
+#include <errno.h>
#include <stdio.h>
+#include <signal.h>
#include <X11/X.h>
-#include "os.h"
-#include "osdep.h"
-#include "opaque.h"
#include <X11/Xos.h>
-#include <signal.h>
-#include <errno.h>
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
@@ -63,8 +60,14 @@ SOFTWARE.
#include <execinfo.h>
#endif
+#include "os/busfault.h"
+#include "os/osdep.h"
+
#include "misc.h"
+#include "os.h"
+#include "opaque.h"
+#include "misc.h"
#include "dixstruct.h"
#if !defined(SYSV) && !defined(WIN32)
@@ -158,8 +161,6 @@ OsSigHandler(int signo)
}
#endif /* !WIN32 || __CYGWIN__ */
-#include "busfault.h"
-
void
OsInit(void)
{
@@ -199,9 +200,7 @@ OsInit(void)
}
}
#endif /* !WIN32 || __CYGWIN__ */
-#ifdef BUSFAULT
busfault_init();
-#endif
server_poll = ospoll_create();
if (!server_poll)
FatalError("failed to allocate poll structure");
diff --git a/os/rpcauth.c b/os/rpcauth.c
index 33260db72..d3d4e4bd8 100644
--- a/os/rpcauth.c
+++ b/os/rpcauth.c
@@ -39,10 +39,14 @@ from The Open Group.
#include <X11/X.h>
#include <X11/Xauth.h>
+
+#include "os/auth.h"
+
#include "misc.h"
#include "os.h"
#include "osdep.h"
#include "dixstruct.h"
+#include "rpcauth.h"
#include <rpc/rpc.h>
@@ -70,7 +74,7 @@ authdes_ezdecode(const char *inmsg, int len)
why = AUTH_FAILED; /* generic error, since there is no AUTH_BADALLOC */
return NULL;
}
- memmove(temp_inmsg, inmsg, len);
+ memcpy(temp_inmsg, inmsg, len);
memset((char *) &msg, 0, sizeof(msg));
memset((char *) &r, 0, sizeof(r));
@@ -155,7 +159,7 @@ SecureRPCCheck(unsigned short data_length, const char *data,
_X_HIDDEN void
SecureRPCInit(void)
{
- if (rpc_id == ~0L)
+ if (rpc_id == (XID) ~0L)
AddAuthorization(9, "SUN-DES-1", 0, (char *) 0);
}
diff --git a/os/rpcauth.h b/os/rpcauth.h
new file mode 100644
index 000000000..255eafcea
--- /dev/null
+++ b/os/rpcauth.h
@@ -0,0 +1,13 @@
+#ifndef _XSERVER_OS_RPCAUTH_H
+#define _XSERVER_OS_RPCAUTH_H
+
+#include "auth.h"
+
+void SecureRPCInit(AuthInitArgs);
+XID SecureRPCCheck(AuthCheckArgs);
+int SecureRPCAdd(AuthAddCArgs);
+int SecureRPCFromID(AuthFromIDArgs);
+int SecureRPCRemove(AuthRemCArgs);
+int SecureRPCReset(AuthRstCArgs);
+
+#endif /* _XSERVER_OS_RPCAUTH_H */
diff --git a/os/strcasestr.c b/os/strcasestr.c
index 3189cf21e..4e483a940 100644
--- a/os/strcasestr.c
+++ b/os/strcasestr.c
@@ -37,6 +37,8 @@
#include <ctype.h>
#include <string.h>
+#include "os.h"
+
/*
* Find the first occurrence of find in s, ignore case.
*/
diff --git a/os/string.c b/os/string.c
new file mode 100644
index 000000000..f0e34e40b
--- /dev/null
+++ b/os/string.c
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 1987, 1998 The Open Group
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ */
+#include <dix-config.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "os.h"
+
+char *
+Xstrdup(const char *s)
+{
+ if (s == NULL)
+ return NULL;
+ return strdup(s);
+}
+
+char *
+XNFstrdup(const char *s)
+{
+ char *ret;
+
+ if (s == NULL)
+ return NULL;
+
+ ret = strdup(s);
+ if (!ret)
+ FatalError("XNFstrdup: Out of memory");
+ return ret;
+}
+
+/*
+ * Tokenize a string into a NULL terminated array of strings. Always returns
+ * an allocated array unless an error occurs.
+ */
+char **
+xstrtokenize(const char *str, const char *separators)
+{
+ char **list, **nlist;
+ char *tok, *tmp;
+ unsigned num = 0, n;
+
+ if (!str)
+ return NULL;
+ list = calloc(1, sizeof(*list));
+ if (!list)
+ return NULL;
+ tmp = strdup(str);
+ if (!tmp)
+ goto error;
+ for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
+ nlist = reallocarray(list, num + 2, sizeof(*list));
+ if (!nlist)
+ goto error;
+ list = nlist;
+ list[num] = strdup(tok);
+ if (!list[num])
+ goto error;
+ list[++num] = NULL;
+ }
+ free(tmp);
+ return list;
+
+ error:
+ free(tmp);
+ for (n = 0; n < num; n++)
+ free(list[n]);
+ free(list);
+ return NULL;
+}
diff --git a/os/utils.c b/os/utils.c
index c9a8e7367..4c5c9e987 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -78,10 +78,14 @@ __stdcall unsigned long GetTickCount(void);
#define TRANS_SERVER
#define TRANS_REOPEN
#include <X11/Xtrans/Xtrans.h>
+
+#include "os/audit.h"
+
#include "input.h"
#include "dixfont.h"
#include <X11/fonts/libxfont2.h>
#include "osdep.h"
+#include "xdmcp.h"
#include "extension.h"
#include <signal.h>
#ifndef WIN32
@@ -102,16 +106,15 @@ __stdcall unsigned long GetTickCount(void);
#endif
#endif
-#include "opaque.h"
+#include "dix/dix_priv.h"
+#include "os/auth.h"
+#include "os/cmdline.h"
+#include "os/osdep.h"
#include "dixstruct.h"
-
#include "xkbsrv.h"
-
#include "picture.h"
-
#include "miinitext.h"
-
#include "present.h"
Bool noTestExtensions;
@@ -143,6 +146,7 @@ Bool noMITShmExtension = FALSE;
Bool noRRExtension = FALSE;
#endif
Bool noRenderExtension = FALSE;
+Bool noShapeExtension = FALSE;
#ifdef XCSECURITY
Bool noSecurityExtension = FALSE;
@@ -167,10 +171,6 @@ Bool noXFixesExtension = FALSE;
/* Xinerama is disabled by default unless enabled via +xinerama */
Bool noPanoramiXExtension = TRUE;
#endif
-#ifdef XSELINUX
-Bool noSELinuxExtension = FALSE;
-int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
-#endif
#ifdef XV
Bool noXvExtension = FALSE;
#endif
@@ -189,20 +189,16 @@ Bool CoreDump;
Bool enableIndirectGLX = FALSE;
+Bool AllowByteSwappedClients = FALSE;
+
#ifdef PANORAMIX
Bool PanoramiXExtensionDisabledHack = FALSE;
#endif
-int auditTrailLevel = 1;
-
char *SeatId = NULL;
sig_atomic_t inSignalContext = FALSE;
-#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
-#define HAS_SAVED_IDS_AND_SETEUID
-#endif
-
#ifdef MONOTONIC_CLOCK
static clockid_t clockid;
#endif
@@ -523,6 +519,8 @@ UseMsg(void)
ErrorF("-br create root window with black background\n");
ErrorF("+bs enable any backing store support\n");
ErrorF("-bs disable any backing store support\n");
+ ErrorF("+byteswappedclients Allow clients with endianess different to that of the server\n");
+ ErrorF("-byteswappedclients Prohibit clients with endianess different to that of the server\n");
ErrorF("-c turns off key-click\n");
ErrorF("c # key-click volume (0-100)\n");
ErrorF("-cc int default color visual class\n");
@@ -720,6 +718,11 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
+ else if (strcmp(argv[i], "-byteswappedclients") == 0) {
+ AllowByteSwappedClients = FALSE;
+ } else if (strcmp(argv[i], "+byteswappedclients") == 0) {
+ AllowByteSwappedClients = TRUE;
+ }
else if (strcmp(argv[i], "-br") == 0); /* default */
else if (strcmp(argv[i], "+bs") == 0)
enableBackingStore = TRUE;
@@ -1108,9 +1111,9 @@ set_font_authorizations(char **authorizations, int *authlen, void *client)
*p++ = (len) >> 8;
*p++ = (len & 0xff);
- memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
+ memcpy(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
p += sizeof(AUTHORIZATION_NAME);
- memmove(p, hnameptr, len);
+ memcpy(p, hnameptr, len);
p += len;
#if defined(IPv6) && defined(AF_INET6)
if (ai) {
@@ -1126,78 +1129,6 @@ set_font_authorizations(char **authorizations, int *authlen, void *client)
#endif /* TCPCONN */
}
-void *
-XNFalloc(unsigned long amount)
-{
- void *ptr = malloc(amount);
-
- if (!ptr)
- FatalError("Out of memory");
- return ptr;
-}
-
-/* The original XNFcalloc was used with the xnfcalloc macro which multiplied
- * the arguments at the call site without allowing calloc to check for overflow.
- * XNFcallocarray was added to fix that without breaking ABI.
- */
-void *
-XNFcalloc(unsigned long amount)
-{
- return XNFcallocarray(1, amount);
-}
-
-void *
-XNFcallocarray(size_t nmemb, size_t size)
-{
- void *ret = calloc(nmemb, size);
-
- if (!ret)
- FatalError("XNFcalloc: Out of memory");
- return ret;
-}
-
-void *
-XNFrealloc(void *ptr, unsigned long amount)
-{
- void *ret = realloc(ptr, amount);
-
- if (!ret)
- FatalError("XNFrealloc: Out of memory");
- return ret;
-}
-
-void *
-XNFreallocarray(void *ptr, size_t nmemb, size_t size)
-{
- void *ret = reallocarray(ptr, nmemb, size);
-
- if (!ret)
- FatalError("XNFreallocarray: Out of memory");
- return ret;
-}
-
-char *
-Xstrdup(const char *s)
-{
- if (s == NULL)
- return NULL;
- return strdup(s);
-}
-
-char *
-XNFstrdup(const char *s)
-{
- char *ret;
-
- if (s == NULL)
- return NULL;
-
- ret = strdup(s);
- if (!ret)
- FatalError("XNFstrdup: Out of memory");
- return ret;
-}
-
void
SmartScheduleStopTimer(void)
{
@@ -1364,49 +1295,6 @@ OsAbort(void)
* as well. As it is now, xkbcomp messages don't end up in the log file.
*/
-int
-System(const char *command)
-{
- int pid, p;
- void (*csig) (int);
- int status;
-
- if (!command)
- return 1;
-
- csig = OsSignal(SIGCHLD, SIG_DFL);
- if (csig == SIG_ERR) {
- perror("signal");
- return -1;
- }
- DebugF("System: `%s'\n", command);
-
- switch (pid = fork()) {
- case -1: /* error */
- p = -1;
- break;
- case 0: /* child */
- if (setgid(getgid()) == -1)
- _exit(127);
- if (setuid(getuid()) == -1)
- _exit(127);
- execl("/bin/sh", "sh", "-c", command, (char *) NULL);
- _exit(127);
- default: /* parent */
- do {
- p = waitpid(pid, &status, 0);
- } while (p == -1 && errno == EINTR);
-
- }
-
- if (OsSignal(SIGCHLD, csig) == SIG_ERR) {
- perror("signal");
- return -1;
- }
-
- return p == -1 ? -1 : status;
-}
-
static struct pid {
struct pid *next;
FILE *fp;
@@ -1508,78 +1396,6 @@ void *
Fopen(const char *file, const char *type)
{
FILE *iop;
-
-#ifndef HAS_SAVED_IDS_AND_SETEUID
- struct pid *cur;
- int pdes[2], pid;
-
- if (file == NULL || type == NULL)
- return NULL;
-
- if ((*type != 'r' && *type != 'w') || type[1])
- return NULL;
-
- if ((cur = malloc(sizeof(struct pid))) == NULL)
- return NULL;
-
- if (pipe(pdes) < 0) {
- free(cur);
- return NULL;
- }
-
- switch (pid = fork()) {
- case -1: /* error */
- close(pdes[0]);
- close(pdes[1]);
- free(cur);
- return NULL;
- case 0: /* child */
- if (setgid(getgid()) == -1)
- _exit(127);
- if (setuid(getuid()) == -1)
- _exit(127);
- if (*type == 'r') {
- if (pdes[1] != 1) {
- /* stdout */
- dup2(pdes[1], 1);
- close(pdes[1]);
- }
- close(pdes[0]);
- }
- else {
- if (pdes[0] != 0) {
- /* stdin */
- dup2(pdes[0], 0);
- close(pdes[0]);
- }
- close(pdes[1]);
- }
- execl("/bin/cat", "cat", file, (char *) NULL);
- _exit(127);
- }
-
- /* Avoid EINTR during stdio calls */
- OsBlockSignals();
-
- /* parent */
- if (*type == 'r') {
- iop = fdopen(pdes[0], type);
- close(pdes[1]);
- }
- else {
- iop = fdopen(pdes[1], type);
- close(pdes[0]);
- }
-
- cur->fp = iop;
- cur->pid = pid;
- cur->next = pidlist;
- pidlist = cur;
-
- DebugF("Fopen(%s), fp = %p\n", file, iop);
-
- return iop;
-#else
int ruid, euid;
ruid = getuid();
@@ -1595,7 +1411,6 @@ Fopen(const char *file, const char *type)
return NULL;
}
return iop;
-#endif /* HAS_SAVED_IDS_AND_SETEUID */
}
int
@@ -1640,11 +1455,7 @@ Pclose(void *iop)
int
Fclose(void *iop)
{
-#ifdef HAS_SAVED_IDS_AND_SETEUID
return fclose(iop);
-#else
- return Pclose(iop);
-#endif
}
#endif /* !WIN32 */
@@ -1679,15 +1490,13 @@ Win32TempDir(void)
int
System(const char *cmdline)
{
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
+ STARTUPINFO si = (STARTUPINFO) {
+ .cb = sizeof(si),
+ };
+ PROCESS_INFORMATION pi = (PROCESS_INFORMATION){0};
DWORD dwExitCode;
char *cmd = strdup(cmdline);
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
- ZeroMemory(&pi, sizeof(pi));
-
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
LPVOID buffer;
@@ -2038,136 +1847,6 @@ CheckUserAuthorization(void)
#endif
}
-/*
- * Tokenize a string into a NULL terminated array of strings. Always returns
- * an allocated array unless an error occurs.
- */
-char **
-xstrtokenize(const char *str, const char *separators)
-{
- char **list, **nlist;
- char *tok, *tmp;
- unsigned num = 0, n;
-
- if (!str)
- return NULL;
- list = calloc(1, sizeof(*list));
- if (!list)
- return NULL;
- tmp = strdup(str);
- if (!tmp)
- goto error;
- for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
- nlist = reallocarray(list, num + 2, sizeof(*list));
- if (!nlist)
- goto error;
- list = nlist;
- list[num] = strdup(tok);
- if (!list[num])
- goto error;
- list[++num] = NULL;
- }
- free(tmp);
- return list;
-
- error:
- free(tmp);
- for (n = 0; n < num; n++)
- free(list[n]);
- free(list);
- return NULL;
-}
-
-/* Format a signed number into a string in a signal safe manner. The string
- * should be at least 21 characters in order to handle all int64_t values.
- */
-void
-FormatInt64(int64_t num, char *string)
-{
- if (num < 0) {
- string[0] = '-';
- num *= -1;
- string++;
- }
- FormatUInt64(num, string);
-}
-
-/* Format a number into a string in a signal safe manner. The string should be
- * at least 21 characters in order to handle all uint64_t values. */
-void
-FormatUInt64(uint64_t num, char *string)
-{
- uint64_t divisor;
- int len;
- int i;
-
- for (len = 1, divisor = 10;
- len < 20 && num / divisor;
- len++, divisor *= 10);
-
- for (i = len, divisor = 1; i > 0; i--, divisor *= 10)
- string[i - 1] = '0' + ((num / divisor) % 10);
-
- string[len] = '\0';
-}
-
-/**
- * Format a double number as %.2f.
- */
-void
-FormatDouble(double dbl, char *string)
-{
- int slen = 0;
- uint64_t frac;
-
- frac = (dbl > 0 ? dbl : -dbl) * 100.0 + 0.5;
- frac %= 100;
-
- /* write decimal part to string */
- if (dbl < 0 && dbl > -1)
- string[slen++] = '-';
- FormatInt64((int64_t)dbl, &string[slen]);
-
- while(string[slen] != '\0')
- slen++;
-
- /* append fractional part, but only if we have enough characters. We
- * expect string to be 21 chars (incl trailing \0) */
- if (slen <= 17) {
- string[slen++] = '.';
- if (frac < 10)
- string[slen++] = '0';
-
- FormatUInt64(frac, &string[slen]);
- }
-}
-
-
-/* Format a number into a hexadecimal string in a signal safe manner. The string
- * should be at least 17 characters in order to handle all uint64_t values. */
-void
-FormatUInt64Hex(uint64_t num, char *string)
-{
- uint64_t divisor;
- int len;
- int i;
-
- for (len = 1, divisor = 0x10;
- len < 16 && num / divisor;
- len++, divisor *= 0x10);
-
- for (i = len, divisor = 1; i > 0; i--, divisor *= 0x10) {
- int val = (num / divisor) % 0x10;
-
- if (val < 10)
- string[i - 1] = '0' + val;
- else
- string[i - 1] = 'a' + val - 10;
- }
-
- string[len] = '\0';
-}
-
#if !defined(WIN32) || defined(__CYGWIN__)
/* Move a file descriptor out of the way of our select mask; this
* is useful for file descriptors which will never appear in the
diff --git a/os/xdmauth.c b/os/xdmauth.c
index c35cade5b..21b79e943 100644
--- a/os/xdmauth.c
+++ b/os/xdmauth.c
@@ -43,8 +43,13 @@ from The Open Group.
#define TRANS_SERVER
#define TRANS_REOPEN
#include <X11/Xtrans/Xtrans.h>
+
+#include "os/auth.h"
+
#include "os.h"
#include "osdep.h"
+#include "xdmcp.h"
+#include "xdmauth.h"
#include "dixstruct.h"
#ifdef HASXDMAUTH
@@ -356,8 +361,8 @@ XdmAddCookie(unsigned short data_length, const char *data, XID id)
return 0;
new->next = xdmAuth;
xdmAuth = new;
- memmove(new->key.data, key_bits, (int) 8);
- memmove(new->rho.data, rho_bits, (int) 8);
+ memcpy(new->key.data, key_bits, 8);
+ memcpy(new->rho.data, rho_bits, 8);
new->id = id;
return 1;
}
diff --git a/os/xdmauth.h b/os/xdmauth.h
new file mode 100644
index 000000000..e922b2e99
--- /dev/null
+++ b/os/xdmauth.h
@@ -0,0 +1,13 @@
+#ifndef _XSERVER_OS_XDMAUTH_H
+#define _XSERVER_OS_XDMAUTH_H
+
+#include "auth.h"
+
+XID XdmCheckCookie(AuthCheckArgs);
+int XdmAddCookie(AuthAddCArgs);
+int XdmFromID(AuthFromIDArgs);
+int XdmRemoveCookie(AuthRemCArgs);
+int XdmResetCookie(AuthRstCArgs);
+void XdmAuthenticationInit(const char *cookie, int cookie_length);
+
+#endif /* _XSERVER_OS_XDMAUTH_H */
diff --git a/os/xdmcp.c b/os/xdmcp.c
index 093e30096..edf69590b 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -34,12 +34,18 @@
#include <netdb.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/X.h>
#include <X11/Xmd.h>
+
+#include "os/auth.h"
+
#include "misc.h"
#include "osdep.h"
+#include "xdmcp.h"
+#include "xdmauth.h"
#include "input.h"
#include "dixstruct.h"
#include "opaque.h"
@@ -1409,7 +1415,7 @@ get_addr_by_name(const char *argtype,
FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
}
if (hep->h_length == sizeof(struct in_addr)) {
- memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
+ memcpy(&addr->sin_addr, hep->h_addr, hep->h_length);
*addrlen = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
addr->sin_port = htons(port);
diff --git a/os/xdmcp.h b/os/xdmcp.h
new file mode 100644
index 000000000..45853c7bd
--- /dev/null
+++ b/os/xdmcp.h
@@ -0,0 +1,29 @@
+#ifndef _XSERVER_OS_XDMCP_H
+#define _XSERVER_OS_XDMCP_H
+
+#include "osdep.h"
+
+#ifdef XDMCP
+/* in xdmcp.c */
+void XdmcpUseMsg(void);
+int XdmcpOptions(int argc, char **argv, int i);
+void XdmcpRegisterConnection(int type, const char *address, int addrlen);
+void XdmcpRegisterAuthorizations(void);
+void XdmcpRegisterAuthorization(const char *name, int namelen);
+void XdmcpInit(void);
+void XdmcpReset(void);
+void XdmcpOpenDisplay(int sock);
+void XdmcpCloseDisplay(int sock);
+void XdmcpRegisterAuthentication(const char *name,
+ int namelen,
+ const char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator,
+ AddAuthorFunc AddAuth);
+
+struct sockaddr_in;
+void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr);
+#endif /* XDMCP */
+
+#endif /* _XSERVER_OS_XDMCP_H */
diff --git a/os/xprintf.c b/os/xprintf.c
index 80caa5790..e19e1ca03 100644
--- a/os/xprintf.c
+++ b/os/xprintf.c
@@ -34,7 +34,7 @@
* use or other dealings in this Software without prior written authorization.
*/
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/os/xsha1.c b/os/xsha1.c
index a160b7eb4..f2863f523 100644
--- a/os/xsha1.c
+++ b/os/xsha1.c
@@ -28,7 +28,7 @@
#endif
#include "os.h"
-#include "xsha1.h"
+#include "os/xsha1.h"
#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \
|| defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */
diff --git a/include/xsha1.h b/os/xsha1.h
index 60c6a9004..60c6a9004 100644
--- a/include/xsha1.h
+++ b/os/xsha1.h
diff --git a/present/present.c b/present/present.c
index 271fe32bc..6fb73901e 100644
--- a/present/present.c
+++ b/present/present.c
@@ -157,7 +157,7 @@ present_get_target_msc(uint64_t target_msc_arg,
uint64_t remainder,
uint32_t options)
{
- const Bool synced_flip = !(options & PresentOptionAsync);
+ const Bool synced_flip = !(options & PresentAllAsyncOptions);
uint64_t target_msc;
/* If the specified target-msc lies in the future, then this
@@ -230,6 +230,12 @@ present_pixmap(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
uint64_t window_msc,
uint64_t divisor,
@@ -250,6 +256,12 @@ present_pixmap(WindowPtr window,
target_crtc,
wait_fence,
idle_fence,
+#ifdef DRI3
+ acquire_syncobj,
+ release_syncobj,
+ acquire_point,
+ release_point,
+#endif /* DRI3 */
options,
window_msc,
divisor,
@@ -272,6 +284,9 @@ present_notify_msc(WindowPtr window,
0, 0,
NULL,
NULL, NULL,
+#ifdef DRI3
+ NULL, NULL, 0, 0,
+#endif /* DRI3 */
divisor == 0 ? PresentOptionAsync : 0,
target_msc, divisor, remainder, NULL, 0);
}
diff --git a/present/present.h b/present/present.h
index d41b36033..c6762cecc 100644
--- a/present/present.h
+++ b/present/present.h
@@ -29,7 +29,15 @@
typedef enum {
PRESENT_FLIP_REASON_UNKNOWN,
- PRESENT_FLIP_REASON_BUFFER_FORMAT
+ PRESENT_FLIP_REASON_BUFFER_FORMAT,
+
+ /* Don't add new flip reasons after the TearFree ones, since it's expected
+ * that the TearFree reasons are the highest ones in order to allow doing
+ * `reason >= PRESENT_FLIP_REASON_DRIVER_TEARFREE` to check if a reason is
+ * PRESENT_FLIP_REASON_DRIVER_TEARFREE{_FLIPPING}.
+ */
+ PRESENT_FLIP_REASON_DRIVER_TEARFREE,
+ PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING
} PresentFlipReason;
typedef struct present_vblank present_vblank_rec, *present_vblank_ptr;
@@ -149,6 +157,9 @@ present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
extern _X_EXPORT Bool
present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
+extern _X_EXPORT void
+present_check_flips(WindowPtr window);
+
typedef void (*present_complete_notify_proc)(WindowPtr window,
CARD8 kind,
CARD8 mode,
diff --git a/present/present_event.c b/present/present_event.c
index 435b26b70..b35609b23 100644
--- a/present/present_event.c
+++ b/present/present_event.c
@@ -52,7 +52,7 @@ present_free_events(WindowPtr window)
return;
while ((event = window_priv->events))
- FreeResource(event->id, RT_NONE);
+ FreeResource(event->id, X11_RESTYPE_NONE);
}
static void
@@ -102,7 +102,8 @@ present_event_swap(xGenericEvent *from, xGenericEvent *to)
}
void
-present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling)
+present_send_config_notify(WindowPtr window, int x, int y, int w, int h,
+ int bw, WindowPtr sibling, CARD32 flags)
{
present_window_priv_ptr window_priv = present_window_priv(window);
@@ -122,7 +123,7 @@ present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw,
.off_y = 0,
.pixmap_width = w,
.pixmap_height = h,
- .pixmap_flags = 0
+ .pixmap_flags = flags
};
present_event_ptr event;
@@ -223,7 +224,7 @@ present_select_input(ClientPtr client, XID eid, WindowPtr window, CARD32 mask)
if (mask)
event->mask = mask;
else
- FreeResource(eid, RT_NONE);
+ FreeResource(eid, X11_RESTYPE_NONE);
return Success;
}
if (ret != BadValue)
diff --git a/present/present_execute.c b/present/present_execute.c
index 68a5878be..5253344a1 100644
--- a/present/present_execute.c
+++ b/present/present_execute.c
@@ -21,6 +21,10 @@
*/
#include "present_priv.h"
+#include <unistd.h>
+#ifdef DRI3
+#include <sys/eventfd.h>
+#endif /* DRI3 */
/*
* Called when the wait fence is triggered; just gets the current msc/ust and
@@ -37,6 +41,21 @@ present_wait_fence_triggered(void *param)
screen_priv->re_execute(vblank);
}
+#ifdef DRI3
+static void present_syncobj_triggered(int fd, int xevents, void *data)
+{
+ present_vblank_ptr vblank = data;
+ ScreenPtr screen = vblank->screen;
+ present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+ SetNotifyFd(fd, NULL, 0, NULL);
+ close(fd);
+ vblank->efd = -1;
+
+ screen_priv->re_execute(vblank);
+}
+#endif /* DRI3 */
+
Bool
present_execute_wait(present_vblank_ptr vblank, uint64_t crtc_msc)
{
@@ -58,6 +77,23 @@ present_execute_wait(present_vblank_ptr vblank, uint64_t crtc_msc)
return TRUE;
}
}
+
+#ifdef DRI3
+ /* Defer execution of explicitly synchronized copies.
+ * Flip synchronization is managed by the driver.
+ */
+ if (!vblank->flip && vblank->acquire_syncobj &&
+ !vblank->acquire_syncobj->is_signaled(vblank->acquire_syncobj,
+ vblank->acquire_point)) {
+ vblank->efd = eventfd(0, EFD_CLOEXEC);
+ SetNotifyFd(vblank->efd, present_syncobj_triggered, X_NOTIFY_READ, vblank);
+ vblank->acquire_syncobj->signaled_eventfd(vblank->acquire_syncobj,
+ vblank->acquire_point,
+ vblank->efd);
+ return TRUE;
+ }
+#endif /* DRI3 */
+
return FALSE;
}
@@ -85,9 +121,17 @@ present_execute_copy(present_vblank_ptr vblank, uint64_t crtc_msc)
* which is then freed, freeing the region
*/
vblank->update = NULL;
- screen_priv->flush(window);
-
- present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
+#ifdef DRI3
+ if (vblank->release_syncobj) {
+ int fence_fd = screen_priv->flush_fenced(window);
+ vblank->release_syncobj->import_fence(vblank->release_syncobj,
+ vblank->release_point, fence_fd);
+ } else
+#endif /* DRI3 */
+ {
+ screen_priv->flush(window);
+ present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
+ }
}
void
diff --git a/present/present_notify.c b/present/present_notify.c
index 445954998..7d19d9cfe 100644
--- a/present/present_notify.c
+++ b/present/present_notify.c
@@ -19,8 +19,10 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
-#include "present_priv.h"
+#include "dix/dix_priv.h"
+#include "present/present_priv.h"
/*
* Mark all pending notifies for 'window' as invalid when
diff --git a/present/present_priv.h b/present/present_priv.h
index 6ebd009a2..351f98621 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -36,6 +36,7 @@
#include <xfixes.h>
#include <randrstr.h>
#include <inttypes.h>
+#include "dri3.h"
#if 0
#define DebugPresent(x) ErrorF x
@@ -43,6 +44,11 @@
#define DebugPresent(x)
#endif
+/* XXX this belongs in presentproto */
+#ifndef PresentWindowDestroyed
+#define PresentWindowDestroyed (1 << 0)
+#endif
+
extern int present_request;
extern DevPrivateKeyRec present_screen_private_key;
@@ -85,6 +91,13 @@ struct present_vblank {
Bool abort_flip; /* aborting this flip */
PresentFlipReason reason; /* reason for which flip is not possible */
Bool has_suboptimal; /* whether client can support SuboptimalCopy mode */
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj;
+ struct dri3_syncobj *release_syncobj;
+ uint64_t acquire_point;
+ uint64_t release_point;
+ int efd;
+#endif /* DRI3 */
};
typedef struct present_screen_priv present_screen_priv_rec, *present_screen_priv_ptr;
@@ -119,6 +132,12 @@ typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
uint64_t window_msc,
uint64_t divisor,
@@ -132,6 +151,7 @@ typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
uint64_t event_id,
uint64_t msc);
typedef void (*present_priv_flush_ptr)(WindowPtr window);
+typedef int (*present_priv_flush_fenced_ptr)(WindowPtr window);
typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
@@ -142,6 +162,7 @@ typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
typedef void (*present_priv_flip_destroy_ptr)(ScreenPtr screen);
struct present_screen_priv {
+ ScreenPtr pScreen;
CloseScreenProcPtr CloseScreen;
ConfigNotifyProcPtr ConfigNotify;
DestroyWindowProcPtr DestroyWindow;
@@ -175,6 +196,7 @@ struct present_screen_priv {
present_priv_queue_vblank_ptr queue_vblank;
present_priv_flush_ptr flush;
+ present_priv_flush_fenced_ptr flush_fenced;
present_priv_re_execute_ptr re_execute;
present_priv_abort_vblank_ptr abort_vblank;
@@ -285,6 +307,12 @@ present_pixmap(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
uint64_t target_msc,
uint64_t divisor,
@@ -307,7 +335,7 @@ void
present_free_events(WindowPtr window);
void
-present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling);
+present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling, CARD32 flags);
void
present_send_complete_notify(WindowPtr window, CARD8 kind, CARD8 mode, CARD32 serial, uint64_t ust, uint64_t msc);
@@ -459,6 +487,12 @@ present_vblank_init(present_vblank_ptr vblank,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
const uint32_t capabilities,
present_notify_ptr notifies,
@@ -477,6 +511,12 @@ present_vblank_create(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
const uint32_t capabilities,
present_notify_ptr notifies,
diff --git a/present/present_request.c b/present/present_request.c
index f3e5679b5..cc947b11b 100644
--- a/present/present_request.c
+++ b/present/present_request.c
@@ -19,9 +19,12 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
+
+#include "dix/dix_priv.h"
#include "present_priv.h"
-#include "randrstr.h"
+#include "randrstr_priv.h"
#include <protocol-versions.h>
static int
@@ -79,80 +82,124 @@ proc_present_query_version(ClientPtr client)
} while (0)
static int
-proc_present_pixmap(ClientPtr client)
+proc_present_pixmap_common(ClientPtr client,
+ Window req_window,
+ Pixmap req_pixmap,
+ CARD32 req_serial,
+ CARD32 req_valid,
+ CARD32 req_update,
+ INT16 req_x_off,
+ INT16 req_y_off,
+ CARD32 req_target_crtc,
+ XSyncFence req_wait_fence,
+ XSyncFence req_idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ CARD64 req_acquire_point,
+ CARD64 req_release_point,
+#endif /* DRI3 */
+ CARD32 req_options,
+ CARD64 req_target_msc,
+ CARD64 req_divisor,
+ CARD64 req_remainder,
+ size_t base_req_size,
+ xPresentNotify *req_notifies)
{
- REQUEST(xPresentPixmapReq);
- WindowPtr window;
- PixmapPtr pixmap;
- RegionPtr valid = NULL;
- RegionPtr update = NULL;
- SyncFence *wait_fence;
- SyncFence *idle_fence;
- RRCrtcPtr target_crtc;
- int ret;
- int nnotifies;
- present_notify_ptr notifies = NULL;
-
- REQUEST_AT_LEAST_SIZE(xPresentPixmapReq);
- ret = dixLookupWindow(&window, stuff->window, client, DixWriteAccess);
+ WindowPtr window;
+ PixmapPtr pixmap;
+ RegionPtr valid = NULL;
+ RegionPtr update = NULL;
+ RRCrtcPtr target_crtc;
+ SyncFence *wait_fence;
+ SyncFence *idle_fence;
+ int nnotifies;
+ present_notify_ptr notifies = NULL;
+ int ret;
+
+ ret = dixLookupWindow(&window, req_window, client, DixWriteAccess);
if (ret != Success)
return ret;
- ret = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, RT_PIXMAP, client, DixReadAccess);
+ ret = dixLookupResourceByType((void **) &pixmap, req_pixmap, X11_RESTYPE_PIXMAP, client, DixReadAccess);
if (ret != Success)
return ret;
if (window->drawable.depth != pixmap->drawable.depth)
return BadMatch;
- VERIFY_REGION_OR_NONE(valid, stuff->valid, client, DixReadAccess);
- VERIFY_REGION_OR_NONE(update, stuff->update, client, DixReadAccess);
+ VERIFY_REGION_OR_NONE(valid, req_valid, client, DixReadAccess);
+ VERIFY_REGION_OR_NONE(update, req_update, client, DixReadAccess);
- VERIFY_CRTC_OR_NONE(target_crtc, stuff->target_crtc, client, DixReadAccess);
+ VERIFY_CRTC_OR_NONE(target_crtc, req_target_crtc, client, DixReadAccess);
- VERIFY_FENCE_OR_NONE(wait_fence, stuff->wait_fence, client, DixReadAccess);
- VERIFY_FENCE_OR_NONE(idle_fence, stuff->idle_fence, client, DixWriteAccess);
+ VERIFY_FENCE_OR_NONE(wait_fence, req_wait_fence, client, DixReadAccess);
+ VERIFY_FENCE_OR_NONE(idle_fence, req_idle_fence, client, DixWriteAccess);
- if (stuff->options & ~(PresentAllOptions)) {
- client->errorValue = stuff->options;
+ if (req_options & ~(PresentAllOptions)) {
+ client->errorValue = req_options;
return BadValue;
}
/*
* Check to see if remainder is sane
*/
- if (stuff->divisor == 0) {
- if (stuff->remainder != 0) {
- client->errorValue = (CARD32) stuff->remainder;
+ if (req_divisor == 0) {
+ if (req_remainder != 0) {
+ client->errorValue = (CARD32)req_remainder;
return BadValue;
}
} else {
- if (stuff->remainder >= stuff->divisor) {
- client->errorValue = (CARD32) stuff->remainder;
+ if (req_remainder >= req_divisor) {
+ client->errorValue = (CARD32)req_remainder;
return BadValue;
}
}
- nnotifies = (client->req_len << 2) - sizeof (xPresentPixmapReq);
+ nnotifies = (client->req_len << 2) - base_req_size;
if (nnotifies % sizeof (xPresentNotify))
return BadLength;
nnotifies /= sizeof (xPresentNotify);
if (nnotifies) {
- ret = present_create_notifies(client, nnotifies, (xPresentNotify *) (stuff + 1), &notifies);
+ ret = present_create_notifies(client, nnotifies, req_notifies, &notifies);
if (ret != Success)
return ret;
}
- ret = present_pixmap(window, pixmap, stuff->serial, valid, update,
- stuff->x_off, stuff->y_off, target_crtc,
- wait_fence, idle_fence, stuff->options,
- stuff->target_msc, stuff->divisor, stuff->remainder, notifies, nnotifies);
+ ret = present_pixmap(window, pixmap, req_serial,
+ valid, update, req_x_off, req_y_off, target_crtc,
+ wait_fence, idle_fence,
+#ifdef DRI3
+ acquire_syncobj, release_syncobj,
+ req_acquire_point, req_release_point,
+#endif /* DRI3 */
+ req_options, req_target_msc, req_divisor, req_remainder,
+ notifies, nnotifies);
+
if (ret != Success)
present_destroy_notifies(notifies, nnotifies);
return ret;
}
static int
+proc_present_pixmap(ClientPtr client)
+{
+ REQUEST(xPresentPixmapReq);
+ REQUEST_AT_LEAST_SIZE(xPresentPixmapReq);
+ return proc_present_pixmap_common(client, stuff->window, stuff->pixmap, stuff->serial,
+ stuff->valid, stuff->update, stuff->x_off, stuff->y_off,
+ stuff->target_crtc,
+ stuff->wait_fence, stuff->idle_fence,
+#ifdef DRI3
+ None, None, 0, 0,
+#endif /* DRI3 */
+ stuff->options, stuff->target_msc,
+ stuff->divisor, stuff->remainder,
+ sizeof (xPresentPixmapReq),
+ (xPresentNotify *)(stuff + 1));
+}
+
+static int
proc_present_notify_msc(ClientPtr client)
{
REQUEST(xPresentNotifyMSCReq);
@@ -240,12 +287,45 @@ proc_present_query_capabilities (ClientPtr client)
return Success;
}
+#ifdef DRI3
+static int
+proc_present_pixmap_synced (ClientPtr client)
+{
+ REQUEST(xPresentPixmapSyncedReq);
+ struct dri3_syncobj *acquire_syncobj;
+ struct dri3_syncobj *release_syncobj;
+
+ REQUEST_AT_LEAST_SIZE(xPresentPixmapSyncedReq);
+ VERIFY_DRI3_SYNCOBJ(stuff->acquire_syncobj, acquire_syncobj, DixWriteAccess);
+ VERIFY_DRI3_SYNCOBJ(stuff->release_syncobj, release_syncobj, DixWriteAccess);
+
+ if (stuff->acquire_point == 0 || stuff->release_point == 0 ||
+ (stuff->acquire_syncobj == stuff->release_syncobj &&
+ stuff->acquire_point >= stuff->release_point))
+ return BadValue;
+
+ return proc_present_pixmap_common(client, stuff->window, stuff->pixmap, stuff->serial,
+ stuff->valid, stuff->update, stuff->x_off, stuff->y_off,
+ stuff->target_crtc,
+ None, None,
+ acquire_syncobj, release_syncobj,
+ stuff->acquire_point, stuff->release_point,
+ stuff->options, stuff->target_msc,
+ stuff->divisor, stuff->remainder,
+ sizeof (xPresentPixmapSyncedReq),
+ (xPresentNotify *)(stuff + 1));
+}
+#endif /* DRI3 */
+
static int (*proc_present_vector[PresentNumberRequests]) (ClientPtr) = {
proc_present_query_version, /* 0 */
proc_present_pixmap, /* 1 */
proc_present_notify_msc, /* 2 */
proc_present_select_input, /* 3 */
proc_present_query_capabilities, /* 4 */
+#ifdef DRI3
+ proc_present_pixmap_synced, /* 5 */
+#endif /* DRI3 */
};
int
@@ -325,12 +405,51 @@ sproc_present_query_capabilities (ClientPtr client)
return (*proc_present_vector[stuff->presentReqType]) (client);
}
+
+#ifdef DRI3
+static int _X_COLD
+sproc_present_pixmap_synced(ClientPtr client)
+{
+ REQUEST(xPresentPixmapSyncedReq);
+ REQUEST_AT_LEAST_SIZE(xPresentPixmapSyncedReq);
+
+ swaps(&stuff->length);
+
+ swapl(&stuff->window);
+
+ swapl(&stuff->pixmap);
+ swapl(&stuff->serial);
+
+ swapl(&stuff->valid);
+ swapl(&stuff->update);
+
+ swaps(&stuff->x_off);
+ swaps(&stuff->y_off);
+ swapl(&stuff->target_crtc);
+
+ swapl(&stuff->acquire_syncobj);
+ swapl(&stuff->release_syncobj);
+ swapll(&stuff->acquire_point);
+ swapll(&stuff->release_point);
+
+ swapl(&stuff->options);
+
+ swapll(&stuff->target_msc);
+ swapll(&stuff->divisor);
+ swapll(&stuff->remainder);
+ return (*proc_present_vector[stuff->presentReqType]) (client);
+}
+#endif /* DRI3 */
+
static int (*sproc_present_vector[PresentNumberRequests]) (ClientPtr) = {
sproc_present_query_version, /* 0 */
sproc_present_pixmap, /* 1 */
sproc_present_notify_msc, /* 2 */
sproc_present_select_input, /* 3 */
sproc_present_query_capabilities, /* 4 */
+#ifdef DRI3
+ sproc_present_pixmap_synced, /* 5 */
+#endif /* DRI3 */
};
int _X_COLD
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 239055bc1..5f05f8fc9 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -23,9 +23,6 @@
#include "present_priv.h"
#include <misync.h>
#include <misyncstr.h>
-#ifdef MONOTONIC_CLOCK
-#include <time.h>
-#endif
/*
* Screen flip mode
@@ -71,6 +68,7 @@ present_check_flip(RRCrtcPtr crtc,
PixmapPtr window_pixmap;
WindowPtr root = screen->root;
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+ PresentFlipReason tmp_reason = PRESENT_FLIP_REASON_UNKNOWN;
if (crtc) {
screen_priv = present_screen_priv(crtc->pScreen);
@@ -91,6 +89,27 @@ present_check_flip(RRCrtcPtr crtc,
if (!screen_priv->info->flip)
return FALSE;
+ /* Ask the driver for permission. Do this now to see if there's TearFree. */
+ if (screen_priv->info->version >= 1 && screen_priv->info->check_flip2) {
+ if (!(*screen_priv->info->check_flip2) (crtc, window, pixmap, sync_flip, &tmp_reason)) {
+ DebugPresent(("\td %08" PRIx32 " -> %08" PRIx32 "\n", window->drawable.id, pixmap ? pixmap->drawable.id : 0));
+ /* It's fine to return now unless the page flip failure reason is
+ * PRESENT_FLIP_REASON_BUFFER_FORMAT; we must only output that
+ * reason if all the other checks pass.
+ */
+ if (!reason || tmp_reason != PRESENT_FLIP_REASON_BUFFER_FORMAT) {
+ if (reason)
+ *reason = tmp_reason;
+ return FALSE;
+ }
+ }
+ } else if (screen_priv->info->check_flip) {
+ if (!(*screen_priv->info->check_flip) (crtc, window, pixmap, sync_flip)) {
+ DebugPresent(("\td %08" PRIx32 " -> %08" PRIx32 "\n", window->drawable.id, pixmap ? pixmap->drawable.id : 0));
+ return FALSE;
+ }
+ }
+
/* Make sure the window hasn't been redirected with Composite */
window_pixmap = screen->GetWindowPixmap(window);
if (window_pixmap != screen->GetScreenPixmap(screen) &&
@@ -115,7 +134,7 @@ present_check_flip(RRCrtcPtr crtc,
/* Does the window match the pixmap exactly? */
if (window->drawable.x != 0 || window->drawable.y != 0 ||
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
window->drawable.x != pixmap->screen_x || window->drawable.y != pixmap->screen_y ||
#endif
window->drawable.width != pixmap->drawable.width ||
@@ -123,17 +142,10 @@ present_check_flip(RRCrtcPtr crtc,
return FALSE;
}
- /* Ask the driver for permission */
- if (screen_priv->info->version >= 1 && screen_priv->info->check_flip2) {
- if (!(*screen_priv->info->check_flip2) (crtc, window, pixmap, sync_flip, reason)) {
- DebugPresent(("\td %08" PRIx32 " -> %08" PRIx32 "\n", window->drawable.id, pixmap ? pixmap->drawable.id : 0));
- return FALSE;
- }
- } else if (screen_priv->info->check_flip) {
- if (!(*screen_priv->info->check_flip) (crtc, window, pixmap, sync_flip)) {
- DebugPresent(("\td %08" PRIx32 " -> %08" PRIx32 "\n", window->drawable.id, pixmap ? pixmap->drawable.id : 0));
- return FALSE;
- }
+ if (tmp_reason == PRESENT_FLIP_REASON_BUFFER_FORMAT) {
+ if (reason)
+ *reason = tmp_reason;
+ return FALSE;
}
return TRUE;
@@ -456,7 +468,9 @@ present_check_flip_window (WindowPtr window)
xorg_list_for_each_entry(vblank, &window_priv->vblank, window_list) {
if (vblank->queued && vblank->flip && !present_check_flip(vblank->crtc, window, vblank->pixmap, vblank->sync_flip, NULL, 0, 0, &reason)) {
vblank->flip = FALSE;
- vblank->reason = reason;
+ /* Don't spuriously flag this as a TearFree presentation */
+ if (reason < PRESENT_FLIP_REASON_DRIVER_TEARFREE)
+ vblank->reason = reason;
if (vblank->sync_flip)
vblank->exec_msc = vblank->target_msc;
}
@@ -560,7 +574,9 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
xorg_list_del(&vblank->window_list);
vblank->queued = FALSE;
- if (vblank->pixmap && vblank->window) {
+ if (vblank->pixmap && vblank->window &&
+ (vblank->reason < PRESENT_FLIP_REASON_DRIVER_TEARFREE ||
+ vblank->exec_msc != vblank->target_msc)) {
if (vblank->flip) {
@@ -627,6 +643,51 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
present_execute_copy(vblank, crtc_msc);
+ /* With TearFree, there's no way to tell exactly when the presentation
+ * will be visible except by waiting for a notification from the kernel
+ * driver indicating that the page flip is complete. This is because the
+ * CRTC's MSC can change while the target MSC is calculated and even
+ * while the page flip IOCTL is sent to the kernel due to scheduling
+ * delays and/or unfortunate timing. Even worse, a page flip isn't
+ * actually guaranteed to be finished after one vblank; it may be
+ * several MSCs until a flip actually finishes depending on delays and
+ * load in hardware.
+ *
+ * So, to get a notification from the driver with TearFree active, the
+ * driver expects a present_flip() call with a NULL pixmap to indicate
+ * that this is a fake flip for a pixmap that's already been copied to
+ * the primary scanout, which will then be flipped by TearFree. TearFree
+ * will then send a notification once the flip containing this pixmap is
+ * complete.
+ *
+ * If the fake flip attempt fails, then fall back to just enqueuing a
+ * vblank event targeting the next MSC.
+ */
+ if (!vblank->queued &&
+ vblank->reason >= PRESENT_FLIP_REASON_DRIVER_TEARFREE) {
+ uint64_t completion_msc = crtc_msc + 1;
+
+ /* If TearFree is already flipping then the presentation will be
+ * visible at the *next* next vblank. This calculation only matters
+ * for the vblank event fallback.
+ */
+ if (vblank->reason == PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING &&
+ vblank->exec_msc < crtc_msc)
+ completion_msc++;
+
+ /* Try the fake flip first and then fall back to a vblank event */
+ if (present_flip(vblank->crtc, vblank->event_id, 0, NULL, TRUE) ||
+ Success == screen_priv->queue_vblank(screen,
+ window,
+ vblank->crtc,
+ vblank->event_id,
+ completion_msc)) {
+ /* Ensure present_execute_post() runs at the next execution */
+ vblank->exec_msc = vblank->target_msc;
+ vblank->queued = TRUE;
+ }
+ }
+
if (vblank->queued) {
xorg_list_add(&vblank->event_queue, &present_exec_queue);
xorg_list_append(&vblank->window_list,
@@ -674,6 +735,12 @@ present_scmd_pixmap(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
uint64_t target_window_msc,
uint64_t divisor,
@@ -690,6 +757,11 @@ present_scmd_pixmap(WindowPtr window,
present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE);
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+#ifdef DRI3
+ if (acquire_syncobj || release_syncobj)
+ return BadValue;
+#endif /* DRI3 */
+
if (!window_priv)
return BadAlloc;
@@ -739,6 +811,11 @@ present_scmd_pixmap(WindowPtr window,
if (vblank->crtc != target_crtc || vblank->target_msc != target_msc)
continue;
+ /* Too late to abort now if TearFree execution already happened */
+ if (vblank->reason >= PRESENT_FLIP_REASON_DRIVER_TEARFREE &&
+ vblank->exec_msc == vblank->target_msc)
+ continue;
+
present_vblank_scrap(vblank);
if (vblank->flip_ready)
present_re_execute(vblank);
@@ -755,6 +832,12 @@ present_scmd_pixmap(WindowPtr window,
target_crtc,
wait_fence,
idle_fence,
+#ifdef DRI3
+ acquire_syncobj,
+ release_syncobj,
+ acquire_point,
+ release_point,
+#endif /* DRI3 */
options,
screen_priv->info ? screen_priv->info->capabilities : 0,
notifies,
@@ -767,7 +850,12 @@ present_scmd_pixmap(WindowPtr window,
vblank->event_id = ++present_scmd_event_id;
- if (vblank->flip && vblank->sync_flip)
+ /* The soonest presentation is crtc_msc+2 if TearFree is already flipping */
+ if (vblank->reason == PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING &&
+ !msc_is_after(vblank->exec_msc, crtc_msc + 1))
+ vblank->exec_msc -= 2;
+ else if (vblank->reason >= PRESENT_FLIP_REASON_DRIVER_TEARFREE ||
+ (vblank->flip && vblank->sync_flip))
vblank->exec_msc--;
xorg_list_append(&vblank->event_queue, &present_exec_queue);
diff --git a/present/present_screen.c b/present/present_screen.c
index 15684eda4..0589b2ee9 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -93,6 +93,15 @@ present_destroy_window(WindowPtr window)
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
present_window_priv_ptr window_priv = present_window_priv(window);
+ present_send_config_notify(window,
+ window->drawable.x,
+ window->drawable.y,
+ window->drawable.width,
+ window->drawable.height,
+ window->borderWidth,
+ window->nextSib,
+ PresentWindowDestroyed);
+
if (window_priv) {
present_clear_window_notifies(window);
present_free_events(window);
@@ -123,7 +132,7 @@ present_config_notify(WindowPtr window,
ScreenPtr screen = window->drawable.pScreen;
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
- present_send_config_notify(window, x, y, w, h, bw, sibling);
+ present_send_config_notify(window, x, y, w, h, bw, sibling, 0);
unwrap(screen_priv, screen, ConfigNotify);
if (screen->ConfigNotify)
@@ -178,10 +187,31 @@ present_screen_priv_init(ScreenPtr screen)
wrap(screen_priv, screen, ClipNotify, present_clip_notify);
dixSetPrivate(&screen->devPrivates, &present_screen_private_key, screen_priv);
+ screen_priv->pScreen = screen;
return screen_priv;
}
+static int
+check_flip_visit(WindowPtr window, void *data)
+{
+ ScreenPtr screen = window->drawable.pScreen;
+ present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+ if (!screen_priv)
+ return WT_DONTWALKCHILDREN;
+
+ screen_priv->check_flip_window(window);
+
+ return WT_WALKCHILDREN;
+}
+
+void
+present_check_flips(WindowPtr window)
+{
+ TraverseTree(window, check_flip_visit, NULL);
+}
+
/*
* Initialize a screen for use with present in default screen flip mode (scmd)
*/
diff --git a/present/present_vblank.c b/present/present_vblank.c
index a9f17d4b2..dd255cc60 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -21,6 +21,7 @@
*/
#include "present_priv.h"
+#include <unistd.h>
void
present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, uint64_t ust, uint64_t crtc_msc)
@@ -55,6 +56,12 @@ present_vblank_init(present_vblank_ptr vblank,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
const uint32_t capabilities,
present_notify_ptr notifies,
@@ -115,7 +122,7 @@ present_vblank_init(present_vblank_ptr vblank,
{
vblank->flip = TRUE;
vblank->sync_flip = TRUE;
- } else if ((capabilities & PresentCapabilityAsync) &&
+ } else if ((capabilities & PresentAllAsyncCapabilities) &&
screen_priv->check_flip (target_crtc, window, pixmap, FALSE, valid, x_off, y_off, &reason))
{
vblank->flip = TRUE;
@@ -135,6 +142,22 @@ present_vblank_init(present_vblank_ptr vblank,
goto no_mem;
}
+#ifdef DRI3
+ vblank->efd = -1;
+
+ if (acquire_syncobj) {
+ vblank->acquire_syncobj = acquire_syncobj;
+ ++acquire_syncobj->refcount;
+ vblank->acquire_point = acquire_point;
+ }
+
+ if (release_syncobj) {
+ vblank->release_syncobj = release_syncobj;
+ ++release_syncobj->refcount;
+ vblank->release_point = release_point;
+ }
+#endif /* DRI3 */
+
if (pixmap)
DebugPresent(("q %" PRIu64 " %p %" PRIu64 ": %08" PRIx32 " -> %08" PRIx32 " (crtc %p) flip %d vsync %d serial %d\n",
vblank->event_id, vblank, target_msc,
@@ -158,6 +181,12 @@ present_vblank_create(WindowPtr window,
RRCrtcPtr target_crtc,
SyncFence *wait_fence,
SyncFence *idle_fence,
+#ifdef DRI3
+ struct dri3_syncobj *acquire_syncobj,
+ struct dri3_syncobj *release_syncobj,
+ uint64_t acquire_point,
+ uint64_t release_point,
+#endif /* DRI3 */
uint32_t options,
const uint32_t capabilities,
present_notify_ptr notifies,
@@ -172,6 +201,10 @@ present_vblank_create(WindowPtr window,
if (present_vblank_init(vblank, window, pixmap, serial, valid, update,
x_off, y_off, target_crtc, wait_fence, idle_fence,
+#ifdef DRI3
+ acquire_syncobj, release_syncobj,
+ acquire_point, release_point,
+#endif /* DRI3 */
options, capabilities, notifies, num_notifies,
target_msc, crtc_msc))
return vblank;
@@ -229,5 +262,20 @@ present_vblank_destroy(present_vblank_ptr vblank)
if (vblank->notifies)
present_destroy_notifies(vblank->notifies, vblank->num_notifies);
+#ifdef DRI3
+ if (vblank->efd >= 0) {
+ SetNotifyFd(vblank->efd, NULL, 0, NULL);
+ close(vblank->efd);
+ }
+
+ if (vblank->acquire_syncobj &&
+ --vblank->acquire_syncobj->refcount == 0)
+ vblank->acquire_syncobj->free(vblank->acquire_syncobj);
+
+ if (vblank->release_syncobj &&
+ --vblank->release_syncobj->refcount == 0)
+ vblank->release_syncobj->free(vblank->release_syncobj);
+#endif /* DRI3 */
+
free(vblank);
}
diff --git a/randr/randr.c b/randr/randr.c
index 6d02c2577..2994bcd6c 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -30,7 +30,7 @@
#include <dix-config.h>
#endif
-#include "randrstr.h"
+#include "randrstr_priv.h"
#include "extinit.h"
/* From render.h */
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 173ecdf4e..fa2203502 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -65,11 +65,6 @@ typedef XID RRCrtc;
typedef XID RRProvider;
typedef XID RRLease;
-extern int RREventBase, RRErrorBase;
-
-extern int (*ProcRandrVector[RRNumberRequests]) (ClientPtr);
-extern int (*SProcRandrVector[RRNumberRequests]) (ClientPtr);
-
/*
* Modeline for a monitor. Name follows directly after this struct
*/
@@ -128,8 +123,8 @@ struct _rrCrtc {
RRTransformRec client_pending_transform;
RRTransformRec client_current_transform;
PictTransform transform;
- struct pict_f_transform f_transform;
- struct pict_f_transform f_inverse;
+ struct pixman_f_transform f_transform;
+ struct pixman_f_transform f_inverse;
PixmapPtr scanout_pixmap;
PixmapPtr scanout_pixmap_back;
@@ -218,6 +213,10 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
Rotation rotation,
int numOutputs, RROutputPtr * outputs);
+typedef void (*RRCrtcGetProcPtr) (ScreenPtr pScreen,
+ RRCrtcPtr crtc,
+ xRRGetCrtcInfoReply *rep);
+
typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc);
typedef Bool (*RRCrtcGetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc);
@@ -420,6 +419,10 @@ typedef struct _rrScrPriv {
RRRequestLeaseProcPtr rrRequestLease;
RRGetLeaseProcPtr rrGetLease;
+
+#if RANDR_12_INTERFACE
+ RRCrtcGetProcPtr rrCrtcGet;
+#endif
} rrScrPrivRec, *rrScrPrivPtr;
extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec;
@@ -459,65 +462,8 @@ typedef struct _RRClient {
/* RRTimesRec times[0]; */
} RRClientRec, *RRClientPtr;
-extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
-extern DevPrivateKeyRec RRClientPrivateKeyRec;
-
-#define RRClientPrivateKey (&RRClientPrivateKeyRec)
extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType, RRProviderType, RRLeaseType;
-#define VERIFY_RR_OUTPUT(id, ptr, a)\
- {\
- int rc = dixLookupResourceByType((void **)&(ptr), id,\
- RROutputType, client, a);\
- if (rc != Success) {\
- client->errorValue = id;\
- return rc;\
- }\
- }
-
-#define VERIFY_RR_CRTC(id, ptr, a)\
- {\
- int rc = dixLookupResourceByType((void **)&(ptr), id,\
- RRCrtcType, client, a);\
- if (rc != Success) {\
- client->errorValue = id;\
- return rc;\
- }\
- }
-
-#define VERIFY_RR_MODE(id, ptr, a)\
- {\
- int rc = dixLookupResourceByType((void **)&(ptr), id,\
- RRModeType, client, a);\
- if (rc != Success) {\
- client->errorValue = id;\
- return rc;\
- }\
- }
-
-#define VERIFY_RR_PROVIDER(id, ptr, a)\
- {\
- int rc = dixLookupResourceByType((void **)&(ptr), id,\
- RRProviderType, client, a);\
- if (rc != Success) {\
- client->errorValue = id;\
- return rc;\
- }\
- }
-
-#define VERIFY_RR_LEASE(id, ptr, a)\
- {\
- int rc = dixLookupResourceByType((void **)&(ptr), id,\
- RRLeaseType, client, a);\
- if (rc != Success) {\
- client->errorValue = id;\
- return rc;\
- }\
- }
-
-#define GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
-#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
-
#ifdef RANDR_12_INTERFACE
/*
* Set the range of sizes for the screen
@@ -678,7 +624,6 @@ extern _X_EXPORT void
* the driver calls this whenever it has updated the mode
*/
extern _X_EXPORT Bool
-
RRCrtcNotify(RRCrtcPtr crtc,
RRModePtr mode,
int x,
@@ -693,7 +638,6 @@ extern _X_EXPORT void
* Request that the Crtc be reconfigured
*/
extern _X_EXPORT Bool
-
RRCrtcSet(RRCrtcPtr crtc,
RRModePtr mode,
int x,
@@ -760,11 +704,10 @@ extern _X_EXPORT void
*/
extern _X_EXPORT int
-
RRCrtcTransformSet(RRCrtcPtr crtc,
PictTransformPtr transform,
- struct pict_f_transform *f_transform,
- struct pict_f_transform *f_inverse,
+ struct pixman_f_transform *f_transform,
+ struct pixman_f_transform *f_inverse,
char *filter, int filter_len, xFixed * params, int nparams);
/*
@@ -819,23 +762,10 @@ extern _X_EXPORT int
extern _X_EXPORT int
ProcRRGetCrtcTransform(ClientPtr client);
-int
- ProcRRGetPanning(ClientPtr client);
-
-int
- ProcRRSetPanning(ClientPtr client);
-
-void
- RRConstrainCursorHarder(DeviceIntPtr, ScreenPtr, int, int *, int *);
-
/* rrdispatch.c */
extern _X_EXPORT Bool
RRClientKnowsRates(ClientPtr pClient);
-/* rrlease.c */
-void
-RRDeliverLeaseEvent(ClientPtr client, WindowPtr window);
-
extern _X_EXPORT void
RRLeaseTerminated(RRLeasePtr lease);
@@ -848,12 +778,6 @@ RRCrtcIsLeased(RRCrtcPtr crtc);
extern _X_EXPORT Bool
RROutputIsLeased(RROutputPtr output);
-void
-RRTerminateLease(RRLeasePtr lease);
-
-Bool
-RRLeaseInit(void);
-
/* rrmode.c */
/*
* Find, and if necessary, create a mode
@@ -923,7 +847,6 @@ extern _X_EXPORT Bool
RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones);
extern _X_EXPORT Bool
-
RROutputSetModes(RROutputPtr output,
RRModePtr * modes, int numModes, int numPreferred);
@@ -997,13 +920,11 @@ extern _X_EXPORT Bool
RRPostPendingProperties(RROutputPtr output);
extern _X_EXPORT int
-
RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
int format, int mode, unsigned long len,
const void *value, Bool sendevent, Bool pending);
extern _X_EXPORT int
-
RRConfigureOutputProperty(RROutputPtr output, Atom property,
Bool pending, Bool range, Bool immutable,
int num_values, const INT32 *values);
@@ -1108,51 +1029,13 @@ ProcRRChangeProviderProperty(ClientPtr client);
extern _X_EXPORT int
ProcRRDeleteProviderProperty(ClientPtr client);
+
/* rrxinerama.c */
#ifdef XINERAMA
extern _X_EXPORT void
RRXineramaExtensionInit(void);
#endif
-void
-RRMonitorInit(ScreenPtr screen);
-
-Bool
-RRMonitorMakeList(ScreenPtr screen, Bool get_active, RRMonitorPtr *monitors_ret, int *nmon_ret);
-
-int
-RRMonitorCountList(ScreenPtr screen);
-
-void
-RRMonitorFreeList(RRMonitorPtr monitors, int nmon);
-
-void
-RRMonitorClose(ScreenPtr screen);
-
-RRMonitorPtr
-RRMonitorAlloc(int noutput);
-
-int
-RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor);
-
-void
-RRMonitorFree(RRMonitorPtr monitor);
-
-int
-ProcRRGetMonitors(ClientPtr client);
-
-int
-ProcRRSetMonitor(ClientPtr client);
-
-int
-ProcRRDeleteMonitor(ClientPtr client);
-
-int
-ProcRRCreateLease(ClientPtr client);
-
-int
-ProcRRFreeLease(ClientPtr client);
-
#endif /* _RANDRSTR_H_ */
/*
diff --git a/randr/randrstr_priv.h b/randr/randrstr_priv.h
new file mode 100644
index 000000000..4864f5272
--- /dev/null
+++ b/randr/randrstr_priv.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2000 Compaq Computer Corporation
+ * Copyright © 2002 Hewlett-Packard Company
+ * Copyright © 2006 Intel Corporation
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ * Author: Jim Gettys, Hewlett-Packard Company, Inc.
+ * Keith Packard, Intel Corporation
+ */
+
+#ifndef _XSERVER_RANDRSTR_PRIV_H_
+#define _XSERVER_RANDRSTR_PRIV_H_
+
+#include "randrstr.h"
+
+extern int RREventBase, RRErrorBase;
+
+extern int (*ProcRandrVector[RRNumberRequests]) (ClientPtr);
+extern int (*SProcRandrVector[RRNumberRequests]) (ClientPtr);
+
+extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
+extern DevPrivateKeyRec RRClientPrivateKeyRec;
+
+#define RRClientPrivateKey (&RRClientPrivateKeyRec)
+
+#define VERIFY_RR_OUTPUT(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((void **)&(ptr), id,\
+ RROutputType, client, a);\
+ if (rc != Success) {\
+ client->errorValue = id;\
+ return rc;\
+ }\
+ }
+
+#define VERIFY_RR_CRTC(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((void **)&(ptr), id,\
+ RRCrtcType, client, a);\
+ if (rc != Success) {\
+ client->errorValue = id;\
+ return rc;\
+ }\
+ }
+
+#define VERIFY_RR_MODE(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((void **)&(ptr), id,\
+ RRModeType, client, a);\
+ if (rc != Success) {\
+ client->errorValue = id;\
+ return rc;\
+ }\
+ }
+
+#define VERIFY_RR_PROVIDER(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((void **)&(ptr), id,\
+ RRProviderType, client, a);\
+ if (rc != Success) {\
+ client->errorValue = id;\
+ return rc;\
+ }\
+ }
+
+#define VERIFY_RR_LEASE(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((void **)&(ptr), id,\
+ RRLeaseType, client, a);\
+ if (rc != Success) {\
+ client->errorValue = id;\
+ return rc;\
+ }\
+ }
+
+#define GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
+#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
+
+int ProcRRGetPanning(ClientPtr client);
+
+int ProcRRSetPanning(ClientPtr client);
+
+void RRConstrainCursorHarder(DeviceIntPtr, ScreenPtr, int, int *, int *);
+
+/* rrlease.c */
+void RRDeliverLeaseEvent(ClientPtr client, WindowPtr window);
+
+void RRTerminateLease(RRLeasePtr lease);
+
+Bool RRLeaseInit(void);
+
+/* rrprovider.c */
+#define PRIME_SYNC_PROP "PRIME Synchronization"
+
+void RRMonitorInit(ScreenPtr screen);
+
+Bool RRMonitorMakeList(ScreenPtr screen, Bool get_active, RRMonitorPtr *monitors_ret, int *nmon_ret);
+
+int RRMonitorCountList(ScreenPtr screen);
+
+void RRMonitorFreeList(RRMonitorPtr monitors, int nmon);
+
+void RRMonitorClose(ScreenPtr screen);
+
+RRMonitorPtr RRMonitorAlloc(int noutput);
+
+int RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor);
+
+void RRMonitorFree(RRMonitorPtr monitor);
+
+int ProcRRGetMonitors(ClientPtr client);
+
+int ProcRRSetMonitor(ClientPtr client);
+
+int ProcRRDeleteMonitor(ClientPtr client);
+
+int ProcRRCreateLease(ClientPtr client);
+
+int ProcRRFreeLease(ClientPtr client);
+
+#endif /* _XSERVER_RANDRSTR_PRIV_H_ */
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index cf149768f..b47f0aeac 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -21,7 +21,7 @@
* OF THIS SOFTWARE.
*/
-#include "randrstr.h"
+#include "randrstr_priv.h"
#include "swaprep.h"
#include "mipointer.h"
@@ -1261,6 +1261,9 @@ ProcRRGetCrtcInfo(ClientPtr client)
}
}
+ if (pScrPriv->rrCrtcGet)
+ pScrPriv->rrCrtcGet(pScreen, crtc, &rep);
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index a5b390914..8cb79b199 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -19,8 +19,11 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
+
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
-#include "randrstr.h"
#include "protocol-versions.h"
Bool
@@ -135,7 +138,7 @@ ProcRRSelectInput(ClientPtr client)
if (!pHead ||
!AddResource(pWin->drawable.id, RREventType,
(void *) pHead)) {
- FreeResource(clientResource, RT_NONE);
+ FreeResource(clientResource, X11_RESTYPE_NONE);
return BadAlloc;
}
*pHead = 0;
diff --git a/randr/rrlease.c b/randr/rrlease.c
index cb366e767..4d92b4af9 100644
--- a/randr/rrlease.c
+++ b/randr/rrlease.c
@@ -19,11 +19,15 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
-#include "randrstr.h"
-#include "swaprep.h"
#include <unistd.h>
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
+
+#include "swaprep.h"
+
RESTYPE RRLeaseType;
/*
@@ -147,7 +151,7 @@ RRLeaseTerminated(RRLeasePtr lease)
RRLeaseChangeState(lease, RRLeaseTerminating, RRLeaseTerminating);
if (lease->id != None)
- FreeResource(lease->id, RT_NONE);
+ FreeResource(lease->id, X11_RESTYPE_NONE);
xorg_list_del(&lease->list);
}
@@ -364,7 +368,7 @@ ProcRRFreeLease(ClientPtr client)
RRTerminateLease(lease);
else
/* Get rid of the resource database entry */
- FreeResource(stuff->lid, RT_NONE);
+ FreeResource(stuff->lid, X11_RESTYPE_NONE);
return Success;
}
diff --git a/randr/rrmode.c b/randr/rrmode.c
index d34025bd0..23d5c70d8 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -19,8 +19,10 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
-#include "randrstr.h"
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
RESTYPE RRModeType;
diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c
index e62bd484d..9280061ff 100644
--- a/randr/rrmonitor.c
+++ b/randr/rrmonitor.c
@@ -19,8 +19,11 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
+
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
-#include "randrstr.h"
#include "swaprep.h"
static Atom
@@ -156,8 +159,8 @@ RRMonitorGetGeometry(RRMonitorPtr monitor, RRMonitorGeometryPtr geometry)
/* Adjust physical sizes to account for total area */
if (active_crtcs > 1 && first.box.x2 != first.box.x1 && first.box.y2 != first.box.y1) {
- geometry->mmWidth = (this.box.x2 - this.box.x1) / (first.box.x2 - first.box.x1) * first.mmWidth;
- geometry->mmHeight = (this.box.y2 - this.box.y1) / (first.box.y2 - first.box.y1) * first.mmHeight;
+ geometry->mmWidth = ((double)(geometry->box.x2 - geometry->box.x1) / (first.box.x2 - first.box.x1)) * first.mmWidth;
+ geometry->mmHeight = ((double)(geometry->box.y2 - geometry->box.y1) / (first.box.y2 - first.box.y1)) * first.mmHeight;
}
} else {
*geometry = monitor->geometry;
@@ -489,17 +492,6 @@ RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor)
}
}
- /* 'name' must not match the name of any Monitor on the screen, or
- * a Value error results.
- */
-
- for (m = 0; m < pScrPriv->numMonitors; m++) {
- if (pScrPriv->monitors[m]->name == monitor->name) {
- client->errorValue = monitor->name;
- return BadValue;
- }
- }
-
/* Allocate space for the new pointer. This is done before
* removing matching monitors as it may fail, and the request
* needs to not have any side-effects on failure
@@ -518,7 +510,6 @@ RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor)
for (m = 0; m < pScrPriv->numMonitors; m++) {
RRMonitorPtr existing = pScrPriv->monitors[m];
- int o, eo;
/* If 'name' matches an existing Monitor on the screen, the
* existing one will be deleted as if RRDeleteMonitor were called.
@@ -528,27 +519,6 @@ RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor)
continue;
}
- /* For each output in 'info.outputs', each one is removed from all
- * pre-existing Monitors. If removing the output causes the list
- * of outputs for that Monitor to become empty, then that
- * Monitor will be deleted as if RRDeleteMonitor were called.
- */
-
- for (eo = 0; eo < existing->numOutputs; eo++) {
- for (o = 0; o < monitor->numOutputs; o++) {
- if (monitor->outputs[o] == existing->outputs[eo]) {
- memmove(existing->outputs + eo, existing->outputs + eo + 1,
- (existing->numOutputs - (eo + 1)) * sizeof (RROutput));
- --existing->numOutputs;
- --eo;
- break;
- }
- }
- if (existing->numOutputs == 0) {
- (void) RRMonitorDelete(client, screen, existing->name);
- break;
- }
- }
if (monitor->primary)
existing->primary = FALSE;
}
diff --git a/randr/rroutput.c b/randr/rroutput.c
index db0bb0f29..0b4639aa6 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -20,10 +20,13 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
-#include "randrstr.h"
#include <X11/Xatom.h>
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
+
RESTYPE RROutputType;
/*
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index c2fb9585c..327a0656c 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -20,7 +20,7 @@
* OF THIS SOFTWARE.
*/
-#include "randrstr.h"
+#include "randrstr_priv.h"
#include "propertyst.h"
#include "swaprep.h"
#include <X11/Xatom.h>
@@ -209,7 +209,7 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
RRDestroyOutputProperty(prop);
return BadAlloc;
}
- new_value.size = len;
+ new_value.size = total_len;
new_value.type = type;
new_value.format = format;
@@ -226,7 +226,7 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
case PropModePrepend:
new_data = new_value.data;
old_data = (void *) (((char *) new_value.data) +
- (prop_value->size * size_in_bytes));
+ (len * size_in_bytes));
break;
}
if (new_data)
@@ -530,7 +530,7 @@ ProcRRChangeOutputProperty(ClientPtr client)
char format, mode;
unsigned long len;
int sizeInBytes;
- int totalSize;
+ uint64_t totalSize;
int err;
REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq);
diff --git a/randr/rrprovider.c b/randr/rrprovider.c
index d628a20d4..9c874aa37 100644
--- a/randr/rrprovider.c
+++ b/randr/rrprovider.c
@@ -22,12 +22,15 @@
*
* Authors: Dave Airlie
*/
-
-#include "randrstr.h"
-#include "swaprep.h"
+#include <dix-config.h>
#include <X11/Xatom.h>
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
+
+#include "swaprep.h"
+
RESTYPE RRProviderType = 0;
/*
@@ -459,7 +462,7 @@ RRProviderInit(void)
return TRUE;
}
-extern _X_EXPORT Bool
+Bool
RRProviderLookup(XID id, RRProviderPtr *provider_p)
{
int rc = dixLookupResourceByType((void **)provider_p, id,
diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c
index b79c17f9b..7f22c7e34 100644
--- a/randr/rrproviderproperty.c
+++ b/randr/rrproviderproperty.c
@@ -20,7 +20,7 @@
* OF THIS SOFTWARE.
*/
-#include "randrstr.h"
+#include "randrstr_priv.h"
#include "propertyst.h"
#include "swaprep.h"
@@ -498,7 +498,7 @@ ProcRRChangeProviderProperty(ClientPtr client)
char format, mode;
unsigned long len;
int sizeInBytes;
- int totalSize;
+ uint64_t totalSize;
int err;
REQUEST_AT_LEAST_SIZE(xRRChangeProviderPropertyReq);
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 58b5299b4..1403a3cf4 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -19,8 +19,10 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
+#include <dix-config.h>
-#include "randrstr.h"
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
static CARD16
RR10CurrentSizeID(ScreenPtr pScreen);
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 7d7b5a884..1f29d9d39 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -20,7 +20,7 @@
* OF THIS SOFTWARE.
*/
-#include "randrstr.h"
+#include "randrstr_priv.h"
static int _X_COLD
SProcRRQueryVersion(ClientPtr client)
diff --git a/randr/rrtransform.h b/randr/rrtransform.h
index f811d2b3d..5b0dcbd58 100644
--- a/randr/rrtransform.h
+++ b/randr/rrtransform.h
@@ -30,8 +30,8 @@ typedef struct _rrTransform RRTransformRec, *RRTransformPtr;
struct _rrTransform {
PictTransform transform;
- struct pict_f_transform f_transform;
- struct pict_f_transform f_inverse;
+ struct pixman_f_transform f_transform;
+ struct pixman_f_transform f_inverse;
PictFilterPtr filter;
xFixed *params;
int nparams;
@@ -73,7 +73,7 @@ RRTransformCompute(int x,
Rotation rotation,
RRTransformPtr rr_transform,
PictTransformPtr transform,
- struct pict_f_transform *f_transform,
- struct pict_f_transform *f_inverse);
+ struct pixman_f_transform *f_transform,
+ struct pixman_f_transform *f_inverse);
#endif /* _RRTRANSFORM_H_ */
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 5f01e953c..36d53dc1e 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -67,10 +67,15 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>,
* David Thomas <davtom@dream.org.uk>.
*/
+#include <dix-config.h>
-#include "randrstr.h"
-#include "swaprep.h"
+#include <X11/Xmd.h>
#include <X11/extensions/panoramiXproto.h>
+
+#include "dix/dix_priv.h"
+#include "randr/randrstr_priv.h"
+
+#include "swaprep.h"
#include "protocol-versions.h"
/* Xinerama is not multi-screen capable; just report about screen 0 */
diff --git a/record/record.c b/record/record.c
index e123867a7..88fbf9c85 100644
--- a/record/record.c
+++ b/record/record.c
@@ -36,6 +36,8 @@ and Jim Haggerty of Metheus.
#include <dix-config.h>
#endif
+#include "dix/eventconvert.h"
+
#include "dixstruct.h"
#include "extnsionst.h"
#include "extinit.h"
@@ -43,7 +45,6 @@ and Jim Haggerty of Metheus.
#include "set.h"
#include "swaprep.h"
#include "inputstr.h"
-#include "eventconvert.h"
#include "scrnintstr.h"
#include <stdio.h>
@@ -2456,7 +2457,7 @@ ProcRecordFreeContext(ClientPtr client)
REQUEST_SIZE_MATCH(xRecordFreeContextReq);
VERIFY_CONTEXT(pContext, stuff->context, client);
- FreeResource(stuff->context, RT_NONE);
+ FreeResource(stuff->context, X11_RESTYPE_NONE);
return Success;
} /* ProcRecordFreeContext */
diff --git a/record/set.c b/record/set.c
index e0db385b9..74e40d93e 100644
--- a/record/set.c
+++ b/record/set.c
@@ -54,6 +54,17 @@ from The Open Group.
#include "misc.h"
#include "set.h"
+/*
+ * Ideally we would always use _Alignof(type) here, but that requires C11, so
+ * we approximate this using sizeof(void*) for older C standards as that
+ * should be a valid assumption on all supported architectures.
+ */
+#if defined(__STDC__) && (__STDC_VERSION__ - 0 >= 201112L)
+#define MinSetAlignment(type) max(_Alignof(type), _Alignof(unsigned long))
+#else
+#define MinSetAlignment(type) max(sizeof(void*), sizeof(unsigned long))
+#endif
+
static int
maxMemberInInterval(RecordSetInterval * pIntervals, int nIntervals)
{
@@ -179,7 +190,7 @@ BitVectorSetMemoryRequirements(RecordSetInterval * pIntervals, int nIntervals,
{
int nlongs;
- *alignment = sizeof(unsigned long);
+ *alignment = MinSetAlignment(BitVectorSet);
nlongs = (maxMember + BITS_PER_LONG) / BITS_PER_LONG;
return (sizeof(BitVectorSet) + nlongs * sizeof(unsigned long));
}
@@ -289,7 +300,7 @@ static int
IntervalListMemoryRequirements(RecordSetInterval * pIntervals, int nIntervals,
int maxMember, int *alignment)
{
- *alignment = sizeof(unsigned long);
+ *alignment = MinSetAlignment(IntervalListSet);
return sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval);
}
diff --git a/render/animcur.c b/render/animcur.c
index ef27bda27..e736e4c24 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -43,7 +43,7 @@
#include "cursorstr.h"
#include "dixfontstr.h"
#include "opaque.h"
-#include "picturestr.h"
+#include "picturestr_priv.h"
#include "inputstr.h"
#include "xace.h"
@@ -336,8 +336,8 @@ AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
/* security creation/labeling check */
if (ac->timer)
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
- RT_NONE, NULL, DixCreateAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, X11_RESTYPE_CURSOR, pCursor,
+ X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) {
TimerFree(ac->timer);
diff --git a/render/filter.c b/render/filter.c
index 2741f406c..44f6b6465 100644
--- a/render/filter.c
+++ b/render/filter.c
@@ -24,6 +24,9 @@
#include <dix-config.h>
#endif
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@@ -43,6 +46,47 @@ static char **filterNames;
static int nfilterNames;
/*
+ * ISO Latin-1 case conversion routine
+ *
+ * this routine always null-terminates the result, so
+ * beware of too-small buffers
+ */
+
+static unsigned char
+ISOLatin1ToLower(unsigned char source)
+{
+ unsigned char dest;
+
+ if ((source >= XK_A) && (source <= XK_Z))
+ dest = source + (XK_a - XK_A);
+ else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
+ dest = source + (XK_agrave - XK_Agrave);
+ else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
+ dest = source + (XK_oslash - XK_Ooblique);
+ else
+ dest = source;
+ return dest;
+}
+
+static int
+CompareISOLatin1Lowered(const unsigned char *s1, int s1len,
+ const unsigned char *s2, int s2len)
+{
+ unsigned char c1, c2;
+
+ for (;;) {
+ /* note -- compare against zero so that -1 ignores len */
+ c1 = s1len-- ? *s1++ : '\0';
+ c2 = s2len-- ? *s2++ : '\0';
+ if (!c1 ||
+ (c1 != c2 &&
+ (c1 = ISOLatin1ToLower(c1)) != (c2 = ISOLatin1ToLower(c2))))
+ break;
+ }
+ return (int) c1 - (int) c2;
+}
+
+/*
* standard but not required filters don't have constant indices
*/
diff --git a/render/glyph.c b/render/glyph.c
index f3ed9cf4c..5fa7f3b5b 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -26,7 +26,7 @@
#include <dix-config.h>
#endif
-#include "xsha1.h"
+#include "os/xsha1.h"
#include "misc.h"
#include "scrnintstr.h"
@@ -42,7 +42,7 @@
#include "gcstruct.h"
#include "servermd.h"
#include "picturestr.h"
-#include "glyphstr.h"
+#include "glyphstr_priv.h"
#include "mipict.h"
/*
@@ -245,10 +245,11 @@ FreeGlyphPicture(GlyphPtr glyph)
}
}
-static void
+void
FreeGlyph(GlyphPtr glyph, int format)
{
CheckDuplicates(&globalGlyphs[format], "FreeGlyph");
+ BUG_RETURN(glyph->refcnt == 0);
if (--glyph->refcnt == 0) {
GlyphRefPtr gr;
int i;
@@ -290,8 +291,6 @@ AddGlyph(GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
gr = FindGlyphRef(&globalGlyphs[glyphSet->fdepth], signature,
TRUE, glyph->sha1);
if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph) {
- FreeGlyphPicture(glyph);
- dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
glyph = gr->glyph;
}
else if (gr->glyph != glyph) {
@@ -354,7 +353,7 @@ AllocateGlyph(xGlyphInfo * gi, int fdepth)
glyph = (GlyphPtr) malloc(size);
if (!glyph)
return 0;
- glyph->refcnt = 0;
+ glyph->refcnt = 1;
glyph->size = size + sizeof(xGlyphInfo);
glyph->info = *gi;
dixInitPrivates(glyph, (char *) glyph + head_size, PRIVATE_GLYPH);
diff --git a/render/glyphstr.h b/render/glyphstr.h
index 2f51bd244..9f6b1c410 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -25,12 +25,8 @@
#ifndef _GLYPHSTR_H_
#define _GLYPHSTR_H_
-#include <X11/extensions/renderproto.h>
#include "picture.h"
#include "screenint.h"
-#include "regionstr.h"
-#include "miscstruct.h"
-#include "privates.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
@@ -48,41 +44,6 @@ typedef struct _Glyph {
/* per-screen pixmaps follow */
} GlyphRec, *GlyphPtr;
-#define GlyphPicture(glyph) ((PicturePtr *) ((glyph) + 1))
-
-typedef struct _GlyphRef {
- CARD32 signature;
- GlyphPtr glyph;
-} GlyphRefRec, *GlyphRefPtr;
-
-#define DeletedGlyph ((GlyphPtr) 1)
-
-typedef struct _GlyphHashSet {
- CARD32 entries;
- CARD32 size;
- CARD32 rehash;
-} GlyphHashSetRec, *GlyphHashSetPtr;
-
-typedef struct _GlyphHash {
- GlyphRefPtr table;
- GlyphHashSetPtr hashSet;
- CARD32 tableEntries;
-} GlyphHashRec, *GlyphHashPtr;
-
-typedef struct _GlyphSet {
- CARD32 refcnt;
- int fdepth;
- PictFormatPtr format;
- GlyphHashRec hash;
- PrivateRec *devPrivates;
-} GlyphSetRec, *GlyphSetPtr;
-
-#define GlyphSetGetPrivate(pGlyphSet,k) \
- dixLookupPrivate(&(pGlyphSet)->devPrivates, k)
-
-#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \
- dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr)
-
typedef struct _GlyphList {
INT16 xOff;
INT16 yOff;
@@ -90,33 +51,6 @@ typedef struct _GlyphList {
PictFormatPtr format;
} GlyphListRec, *GlyphListPtr;
-extern void
- GlyphUninit(ScreenPtr pScreen);
-
-extern GlyphPtr FindGlyphByHash(unsigned char sha1[20], int format);
-
-extern int
-HashGlyph(xGlyphInfo * gi,
- CARD8 *bits, unsigned long size, unsigned char sha1[20]);
-
-extern void
- AddGlyph(GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
-
-extern Bool
- DeleteGlyph(GlyphSetPtr glyphSet, Glyph id);
-
-extern GlyphPtr FindGlyph(GlyphSetPtr glyphSet, Glyph id);
-
-extern GlyphPtr AllocateGlyph(xGlyphInfo * gi, int format);
-
-extern Bool
- ResizeGlyphSet(GlyphSetPtr glyphSet, CARD32 change);
-
-extern GlyphSetPtr AllocateGlyphSet(int fdepth, PictFormatPtr format);
-
-extern int
- FreeGlyphSet(void *value, XID gid);
-
#define GLYPH_HAS_GLYPH_PICTURE_ACCESSOR 1 /* used for api compat */
extern _X_EXPORT PicturePtr
GetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen);
diff --git a/render/glyphstr_priv.h b/render/glyphstr_priv.h
new file mode 100644
index 000000000..dd1bc5482
--- /dev/null
+++ b/render/glyphstr_priv.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 2000 SuSE, Inc.
+ */
+#ifndef _XSERVER_GLYPHSTR_PRIV_H_
+#define _XSERVER_GLYPHSTR_PRIV_H_
+
+#include <X11/extensions/renderproto.h>
+#include "glyphstr.h"
+#include "picture.h"
+#include "screenint.h"
+#include "regionstr.h"
+#include "miscstruct.h"
+#include "privates.h"
+
+#define GlyphPicture(glyph) ((PicturePtr *) ((glyph) + 1))
+
+typedef struct {
+ CARD32 signature;
+ GlyphPtr glyph;
+} GlyphRefRec, *GlyphRefPtr;
+
+#define DeletedGlyph ((GlyphPtr) 1)
+
+typedef struct {
+ CARD32 entries;
+ CARD32 size;
+ CARD32 rehash;
+} GlyphHashSetRec, *GlyphHashSetPtr;
+
+typedef struct {
+ GlyphRefPtr table;
+ GlyphHashSetPtr hashSet;
+ CARD32 tableEntries;
+} GlyphHashRec, *GlyphHashPtr;
+
+typedef struct {
+ CARD32 refcnt;
+ int fdepth;
+ PictFormatPtr format;
+ GlyphHashRec hash;
+ PrivateRec *devPrivates;
+} GlyphSetRec, *GlyphSetPtr;
+
+#define GlyphSetGetPrivate(pGlyphSet,k) \
+ dixLookupPrivate(&(pGlyphSet)->devPrivates, k)
+
+#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \
+ dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr)
+
+void GlyphUninit(ScreenPtr pScreen);
+GlyphPtr FindGlyphByHash(unsigned char sha1[20], int format);
+int HashGlyph(xGlyphInfo * gi, CARD8 *bits, unsigned long size, unsigned char sha1[20]);
+void AddGlyph(GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
+Bool DeleteGlyph(GlyphSetPtr glyphSet, Glyph id);
+GlyphPtr FindGlyph(GlyphSetPtr glyphSet, Glyph id);
+GlyphPtr AllocateGlyph(xGlyphInfo * gi, int format);
+void FreeGlyph(GlyphPtr glyph, int format);
+Bool ResizeGlyphSet(GlyphSetPtr glyphSet, CARD32 change);
+GlyphSetPtr AllocateGlyphSet(int fdepth, PictFormatPtr format);
+int FreeGlyphSet(void *value, XID gid);
+
+#endif /* _XSERVER_GLYPHSTR_PRIV_H_ */
diff --git a/render/picture.c b/render/picture.c
index 2be4b1954..45498b093 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -39,7 +39,8 @@
#include "dixstruct.h"
#include "gcstruct.h"
#include "servermd.h"
-#include "picturestr.h"
+#include "picturestr_priv.h"
+#include "glyphstr_priv.h"
#include "xace.h"
#ifdef PANORAMIX
#include "panoramiXsrv.h"
@@ -421,7 +422,7 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
if (format->index.vid == pScreen->rootVisual) {
dixLookupResourceByType((void **) &format->index.pColormap,
- pScreen->defColormap, RT_COLORMAP,
+ pScreen->defColormap, X11_RESTYPE_COLORMAP,
serverClient, DixGetAttrAccess);
}
else {
@@ -589,7 +590,7 @@ GetPictureBytes(void *value, XID id, ResourceSizePtr size)
size->pixmapRefSize = 0;
if (picture->pDrawable && (picture->pDrawable->type == DRAWABLE_PIXMAP))
{
- SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+ SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(X11_RESTYPE_PIXMAP);
ResourceSizeRec pixmapSize = { 0, 0, 0 };
PixmapPtr pixmap = (PixmapPtr)picture->pDrawable;
pixmapSizeFunc(pixmap, pixmap->drawable.id, &pixmapSize);
@@ -639,7 +640,7 @@ PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
(formats[n].id, PictFormatType, (void *) (formats + n))) {
int i;
for (i = 0; i < n; i++)
- FreeResource(formats[i].id, RT_NONE);
+ FreeResource(formats[i].id, X11_RESTYPE_NONE);
free(formats);
return FALSE;
}
@@ -760,7 +761,7 @@ CreatePicture(Picture pid,
/* security creation/labeling check */
*error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture,
- RT_PIXMAP, pDrawable, DixCreateAccess | DixSetAttrAccess);
+ X11_RESTYPE_PIXMAP, pDrawable, DixCreateAccess | DixSetAttrAccess);
if (*error != Success)
goto out;
@@ -1027,7 +1028,7 @@ cpClipMask(void **result, XID id, ScreenPtr screen, ClientPtr client, Mask mode)
id = res->info[screen->myNum].id;
}
#endif
- return dixLookupResourceByType(result, id, RT_PIXMAP, client, mode);
+ return dixLookupResourceByType(result, id, X11_RESTYPE_PIXMAP, client, mode);
}
#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val)
diff --git a/render/picture.h b/render/picture.h
index 4499a0021..c3a73d1d8 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -125,7 +125,10 @@ typedef enum _PictFormatShort {
/* 1bpp formats */
PICT_a1 = PIXMAN_a1,
- PICT_g1 = PIXMAN_g1
+ PICT_g1 = PIXMAN_g1,
+
+/* YCbCr formats */
+ PICT_yuv2 = PIXMAN_yuy2
} PictFormatShort;
/*
diff --git a/render/picturestr.h b/render/picturestr.h
index dd25a272d..001d37bfa 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -24,6 +24,7 @@
#ifndef _PICTURESTR_H_
#define _PICTURESTR_H_
+#include <X11/extensions/renderproto.h>
#include "scrnintstr.h"
#include "glyphstr.h"
#include "resource.h"
@@ -56,10 +57,6 @@ typedef struct _PictFormat {
typedef struct pixman_vector PictVector, *PictVectorPtr;
typedef struct pixman_transform PictTransform, *PictTransformPtr;
-#define pict_f_vector pixman_f_vector
-#define pict_f_transform pixman_f_transform
-
-#define PICT_GRADIENT_STOPTABLE_SIZE 1024
#define SourcePictTypeSolidFill 0
#define SourcePictTypeLinear 1
#define SourcePictTypeRadial 2
@@ -350,31 +347,12 @@ extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec;
extern _X_EXPORT DevPrivateKeyRec PictureWindowPrivateKeyRec;
#define PictureWindowPrivateKey (&PictureWindowPrivateKeyRec)
-extern RESTYPE PictureType;
-extern RESTYPE PictFormatType;
-extern RESTYPE GlyphSetType;
-
#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
#define GetPictureScreenIfSet(s) (dixPrivateKeyRegistered(PictureScreenPrivateKey) ? GetPictureScreen(s) : NULL)
#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
-#define VERIFY_PICTURE(pPicture, pid, client, mode) {\
- int tmprc = dixLookupResourceByType((void *)&(pPicture), pid,\
- PictureType, client, mode);\
- if (tmprc != Success)\
- return tmprc;\
-}
-
-#define VERIFY_ALPHA(pPicture, pid, client, mode) {\
- if (pid == None) \
- pPicture = 0; \
- else { \
- VERIFY_PICTURE(pPicture, pid, client, mode); \
- } \
-} \
-
extern _X_EXPORT PictFormatPtr
PictureWindowFormat(WindowPtr pWindow);
@@ -508,13 +486,6 @@ CompositeTriFan(CARD8 op,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
-Bool
- AnimCurInit(ScreenPtr pScreen);
-
-int
-AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
- CursorPtr *ppCursor, ClientPtr client, XID cid);
-
extern _X_EXPORT void
AddTraps(PicturePtr pPicture,
INT16 xOff, INT16 yOff, int ntraps, xTrap * traps);
@@ -545,11 +516,6 @@ CreateConicalGradientPicture(Picture pid,
int nStops,
xFixed * stops, xRenderColor * colors, int *error);
-#ifdef PANORAMIX
-extern void PanoramiXRenderInit(void);
-extern void PanoramiXRenderReset(void);
-#endif
-
/*
* matrix.c
*/
diff --git a/render/picturestr_priv.h b/render/picturestr_priv.h
new file mode 100644
index 000000000..b5064a5ac
--- /dev/null
+++ b/render/picturestr_priv.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
+ * Copyright © 2000 SuSE, Inc.
+ */
+#ifndef _XSERVER_PICTURESTR_PRIV_H_
+#define _XSERVER_PICTURESTR_PRIV_H_
+
+#include "picturestr.h"
+#include "scrnintstr.h"
+#include "glyphstr.h"
+#include "resource.h"
+#include "privates.h"
+
+#define PICT_GRADIENT_STOPTABLE_SIZE 1024
+
+extern RESTYPE PictureType;
+extern RESTYPE PictFormatType;
+extern RESTYPE GlyphSetType;
+
+#define VERIFY_PICTURE(pPicture, pid, client, mode) {\
+ int tmprc = dixLookupResourceByType((void *)&(pPicture), pid,\
+ PictureType, client, mode);\
+ if (tmprc != Success)\
+ return tmprc;\
+}
+
+#define VERIFY_ALPHA(pPicture, pid, client, mode) {\
+ if (pid == None) \
+ pPicture = 0; \
+ else { \
+ VERIFY_PICTURE(pPicture, pid, client, mode); \
+ } \
+} \
+
+Bool AnimCurInit(ScreenPtr pScreen);
+
+int AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
+ CursorPtr *ppCursor, ClientPtr client, XID cid);
+
+#ifdef PANORAMIX
+void PanoramiXRenderInit(void);
+void PanoramiXRenderReset(void);
+#endif /* PANORAMIX */
+
+#endif /* _XSERVER_PICTURESTR_PRIV_H_ */
diff --git a/render/render.c b/render/render.c
index 456f156d4..af84a0345 100644
--- a/render/render.c
+++ b/render/render.c
@@ -28,6 +28,12 @@
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/extensions/render.h>
+#include <X11/extensions/renderproto.h>
+#include <X11/Xfuncproto.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
@@ -39,11 +45,8 @@
#include "extnsionst.h"
#include "extinit.h"
#include "servermd.h"
-#include <X11/extensions/render.h>
-#include <X11/extensions/renderproto.h>
-#include "picturestr.h"
-#include "glyphstr.h"
-#include <X11/Xfuncproto.h>
+#include "picturestr_priv.h"
+#include "glyphstr_priv.h"
#include "cursorstr.h"
#include "xace.h"
#include "protocol-versions.h"
@@ -646,7 +649,7 @@ ProcRenderFreePicture(ClientPtr client)
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
VERIFY_PICTURE(pPicture, stuff->picture, client, DixDestroyAccess);
- FreeResource(stuff->picture, RT_NONE);
+ FreeResource(stuff->picture, X11_RESTYPE_NONE);
return Success;
}
@@ -927,7 +930,7 @@ ProcRenderCreateGlyphSet(ClientPtr client)
return BadAlloc;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType,
- glyphSet, RT_NONE, NULL, DixCreateAccess);
+ glyphSet, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success)
return rc;
if (!AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet))
@@ -977,7 +980,7 @@ ProcRenderFreeGlyphSet(ClientPtr client)
client->errorValue = stuff->glyphset;
return rc;
}
- FreeResource(stuff->glyphset, RT_NONE);
+ FreeResource(stuff->glyphset, X11_RESTYPE_NONE);
return Success;
}
@@ -1076,6 +1079,7 @@ ProcRenderAddGlyphs(ClientPtr client)
if (glyph_new->glyph && glyph_new->glyph != DeletedGlyph) {
glyph_new->found = TRUE;
+ ++glyph_new->glyph->refcnt;
}
else {
GlyphPtr glyph;
@@ -1168,8 +1172,10 @@ ProcRenderAddGlyphs(ClientPtr client)
err = BadAlloc;
goto bail;
}
- for (i = 0; i < nglyphs; i++)
+ for (i = 0; i < nglyphs; i++) {
AddGlyph(glyphSet, glyphs[i].glyph, glyphs[i].id);
+ FreeGlyph(glyphs[i].glyph, glyphSet->fdepth);
+ }
if (glyphsBase != glyphsLocal)
free(glyphsBase);
@@ -1179,9 +1185,13 @@ ProcRenderAddGlyphs(ClientPtr client)
FreePicture((void *) pSrc, 0);
if (pSrcPix)
FreeScratchPixmapHeader(pSrcPix);
- for (i = 0; i < nglyphs; i++)
- if (glyphs[i].glyph && !glyphs[i].found)
- free(glyphs[i].glyph);
+ for (i = 0; i < nglyphs; i++) {
+ if (glyphs[i].glyph) {
+ --glyphs[i].glyph->refcnt;
+ if (!glyphs[i].found)
+ free(glyphs[i].glyph);
+ }
+ }
if (glyphsBase != glyphsLocal)
free(glyphsBase);
return err;
@@ -1625,7 +1635,7 @@ ProcRenderCreateCursor(ClientPtr client)
&pCursor, client, stuff->cid);
if (rc != Success)
goto bail;
- if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) {
+ if (!AddResource(stuff->cid, X11_RESTYPE_CURSOR, (void *) pCursor)) {
rc = BadAlloc;
goto bail;
}
@@ -1795,7 +1805,7 @@ ProcRenderCreateAnimCursor(ClientPtr client)
elt = (xAnimCursorElt *) (stuff + 1);
for (i = 0; i < ncursor; i++) {
ret = dixLookupResourceByType((void **) (cursors + i), elt->cursor,
- RT_CURSOR, client, DixReadAccess);
+ X11_RESTYPE_CURSOR, client, DixReadAccess);
if (ret != Success) {
free(cursors);
return ret;
@@ -1809,7 +1819,7 @@ ProcRenderCreateAnimCursor(ClientPtr client)
if (ret != Success)
return ret;
- if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor))
+ if (AddResource(stuff->cid, X11_RESTYPE_CURSOR, (void *) pCursor))
return Success;
return BadAlloc;
}
@@ -1853,7 +1863,7 @@ ProcRenderCreateSolidFill(ClientPtr client)
return error;
/* security creation/labeling check */
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
- pPicture, RT_NONE, NULL, DixCreateAccess);
+ pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
return error;
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
@@ -1892,7 +1902,7 @@ ProcRenderCreateLinearGradient(ClientPtr client)
return error;
/* security creation/labeling check */
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
- pPicture, RT_NONE, NULL, DixCreateAccess);
+ pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
return error;
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
@@ -1932,7 +1942,7 @@ ProcRenderCreateRadialGradient(ClientPtr client)
return error;
/* security creation/labeling check */
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
- pPicture, RT_NONE, NULL, DixCreateAccess);
+ pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
return error;
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
@@ -1971,7 +1981,7 @@ ProcRenderCreateConicalGradient(ClientPtr client)
return error;
/* security creation/labeling check */
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
- pPicture, RT_NONE, NULL, DixCreateAccess);
+ pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
return error;
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
diff --git a/test/bugs/bug1354.c b/test/bugs/bug1354.c
new file mode 100644
index 000000000..edc3f228c
--- /dev/null
+++ b/test/bugs/bug1354.c
@@ -0,0 +1,149 @@
+#include <xcb/xcb.h>
+#include <xcb/xcb_aux.h>
+#include <xcb/xcb_image.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <ctype.h>
+#include <unistd.h>
+
+/*
+ * This is a test which try to test correct glamor colors when rendered.
+ * It should be run with fullscreen Xephyr (with glamor) with present and with
+ * etalon high-level Xserver (can be any, on CI - Xvfb). For testing this test
+ * creates an image in Xephyr X server, which filled by one of colors defined in
+ * test_pixels. Then it captures central pixel from both Xephyr and Xserver above.
+ * If pixels differ - test failed. Sleep is used to ensure than presentation on both
+ * Xephyr and Xvfb kicks (xcb_aux_sync was not enough) and test results will be actual
+ */
+
+#define WIDTH 300
+#define HEIGHT 300
+
+int get_display_pixel(xcb_connection_t* c, xcb_drawable_t win);
+void draw_display_pixel(xcb_connection_t* c, xcb_drawable_t win, uint32_t pixel_color);
+
+int get_display_pixel(xcb_connection_t* c, xcb_drawable_t win)
+{
+ xcb_image_t *image;
+ uint32_t pixel;
+ int format = XCB_IMAGE_FORMAT_XY_PIXMAP;
+
+ image = xcb_image_get (c, win,
+ 0, 0, WIDTH, HEIGHT,
+ UINT32_MAX,
+ format);
+ if (!image) {
+ printf("xcb_image_get failed: exiting\n");
+ exit(1);
+ }
+
+ pixel = xcb_image_get_pixel(image, WIDTH/2, HEIGHT/2);
+
+ return pixel;
+}
+
+void draw_display_pixel(xcb_connection_t* c, xcb_drawable_t win, uint32_t pixel_color)
+{
+ xcb_gcontext_t foreground;
+ uint32_t mask = 0;
+
+ xcb_rectangle_t rectangles[] = {
+ {0, 0, WIDTH, HEIGHT},
+ };
+
+ foreground = xcb_generate_id (c);
+ mask = XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH | XCB_GC_SUBWINDOW_MODE;
+
+ uint32_t values[] = {
+ pixel_color,
+ 20,
+ XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS
+ };
+
+ xcb_create_gc (c, foreground, win, mask, values);
+
+ xcb_poly_fill_rectangle (c, win, foreground, 1, rectangles);
+ xcb_aux_sync ( c );
+}
+
+
+int main(int argc, char* argv[])
+{
+ xcb_connection_t *c, *r;
+ xcb_screen_t *screen1, *screen2;
+ xcb_drawable_t win1, win2;
+ char *name_test = NULL, *name_relevant = NULL;
+ uint32_t pixel_server1, pixel_server2;
+ int result = 0;
+ uint32_t test_pixels[3] = {0xff0000, 0x00ff00, 0x0000ff};
+ int gv;
+
+ while ((gv = getopt (argc, argv, "t:r:")) != -1)
+ switch (gv)
+ {
+ case 't':
+ name_test = optarg;
+ break;
+ case 'r':
+ name_relevant = optarg;
+ break;
+ case '?':
+ if (optopt == 't' || optopt == 'r')
+ fprintf (stderr, "Option -%c requires an argument - test screen name.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr,
+ "Unknown option character `\\x%x'.\n",
+ optopt);
+ return 1;
+ default:
+ abort ();
+ }
+
+ printf("test=%s, rel=%s\n", name_test, name_relevant);
+
+ c = xcb_connect (name_test, NULL);
+ r = xcb_connect (name_relevant, NULL);
+
+ /* get the first screen */
+ screen1 = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
+
+ win1 = xcb_generate_id (c);
+ xcb_create_window (c, /* Connection */
+ XCB_COPY_FROM_PARENT, /* depth (same as root)*/
+ win1, /* window Id */
+ screen1->root, /* parent window */
+ 0, 0, /* x, y */
+ WIDTH, HEIGHT, /* width, height */
+ 20, /* border_width */
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
+ screen1->root_visual, /* visual */
+ 0, NULL ); /* masks, not used yet */
+
+
+ /* Map the window on the screen */
+ xcb_map_window (c, win1);
+ xcb_aux_sync(c);
+
+ /* get the first screen */
+ screen2 = xcb_setup_roots_iterator (xcb_get_setup (r)).data;
+
+ /* root window */
+ win2 = screen2->root;
+
+ for(int i = 0; i < 3; i++)
+ {
+ draw_display_pixel(c, win1, test_pixels[i]);
+ xcb_aux_sync(r);
+ pixel_server1 = get_display_pixel(c, win1);
+ sleep(1);
+ pixel_server2 = get_display_pixel(r, win2);
+ xcb_aux_sync(r);
+ printf("p=0x%x, p2=0x%x\n", pixel_server1, pixel_server2);
+ result+= pixel_server1 == pixel_server2;
+ }
+ return result == 3 ? 0 : 1;
+}
diff --git a/test/bugs/meson.build b/test/bugs/meson.build
new file mode 100644
index 000000000..9ffb26443
--- /dev/null
+++ b/test/bugs/meson.build
@@ -0,0 +1,39 @@
+xcb_dep = dependency('xcb', required: false)
+xcb_image_dep = dependency('xcb-image', required: false)
+xcb_util_dep = dependency('xcb-util', required: false)
+
+if get_option('xvfb')
+ xvfb_args = [
+ xvfb_server.full_path(),
+ '-screen',
+ 'scrn',
+ '1280x1024x24'
+ ]
+
+ if xcb_dep.found() and xcb_image_dep.found() and xcb_util_dep.found() and get_option('xvfb') and get_option('xephyr') and build_glamor
+ bug1354 = executable('bug1354', 'bug1354.c', dependencies: [xcb_dep, xcb_image_dep, xcb_util_dep])
+ foreach testsuite: [
+ ['-gl', ':201', ':200'],
+ ['-gles2', ':199', ':198'],
+ ['-gles3', ':203', ':202']
+ ]
+ test('bug1354' + testsuite[0],
+ simple_xinit,
+ args: [simple_xinit.full_path(),
+ bug1354.full_path(),
+ '-t', testsuite[1],'-r', testsuite[2],
+ '----',
+ xephyr_server.full_path(),
+ '-glamor',
+ '-schedMax', '2000',
+ testsuite[1],
+ '--',
+ xvfb_args,
+ testsuite[2]
+ ],
+ suite: 'xephyr-glamor' + testsuite[0],
+ timeout: 300,
+ )
+ endforeach
+ endif
+endif \ No newline at end of file
diff --git a/test/fixes.c b/test/fixes.c
index ba7323495..b5d57cf8f 100644
--- a/test/fixes.c
+++ b/test/fixes.c
@@ -347,13 +347,15 @@ fixes_pointer_barrier_clamp_test(void)
assert(cy == barrier.y1);
}
-int
+const testfunc_t*
fixes_test(void)
{
+ static const testfunc_t testfuncs[] = {
+ fixes_pointer_barriers_test,
+ fixes_pointer_barrier_direction_test,
+ fixes_pointer_barrier_clamp_test,
+ NULL,
+ };
- fixes_pointer_barriers_test();
- fixes_pointer_barrier_direction_test();
- fixes_pointer_barrier_clamp_test();
-
- return 0;
+ return testfuncs;
}
diff --git a/test/hashtabletest.c b/test/hashtabletest.c
index 0387587cb..59c39b464 100644
--- a/test/hashtabletest.c
+++ b/test/hashtabletest.c
@@ -14,17 +14,17 @@ static void
print_xid(void* ptr, void* v)
{
XID *x = v;
- printf("%ld", (long)(*x));
+ dbg("%ld", (long)(*x));
}
static void
print_int(void* ptr, void* v)
{
int *x = v;
- printf("%d", *x);
+ dbg("%d", *x);
}
-static int
+static void
test1(void)
{
HashTable h;
@@ -32,7 +32,7 @@ test1(void)
int ok = 1;
const int numKeys = 420;
- printf("test1\n");
+ dbg("test1\n");
h = ht_create(sizeof(XID), sizeof(int), ht_resourceid_hash, ht_resourceid_compare, NULL);
for (c = 0; c < numKeys; ++c) {
@@ -44,9 +44,11 @@ test1(void)
}
}
- printf("Distribution after insertion\n");
- ht_dump_distribution(h);
- ht_dump_contents(h, print_xid, print_int, NULL);
+ if (verbose) {
+ dbg("Distribution after insertion\n");
+ ht_dump_distribution(h);
+ ht_dump_contents(h, print_xid, print_int, NULL);
+ }
for (c = 0; c < numKeys; ++c) {
XID id = c;
@@ -55,34 +57,36 @@ test1(void)
if (*v == 2 * c) {
// ok
} else {
- printf("Key %d doesn't have expected value %d but has %d instead\n",
+ dbg("Key %d doesn't have expected value %d but has %d instead\n",
c, 2 * c, *v);
ok = 0;
}
} else {
ok = 0;
- printf("Cannot find key %d\n", c);
+ dbg("Cannot find key %d\n", c);
}
}
if (ok) {
- printf("%d keys inserted and found\n", c);
+ dbg("%d keys inserted and found\n", c);
for (c = 0; c < numKeys; ++c) {
XID id = c;
ht_remove(h, &id);
}
- printf("Distribution after deletion\n");
- ht_dump_distribution(h);
+ if (verbose) {
+ dbg("Distribution after deletion\n");
+ ht_dump_distribution(h);
+ }
}
ht_destroy(h);
- return ok;
+ assert(ok);
}
-static int
+static void
test2(void)
{
HashTable h;
@@ -90,7 +94,7 @@ test2(void)
int ok = 1;
const int numKeys = 420;
- printf("test2\n");
+ dbg("test2\n");
h = ht_create(sizeof(XID), 0, ht_resourceid_hash, ht_resourceid_compare, NULL);
for (c = 0; c < numKeys; ++c) {
@@ -102,7 +106,7 @@ test2(void)
XID id = c;
if (!ht_find(h, &id)) {
ok = 0;
- printf("Cannot find key %d\n", c);
+ dbg("Cannot find key %d\n", c);
}
}
@@ -110,22 +114,22 @@ test2(void)
XID id = c + 1;
if (ht_find(h, &id)) {
ok = 0;
- printf("Could find a key that shouldn't be there\n");
+ dbg("Could find a key that shouldn't be there\n");
}
}
ht_destroy(h);
if (ok) {
- printf("Test with empty keys OK\n");
+ dbg("Test with empty keys OK\n");
} else {
- printf("Test with empty keys FAILED\n");
+ dbg("Test with empty keys FAILED\n");
}
- return ok;
+ assert(ok);
}
-static int
+static void
test3(void)
{
int ok = 1;
@@ -133,34 +137,38 @@ test3(void)
.keySize = 4
};
HashTable h;
- printf("test3\n");
+ dbg("test3\n");
h = ht_create(4, 0, ht_generic_hash, ht_generic_compare, &hashSetup);
if (!ht_add(h, "helo") ||
!ht_add(h, "wrld")) {
- printf("Could not insert keys\n");
+ dbg("Could not insert keys\n");
}
if (!ht_find(h, "helo") ||
!ht_find(h, "wrld")) {
ok = 0;
- printf("Could not find inserted keys\n");
+ dbg("Could not find inserted keys\n");
}
- printf("Hash distribution with two strings\n");
- ht_dump_distribution(h);
+ if (verbose) {
+ dbg("Hash distribution with two strings\n");
+ ht_dump_distribution(h);
+ }
ht_destroy(h);
- return ok;
+ assert(ok);
}
-int
+const testfunc_t*
hashtabletest_test(void)
{
- int ok = test1();
- ok = ok && test2();
- ok = ok && test3();
-
- return ok ? 0 : 1;
+ static const testfunc_t testfuncs[] = {
+ test1,
+ test2,
+ test3,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/input.c b/test/input.c
index e27374db3..14ddd8a79 100644
--- a/test/input.c
+++ b/test/input.c
@@ -37,8 +37,10 @@
#include <X11/Xatom.h>
#include "windowstr.h"
#include "inputstr.h"
-#include "eventconvert.h"
#include "exevents.h"
+
+#include "dix/eventconvert.h"
+
#include "exglobals.h"
#include "dixgrabs.h"
#include "eventstr.h"
@@ -154,6 +156,9 @@ dix_init_valuators(void)
assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
assert(axis->scroll.increment == 3.0);
assert(axis->scroll.flags == SCROLL_FLAG_NONE);
+
+ FreeDeviceClass(ValuatorClass, (void**)&val);
+ free(dev.last.scroll); /* sigh, allocated but not freed by the valuator functions */
}
/* just check the known success cases, and that error cases set the client's
@@ -282,6 +287,7 @@ dix_event_to_core(int type)
ev.detail.key = 0;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
x = 1;
y = 2;
@@ -289,6 +295,7 @@ dix_event_to_core(int type)
ev.root_y = y;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
x = 0x7FFF;
y = 0x7FFF;
@@ -296,6 +303,7 @@ dix_event_to_core(int type)
ev.root_y = y;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
x = 0x8000; /* too high */
y = 0x8000; /* too high */
@@ -307,6 +315,7 @@ dix_event_to_core(int type)
assert(count == 1);
assert(core->u.keyButtonPointer.rootX != x);
assert(core->u.keyButtonPointer.rootY != y);
+ free(core);
x = 0x7FFF;
y = 0x7FFF;
@@ -316,16 +325,19 @@ dix_event_to_core(int type)
ev.time = time;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
detail = 1;
ev.detail.key = detail;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
detail = 0xFF; /* highest value */
ev.detail.key = detail;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
detail = 0xFFF; /* too big */
ev.detail.key = detail;
@@ -338,6 +350,7 @@ dix_event_to_core(int type)
ev.corestate = state;
rc = EventToCore((InternalEvent *) &ev, &core, &count);
test_event();
+ free(core);
state = 0x10000; /* too big */
ev.corestate = state;
@@ -347,6 +360,7 @@ dix_event_to_core(int type)
assert(count == 1);
assert(core->u.keyButtonPointer.state != state);
assert(core->u.keyButtonPointer.state == (state & 0xFFFF));
+ free(core);
#undef test_event
}
@@ -985,7 +999,7 @@ test_padding_for_int32(int i)
static void
include_byte_padding_macros(void)
{
- printf("Testing bits_to_bytes()\n");
+ dbg("Testing bits_to_bytes()\n");
/* the macros don't provide overflow protection */
test_bits_to_byte(0);
@@ -998,7 +1012,7 @@ include_byte_padding_macros(void)
test_bits_to_byte(INT_MAX - 9);
test_bits_to_byte(INT_MAX - 8);
- printf("Testing bytes_to_int32()\n");
+ dbg("Testing bytes_to_int32()\n");
test_bytes_to_int32(0);
test_bytes_to_int32(1);
@@ -1014,7 +1028,7 @@ include_byte_padding_macros(void)
test_bytes_to_int32(INT_MAX - 4);
test_bytes_to_int32(INT_MAX - 3);
- printf("Testing pad_to_int32()\n");
+ dbg("Testing pad_to_int32()\n");
test_pad_to_int32(0);
test_pad_to_int32(1);
@@ -1031,7 +1045,7 @@ include_byte_padding_macros(void)
test_pad_to_int32(INT_MAX - 4);
test_pad_to_int32(INT_MAX - 3);
- printf("Testing padding_for_int32()\n");
+ dbg("Testing padding_for_int32()\n");
test_padding_for_int32(0);
test_padding_for_int32(1);
@@ -1064,7 +1078,7 @@ xi_unregister_handlers(void)
handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
assert(handler == 3);
- printf("Unlinking from front.\n");
+ dbg("Unlinking from front.\n");
XIUnregisterPropertyHandler(&dev, 4); /* NOOP */
assert(dev.properties.handlers->id == 3);
@@ -1197,6 +1211,7 @@ dix_input_attributes(void)
new = DuplicateInputAttributes(orig);
assert(memcmp(orig, new, sizeof(InputAttributes)) == 0);
+ FreeInputAttributes(new);
orig->product = xnfstrdup("product name");
new = DuplicateInputAttributes(orig);
@@ -1330,6 +1345,7 @@ dix_input_valuator_masks(void)
}
valuator_mask_free(&mask);
+ valuator_mask_free(&copy);
assert(mask == NULL);
}
@@ -1361,6 +1377,9 @@ dix_valuator_mode(void)
valuator_set_mode(&dev, VALUATOR_MODE_ALL_AXES, Relative);
for (i = 0; i < num_axes; i++)
assert(valuator_get_mode(&dev, i) == Relative);
+
+ FreeDeviceClass(ValuatorClass, (void**)&dev.valuator);
+ free(dev.last.scroll); /* sigh, allocated but not freed by the valuator functions */
}
static void
@@ -1548,7 +1567,7 @@ input_option_test(void)
InputOption *opt;
const char *val;
- printf("Testing input_option list interface\n");
+ dbg("Testing input_option list interface\n");
list = input_option_new(list, "key", "value");
assert(list);
@@ -1637,7 +1656,7 @@ _test_double_fp16_values(double orig_d)
double final_d;
if (orig_d > 0x7FFF) {
- printf("Test out of range\n");
+ dbg("Test out of range\n");
assert(0);
}
@@ -1651,7 +1670,7 @@ _test_double_fp16_values(double orig_d)
* snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
* snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
*
- * printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+ * dbg("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
* }
*/
@@ -1672,7 +1691,7 @@ _test_double_fp32_values(double orig_d)
double final_d;
if (orig_d > 0x7FFFFFFF) {
- printf("Test out of range\n");
+ dbg("Test out of range\n");
assert(0);
}
@@ -1686,7 +1705,7 @@ _test_double_fp32_values(double orig_d)
* snprintf(first_fp32_s, sizeof(first_fp32_s), "%d + %u * 2^-32", first_fp32.integral, first_fp32.frac);
* snprintf(final_fp32_s, sizeof(final_fp32_s), "%d + %u * 2^-32", first_fp32.integral, final_fp32.frac);
*
- * printf("FP32: original double: %f first fp32: %s, re-encoded double: %f, final fp32: %s\n", orig_d, first_fp32_s, final_d, final_fp32_s);
+ * dbg("FP32: original double: %f first fp32: %s, re-encoded double: %f, final fp32: %s\n", orig_d, first_fp32_s, final_d, final_fp32_s);
* }
*/
@@ -1705,7 +1724,7 @@ dix_double_fp_conversion(void)
{
uint32_t i;
- printf("Testing double to FP1616/FP3232 conversions\n");
+ dbg("Testing double to FP1616/FP3232 conversions\n");
_test_double_fp16_values(0);
for (i = 1; i < 0x7FFF; i <<= 1) {
@@ -1909,28 +1928,31 @@ dix_enqueue_events(void)
inputInfo.devices = NULL;
}
-int
+const testfunc_t*
input_test(void)
{
- dix_enqueue_events();
- dix_double_fp_conversion();
- dix_input_valuator_masks();
- dix_input_valuator_masks_unaccel();
- dix_input_attributes();
- dix_init_valuators();
- dix_event_to_core_conversion();
- dix_event_to_xi1_conversion();
- dix_check_grab_values();
- xi2_struct_sizes();
- dix_grab_matching();
- dix_valuator_mode();
- include_byte_padding_macros();
- include_bit_test_macros();
- xi_unregister_handlers();
- dix_valuator_alloc();
- dix_get_master();
- input_option_test();
- mieq_test();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ dix_enqueue_events,
+ dix_double_fp_conversion,
+ dix_input_valuator_masks,
+ dix_input_valuator_masks_unaccel,
+ dix_input_attributes,
+ dix_init_valuators,
+ dix_event_to_core_conversion,
+ dix_event_to_xi1_conversion,
+ dix_check_grab_values,
+ xi2_struct_sizes,
+ dix_grab_matching,
+ dix_valuator_mode,
+ include_byte_padding_macros,
+ include_bit_test_macros,
+ xi_unregister_handlers,
+ dix_valuator_alloc,
+ dix_get_master,
+ input_option_test,
+ mieq_test,
+ NULL,
+ };
+
+ return testfuncs;
}
diff --git a/test/list.c b/test/list.c
index d51817c21..06a9afc1e 100644
--- a/test/list.c
+++ b/test/list.c
@@ -266,6 +266,8 @@ test_nt_list_append(void)
i++;
}
assert(i == 11);
+
+ free(foo);
}
static void
@@ -300,6 +302,8 @@ test_nt_list_insert(void)
i++;
}
assert(i == 11);
+
+ free(foo);
}
static void
@@ -373,19 +377,21 @@ test_nt_list_delete(void)
free(list);
}
-int
+const testfunc_t*
list_test(void)
{
- test_xorg_list_init();
- test_xorg_list_add();
- test_xorg_list_append();
- test_xorg_list_del();
- test_xorg_list_for_each();
-
- test_nt_list_init();
- test_nt_list_append();
- test_nt_list_insert();
- test_nt_list_delete();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ test_xorg_list_init,
+ test_xorg_list_add,
+ test_xorg_list_append,
+ test_xorg_list_del,
+ test_xorg_list_for_each,
+
+ test_nt_list_init,
+ test_nt_list_append,
+ test_nt_list_insert,
+ test_nt_list_delete,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/meson.build b/test/meson.build
index e39f31a40..7c1663175 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -2,25 +2,41 @@ simple_xinit = executable(
'simple-xinit',
'simple-xinit.c',
include_directories: inc,
+ dependencies: [ xproto_dep ],
)
piglit_env = environment()
-piglit_env.set('XSERVER_DIR', meson.source_root())
-piglit_env.set('XSERVER_BUILDDIR', meson.build_root())
+piglit_env.set('XSERVER_DIR', meson.project_source_root())
+piglit_env.set('XSERVER_BUILDDIR', meson.project_build_root())
+
+gles20_env = environment()
+gles20_env.set('XSERVER_DIR', meson.project_source_root())
+gles20_env.set('XSERVER_BUILDDIR', meson.project_build_root())
+gles20_env.set('MESA_GLES_VERSION_OVERRIDE', '2.0')
some_ops = ' -o clear,src,dst,over,xor,disjointover'
-rendercheck_tests = [
+gles2_working_formats = ' -f '+ ','.join(['a8',
+ 'a8r8g8b8',
+ 'x8r8g8b8',
+ 'b8g8r8a8',
+ 'b8g8r8x8',
+ 'r8g8b8',
+ 'r5g5b5',
+ 'b5g5r5',
+ 'r5g6b5',
+ 'b5g6r5',
+ 'b8g8r8',
+ 'x8b8g8r8',
+ 'x2r10g10b10',
+ 'x2b10g10r10'])
+rendercheck_tests_noblend = [
['blend/All/a8r8g8b8', '-t blend -f a8r8g8b8'],
['blend/All/x8r8g8b8', '-t blend -f a8r8g8b8,x8r8g8b8'],
['blend/All/a2r10g10b10', '-t blend -f a8r8g8b8,a2r10g10b10'],
- ['blend/Clear', '-t blend -o clear'],
- ['blend/Src', '-t blend -o src'],
- ['blend/Over', '-t blend -o over'],
['composite/Some/a8r8g8b8', '-t composite -f a8r8g8b8' + some_ops],
['composite/Some/x8r8g8b8', '-t composite -f a8r8g8b8,x8r8g8b8' + some_ops],
['composite/Some/a2r10g10b10', '-t composite -f a8r8g8b8,a2r10g10b10' + some_ops],
['ca composite/Some/a8r8g8b8', '-t cacomposite -f a8r8g8b8' + some_ops],
- ['ca composite/Some/a8', '-t cacomposite -f a8r8g8b8,a8' + some_ops],
['ca composite/Some/x8r8g8b8', '-t cacomposite -f a8r8g8b8,x8r8g8b8' + some_ops],
['ca composite/Some/a2r10g10b10', '-t cacomposite -f a8r8g8b8,a2r10g10b10' + some_ops],
['fill', '-t fill'],
@@ -34,7 +50,24 @@ rendercheck_tests = [
['LibreOffice xRGB', '-t libreoffice_xrgb'],
['GTK ARGB vs xBGR', '-t gtk_argb_xbgr'],
]
-
+rendercheck_blend = [
+ ['blend/Clear', '-t blend -o clear'],
+ ['blend/Src', '-t blend -o src'],
+ ['blend/Over', '-t blend -o over'],
+]
+#A8 test failing on GLES 2.0 llvmpipe before mesa 23.
+rendercheck_a8 = [
+ ['ca composite/Some/a8', '-t cacomposite -f a8r8g8b8,a8' + some_ops],
+]
+#Exclude 15bpp for now due to GLES limitation (see glamor.c:470)
+rendercheck_blend_gles2 = [
+ ['blend/Clear', '-t blend -o clear' + gles2_working_formats],
+ ['blend/Src', '-t blend -o src' + gles2_working_formats],
+ ['blend/Over', '-t blend -o over' + gles2_working_formats],
+]
+rendercheck_tests = rendercheck_blend + rendercheck_tests_noblend + rendercheck_a8
+rendercheck_tests_gles2_success = rendercheck_blend_gles2 + rendercheck_tests_noblend
+rendercheck_tests_gles3 = rendercheck_blend_gles2 + rendercheck_tests_noblend + rendercheck_a8
rendercheck = find_program('rendercheck', required:false)
if get_option('xvfb')
@@ -59,7 +92,7 @@ if get_option('xvfb')
# Use full_path so people can copy and paste the
# command line from testlog.txt easily.
args: [
- rendercheck.path(),
+ rendercheck.full_path(),
rctest[1].split(' '),
'--',
xvfb_args,
@@ -70,31 +103,47 @@ if get_option('xvfb')
endif
if get_option('xephyr') and build_glamor
- test('XTS',
- find_program('scripts/xephyr-glamor-piglit.sh'),
- env: piglit_env,
- timeout: 1200,
- suite: 'xephr-glamor',
- )
+ foreach testsuite : ['','-gles2','-gles3']
+ test_env = piglit_env
+ if(testsuite == '-gles2')
+ test_env = gles20_env
+ endif
+ test('XTS',
+ find_program('scripts/xephyr-glamor' + testsuite + '-piglit.sh'),
+ env: piglit_env,
+ timeout: 1200,
+ suite: 'xephyr-glamor' + testsuite,
+ )
+ endforeach
+ test_parameters = [
+ [rendercheck_tests, '', piglit_env, '', false],
+ [rendercheck_tests_gles2_success, '_gles2', gles20_env, '-gles2', false],
+ [rendercheck_a8, '_gles2', gles20_env, '-gles2', true],
+ [rendercheck_tests_gles3, '_gles2', piglit_env, '-gles3', false]
+ ]
if rendercheck.found()
- foreach rctest: rendercheck_tests
- test(rctest[0],
- simple_xinit,
- args: [simple_xinit.full_path(),
- rendercheck.path(),
- rctest[1].split(' '),
- '----',
- xephyr_server.full_path(),
- '-glamor',
- '-glamor-skip-present',
- '-schedMax', '2000',
- '--',
- xvfb_args,
- ],
- suite: 'xephr-glamor',
- timeout: 300,
- )
+ foreach testsuite : test_parameters
+ foreach rctest : testsuite[0]
+ test(rctest[0],
+ simple_xinit,
+ args: [simple_xinit.full_path(),
+ rendercheck.full_path(),
+ rctest[1].split(' '),
+ '----',
+ xephyr_server.full_path(),
+ '-glamor' + testsuite[1],
+ '-glamor-skip-present',
+ '-schedMax', '2000',
+ '--',
+ xvfb_args,
+ ],
+ env: testsuite[2],
+ suite: 'xephyr-glamor' + testsuite[3],
+ should_fail: testsuite[4],
+ timeout: 300,
+ )
+ endforeach
endforeach
endif
endif
@@ -116,6 +165,7 @@ endif
subdir('bigreq')
subdir('damage')
subdir('sync')
+subdir('bugs')
if build_xorg
# Tests that require at least some DDX functions in order to fully link
@@ -138,15 +188,14 @@ if build_xorg
'xfree86.c',
'xtest.c',
]
- unit_defines = ['-DXORG_TESTS']
+ unit_c_args = ['-DXORG_TESTS']
unit_includes = [inc, xorg_inc]
if build_res
unit_sources += ['hashtabletest.c']
- unit_defines += ['-DRES_TESTS']
+ unit_c_args += ['-DRES_TESTS']
endif
- unit_c_args = unit_defines
if meson.get_compiler('c').has_link_argument('-Wl,-wrap')
# LTO breaks with -Wl,-wrap on certain configurations
unit_c_args += ['-fno-lto']
@@ -165,7 +214,7 @@ if build_xorg
'xi2/protocol-eventconvert.c',
'xi2/xi2.c',
]
- unit_defines += ['-DLDWRAP_TESTS']
+ unit_c_args += ['-DLDWRAP_TESTS']
unit_includes += [include_directories('xi1', 'xi2')]
ldwraps = [
'-Wl,-wrap,dixLookupWindow',
@@ -184,7 +233,7 @@ if build_xorg
unit = executable('tests',
unit_sources,
c_args: unit_c_args,
- dependencies: [pixman_dep, randrproto_dep, inputproto_dep, libxcvt_dep],
+ dependencies: [x11_dep, pixman_dep, randrproto_dep, inputproto_dep, libxcvt_dep],
include_directories: unit_includes,
link_args: ldwraps,
link_with: xorg_link,
diff --git a/test/misc.c b/test/misc.c
index 19ff13275..ba7a80b51 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -223,13 +223,17 @@ bswap_test(void)
assert(result_64 == expect_64);
}
-int
+const testfunc_t*
misc_test(void)
{
- dix_version_compare();
- dix_update_desktop_dimensions();
- dix_request_size_checks();
- bswap_test();
+ static const testfunc_t testfuncs[] = {
+ dix_version_compare,
+ dix_update_desktop_dimensions,
+ dix_request_size_checks,
+ bswap_test,
+ NULL,
+ };
+ return testfuncs;
return 0;
}
diff --git a/test/scripts/xephyr-glamor-gles2-piglit.sh b/test/scripts/xephyr-glamor-gles2-piglit.sh
new file mode 100755
index 000000000..59ca12d26
--- /dev/null
+++ b/test/scripts/xephyr-glamor-gles2-piglit.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# this times out on Travis, because the tests take too long.
+if test "x$TRAVIS_BUILD_DIR" != "x"; then
+ exit 77
+fi
+
+# Start a Xephyr server using glamor. Since the test environment is
+# headless, we start an Xvfb first to host the Xephyr.
+export PIGLIT_RESULTS_DIR=$XSERVER_BUILDDIR/test/piglit-results/xephyr-glamor-gles2
+
+export SERVER_COMMAND="$XSERVER_BUILDDIR/hw/kdrive/ephyr/Xephyr \
+ -glamor_gles2 \
+ -glamor-skip-present \
+ -noreset \
+ -schedMax 2000 \
+ -screen 1280x1024"
+
+# Tests that currently fail on llvmpipe on CI
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@6"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@7"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@4"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@5"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcopyarea@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2"
+
+export PIGLIT_ARGS
+
+$XSERVER_BUILDDIR/test/simple-xinit \
+ $XSERVER_DIR/test/scripts/run-piglit.sh \
+ -- \
+ $XSERVER_BUILDDIR/hw/vfb/Xvfb \
+ -screen scrn 1280x1024x24
diff --git a/test/scripts/xephyr-glamor-gles3-piglit.sh b/test/scripts/xephyr-glamor-gles3-piglit.sh
new file mode 100755
index 000000000..87b0a9b09
--- /dev/null
+++ b/test/scripts/xephyr-glamor-gles3-piglit.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# this times out on Travis, because the tests take too long.
+if test "x$TRAVIS_BUILD_DIR" != "x"; then
+ exit 77
+fi
+
+# Start a Xephyr server using glamor. Since the test environment is
+# headless, we start an Xvfb first to host the Xephyr.
+export PIGLIT_RESULTS_DIR=$XSERVER_BUILDDIR/test/piglit-results/xephyr-glamor-gles3
+
+export SERVER_COMMAND="$XSERVER_BUILDDIR/hw/kdrive/ephyr/Xephyr \
+ -glamor_gles2 \
+ -glamor-skip-present \
+ -noreset \
+ -schedMax 2000 \
+ -screen 1280x1024"
+
+# Tests that currently fail on llvmpipe on CI
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@6"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@7"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@4"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@5"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xcopyarea@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2"
+
+export PIGLIT_ARGS
+
+$XSERVER_BUILDDIR/test/simple-xinit \
+ $XSERVER_DIR/test/scripts/run-piglit.sh \
+ -- \
+ $XSERVER_BUILDDIR/hw/vfb/Xvfb \
+ -screen scrn 1280x1024x24
diff --git a/test/scripts/xephyr-glamor-piglit.sh b/test/scripts/xephyr-glamor-piglit.sh
index 0458f271b..62c17701f 100755
--- a/test/scripts/xephyr-glamor-piglit.sh
+++ b/test/scripts/xephyr-glamor-piglit.sh
@@ -22,6 +22,8 @@ PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@7"
PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@4"
PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@5"
PIGLIT_ARGS="$PIGLIT_ARGS -x xcopyarea@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2"
export PIGLIT_ARGS
diff --git a/test/scripts/xinit-piglit-session.sh b/test/scripts/xinit-piglit-session.sh
index 97bf2b9e0..6a51f9650 100755
--- a/test/scripts/xinit-piglit-session.sh
+++ b/test/scripts/xinit-piglit-session.sh
@@ -31,6 +31,8 @@ PIGLIT_ARGS="$PIGLIT_ARGS -x xlistfontswithinfo@4"
PIGLIT_ARGS="$PIGLIT_ARGS -x xloadqueryfont@1"
PIGLIT_ARGS="$PIGLIT_ARGS -x xqueryfont@1"
PIGLIT_ARGS="$PIGLIT_ARGS -x xqueryfont@2"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2"
# Run as meson unit tests.
PIGLIT_ARGS="$PIGLIT_ARGS -x rendercheck"
diff --git a/test/scripts/xwayland-piglit.sh b/test/scripts/xwayland-piglit.sh
index a898008eb..9d6e54d01 100755
--- a/test/scripts/xwayland-piglit.sh
+++ b/test/scripts/xwayland-piglit.sh
@@ -1,4 +1,16 @@
-#!/bin/sh -e
+#!/bin/bash -e
+
+if test "x$XTEST_DIR" = "x"; then
+ echo "XTEST_DIR must be set to the directory of the xtest repository."
+ # Exit as a "skip" so make check works even without xtest.
+ exit 77
+fi
+
+if test "x$PIGLIT_DIR" = "x"; then
+ echo "PIGLIT_DIR must be set to the directory of the piglit repository."
+ # Exit as a "skip" so make check works even without piglit.
+ exit 77
+fi
# this times out on Travis, because the tests take too long.
if test "x$TRAVIS_BUILD_DIR" != "x"; then
@@ -17,8 +29,17 @@ weston --no-config --backend=headless-backend.so --socket=wayland-$$ &
WESTON_PID=$!
export WAYLAND_DISPLAY=wayland-$$
+# Need to kill weston before exiting, or meson will time out waiting for it to terminate
+# We rely on bash's behaviour, which executes the EXIT trap handler even if the shell is
+# terminated due to receiving a signal
+trap 'kill $WESTON_PID' EXIT
+
# Wait for weston to initialize before starting Xwayland
-timeout --preserve-status 60s bash -c 'while ! weston-info &>/dev/null; do sleep 1; done'
+if ! timeout 5s bash -c "while ! $XSERVER_BUILDDIR/hw/xwayland/Xwayland -pogo -displayfd 1 &>/dev/null; do sleep 1; done"; then
+ # Try running Xwayland one more time, so we can propagate its stdout/stderr
+ # output and exit status
+ $XSERVER_BUILDDIR/hw/xwayland/Xwayland -pogo -displayfd 1
+fi
# Start an Xwayland server
export PIGLIT_RESULTS_DIR=$XSERVER_BUILDDIR/test/piglit-results/xwayland
@@ -33,13 +54,9 @@ PIGLIT_ARGS="$PIGLIT_ARGS -x xcleararea@7"
PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@4"
PIGLIT_ARGS="$PIGLIT_ARGS -x xclearwindow@5"
PIGLIT_ARGS="$PIGLIT_ARGS -x xcopyarea@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@1"
+PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2"
export PIGLIT_ARGS
-# Do not let run-piglit.sh exit status terminate this script prematurely
-set +e
$XSERVER_DIR/test/scripts/run-piglit.sh
-PIGLIT_STATUS=$?
-
-kill $WESTON_PID
-exit $PIGLIT_STATUS
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 4ba8485fc..22966ed4c 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -30,6 +30,9 @@
#include <stdint.h>
#include <unistd.h>
+
+#include "os/fmt.h"
+
#include "assert.h"
#include "misc.h"
@@ -148,6 +151,8 @@ number_formatting(void)
-0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
} ;
+ LogSetParameter(XLOG_VERBOSITY, -1);
+
for (i = 0; i < ARRAY_SIZE(unsigned_tests); i++)
assert(check_number_format_test(unsigned_tests[i]));
@@ -176,13 +181,18 @@ static void logging_format(void)
char read_buf[2048];
char *logmsg;
uintptr_t ptr;
+ char *fname = NULL;
+
+ LogSetParameter(XLOG_VERBOSITY, -1);
/* set up buf to contain ".....end" */
memset(buf, '.', sizeof(buf));
strcpy(&buf[sizeof(buf) - 4], "end");
- LogInit(log_file_path, NULL);
+ fname = (char*)LogInit(log_file_path, NULL);
+ assert(fname != NULL);
assert((f = fopen(log_file_path, "r")));
+ free(fname);
#define read_log_msg(msg) do { \
msg = fgets(read_buf, sizeof(read_buf), f); \
@@ -194,59 +204,59 @@ static void logging_format(void)
} while (0)
/* boring test message */
- LogMessageVerbSigSafe(X_ERROR, -1, "test message\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "test message\n");
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test message\n") == 0);
/* long buf is truncated to "....en\n" */
- LogMessageVerbSigSafe(X_ERROR, -1, buf);
+ LogMessageVerbSigSafe(X_ERROR, 1, buf);
read_log_msg(logmsg);
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
/* same thing, this time as string substitution */
- LogMessageVerbSigSafe(X_ERROR, -1, "%s", buf);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%s", buf);
read_log_msg(logmsg);
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
/* strings containing placeholders should just work */
- LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", str);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%s\n", str);
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
/* literal % */
- LogMessageVerbSigSafe(X_ERROR, -1, "test %%\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "test %%\n");
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test %\n") == 0);
/* character */
- LogMessageVerbSigSafe(X_ERROR, -1, "test %c\n", 'a');
+ LogMessageVerbSigSafe(X_ERROR, 1, "test %c\n", 'a');
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test a\n") == 0);
/* something unsupported % */
- LogMessageVerbSigSafe(X_ERROR, -1, "test %Q\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "test %Q\n");
read_log_msg(logmsg);
assert(strstr(logmsg, "BUG") != NULL);
- LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "\n");
fseek(f, 0, SEEK_END);
/* string substitution */
- LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
+ LogMessageVerbSigSafe(X_ERROR, 1, "%s\n", "substituted string");
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) substituted string\n") == 0);
/* Invalid format */
- LogMessageVerbSigSafe(X_ERROR, -1, "%4", 4);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%4", 4);
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) ") == 0);
- LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "\n");
fseek(f, 0, SEEK_END);
/* %hld is bogus */
- LogMessageVerbSigSafe(X_ERROR, -1, "%hld\n", 4);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%hld\n", 4);
read_log_msg(logmsg);
assert(strstr(logmsg, "BUG") != NULL);
- LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "\n");
fseek(f, 0, SEEK_END);
/* number substitution */
@@ -254,12 +264,12 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %u\n", ui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%u\n", ui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%u\n", ui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %x\n", ui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%x\n", ui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%x\n", ui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
@@ -273,22 +283,21 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %lu\n", lui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%lu\n", lui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%lu\n", lui);
read_log_msg(logmsg);
sprintf(expected, "(EE) %lld\n", (unsigned long long)ui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (unsigned long long)ui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%lld\n", (unsigned long long)ui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %lx\n", lui);
- printf("%s\n", expected);
- LogMessageVerbSigSafe(X_ERROR, -1, "%lx\n", lui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%lx\n", lui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %llx\n", (unsigned long long)ui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%llx\n", (unsigned long long)ui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%llx\n", (unsigned long long)ui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
@@ -303,12 +312,12 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %d\n", i);
- LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%d\n", i);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %d\n", i | INT_MIN);
- LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i | INT_MIN);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%d\n", i | INT_MIN);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
@@ -322,22 +331,22 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %ld\n", li);
- LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%ld\n", li);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %ld\n", li | LONG_MIN);
- LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li | LONG_MIN);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%ld\n", li | LONG_MIN);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %lld\n", (long long)li);
- LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)li);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%lld\n", (long long)li);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %lld\n", (long long)(li | LONG_MIN));
- LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)(li | LONG_MIN));
+ LogMessageVerbSigSafe(X_ERROR, 1, "%lld\n", (long long)(li | LONG_MIN));
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
@@ -350,7 +359,7 @@ static void logging_format(void)
/* pointer substitution */
/* we print a null-pointer differently to printf */
- LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", NULL);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%p\n", NULL);
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) 0x0\n") == 0);
@@ -362,7 +371,7 @@ static void logging_format(void)
#else
sprintf(expected, "(EE) %p\n", (void*)ptr);
#endif
- LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", (void*)ptr);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%p\n", (void*)ptr);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
ptr <<= 1;
@@ -373,20 +382,20 @@ static void logging_format(void)
double d = float_tests[i];
char expected[30];
sprintf(expected, "(EE) %.2f\n", d);
- LogMessageVerbSigSafe(X_ERROR, -1, "%f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
/* test for length modifiers, we just ignore them atm */
- LogMessageVerbSigSafe(X_ERROR, -1, "%.3f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%.3f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
- LogMessageVerbSigSafe(X_ERROR, -1, "%3f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%3f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
- LogMessageVerbSigSafe(X_ERROR, -1, "%.0f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%.0f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
}
@@ -399,11 +408,13 @@ static void logging_format(void)
}
#pragma GCC diagnostic pop /* "-Wformat-security" */
-int
+const testfunc_t*
signal_logging_test(void)
{
- number_formatting();
- logging_format();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ number_formatting,
+ logging_format,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/simple-xinit.c b/test/simple-xinit.c
index e85b48092..57e7eed57 100644
--- a/test/simple-xinit.c
+++ b/test/simple-xinit.c
@@ -25,6 +25,8 @@
#include <dix-config.h>
#endif
+#include <X11/Xfuncproto.h>
+
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
@@ -53,7 +55,7 @@ kill_server(int server_pid)
}
}
-static void
+_X_NORETURN static void
usage(int argc, char **argv)
{
fprintf(stderr, "%s <client command> -- <server command>\n", argv[0]);
diff --git a/test/string.c b/test/string.c
index 3feb88260..6fa4882d9 100644
--- a/test/string.c
+++ b/test/string.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -65,10 +65,13 @@ strndup_checks(void)
free(allofit);
}
-int
+const testfunc_t*
string_test(void)
{
- strndup_checks();
+ static const testfunc_t testfuncs[] = {
+ strndup_checks,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/test_xkb.c b/test/test_xkb.c
index f81a7ed65..303bbec53 100644
--- a/test/test_xkb.c
+++ b/test/test_xkb.c
@@ -43,12 +43,10 @@
#include "inputstr.h"
#include "opaque.h"
#include "property.h"
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "../xkb/xkbgeom.h"
#include <X11/extensions/XKMformat.h>
#include "xkbfile.h"
-#include "../xkb/xkb.h"
#include <assert.h>
#include "tests-common.h"
@@ -76,6 +74,8 @@ xkb_get_rules_test(void)
assert(strcmp(rmlvo.layout, XKB_DFLT_LAYOUT) == 0);
assert(strcmp(rmlvo.variant, XKB_DFLT_VARIANT) == 0);
assert(strcmp(rmlvo.options, XKB_DFLT_OPTIONS) == 0);
+
+ XkbFreeRMLVOSet(&rmlvo, FALSE);
}
/**
@@ -115,6 +115,7 @@ xkb_set_rules_test(void)
assert(strcmp(rmlvo.options, rmlvo_new.options) == 0);
XkbFreeRMLVOSet(&rmlvo, FALSE);
+ XkbFreeRMLVOSet(&rmlvo_new, FALSE);
}
/**
@@ -140,6 +141,7 @@ xkb_set_get_rules_test(void)
/* pass 1 */
XkbSetRulesDflts(&rmlvo);
+ XkbFreeRMLVOSet(&rmlvo, FALSE);
XkbGetRulesDflts(&rmlvo);
/* Make a backup copy */
@@ -160,20 +162,26 @@ xkb_set_get_rules_test(void)
assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
+ XkbFreeRMLVOSet(&rmlvo, FALSE);
XkbGetRulesDflts(&rmlvo);
assert(strcmp(rmlvo.rules, rmlvo_backup.rules) == 0);
assert(strcmp(rmlvo.model, rmlvo_backup.model) == 0);
assert(strcmp(rmlvo.layout, rmlvo_backup.layout) == 0);
assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
+
+ XkbFreeRMLVOSet(&rmlvo, FALSE);
+ XkbFreeRMLVOSet(&rmlvo_backup, FALSE);
}
-int
+const testfunc_t*
xkb_test(void)
{
- xkb_set_get_rules_test();
- xkb_get_rules_test();
- xkb_set_rules_test();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ xkb_set_get_rules_test,
+ xkb_get_rules_test,
+ xkb_set_rules_test,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/tests-common.c b/test/tests-common.c
index 686852827..dad07412b 100644
--- a/test/tests-common.c
+++ b/test/tests-common.c
@@ -7,27 +7,34 @@
#include "tests-common.h"
void
-run_test_in_child(int (*func)(void), const char *funcname)
+run_test_in_child(const testfunc_t* (*suite)(void), const char *funcname)
{
int cpid;
int csts;
int exit_code = -1;
+ const testfunc_t *func = suite();
printf("\n---------------------\n%s...\n", funcname);
- cpid = fork();
- if (cpid) {
- waitpid(cpid, &csts, 0);
- if (!WIFEXITED(csts))
- goto child_failed;
- exit_code = WEXITSTATUS(csts);
- if (exit_code == 0)
- printf(" Pass\n");
- else {
-child_failed:
- printf(" FAIL\n");
- exit(exit_code);
+
+ while (*func)
+ {
+ cpid = fork();
+ if (cpid) {
+ waitpid(cpid, &csts, 0);
+ if (!WIFEXITED(csts))
+ goto child_failed;
+ exit_code = WEXITSTATUS(csts);
+ if (exit_code != 0) {
+ child_failed:
+ printf(" FAIL\n");
+ exit(exit_code);
+ }
+ } else {
+ testfunc_t f = *func;
+ f();
+ exit(0);
}
- } else {
- exit(func());
+ func++;
}
+ printf(" Pass\n");
}
diff --git a/test/tests-common.h b/test/tests-common.h
index ea0642247..c3bcf26a2 100644
--- a/test/tests-common.h
+++ b/test/tests-common.h
@@ -3,10 +3,11 @@
#include "tests.h"
+
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
#define run_test(func) run_test_in_child(func, #func)
-void run_test_in_child(int (*func)(void), const char *funcname);
+void run_test_in_child(const testfunc_t* (*func)(void), const char *funcname);
#endif /* TESTS_COMMON_H */
diff --git a/test/tests.c b/test/tests.c
index 97603822a..4ef0036a3 100644
--- a/test/tests.c
+++ b/test/tests.c
@@ -2,6 +2,8 @@
#include "tests.h"
#include "tests-common.h"
+int verbose = 0;
+
int
main(int argc, char **argv)
{
diff --git a/test/tests.h b/test/tests.h
index b96ca78bb..d04d6ea63 100644
--- a/test/tests.h
+++ b/test/tests.h
@@ -1,38 +1,51 @@
#ifndef TESTS_H
#define TESTS_H
-int fixes_test(void);
-int hashtabletest_test(void);
-int input_test(void);
-int list_test(void);
-int misc_test(void);
-int signal_logging_test(void);
-int string_test(void);
-int touch_test(void);
-int xfree86_test(void);
-int xkb_test(void);
-int xtest_test(void);
-
-int protocol_xchangedevicecontrol_test(void);
-
-int protocol_xiqueryversion_test(void);
-int protocol_xiquerydevice_test(void);
-int protocol_xiselectevents_test(void);
-int protocol_xigetselectedevents_test(void);
-int protocol_xisetclientpointer_test(void);
-int protocol_xigetclientpointer_test(void);
-int protocol_xipassivegrabdevice_test(void);
-int protocol_xiquerypointer_test(void);
-int protocol_xiwarppointer_test(void);
-int protocol_eventconvert_test(void);
-int xi2_test(void);
-
-#ifndef INSIDE_PROTOCOL_COMMON
-
-extern int enable_XISetEventMask_wrap;
-extern int enable_GrabButton_wrap;
-
-#endif /* INSIDE_PROTOCOL_COMMON */
+extern int verbose;
+#define dbg(...) if (verbose) printf("DBG" __VA_ARGS__);
+
+#define DECLARE_WRAP_FUNCTION(f_, rval_, ...) \
+ extern rval_ (*wrapped_ ## f_)(__VA_ARGS__) \
+
+#define IMPLEMENT_WRAP_FUNCTION(f_, ...) \
+ if (wrapped_ ## f_) wrapped_ ## f_(__VA_ARGS__); \
+ else __real_ ## f_(__VA_ARGS__)
+
+#define IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(f_, ...) \
+ if (wrapped_ ## f_) return wrapped_ ## f_(__VA_ARGS__); \
+ else return __real_ ## f_(__VA_ARGS__)
+
+#define WRAP_FUNCTION(f_, rval_, ...) \
+ rval_ (*wrapped_ ## f_)(__VA_ARGS__); \
+ extern rval_ __real_ ## f_(__VA_ARGS__); \
+ rval_ __wrap_ ## f_(__VA_ARGS__); \
+ rval_ __wrap_ ## f_(__VA_ARGS__)
+
+typedef void (*testfunc_t)(void);
+
+const testfunc_t* fixes_test(void);
+const testfunc_t* hashtabletest_test(void);
+const testfunc_t* input_test(void);
+const testfunc_t* list_test(void);
+const testfunc_t* misc_test(void);
+const testfunc_t* signal_logging_test(void);
+const testfunc_t* string_test(void);
+const testfunc_t* touch_test(void);
+const testfunc_t* xfree86_test(void);
+const testfunc_t* xkb_test(void);
+const testfunc_t* xtest_test(void);
+const testfunc_t* protocol_xchangedevicecontrol_test(void);
+const testfunc_t* protocol_xiqueryversion_test(void);
+const testfunc_t* protocol_xiquerydevice_test(void);
+const testfunc_t* protocol_xiselectevents_test(void);
+const testfunc_t* protocol_xigetselectedevents_test(void);
+const testfunc_t* protocol_xisetclientpointer_test(void);
+const testfunc_t* protocol_xigetclientpointer_test(void);
+const testfunc_t* protocol_xipassivegrabdevice_test(void);
+const testfunc_t* protocol_xiquerypointer_test(void);
+const testfunc_t* protocol_xiwarppointer_test(void);
+const testfunc_t* protocol_eventconvert_test(void);
+const testfunc_t* xi2_test(void);
#endif /* TESTS_H */
diff --git a/test/touch.c b/test/touch.c
index 7b22ceddb..e4d14f63d 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -36,26 +36,45 @@
#include "tests-common.h"
static void
+free_device(DeviceIntPtr dev)
+{
+ free(dev->name);
+ free(dev->last.scroll); /* sigh, allocated but not freed by the valuator functions */
+ for (int i = 0; i < dev->last.num_touches; i++)
+ valuator_mask_free(&dev->last.touches[i].valuators);
+
+ free(dev->last.touches); /* sigh, allocated but not freed by the valuator functions */
+ FreeDeviceClass(XIValuatorClass, (void**)&dev->valuator);
+ FreeDeviceClass(XITouchClass, (void**)&dev->touch);
+}
+
+static void
touch_grow_queue(void)
{
DeviceIntRec dev;
- ValuatorClassRec val;
- TouchClassRec touch;
+ SpriteInfoRec sprite;
size_t size, new_size;
int i;
+ ScreenRec screen;
+ Atom labels[2] = { 0 };
+
+ screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev));
+ dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */
dev.name = xnfstrdup("test device");
dev.id = 2;
- dev.valuator = &val;
- val.numAxes = 5;
- dev.touch = &touch;
+
+ InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+ InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+ memset(&sprite, 0, sizeof(sprite));
+ dev.spriteInfo = &sprite;
+
inputInfo.devices = &dev;
size = 5;
- dev.last.num_touches = size;
- dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches));
assert(dev.last.touches);
for (i = 0; i < size; i++) {
dev.last.touches[i].active = TRUE;
@@ -91,27 +110,33 @@ touch_grow_queue(void)
assert(t->ddx_id == 0);
}
- free(dev.name);
+ free_device(&dev);
}
static void
touch_find_ddxid(void)
{
DeviceIntRec dev;
+ SpriteInfoRec sprite;
DDXTouchPointInfoPtr ti, ti2;
- ValuatorClassRec val;
- TouchClassRec touch;
int size = 5;
int i;
+ Atom labels[2] = { 0 };
+ ScreenRec screen;
+
+ screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev));
+ dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */
dev.name = xnfstrdup("test device");
dev.id = 2;
- dev.valuator = &val;
- val.numAxes = 5;
- dev.touch = &touch;
- dev.last.num_touches = size;
- dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches));
+
+ InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+ InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+ memset(&sprite, 0, sizeof(sprite));
+ dev.spriteInfo = &sprite;
+
inputInfo.devices = &dev;
assert(dev.last.touches);
@@ -159,32 +184,35 @@ touch_find_ddxid(void)
ti = TouchFindByDDXID(&dev, 40, TRUE);
assert(ti == &dev.last.touches[size+1]);
- free(dev.name);
+ free_device(&dev);
}
static void
touch_begin_ddxtouch(void)
{
DeviceIntRec dev;
+ SpriteInfoRec sprite;
DDXTouchPointInfoPtr ti;
- ValuatorClassRec val;
- TouchClassRec touch;
int ddx_id = 123;
unsigned int last_client_id = 0;
- int size = 5;
+ Atom labels[2] = { 0 };
+ ScreenRec screen;
+
+ screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev));
+ dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */
dev.name = xnfstrdup("test device");
dev.id = 2;
- dev.valuator = &val;
- val.numAxes = 5;
- touch.mode = XIDirectTouch;
- dev.touch = &touch;
- dev.last.num_touches = size;
- dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches));
inputInfo.devices = &dev;
- assert(dev.last.touches);
+ InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+ InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+ memset(&sprite, 0, sizeof(sprite));
+ dev.spriteInfo = &sprite;
+
+ assert(dev.last.touches);
ti = TouchBeginDDXTouch(&dev, ddx_id);
assert(ti);
assert(ti->ddx_id == ddx_id);
@@ -206,41 +234,36 @@ touch_begin_ddxtouch(void)
assert(!ti->emulate_pointer);
last_client_id = ti->client_id;
- free(dev.name);
+ free_device(&dev);
}
static void
touch_begin_touch(void)
{
DeviceIntRec dev;
- TouchClassRec touch;
- ValuatorClassRec val;
TouchPointInfoPtr ti;
int touchid = 12434;
int sourceid = 23;
SpriteInfoRec sprite;
ScreenRec screen;
+ Atom labels[2] = { 0 };
screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev));
+ dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */
dev.name = xnfstrdup("test device");
dev.id = 2;
- memset(&sprite, 0, sizeof(sprite));
- dev.spriteInfo = &sprite;
-
- memset(&touch, 0, sizeof(touch));
- touch.num_touches = 0;
-
- memset(&val, 0, sizeof(val));
- dev.valuator = &val;
- val.numAxes = 2;
-
ti = TouchBeginTouch(&dev, sourceid, touchid, TRUE);
assert(!ti);
- dev.touch = &touch;
+ InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+ InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+ memset(&sprite, 0, sizeof(sprite));
+ dev.spriteInfo = &sprite;
+
ti = TouchBeginTouch(&dev, sourceid, touchid, TRUE);
assert(ti);
assert(ti->client_id == touchid);
@@ -248,9 +271,9 @@ touch_begin_touch(void)
assert(ti->sourceid == sourceid);
assert(ti->emulate_pointer);
- assert(touch.num_touches == 1);
+ assert(dev.touch->num_touches == 5);
- free(dev.name);
+ free_device(&dev);
}
static void
@@ -265,6 +288,7 @@ touch_init(void)
screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev));
+ dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */
dev.name = xnfstrdup("test device");
memset(&sprite, 0, sizeof(sprite));
@@ -279,19 +303,19 @@ touch_init(void)
assert(rc == TRUE);
assert(dev.touch);
- free(dev.name);
+ free_device(&dev);
}
-int
+const testfunc_t*
touch_test(void)
{
- printf("touch_test: start...\n");
- touch_grow_queue();
- touch_find_ddxid();
- touch_begin_ddxtouch();
- touch_init();
- touch_begin_touch();
-
- printf("touch_test: exiting successfully\n");
- return 0;
+ static const testfunc_t testfuncs[] = {
+ touch_grow_queue,
+ touch_find_ddxid,
+ touch_begin_ddxtouch,
+ touch_init,
+ touch_begin_touch,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/xfree86.c b/test/xfree86.c
index 59e371633..7cbd37f40 100644
--- a/test/xfree86.c
+++ b/test/xfree86.c
@@ -63,17 +63,24 @@ xfree86_option_list_duplicate(void)
assert(strcmp(val1, v1) == 0);
assert(strcmp(val1, val2) == 0);
+ free(val1);
+ free(val2);
val1 = xf86CheckStrOption(options, o2, "1");
val2 = xf86CheckStrOption(duplicate, o2, "2");
assert(strcmp(val1, v2) == 0);
assert(strcmp(val1, val2) == 0);
+ free(val1);
+ free(val2);
a = xf86FindOption(options, o_null);
b = xf86FindOption(duplicate, o_null);
assert(a);
assert(b);
+
+ xf86OptionListFree(duplicate);
+ xf86OptionListFree(options);
}
static void
@@ -101,11 +108,13 @@ xfree86_add_comment(void)
free(current);
}
-int
+const testfunc_t*
xfree86_test(void)
{
- xfree86_option_list_duplicate();
- xfree86_add_comment();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ xfree86_option_list_duplicate,
+ xfree86_add_comment,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/xi1/protocol-xchangedevicecontrol.c b/test/xi1/protocol-xchangedevicecontrol.c
index e386d0c09..4c1a1740a 100644
--- a/test/xi1/protocol-xchangedevicecontrol.c
+++ b/test/xi1/protocol-xchangedevicecontrol.c
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -40,11 +40,13 @@
#include "protocol-common.h"
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
+
extern ClientRec client_window;
static ClientRec client_request;
static void
-reply_ChangeDeviceControl(ClientPtr client, int len, char *data, void *userdata)
+reply_ChangeDeviceControl(ClientPtr client, int len, void *data)
{
xChangeDeviceControlReply *rep = (xChangeDeviceControlReply *) data;
@@ -85,27 +87,29 @@ static unsigned char *data[4096]; /* the request buffer */
static void
test_ChangeDeviceControl(void)
{
+ init_simple();
+
xChangeDeviceControlReq *request = (xChangeDeviceControlReq *) data;
xDeviceCtl *control = (xDeviceCtl *) (&request[1]);
request_init(request, ChangeDeviceControl);
- reply_handler = reply_ChangeDeviceControl;
+ wrapped_WriteToClient = reply_ChangeDeviceControl;
client_request = init_client(request->length, request);
- printf("Testing invalid lengths:\n");
- printf(" -- no control struct\n");
+ dbg("Testing invalid lengths:\n");
+ dbg(" -- no control struct\n");
request_ChangeDeviceControl(&client_request, request, control, BadLength);
- printf(" -- xDeviceResolutionCtl\n");
+ dbg(" -- xDeviceResolutionCtl\n");
request_init(request, ChangeDeviceControl);
request->control = DEVICE_RESOLUTION;
control->length = (sizeof(xDeviceResolutionCtl) >> 2);
request->length += control->length - 2;
request_ChangeDeviceControl(&client_request, request, control, BadLength);
- printf(" -- xDeviceEnableCtl\n");
+ dbg(" -- xDeviceEnableCtl\n");
request_init(request, ChangeDeviceControl);
request->control = DEVICE_ENABLE;
control->length = (sizeof(xDeviceEnableCtl) >> 2);
@@ -115,12 +119,12 @@ test_ChangeDeviceControl(void)
/* XXX: Test functionality! */
}
-int
+const testfunc_t*
protocol_xchangedevicecontrol_test(void)
{
- init_simple();
-
- test_ChangeDeviceControl();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ test_ChangeDeviceControl,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index 69d7c14cb..f193bce45 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -30,6 +30,9 @@
#include <errno.h>
#include <stdint.h>
+
+#include "dix/dix_priv.h"
+
#include "extinit.h" /* for XInputExtensionInit */
#include "exglobals.h"
#include "xkbsrv.h" /* for XkbInitPrivates */
@@ -37,7 +40,6 @@
#include "syncsrv.h"
#include <X11/extensions/XI2.h>
-#define INSIDE_PROTOCOL_COMMON
#include "protocol-common.h"
struct devices devices;
@@ -46,13 +48,6 @@ WindowRec root;
WindowRec window;
static ClientRec server_client;
-void *global_userdata;
-
-void (*reply_handler) (ClientPtr client, int len, char *data, void *userdata);
-
-int enable_GrabButton_wrap = 1;
-int enable_XISetEventMask_wrap = 1;
-
static void
fake_init_sprite(DeviceIntPtr dev)
{
@@ -287,12 +282,31 @@ init_simple(void)
devices = init_devices();
}
-void
-__wrap_WriteToClient(ClientPtr client, int len, void *data)
+WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data)
+{
+ IMPLEMENT_WRAP_FUNCTION(WriteToClient, client, len, data);
+}
+
+WRAP_FUNCTION(XISetEventMask, int,
+ DeviceIntPtr dev, WindowPtr win, ClientPtr client,
+ int len, unsigned char *mask)
{
- assert(reply_handler != NULL);
+ IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(XISetEventMask, dev, win, client, len, mask);
+}
- (*reply_handler) (client, len, data, global_userdata);
+WRAP_FUNCTION(AddResource, Bool, XID id, RESTYPE type, void *value)
+{
+ IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(AddResource, id, type, value);
+}
+
+WRAP_FUNCTION(GrabButton, int,
+ ClientPtr client, DeviceIntPtr dev,
+ DeviceIntPtr modifier_device, int button,
+ GrabParameters *param, enum InputLevel grabtype,
+ GrabMask *mask)
+{
+ IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(GrabButton, client, dev, modifier_device,
+ button, param, grabtype, mask);
}
/* dixLookupWindow requires a lot of setup not necessary for this test.
@@ -300,8 +314,8 @@ __wrap_WriteToClient(ClientPtr client, int len, void *data)
* fake client window. If the requested ID is neither of those wanted,
* return whatever the real dixLookupWindow does.
*/
-int
-__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
+WRAP_FUNCTION(dixLookupWindow, int,
+ WindowPtr *win, XID id, ClientPtr client, Mask access)
{
if (id == root.drawable.id) {
*win = &root;
@@ -317,9 +331,8 @@ __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
extern ClientRec client_window;
-int
-__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
- Mask access)
+WRAP_FUNCTION(dixLookupClient, int,
+ ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
{
if (rid == ROOT_WINDOW_ID)
return BadWindow;
diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
index 742ce348f..c3485a432 100644
--- a/test/xi2/protocol-common.h
+++ b/test/xi2/protocol-common.h
@@ -91,17 +91,6 @@ struct devices {
extern struct devices devices;
/**
- * test-specific userdata, passed into the reply handler.
- */
-extern void *global_userdata;
-
-/**
- * The reply handler called from WriteToClient. Set this handler if you need
- * to check the reply values.
- */
-extern void (*reply_handler) (ClientPtr client, int len, char *data, void *userdata);
-
-/**
* The default screen used for the windows. Initialized by init_simple().
*/
extern ScreenRec screen;
@@ -142,16 +131,4 @@ void init_window(WindowPtr window, WindowPtr parent, int id);
*/
void init_simple(void);
-/* Declarations for various overrides in the test files. */
-void __wrap_WriteToClient(ClientPtr client, int len, void *data);
-int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
- int len, unsigned char *mask);
-int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
- Mask access);
-int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
- Mask access);
-Bool __wrap_AddResource(XID id, RESTYPE type, void *value);
-int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
-int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
-
#endif /* PROTOCOL_COMMON_H */
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index 0e0123708..fb0627bb5 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -29,9 +29,10 @@
#include <stdint.h>
+#include "dix/eventconvert.h"
+
#include "inputstr.h"
#include "eventstr.h"
-#include "eventconvert.h"
#include "exevents.h"
#include "inpututils.h"
#include <X11/extensions/XI2proto.h>
@@ -272,7 +273,7 @@ test_convert_XIRawEvent(void)
static void
test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent * out, BOOL swap)
{
- int buttons, valuators;
+ int valuators;
int i;
unsigned char *ptr;
uint32_t flagmask = 0;
@@ -346,11 +347,9 @@ test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent * out, BOOL swap)
assert(out->root_x == double_to_fp1616(in->root_x + in->root_x_frac));
assert(out->root_y == double_to_fp1616(in->root_y + in->root_y_frac));
- buttons = 0;
for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++) {
if (XIMaskIsSet(in->buttons, i)) {
assert(out->buttons_len >= bytes_to_int32(bits_to_bytes(i)));
- buttons++;
}
}
@@ -742,7 +741,7 @@ test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
flags & SCROLL_FLAG_PREFERRED);
}
default:
- printf("Invalid class type.\n\n");
+ dbg("Invalid class type.\n\n");
assert(1);
break;
}
@@ -1206,15 +1205,17 @@ test_convert_XIBarrierEvent(void)
test_XIBarrierEvent(&in);
}
-int
+const testfunc_t*
protocol_eventconvert_test(void)
{
- test_convert_XIRawEvent();
- test_convert_XIFocusEvent();
- test_convert_XIDeviceEvent();
- test_convert_XIDeviceChangedEvent();
- test_convert_XITouchOwnershipEvent();
- test_convert_XIBarrierEvent();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ test_convert_XIRawEvent,
+ test_convert_XIFocusEvent,
+ test_convert_XIDeviceEvent,
+ test_convert_XIDeviceChangedEvent,
+ test_convert_XITouchOwnershipEvent,
+ test_convert_XIBarrierEvent,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xigetclientpointer.c b/test/xi2/protocol-xigetclientpointer.c
index 40dacfc4d..6a066b022 100644
--- a/test/xi2/protocol-xigetclientpointer.c
+++ b/test/xi2/protocol-xigetclientpointer.c
@@ -43,6 +43,8 @@
#include "protocol-common.h"
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
+
static struct {
int cp_is_set;
DeviceIntPtr dev;
@@ -53,21 +55,24 @@ extern ClientRec client_window;
static ClientRec client_request;
static void
-reply_XIGetClientPointer(ClientPtr client, int len, char *data, void *userdata)
+reply_XIGetClientPointer(ClientPtr client, int len, void *data)
{
- xXIGetClientPointerReply *rep = (xXIGetClientPointerReply *) data;
+ xXIGetClientPointerReply *reply = (xXIGetClientPointerReply *) data;
+ xXIGetClientPointerReply rep = *reply; /* copy so swapping doesn't touch the real reply */
+
+ assert(len < 0xffff); /* suspicious size, swapping bug */
if (client->swapped) {
- swapl(&rep->length);
- swaps(&rep->sequenceNumber);
- swaps(&rep->deviceid);
+ swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swaps(&rep.deviceid);
}
- reply_check_defaults(rep, len, XIGetClientPointer);
+ reply_check_defaults(&rep, len, XIGetClientPointer);
- assert(rep->set == test_data.cp_is_set);
- if (rep->set)
- assert(rep->deviceid == test_data.dev->id);
+ assert(rep.set == test_data.cp_is_set);
+ if (rep.set)
+ assert(rep.deviceid == test_data.dev->id);
}
static void
@@ -100,34 +105,37 @@ test_XIGetClientPointer(void)
{
xXIGetClientPointerReq request;
+ init_simple();
+ client_window = init_client(0, NULL);
+
request_init(&request, XIGetClientPointer);
request.win = CLIENT_WINDOW_ID;
- reply_handler = reply_XIGetClientPointer;
+ wrapped_WriteToClient = reply_XIGetClientPointer;
client_request = init_client(request.length, &request);
- printf("Testing invalid window\n");
+ dbg("Testing invalid window\n");
request.win = INVALID_WINDOW_ID;
request_XIGetClientPointer(&client_request, &request, BadWindow);
- printf("Testing invalid length\n");
+ dbg("Testing invalid length\n");
client_request.req_len -= 4;
request_XIGetClientPointer(&client_request, &request, BadLength);
client_request.req_len += 4;
test_data.cp_is_set = FALSE;
- printf("Testing window None, unset ClientPointer.\n");
+ dbg("Testing window None, unset ClientPointer.\n");
request.win = None;
request_XIGetClientPointer(&client_request, &request, Success);
- printf("Testing valid window, unset ClientPointer.\n");
+ dbg("Testing valid window, unset ClientPointer.\n");
request.win = CLIENT_WINDOW_ID;
request_XIGetClientPointer(&client_request, &request, Success);
- printf("Testing valid window, set ClientPointer.\n");
+ dbg("Testing valid window, set ClientPointer.\n");
client_window.clientPtr = devices.vcp;
test_data.dev = devices.vcp;
test_data.cp_is_set = TRUE;
@@ -136,7 +144,7 @@ test_XIGetClientPointer(void)
client_window.clientPtr = NULL;
- printf("Testing window None, set ClientPointer.\n");
+ dbg("Testing window None, set ClientPointer.\n");
client_request.clientPtr = devices.vcp;
test_data.dev = devices.vcp;
test_data.cp_is_set = TRUE;
@@ -144,13 +152,13 @@ test_XIGetClientPointer(void)
request_XIGetClientPointer(&client_request, &request, Success);
}
-int
+const testfunc_t*
protocol_xigetclientpointer_test(void)
{
- init_simple();
- client_window = init_client(0, NULL);
-
- test_XIGetClientPointer();
+ static const testfunc_t testfuncs[] = {
+ test_XIGetClientPointer,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xigetselectedevents.c b/test/xi2/protocol-xigetselectedevents.c
index 0c7ef1675..2ea365d01 100644
--- a/test/xi2/protocol-xigetselectedevents.c
+++ b/test/xi2/protocol-xigetselectedevents.c
@@ -52,10 +52,11 @@
#include "protocol-common.h"
-static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data,
- void *userdata);
-static void reply_XIGetSelectedEvents_data(ClientPtr client, int len,
- char *data, void *userdata);
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
+DECLARE_WRAP_FUNCTION(AddResource, Bool, XID id, RESTYPE type, void *value);
+
+static void reply_XIGetSelectedEvents(ClientPtr client, int len, void *data);
+static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, void *data);
static struct {
int num_masks_expected;
@@ -66,38 +67,42 @@ static struct {
extern ClientRec client_window;
/* AddResource is called from XISetSEventMask, we don't need this */
-Bool
-__wrap_AddResource(XID id, RESTYPE type, void *value)
+static Bool
+override_AddResource(XID id, RESTYPE type, void *value)
{
return TRUE;
}
static void
-reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata)
+reply_XIGetSelectedEvents(ClientPtr client, int len, void *data)
{
- xXIGetSelectedEventsReply *rep = (xXIGetSelectedEventsReply *) data;
+ xXIGetSelectedEventsReply *reply = (xXIGetSelectedEventsReply *) data;
+ xXIGetSelectedEventsReply rep = *reply; /* copy so swapping doesn't touch the real reply */
+
+ assert(len < 0xffff); /* suspicious size, swapping bug */
if (client->swapped) {
- swapl(&rep->length);
- swaps(&rep->sequenceNumber);
- swaps(&rep->num_masks);
+ swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swaps(&rep.num_masks);
}
- reply_check_defaults(rep, len, XIGetSelectedEvents);
+ reply_check_defaults(&rep, len, XIGetSelectedEvents);
- assert(rep->num_masks == test_data.num_masks_expected);
+ assert(rep.num_masks == test_data.num_masks_expected);
- reply_handler = reply_XIGetSelectedEvents_data;
+ wrapped_WriteToClient = reply_XIGetSelectedEvents_data;
}
static void
-reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data,
- void *userdata)
+reply_XIGetSelectedEvents_data(ClientPtr client, int len, void *data)
{
int i;
xXIEventMask *mask;
unsigned char *bitmask;
+ assert(len < 0xffff); /* suspicious size, swapping bug */
+
mask = (xXIEventMask *) data;
for (i = 0; i < test_data.num_masks_expected; i++) {
if (client->swapped) {
@@ -127,12 +132,12 @@ request_XIGetSelectedEvents(xXIGetSelectedEventsReq * req, int error)
client = init_client(req->length, req);
- reply_handler = reply_XIGetSelectedEvents;
+ wrapped_WriteToClient = reply_XIGetSelectedEvents;
rc = ProcXIGetSelectedEvents(&client);
assert(rc == error);
- reply_handler = reply_XIGetSelectedEvents;
+ wrapped_WriteToClient = reply_XIGetSelectedEvents;
client.swapped = TRUE;
swapl(&req->win);
swaps(&req->length);
@@ -145,17 +150,22 @@ test_XIGetSelectedEvents(void)
{
int i, j;
xXIGetSelectedEventsReq request;
- ClientRec client = init_client(0, NULL);
+ ClientRec client;
unsigned char *mask;
DeviceIntRec dev;
+ wrapped_AddResource = override_AddResource;
+
+ init_simple();
+ client = init_client(0, NULL);
+
request_init(&request, XIGetSelectedEvents);
- printf("Testing for BadWindow on invalid window.\n");
+ dbg("Testing for BadWindow on invalid window.\n");
request.win = None;
request_XIGetSelectedEvents(&request, BadWindow);
- printf("Testing for zero-length (unset) masks.\n");
+ dbg("Testing for zero-length (unset) masks.\n");
/* No masks set yet */
test_data.num_masks_expected = 0;
request.win = ROOT_WINDOW_ID;
@@ -166,7 +176,7 @@ test_XIGetSelectedEvents(void)
memset(test_data.mask, 0, sizeof(test_data.mask));
- printf("Testing for valid masks\n");
+ dbg("Testing for valid masks\n");
memset(&dev, 0, sizeof(dev)); /* dev->id is enough for XISetEventMask */
request.win = ROOT_WINDOW_ID;
@@ -192,7 +202,7 @@ test_XIGetSelectedEvents(void)
}
}
- printf("Testing removing all masks\n");
+ dbg("Testing removing all masks\n");
/* Unset all masks one-by-one */
for (j = MAXDEVICES - 1; j >= 0; j--) {
if (j < devices.num_devices + 2)
@@ -208,14 +218,14 @@ test_XIGetSelectedEvents(void)
}
}
-int
+const testfunc_t*
protocol_xigetselectedevents_test(void)
{
- init_simple();
- enable_GrabButton_wrap = 0;
- enable_XISetEventMask_wrap = 0;
-
- test_XIGetSelectedEvents();
+ static const testfunc_t testfuncs[] = {
+ test_XIGetSelectedEvents,
+ NULL,
+ };
+ return testfuncs;
return 0;
}
diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
index 56645c63a..d7aaf23d4 100644
--- a/test/xi2/protocol-xipassivegrabdevice.c
+++ b/test/xi2/protocol-xipassivegrabdevice.c
@@ -44,6 +44,13 @@
#include "protocol-common.h"
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
+DECLARE_WRAP_FUNCTION(GrabButton, int,
+ ClientPtr client, DeviceIntPtr dev,
+ DeviceIntPtr modifier_device, int button,
+ GrabParameters *param, enum InputLevel grabtype,
+ GrabMask *mask);
+
extern ClientRec client_window;
static ClientRec client_request;
@@ -54,26 +61,16 @@ static struct test_data {
int num_modifiers;
} testdata;
-int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
- DeviceIntPtr modifier_device, int button,
- GrabParameters *param, enum InputLevel grabtype,
- GrabMask *mask);
-int __real_GrabButton(ClientPtr client, DeviceIntPtr dev,
- DeviceIntPtr modifier_device, int button,
- GrabParameters *param, enum InputLevel grabtype,
- GrabMask *mask);
+
static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len,
- char *data, void *closure);
+ void *data);
-int
-__wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
+static int
+override_GrabButton(ClientPtr client, DeviceIntPtr dev,
DeviceIntPtr modifier_device, int button,
GrabParameters *param, enum InputLevel grabtype,
GrabMask *mask)
{
- if (!enable_GrabButton_wrap)
- __real_GrabButton(client, dev, modifier_device, button, param, grabtype, mask);
-
/* Fail every odd modifier */
if (param->modifiers % 2)
return BadAccess;
@@ -82,34 +79,38 @@ __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
}
static void
-reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *closure)
+reply_XIPassiveGrabDevice(ClientPtr client, int len, void *data)
{
- xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply *) data;
+ xXIPassiveGrabDeviceReply *reply = (xXIPassiveGrabDeviceReply *) data;
+ xXIPassiveGrabDeviceReply rep = *reply; /* copy so swapping doesn't touch the real reply */
+
+ assert(len < 0xffff); /* suspicious size, swapping bug */
if (client->swapped) {
- swaps(&rep->sequenceNumber);
- swapl(&rep->length);
- swaps(&rep->num_modifiers);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swaps(&rep.num_modifiers);
- testdata.num_modifiers = rep->num_modifiers;
+ testdata.num_modifiers = rep.num_modifiers;
}
- reply_check_defaults(rep, len, XIPassiveGrabDevice);
+ reply_check_defaults(&rep, len, XIPassiveGrabDevice);
/* ProcXIPassiveGrabDevice sends the data in two batches, let the second
* handler handle the modifier data */
- if (rep->num_modifiers > 0)
- reply_handler = reply_XIPassiveGrabDevice_data;
+ if (rep.num_modifiers > 0)
+ wrapped_WriteToClient = reply_XIPassiveGrabDevice_data;
}
static void
-reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data,
- void *closure)
+reply_XIPassiveGrabDevice_data(ClientPtr client, int len, void *data)
{
int i;
xXIGrabModifierInfo *mods = (xXIGrabModifierInfo *) data;
+ assert(len < 0xffff); /* suspicious size, swapping bug */
+
for (i = 0; i < testdata.num_modifiers; i++, mods++) {
if (client->swapped)
swapl(&mods->modifiers);
@@ -124,7 +125,7 @@ reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data,
assert(mods->pad1 == 0);
}
- reply_handler = reply_XIPassiveGrabDevice;
+ wrapped_WriteToClient = reply_XIPassiveGrabDevice;
}
static void
@@ -175,19 +176,23 @@ test_XIPassiveGrabDevice(void)
xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq *) data;
unsigned char *mask;
+ wrapped_GrabButton = override_GrabButton;
+
+ init_simple();
+
request_init(request, XIPassiveGrabDevice);
request->grab_window = CLIENT_WINDOW_ID;
- reply_handler = reply_XIPassiveGrabDevice;
+ wrapped_WriteToClient = reply_XIPassiveGrabDevice;
client_request = init_client(request->length, request);
- printf("Testing invalid device\n");
+ dbg("Testing invalid device\n");
request->deviceid = 12;
request_XIPassiveGrabDevice(&client_request, request, BadDevice,
request->deviceid);
- printf("Testing invalid length\n");
+ dbg("Testing invalid length\n");
request->length -= 2;
request_XIPassiveGrabDevice(&client_request, request, BadLength,
client_request.errorValue);
@@ -196,14 +201,14 @@ test_XIPassiveGrabDevice(void)
request->grab_window = CLIENT_WINDOW_ID;
request->deviceid = XIAllMasterDevices;
- printf("Testing invalid grab types\n");
+ dbg("Testing invalid grab types\n");
for (i = XIGrabtypeGestureSwipeBegin + 1; i < 0xFF; i++) {
request->grab_type = i;
request_XIPassiveGrabDevice(&client_request, request, BadValue,
request->grab_type);
}
- printf("Testing invalid grab type + detail combinations\n");
+ dbg("Testing invalid grab type + detail combinations\n");
request->grab_type = XIGrabtypeEnter;
request->detail = 1;
request_XIPassiveGrabDevice(&client_request, request, BadValue,
@@ -215,7 +220,7 @@ test_XIPassiveGrabDevice(void)
request->detail = 0;
- printf("Testing invalid masks\n");
+ dbg("Testing invalid masks\n");
mask = (unsigned char *) &request[1];
request->mask_len = bytes_to_int32(XI2LASTEVENT + 1);
@@ -247,12 +252,13 @@ test_XIPassiveGrabDevice(void)
request_XIPassiveGrabDevice(&client_request, request, Success, 0);
}
-int
+const testfunc_t*
protocol_xipassivegrabdevice_test(void)
{
- init_simple();
-
- test_XIPassiveGrabDevice();
+ static const testfunc_t testfuncs[] = {
+ test_XIPassiveGrabDevice,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c
index 821ca4063..f0b03a19a 100644
--- a/test/xi2/protocol-xiquerydevice.c
+++ b/test/xi2/protocol-xiquerydevice.c
@@ -42,6 +42,8 @@
#include "xiquerydevice.h"
#include "protocol-common.h"
+
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
/*
* Protocol testing for XIQueryDevice request and reply.
*
@@ -52,56 +54,57 @@
* Repeatedly test with varying deviceids and check against data in reply.
*/
-struct test_data {
+static struct test_data {
int which_device;
int num_devices_in_reply;
-};
+} test_data;
extern ClientRec client_window;
-static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data,
- void *closure);
-static void reply_XIQueryDevice(ClientPtr client, int len, char *data,
- void *closure);
+static void reply_XIQueryDevice_data(ClientPtr client, int len, void *data);
/* reply handling for the first bytes that constitute the reply */
static void
-reply_XIQueryDevice(ClientPtr client, int len, char *data, void *userdata)
+reply_XIQueryDevice(ClientPtr client, int len, void *data)
{
- xXIQueryDeviceReply *rep = (xXIQueryDeviceReply *) data;
- struct test_data *querydata = (struct test_data *) userdata;
+ xXIQueryDeviceReply *reply = (xXIQueryDeviceReply *) data;
+ xXIQueryDeviceReply rep = *reply; /* copy so swapping doesn't touch the real reply */
+
+ assert(len < 0xffff); /* suspicious size, swapping bug */
if (client->swapped) {
- swapl(&rep->length);
- swaps(&rep->sequenceNumber);
- swaps(&rep->num_devices);
+ swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swaps(&rep.num_devices);
}
- reply_check_defaults(rep, len, XIQueryDevice);
+ reply_check_defaults(&rep, len, XIQueryDevice);
- if (querydata->which_device == XIAllDevices)
- assert(rep->num_devices == devices.num_devices);
- else if (querydata->which_device == XIAllMasterDevices)
- assert(rep->num_devices == devices.num_master_devices);
+ if (test_data.which_device == XIAllDevices)
+ assert(rep.num_devices == devices.num_devices);
+ else if (test_data.which_device == XIAllMasterDevices)
+ assert(rep.num_devices == devices.num_master_devices);
else
- assert(rep->num_devices == 1);
+ assert(rep.num_devices == 1);
+
+ test_data.num_devices_in_reply = rep.num_devices;
- querydata->num_devices_in_reply = rep->num_devices;
- reply_handler = reply_XIQueryDevice_data;
+ wrapped_WriteToClient = reply_XIQueryDevice_data;
}
/* reply handling for the trailing bytes that constitute the device info */
static void
-reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *closure)
+reply_XIQueryDevice_data(ClientPtr client, int len, void *data)
{
int i, j;
- struct test_data *querydata = (struct test_data *) closure;
DeviceIntPtr dev;
xXIDeviceInfo *info = (xXIDeviceInfo *) data;
xXIAnyInfo *any;
- for (i = 0; i < querydata->num_devices_in_reply; i++) {
+ assert(len < 0xffff); /* suspicious size, swapping bug */
+
+ for (i = 0; i < test_data.num_devices_in_reply; i++) {
if (client->swapped) {
swaps(&info->deviceid);
swaps(&info->attachment);
@@ -110,8 +113,8 @@ reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *closure)
swaps(&info->name_len);
}
- if (querydata->which_device > XIAllMasterDevices)
- assert(info->deviceid == querydata->which_device);
+ if (test_data.which_device > XIAllMasterDevices)
+ assert(info->deviceid == test_data.which_device);
assert(info->deviceid >= 2); /* 0 and 1 is reserved */
@@ -287,7 +290,7 @@ request_XIQueryDevice(struct test_data *querydata, int deviceid, int error)
request_init(&request, XIQueryDevice);
client = init_client(request.length, &request);
- reply_handler = reply_XIQueryDevice;
+ wrapped_WriteToClient = reply_XIQueryDevice;
querydata->which_device = deviceid;
@@ -298,7 +301,7 @@ request_XIQueryDevice(struct test_data *querydata, int deviceid, int error)
if (rc != Success)
assert(client.errorValue == deviceid);
- reply_handler = reply_XIQueryDevice;
+ wrapped_WriteToClient = reply_XIQueryDevice;
client.swapped = TRUE;
swaps(&request.length);
@@ -315,35 +318,33 @@ test_XIQueryDevice(void)
{
int i;
xXIQueryDeviceReq request;
- struct test_data data;
- reply_handler = reply_XIQueryDevice;
- global_userdata = &data;
+ init_simple();
+
+ wrapped_WriteToClient = reply_XIQueryDevice;
request_init(&request, XIQueryDevice);
- printf("Testing XIAllDevices.\n");
- request_XIQueryDevice(&data, XIAllDevices, Success);
- printf("Testing XIAllMasterDevices.\n");
- request_XIQueryDevice(&data, XIAllMasterDevices, Success);
+ dbg("Testing XIAllDevices.\n");
+ request_XIQueryDevice(&test_data, XIAllDevices, Success);
+ dbg("Testing XIAllMasterDevices.\n");
+ request_XIQueryDevice(&test_data, XIAllMasterDevices, Success);
- printf("Testing existing device ids.\n");
+ dbg("Testing existing device ids.\n");
for (i = 2; i < 6; i++)
- request_XIQueryDevice(&data, i, Success);
+ request_XIQueryDevice(&test_data, i, Success);
- printf("Testing non-existing device ids.\n");
+ dbg("Testing non-existing device ids.\n");
for (i = 6; i <= 0xFFFF; i++)
- request_XIQueryDevice(&data, i, BadDevice);
-
- reply_handler = NULL;
-
+ request_XIQueryDevice(&test_data, i, BadDevice);
}
-int
+const testfunc_t*
protocol_xiquerydevice_test(void)
{
- init_simple();
-
- test_XIQueryDevice();
+ static const testfunc_t testfuncs[] = {
+ test_XIQueryDevice,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c
index e04b0bad8..394fc7c00 100644
--- a/test/xi2/protocol-xiquerypointer.c
+++ b/test/xi2/protocol-xiquerypointer.c
@@ -44,10 +44,11 @@
#include "protocol-common.h"
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
+
extern ClientRec client_window;
static ClientRec client_request;
-static void reply_XIQueryPointer_data(ClientPtr client, int len,
- char *data, void *closure);
+static void reply_XIQueryPointer_data(ClientPtr client, int len, void *data);
static struct {
DeviceIntPtr dev;
@@ -55,39 +56,42 @@ static struct {
} test_data;
static void
-reply_XIQueryPointer(ClientPtr client, int len, char *data, void *closure)
+reply_XIQueryPointer(ClientPtr client, int len, void *data)
{
- xXIQueryPointerReply *rep = (xXIQueryPointerReply *) data;
+ xXIQueryPointerReply *reply = (xXIQueryPointerReply *) data;
+ xXIQueryPointerReply rep = *reply; /* copy so swapping doesn't touch the real reply */
SpritePtr sprite;
- if (!rep->repType)
+ assert(len < 0xffff); /* suspicious size, swapping bug */
+
+ if (!rep.repType)
return;
if (client->swapped) {
- swapl(&rep->length);
- swaps(&rep->sequenceNumber);
- swapl(&rep->root);
- swapl(&rep->child);
- swapl(&rep->root_x);
- swapl(&rep->root_y);
- swapl(&rep->win_x);
- swapl(&rep->win_y);
- swaps(&rep->buttons_len);
+ swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.root);
+ swapl(&rep.child);
+ swapl(&rep.root_x);
+ swapl(&rep.root_y);
+ swapl(&rep.win_x);
+ swapl(&rep.win_y);
+ swaps(&rep.buttons_len);
}
- reply_check_defaults(rep, len, XIQueryPointer);
+ reply_check_defaults(&rep, len, XIQueryPointer);
- assert(rep->root == root.drawable.id);
- assert(rep->same_screen == xTrue);
+ assert(rep.root == root.drawable.id);
+ assert(rep.same_screen == xTrue);
sprite = test_data.dev->spriteInfo->sprite;
- assert((rep->root_x >> 16) == sprite->hot.x);
- assert((rep->root_y >> 16) == sprite->hot.y);
+ assert((rep.root_x >> 16) == sprite->hot.x);
+ assert((rep.root_y >> 16) == sprite->hot.y);
if (test_data.win == &root) {
- assert(rep->root_x == rep->win_x);
- assert(rep->root_y == rep->win_y);
- assert(rep->child == window.drawable.id);
+ assert(rep.root_x == rep.win_x);
+ assert(rep.root_y == rep.win_y);
+ assert(rep.child == window.drawable.id);
}
else {
int x, y;
@@ -95,20 +99,22 @@ reply_XIQueryPointer(ClientPtr client, int len, char *data, void *closure)
x = sprite->hot.x - window.drawable.x;
y = sprite->hot.y - window.drawable.y;
- assert((rep->win_x >> 16) == x);
- assert((rep->win_y >> 16) == y);
- assert(rep->child == None);
+ assert((rep.win_x >> 16) == x);
+ assert((rep.win_y >> 16) == y);
+ assert(rep.child == None);
}
- assert(rep->same_screen == xTrue);
+ assert(rep.same_screen == xTrue);
- reply_handler = reply_XIQueryPointer_data;
+ wrapped_WriteToClient = reply_XIQueryPointer_data;
}
static void
-reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *closure)
+reply_XIQueryPointer_data(ClientPtr client, int len, void *data)
{
- reply_handler = reply_XIQueryPointer;
+ wrapped_WriteToClient = reply_XIQueryPointer;
+
+ assert(len < 0xffff); /* suspicious size, swapping bug */
}
static void
@@ -139,11 +145,13 @@ test_XIQueryPointer(void)
int i;
xXIQueryPointerReq request;
+ init_simple();
+
memset(&request, 0, sizeof(request));
request_init(&request, XIQueryPointer);
- reply_handler = reply_XIQueryPointer;
+ wrapped_WriteToClient = reply_XIQueryPointer;
client_request = init_client(request.length, &request);
@@ -192,12 +200,12 @@ test_XIQueryPointer(void)
request_XIQueryPointer(&client_request, &request, BadLength);
}
-int
+const testfunc_t*
protocol_xiquerypointer_test(void)
{
- init_simple();
-
- test_XIQueryPointer();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ test_XIQueryPointer,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
index 89df18431..521703c5a 100644
--- a/test/xi2/protocol-xiqueryversion.c
+++ b/test/xi2/protocol-xiqueryversion.c
@@ -50,56 +50,62 @@
#include "protocol-common.h"
#include "exglobals.h"
+DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
+
extern XExtensionVersion XIVersion;
-struct test_data {
+static struct test_data {
int major_client;
int minor_client;
int major_server;
int minor_server;
int major_expected;
int minor_expected;
-};
+} versions;
+
extern ClientRec client_window;
static void
-reply_XIQueryVersion(ClientPtr client, int len, char *data, void *closure)
+reply_XIQueryVersion(ClientPtr client, int len, void *data)
{
- xXIQueryVersionReply *rep = (xXIQueryVersionReply *) data;
- struct test_data *versions = (struct test_data *) closure;
+ xXIQueryVersionReply *reply = (xXIQueryVersionReply *) data;
+ xXIQueryVersionReply rep = *reply; /* copy so swapping doesn't touch the real reply */
+
unsigned int sver, cver, ver;
+ assert(len < 0xffff); /* suspicious size, swapping bug */
+
if (client->swapped) {
- swapl(&rep->length);
- swaps(&rep->sequenceNumber);
- swaps(&rep->major_version);
- swaps(&rep->minor_version);
+ swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swaps(&rep.major_version);
+ swaps(&rep.minor_version);
}
- reply_check_defaults(rep, len, XIQueryVersion);
+ reply_check_defaults(&rep, len, XIQueryVersion);
- assert(rep->length == 0);
+ assert(rep.length == 0);
- sver = versions->major_server * 1000 + versions->minor_server;
- cver = versions->major_client * 1000 + versions->minor_client;
- ver = rep->major_version * 1000 + rep->minor_version;
+ sver = versions.major_server * 1000 + versions.minor_server;
+ cver = versions.major_client * 1000 + versions.minor_client;
+ ver = rep.major_version * 1000 + rep.minor_version;
assert(ver >= 2000);
assert((sver > cver) ? ver == cver : ver == sver);
}
static void
-reply_XIQueryVersion_multiple(ClientPtr client, int len, char *data, void *closure)
+reply_XIQueryVersion_multiple(ClientPtr client, int len, void *data)
{
- xXIQueryVersionReply *rep = (xXIQueryVersionReply *) data;
- struct test_data *versions = (struct test_data *) closure;
+ xXIQueryVersionReply *reply = (xXIQueryVersionReply *) data;
+ xXIQueryVersionReply rep = *reply; /* copy so swapping doesn't touch the real reply */
- reply_check_defaults(rep, len, XIQueryVersion);
- assert(rep->length == 0);
+ reply_check_defaults(&rep, len, XIQueryVersion);
+ assert(rep.length == 0);
- assert(versions->major_expected == rep->major_version);
- assert(versions->minor_expected == rep->minor_version);
+ assert(versions.major_expected == rep.major_version);
+ assert(versions.minor_expected == rep.minor_version);
}
/**
@@ -112,13 +118,11 @@ static void
request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error)
{
int rc;
- struct test_data versions;
xXIQueryVersionReq request;
ClientRec client;
request_init(&request, XIQueryVersion);
client = init_client(request.length, &request);
- global_userdata = (void *) &versions;
/* Change the server to support smaj.smin */
XIVersion.major_version = smaj;
@@ -151,25 +155,27 @@ request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error)
static void
test_XIQueryVersion(void)
{
- reply_handler = reply_XIQueryVersion;
+ init_simple();
+
+ wrapped_WriteToClient = reply_XIQueryVersion;
- printf("Server version 2.0 - client versions [1..3].0\n");
+ dbg("Server version 2.0 - client versions [1..3].0\n");
/* some simple tests to catch common errors quickly */
request_XIQueryVersion(2, 0, 1, 0, BadValue);
request_XIQueryVersion(2, 0, 2, 0, Success);
request_XIQueryVersion(2, 0, 3, 0, Success);
- printf("Server version 3.0 - client versions [1..3].0\n");
+ dbg("Server version 3.0 - client versions [1..3].0\n");
request_XIQueryVersion(3, 0, 1, 0, BadValue);
request_XIQueryVersion(3, 0, 2, 0, Success);
request_XIQueryVersion(3, 0, 3, 0, Success);
- printf("Server version 2.0 - client versions [1..3].[1..3]\n");
+ dbg("Server version 2.0 - client versions [1..3].[1..3]\n");
request_XIQueryVersion(2, 0, 1, 1, BadValue);
request_XIQueryVersion(2, 0, 2, 2, Success);
request_XIQueryVersion(2, 0, 3, 3, Success);
- printf("Server version 2.2 - client versions [1..3].0\n");
+ dbg("Server version 2.2 - client versions [1..3].0\n");
request_XIQueryVersion(2, 2, 1, 0, BadValue);
request_XIQueryVersion(2, 2, 2, 0, Success);
request_XIQueryVersion(2, 2, 3, 0, Success);
@@ -178,7 +184,7 @@ test_XIQueryVersion(void)
/* this one takes a while */
unsigned int cmin, cmaj, smin, smaj;
- printf("Testing all combinations.\n");
+ dbg("Testing all combinations.\n");
for (smaj = 2; smaj <= 0xFFFF; smaj++)
for (smin = 0; smin <= 0xFFFF; smin++)
for (cmin = 0; cmin <= 0xFFFF; cmin++)
@@ -189,8 +195,6 @@ test_XIQueryVersion(void)
}
#endif
-
- reply_handler = NULL;
}
@@ -200,9 +204,10 @@ test_XIQueryVersion_multiple(void)
xXIQueryVersionReq request;
ClientRec client;
XIClientPtr pXIClient;
- struct test_data versions;
int rc;
+ init_simple();
+
request_init(&request, XIQueryVersion);
client = init_client(request.length, &request);
@@ -210,8 +215,7 @@ test_XIQueryVersion_multiple(void)
XIVersion.major_version = 2;
XIVersion.minor_version = 2;
- reply_handler = reply_XIQueryVersion_multiple;
- global_userdata = (void *) &versions;
+ wrapped_WriteToClient = reply_XIQueryVersion_multiple;
/* run 1 */
@@ -290,13 +294,14 @@ test_XIQueryVersion_multiple(void)
assert(rc == BadValue);
}
-int
+const testfunc_t*
protocol_xiqueryversion_test(void)
{
- init_simple();
-
- test_XIQueryVersion();
- test_XIQueryVersion_multiple();
+ static const testfunc_t testfuncs[] = {
+ test_XIQueryVersion,
+ test_XIQueryVersion_multiple,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
index 0a4da5bc4..9389bd27e 100644
--- a/test/xi2/protocol-xiselectevents.c
+++ b/test/xi2/protocol-xiselectevents.c
@@ -63,21 +63,19 @@
#include "protocol-common.h"
+DECLARE_WRAP_FUNCTION(XISetEventMask, int, DeviceIntPtr dev,
+ WindowPtr win, ClientPtr client,
+ int len, unsigned char *mask);
+
+
static unsigned char *data[4096 * 20]; /* the request data buffer */
extern ClientRec client_window;
-int
-__real_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
- int len, unsigned char *mask);
-
-int
-__wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
- int len, unsigned char *mask)
+static int
+override_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
+ int len, unsigned char *mask)
{
- if (!enable_XISetEventMask_wrap)
- return __real_XISetEventMask(dev, win, client, len, mask);
-
return Success;
}
@@ -172,7 +170,7 @@ request_XISelectEvents_masks(xXISelectEventsReq * req)
req->win = ROOT_WINDOW_ID;
/* if a clients submits more than 100 masks, consider it insane and untested */
- for (i = 1; i <= 1000; i++) {
+ for (i = 1; i <= 1000; i += 33) {
req->num_masks = i;
mask->deviceid = XIAllDevices;
@@ -288,11 +286,15 @@ test_XISelectEvents(void)
xXIEventMask *mask;
xXISelectEventsReq *req;
+ wrapped_XISetEventMask = override_XISetEventMask;
+
+ init_simple();
+
req = (xXISelectEventsReq *) data;
request_init(req, XISelectEvents);
- printf("Testing for BadValue on zero-length masks\n");
+ dbg("Testing for BadValue on zero-length masks\n");
/* zero masks are BadValue, regardless of the window */
req->num_masks = 0;
@@ -305,7 +307,7 @@ test_XISelectEvents(void)
req->win = CLIENT_WINDOW_ID;
request_XISelectEvent(req, BadValue);
- printf("Testing for BadWindow.\n");
+ dbg("Testing for BadWindow.\n");
/* None window is BadWindow, regardless of the masks.
* We don't actually need to set the masks here, BadWindow must occur
* before checking the masks.
@@ -325,7 +327,7 @@ test_XISelectEvents(void)
req->num_masks = 0xFFFC;
request_XISelectEvent(req, BadWindow);
- printf("Triggering num_masks/length overflow\n");
+ dbg("Triggering num_masks/length overflow\n");
req->win = ROOT_WINDOW_ID;
/* Integer overflow - req->length can't hold that much */
req->num_masks = 0xFFFF;
@@ -334,14 +336,14 @@ test_XISelectEvents(void)
req->win = ROOT_WINDOW_ID;
req->num_masks = 1;
- printf("Triggering bogus mask length error\n");
+ dbg("Triggering bogus mask length error\n");
mask = (xXIEventMask *) &req[1];
mask->deviceid = 0;
mask->mask_len = 0xFFFF;
request_XISelectEvent(req, BadLength);
/* testing various device ids */
- printf("Testing existing device ids.\n");
+ dbg("Testing existing device ids.\n");
for (i = 0; i < 6; i++) {
mask = (xXIEventMask *) &req[1];
mask->deviceid = i;
@@ -351,7 +353,7 @@ test_XISelectEvents(void)
request_XISelectEvent(req, Success);
}
- printf("Testing non-existing device ids.\n");
+ dbg("Testing non-existing device ids.\n");
for (i = 6; i <= 0xFFFF; i++) {
req->win = ROOT_WINDOW_ID;
req->num_masks = 1;
@@ -364,12 +366,13 @@ test_XISelectEvents(void)
request_XISelectEvents_masks(req);
}
-int
+const testfunc_t*
protocol_xiselectevents_test(void)
{
- init_simple();
-
- test_XISelectEvents();
+ static const testfunc_t testfuncs[] = {
+ test_XISelectEvents,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c
index 0e94a91e2..881fcf3f1 100644
--- a/test/xi2/protocol-xisetclientpointer.c
+++ b/test/xi2/protocol-xisetclientpointer.c
@@ -85,18 +85,21 @@ test_XISetClientPointer(void)
int i;
xXISetClientPointerReq request;
+ init_simple();
+ client_window = init_client(0, NULL);
+
request_init(&request, XISetClientPointer);
request.win = CLIENT_WINDOW_ID;
- printf("Testing BadDevice error for XIAllDevices and XIMasterDevices.\n");
+ dbg("Testing BadDevice error for XIAllDevices and XIMasterDevices.\n");
request.deviceid = XIAllDevices;
request_XISetClientPointer(&request, BadDevice);
request.deviceid = XIAllMasterDevices;
request_XISetClientPointer(&request, BadDevice);
- printf("Testing Success for VCP and VCK.\n");
+ dbg("Testing Success for VCP and VCK.\n");
request.deviceid = devices.vcp->id; /* 2 */
request_XISetClientPointer(&request, Success);
assert(client_window.clientPtr->id == 2);
@@ -105,32 +108,32 @@ test_XISetClientPointer(void)
request_XISetClientPointer(&request, Success);
assert(client_window.clientPtr->id == 2);
- printf("Testing BadDevice error for all other devices.\n");
+ dbg("Testing BadDevice error for all other devices.\n");
for (i = 4; i <= 0xFFFF; i++) {
request.deviceid = i;
request_XISetClientPointer(&request, BadDevice);
}
- printf("Testing window None\n");
+ dbg("Testing window None\n");
request.win = None;
request.deviceid = devices.vcp->id; /* 2 */
request_XISetClientPointer(&request, Success);
assert(client_request.clientPtr->id == 2);
- printf("Testing invalid window\n");
+ dbg("Testing invalid window\n");
request.win = INVALID_WINDOW_ID;
request.deviceid = devices.vcp->id;
request_XISetClientPointer(&request, BadWindow);
}
-int
+const testfunc_t*
protocol_xisetclientpointer_test(void)
{
- init_simple();
- client_window = init_client(0, NULL);
-
- test_XISetClientPointer();
+ static const testfunc_t testfuncs[] = {
+ test_XISetClientPointer,
+ NULL,
+ };
- return 0;
+ return testfuncs;
}
diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c
index 1b6a2fca6..417d9adfc 100644
--- a/test/xi2/protocol-xiwarppointer.c
+++ b/test/xi2/protocol-xiwarppointer.c
@@ -106,6 +106,9 @@ test_XIWarpPointer(void)
ClientRec client_request;
xXIWarpPointerReq request;
+ init_simple();
+ screen.SetCursorPosition = ScreenSetCursorPosition;
+
memset(&request, 0, sizeof(request));
request_init(&request, XIWarpPointer);
@@ -188,13 +191,12 @@ test_XIWarpPointer(void)
request_XIWarpPointer(&client_request, &request, BadLength);
}
-int
+const testfunc_t*
protocol_xiwarppointer_test(void)
{
- init_simple();
- screen.SetCursorPosition = ScreenSetCursorPosition;
-
- test_XIWarpPointer();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ test_XIWarpPointer,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c
index 153cd759b..03022ebfa 100644
--- a/test/xi2/xi2.c
+++ b/test/xi2/xi2.c
@@ -139,10 +139,14 @@ xi2mask_test(void)
free(mask);
}
-int
+const testfunc_t*
xi2_test(void)
{
- xi2mask_test();
+ static const testfunc_t testfuncs[] = {
+ xi2mask_test,
+ NULL,
+ };
+ return testfuncs;
return 0;
}
diff --git a/test/xtest.c b/test/xtest.c
index 12433afc4..1d38f3d47 100644
--- a/test/xtest.c
+++ b/test/xtest.c
@@ -29,6 +29,9 @@
#endif
#include <stdint.h>
#include <X11/Xatom.h>
+
+#include "dix/dix_priv.h"
+
#include "input.h"
#include "inputstr.h"
#include "scrnintstr.h"
@@ -60,12 +63,12 @@ device_cursor_cleanup(DeviceIntPtr dev, ScreenPtr screen)
}
static void
-xtest_init_devices(void)
+xtest_init(void)
{
- ScreenRec screen = {0};
- ClientRec server_client = {0};
- WindowRec root = {{0}};
- WindowOptRec optional = {0};
+ static ScreenRec screen = {0};
+ static ClientRec server_client = {0};
+ static WindowRec root = {{0}};
+ static WindowOptRec optional = {0};
/* random stuff that needs initialization */
root.drawable.id = 0xab;
@@ -89,6 +92,18 @@ xtest_init_devices(void)
/* this also inits the xtest devices */
InitCoreDevices();
+}
+
+static void
+xtest_cleanup(void)
+{
+ CloseDownDevices();
+}
+
+static void
+xtest_init_devices(void)
+{
+ xtest_init();
assert(xtestpointer);
assert(xtestkeyboard);
@@ -100,6 +115,8 @@ xtest_init_devices(void)
assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
+
+ xtest_cleanup();
}
/**
@@ -112,8 +129,11 @@ xtest_properties(void)
int rc;
char value = 1;
XIPropertyValuePtr prop;
- Atom xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
+ Atom xtest_prop;
+
+ xtest_init();
+ xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop);
assert(rc == Success);
assert(prop);
@@ -130,13 +150,17 @@ xtest_properties(void)
XA_INTEGER, 8, PropModeReplace, 1, &value,
FALSE);
assert(rc == BadAccess);
+
+ xtest_cleanup();
}
-int
+const testfunc_t*
xtest_test(void)
{
- xtest_init_devices();
- xtest_properties();
-
- return 0;
+ static const testfunc_t testfuncs[] = {
+ xtest_init_devices,
+ xtest_properties,
+ NULL,
+ };
+ return testfuncs;
}
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index c5d4554b2..51c7b3010 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
* Copyright 2010 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -46,6 +46,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "xfixesint.h"
#include "scrnintstr.h"
#include "cursorstr.h"
@@ -72,7 +74,7 @@ static void deleteCursorHideCountsForScreen(ScreenPtr pScreen);
do { \
int err; \
err = dixLookupResourceByType((void **) &pCursor, cursor, \
- RT_CURSOR, client, access); \
+ X11_RESTYPE_CURSOR, client, access); \
if (err != Success) { \
client->errorValue = cursor; \
return err; \
@@ -371,8 +373,8 @@ ProcXFixesGetCursorImage(ClientPtr client)
pCursor = CursorForClient(client);
if (!pCursor)
return BadCursor;
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
- pCursor, RT_NONE, NULL, DixReadAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, X11_RESTYPE_CURSOR,
+ pCursor, X11_RESTYPE_NONE, NULL, DixReadAccess);
if (rc != Success)
return rc;
GetSpritePosition(PickPointer(client), &x, &y);
@@ -520,8 +522,8 @@ ProcXFixesGetCursorImageAndName(ClientPtr client)
pCursor = CursorForClient(client);
if (!pCursor)
return BadCursor;
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
- pCursor, RT_NONE, NULL, DixReadAccess | DixGetAttrAccess);
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, X11_RESTYPE_CURSOR,
+ pCursor, X11_RESTYPE_NONE, NULL, DixReadAccess | DixGetAttrAccess);
if (rc != Success)
return rc;
GetSpritePosition(PickPointer(client), &x, &y);
@@ -595,7 +597,9 @@ typedef struct {
} ReplaceCursorLookupRec, *ReplaceCursorLookupPtr;
static const RESTYPE CursorRestypes[] = {
- RT_WINDOW, RT_PASSIVEGRAB, RT_CURSOR
+ X11_RESTYPE_WINDOW,
+ X11_RESTYPE_PASSIVEGRAB,
+ X11_RESTYPE_CURSOR
};
static Bool
@@ -608,19 +612,19 @@ ReplaceCursorLookup(void *value, XID id, void *closure)
XID cursor = 0;
switch (rcl->type) {
- case RT_WINDOW:
+ case X11_RESTYPE_WINDOW:
pWin = (WindowPtr) value;
if (pWin->optional) {
pCursorRef = &pWin->optional->cursor;
pCursor = *pCursorRef;
}
break;
- case RT_PASSIVEGRAB:
+ case X11_RESTYPE_PASSIVEGRAB:
pGrab = (GrabPtr) value;
pCursorRef = &pGrab->cursor;
pCursor = *pCursorRef;
break;
- case RT_CURSOR:
+ case X11_RESTYPE_CURSOR:
pCursorRef = 0;
pCursor = (CursorPtr) value;
cursor = id;
@@ -633,7 +637,7 @@ ReplaceCursorLookup(void *value, XID id, void *closure)
if (pCursorRef)
*pCursorRef = curs;
else
- ChangeResourceValue(id, RT_CURSOR, curs);
+ ChangeResourceValue(id, X11_RESTYPE_CURSOR, curs);
FreeCursor(pCursor, cursor);
}
}
@@ -854,7 +858,7 @@ ProcXFixesHideCursor(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesHideCursorReq);
- ret = dixLookupResourceByType((void **) &pWin, stuff->window, RT_WINDOW,
+ ret = dixLookupResourceByType((void **) &pWin, stuff->window, X11_RESTYPE_WINDOW,
client, DixGetAttrAccess);
if (ret != Success) {
client->errorValue = stuff->window;
@@ -918,7 +922,7 @@ ProcXFixesShowCursor(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesShowCursorReq);
- rc = dixLookupResourceByType((void **) &pWin, stuff->window, RT_WINDOW,
+ rc = dixLookupResourceByType((void **) &pWin, stuff->window, X11_RESTYPE_WINDOW,
client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
diff --git a/xfixes/disconnect.c b/xfixes/disconnect.c
index 77932725e..e412942b1 100644
--- a/xfixes/disconnect.c
+++ b/xfixes/disconnect.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
* Copyright 2010 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -46,6 +46,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "xfixesint.h"
#include "opaque.h"
diff --git a/xfixes/region.c b/xfixes/region.c
index 7c0a7d2fe..4595f8f2d 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -24,9 +24,11 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+#include "render/picturestr_priv.h"
+
#include "xfixesint.h"
#include "scrnintstr.h"
-#include <picturestr.h>
#include <regionstr.h>
#include <gcstruct.h>
@@ -115,7 +117,7 @@ ProcXFixesCreateRegionFromBitmap(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
- rc = dixLookupResourceByType((void **) &pPixmap, stuff->bitmap, RT_PIXMAP,
+ rc = dixLookupResourceByType((void **) &pPixmap, stuff->bitmap, X11_RESTYPE_PIXMAP,
client, DixReadAccess);
if (rc != Success) {
client->errorValue = stuff->bitmap;
@@ -159,7 +161,7 @@ ProcXFixesCreateRegionFromWindow(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromWindowReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
- rc = dixLookupResourceByType((void **) &pWin, stuff->window, RT_WINDOW,
+ rc = dixLookupResourceByType((void **) &pWin, stuff->window, X11_RESTYPE_WINDOW,
client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
@@ -299,7 +301,7 @@ ProcXFixesDestroyRegion(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
- FreeResource(stuff->region, RT_NONE);
+ FreeResource(stuff->region, X11_RESTYPE_NONE);
return Success;
}
@@ -650,7 +652,7 @@ ProcXFixesSetWindowShapeRegion(ClientPtr client)
REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
- rc = dixLookupResourceByType((void **) &pWin, stuff->dest, RT_WINDOW,
+ rc = dixLookupResourceByType((void **) &pWin, stuff->dest, X11_RESTYPE_WINDOW,
client, DixSetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->dest;
diff --git a/xfixes/saveset.c b/xfixes/saveset.c
index fd9c7a124..981d15b86 100644
--- a/xfixes/saveset.c
+++ b/xfixes/saveset.c
@@ -24,6 +24,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "xfixesint.h"
int
diff --git a/xfixes/select.c b/xfixes/select.c
index 19b2c7324..ebdd77181 100644
--- a/xfixes/select.c
+++ b/xfixes/select.c
@@ -24,6 +24,8 @@
#include <dix-config.h>
#endif
+#include "dix/dix_priv.h"
+
#include "xfixesint.h"
#include "xace.h"
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index ecb6f298f..3d044f918 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
* Copyright 2010, 2021 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index cf9a8f9bd..a1dd6fe63 100644
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates.
* Copyright 2010, 2021 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index 3e380a8ea..fa4c86d44 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -34,7 +34,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "misc.h"
#include "inputstr.h"
#include <X11/keysym.h>
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
/***====================================================================***/
diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c
index 2bad695e0..0a3b5cbc7 100644
--- a/xkb/XKBMisc.c
+++ b/xkb/XKBMisc.c
@@ -34,7 +34,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "misc.h"
#include "inputstr.h"
#include <X11/keysym.h>
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
/***====================================================================***/
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index f9b7b06d9..18e0ec3be 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -31,19 +31,21 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <xkb-config.h>
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
#include <X11/X.h>
#include <X11/Xos.h>
#include <X11/Xproto.h>
#include <X11/keysym.h>
+#include <X11/extensions/XI.h>
#include <X11/extensions/XKM.h>
+
+#include "os/osdep.h"
+
#include "inputstr.h"
#include "scrnintstr.h"
#include "windowstr.h"
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
-#include <X11/extensions/XI.h>
-#include "xkb.h"
#define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\""
#define ERROR_PREFIX "\"> \""
@@ -70,9 +72,17 @@ OutputDirectory(char *outdir, size_t size)
/* Can we write an xkm and then open it too? */
if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 0) {
directory = XKM_OUTPUT_DIR;
- if (XKM_OUTPUT_DIR[strlen(XKM_OUTPUT_DIR) - 1] != '/')
- pathsep = "/";
+ } else {
+ const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
+
+ if (xdg_runtime_dir && xdg_runtime_dir[0] == '/' &&
+ access(xdg_runtime_dir, W_OK | X_OK) == 0)
+ directory = xdg_runtime_dir;
}
+
+ if (directory && directory[strlen(directory) - 1] != '/')
+ pathsep = "/";
+
#else
directory = Win32TempDir();
pathsep = "\\";
diff --git a/xkb/maprules.c b/xkb/maprules.c
index a096f2087..e071ab539 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -47,7 +47,6 @@
#include "dix.h"
#include "os.h"
#include "xkbstr.h"
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
/***====================================================================***/
diff --git a/xkb/xkb.h b/xkb/xkb-procs.h
index f3a60af6b..d0ae8309a 100644
--- a/xkb/xkb.h
+++ b/xkb/xkb-procs.h
@@ -27,4 +27,7 @@ extern int ProcXkbGetKbdByName(ClientPtr client);
extern int ProcXkbGetDeviceInfo(ClientPtr client);
extern int ProcXkbSetDeviceInfo(ClientPtr client);
extern int ProcXkbSetDebuggingFlags(ClientPtr client);
+
+extern int SProcXkbDispatch(ClientPtr client);
+
#endif
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 820cd7166..b324aeaa8 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -31,18 +31,20 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XKMformat.h>
+
+#include "dix/dix_priv.h"
+
#include "misc.h"
#include "inputstr.h"
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "extnsionst.h"
#include "extinit.h"
#include "xace.h"
-#include "xkb.h"
+#include "xkb-procs.h"
#include "protocol-versions.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XKMformat.h>
int XkbEventBase;
static int XkbErrorBase;
@@ -2433,7 +2435,7 @@ _XkbSetMapCheckLength(xkbSetMapReq *req)
}
/* actions */
if (req->present & XkbKeyActionsMask) {
- _add_check_len(req->totalActs * sz_xkbActionWireDesc
+ _add_check_len(req->totalActs * sz_xkbActionWireDesc
+ XkbPaddedSize(req->nKeyActs));
}
/* behaviours */
@@ -2461,8 +2463,7 @@ _XkbSetMapCheckLength(xkbSetMapReq *req)
if (len == req_len)
return Success;
bad:
- ErrorF("[xkb] BOGUS LENGTH in SetMap: expected %ld got %ld\n",
- len, req_len);
+ ErrorF("[xkb] BOGUS LENGTH in SetMap: expected %zd got %zd\n", len, req_len);
return BadLength;
}
@@ -5137,6 +5138,11 @@ _GetCountedString(char **wire_inout, ClientPtr client, char **str)
CARD16 len;
wire = *wire_inout;
+
+ if (client->req_len <
+ bytes_to_int32(wire + 2 - (char *) client->requestBuffer))
+ return BadValue;
+
len = *(CARD16 *) wire;
if (client->swapped) {
swaps(&len);
@@ -5156,7 +5162,7 @@ _GetCountedString(char **wire_inout, ClientPtr client, char **str)
}
static Status
-_CheckSetDoodad(char **wire_inout,
+_CheckSetDoodad(char **wire_inout, xkbSetGeometryReq *req,
XkbGeometryPtr geom, XkbSectionPtr section, ClientPtr client)
{
char *wire;
@@ -5167,6 +5173,9 @@ _CheckSetDoodad(char **wire_inout,
Status status;
dWire = (xkbDoodadWireDesc *) (*wire_inout);
+ if (!_XkbCheckRequestBounds(client, req, dWire, dWire + 1))
+ return BadLength;
+
any = dWire->any;
wire = (char *) &dWire[1];
if (client->swapped) {
@@ -5269,7 +5278,7 @@ _CheckSetDoodad(char **wire_inout,
}
static Status
-_CheckSetOverlay(char **wire_inout,
+_CheckSetOverlay(char **wire_inout, xkbSetGeometryReq *req,
XkbGeometryPtr geom, XkbSectionPtr section, ClientPtr client)
{
register int r;
@@ -5280,6 +5289,9 @@ _CheckSetOverlay(char **wire_inout,
wire = *wire_inout;
olWire = (xkbOverlayWireDesc *) wire;
+ if (!_XkbCheckRequestBounds(client, req, olWire, olWire + 1))
+ return BadLength;
+
if (client->swapped) {
swapl(&olWire->name);
}
@@ -5291,6 +5303,9 @@ _CheckSetOverlay(char **wire_inout,
xkbOverlayKeyWireDesc *kWire;
XkbOverlayRowPtr row;
+ if (!_XkbCheckRequestBounds(client, req, rWire, rWire + 1))
+ return BadLength;
+
if (rWire->rowUnder > section->num_rows) {
client->errorValue = _XkbErrCode4(0x20, r, section->num_rows,
rWire->rowUnder);
@@ -5299,6 +5314,9 @@ _CheckSetOverlay(char **wire_inout,
row = XkbAddGeomOverlayRow(ol, rWire->rowUnder, rWire->nKeys);
kWire = (xkbOverlayKeyWireDesc *) &rWire[1];
for (k = 0; k < rWire->nKeys; k++, kWire++) {
+ if (!_XkbCheckRequestBounds(client, req, kWire, kWire + 1))
+ return BadLength;
+
if (XkbAddGeomOverlayKey(ol, row,
(char *) kWire->over,
(char *) kWire->under) == NULL) {
@@ -5332,6 +5350,9 @@ _CheckSetSections(XkbGeometryPtr geom,
register int r;
xkbRowWireDesc *rWire;
+ if (!_XkbCheckRequestBounds(client, req, sWire, sWire + 1))
+ return BadLength;
+
if (client->swapped) {
swapl(&sWire->name);
swaps(&sWire->top);
@@ -5357,6 +5378,9 @@ _CheckSetSections(XkbGeometryPtr geom,
XkbRowPtr row;
xkbKeyWireDesc *kWire;
+ if (!_XkbCheckRequestBounds(client, req, rWire, rWire + 1))
+ return BadLength;
+
if (client->swapped) {
swaps(&rWire->top);
swaps(&rWire->left);
@@ -5368,16 +5392,19 @@ _CheckSetSections(XkbGeometryPtr geom,
row->left = rWire->left;
row->vertical = rWire->vertical;
kWire = (xkbKeyWireDesc *) &rWire[1];
- for (k = 0; k < rWire->nKeys; k++) {
+ for (k = 0; k < rWire->nKeys; k++, kWire++) {
XkbKeyPtr key;
+ if (!_XkbCheckRequestBounds(client, req, kWire, kWire + 1))
+ return BadLength;
+
key = XkbAddGeomKey(row);
if (!key)
return BadAlloc;
- memcpy(key->name.name, kWire[k].name, XkbKeyNameLength);
- key->gap = kWire[k].gap;
- key->shape_ndx = kWire[k].shapeNdx;
- key->color_ndx = kWire[k].colorNdx;
+ memcpy(key->name.name, kWire->name, XkbKeyNameLength);
+ key->gap = kWire->gap;
+ key->shape_ndx = kWire->shapeNdx;
+ key->color_ndx = kWire->colorNdx;
if (key->shape_ndx >= geom->num_shapes) {
client->errorValue = _XkbErrCode3(0x10, key->shape_ndx,
geom->num_shapes);
@@ -5389,14 +5416,14 @@ _CheckSetSections(XkbGeometryPtr geom,
return BadMatch;
}
}
- rWire = (xkbRowWireDesc *) &kWire[rWire->nKeys];
+ rWire = (xkbRowWireDesc *)kWire;
}
wire = (char *) rWire;
if (sWire->nDoodads > 0) {
register int d;
for (d = 0; d < sWire->nDoodads; d++) {
- status = _CheckSetDoodad(&wire, geom, section, client);
+ status = _CheckSetDoodad(&wire, req, geom, section, client);
if (status != Success)
return status;
}
@@ -5405,7 +5432,7 @@ _CheckSetSections(XkbGeometryPtr geom,
register int o;
for (o = 0; o < sWire->nOverlays; o++) {
- status = _CheckSetOverlay(&wire, geom, section, client);
+ status = _CheckSetOverlay(&wire, req, geom, section, client);
if (status != Success)
return status;
}
@@ -5439,6 +5466,9 @@ _CheckSetShapes(XkbGeometryPtr geom,
xkbOutlineWireDesc *olWire;
XkbOutlinePtr ol;
+ if (!_XkbCheckRequestBounds(client, req, shapeWire, shapeWire + 1))
+ return BadLength;
+
shape =
XkbAddGeomShape(geom, shapeWire->name, shapeWire->nOutlines);
if (!shape)
@@ -5449,21 +5479,27 @@ _CheckSetShapes(XkbGeometryPtr geom,
XkbPointPtr pt;
xkbPointWireDesc *ptWire;
+ if (!_XkbCheckRequestBounds(client, req, olWire, olWire + 1))
+ return BadLength;
+
ol = XkbAddGeomOutline(shape, olWire->nPoints);
if (!ol)
return BadAlloc;
ol->corner_radius = olWire->cornerRadius;
ptWire = (xkbPointWireDesc *) &olWire[1];
- for (p = 0, pt = ol->points; p < olWire->nPoints; p++, pt++) {
- pt->x = ptWire[p].x;
- pt->y = ptWire[p].y;
+ for (p = 0, pt = ol->points; p < olWire->nPoints; p++, pt++, ptWire++) {
+ if (!_XkbCheckRequestBounds(client, req, ptWire, ptWire + 1))
+ return BadLength;
+
+ pt->x = ptWire->x;
+ pt->y = ptWire->y;
if (client->swapped) {
swaps(&pt->x);
swaps(&pt->y);
}
}
ol->num_points = olWire->nPoints;
- olWire = (xkbOutlineWireDesc *) (&ptWire[olWire->nPoints]);
+ olWire = (xkbOutlineWireDesc *)ptWire;
}
if (shapeWire->primaryNdx != XkbNoShape)
shape->primary = &shape->outlines[shapeWire->primaryNdx];
@@ -5560,12 +5596,15 @@ _CheckSetGeom(XkbGeometryPtr geom, xkbSetGeometryReq * req, ClientPtr client)
return status;
for (i = 0; i < req->nDoodads; i++) {
- status = _CheckSetDoodad(&wire, geom, NULL, client);
+ status = _CheckSetDoodad(&wire, req, geom, NULL, client);
if (status != Success)
return status;
}
for (i = 0; i < req->nKeyAliases; i++) {
+ if (!_XkbCheckRequestBounds(client, req, wire, wire + XkbKeyNameLength))
+ return BadLength;
+
if (XkbAddGeomKeyAlias(geom, &wire[XkbKeyNameLength], wire) == NULL)
return BadAlloc;
wire += 2 * XkbKeyNameLength;
@@ -5761,7 +5800,8 @@ static unsigned char componentExprLegal[] = {
};
static char *
-GetComponentSpec(unsigned char **pWire, Bool allowExpr, int *errRtrn)
+GetComponentSpec(ClientPtr client, xkbGetKbdByNameReq *stuff,
+ unsigned char **pWire, Bool allowExpr, int *errRtrn)
{
int len;
register int i;
@@ -5773,8 +5813,16 @@ GetComponentSpec(unsigned char **pWire, Bool allowExpr, int *errRtrn)
legal = &componentSpecLegal[0];
wire = *pWire;
+ if (!_XkbCheckRequestBounds(client, stuff, wire, wire + 1)) {
+ *errRtrn = BadLength;
+ return NULL;
+ }
len = (*(unsigned char *) wire++);
if (len > 0) {
+ if (!_XkbCheckRequestBounds(client, stuff, wire, wire + len)) {
+ *errRtrn = BadLength;
+ return NULL;
+ }
str = calloc(1, len + 1);
if (str) {
tmp = str;
@@ -5828,6 +5876,8 @@ ProcXkbListComponents(ClientPtr client)
* length wrong. */
str = (unsigned char *) &stuff[1];
for (i = 0; i < 6; i++) {
+ if (!_XkbCheckRequestBounds(client, stuff, str, str + 1))
+ return BadLength;
size = *((uint8_t *)str);
len = (str + size + 1) - ((unsigned char *) stuff);
if ((XkbPaddedSize(len) / 4) > stuff->length)
@@ -5902,18 +5952,32 @@ ProcXkbGetKbdByName(ClientPtr client)
xkb = dev->key->xkbInfo->desc;
status = Success;
str = (unsigned char *) &stuff[1];
- if (GetComponentSpec(&str, TRUE, &status)) /* keymap, unsupported */
- return BadMatch;
- names.keycodes = GetComponentSpec(&str, TRUE, &status);
- names.types = GetComponentSpec(&str, TRUE, &status);
- names.compat = GetComponentSpec(&str, TRUE, &status);
- names.symbols = GetComponentSpec(&str, TRUE, &status);
- names.geometry = GetComponentSpec(&str, TRUE, &status);
- if (status != Success)
+ {
+ char *keymap = GetComponentSpec(client, stuff, &str, TRUE, &status); /* keymap, unsupported */
+ if (keymap) {
+ free(keymap);
+ return BadMatch;
+ }
+ }
+ names.keycodes = GetComponentSpec(client, stuff, &str, TRUE, &status);
+ names.types = GetComponentSpec(client, stuff, &str, TRUE, &status);
+ names.compat = GetComponentSpec(client, stuff, &str, TRUE, &status);
+ names.symbols = GetComponentSpec(client, stuff, &str, TRUE, &status);
+ names.geometry = GetComponentSpec(client, stuff, &str, TRUE, &status);
+ if (status == Success) {
+ len = str - ((unsigned char *) stuff);
+ if ((XkbPaddedSize(len) / 4) != stuff->length)
+ status = BadLength;
+ }
+
+ if (status != Success) {
+ free(names.keycodes);
+ free(names.types);
+ free(names.compat);
+ free(names.symbols);
+ free(names.geometry);
return status;
- len = str - ((unsigned char *) stuff);
- if ((XkbPaddedSize(len) / 4) != stuff->length)
- return BadLength;
+ }
CHK_MASK_LEGAL(0x01, stuff->want, XkbGBN_AllComponentsMask);
CHK_MASK_LEGAL(0x02, stuff->need, XkbGBN_AllComponentsMask);
@@ -6550,7 +6614,8 @@ ProcXkbGetDeviceInfo(ClientPtr client)
static char *
CheckSetDeviceIndicators(char *wire,
DeviceIntPtr dev,
- int num, int *status_rtrn, ClientPtr client)
+ int num, int *status_rtrn, ClientPtr client,
+ xkbSetDeviceInfoReq * stuff)
{
xkbDeviceLedsWireDesc *ledWire;
int i;
@@ -6558,6 +6623,11 @@ CheckSetDeviceIndicators(char *wire,
ledWire = (xkbDeviceLedsWireDesc *) wire;
for (i = 0; i < num; i++) {
+ if (!_XkbCheckRequestBounds(client, stuff, ledWire, ledWire + 1)) {
+ *status_rtrn = BadLength;
+ return (char *) ledWire;
+ }
+
if (client->swapped) {
swaps(&ledWire->ledClass);
swaps(&ledWire->ledID);
@@ -6585,6 +6655,11 @@ CheckSetDeviceIndicators(char *wire,
atomWire = (CARD32 *) &ledWire[1];
if (nNames > 0) {
for (n = 0; n < nNames; n++) {
+ if (!_XkbCheckRequestBounds(client, stuff, atomWire, atomWire + 1)) {
+ *status_rtrn = BadLength;
+ return (char *) atomWire;
+ }
+
if (client->swapped) {
swapl(atomWire);
}
@@ -6596,6 +6671,10 @@ CheckSetDeviceIndicators(char *wire,
mapWire = (xkbIndicatorMapWireDesc *) atomWire;
if (nMaps > 0) {
for (n = 0; n < nMaps; n++) {
+ if (!_XkbCheckRequestBounds(client, stuff, mapWire, mapWire + 1)) {
+ *status_rtrn = BadLength;
+ return (char *) mapWire;
+ }
if (client->swapped) {
swaps(&mapWire->virtualMods);
swapl(&mapWire->ctrls);
@@ -6647,11 +6726,6 @@ SetDeviceIndicators(char *wire,
xkbIndicatorMapWireDesc *mapWire;
XkbSrvLedInfoPtr sli;
- if (!_XkbCheckRequestBounds(client, stuff, ledWire, ledWire + 1)) {
- *status_rtrn = BadLength;
- return (char *) ledWire;
- }
-
namec = mapc = statec = 0;
sli = XkbFindSrvLedInfo(dev, ledWire->ledClass, ledWire->ledID,
XkbXI_IndicatorMapsMask);
@@ -6670,10 +6744,6 @@ SetDeviceIndicators(char *wire,
memset((char *) sli->names, 0, XkbNumIndicators * sizeof(Atom));
for (n = 0, bit = 1; n < XkbNumIndicators; n++, bit <<= 1) {
if (ledWire->namesPresent & bit) {
- if (!_XkbCheckRequestBounds(client, stuff, atomWire, atomWire + 1)) {
- *status_rtrn = BadLength;
- return (char *) atomWire;
- }
sli->names[n] = (Atom) *atomWire;
if (sli->names[n] == None)
ledWire->namesPresent &= ~bit;
@@ -6691,10 +6761,6 @@ SetDeviceIndicators(char *wire,
if (ledWire->mapsPresent) {
for (n = 0, bit = 1; n < XkbNumIndicators; n++, bit <<= 1) {
if (ledWire->mapsPresent & bit) {
- if (!_XkbCheckRequestBounds(client, stuff, mapWire, mapWire + 1)) {
- *status_rtrn = BadLength;
- return (char *) mapWire;
- }
sli->maps[n].flags = mapWire->flags;
sli->maps[n].which_groups = mapWire->whichGroups;
sli->maps[n].groups = mapWire->groups;
@@ -6730,13 +6796,17 @@ SetDeviceIndicators(char *wire,
}
static int
-_XkbSetDeviceInfo(ClientPtr client, DeviceIntPtr dev,
+_XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
xkbSetDeviceInfoReq * stuff)
{
char *wire;
wire = (char *) &stuff[1];
if (stuff->change & XkbXI_ButtonActionsMask) {
+ int sz = stuff->nBtns * SIZEOF(xkbActionWireDesc);
+ if (!_XkbCheckRequestBounds(client, stuff, wire, (char *) wire + sz))
+ return BadLength;
+
if (!dev->button) {
client->errorValue = _XkbErrCode2(XkbErr_BadClass, ButtonClass);
return XkbKeyboardErrorCode;
@@ -6747,13 +6817,13 @@ _XkbSetDeviceInfo(ClientPtr client, DeviceIntPtr dev,
dev->button->numButtons);
return BadMatch;
}
- wire += (stuff->nBtns * SIZEOF(xkbActionWireDesc));
+ wire += sz;
}
if (stuff->change & XkbXI_IndicatorsMask) {
int status = Success;
wire = CheckSetDeviceIndicators(wire, dev, stuff->nDeviceLedFBs,
- &status, client);
+ &status, client, stuff);
if (status != Success)
return status;
}
@@ -6764,8 +6834,8 @@ _XkbSetDeviceInfo(ClientPtr client, DeviceIntPtr dev,
}
static int
-_XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
- xkbSetDeviceInfoReq * stuff)
+_XkbSetDeviceInfo(ClientPtr client, DeviceIntPtr dev,
+ xkbSetDeviceInfoReq * stuff)
{
char *wire;
xkbExtensionDeviceNotify ed;
@@ -6774,7 +6844,7 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
ed.deviceID = dev->id;
wire = (char *) &stuff[1];
if (stuff->change & XkbXI_ButtonActionsMask) {
- int nBtns, sz, i;
+ int nBtns, sz, i;
XkbAction *acts;
DeviceIntPtr kbd;
@@ -6789,8 +6859,6 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
if (stuff->firstBtn + stuff->nBtns > nBtns)
return BadValue;
sz = stuff->nBtns * SIZEOF(xkbActionWireDesc);
- if (!_XkbCheckRequestBounds(client, stuff, wire, (char *) wire + sz))
- return BadLength;
memcpy((char *) &acts[stuff->firstBtn], (char *) wire, sz);
wire += sz;
ed.reason |= XkbXI_ButtonActionsMask;
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index f80057747..4f1fee280 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -46,6 +46,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
int XkbDfltRepeatDelay = 660;
int XkbDfltRepeatInterval = 40;
+#define _OFF_TIMER 0
+#define _KRG_WARN_TIMER 1
+#define _KRG_TIMER 2
+#define _SK_TIMEOUT_TIMER 3
+#define _ALL_TIMEOUT_TIMER 4
+
#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index db29091e7..5e9a6b6d6 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -38,7 +38,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "exevents.h"
#include "eventstr.h"
#include <xkbsrv.h>
-#include "xkb.h"
#include <ctype.h>
#include "mi.h"
#include "mipointer.h"
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 0bbd66186..f8f65d4a7 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -39,7 +39,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "exglobals.h"
#include "windowstr.h"
#include <xkbsrv.h>
-#include "xkb.h"
/***====================================================================***/
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 4108e1b26..c06ec09d4 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -39,17 +39,18 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
+
+#include "os/cmdline.h"
+
#include "misc.h"
#include "inputstr.h"
#include "opaque.h"
#include "property.h"
#include "scrnintstr.h"
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "xkbgeom.h"
#include <X11/extensions/XKMformat.h>
#include "xkbfile.h"
-#include "xkb.h"
#define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1)
@@ -664,7 +665,7 @@ InitKeyboardDeviceStructInternal(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
return FALSE;
}
-_X_EXPORT Bool
+Bool
InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
{
@@ -672,7 +673,7 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
NULL, 0, bell_func, ctrl_func);
}
-_X_EXPORT Bool
+Bool
InitKeyboardDeviceStructFromString(DeviceIntPtr dev,
const char *keymap, int keymap_length,
BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
@@ -725,6 +726,7 @@ XkbFreeInfo(XkbSrvInfoPtr xkbi)
XkbFreeKeyboard(xkbi->desc, XkbAllComponentsMask, TRUE);
xkbi->desc = NULL;
}
+ free(xkbi->filters);
free(xkbi);
return;
}
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index 5792d9fb7..2ddd7a402 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -38,7 +38,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <X11/extensions/XI.h>
#include <xkbsrv.h>
-#include "xkb.h"
/***====================================================================***/
@@ -435,6 +434,44 @@ XkbUpdateIndicators(DeviceIntPtr dev,
/***====================================================================***/
+ /*
+ * void
+ * XkbForceUpdateDeviceLEDs(DeviceIntPtr dev)
+ *
+ * Force update LED states to the hardware from the device state
+ * specified by 'dev'.
+ *
+ * If 'dev' is a master device, this function will also force update
+ * its slave devices.
+ *
+ * Used if the actual LED state was externally set and need to push
+ * current state to the hardware e.g. switching between VTs.
+ */
+
+void
+XkbForceUpdateDeviceLEDs(DeviceIntPtr dev)
+{
+ DeviceIntPtr master;
+ XkbSrvLedInfoPtr sli;
+
+ if (!dev->key)
+ return;
+
+ sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId, 0);
+ XkbDDXUpdateDeviceIndicators(dev, sli, sli->effectiveState);
+
+ if (IsMaster(dev)) {
+ master = dev;
+ nt_list_for_each_entry(dev, inputInfo.devices, next) {
+ if (!dev->key || GetMaster(dev, MASTER_KEYBOARD) != master)
+ continue;
+
+ sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId, 0);
+ XkbDDXUpdateDeviceIndicators(dev, sli, sli->effectiveState);
+ }
+ }
+}
+
/***====================================================================***/
/*
diff --git a/xkb/xkbSwap.c b/xkb/xkbSwap.c
index 50cabb90e..efbdb81c1 100644
--- a/xkb/xkbSwap.c
+++ b/xkb/xkbSwap.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <xkbsrv.h>
#include "xkbstr.h"
#include "extnsionst.h"
-#include "xkb.h"
+#include "xkb-procs.h"
/*
* REQUEST SWAPPING
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 8975ade8d..9ad66927c 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -63,11 +63,8 @@ DEALINGS IN THE SOFTWARE.
#include "misc.h"
#include "inputstr.h"
#include "eventstr.h"
-
-#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "xkbgeom.h"
-#include "xkb.h"
/***====================================================================***/
@@ -214,7 +211,7 @@ XkbMaskForVMask(XkbDescPtr xkb, unsigned vmask)
/***====================================================================***/
-void
+static void
XkbUpdateKeyTypesFromCore(DeviceIntPtr pXDev,
KeySymsPtr pCore,
KeyCode first, CARD8 num, XkbChangesPtr changes)
@@ -902,9 +899,9 @@ XkbConvertCase(register KeySym sym, KeySym * lower, KeySym * upper)
break;
case 6: /* Cyrillic */
/* Assume the KeySym is a legal value (ignore discontinuities) */
- if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
+ if (sym >= XK_Serbian_DJE && sym <= XK_Cyrillic_DZHE)
*lower -= (XK_Serbian_DJE - XK_Serbian_dje);
- else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
+ else if (sym >= XK_Serbian_dje && sym <= XK_Cyrillic_dzhe)
*upper += (XK_Serbian_DJE - XK_Serbian_dje);
else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
*lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
@@ -1327,6 +1324,7 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
}
else {
free(dst->names->radio_groups);
+ dst->names->radio_groups = NULL;
}
dst->names->num_rg = src->names->num_rg;
diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c
index 2ecdcd555..47da228ca 100644
--- a/xkb/xkbfmisc.c
+++ b/xkb/xkbfmisc.c
@@ -43,10 +43,8 @@
#include "inputstr.h"
#include "dix.h"
#include "xkbstr.h"
-#define XKBSRV_NEED_FILE_FUNCS 1
#include <xkbsrv.h>
#include "xkbgeom.h"
-#include "xkb.h"
unsigned
_XkbKSCheckCase(KeySym ks)
@@ -433,37 +431,3 @@ XkbConvertGetByNameComponents(Bool toXkm, unsigned orig)
}
return rtrn;
}
-
-/***====================================================================***/
-
-#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
-
-Bool
-XkbNameMatchesPattern(char *name, char *ptrn)
-{
- while (ptrn[0] != '\0') {
- if (name[0] == '\0') {
- if (ptrn[0] == '*') {
- ptrn++;
- continue;
- }
- return FALSE;
- }
- if (ptrn[0] == '?') {
- if (UNMATCHABLE(name[0]))
- return FALSE;
- }
- else if (ptrn[0] == '*') {
- if ((!UNMATCHABLE(name[0])) &&
- XkbNameMatchesPattern(name + 1, ptrn))
- return TRUE;
- return XkbNameMatchesPattern(name, ptrn + 1);
- }
- else if (ptrn[0] != name[0])
- return FALSE;
- name++;
- ptrn++;
- }
- /* if we get here, the pattern is exhausted (-:just like me:-) */
- return name[0] == '\0';
-}
diff --git a/xkb/xkbout.c b/xkb/xkbout.c
index 5f77ab01d..46e07db3f 100644
--- a/xkb/xkbout.c
+++ b/xkb/xkbout.c
@@ -41,7 +41,6 @@
#include "inputstr.h"
#include "dix.h"
#include "xkbstr.h"
-#define XKBSRV_NEED_FILE_FUNCS 1
#include <xkbsrv.h>
#include "xkbgeom.h"
diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
index fb17f513e..7f377fdfc 100644
--- a/xkb/xkbtext.c
+++ b/xkb/xkbtext.c
@@ -41,7 +41,6 @@
#include "inputstr.h"
#include "dix.h"
#include "xkbstr.h"
-#define XKBSRV_NEED_FILE_FUNCS 1
#include <xkbsrv.h>
#include "xkbgeom.h"
diff --git a/xkb/xkmread.c b/xkb/xkmread.c
index 842887c09..007c764cb 100644
--- a/xkb/xkmread.c
+++ b/xkb/xkmread.c
@@ -1168,23 +1168,6 @@ ReadXkmGeometry(FILE * file, XkbDescPtr xkb)
return nRead;
}
-Bool
-XkmProbe(FILE * file)
-{
- unsigned hdr, tmp;
- int nRead = 0;
-
- hdr = (('x' << 24) | ('k' << 16) | ('m' << 8) | XkmFileVersion);
- tmp = XkmGetCARD32(file, &nRead);
- if (tmp != hdr) {
- if ((tmp & (~0xff)) == (hdr & (~0xff))) {
- _XkbLibError(_XkbErrBadFileVersion, "XkmProbe", tmp & 0xff);
- }
- return 0;
- }
- return 1;
-}
-
static Bool
XkmReadTOC(FILE * file, xkmFileInfo * file_info, int max_toc,
xkmSectionInfo * toc)