Compare commits

..

92 commits

Author SHA1 Message Date
Jeremy Huddleston
e597f0119c configure.ac: 1.11.4
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-01-27 21:07:17 -08:00
Jeremy Huddleston
6c491463ee 1.11.3.902 (1.11.4 RC2)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-01-20 23:56:38 -08:00
Jeremy Huddleston
b747a91485 XQuartz: Bump bundle version to 2.7.1
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-01-18 11:47:21 -08:00
Peter Hutterer
a1ed67fa05 render: don't bother with animated cursors on floating slaves (#39989)
X.Org Bug 39989 <http://bugs.freedesktop.org/show_bug.cgi?id=39989>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit bbb6b8c834)
2012-01-18 10:55:12 -08:00
Peter Hutterer
f89c39e6c9 dix: Update pointer limits for floating devices too (#43635)
When the screen is restructured, the pointer limits need to be reset for
floating slave devices as well, not just for master pointers. Only skip
devices that don't have a cursor (attached slaves and keyboard)

Bug reproducer: float an absolute slave device, rotate the screen - the
device is now confined to a section of the screen only.

X.Org Bug 43635 <http://bugs.freedesktop.org/show_bug.cgi?id=43635>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 35bd77e9d0)
2012-01-18 10:54:13 -08:00
Zhigang Gong
dea9377a25 mi/mibitblt: Fix an overflow bug of bit shift.
When depth equal to 32 and planeMask equal to 0, the overflow will
occur and cause the pixmap can't be cleared. There are some test
cases in XTS hit this bug, and this fix can eliminate the corresponding
failures.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit f4956faab9)
2012-01-18 10:53:31 -08:00
Alan Coopersmith
d2db5100b1 Convert DetermineClientCmd to use strdup instead of malloc+strncpy
*cmdname is initialized to NULL earlier in the function, so it's
okay to overwrite it with NULL if strdup fails, don't need that
extra check.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 780133f9ae)
2012-01-18 10:50:16 -08:00
Adam Jackson
5b28bcb340 dix: Tune dixLookupDrawable for success
The vast vast vast majority of resource lookups are successful.  Move some
work to the error paths so we don't punish success.

Before:
40000000 trep @   0.0009 msec (1109091.3/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square

After:
40000000 trep @   0.0009 msec (1148346.9/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2091666.1/sec): ShmPutImage 10x10 square

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 8f9bdfd293)
2012-01-18 10:40:03 -08:00
Adam Jackson
e1ea93fec9 dix: Tune dtrace hooks around Dispatch
Don't call LookupMajorName if the hooks aren't active, it's quite expensive.

Before:
40000000 trep @   0.0009 msec (1087458.5/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square

After:
40000000 trep @   0.0009 msec (1109091.3/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 83a98543b5)
2012-01-18 10:39:23 -08:00
Adam Jackson
9eaa0b5c89 xace: ricer tuning for XaceHook
gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the
varargs code for some reason, so do it ourselves.

Before:
40000000 trep @   0.0010 msec (1050420.2/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (1921147.6/sec): ShmPutImage 10x10 square

After:
40000000 trep @   0.0009 msec (1087458.5/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 11977fab54)
2012-01-18 10:39:13 -08:00
Peter Hutterer
a3b6ecc893 xfree86: split warning about missing identifier or input driver
Check for identifier first and bail if it's missing (also remove the current
identifier check after we've already bailed due to missing identifiers)

If a driver is missing, warn but also say that we may have added this device
already. I see too many bugreports with incorrectly shortened log files.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
(cherry picked from commit 75953ccb9e)
2012-01-18 10:36:34 -08:00
Julien Cristau
4a339afc58 os: don't ignore failure from dladdr
If dladdr returns 0, don't go and use the returned Dl_info, it may
contain garbage.

X.Org bug#44315 <https://bugs.freedesktop.org/show_bug.cgi?id=44315>

Reported-and-tested-by: Cyril Brulebois <kibi@debian.org>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
Signed-off-by: Julien Cristau <jcristau@debian.org>
(cherry picked from commit 6269977c91)
2012-01-18 10:32:54 -08:00
Matthieu Herrb
9a4be7e99f Add OpenBSD support to DetermineClientCmd()
Uses kvm_getargv() from libkvm.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 6d6d4cb604)
2012-01-18 10:32:53 -08:00
Alan Coopersmith
8046717d72 Add Solaris support to DetermineClientCmd
Uses /proc/pid/psinfo to read command & partial arguments.

Moves cmdsize & argsize variables into non-Solaris #else clause
to avoid unused variable warnings.

Fixes format mismatch errors when building with DEBUG defined on
a 64-bit platform (where Mask is defined as CARD32).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit cfc4c3d7fa)
2012-01-18 10:32:51 -08:00
Jeremy Huddleston
cea9f9f273 configure.ac: 1.11.3.901 (1.11.4 RC1)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-01-06 23:05:53 -08:00
Jeremy Huddleston
b15be8547d Xi: Fix mishandled git merge
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-01-06 23:05:42 -08:00
Jeremy Huddleston
82e0ae0423 Merge remote-tracking branch 'whot/server-1.11-branch' into server-1.11-branch 2012-01-02 20:58:22 -05:00
Carlos Garnacho
4e4bb319a4 Xi: assign correct grab_mode/other_device_mode in XI2 passive grabs
CreateGrab() expects the keyboard mode to be stored in grab_mode, and the
pointer mode in other_device_mode, so respect this in passive XI2 grabs,
and switch modes if needed.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 5b169cb695)
2012-01-03 11:30:00 +10:00
Alan Coopersmith
8c73f6bcbd Change disable_clientpointer return type to void
It doesn't return anything, nor does it's caller expect it to.

Fixes Solaris Studio compiler error:
"xichangehierarchy.c", line 214: Function has no return statement : disable_clientpointer

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 372a6f10dc)
2012-01-03 11:29:43 +10:00
Peter Hutterer
ae4272a574 xfixes: don't dereference a NULL cursor
If the new cursor is the NULL cursor, don't dereference it and use zeros
instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 1ab50be938)
2012-01-03 11:24:51 +10:00
Peter Hutterer
20efd3c158 Xi: when removing a device, reset ClientPointers where needed
if a client had the to-be-removed device as ClientPointer, reset to NULL.

Fixes #43165

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit d2ebbcdaf6)
2012-01-03 11:24:46 +10:00
Peter Hutterer
cf296f2eef Xext: don't swap CARD8 in SProcSELinuxQueryVersion
xselinux_ext.c: In function 'SELinuxSendItemsToClient':
xselinux_ext.c:340:16: warning: unused variable 'n' [-Wunused-variable]
xselinux_ext.c: In function 'SProcSELinuxQueryVersion':
xselinux_ext.c:532:62: error: call to 'wrong_size' declared with attribute
error: wrong sized variable passed to swap
xselinux_ext.c:533:62: error: call to 'wrong_size' declared with attribute
error: wrong sized variable passed to swap

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
(cherry picked from commit bb4aa1f263)

Conflicts:

	Xext/xselinux_ext.c
2012-01-03 11:23:18 +10:00
Peter Hutterer
4b38661024 dix: button state must show the logical buttons, not physical buttons
If the device is mapped 3 2 1, a click on physical button 1 sends a button 3
press, but the state was set for button 1. Fix this, the state must be set
for that button's logical mapping.

https://bugzilla.gnome.org/show_bug.cgi?id=655928

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 9567d21e85b99febe805263a4d93b15fd1f7ab42)

Conflicts:

	dix/inpututils.c
2012-01-03 10:47:53 +10:00
Peter Hutterer
f9b00c2aba Xi: when removing a device, reset ClientPointers where needed
if a client had the to-be-removed device as ClientPointer, reset to NULL.

Fixes #43165

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit d2ebbcdaf6)
2012-01-02 15:39:21 -05:00
Peter Hutterer
e4984b3023 xfixes: don't dereference a NULL cursor
If the new cursor is the NULL cursor, don't dereference it and use zeros
instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 1ab50be938)
2012-01-02 15:38:52 -05:00
Peter Hutterer
625d108819 dmx: force -fno-strict-aliasing for xinput example
Compiler warning:
xinput.c:272: warning: dereferencing pointer 'e' does break strict-aliasing
rules

The code itself is the usual XInput client-side code:
        XEvent event;
        XDeviceMotionEvent *e = (XDeviceMotionEvent *)&event;
        XNextEvent(display, &event);
        printf("%d\n", e->type);

Since XDeviceMotionEvent is not guaranteed the same size as XEvent, clients
must use pointer aliasing as above when using the XNextEvent API. Disable
strict aliasing for this example.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 3aca819940)
2011-12-21 12:21:58 -08:00
Keith Packard
53e347b22b Save major/minor opcodes in ClientRec for RecordAReply
The record extension needs the major and minor opcodes in the reply
hook, but the request buffer may have been freed by the time the hook
is invoked. Saving the request major and minor codes as the request is
executed avoids fetching from the defunct request buffer.

This patch also eliminates the public MinorOpcodeOfRequest function,
inlining it into Dispatch. Usages of that function have been replaced
with direct access to the new ClientRec field.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit fb22a408c6)

Conflicts:

	include/extension.h
2011-12-21 09:55:58 -08:00
Julien Cristau
b736f8c92b Fix ShmPutImage for XYBitmap
We can't call CopyArea in that case because the image has depth 1, which
might not match the target drawable, so we might overrun the shm
segment.  Commit 11817a881c apparently
fixed a similar bug for XYPixmap, but missed the bitmap case.

Fixes: http://bugs.debian.org/629611

Thanks to Alan Curry for diagnosing this and providing a test case.

Reported-and-tested-by: Alan Curry <pacman@kosh.dhis.org>
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Cristau <jcristau@debian.org>
(cherry picked from commit 08ec4da6a7)
2011-12-21 09:52:21 -08:00
Jeremy Huddleston
b2a4c09507 kdrive/linux: Fix compilation with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast
Reported-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit 1deede3c48)
2011-12-20 01:13:26 -08:00
Jeremy Huddleston
beaa7ad2ec configure.ac: Make Xephyr dependency error message more informative
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit d0170d54c7)
2011-12-20 01:13:21 -08:00
Jeremy Huddleston
41524dd610 configure.ac: 1.11.3
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-12-16 17:47:46 -08:00
Gaetan Nadon
ee66474eb2 dmx: fix distcheck failure, missing compsize.h in Makefile.am
which was added in commit:
dmx: Build fix for -Werror=implicit-function-declaration

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 2c1d0a539c)
2011-12-15 14:55:37 -08:00
Jeremy Huddleston
0ca8869e45 configure.ac: 1.11.2.902 (1.11.3 RC2)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-12-09 12:58:30 -08:00
Dave Airlie
e76c397eb9 kdrive: drop screen crossing code.
The only kdrive server we probably care about anymore is Xephyr,
and this screen enable/disable code totally breaks it in multi-screen mode.

When you are in one screen the other stops updating.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=757457

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 98c4a888a4)
2011-12-09 12:35:59 -08:00
Dave Airlie
db418ff750 hal: free tmp_val in one missing case
Pointed out by coverity scan.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit 8d3731a811)
2011-12-09 12:35:44 -08:00
Dave Airlie
6b11b18ab6 xv: test correct number of requests. (v2)
Pointed out by coverity.

v2: fix swapped as well, as pointed out by Alan

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 41229392b7)
2011-12-09 12:35:37 -08:00
Dave Airlie
df16b789aa xaa: avoid possible freed pointer reuse in epilogue
If the pGCPriv->flags == 2, then we try to assign the freed pGCPriv->XAAOps
avoid this by clearing the flags in to be destroyed pGCPriv.

Reported by coverity.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 1049139499)
2011-12-09 12:35:27 -08:00
Dave Airlie
befa8a3b83 Xi: avoid overrun of callback array.
This code had an off-by-one and would allow writing one past the end of
the callbacks array.

Pointed out by coverity.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 682c09a2ce)
2011-12-09 12:35:18 -08:00
Dave Airlie
b22783f483 xext: don't free uninitialised pointer when malloc fails. (v2)
Initialise the pAttr->values to values so if the values allocation
fails it just ends up as free(NULL).

Pointed out by coverity.

v2: use Alan's suggestion.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit b62dc4fcbc)
2011-12-09 12:34:41 -08:00
Adam Jackson
083599c559 fbdevhw: iterate over all modes that match a mode. (v3)
So on RHEL5 anaconda sets an xorg.conf with a fixed 800x600 mode in it,
we run radeonfb and fbdev since ati won't work in userspace due to domain
issues in the older codebase.

On certain pseries blades the built-in KVM can't accept an 800x600-43 mode,
it requires the 800x600-60 mode, so we have to have the kernel radeonfb
driver reject the 800x600-43 mode when it sees it. However then fbdev
doesn't try any of the other 800x600 modes in the modelist, and we end up
getting a default 640x480 mode we don't want.

This patch changes the mode validation loop to continue on with the other modes
that match to find one that works.

v2: move code around to avoid extra loop, after comment from Jamey.
v3: move loop setup back into loop as per Jeremy's review.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 22605effd1)
2011-12-09 12:34:22 -08:00
Alan Coopersmith
05a890df0a LoaderOpen returns either a valid pointer or NULL, so don't check for < 0
Fixes Sun cc warning that was recently elevated to error by the
stricter default CFLAGS changes to xorg-macros:

"loadmod.c", line 914: improper pointer/integer combination: op "<"

Should have been changed when commit ab7f057ce9 changed the
LoaderOpen return type from int to void *.

Changes log message when file is found but dlopen() fails from:
 (EE) LoadModule: Module dbe does not have a dbeModuleData data object.
 (EE) Failed to load module "dbe" (invalid module, 0)
to:
 (EE) Failed to load module "dbe" (loader failed, 7)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit e4dcf580f0)
2011-12-09 12:33:42 -08:00
Alan Coopersmith
f494410842 Limit the number of screens Xvfb will attempt to allocate memory for
Commit f9e3a2955d removing the MAXSCREEN limit left the screen
number too unlimited, and allowed any positive int for a screen number:

Xvfb :1 -screen 2147483647 1024x1024x8

Fatal server error:
Not enough memory for screen 2147483647

Found by Parfait 0.3.7:
Error: Integer overflow (CWE 190)
   Integer parameter of memory allocation function realloc() may overflow due to multiplication with constant value 1112
        at line 293 of hw/vfb/InitOutput.c in function 'ddxProcessArgument'.

Since the X11 connection setup only has a CARD8 for number of SCREENS,
limit to 255 screens, which is also low enough to avoid overflow on the
sizeof(*vfbScreens) * (screenNum + 1) calculation for realloc.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit feebf67463)
2011-12-09 12:32:43 -08:00
Rui Matos
bed7d7f31e randr: Make the RRConstrainCursorHarder logic the same as miPointerSetPosition
The constraining logic in RRConstrainCursorHarder allows the cursor to reach
crtc positions of x = width and y = height while the constraining code in
miPointerSetPosition only allows it to reach x = width - 1 and y = height - 1
for the analogous screen case.

This patch makes the former's logic equivalent to the latter's which allows
applications to benefit from Fitts's law. E.g. a maximized application
adjacent to a crtc border wouldn't get pointer events if the user moved the
pointer all the way until it's contained.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 9cc44b955b)
2011-11-28 09:00:52 -08:00
Jeremy Huddleston
4689c84a07 configure.ac: 1.11.2.901 (1.11.3 RC1)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-28 00:07:29 -08:00
Derek Buitenhuis
e2661ddbc5 Fix vesa's VBE PanelID interpretation
xserver's VESA driver's VBE (Vesa BIOS Extensions) code
includes a PanelID probe, which can get a monitor's native
resolution. From this, using CVT formulas, it derives
horizontal sync rate and a vertical refresh rate ranges.

It however, only derives the upper bounds of the ranges, and
the lower bounds cannot de derived. By default, they are set
to hardcoded constants which represent the lowest supported
resolution: 640x480. The constants in vbe.c however, were
not actually derived from forulas, but carried over from
other code from the bad old days, and are not relevant
to flat panel displays. This caused, for example, EEEPC701's
panel, with a native resolution of 800x480, to end up with
a upper bound of the horizontal sync rate that was lower
than the hardcoded lower bound, which of course broke things.

These numbers have been rederived using both my own CVT tool
based on xf86CVTMode(), and using the provided 'cvt' tool
that comes with xserver.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit f0d50cc665)
2011-11-24 12:15:00 -08:00
Jeremy Huddleston
2e3406fc67 dmx: Build fix for -Werror=implicit-function-declaration
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit f405dfffe7)
2011-11-24 12:05:59 -08:00
dtakahashi42
b440fc9c1b rootless: Fix a server crash when choosing a color with the gimp color wheel
https://trac.macports.org/ticket/30927

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 328074890e)
2011-11-21 18:44:34 -08:00
Ross Burton
40c1287f36 edid: Add quirk for Acer Aspire One 110
At least one revision of the AAO reports a 190x110mm maximum size but a
451x113mm mode.

X.Org Bug 41141 <https://bugs.freedesktop.org/show_bug.cgi?id=41141>

Signed-off-by: Ross Burton <ross@linux.intel.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 58864146fb)
2011-11-21 18:44:24 -08:00
Chris Wilson
7972e2dade dri2: Register the DRI2DrawableType after server regeneration
The Resource database is reset upon regeneration and so the dri2 module
needs to re-register its RESTYPE for the drawable or else it will
clobber the next unsuspecting user of the database. Fortunately, DRI2 is
loaded late in the initialisation sequence and was last up until
xf86-video-intel started using the Resource database to track
outstanding swaps...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
(cherry picked from commit 34b0e4eee9)
2011-11-21 18:44:17 -08:00
Chris Wilson
73beaf9033 DRI2: Avoid a NULL pointer dereference
Bugzilla:  https://bugs.freedesktop.org/show_bug.cgi?id=41211

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit bfa1a0dd19)
2011-11-21 18:43:49 -08:00
Chris Wilson
6105fcaa35 VidMode: prevent crash with no modes
Bugzilla:  https://bugs.freedesktop.org/show_bug.cgi?id=17431

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit eeb21a133b)
2011-11-21 18:43:43 -08:00
Rami Ylimäki
d113b29115 record: Prevent out of bounds access when recording a reply.
Any pad bytes in replies are written to the client from a zeroed
array. However, record extension tries to incorrectly access the pad
bytes from the end of reply data.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
(cherry picked from commit c1bb8f43b9)
2011-11-21 18:43:32 -08:00
Jeremy Huddleston
4dc5b6ea9f xfree86: Fix powerpc build with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast
memType is a uint64_t on powerpc. Using memType only really makes
sense for *physical* addresses, which can be 64-bit for 32-bit
systems running on 64-bit hardware.

However, unmapVidMem() only deals with *virtual* addresses, which
are guaranteed to fit into an uintptr_t.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
(cherry picked from commit eb3377ffb8)
2011-11-21 18:42:42 -08:00
Peter Hutterer
a1925f0879 include: export GetProximityEvents and QueueProximityEvents
This is mainly needed for consistency with GetPointerEvents and friend.
No-one seems to actually need this function from outside the usual DDXs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit fc16917ad6)
2011-11-21 17:59:17 -08:00
Peter Hutterer
a6a21f84bb dix: Don't let a driver without a ProximityClassRec post events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 11840595a1)
2011-11-21 17:58:49 -08:00
Peter Hutterer
2f2d871ccd Xi: allow passive keygrabs on the XIAll(Master)Devices fake devices
They don't have a KeyClassRec, but we must still allow passive grabs on
them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Bastien Nocera <hadess@hadess.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit 22715e465b)
2011-11-21 17:58:31 -08:00
Peter Hutterer
34bb83b9df dix: block signals when closing all devices
When closing down all devices, we manually unset master for all attached
devices, but the device's sprite info still points to the master's sprite
info. This leaves us a window where the master is freed already but the
device isn't yet. A signal during that window causes dereference of the
already freed spriteInfo in mieqEnqueue's EnqueueScreen macro.

Simply block signals when removing all devices. It's not like we're really
worrying about high-responsive input at this stage.

https://bugzilla.redhat.com/show_bug.cgi?id=737031

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
(cherry picked from commit d7c44a7c97)
2011-11-07 18:00:33 -08:00
Christopher Yeleighton
97f2ae60fc Bug 38420: Xvfb crashes in miInitVisuals() when started with depth=2
https://bugs.freedesktop.org/show_bug.cgi?id=38420

Exit with fatal error message, not segfault.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 7d50211ab5)
2011-11-06 16:53:06 -08:00
Dave Airlie
89626304ea xf86Crtc: handle no outputs with no modes harder.
If you started an X server with no connected outputs, we pick a default
1024x768 mode, however if you then ran an xvidmode using app against that
server it would segfault the server due to not finding any valid modes.

This was due to the no output mode set code, only adding the modes to the
scrn->modes once, when something called randr 1.2 xf86SetScrnInfoModes would
get called and remove all the modes and we'd end up with 0.

This change fixes xf86SetScrnInfoModes to always report a scrn mode of at
least 1024x768, and pushes the initial configuration to just call it instead
of setting up the mode itself.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=746926

I've seen other bugs like this on other distros so it might also actually fix them.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 17416e88dc)
2011-11-06 16:52:56 -08:00
Jeremy Huddleston
c68a84e73d configure.ac: Bump to 1.11.2
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-04 10:24:08 -07:00
Jeremy Huddleston
2d6760f591 Revert "dix: don't XWarpPointer through the last slave anymore (#38313)"
This reverts commit bbe6a69da3.

This commit caused a regression.

See: http://xquartz.macosforge.org/trac/ticket/517#comment:10
2011-11-03 15:01:35 -07:00
Jeremy Huddleston
0bffe6b38c configure.ac: Bump to 1.11.1.902 (1.11.2 RC2)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-28 18:32:28 -07:00
Jeremy Huddleston
a1d638da0d XWin: windowswm: Correct byte swapping in event notifications
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
(cherry picked from commit 286fa9bf9b)
2011-10-28 18:31:15 -07:00
Jeremy Huddleston
0715469f1c XQuartz: appledri: Correct byte swapping in event notifications
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit dc054fefc5)
2011-10-28 18:31:10 -07:00
Jeremy Huddleston
bc2600466e XQuartz: applewm: Correct byte swapping in event notifications
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit d5fee2b638)
2011-10-28 18:31:05 -07:00
Jeremy Huddleston
7be5492bcf XQuartz: appledri: Allow byte swapped requests
Even though it's only valid when local, it is possible for a local
client and the server to not match endianness, such as when running
a ppc application under Rosetta.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 1c8bda798b)
2011-10-24 18:25:10 -07:00
Jeremy Huddleston
0ad049706d XQuartz: appledri: Fix byte swapping in replies
Even though it's only valid when local, it is possible for a local
client and the server to not match endianness, such as when running
a ppc application under Rosetta.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit 14205ade0c)

Conflicts:

	hw/xquartz/xpr/appledri.c

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-24 18:25:10 -07:00
Jeremy Huddleston
3b931c9276 XQuartz: appledri: Set the correct reply length for XAppleDRICreatePixmap
http://xquartz.macosforge.org/trac/ticket/508

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit 2ba0ac202a)
2011-10-24 18:16:57 -07:00
Jeremy Huddleston
f22a41416b Xnest: Match the host's keymap
This was a regression.

Introduced by: 08363c5830 and
               32db27a7f8
Masked by: 1e69fd4a60

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
(cherry picked from commit 83fef4235d)
2011-10-24 18:16:46 -07:00
Tomáš Trnka
82445286d5 Fix drain_console unregistration
Bug introduced by 9dca441670
xfree86: add a hook to replace the new console handler.

console_handler was not being set, making the server eat up CPU spinning
in WaitForSomething selecting consoleFd over and over again, every time
trying to unregister drain_console without success due to
console_handler being NULL.

Let's just fix the unregistration in xf86SetConsoleHandler() and use that.

But wait, there could be a catch: If some driver replaced the handler using
xf86SetConsoleHandler(), the unregistration in xf86CloseConsole will unregister
that one. I don't understand Xorg well enough to know whether this poses a
problem (could mess up driver deinit somehow or something like that). As it is,
xf86SetConsoleHandler() doesn't offer any way to prevent this (i.e. check which
handler is currently registered).

I had been using it for two days on my machine that previously hit 100% CPU
several times a day. That has now gone away without any new problems appearing.

Signed-off-by: Tomas Trnka <tomastrnka@gmx.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 323869f329)
2011-10-24 16:36:06 -07:00
Jesse Barnes
c8c5ed998a crtc: match full preferred modes if possible when choosing an initial config
It's fairly common to have multiple, identical monitors plugged in.  In
that case, it's preferable to run the monitor's preferred mode on each
output, rather than just matching the width & height and end up with
different timings or refresh rates.

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 3e145d3d67)
2011-10-24 10:19:15 -07:00
Ville Syrjala
d780c6f630 composite: Update borderClip in compAllocPixmap()
Previously the parent constrained borderClip was copied over
when compRedirectWindow() is called. That is insufficient eg. in
case the window was already redirected, but not yet realized. So
copy the borderClip over in compAllocPixmap() instead.

Example:
Window 1 is below an automatically redirect window 2. Window 2 is
unmapped and moved outside the extents of window 1. Window 2 is
then mapped again, and MarkOverlappedWindows() uses the up to
date borderSize of window 2 to mark windows, which leaves
window 1 unmarked. Then exposures are calculated using the stale
borderClip of window 2, which causes the window below window 2,
to be exposed through an apparent hole in window 1.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=22566

Signed-off-by: Ville Syrjala <syrjala@sci.fi>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit a5266dcb3a)
2011-10-24 10:06:26 -07:00
Matthieu Herrb
12f65819ff Fix CVE-2011-4029: File permission change vulnerability.
Use fchmod() to change permissions of the lock file instead
of chmod(), thus avoid the race that can be exploited to set
a symbolic link to any file or directory in the system.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit b67581cf82)
2011-10-18 09:25:07 -07:00
Matthieu Herrb
f80d233578 Fix CVE-2011-4028: File disclosure vulnerability.
use O_NOFOLLOW to open the existing lock file, so symbolic links
aren't followed, thus avoid revealing if it point to an existing
file.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 6ba44b91e3)
2011-10-18 09:25:07 -07:00
Jeremy Huddleston
374be44d13 configure.ac: Bump to 1.11.1.901 (1.11.2 RC1)
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-14 16:29:54 -07:00
Peter Hutterer
bbe6a69da3 dix: don't XWarpPointer through the last slave anymore (#38313)
This line was introduced pre-1.6 to fix Bug 19297. The effect of warping
through the VCP then was that if a device had custom valuator ranges, the
warp position would be wrong. The better device for this effect is the the
XTest device.

This fixes a server crash where the lastSlave is a pointer device without
valuators (Bug 38313#0).

And while we're at it, make sure the Xinerama code-path does the same.

X.Org Bug 38313 <http://bugs.freedesktop.org/show_bug.cgi?id=38313>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit 2bfb802839)
2011-10-14 15:35:33 +10:00
Nobuhiro Iwamatsu
2e28ff155f Disable check of double-aligned in test/input.c on Renesas SH
Renesas SH is not aligned at size of double.
When structure has double value, It is aligned in 4byte (long).

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit b29ce0726d)
2011-10-14 15:35:31 +10:00
Peter Hutterer
79ac611d31 dix: don't use the pointer as modifier device in UngrabKey.
Modifier device is always the keyboard.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit 8c5a4d6fbe)
2011-10-14 15:35:23 +10:00
Peter Hutterer
843737b4f9 dix: ignore devices when adding passive core grabs to list (#39545)
Passive core grabs are mostly device-independent. In an MPX scenario, they
may change to reflect whichever master pair activated the grab last. For
adding new grabs to the list, ignore the device for core grabs to return
failures when trying to set the same grab combo twice on a window.

X.Org Bug 39545 <http://bugs.freedesktop.org/show_bug.cgi?id=39545>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit 09496996ac)
2011-10-14 15:35:06 +10:00
Peter Hutterer
cb9c1d6d6c dix: avoid using the VCP as modifier device
Core grabs may change device when they're activated to reflect the master
they apply to. If the device is a keyboard, modifierDevice is erroneously
set to the Virtual Core Pointer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit 80c3704853)
2011-10-14 15:34:59 +10:00
Peter Hutterer
ef5c31430c config: fix a log message
PRODUCT was taken from the parent, hence ppath.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit e684e816ac)
2011-10-14 15:34:35 +10:00
Peter Harris
ec8ee3a9f7 xkb: add missing swaps for xkbGetDeviceInfoReply
Caught during review of e095369bf.

Signed-off-by: Peter Harris <pharris@opentext.com>
Reviewed-by-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
(cherry picked from commit c90903b4f7)

Conflicts:

	xkb/xkb.c

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-14 15:33:56 +10:00
Jeremy Huddleston
603ad6608a XQuartz: pbproxy: Add missing AM_OBJCFLAGS
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit fae7ed62ad)
2011-10-09 01:36:11 -07:00
vdb@picaros.org
65469f5ea9 Fix a rare memory leak
Signed-off-by: Servaas Vandenberghe <vdb@picaros.org>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit e4cddf509e)
2011-10-09 01:36:01 -07:00
Kirill Elagin
bec15eb73a Fix server crash due to invalid images
See https://bugs.freedesktop.org/show_bug.cgi?id=39383

Signed-off-by: Kirill Elagin <kirelagin@gmail.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 5361121339)
2011-10-09 01:35:49 -07:00
Alan Hourihane
b45e226753 dixfonts: Don't overwrite local c variable until new_closure is safely initialized.
Signed-off-by: Alan Hourihane <alanh@vmware.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 7a33c5b934)
2011-10-09 01:35:37 -07:00
Sam Spilsbury
e9ae333160 Remove the SendEvent bit (0x80) before doing range checks on event type.
Some extension libraries may set this bit before converting the event to
wire protocol and as such range checking the event will cause an invalid
BadValue error to result. As the documentation suggests the the bit
should be "forced on", remove it before doing range checks and continue
to force it on in the server.

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 2d2dce558d)
2011-10-04 20:08:33 -07:00
Carlos Garnacho
347f5610ca Xi: Fix passive XI2 ungrabs on XIAll[Master]Devices
The corresponding DeviceIntPtr wasn't being gotten properly,
resulting in BadDevice from dixLookupDevice().

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit f52d5cd374)
2011-10-04 20:08:24 -07:00
Jeremy Huddleston
7b74bb6752 XQuartz: Use set_front_process rather than X11ApplicationSetFrontProcess since we're already in the AppKit thread
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 38e9e28ba2)
2011-10-04 20:02:29 -07:00
Jamey Sharp
bd6ea85209 Fix pixmap double-frees on error paths.
If AddResource fails, it will automatically free the object that was
passed to it by calling the appropriate deleteFunc; and of course
FreeResource also calls the deleteFunc. In both cases it's wrong to call
the destroy hook manually.

Commit by Jamey Sharp and Josh Triplett.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
(cherry picked from commit 0f380a5005)
2011-10-04 19:59:27 -07:00
Jeremy Huddleston
aabd25bd0b configure.ac: Version bumped to 1.11.1
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-09-24 00:06:32 -07:00
Aaron Plattner
8988105166 fb: Rename wfbTriangles and wfbTrapezoids
These symbols were not renamed when they were added to libfb:

 # nm -D libwfb.so | grep ' fb'
 0000000000028d00 T fbTrapezoids
 0000000000028d60 T fbTriangles

This causes corruption and/or crashes on wfb-ful drivers like nvidia:

 Program received signal SIGABRT, Aborted.
 0x00007fd67f3a0405 in *__GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
 64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
     in ../nptl/sysdeps/unix/sysv/linux/raise.c
 (gdb) bt
 #0  0x00007fd67f3a0405 in *__GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
 #1  0x00007fd67f3a3680 in *__GI_abort () at abort.c:92
 #2  0x00007fd67f3995b1 in *__GI___assert_fail (assertion=0x7fd679ecb804 "key->initialized", file=<optimized out>, line=116, function=0x7fd679ecbbc0 "dixGetPrivateAddr")
     at assert.c:81
 #3  0x00007fd679ec55b6 in ?? () from /usr/lib/xorg/modules/libfb.so
 #4  0x00007fd679eca9ef in ?? () from /usr/lib/xorg/modules/libfb.so
 #5  0x00007fd679ecae20 in fbTriangles () from /usr/lib/xorg/modules/libfb.so
 #6  0x00007fd67a58fc55 in ?? () from /usr/lib/xorg/modules/drivers/nvidia_drv.so
 #7  0x00000000004f38d1 in ?? ()
 #8  0x0000000000437ae9 in ?? ()
 #9  0x0000000000426eaa in ?? ()
 #10 0x00007fd67f38cead in __libc_start_main (main=<optimized out>, argc=<optimized out>, ubp_av=<optimized out>, init=<optimized out>, fini=<optimized out>,
     rtld_fini=<optimized out>, stack_end=0x7fff99860d78) at libc-start.c:228
 #11 0x000000000042719d in _start ()

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 03d032991d)
2011-09-21 14:32:58 -07:00
2045 changed files with 452821 additions and 335419 deletions

View file

@ -1,84 +0,0 @@
branches:
except:
- /travis.*/
version: '{build}'
skip_tags: true
clone_depth: 8
environment:
APPVEYOR_SAVE_CACHE_ON_ERROR: true
CYGWIN_MIRROR: http://cygwin.mirror.constant.com
CACHE: C:\cache
matrix:
- BUILD: i686-pc-cygwin
CYGWIN_ROOT: C:\cygwin
SETUP: setup-x86.exe
- BUILD: x86_64-pc-cygwin
CYGWIN_ROOT: C:\cygwin64
SETUP: setup-x86_64.exe
install:
- echo Updating Cygwin and installing build prerequisites
- "%CYGWIN_ROOT%\\%SETUP% -qnNdO -R %CYGWIN_ROOT% -s %CYGWIN_MIRROR% -l %CACHE% -g -P \
binutils,\
bison,\
ccache,\
flex,\
gcc-core,\
meson,\
ninja,\
pkg-config,\
python38,\
windowsdriproto,\
xorgproto,\
libepoxy-devel,\
libfontenc-devel,\
libfreetype-devel,\
libGL-devel,\
libnettle-devel,\
libpixman1-devel,\
libtirpc-devel,\
libXRes-devel,\
libXaw-devel,\
libXdmcp-devel,\
libXext-devel,\
libXfont2-devel,\
libXi-devel,\
libXinerama-devel,\
libXmu-devel,\
libXpm-devel,\
libXrender-devel,\
libXtst-devel,\
libxcb-composite-devel,\
libxcb-ewmh-devel,\
libxcb-icccm-devel,\
libxcb-image-devel,\
libxcb-keysyms-devel,\
libxcb-randr-devel,\
libxcb-render-devel,\
libxcb-render-util-devel,\
libxcb-shape-devel,\
libxcb-util-devel,\
libxcb-xkb-devel,\
libxcvt-devel,\
libxkbfile-devel,\
font-util,\
khronos-opengl-registry,\
python38-lxml,\
xkbcomp-devel,\
xkeyboard-config,\
xtrans"
- echo Install done
- "%CYGWIN_ROOT%\\%SETUP% -qnNdO -R %CYGWIN_ROOT% -s %CYGWIN_MIRROR% -l %CACHE% -g"
cache:
- C:\cache
- '%CYGWIN_ROOT%\home\%USERNAME%\.ccache'
build_script:
- SET PATH=%CYGWIN_ROOT%/bin
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; meson setup --prefix=/usr -Dxv=false -Dxf86bigfont=true -Dxephyr=true -Dxnest=true -Dxvfb=true -Dxwin=true -Dxorg=true -Dpciaccess=false -Dint10=false -Dglamor=false build"'
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; meson configure build"'
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ninja -C build"'
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ccache -s"'
test_script:
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ninja -C build test"'
after_test:
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ninja -C build install"'
deploy: off

View file

@ -1 +0,0 @@
((c-mode . ((c-basic-offset . 4) (indent-tabs-mode . nil))))

View file

@ -1,24 +0,0 @@
# This file contains revisions to be ignored by git blame.
# These revisions are expected to be formatting-only changes.
#
# Calling `git blame --ignore-revs-file .git-blame-ignore-revs` will
# tell git blame to ignore changes made by these revisions when assigning
# assigning blame, as if the change never happened.
#
# You can enable this as a default for your local repository by running
# `git config blame.ignoreRevsFile .git-blame-ignore-revs`
# Important: if you do this, then switch to a branch without this file,
# `git blame` will fail with an error.
#
# Introduce a consistent coding style
9838b7032ea9792bec21af424c53c07078636d21
# Drop trailing whitespaces
732fd7e571b81d63aa44d6e4cf55883479e88f2f
# glamor: Apply x-indent.sh.
d84d71029ae9e462559d64eff7259e2cc7732fac
# indent fixes (OMG SO UGLY), and nuke old RCS keywords.
6d7083bd69724586338d79784655328f1fcd2ae5

81
.gitignore vendored
View file

@ -1,4 +1,81 @@
#
# 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
texinfo.tex
ylwrap
# Do not edit the following section
# Edit Compile Debug Document Distribute
*~ *~
*.swp *.[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
*.patch *.patch
tags *.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

366
.mailmap
View file

@ -1,366 +0,0 @@
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 <pharris2@rocketsoftware.com> <peter.harris@hummingbird.com>
Peter Harris <pharris2@rocketsoftware.com> <pharris@opentext.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>

View file

@ -1,27 +0,0 @@
language: c
cache:
ccache: true
directories:
- $HOME/Library/Caches/Homebrew
branches:
except:
- /appveyor.*/
os: osx
osx_image: xcode9.2
matrix:
include:
- env: TOOL=meson
- env: TOOL=autotools
install:
- brew update
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache meson
script:
- ./test/scripts/build-travis-osx.sh $TOOL
- ccache -s
before_cache:
- brew cleanup

29
COPYING
View file

@ -8,7 +8,6 @@ possible, and insert their name to this list. Please sort by surname
for people, and by the full name for other entities (e.g. Juliusz for people, and by the full name for other entities (e.g. Juliusz
Chroboczek sorts before Intel Corporation sorts before Daniel Stone). Chroboczek sorts before Intel Corporation sorts before Daniel Stone).
Copyright © 2011 Dave Airlie
Copyright © 2000-2001 Juliusz Chroboczek Copyright © 2000-2001 Juliusz Chroboczek
Copyright © 1998 Egbert Eich Copyright © 1998 Egbert Eich
Copyright © 2006-2007 Intel Corporation Copyright © 2006-2007 Intel Corporation
@ -16,12 +15,11 @@ Copyright © 2006 Nokia Corporation
Copyright © 2006-2008 Peter Hutterer Copyright © 2006-2008 Peter Hutterer
Copyright © 2006 Adam Jackson Copyright © 2006 Adam Jackson
Copyright © 2009-2010 NVIDIA Corporation Copyright © 2009-2010 NVIDIA Corporation
Copyright © 1987, 2003-2006, 2008-2010, 2025 Oracle and/or its affiliates. Copyright © 1987, 2003-2006, 2008-2010 Oracle and/or its affiliates.
Copyright © 1999 Keith Packard Copyright © 1999 Keith Packard
Copyright © 2007-2009 Red Hat, Inc. Copyright © 2007-2009 Red Hat, Inc.
Copyright © 2005-2008 Daniel Stone Copyright © 2005-2008 Daniel Stone
Copyright © 2006-2009 Simon Thum Copyright © 2006-2009 Simon Thum
Copyright © 2003-2008, 2013 Geert Uytterhoeven
Copyright © 2006 Luc Verhaegen Copyright © 2006 Luc Verhaegen
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -146,29 +144,6 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium. in this Software without prior written authorization from the X Consortium.
Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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, sub license, 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 NON-INFRINGEMENT.
IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
Copyright © 1999-2000 SuSE, Inc. Copyright © 1999-2000 SuSE, Inc.
Copyright © 2007 Red Hat, Inc. Copyright © 2007 Red Hat, Inc.
@ -1813,7 +1788,7 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
Copyright (c) 1987, 1990, 1993 Copyright (c) 1989, 1990, 1993, 1994
The Regents of the University of California. All rights reserved. The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by This code is derived from software contributed to Berkeley by

97
Makefile.am Normal file
View file

@ -0,0 +1,97 @@
AUTOMAKE_OPTIONS=nostdinc
ACLOCAL_AMFLAGS = -I m4
if COMPOSITE
COMPOSITE_DIR=composite
endif
if GLX
GLX_DIR=glx
endif
if DBE
DBE_DIR=dbe
endif
if RECORD
RECORD_DIR=record
endif
SUBDIRS = \
doc \
man \
include \
dix \
fb \
mi \
Xext \
miext \
os \
randr \
render \
Xi \
xkb \
$(DBE_DIR) \
$(RECORD_DIR) \
xfixes \
damageext \
$(COMPOSITE_DIR) \
$(GLX_DIR) \
exa \
config \
hw \
test
if XORG
aclocaldir = $(datadir)/aclocal
aclocal_DATA = xorg-server.m4
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-server.pc
endif
EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh
DISTCHECK_CONFIGURE_FLAGS=\
--with-xkb-path=$(XKB_BASE_DIRECTORY) \
--with-xkb-bin-directory=$(XKB_BIN_DIRECTORY) \
--with-xkb-output='$${datadir}/X11/xkb/compiled'
.PHONY: ChangeLog INSTALL
INSTALL:
$(INSTALL_CMD)
ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL
DIST_SUBDIRS = \
doc \
man \
include \
dix \
fb \
mi \
Xext \
miext \
os \
randr \
render \
Xi \
xkb \
dbe \
record \
xfixes \
damageext \
composite \
glx \
exa \
config \
hw \
test
# gross hack
relink: all
$(AM_V_at)$(MAKE) -C hw relink

38
README Normal file
View file

@ -0,0 +1,38 @@
X Server
The X server accepts requests from client applications to create windows,
which are (normally rectangular) "virtual screens" that the client program
can draw into.
Windows are then composed on the actual screen by the X server
(or by a separate composite manager) as directed by the window manager,
which usually communicates with the user via graphical controls such as buttons
and draggable titlebars and borders.
For a comprehensive overview of X Server and X Window System, consult the
following article:
http://en.wikipedia.org/wiki/X_server
All questions regarding this software should be directed at the
Xorg mailing list:
http://lists.freedesktop.org/mailman/listinfo/xorg
Please submit bug reports to the Xorg bugzilla:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
The master development code repository can be found at:
git://anongit.freedesktop.org/git/xorg/xserver
http://cgit.freedesktop.org/xorg/xserver
For patch submission instructions, see:
http://www.x.org/wiki/Development/Documentation/SubmittingPatches
For more information on the git code manager, see:
http://wiki.x.org/wiki/GitPage

View file

@ -1,41 +0,0 @@
************************************************************************
* This is the now defunct 'master' branch of the xserver repository. *
* Ongoing development has moved to the 'main' branch instead. *
************************************************************************
X Server
--------
The X server accepts requests from client applications to create windows,
which are (normally rectangular) "virtual screens" that the client program
can draw into.
Windows are then composed on the actual screen by the X server
(or by a separate composite manager) as directed by the window manager,
which usually communicates with the user via graphical controls such as buttons
and draggable titlebars and borders.
For a comprehensive overview of X Server and X Window System, consult the
following article:
https://en.wikipedia.org/wiki/X_server
All questions regarding this software should be directed at the
Xorg mailing list:
https://lists.freedesktop.org/mailman/listinfo/xorg
The primary development code repository can be found at:
https://gitlab.freedesktop.org/xorg/xserver
For patch submission instructions, see:
https://www.x.org/wiki/Development/Documentation/SubmittingPatches
As with other projects hosted on freedesktop.org, X.Org follows its
Code of Conduct, based on the Contributor Covenant. Please conduct
yourself in a respectful and civilized manner when using the above
mailing lists, bug trackers, etc:
https://www.freedesktop.org/wiki/CodeOfConduct

View file

@ -1,50 +0,0 @@
# Reporting Security Issues
Please notify us of any security issues by sending mail to
<xorg-security@lists.x.org>.
See https://www.x.org/wiki/Development/Security/Organization/
for more information about the X.Org security team.
# Learning about Security Fixes
X.Org announces security bugs and bug fix releases on the xorg-announce
mailing list. See the archives at https://lists.x.org/archives/xorg-announce/
and see https://lists.x.org/mailman/listinfo/xorg-announce to subscribe.
Security advisories are also listed on our wiki at
https://www.x.org/wiki/Development/Security/ and mailed to the
https://oss-security.openwall.org/wiki/mailing-lists/oss-security mailing list.
# Security model and trust boundaries
Only the Xorg server is expected to run with elevated privileges.
(Some distros may run Xorg with a wrapper to only grant these privileges when
necessary.) The Xorg server usually requires root access to hardware devices
and I/O registers when using a UMS (Userspace Mode Setting) driver, and not
when using a KMS (Kernel Mode Setting) driver, or drivers which do not require
actual hardware access (such as xf86-video-dummy).
All other X servers (Xephyr, Xnest, Xvfb, etc.) are expected to run with only
the privileges of the user who started the server. They should not require
direct access to any devices.
The Xorg server uses configuration files to control various aspects of its
operation (see the xorg.conf(5) man page), including specifying loadable
object modules to run code from with the full privileges of the X server.
There is no attempt to sandbox these modules - they are considered to be fully
trusted, and thus anyone who can edit a config file is considered to be fully
trusted - a module being able to control or crash the X server is not considered
a security vulnerability (though a crash would be a non-security bug in the
module). The configuration file loading mechanism takes steps to verify that
config files are owned by trusted users before reading them, and failure to do
so would be considered a security vulnerability.
Access control for which clients can connect to the X server is provided by
a number of mechanisms, see the Xsecurity(7) man page for details. Once a
client is authenticated via those mechanisms and has an active connection,
we do not consider it a security vulnerability for them to be able to take
any actions described in the X11 protocol or extension specifications, such
as changing monitor configurations or killing other clients, though we will
accept non-security bug reports for clients doing so in a manner or via
requests not documented in the protocol specs as doing those operations.

133
Xext/Makefile.am Normal file
View file

@ -0,0 +1,133 @@
# libXext.la: includes all extensions and should be linked into Xvfb,
# Xnest, Xdmx and Xprt
# libXextbuiltin.la: includes those extensions that are built directly into
# Xorg by default
# libXextmodule.la: includes those extensions that are built into a module
# that Xorg loads
if XORG
noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la
else
noinst_LTLIBRARIES = libXext.la
endif
INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod
AM_CFLAGS = $(DIX_CFLAGS)
if XORG
sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h syncsdk.h
endif
# Sources always included in libXextbuiltin.la & libXext.la
BUILTIN_SRCS = \
bigreq.c \
geext.c \
shape.c \
sleepuntil.c \
sleepuntil.h \
sync.c \
syncsdk.h \
syncsrv.h \
xcmisc.c \
xtest.c
# Sources always included in libXextmodule.la & libXext.la. That's right, zero.
MODULE_SRCS =
MODULE_LIBS =
# Optional sources included if extension enabled by configure.ac rules
# MIT Shared Memory extension
MITSHM_SRCS = shm.c shmint.h
if MITSHM
BUILTIN_SRCS += $(MITSHM_SRCS)
endif
# XVideo extension
XV_SRCS = xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h
if XV
MODULE_SRCS += $(XV_SRCS)
endif
# XResource extension: lets clients get data about per-client resource usage
RES_SRCS = xres.c
if RES
MODULE_SRCS += $(RES_SRCS)
endif
# MIT ScreenSaver extension
SCREENSAVER_SRCS = saver.c
if SCREENSAVER
MODULE_SRCS += $(SCREENSAVER_SRCS)
endif
# Xinerama extension: making multiple video devices act as one virtual screen
XINERAMA_SRCS = panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c
if XINERAMA
BUILTIN_SRCS += $(XINERAMA_SRCS)
if XORG
sdk_HEADERS += panoramiXsrv.h panoramiX.h
endif
endif
# X-ACE extension: provides hooks for building security policy extensions
# like XC-Security, X-SELinux & XTSol
XACE_SRCS = xace.c xace.h xacestr.h
if XACE
BUILTIN_SRCS += $(XACE_SRCS)
if XORG
sdk_HEADERS += xace.h xacestr.h
endif
endif
# SELinux extension: provides SELinux policy support for X objects
# requires X-ACE extension
XSELINUX_SRCS = xselinux_ext.c xselinux_hooks.c xselinux_label.c xselinux.h xselinuxint.h
if XSELINUX
MODULE_SRCS += $(XSELINUX_SRCS)
MODULE_LIBS += $(SELINUX_LIBS)
endif
# Security extension: multi-level security to protect clients from each other
XCSECURITY_SRCS = security.c securitysrv.h
if XCSECURITY
BUILTIN_SRCS += $(XCSECURITY_SRCS)
endif
# XF86 Big Font extension
BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h
if XF86BIGFONT
BUILTIN_SRCS += $(BIGFONT_SRCS)
endif
# DPMS extension
DPMS_SRCS = dpms.c dpmsproc.h
if DPMSExtension
MODULE_SRCS += $(DPMS_SRCS)
endif
# Now take all of the above, mix well, bake for 10 minutes and get libXext*.la
libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS)
libXext_la_LIBADD = $(MODULE_LIBS)
if XORG
libXextbuiltin_la_SOURCES = $(BUILTIN_SRCS)
libXextmodule_la_SOURCES = $(MODULE_SRCS)
libXextmodule_la_LIBADD = $(MODULE_LIBS)
endif
EXTRA_DIST = \
$(MITSHM_SRCS) \
$(XV_SRCS) \
$(RES_SRCS) \
$(SCREENSAVER_SRCS) \
$(XACE_SRCS) \
$(XCSECURITY_SRCS) \
$(XSELINUX_SRCS) \
$(XINERAMA_SRCS) \
$(BIGFONT_SRCS) \
$(DPMS_SRCS) \
$(GE_SRCS)

View file

@ -26,47 +26,53 @@ from The Open Group.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "dix_priv.h"
#include "extnsionst.h" #include "extnsionst.h"
#include <X11/extensions/bigreqsproto.h> #include <X11/extensions/bigreqsproto.h>
#include "opaque.h" #include "opaque.h"
#include "extinit_priv.h" #include "modinit.h"
void BigReqExtensionInit(INITARGS);
static int static int
ProcBigReqDispatch(ClientPtr client) ProcBigReqDispatch (ClientPtr client)
{ {
REQUEST(xBigReqEnableReq); REQUEST(xBigReqEnableReq);
xBigReqEnableReply rep; xBigReqEnableReply rep;
int n;
if (client->swapped) {
swaps(&stuff->length, n);
}
if (stuff->brReqType != X_BigReqEnable) if (stuff->brReqType != X_BigReqEnable)
return BadRequest; return BadRequest;
REQUEST_SIZE_MATCH(xBigReqEnableReq); REQUEST_SIZE_MATCH(xBigReqEnableReq);
client->big_requests = TRUE; client->big_requests = TRUE;
rep = (xBigReqEnableReply) { memset(&rep, 0, sizeof(xBigReqEnableReply));
.type = X_Reply, rep.type = X_Reply;
.sequenceNumber = client->sequence, rep.length = 0;
.length = 0, rep.sequenceNumber = client->sequence;
.max_request_size = maxBigRequestSize rep.max_request_size = maxBigRequestSize;
};
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swapl(&rep.max_request_size); swapl(&rep.max_request_size, n);
} }
WriteToClient(client, sizeof(xBigReqEnableReply), &rep); WriteToClient(client, sizeof(xBigReqEnableReply), (char *)&rep);
return Success; return Success;
} }
void void
BigReqExtensionInit(void) BigReqExtensionInit(INITARGS)
{ {
AddExtension(XBigReqExtensionName, 0, 0, AddExtension(XBigReqExtensionName, 0, 0,
ProcBigReqDispatch, ProcBigReqDispatch, ProcBigReqDispatch, ProcBigReqDispatch,
NULL, StandardMinorOpcode); NULL, StandardMinorOpcode);
} }

View file

@ -14,26 +14,24 @@ all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 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. IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Digital Equipment Corporation Except as contained in this notice, the name of Digital Equipment Corporation
shall not be used in advertising or otherwise to promote the sale, use or other shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from Digital dealings in this Software without prior written authorization from Digital
Equipment Corporation. Equipment Corporation.
******************************************************************/ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include "os/screensaver.h"
#include "Xext/geext.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
@ -41,276 +39,28 @@ Equipment Corporation.
#include "opaque.h" #include "opaque.h"
#include <X11/extensions/dpmsproto.h> #include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h" #include "dpmsproc.h"
#include "extinit_priv.h" #include "modinit.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "protocol-versions.h"
CARD16 DPMSPowerLevel = 0;
Bool DPMSDisabledSwitch = FALSE;
CARD32 DPMSStandbyTime = -1;
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)
{
int i;
/* For each screen, check if DPMS is supported */
for (i = 0; i < screenInfo.numScreens; i++)
if (screenInfo.screens[i]->DPMS != NULL)
return TRUE;
for (i = 0; i < screenInfo.numGPUScreens; i++)
if (screenInfo.gpuscreens[i]->DPMS != NULL)
return TRUE;
return FALSE;
}
static Bool
isUnblank(int mode)
{
switch (mode) {
case SCREEN_SAVER_OFF:
case SCREEN_SAVER_FORCER:
return TRUE;
case SCREEN_SAVER_ON:
case SCREEN_SAVER_CYCLE:
return FALSE;
default:
return TRUE;
}
}
int
DPMSSet(ClientPtr client, int level)
{
int rc, i;
int old_level = DPMSPowerLevel;
DPMSPowerLevel = level;
if (level != DPMSModeOn) {
if (isUnblank(screenIsSaved)) {
rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
if (rc != Success)
return rc;
}
} else if (!isUnblank(screenIsSaved)) {
rc = dixSaveScreens(client, SCREEN_SAVER_OFF, ScreenSaverReset);
if (rc != Success)
return rc;
}
for (i = 0; i < screenInfo.numScreens; i++)
if (screenInfo.screens[i]->DPMS != NULL)
screenInfo.screens[i]->DPMS(screenInfo.screens[i], level);
for (i = 0; i < screenInfo.numGPUScreens; i++)
if (screenInfo.gpuscreens[i]->DPMS != NULL)
screenInfo.gpuscreens[i]->DPMS(screenInfo.gpuscreens[i], level);
if (DPMSPowerLevel != old_level)
SendDPMSInfoNotify();
return Success;
}
static int static int
ProcDPMSGetVersion(ClientPtr client) ProcDPMSGetVersion(ClientPtr client)
{ {
/* REQUEST(xDPMSGetVersionReq); */ /* REQUEST(xDPMSGetVersionReq); */
xDPMSGetVersionReply rep = { xDPMSGetVersionReply rep;
.type = X_Reply, int n;
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_DPMS_MAJOR_VERSION,
.minorVersion = SERVER_DPMS_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xDPMSGetVersionReq); REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = DPMSMajorVersion;
rep.minorVersion = DPMSMinorVersion;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swaps(&rep.majorVersion); swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion); swaps(&rep.minorVersion, n);
} }
WriteToClient(client, sizeof(xDPMSGetVersionReply), &rep); WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *)&rep);
return Success; return Success;
} }
@ -318,19 +68,20 @@ static int
ProcDPMSCapable(ClientPtr client) ProcDPMSCapable(ClientPtr client)
{ {
/* REQUEST(xDPMSCapableReq); */ /* REQUEST(xDPMSCapableReq); */
xDPMSCapableReply rep = { xDPMSCapableReply rep;
.type = X_Reply, int n;
.sequenceNumber = client->sequence,
.length = 0,
.capable = TRUE
};
REQUEST_SIZE_MATCH(xDPMSCapableReq); REQUEST_SIZE_MATCH(xDPMSCapableReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.capable = DPMSCapableFlag;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
} }
WriteToClient(client, sizeof(xDPMSCapableReply), &rep); WriteToClient(client, sizeof(xDPMSCapableReply), (char *)&rep);
return Success; return Success;
} }
@ -338,24 +89,25 @@ static int
ProcDPMSGetTimeouts(ClientPtr client) ProcDPMSGetTimeouts(ClientPtr client)
{ {
/* REQUEST(xDPMSGetTimeoutsReq); */ /* REQUEST(xDPMSGetTimeoutsReq); */
xDPMSGetTimeoutsReply rep = { xDPMSGetTimeoutsReply rep;
.type = X_Reply, int n;
.sequenceNumber = client->sequence,
.length = 0,
.standby = DPMSStandbyTime / MILLI_PER_SECOND,
.suspend = DPMSSuspendTime / MILLI_PER_SECOND,
.off = DPMSOffTime / MILLI_PER_SECOND
};
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq); REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.standby = DPMSStandbyTime / MILLI_PER_SECOND;
rep.suspend = DPMSSuspendTime / MILLI_PER_SECOND;
rep.off = DPMSOffTime / MILLI_PER_SECOND;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swaps(&rep.standby); swaps(&rep.standby, n);
swaps(&rep.suspend); swaps(&rep.suspend, n);
swaps(&rep.off); swaps(&rep.off, n);
} }
WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), &rep); WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *)&rep);
return Success; return Success;
} }
@ -366,14 +118,16 @@ ProcDPMSSetTimeouts(ClientPtr client)
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
if ((stuff->off != 0) && (stuff->off < stuff->suspend)) { if ((stuff->off != 0)&&(stuff->off < stuff->suspend))
client->errorValue = stuff->off; {
return BadValue; client->errorValue = stuff->off;
} return BadValue;
if ((stuff->suspend != 0) && (stuff->suspend < stuff->standby)) {
client->errorValue = stuff->suspend;
return BadValue;
} }
if ((stuff->suspend != 0)&&(stuff->suspend < stuff->standby))
{
client->errorValue = stuff->suspend;
return BadValue;
}
DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND; DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND;
DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND; DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND;
@ -390,10 +144,10 @@ ProcDPMSEnable(ClientPtr client)
REQUEST_SIZE_MATCH(xDPMSEnableReq); REQUEST_SIZE_MATCH(xDPMSEnableReq);
DPMSEnabled = TRUE; if (DPMSCapableFlag) {
if (!was_enabled) { DPMSEnabled = TRUE;
SetScreenSaverTimer(); if (!was_enabled)
SendDPMSInfoNotify(); SetScreenSaverTimer();
} }
return Success; return Success;
@ -402,8 +156,6 @@ ProcDPMSEnable(ClientPtr client)
static int static int
ProcDPMSDisable(ClientPtr client) ProcDPMSDisable(ClientPtr client)
{ {
Bool was_enabled = DPMSEnabled;
/* REQUEST(xDPMSDisableReq); */ /* REQUEST(xDPMSDisableReq); */
REQUEST_SIZE_MATCH(xDPMSDisableReq); REQUEST_SIZE_MATCH(xDPMSDisableReq);
@ -411,8 +163,6 @@ ProcDPMSDisable(ClientPtr client)
DPMSSet(client, DPMSModeOn); DPMSSet(client, DPMSModeOn);
DPMSEnabled = FALSE; DPMSEnabled = FALSE;
if (was_enabled)
SendDPMSInfoNotify();
return Success; return Success;
} }
@ -425,13 +175,14 @@ ProcDPMSForceLevel(ClientPtr client)
REQUEST_SIZE_MATCH(xDPMSForceLevelReq); REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
if (!DPMSEnabled) if (!DPMSEnabled)
return BadMatch; return BadMatch;
if (stuff->level != DPMSModeOn && if (stuff->level != DPMSModeOn &&
stuff->level != DPMSModeStandby && stuff->level != DPMSModeStandby &&
stuff->level != DPMSModeSuspend && stuff->level != DPMSModeOff) { stuff->level != DPMSModeSuspend &&
client->errorValue = stuff->level; stuff->level != DPMSModeOff) {
return BadValue; client->errorValue = stuff->level;
return BadValue;
} }
DPMSSet(client, stuff->level); DPMSSet(client, stuff->level);
@ -443,157 +194,186 @@ static int
ProcDPMSInfo(ClientPtr client) ProcDPMSInfo(ClientPtr client)
{ {
/* REQUEST(xDPMSInfoReq); */ /* REQUEST(xDPMSInfoReq); */
xDPMSInfoReply rep = { xDPMSInfoReply rep;
.type = X_Reply, int n;
.sequenceNumber = client->sequence,
.length = 0,
.power_level = DPMSPowerLevel,
.state = DPMSEnabled
};
REQUEST_SIZE_MATCH(xDPMSInfoReq); REQUEST_SIZE_MATCH(xDPMSInfoReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.power_level = DPMSPowerLevel;
rep.state = DPMSEnabled;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swaps(&rep.power_level); swaps(&rep.power_level, n);
} }
WriteToClient(client, sizeof(xDPMSInfoReply), &rep); WriteToClient(client, sizeof(xDPMSInfoReply), (char *)&rep);
return Success; return Success;
} }
static int static int
ProcDPMSDispatch(ClientPtr client) ProcDPMSDispatch (ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data)
{
case X_DPMSGetVersion: case X_DPMSGetVersion:
return ProcDPMSGetVersion(client); return ProcDPMSGetVersion(client);
case X_DPMSCapable: case X_DPMSCapable:
return ProcDPMSCapable(client); return ProcDPMSCapable(client);
case X_DPMSGetTimeouts: case X_DPMSGetTimeouts:
return ProcDPMSGetTimeouts(client); return ProcDPMSGetTimeouts(client);
case X_DPMSSetTimeouts: case X_DPMSSetTimeouts:
return ProcDPMSSetTimeouts(client); return ProcDPMSSetTimeouts(client);
case X_DPMSEnable: case X_DPMSEnable:
return ProcDPMSEnable(client); return ProcDPMSEnable(client);
case X_DPMSDisable: case X_DPMSDisable:
return ProcDPMSDisable(client); return ProcDPMSDisable(client);
case X_DPMSForceLevel: case X_DPMSForceLevel:
return ProcDPMSForceLevel(client); return ProcDPMSForceLevel(client);
case X_DPMSInfo: case X_DPMSInfo:
return ProcDPMSInfo(client); return ProcDPMSInfo(client);
case X_DPMSSelectInput:
return ProcDPMSSelectInput(client);
default: default:
return BadRequest; return BadRequest;
} }
} }
static int _X_COLD static int
SProcDPMSGetVersion(ClientPtr client) SProcDPMSGetVersion(ClientPtr client)
{ {
int n;
REQUEST(xDPMSGetVersionReq); REQUEST(xDPMSGetVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSGetVersionReq); REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion, n);
return ProcDPMSGetVersion(client); return ProcDPMSGetVersion(client);
} }
static int _X_COLD static int
SProcDPMSCapable(ClientPtr client)
{
REQUEST(xDPMSCapableReq);
int n;
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSCapableReq);
return ProcDPMSCapable(client);
}
static int
SProcDPMSGetTimeouts(ClientPtr client)
{
REQUEST(xDPMSGetTimeoutsReq);
int n;
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
return ProcDPMSGetTimeouts(client);
}
static int
SProcDPMSSetTimeouts(ClientPtr client) SProcDPMSSetTimeouts(ClientPtr client)
{ {
REQUEST(xDPMSSetTimeoutsReq); REQUEST(xDPMSSetTimeoutsReq);
int n;
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
swaps(&stuff->standby); swaps(&stuff->standby, n);
swaps(&stuff->suspend); swaps(&stuff->suspend, n);
swaps(&stuff->off); swaps(&stuff->off, n);
return ProcDPMSSetTimeouts(client); return ProcDPMSSetTimeouts(client);
} }
static int _X_COLD static int
SProcDPMSEnable(ClientPtr client)
{
REQUEST(xDPMSEnableReq);
int n;
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSEnableReq);
return ProcDPMSEnable(client);
}
static int
SProcDPMSDisable(ClientPtr client)
{
REQUEST(xDPMSDisableReq);
int n;
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSDisableReq);
return ProcDPMSDisable(client);
}
static int
SProcDPMSForceLevel(ClientPtr client) SProcDPMSForceLevel(ClientPtr client)
{ {
REQUEST(xDPMSForceLevelReq); REQUEST(xDPMSForceLevelReq);
int n;
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq); REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
swaps(&stuff->level); swaps(&stuff->level, n);
return ProcDPMSForceLevel(client); return ProcDPMSForceLevel(client);
} }
static int _X_COLD static int
SProcDPMSSelectInput(ClientPtr client) SProcDPMSInfo(ClientPtr client)
{ {
REQUEST(xDPMSSelectInputReq); REQUEST(xDPMSInfoReq);
REQUEST_SIZE_MATCH(xDPMSSelectInputReq); int n;
swapl(&stuff->eventMask);
return ProcDPMSSelectInput(client); swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSInfoReq);
return ProcDPMSInfo(client);
} }
static int
SProcDPMSDispatch (ClientPtr client)
static int _X_COLD
SProcDPMSDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data)
{
case X_DPMSGetVersion: case X_DPMSGetVersion:
return SProcDPMSGetVersion(client); return SProcDPMSGetVersion(client);
case X_DPMSCapable: case X_DPMSCapable:
return ProcDPMSCapable(client); return SProcDPMSCapable(client);
case X_DPMSGetTimeouts: case X_DPMSGetTimeouts:
return ProcDPMSGetTimeouts(client); return SProcDPMSGetTimeouts(client);
case X_DPMSSetTimeouts: case X_DPMSSetTimeouts:
return SProcDPMSSetTimeouts(client); return SProcDPMSSetTimeouts(client);
case X_DPMSEnable: case X_DPMSEnable:
return ProcDPMSEnable(client); return SProcDPMSEnable(client);
case X_DPMSDisable: case X_DPMSDisable:
return ProcDPMSDisable(client); return SProcDPMSDisable(client);
case X_DPMSForceLevel: case X_DPMSForceLevel:
return SProcDPMSForceLevel(client); return SProcDPMSForceLevel(client);
case X_DPMSInfo: case X_DPMSInfo:
return ProcDPMSInfo(client); return SProcDPMSInfo(client);
case X_DPMSSelectInput:
return SProcDPMSSelectInput(client);
default: default:
return BadRequest; return BadRequest;
} }
} }
static void
DPMSCloseDownExtension(ExtensionEntry *e)
{
DPMSSet(serverClient, DPMSModeOn);
}
void void
DPMSExtensionInit(void) DPMSExtensionInit(INITARGS)
{ {
ExtensionEntry *extEntry; AddExtension(DPMSExtensionName, 0, 0,
ProcDPMSDispatch, SProcDPMSDispatch,
#define CONDITIONALLY_SET_DPMS_TIMEOUT(_timeout_value_) \ NULL, StandardMinorOpcode);
if (_timeout_value_ == -1) { /* not yet set from config */ \
_timeout_value_ = ScreenSaverTime; \
}
CONDITIONALLY_SET_DPMS_TIMEOUT(DPMSStandbyTime)
CONDITIONALLY_SET_DPMS_TIMEOUT(DPMSSuspendTime)
CONDITIONALLY_SET_DPMS_TIMEOUT(DPMSOffTime)
DPMSPowerLevel = DPMSModeOn;
DPMSEnabled = DPMSSupported();
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);
}
} }

View file

@ -9,14 +9,7 @@
#include "dixstruct.h" #include "dixstruct.h"
extern int DPMSSet(ClientPtr client, int level); int DPMSSet(ClientPtr client, int level);
extern Bool DPMSSupported(void); Bool DPMSSupported(void);
extern CARD32 DPMSStandbyTime;
extern CARD32 DPMSSuspendTime;
extern CARD32 DPMSOffTime;
extern CARD16 DPMSPowerLevel;
extern Bool DPMSEnabled;
extern Bool DPMSDisabledSwitch;
#endif #endif

45
Xext/dpmsstubs.c Normal file
View file

@ -0,0 +1,45 @@
/*****************************************************************
Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from Digital
Equipment Corporation.
******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "dpmsproc.h"
#define FALSE 0
Bool DPMSSupported(void)
{
return FALSE;
}
int DPMSSet(ClientPtr client, int level)
{
return Success;
}

View file

@ -23,36 +23,32 @@
* Author: Peter Hutterer, University of South Australia, NICTA * Author: Peter Hutterer, University of South Australia, NICTA
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "windowstr.h" #include "windowstr.h"
#include <X11/extensions/ge.h> #include <X11/extensions/ge.h>
#include "geint.h"
#include "geext.h" #include "geext.h"
#include "protocol-versions.h" #include "protocol-versions.h"
#include "extinit_priv.h"
DevPrivateKeyRec GEClientPrivateKeyRec; DevPrivateKeyRec GEClientPrivateKeyRec;
#define GEClientPrivateKey (&GEClientPrivateKeyRec) int RT_GECLIENT = 0;
/** Struct to keep information about registered extensions */ GEExtension GEExtensions[MAXEXTENSIONS];
typedef struct _GEExtension {
/** Event swapping routine */
void (*evswap) (xGenericEvent *from, xGenericEvent *to);
} GEExtension, *GEExtensionPtr;
static GEExtension GEExtensions[MAXEXTENSIONS]; /* Major available requests */
static const int version_requests[] = {
typedef struct _GEClientInfo { X_GEQueryVersion, /* before client sends QueryVersion */
CARD32 major_version; X_GEQueryVersion, /* must be set to last request in version 1 */
CARD32 minor_version; };
} GEClientInfoRec, *GEClientInfoPtr;
#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey)))
/* Forward declarations */ /* Forward declarations */
static void SGEGenericEvent(xEvent *from, xEvent *to); static void SGEGenericEvent(xEvent* from, xEvent* to);
#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
#define EXT_MASK(ext) ((ext) & 0x7F) #define EXT_MASK(ext) ((ext) & 0x7F)
/************************************************************/ /************************************************************/
@ -62,52 +58,65 @@ static void SGEGenericEvent(xEvent *from, xEvent *to);
static int static int
ProcGEQueryVersion(ClientPtr client) ProcGEQueryVersion(ClientPtr client)
{ {
int n;
GEClientInfoPtr pGEClient = GEGetClient(client); GEClientInfoPtr pGEClient = GEGetClient(client);
xGEQueryVersionReply rep; xGEQueryVersionReply rep;
REQUEST(xGEQueryVersionReq); REQUEST(xGEQueryVersionReq);
REQUEST_SIZE_MATCH(xGEQueryVersionReq); REQUEST_SIZE_MATCH(xGEQueryVersionReq);
rep = (xGEQueryVersionReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GEQueryVersion;
.RepType = X_GEQueryVersion, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0,
/* return the supported version by the server */ /* return the supported version by the server */
.majorVersion = SERVER_GE_MAJOR_VERSION, rep.majorVersion = SERVER_GE_MAJOR_VERSION;
.minorVersion = SERVER_GE_MINOR_VERSION rep.minorVersion = SERVER_GE_MINOR_VERSION;
};
/* Remember version the client requested */ /* Remember version the client requested */
pGEClient->major_version = stuff->majorVersion; pGEClient->major_version = stuff->majorVersion;
pGEClient->minor_version = stuff->minorVersion; pGEClient->minor_version = stuff->minorVersion;
if (client->swapped) { if (client->swapped)
swaps(&rep.sequenceNumber); {
swapl(&rep.length); swaps(&rep.sequenceNumber, n);
swaps(&rep.majorVersion); swapl(&rep.length, n);
swaps(&rep.minorVersion); swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
} }
WriteToClient(client, sizeof(xGEQueryVersionReply), &rep); WriteToClient(client, sizeof(xGEQueryVersionReply), (char*)&rep);
return Success; return Success;
} }
int (*ProcGEVector[GENumberRequests])(ClientPtr) = {
/* Version 1.0 */
ProcGEQueryVersion
};
/************************************************************/ /************************************************************/
/* swapped request handlers */ /* swapped request handlers */
/************************************************************/ /************************************************************/
static int _X_COLD static int
SProcGEQueryVersion(ClientPtr client) SProcGEQueryVersion(ClientPtr client)
{ {
int n;
REQUEST(xGEQueryVersionReq); REQUEST(xGEQueryVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGEQueryVersionReq); REQUEST_SIZE_MATCH(xGEQueryVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion, n);
return ProcGEQueryVersion(client); return(*ProcGEVector[stuff->ReqType])(client);
} }
int (*SProcGEVector[GENumberRequests])(ClientPtr) = {
/* Version 1.0 */
SProcGEQueryVersion
};
/************************************************************/ /************************************************************/
/* callbacks */ /* callbacks */
/************************************************************/ /************************************************************/
@ -116,35 +125,51 @@ SProcGEQueryVersion(ClientPtr client)
static int static int
ProcGEDispatch(ClientPtr client) ProcGEDispatch(ClientPtr client)
{ {
REQUEST(xReq); GEClientInfoPtr pGEClient = GEGetClient(client);
REQUEST(xGEReq);
switch (stuff->data) { if (pGEClient->major_version >= NUM_VERSION_REQUESTS)
case X_GEQueryVersion:
return ProcGEQueryVersion(client);
default:
return BadRequest; return BadRequest;
} if (stuff->ReqType > version_requests[pGEClient->major_version])
return BadRequest;
return (ProcGEVector[stuff->ReqType])(client);
} }
/* dispatch swapped requests */ /* dispatch swapped requests */
static int _X_COLD static int
SProcGEDispatch(ClientPtr client) SProcGEDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xGEReq);
swaps(&stuff->length); if (stuff->ReqType >= GENumberRequests)
switch (stuff->data) {
case X_GEQueryVersion:
return SProcGEQueryVersion(client);
default:
return BadRequest; return BadRequest;
} return (*SProcGEVector[stuff->ReqType])(client);
}
/**
* Called when a new client inits a connection to the X server.
*
* We alloc a simple struct to store the client's major/minor version. Can be
* used in the furture for versioning support.
*/
static void
GEClientCallback(CallbackListPtr *list,
pointer closure,
pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
GEClientInfoPtr pGEClient = GEGetClient(pClient);
pGEClient->major_version = 0;
pGEClient->minor_version = 0;
} }
/* Reset extension. Called on server shutdown. */ /* Reset extension. Called on server shutdown. */
static void static void
GEResetProc(ExtensionEntry * extEntry) GEResetProc(ExtensionEntry *extEntry)
{ {
DeleteCallback(&ClientStateCallback, GEClientCallback, 0);
EventSwapVector[GenericEvent] = NotImplemented; EventSwapVector[GenericEvent] = NotImplemented;
} }
@ -155,13 +180,14 @@ GEResetProc(ExtensionEntry * extEntry)
* written on the wire, this one calls the registered swap function to do the * written on the wire, this one calls the registered swap function to do the
* work. * work.
*/ */
static void _X_COLD static void
SGEGenericEvent(xEvent *from, xEvent *to) SGEGenericEvent(xEvent* from, xEvent* to)
{ {
xGenericEvent *gefrom = (xGenericEvent *) from; xGenericEvent* gefrom = (xGenericEvent*)from;
xGenericEvent *geto = (xGenericEvent *) to; xGenericEvent* geto = (xGenericEvent*)to;
if ((gefrom->extension & 0x7f) > MAXEXTENSIONS) { if ((gefrom->extension & 0x7f) > MAXEXTENSIONS)
{
ErrorF("GE: Invalid extension offset for event.\n"); ErrorF("GE: Invalid extension offset for event.\n");
return; return;
} }
@ -177,16 +203,28 @@ SGEGenericEvent(xEvent *from, xEvent *to)
void void
GEExtensionInit(void) GEExtensionInit(void)
{ {
if (!dixRegisterPrivateKey ExtensionEntry *extEntry;
(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
if (!dixRegisterPrivateKey(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n"); FatalError("GEExtensionInit: GE private request failed.\n");
if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, SProcGEDispatch, if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))
GEResetProc, StandardMinorOpcode)) {
FatalError("GEInit: AddExtensions failed.\n"); FatalError("GEExtensionInit: register client callback failed.\n");
}
if((extEntry = AddExtension(GE_NAME,
0, GENumberErrors,
ProcGEDispatch, SProcGEDispatch,
GEResetProc, StandardMinorOpcode)) != 0)
{
memset(GEExtensions, 0, sizeof(GEExtensions));
EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent;
} else {
FatalError("GEInit: AddExtensions failed.\n");
}
memset(GEExtensions, 0, sizeof(GEExtensions));
EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent;
} }
/************************************************************/ /************************************************************/
@ -202,22 +240,24 @@ GEExtensionInit(void)
*/ */
void void
GERegisterExtension(int extension, GERegisterExtension(int extension,
void (*ev_swap) (xGenericEvent *from, xGenericEvent *to)) void (*ev_swap)(xGenericEvent* from, xGenericEvent* to))
{ {
if (EXT_MASK(extension) >= MAXEXTENSIONS) if (EXT_MASK(extension) >= MAXEXTENSIONS)
FatalError("GE: extension > MAXEXTENSIONS. This should not happen.\n"); FatalError("GE: extension > MAXEXTENSIONS. This should not happen.\n");
/* extension opcodes are > 128, might as well save some space here */ /* extension opcodes are > 128, might as well save some space here */
GEExtensions[EXT_MASK(extension)].evswap = ev_swap; GEExtensions[EXT_MASK(extension)].evswap = ev_swap;
} }
/* Sets type and extension field for a generic event. This is just an /* Sets type and extension field for a generic event. This is just an
* auxiliary function, extensions could do it manually too. * auxiliary function, extensions could do it manually too.
*/ */
void void
GEInitEvent(xGenericEvent *ev, int extension) GEInitEvent(xGenericEvent* ev, int extension)
{ {
ev->type = GenericEvent; ev->type = GenericEvent;
ev->extension = extension; ev->extension = extension;
ev->length = 0; ev->length = 0;
} }

View file

@ -25,19 +25,59 @@ other dealings in this Software without prior written authorization
from the author. from the author.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _GEEXT_H_ #ifndef _GEEXT_H_
#define _GEEXT_H_ #define _GEEXT_H_
#include <X11/Xfuncproto.h>
#include <X11/extensions/geproto.h> #include <X11/extensions/geproto.h>
/** Struct to keep information about registered extensions */
typedef struct _GEExtension {
/** Event swapping routine */
void (*evswap)(xGenericEvent* from, xGenericEvent* to);
} GEExtension, *GEExtensionPtr;
/* All registered extensions and their handling functions. */
extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS];
/* Typecast to generic event */
#define GEV(ev) ((xGenericEvent*)(ev))
/* Returns the extension offset from the event */
#define GEEXT(ev) (GEV(ev)->extension)
/* Return zero-based extension offset (offset - 128). Only for use in arrays */
#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F)
/* True if mask is set for extension on window */
#define GEMaskIsSet(pWin, extension, mask) \
((pWin)->optional && \
(pWin)->optional->geMasks && \
((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask)))
/* Returns first client */
#define GECLIENT(pWin) \
(((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL)
/* Returns the event_fill for the given event */
#define GEEventFill(ev) \
GEExtensions[GEEXTIDX(ev)].evfill
#define GEIsType(ev, ext, ev_type) \
((GEV(ev)->type == GenericEvent) && \
GEEXT(ev) == (ext) && \
GEV(ev)->evtype == (ev_type))
/* Interface for other extensions */ /* Interface for other extensions */
extern _X_EXPORT void GERegisterExtension(int extension, extern _X_EXPORT void GERegisterExtension(
void (*ev_dispatch) (xGenericEvent int extension,
*from, void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to));
xGenericEvent
*to));
extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension); extern _X_EXPORT void GEInitEvent(xGenericEvent* ev, int extension);
#endif /* _GEEXT_H_ */ extern _X_EXPORT void GEExtensionInit(void);
#endif /* _GEEXT_H_ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright © 2011 Daniel Stone * Copyright 2007-2008 Peter Hutterer
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -20,36 +20,34 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
* *
* Author: Daniel Stone <daniel@fooishbar.org> * Author: Peter Hutterer, University of South Australia, NICTA
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef XF86EXTENSIONS_H #ifndef _GEINT_H_
#define XF86EXTENSIONS_H #define _GEINT_H_
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h" #include "extnsionst.h"
#include <X11/extensions/geproto.h>
#ifdef XF86DRI extern _X_EXPORT DevPrivateKeyRec GEClientPrivateKeyRec;
extern _X_EXPORT Bool noXFree86DRIExtension; #define GEClientPrivateKey (&GEClientPrivateKeyRec)
extern void XFree86DRIExtensionInit(void);
#endif
#ifdef DRI2 typedef struct _GEClientInfo {
#include <X11/extensions/dri2proto.h> CARD32 major_version;
extern _X_EXPORT Bool noDRI2Extension; CARD32 minor_version;
extern void DRI2ExtensionInit(void); } GEClientInfoRec, *GEClientInfoPtr;
#endif
#ifdef XF86VIDMODE #define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey)))
#include <X11/extensions/xf86vmproto.h>
extern _X_EXPORT Bool noXFree86VidModeExtension;
extern void XFree86VidModeExtensionInit(void);
#endif
#ifdef XFreeXDGA extern _X_EXPORT int (*ProcGEVector[/*GENumRequests*/])(ClientPtr);
#include <X11/extensions/xf86dgaproto.h> extern _X_EXPORT int (*SProcGEVector[/*GENumRequests*/])(ClientPtr);
extern _X_EXPORT Bool noXFree86DGAExtension;
extern void XFree86DGAExtensionInit(void);
extern void XFree86DGARegister(void);
#endif
#endif #endif /* _GEINT_H_ */

View file

@ -1,296 +0,0 @@
#include <dix-config.h>
#include <stdlib.h>
#include "misc.h"
#include "hashtable.h"
/* HashResourceID */
#include "resource.h"
#define INITHASHSIZE 6
#define MAXHASHSIZE 11
struct HashTableRec {
int keySize;
int dataSize;
int elements; /* number of elements inserted */
int bucketBits; /* number of buckets is 1 << bucketBits */
struct xorg_list *buckets; /* array of bucket list heads */
HashFunc hash;
HashCompareFunc compare;
void *cdata;
};
typedef struct {
struct xorg_list l;
void *key;
void *data;
} BucketRec, *BucketPtr;
HashTable
ht_create(int keySize,
int dataSize,
HashFunc hash,
HashCompareFunc compare,
void *cdata)
{
int c;
int numBuckets;
HashTable ht = malloc(sizeof(struct HashTableRec));
if (!ht) {
return NULL;
}
ht->keySize = keySize;
ht->dataSize = dataSize;
ht->hash = hash;
ht->compare = compare;
ht->elements = 0;
ht->bucketBits = INITHASHSIZE;
numBuckets = 1 << ht->bucketBits;
ht->buckets = xallocarray(numBuckets, sizeof(*ht->buckets));
ht->cdata = cdata;
if (ht->buckets) {
for (c = 0; c < numBuckets; ++c) {
xorg_list_init(&ht->buckets[c]);
}
return ht;
} else {
free(ht);
return NULL;
}
}
void
ht_destroy(HashTable ht)
{
int c;
BucketPtr it, tmp;
int numBuckets = 1 << ht->bucketBits;
for (c = 0; c < numBuckets; ++c) {
xorg_list_for_each_entry_safe(it, tmp, &ht->buckets[c], l) {
xorg_list_del(&it->l);
free(it->key);
free(it->data);
free(it);
}
}
free(ht->buckets);
free(ht);
}
static Bool
double_size(HashTable ht)
{
struct xorg_list *newBuckets;
int numBuckets = 1 << ht->bucketBits;
int newBucketBits = ht->bucketBits + 1;
int newNumBuckets = 1 << newBucketBits;
int c;
newBuckets = xallocarray(newNumBuckets, sizeof(*ht->buckets));
if (newBuckets) {
for (c = 0; c < newNumBuckets; ++c) {
xorg_list_init(&newBuckets[c]);
}
for (c = 0; c < numBuckets; ++c) {
BucketPtr it, tmp;
xorg_list_for_each_entry_safe(it, tmp, &ht->buckets[c], l) {
struct xorg_list *newBucket =
&newBuckets[ht->hash(ht->cdata, it->key, newBucketBits)];
xorg_list_del(&it->l);
xorg_list_add(&it->l, newBucket);
}
}
free(ht->buckets);
ht->buckets = newBuckets;
ht->bucketBits = newBucketBits;
return TRUE;
} else {
return FALSE;
}
}
void *
ht_add(HashTable ht, const void *key)
{
unsigned index = ht->hash(ht->cdata, key, ht->bucketBits);
struct xorg_list *bucket = &ht->buckets[index];
BucketRec *elem = calloc(1, sizeof(BucketRec));
if (!elem) {
goto outOfMemory;
}
elem->key = malloc(ht->keySize);
if (!elem->key) {
goto outOfMemory;
}
/* we avoid signaling an out-of-memory error if dataSize is 0 */
elem->data = calloc(1, ht->dataSize);
if (ht->dataSize && !elem->data) {
goto outOfMemory;
}
xorg_list_add(&elem->l, bucket);
++ht->elements;
memcpy(elem->key, key, ht->keySize);
if (ht->elements > 4 * (1 << ht->bucketBits) &&
ht->bucketBits < MAXHASHSIZE) {
if (!double_size(ht)) {
--ht->elements;
xorg_list_del(&elem->l);
goto outOfMemory;
}
}
/* if memory allocation has failed due to dataSize being 0, return
a "dummy" pointer pointing at the of the key */
return elem->data ? elem->data : ((char*) elem->key + ht->keySize);
outOfMemory:
if (elem) {
free(elem->key);
free(elem->data);
free(elem);
}
return NULL;
}
void
ht_remove(HashTable ht, const void *key)
{
unsigned index = ht->hash(ht->cdata, key, ht->bucketBits);
struct xorg_list *bucket = &ht->buckets[index];
BucketPtr it;
xorg_list_for_each_entry(it, bucket, l) {
if (ht->compare(ht->cdata, key, it->key) == 0) {
xorg_list_del(&it->l);
--ht->elements;
free(it->key);
free(it->data);
free(it);
return;
}
}
}
void *
ht_find(HashTable ht, const void *key)
{
unsigned index = ht->hash(ht->cdata, key, ht->bucketBits);
struct xorg_list *bucket = &ht->buckets[index];
BucketPtr it;
xorg_list_for_each_entry(it, bucket, l) {
if (ht->compare(ht->cdata, key, it->key) == 0) {
return it->data ? it->data : ((char*) it->key + ht->keySize);
}
}
return NULL;
}
void
ht_dump_distribution(HashTable ht)
{
int c;
int numBuckets = 1 << ht->bucketBits;
for (c = 0; c < numBuckets; ++c) {
BucketPtr it;
int n = 0;
xorg_list_for_each_entry(it, &ht->buckets[c], l) {
++n;
}
printf("%d: %d\n", c, n);
}
}
/* Picked the function from http://burtleburtle.net/bob/hash/doobs.html by
Bob Jenkins, which is released in public domain */
static CARD32
one_at_a_time_hash(const void *data, int len)
{
CARD32 hash;
int i;
const char *key = data;
for (hash=0, i=0; i<len; ++i) {
hash += key[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
unsigned
ht_generic_hash(void *cdata, const void *ptr, int numBits)
{
HtGenericHashSetupPtr setup = cdata;
return one_at_a_time_hash(ptr, setup->keySize) & ~((~0U) << numBits);
}
int
ht_generic_compare(void *cdata, const void *l, const void *r)
{
HtGenericHashSetupPtr setup = cdata;
return memcmp(l, r, setup->keySize);
}
unsigned
ht_resourceid_hash(void * cdata, const void * data, int numBits)
{
const XID* idPtr = data;
XID id = *idPtr & RESOURCE_ID_MASK;
(void) cdata;
return HashResourceID(id, numBits);
}
int
ht_resourceid_compare(void* cdata, const void* a, const void* b)
{
const XID* xa = a;
const XID* xb = b;
(void) cdata;
return
*xa < *xb ? -1 :
*xa > *xb ? 1 :
0;
}
void
ht_dump_contents(HashTable ht,
void (*print_key)(void *opaque, void *key),
void (*print_value)(void *opaque, void *value),
void* opaque)
{
int c;
int numBuckets = 1 << ht->bucketBits;
for (c = 0; c < numBuckets; ++c) {
BucketPtr it;
int n = 0;
printf("%d: ", c);
xorg_list_for_each_entry(it, &ht->buckets[c], l) {
if (n > 0) {
printf(", ");
}
print_key(opaque, it->key);
printf("->");
print_value(opaque, it->data);
++n;
}
printf("\n");
}
}

View file

@ -1,137 +0,0 @@
#ifndef HASHTABLE_H
#define HASHTABLE_H 1
#include <dix-config.h>
#include <X11/Xfuncproto.h>
#include <X11/Xdefs.h>
#include "list.h"
/** @brief A hashing function.
@param[in/out] cdata Opaque data that can be passed to HtInit that will
eventually end up here
@param[in] ptr The data to be hashed. The size of the data, if
needed, can be configured via a record that can be
passed via cdata.
@param[in] numBits The number of bits this hash needs to have in the
resulting hash
@return A numBits-bit hash of the data
*/
typedef unsigned (*HashFunc)(void * cdata, const void * ptr, int numBits);
/** @brief A comparison function for hashed keys.
@param[in/out] cdata Opaque data that ca be passed to Htinit that will
eventually end up here
@param[in] l The left side data to be compared
@param[in] r The right side data to be compared
@return -1 if l < r, 0 if l == r, 1 if l > r
*/
typedef int (*HashCompareFunc)(void * cdata, const void * l, const void * r);
struct HashTableRec;
typedef struct HashTableRec *HashTable;
/** @brief A configuration for HtGenericHash */
typedef struct {
int keySize;
} HtGenericHashSetupRec, *HtGenericHashSetupPtr;
/** @brief ht_create initializes a hash table for a certain hash table
configuration
@param[out] ht The hash table structure to initialize
@param[in] keySize The key size in bytes
@param[in] dataSize The data size in bytes
@param[in] hash The hash function to use for hashing keys
@param[in] compare The comparison function for hashing keys
@param[in] cdata Opaque data that will be passed to hash and
comparison functions
*/
extern _X_EXPORT HashTable ht_create(int keySize,
int dataSize,
HashFunc hash,
HashCompareFunc compare,
void *cdata);
/** @brief HtDestruct deinitializes the structure. It does not free the
memory allocated to HashTableRec
*/
extern _X_EXPORT void ht_destroy(HashTable ht);
/** @brief Adds a new key to the hash table. The key will be copied
and a pointer to the value will be returned. The data will
be initialized with zeroes.
@param[in/out] ht The hash table
@param[key] key The key. The contents of the key will be copied.
@return On error NULL is returned, otherwise a pointer to the data
associated with the newly inserted key.
@note If dataSize is 0, a pointer to the end of the key may be returned
to avoid returning NULL. Obviously the data pointed cannot be
modified, as implied by dataSize being 0.
*/
extern _X_EXPORT void *ht_add(HashTable ht, const void *key);
/** @brief Removes a key from the hash table along with its
associated data, which will be free'd.
*/
extern _X_EXPORT void ht_remove(HashTable ht, const void *key);
/** @brief Finds the associated data of a key from the hash table.
@return If the key cannot be found, the function returns NULL.
Otherwise it returns a pointer to the data associated
with the key.
@note If dataSize == 0, this function may return NULL
even if the key has been inserted! If dataSize == NULL,
use HtMember instead to determine if a key has been
inserted.
*/
extern _X_EXPORT void *ht_find(HashTable ht, const void *key);
/** @brief A generic hash function */
extern _X_EXPORT unsigned ht_generic_hash(void *cdata,
const void *ptr,
int numBits);
/** @brief A generic comparison function. It compares data byte-wise. */
extern _X_EXPORT int ht_generic_compare(void *cdata,
const void *l,
const void *r);
/** @brief A debugging function that dumps the distribution of the
hash table: for each bucket, list the number of elements
contained within. */
extern _X_EXPORT void ht_dump_distribution(HashTable ht);
/** @brief A debugging function that dumps the contents of the hash
table: for each bucket, list the elements contained
within. */
extern _X_EXPORT void ht_dump_contents(HashTable ht,
void (*print_key)(void *opaque, void *key),
void (*print_value)(void *opaque, void *value),
void* opaque);
/** @brief A hashing function to be used for hashing resource IDs when
used with HashTables. It makes no use of cdata, so that can
be NULL. It uses HashXID underneath, and should HashXID be
unable to hash the value, it switches into using the generic
hash function. */
extern _X_EXPORT unsigned ht_resourceid_hash(void *cdata,
const void * data,
int numBits);
/** @brief A comparison function to be used for comparing resource
IDs when used with HashTables. It makes no use of cdata,
so that can be NULL. */
extern _X_EXPORT int ht_resourceid_compare(void *cdata,
const void *a,
const void *b);
#endif // HASHTABLE_H

View file

@ -1,77 +0,0 @@
srcs_xext = [
'bigreq.c',
'geext.c',
'shape.c',
'sleepuntil.c',
'sync.c',
'xcmisc.c',
'xtest.c',
]
hdrs_xext = [
'geext.h',
'syncsdk.h',
]
if build_dpms
srcs_xext += 'dpms.c'
endif
if build_mitshm
srcs_xext += 'shm.c'
hdrs_xext += ['shmint.h']
endif
if build_hashtable
srcs_xext += 'hashtable.c'
endif
if build_res
srcs_xext += 'xres.c'
endif
if build_screensaver
srcs_xext += 'saver.c'
endif
if build_xace
srcs_xext += 'xace.c'
endif
if build_xf86bigfont
srcs_xext += 'xf86bigfont.c'
endif
if build_xinerama
srcs_xext += ['panoramiX.c', 'panoramiXprocs.c', 'panoramiXSwap.c']
hdrs_xext += ['panoramiX.h', 'panoramiXsrv.h']
endif
if build_xsecurity
srcs_xext += ['security.c']
endif
if build_xselinux
srcs_xext += ['xselinux_ext.c', 'xselinux_hooks.c', 'xselinux_label.c']
endif
if build_xv
srcs_xext += ['xvmain.c', 'xvdisp.c', 'xvmc.c']
hdrs_xext += ['xvdix.h', 'xvmcext.h']
endif
libxserver_xext = static_library('libxserver_xext',
srcs_xext,
include_directories: inc,
dependencies: common_dep,
)
libxserver_xext_vidmode = static_library('libxserver_xext_vidmode',
'vidmode.c',
include_directories: inc,
dependencies: common_dep,
)
if build_xorg
install_data(hdrs_xext, install_dir: xorgsdkdir)
endif

File diff suppressed because it is too large Load diff

View file

@ -26,9 +26,10 @@ Equipment Corporation.
******************************************************************/ ******************************************************************/
/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ /* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */
/* /*
* PanoramiX definitions * PanoramiX definitions
*/ */
@ -39,31 +40,32 @@ Equipment Corporation.
#ifndef _PANORAMIX_H_ #ifndef _PANORAMIX_H_
#define _PANORAMIX_H_ #define _PANORAMIX_H_
#define _PANORAMIX_SERVER
#include <X11/extensions/panoramiXproto.h> #include <X11/extensions/panoramiXproto.h>
#undef _PANORAMIX_SERVER
#include "gcstruct.h" #include "gcstruct.h"
#include "dixstruct.h" #include "dixstruct.h"
typedef struct _PanoramiXInfo { typedef struct _PanoramiXInfo {
XID id; XID id ;
} PanoramiXInfo; } PanoramiXInfo;
typedef struct { typedef struct {
PanoramiXInfo info[MAXSCREENS]; PanoramiXInfo info[MAXSCREENS];
RESTYPE type; RESTYPE type;
union { union {
struct { struct {
char visibility; char visibility;
char class; char class;
char root; char root;
} win; } win;
struct { struct {
Bool shared; Bool shared;
} pix; } pix;
struct { struct {
Bool root; Bool root;
} pict; } pict;
char raw_data[4]; char raw_data[4];
} u; } u;
} PanoramiXRes; } PanoramiXRes;
@ -75,4 +77,4 @@ typedef struct {
#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) #define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)
#define IS_ROOT_DRAWABLE(d) (((d)->type == XRT_WINDOW) && (d)->u.win.root) #define IS_ROOT_DRAWABLE(d) (((d)->type == XRT_WINDOW) && (d)->u.win.root)
#endif /* _PANORAMIX_H_ */ #endif /* _PANORAMIX_H_ */

View file

@ -23,7 +23,9 @@ dealings in this Software without prior written authorization from Digital
Equipment Corporation. Equipment Corporation.
******************************************************************/ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
@ -45,51 +47,96 @@ Equipment Corporation.
#include "globals.h" #include "globals.h"
#include "panoramiXh.h" #include "panoramiXh.h"
static int _X_COLD static int
SProcPanoramiXQueryVersion (ClientPtr client)
{
REQUEST(xPanoramiXQueryVersionReq);
int n;
swaps(&stuff->length,n);
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
return ProcPanoramiXQueryVersion(client);
}
static int
SProcPanoramiXGetState(ClientPtr client) SProcPanoramiXGetState(ClientPtr client)
{ {
REQUEST(xPanoramiXGetStateReq); REQUEST(xPanoramiXGetStateReq);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); int n;
swapl(&stuff->window);
return ProcPanoramiXGetState(client); swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
swapl (&stuff->window, n);
return ProcPanoramiXGetState(client);
} }
static int _X_COLD static int
SProcPanoramiXGetScreenCount(ClientPtr client) SProcPanoramiXGetScreenCount(ClientPtr client)
{ {
REQUEST(xPanoramiXGetScreenCountReq); REQUEST(xPanoramiXGetScreenCountReq);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); int n;
swapl(&stuff->window);
return ProcPanoramiXGetScreenCount(client); swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
swapl (&stuff->window, n);
return ProcPanoramiXGetScreenCount(client);
} }
static int _X_COLD static int
SProcPanoramiXGetScreenSize(ClientPtr client) SProcPanoramiXGetScreenSize(ClientPtr client)
{ {
REQUEST(xPanoramiXGetScreenSizeReq); REQUEST(xPanoramiXGetScreenSizeReq);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); int n;
swapl(&stuff->window);
swapl(&stuff->screen); swaps (&stuff->length, n);
return ProcPanoramiXGetScreenSize(client); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
swapl (&stuff->window, n);
swapl (&stuff->screen, n);
return ProcPanoramiXGetScreenSize(client);
} }
int _X_COLD
SProcPanoramiXDispatch(ClientPtr client) static int
SProcXineramaIsActive(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xXineramaIsActiveReq);
switch (stuff->data) { int n;
case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client); swaps (&stuff->length, n);
case X_PanoramiXGetState: REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
return SProcPanoramiXGetState(client); return ProcXineramaIsActive(client);
case X_PanoramiXGetScreenCount: }
return SProcPanoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize:
return SProcPanoramiXGetScreenSize(client); static int
case X_XineramaIsActive: SProcXineramaQueryScreens(ClientPtr client)
return ProcXineramaIsActive(client); {
case X_XineramaQueryScreens: REQUEST(xXineramaQueryScreensReq);
return ProcXineramaQueryScreens(client); int n;
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
return ProcXineramaQueryScreens(client);
}
int
SProcPanoramiXDispatch (ClientPtr client)
{ REQUEST(xReq);
switch (stuff->data)
{
case X_PanoramiXQueryVersion:
return SProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:
return SProcPanoramiXGetState(client);
case X_PanoramiXGetScreenCount:
return SProcPanoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize:
return SProcPanoramiXGetScreenSize(client);
case X_XineramaIsActive:
return SProcXineramaIsActive(client);
case X_XineramaQueryScreens:
return SProcXineramaQueryScreens(client);
} }
return BadRequest; return BadRequest;
} }

View file

@ -16,7 +16,7 @@ extern int PanoramiXUnmapSubwindows(ClientPtr client);
extern int PanoramiXConfigureWindow(ClientPtr client); extern int PanoramiXConfigureWindow(ClientPtr client);
extern int PanoramiXCirculateWindow(ClientPtr client); extern int PanoramiXCirculateWindow(ClientPtr client);
extern int PanoramiXGetGeometry(ClientPtr client); extern int PanoramiXGetGeometry(ClientPtr client);
extern int PanoramiXTranslateCoords(ClientPtr client); extern int PanoramiXTranslateCoords(ClientPtr client);
extern int PanoramiXCreatePixmap(ClientPtr client); extern int PanoramiXCreatePixmap(ClientPtr client);
extern int PanoramiXFreePixmap(ClientPtr client); extern int PanoramiXFreePixmap(ClientPtr client);
extern int PanoramiXChangeGC(ClientPtr client); extern int PanoramiXChangeGC(ClientPtr client);
@ -40,7 +40,7 @@ extern int PanoramiXPolyFillRectangle(ClientPtr client);
extern int PanoramiXPutImage(ClientPtr client); extern int PanoramiXPutImage(ClientPtr client);
extern int PanoramiXGetImage(ClientPtr client); extern int PanoramiXGetImage(ClientPtr client);
extern int PanoramiXPolyText8(ClientPtr client); extern int PanoramiXPolyText8(ClientPtr client);
extern int PanoramiXPolyText16(ClientPtr client); extern int PanoramiXPolyText16(ClientPtr client);
extern int PanoramiXImageText8(ClientPtr client); extern int PanoramiXImageText8(ClientPtr client);
extern int PanoramiXImageText16(ClientPtr client); extern int PanoramiXImageText16(ClientPtr client);
extern int PanoramiXCreateColormap(ClientPtr client); extern int PanoramiXCreateColormap(ClientPtr client);
@ -57,11 +57,11 @@ extern int PanoramiXAllocColorPlanes(ClientPtr client);
#define PROC_EXTERN(pfunc) extern int pfunc(ClientPtr) #define PROC_EXTERN(pfunc) extern int pfunc(ClientPtr)
PROC_EXTERN(ProcPanoramiXQueryVersion); PROC_EXTERN(ProcPanoramiXQueryVersion);
PROC_EXTERN(ProcPanoramiXGetState); PROC_EXTERN(ProcPanoramiXGetState);
PROC_EXTERN(ProcPanoramiXGetScreenCount); PROC_EXTERN(ProcPanoramiXGetScreenCount);
PROC_EXTERN(ProcPanoramiXGetScreenSize); PROC_EXTERN(ProcPanoramiXGetScreenSize);
PROC_EXTERN(ProcXineramaQueryScreens); PROC_EXTERN(ProcXineramaQueryScreens);
PROC_EXTERN(ProcXineramaIsActive); PROC_EXTERN(ProcXineramaIsActive);
@ -70,4 +70,4 @@ extern int SProcPanoramiXDispatch(ClientPtr client);
extern int connBlockScreenStart; extern int connBlockScreenStart;
extern xConnSetupPrefix connSetupPrefix; extern xConnSetupPrefix connSetupPrefix;
extern int (*SavedProcVector[256]) (ClientPtr client); extern int (* SavedProcVector[256]) (ClientPtr client);

File diff suppressed because it is too large Load diff

View file

@ -11,17 +11,15 @@
extern _X_EXPORT int PanoramiXNumScreens; extern _X_EXPORT int PanoramiXNumScreens;
extern _X_EXPORT int PanoramiXPixWidth; extern _X_EXPORT int PanoramiXPixWidth;
extern _X_EXPORT int PanoramiXPixHeight; extern _X_EXPORT int PanoramiXPixHeight;
extern _X_EXPORT RegionRec PanoramiXScreenRegion;
extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig); extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig);
extern _X_EXPORT void PanoramiXConsolidate(void); extern _X_EXPORT void PanoramiXConsolidate(void);
extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void); extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void);
extern _X_EXPORT PanoramiXRes *PanoramiXFindIDByScrnum(RESTYPE, XID, int); extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int);
extern _X_EXPORT Bool extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
XineramaRegisterConnectionBlockCallback(void (*func) (void)); extern _X_EXPORT int XineramaDeleteResource(pointer, XID);
extern _X_EXPORT int XineramaDeleteResource(void *, XID);
extern _X_EXPORT void XineramaReinitData(void); extern _X_EXPORT void XineramaReinitData(ScreenPtr);
extern _X_EXPORT RESTYPE XRC_DRAWABLE; extern _X_EXPORT RESTYPE XRC_DRAWABLE;
extern _X_EXPORT RESTYPE XRT_WINDOW; extern _X_EXPORT RESTYPE XRT_WINDOW;
@ -37,20 +35,24 @@ extern _X_EXPORT RESTYPE XRT_PICTURE;
* layers agree that the visuals are equal. The first visual is always from * layers agree that the visuals are equal. The first visual is always from
* screen 0. * screen 0.
*/ */
typedef Bool (*XineramaVisualsEqualProcPtr) (VisualPtr, ScreenPtr, VisualPtr); typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr);
extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr; extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr;
extern _X_EXPORT void XineramaGetImageData(DrawablePtr *pDrawables, extern _X_EXPORT void XineramaGetImageData(
int left, DrawablePtr *pDrawables,
int top, int left,
int width, int top,
int height, int width,
unsigned int format, int height,
unsigned long planemask, unsigned int format,
char *data, int pitch, Bool isRoot); unsigned long planemask,
char *data,
int pitch,
Bool isRoot
);
static inline void static inline void panoramix_setup_ids(PanoramiXRes *resource,
panoramix_setup_ids(PanoramiXRes * resource, ClientPtr client, XID base_id) ClientPtr client, XID base_id)
{ {
int j; int j;
@ -60,4 +62,4 @@ panoramix_setup_ids(PanoramiXRes * resource, ClientPtr client, XID base_id)
} }
} }
#endif /* _PANORAMIXSRV_H_ */ #endif /* _PANORAMIXSRV_H_ */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -30,34 +30,54 @@ from The Open Group.
#ifndef _SECURITY_SRV_H #ifndef _SECURITY_SRV_H
#define _SECURITY_SRV_H #define _SECURITY_SRV_H
/* Allow client side portions of <X11/extensions/security.h> to compile */
#ifndef Status
# define Status int
# define NEED_UNDEF_Status
#endif
#ifndef Display
# define Display void
# define NEED_UNDEF_Display
#endif
#include <X11/extensions/secur.h> #include <X11/extensions/secur.h>
#include "input.h" /* for DeviceIntPtr */ #ifdef NEED_UNDEF_Status
#include "property.h" /* for PropertyPtr */ # undef Status
#include "pixmap.h" /* for DrawablePtr */ # undef NEED_UNDEF_Status
#include "resource.h" /* for RESTYPE */ #endif
#ifdef NEED_UNDEF_Display
# undef Display
# undef NEED_UNDEF_Display
#endif
#include "input.h" /* for DeviceIntPtr */
#include "property.h" /* for PropertyPtr */
#include "pixmap.h" /* for DrawablePtr */
#include "resource.h" /* for RESTYPE */
/* resource type to pass in LookupIDByType for authorizations */ /* resource type to pass in LookupIDByType for authorizations */
extern RESTYPE SecurityAuthorizationResType; extern RESTYPE SecurityAuthorizationResType;
/* this is what we store for an authorization */ /* this is what we store for an authorization */
typedef struct { typedef struct {
XID id; /* resource ID */ XID id; /* resource ID */
CARD32 timeout; /* how long to live in seconds after refcnt == 0 */ CARD32 timeout; /* how long to live in seconds after refcnt == 0 */
unsigned int trustLevel; /* trusted/untrusted */ unsigned int trustLevel; /* trusted/untrusted */
XID group; /* see embedding extension */ XID group; /* see embedding extension */
unsigned int refcnt; /* how many clients connected with this auth */ unsigned int refcnt; /* how many clients connected with this auth */
unsigned int secondsRemaining; /* overflow time amount for >49 days */ unsigned int secondsRemaining; /* overflow time amount for >49 days */
OsTimerPtr timer; /* timer for this auth */ OsTimerPtr timer; /* timer for this auth */
struct _OtherClients *eventClients; /* clients wanting events */ struct _OtherClients *eventClients; /* clients wanting events */
} SecurityAuthorizationRec, *SecurityAuthorizationPtr; } SecurityAuthorizationRec, *SecurityAuthorizationPtr;
typedef struct { typedef struct {
XID group; /* the group that was sent in GenerateAuthorization */ XID group; /* the group that was sent in GenerateAuthorization */
Bool valid; /* did anyone recognize it? if so, set to TRUE */ Bool valid; /* did anyone recognize it? if so, set to TRUE */
} SecurityValidateGroupInfoRec; } SecurityValidateGroupInfoRec;
/* Give this value or higher to the -audit option to get security messages */ /* Give this value or higher to the -audit option to get security messages */
#define SECURITY_AUDIT_LEVEL 4 #define SECURITY_AUDIT_LEVEL 4
#endif /* _SECURITY_SRV_H */ #endif /* _SECURITY_SRV_H */

File diff suppressed because it is too large Load diff

1591
Xext/shm.c

File diff suppressed because it is too large Load diff

View file

@ -42,52 +42,28 @@
int /* sh */, \ int /* sh */, \
int /* dx */, \ int /* dx */, \
int /* dy */, \ int /* dy */, \
char * /* data */ char * /* data */
#define XSHM_CREATE_PIXMAP_ARGS \ #define XSHM_CREATE_PIXMAP_ARGS \
ScreenPtr /* pScreen */, \ ScreenPtr /* pScreen */, \
int /* width */, \ int /* width */, \
int /* height */, \ int /* height */, \
int /* depth */, \ int /* depth */, \
char * /* addr */ char * /* addr */
typedef struct _ShmFuncs { typedef struct _ShmFuncs {
PixmapPtr (*CreatePixmap) (XSHM_CREATE_PIXMAP_ARGS); PixmapPtr (* CreatePixmap)(XSHM_CREATE_PIXMAP_ARGS);
void (*PutImage) (XSHM_PUT_IMAGE_ARGS); void (* PutImage)(XSHM_PUT_IMAGE_ARGS);
} ShmFuncs, *ShmFuncsPtr; } ShmFuncs, *ShmFuncsPtr;
#if XTRANS_SEND_FDS extern _X_EXPORT void
#define SHM_FD_PASSING 1 ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs);
#endif
typedef struct _ShmDesc {
struct _ShmDesc *next;
int shmid;
int refcnt;
char *addr;
Bool writable;
unsigned long size;
#ifdef SHM_FD_PASSING
Bool is_fd;
struct busfault *busfault;
XID resource;
#endif
} ShmDescRec, *ShmDescPtr;
#ifdef SHM_FD_PASSING
#define SHMDESC_IS_FD(shmdesc) ((shmdesc)->is_fd)
#else
#define SHMDESC_IS_FD(shmdesc) (0)
#endif
extern _X_EXPORT void extern _X_EXPORT void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); ShmRegisterFbFuncs(ScreenPtr pScreen);
extern _X_EXPORT void
ShmRegisterFbFuncs(ScreenPtr pScreen);
extern _X_EXPORT RESTYPE ShmSegType; extern _X_EXPORT RESTYPE ShmSegType;
extern _X_EXPORT int ShmCompletionCode; extern _X_EXPORT int ShmCompletionCode;
extern _X_EXPORT int BadShmSegCode; extern _X_EXPORT int BadShmSegCode;
#endif /* _SHMINT_H_ */ #endif /* _SHMINT_H_ */

View file

@ -27,7 +27,9 @@ in this Software without prior written authorization from The Open Group.
/* dixsleep.c - implement millisecond timeouts for X clients */ /* dixsleep.c - implement millisecond timeouts for X clients */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "sleepuntil.h" #include "sleepuntil.h"
#include <X11/X.h> #include <X11/X.h>
@ -39,165 +41,185 @@ in this Software without prior written authorization from The Open Group.
#include "scrnintstr.h" #include "scrnintstr.h"
typedef struct _Sertafied { typedef struct _Sertafied {
struct _Sertafied *next; struct _Sertafied *next;
TimeStamp revive; TimeStamp revive;
ClientPtr pClient; ClientPtr pClient;
XID id; XID id;
void (*notifyFunc) (ClientPtr /* client */ , void (*notifyFunc)(
void * /* closure */ ClientPtr /* client */,
); pointer /* closure */
);
void *closure; pointer closure;
} SertafiedRec, *SertafiedPtr; } SertafiedRec, *SertafiedPtr;
static SertafiedPtr pPending; static SertafiedPtr pPending;
static RESTYPE SertafiedResType; static RESTYPE SertafiedResType;
static Bool BlockHandlerRegistered; static Bool BlockHandlerRegistered;
static int SertafiedGeneration; static int SertafiedGeneration;
static void ClientAwaken(ClientPtr /* client */ , static void ClientAwaken(
void * /* closure */ ClientPtr /* client */,
); pointer /* closure */
static int SertafiedDelete(void * /* value */ , );
XID /* id */ static int SertafiedDelete(
); pointer /* value */,
static void SertafiedBlockHandler(void *data, XID /* id */
void *timeout); );
static void SertafiedBlockHandler(
static void SertafiedWakeupHandler(void *data, pointer /* data */,
int i); OSTimePtr /* wt */,
pointer /* LastSelectMask */
);
static void SertafiedWakeupHandler(
pointer /* data */,
int /* i */,
pointer /* LastSelectMask */
);
int int
ClientSleepUntil(ClientPtr client, ClientSleepUntil (ClientPtr client,
TimeStamp *revive, TimeStamp *revive,
void (*notifyFunc) (ClientPtr, void *), void *closure) void (*notifyFunc)(ClientPtr, pointer),
pointer closure)
{ {
SertafiedPtr pRequest, pReq, pPrev; SertafiedPtr pRequest, pReq, pPrev;
if (SertafiedGeneration != serverGeneration) { if (SertafiedGeneration != serverGeneration)
SertafiedResType = CreateNewResourceType(SertafiedDelete, {
"ClientSleep"); SertafiedResType = CreateNewResourceType (SertafiedDelete,
if (!SertafiedResType) "ClientSleep");
return FALSE; if (!SertafiedResType)
SertafiedGeneration = serverGeneration; return FALSE;
BlockHandlerRegistered = FALSE; SertafiedGeneration = serverGeneration;
BlockHandlerRegistered = FALSE;
} }
pRequest = malloc(sizeof(SertafiedRec)); pRequest = malloc(sizeof (SertafiedRec));
if (!pRequest) if (!pRequest)
return FALSE; return FALSE;
pRequest->pClient = client; pRequest->pClient = client;
pRequest->revive = *revive; pRequest->revive = *revive;
pRequest->id = FakeClientID(client->index); pRequest->id = FakeClientID (client->index);
pRequest->closure = closure; pRequest->closure = closure;
if (!BlockHandlerRegistered) { if (!BlockHandlerRegistered)
if (!RegisterBlockAndWakeupHandlers(SertafiedBlockHandler, {
SertafiedWakeupHandler, if (!RegisterBlockAndWakeupHandlers (SertafiedBlockHandler,
(void *) 0)) { SertafiedWakeupHandler,
free(pRequest); (pointer) 0))
return FALSE; {
} free(pRequest);
BlockHandlerRegistered = TRUE; return FALSE;
}
BlockHandlerRegistered = TRUE;
} }
pRequest->notifyFunc = 0; pRequest->notifyFunc = 0;
if (!AddResource(pRequest->id, SertafiedResType, (void *) pRequest)) if (!AddResource (pRequest->id, SertafiedResType, (pointer) pRequest))
return FALSE; return FALSE;
if (!notifyFunc) if (!notifyFunc)
notifyFunc = ClientAwaken; notifyFunc = ClientAwaken;
pRequest->notifyFunc = notifyFunc; pRequest->notifyFunc = notifyFunc;
/* Insert into time-ordered queue, with earliest activation time coming first. */ /* Insert into time-ordered queue, with earliest activation time coming first. */
pPrev = 0; pPrev = 0;
for (pReq = pPending; pReq; pReq = pReq->next) { for (pReq = pPending; pReq; pReq = pReq->next)
if (CompareTimeStamps(pReq->revive, *revive) == LATER) {
break; if (CompareTimeStamps (pReq->revive, *revive) == LATER)
pPrev = pReq; break;
pPrev = pReq;
} }
if (pPrev) if (pPrev)
pPrev->next = pRequest; pPrev->next = pRequest;
else else
pPending = pRequest; pPending = pRequest;
pRequest->next = pReq; pRequest->next = pReq;
IgnoreClient(client); IgnoreClient (client);
return TRUE; return TRUE;
} }
static void static void
ClientAwaken(ClientPtr client, void *closure) ClientAwaken (ClientPtr client, pointer closure)
{ {
AttendClient(client); if (!client->clientGone)
AttendClient (client);
} }
static int static int
SertafiedDelete(void *value, XID id) SertafiedDelete (pointer value, XID id)
{ {
SertafiedPtr pRequest = (SertafiedPtr) value; SertafiedPtr pRequest = (SertafiedPtr)value;
SertafiedPtr pReq, pPrev; SertafiedPtr pReq, pPrev;
pPrev = 0; pPrev = 0;
for (pReq = pPending; pReq; pPrev = pReq, pReq = pReq->next) for (pReq = pPending; pReq; pPrev = pReq, pReq = pReq->next)
if (pReq == pRequest) { if (pReq == pRequest)
if (pPrev) {
pPrev->next = pReq->next; if (pPrev)
else pPrev->next = pReq->next;
pPending = pReq->next; else
break; pPending = pReq->next;
} break;
}
if (pRequest->notifyFunc) if (pRequest->notifyFunc)
(*pRequest->notifyFunc) (pRequest->pClient, pRequest->closure); (*pRequest->notifyFunc) (pRequest->pClient, pRequest->closure);
free(pRequest); free(pRequest);
return TRUE; return TRUE;
} }
static void static void
SertafiedBlockHandler(void *data, void *wt) SertafiedBlockHandler (pointer data, OSTimePtr wt, pointer LastSelectMask)
{ {
SertafiedPtr pReq, pNext; SertafiedPtr pReq, pNext;
unsigned long delay; unsigned long delay;
TimeStamp now; TimeStamp now;
if (!pPending) if (!pPending)
return; return;
now.milliseconds = GetTimeInMillis(); now.milliseconds = GetTimeInMillis ();
now.months = currentTime.months; now.months = currentTime.months;
if ((int) (now.milliseconds - currentTime.milliseconds) < 0) if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
now.months++; now.months++;
for (pReq = pPending; pReq; pReq = pNext) { for (pReq = pPending; pReq; pReq = pNext)
pNext = pReq->next; {
if (CompareTimeStamps(pReq->revive, now) == LATER) pNext = pReq->next;
break; if (CompareTimeStamps (pReq->revive, now) == LATER)
FreeResource(pReq->id, X11_RESTYPE_NONE); break;
FreeResource (pReq->id, RT_NONE);
/* AttendClient() may have been called via the resource delete /* AttendClient() may have been called via the resource delete
* function so a client may have input to be processed and so * function so a client may have input to be processed and so
* set delay to 0 to prevent blocking in WaitForSomething(). * set delay to 0 to prevent blocking in WaitForSomething().
*/ */
AdjustWaitForDelay(wt, 0); AdjustWaitForDelay (wt, 0);
} }
pReq = pPending; pReq = pPending;
if (!pReq) if (!pReq)
return; return;
delay = pReq->revive.milliseconds - now.milliseconds; delay = pReq->revive.milliseconds - now.milliseconds;
AdjustWaitForDelay(wt, delay); AdjustWaitForDelay (wt, delay);
} }
static void static void
SertafiedWakeupHandler(void *data, int i) SertafiedWakeupHandler (pointer data, int i, pointer LastSelectMask)
{ {
SertafiedPtr pReq, pNext; SertafiedPtr pReq, pNext;
TimeStamp now; TimeStamp now;
now.milliseconds = GetTimeInMillis(); now.milliseconds = GetTimeInMillis ();
now.months = currentTime.months; now.months = currentTime.months;
if ((int) (now.milliseconds - currentTime.milliseconds) < 0) if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
now.months++; now.months++;
for (pReq = pPending; pReq; pReq = pNext) { for (pReq = pPending; pReq; pReq = pNext)
pNext = pReq->next; {
if (CompareTimeStamps(pReq->revive, now) == LATER) pNext = pReq->next;
break; if (CompareTimeStamps (pReq->revive, now) == LATER)
FreeResource(pReq->id, X11_RESTYPE_NONE); break;
FreeResource (pReq->id, RT_NONE);
} }
if (!pPending) { if (!pPending)
RemoveBlockAndWakeupHandlers(SertafiedBlockHandler, {
SertafiedWakeupHandler, (void *) 0); RemoveBlockAndWakeupHandlers (SertafiedBlockHandler,
BlockHandlerRegistered = FALSE; SertafiedWakeupHandler,
(pointer) 0);
BlockHandlerRegistered = FALSE;
} }
} }

View file

@ -33,10 +33,14 @@
#include "dix.h" #include "dix.h"
extern int ClientSleepUntil(ClientPtr client, extern int ClientSleepUntil(
TimeStamp *revive, ClientPtr client,
void (*notifyFunc) (ClientPtr /* client */ , TimeStamp *revive,
void * /* closure */ void (*notifyFunc)(
), void *Closure); ClientPtr /* client */,
pointer /* closure */
),
pointer Closure
);
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -27,10 +27,7 @@
#include "misync.h" #include "misync.h"
extern _X_EXPORT int extern _X_EXPORT int
SyncVerifyFence(SyncFence ** ppFence, XID fid, ClientPtr client, Mask mode); SyncVerifyFence(SyncFence **ppFence, XID fid, ClientPtr client, Mask mode);
extern _X_EXPORT SyncObject*
SyncCreate(ClientPtr client, XID id, unsigned char type);
#define VERIFY_SYNC_FENCE(pFence, fid, client, mode) \ #define VERIFY_SYNC_FENCE(pFence, fid, client, mode) \
do { \ do { \
@ -46,4 +43,5 @@ extern _X_EXPORT SyncObject*
VERIFY_SYNC_FENCE((pFence), (fid), (client), (mode)); \ VERIFY_SYNC_FENCE((pFence), (fid), (client), (mode)); \
} while (0) } while (0)
#endif /* _SYNCSDK_H_ */ #endif /* _SYNCSDK_H_ */

View file

@ -30,13 +30,13 @@ and Olivetti Research Limited, Cambridge, England.
All Rights Reserved All Rights Reserved
Permission to use, copy, modify, and distribute this software and its Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or Olivetti supporting documentation, and that the names of Digital or Olivetti
not be used in advertising or publicity pertaining to distribution of the not be used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. software without specific, written prior permission.
DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
@ -51,7 +51,6 @@ PERFORMANCE OF THIS SOFTWARE.
#ifndef _SYNCSRV_H_ #ifndef _SYNCSRV_H_
#define _SYNCSRV_H_ #define _SYNCSRV_H_
#include "list.h"
#include "misync.h" #include "misync.h"
#include "misyncstr.h" #include "misyncstr.h"
@ -66,86 +65,82 @@ typedef enum {
XSyncCounterUnrestricted XSyncCounterUnrestricted
} SyncCounterType; } SyncCounterType;
typedef void (*SyncSystemCounterQueryValue)(void *counter,
int64_t *value_return
);
typedef void (*SyncSystemCounterBracketValues)(void *counter,
int64_t *pbracket_less,
int64_t *pbracket_greater
);
typedef struct _SysCounterInfo { typedef struct _SysCounterInfo {
SyncCounter *pCounter; char *name;
char *name; CARD64 resolution;
int64_t resolution; CARD64 bracket_greater;
int64_t bracket_greater; CARD64 bracket_less;
int64_t bracket_less; SyncCounterType counterType; /* how can this counter change */
SyncCounterType counterType; /* how can this counter change */ void (*QueryValue)(
SyncSystemCounterQueryValue QueryValue; pointer /*pCounter*/,
SyncSystemCounterBracketValues BracketValues; CARD64 * /*freshvalue*/
void *private; );
struct xorg_list entry; void (*BracketValues)(
pointer /*pCounter*/,
CARD64 * /*lessthan*/,
CARD64 * /*greaterthan*/
);
} SysCounterInfo; } SysCounterInfo;
typedef struct _SyncAlarmClientList { typedef struct _SyncAlarmClientList {
ClientPtr client; ClientPtr client;
XID delete_id; XID delete_id;
struct _SyncAlarmClientList *next; struct _SyncAlarmClientList *next;
} SyncAlarmClientList; } SyncAlarmClientList;
typedef struct _SyncAlarm { typedef struct _SyncAlarm {
SyncTrigger trigger; SyncTrigger trigger;
ClientPtr client; ClientPtr client;
XSyncAlarm alarm_id; XSyncAlarm alarm_id;
int64_t delta; CARD64 delta;
int events; int events;
int state; int state;
SyncAlarmClientList *pEventClients; SyncAlarmClientList *pEventClients;
} SyncAlarm; } SyncAlarm;
typedef struct { typedef struct {
ClientPtr client; ClientPtr client;
CARD32 delete_id; CARD32 delete_id;
int num_waitconditions; int num_waitconditions;
} SyncAwaitHeader; } SyncAwaitHeader;
typedef struct { typedef struct {
SyncTrigger trigger; SyncTrigger trigger;
int64_t event_threshold; CARD64 event_threshold;
SyncAwaitHeader *pHeader; SyncAwaitHeader *pHeader;
} SyncAwait; } SyncAwait;
typedef union { typedef union {
SyncAwaitHeader header; SyncAwaitHeader header;
SyncAwait await; SyncAwait await;
} SyncAwaitUnion; } SyncAwaitUnion;
extern SyncCounter* SyncCreateSystemCounter(const char *name, extern pointer SyncCreateSystemCounter(
int64_t initial_value, char * /* name */,
int64_t resolution, CARD64 /* inital_value */,
SyncCounterType counterType, CARD64 /* resolution */,
SyncSystemCounterQueryValue QueryValue, SyncCounterType /* change characterization */,
SyncSystemCounterBracketValues BracketValues void (* /*QueryValue*/ ) (
); pointer /* pCounter */,
CARD64 * /* pValue_return */), /* XXX prototype */
void (* /*BracketValues*/) (
pointer /* pCounter */,
CARD64 * /* pbracket_less */,
CARD64 * /* pbracket_greater */)
);
extern void SyncChangeCounter(SyncCounter *pCounter, extern void SyncChangeCounter(
int64_t new_value); SyncCounter * /* pCounter*/,
CARD64 /* new_value */
);
extern void SyncDestroySystemCounter(void *pCounter); extern void SyncDestroySystemCounter(
pointer pCounter
);
extern SyncCounter *SyncInitDeviceIdleTime(DeviceIntPtr dev); extern void InitServertime(void);
extern void SyncRemoveDeviceIdleTime(SyncCounter *counter);
int extern void SyncExtensionInit(void);
SyncCreateFenceFromFD(ClientPtr client, DrawablePtr pDraw, XID id, int fd, BOOL initially_triggered); #endif /* _SYNCSRV_H_ */
int
SyncFDFromFence(ClientPtr client, DrawablePtr pDraw, SyncFence *fence);
void
SyncDeleteTriggerFromSyncObject(SyncTrigger * pTrigger);
int
SyncAddTriggerToSyncObject(SyncTrigger * pTrigger);
#endif /* _SYNCSRV_H_ */

File diff suppressed because it is too large Load diff

View file

@ -17,12 +17,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdarg.h> #include <stdarg.h>
#include "os/client_priv.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "pixmapstr.h" #include "pixmapstr.h"
@ -30,133 +29,172 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "gcstruct.h" #include "gcstruct.h"
#include "xacestr.h" #include "xacestr.h"
CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = { 0 }; #define XSERV_t
#define TRANS_SERVER
#include <X11/Xtrans/Xtrans.h>
#include "../os/osdep.h"
_X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = {0};
/* Special-cased hook functions. Called by Xserver. /* Special-cased hook functions. Called by Xserver.
*/ */
int int XaceHookDispatch(ClientPtr client, int major)
XaceHookDispatch0(ClientPtr client, int major)
{ {
/* Call the extension dispatch hook */ /* Call the audit begin callback, there is no return value. */
ExtensionEntry *ext = GetExtensionEntry(major); XaceAuditRec rec = { client, 0 };
XaceExtAccessRec erec = { client, ext, DixUseAccess, Success }; CallCallbacks(&XaceHooks[XACE_AUDIT_BEGIN], &rec);
if (ext)
CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &erec); if (major < 128) {
/* On error, pretend extension doesn't exist */ /* Call the core dispatch hook */
return (erec.status == Success) ? Success : BadRequest; XaceCoreDispatchRec rec = { client, Success /* default allow */ };
CallCallbacks(&XaceHooks[XACE_CORE_DISPATCH], &rec);
return rec.status;
} else {
/* Call the extension dispatch hook */
ExtensionEntry *ext = GetExtensionEntry(major);
XaceExtAccessRec rec = { client, ext, DixUseAccess, Success };
if (ext)
CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &rec);
/* On error, pretend extension doesn't exist */
return (rec.status == Success) ? Success : BadRequest;
}
} }
int int XaceHookPropertyAccess(ClientPtr client, WindowPtr pWin,
XaceHookPropertyAccess(ClientPtr client, WindowPtr pWin, PropertyPtr *ppProp, Mask access_mode)
PropertyPtr *ppProp, Mask access_mode)
{ {
XacePropertyAccessRec rec = { client, pWin, ppProp, access_mode, Success }; XacePropertyAccessRec rec = { client, pWin, ppProp, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_PROPERTY_ACCESS], &rec); CallCallbacks(&XaceHooks[XACE_PROPERTY_ACCESS], &rec);
return rec.status; return rec.status;
} }
int int XaceHookSelectionAccess(ClientPtr client,
XaceHookSelectionAccess(ClientPtr client, Selection ** ppSel, Mask access_mode) Selection **ppSel, Mask access_mode)
{ {
XaceSelectionAccessRec rec = { client, ppSel, access_mode, Success }; XaceSelectionAccessRec rec = { client, ppSel, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_SELECTION_ACCESS], &rec); CallCallbacks(&XaceHooks[XACE_SELECTION_ACCESS], &rec);
return rec.status; return rec.status;
} }
int XaceHookResourceAccess(ClientPtr client, XID id, RESTYPE rtype, void *res, void XaceHookAuditEnd(ClientPtr ptr, int result)
RESTYPE ptype, void *parent, Mask access_mode)
{ {
XaceResourceAccessRec rec = { client, id, rtype, res, ptype, parent, XaceAuditRec rec = { ptr, result };
access_mode, Success }; /* call callbacks, there is no return value. */
CallCallbacks(&XaceHooks[XACE_RESOURCE_ACCESS], &rec); CallCallbacks(&XaceHooks[XACE_AUDIT_END], &rec);
return rec.status;
} }
int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode) /* Entry point for hook functions. Called by Xserver.
{
XaceDeviceAccessRec rec = { client, dev, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_DEVICE_ACCESS], &rec);
return rec.status;
}
int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win,
xEventPtr ev, int count)
{
XaceSendAccessRec rec = { client, dev, win, ev, count, Success };
CallCallbacks(&XaceHooks[XACE_SEND_ACCESS], &rec);
return rec.status;
}
int XaceHookReceiveAccess(ClientPtr client, WindowPtr win,
xEventPtr ev, int count)
{
XaceReceiveAccessRec rec = { client, win, ev, count, Success };
CallCallbacks(&XaceHooks[XACE_RECEIVE_ACCESS], &rec);
return rec.status;
}
int XaceHookClientAccess(ClientPtr client, ClientPtr target, Mask access_mode)
{
XaceClientAccessRec rec = { client, target, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_CLIENT_ACCESS], &rec);
return rec.status;
}
int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext)
{
XaceExtAccessRec rec = { client, ext, DixGetAttrAccess, Success };
CallCallbacks(&XaceHooks[XACE_EXT_ACCESS], &rec);
return rec.status;
}
int XaceHookServerAccess(ClientPtr client, Mask access_mode)
{
XaceServerAccessRec rec = { client, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_SERVER_ACCESS], &rec);
return rec.status;
}
int XaceHookScreenAccess(ClientPtr client, ScreenPtr screen, Mask access_mode)
{
XaceScreenAccessRec rec = { client, screen, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_SCREEN_ACCESS], &rec);
return rec.status;
}
int XaceHookScreensaverAccess(ClientPtr client, ScreenPtr screen, Mask access_mode)
{
XaceScreenAccessRec rec = { client, screen, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_SCREENSAVER_ACCESS], &rec);
return rec.status;
}
int XaceHookAuthAvail(ClientPtr client, XID authId)
{
XaceAuthAvailRec rec = { client, authId };
CallCallbacks(&XaceHooks[XACE_AUTH_AVAIL], &rec);
return Success;
}
int XaceHookKeyAvail(xEventPtr ev, DeviceIntPtr dev, int count)
{
XaceKeyAvailRec rec = { ev, dev, count };
CallCallbacks(&XaceHooks[XACE_KEY_AVAIL], &rec);
return Success;
}
/* XaceHookIsSet
*
* Utility function to determine whether there are any callbacks listening on a
* particular XACE hook.
*
* Returns non-zero if there is a callback, zero otherwise.
*/ */
int int XaceHook(int hook, ...)
XaceHookIsSet(int hook)
{ {
if (hook < 0 || hook >= XACE_NUM_HOOKS) union {
return 0; XaceResourceAccessRec res;
return XaceHooks[hook] != NULL; XaceDeviceAccessRec dev;
XaceSendAccessRec send;
XaceReceiveAccessRec recv;
XaceClientAccessRec client;
XaceExtAccessRec ext;
XaceServerAccessRec server;
XaceScreenAccessRec screen;
XaceAuthAvailRec auth;
XaceKeyAvailRec key;
} u;
int *prv = NULL; /* points to return value from callback */
va_list ap; /* argument list */
if (!XaceHooks[hook])
return Success;
va_start(ap, hook);
/* Marshal arguments for passing to callback.
* Each callback has its own case, which sets up a structure to hold
* the arguments and integer return parameter, or in some cases just
* sets calldata directly to a single argument (with no return result)
*/
switch (hook)
{
case XACE_RESOURCE_ACCESS:
u.res.client = va_arg(ap, ClientPtr);
u.res.id = va_arg(ap, XID);
u.res.rtype = va_arg(ap, RESTYPE);
u.res.res = va_arg(ap, pointer);
u.res.ptype = va_arg(ap, RESTYPE);
u.res.parent = va_arg(ap, pointer);
u.res.access_mode = va_arg(ap, Mask);
u.res.status = Success; /* default allow */
prv = &u.res.status;
break;
case XACE_DEVICE_ACCESS:
u.dev.client = va_arg(ap, ClientPtr);
u.dev.dev = va_arg(ap, DeviceIntPtr);
u.dev.access_mode = va_arg(ap, Mask);
u.dev.status = Success; /* default allow */
prv = &u.dev.status;
break;
case XACE_SEND_ACCESS:
u.send.client = va_arg(ap, ClientPtr);
u.send.dev = va_arg(ap, DeviceIntPtr);
u.send.pWin = va_arg(ap, WindowPtr);
u.send.events = va_arg(ap, xEventPtr);
u.send.count = va_arg(ap, int);
u.send.status = Success; /* default allow */
prv = &u.send.status;
break;
case XACE_RECEIVE_ACCESS:
u.recv.client = va_arg(ap, ClientPtr);
u.recv.pWin = va_arg(ap, WindowPtr);
u.recv.events = va_arg(ap, xEventPtr);
u.recv.count = va_arg(ap, int);
u.recv.status = Success; /* default allow */
prv = &u.recv.status;
break;
case XACE_CLIENT_ACCESS:
u.client.client = va_arg(ap, ClientPtr);
u.client.target = va_arg(ap, ClientPtr);
u.client.access_mode = va_arg(ap, Mask);
u.client.status = Success; /* default allow */
prv = &u.client.status;
break;
case XACE_EXT_ACCESS:
u.ext.client = va_arg(ap, ClientPtr);
u.ext.ext = va_arg(ap, ExtensionEntry*);
u.ext.access_mode = DixGetAttrAccess;
u.ext.status = Success; /* default allow */
prv = &u.ext.status;
break;
case XACE_SERVER_ACCESS:
u.server.client = va_arg(ap, ClientPtr);
u.server.access_mode = va_arg(ap, Mask);
u.server.status = Success; /* default allow */
prv = &u.server.status;
break;
case XACE_SCREEN_ACCESS:
case XACE_SCREENSAVER_ACCESS:
u.screen.client = va_arg(ap, ClientPtr);
u.screen.screen = va_arg(ap, ScreenPtr);
u.screen.access_mode = va_arg(ap, Mask);
u.screen.status = Success; /* default allow */
prv = &u.screen.status;
break;
case XACE_AUTH_AVAIL:
u.auth.client = va_arg(ap, ClientPtr);
u.auth.authId = va_arg(ap, XID);
break;
case XACE_KEY_AVAIL:
u.key.event = va_arg(ap, xEventPtr);
u.key.keybd = va_arg(ap, DeviceIntPtr);
u.key.count = va_arg(ap, int);
break;
default:
va_end(ap);
return 0; /* unimplemented hook number */
}
va_end(ap);
/* call callbacks and return result, if any. */
CallCallbacks(&XaceHooks[hook], &u);
return prv ? *prv : Success;
} }
/* XaceCensorImage /* XaceCensorImage
@ -180,104 +218,114 @@ XaceHookIsSet(int hook)
* region of the window will be destroyed (overwritten) in pBuf. * region of the window will be destroyed (overwritten) in pBuf.
*/ */
void void
XaceCensorImage(ClientPtr client, XaceCensorImage(
RegionPtr pVisibleRegion, ClientPtr client,
long widthBytesLine, RegionPtr pVisibleRegion,
DrawablePtr pDraw, long widthBytesLine,
int x, int y, int w, int h, unsigned int format, char *pBuf) DrawablePtr pDraw,
int x, int y, int w, int h,
unsigned int format,
char *pBuf)
{ {
RegionRec imageRegion; /* region representing x,y,w,h */ RegionRec imageRegion; /* region representing x,y,w,h */
RegionRec censorRegion; /* region to obliterate */ RegionRec censorRegion; /* region to obliterate */
BoxRec imageBox; BoxRec imageBox;
int nRects; int nRects;
imageBox.x1 = pDraw->x + x; imageBox.x1 = x;
imageBox.y1 = pDraw->y + y; imageBox.y1 = y;
imageBox.x2 = pDraw->x + x + w; imageBox.x2 = x + w;
imageBox.y2 = pDraw->y + y + h; imageBox.y2 = y + h;
RegionInit(&imageRegion, &imageBox, 1); RegionInit(&imageRegion, &imageBox, 1);
RegionNull(&censorRegion); RegionNull(&censorRegion);
/* censorRegion = imageRegion - visibleRegion */ /* censorRegion = imageRegion - visibleRegion */
RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion); RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion);
nRects = RegionNumRects(&censorRegion); nRects = RegionNumRects(&censorRegion);
if (nRects > 0) { /* we have something to censor */ if (nRects > 0)
GCPtr pScratchGC = NULL; { /* we have something to censor */
PixmapPtr pPix = NULL; GCPtr pScratchGC = NULL;
xRectangle *pRects = NULL; PixmapPtr pPix = NULL;
Bool failed = FALSE; xRectangle *pRects = NULL;
int depth = 1; Bool failed = FALSE;
int bitsPerPixel = 1; int depth = 1;
int i; int bitsPerPixel = 1;
BoxPtr pBox; int i;
BoxPtr pBox;
/* convert region to list-of-rectangles for PolyFillRect */ /* convert region to list-of-rectangles for PolyFillRect */
pRects = malloc(nRects * sizeof(xRectangle)); pRects = malloc(nRects * sizeof(xRectangle));
if (!pRects) { if (!pRects)
failed = TRUE; {
goto failSafe; failed = TRUE;
} goto failSafe;
for (pBox = RegionRects(&censorRegion), i = 0; i < nRects; i++, pBox++) { }
pRects[i].x = pBox->x1 - imageBox.x1; for (pBox = RegionRects(&censorRegion), i = 0;
pRects[i].y = pBox->y1 - imageBox.y1; i < nRects;
pRects[i].width = pBox->x2 - pBox->x1; i++, pBox++)
pRects[i].height = pBox->y2 - pBox->y1; {
} pRects[i].x = pBox->x1;
pRects[i].y = pBox->y1 - imageBox.y1;
pRects[i].width = pBox->x2 - pBox->x1;
pRects[i].height = pBox->y2 - pBox->y1;
}
/* use pBuf as a fake pixmap */ /* use pBuf as a fake pixmap */
if (format == ZPixmap) { if (format == ZPixmap)
depth = pDraw->depth; {
bitsPerPixel = pDraw->bitsPerPixel; depth = pDraw->depth;
} bitsPerPixel = pDraw->bitsPerPixel;
}
pPix = GetScratchPixmapHeader(pDraw->pScreen, w, h, pPix = GetScratchPixmapHeader(pDraw->pScreen, w, h,
depth, bitsPerPixel, depth, bitsPerPixel,
widthBytesLine, (void *) pBuf); widthBytesLine, (pointer)pBuf);
if (!pPix) { if (!pPix)
failed = TRUE; {
goto failSafe; failed = TRUE;
} goto failSafe;
}
pScratchGC = GetScratchGC(depth, pPix->drawable.pScreen); pScratchGC = GetScratchGC(depth, pPix->drawable.pScreen);
if (!pScratchGC) { if (!pScratchGC)
failed = TRUE; {
goto failSafe; failed = TRUE;
} goto failSafe;
}
ValidateGC(&pPix->drawable, pScratchGC); ValidateGC(&pPix->drawable, pScratchGC);
(*pScratchGC->ops->PolyFillRect) (&pPix->drawable, (* pScratchGC->ops->PolyFillRect)(&pPix->drawable,
pScratchGC, nRects, pRects); pScratchGC, nRects, pRects);
failSafe: failSafe:
if (failed) { if (failed)
/* Censoring was not completed above. To be safe, wipe out {
* all the image data so that nothing trusted gets out. /* Censoring was not completed above. To be safe, wipe out
*/ * all the image data so that nothing trusted gets out.
memset(pBuf, 0, (int) (widthBytesLine * h)); */
} memset(pBuf, 0, (int)(widthBytesLine * h));
free(pRects); }
if (pScratchGC) free(pRects);
FreeScratchGC(pScratchGC); if (pScratchGC) FreeScratchGC(pScratchGC);
if (pPix) if (pPix) FreeScratchPixmapHeader(pPix);
FreeScratchPixmapHeader(pPix);
} }
RegionUninit(&imageRegion); RegionUninit(&imageRegion);
RegionUninit(&censorRegion); RegionUninit(&censorRegion);
} /* XaceCensorImage */ } /* XaceCensorImage */
/* /*
* Xtrans wrappers for use by modules * Xtrans wrappers for use by modules
*/ */
int int XaceGetConnectionNumber(ClientPtr client)
XaceGetConnectionNumber(ClientPtr client)
{ {
return GetClientFd(client); XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn;
return _XSERVTransGetConnectionNumber(ci);
} }
int int XaceIsLocal(ClientPtr client)
XaceIsLocal(ClientPtr client)
{ {
return ClientIsLocal(client); XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn;
return _XSERVTransIsLocal(ci);
} }

View file

@ -25,7 +25,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_MAJOR_VERSION 2 #define XACE_MAJOR_VERSION 2
#define XACE_MINOR_VERSION 0 #define XACE_MINOR_VERSION 0
#include "extnsionst.h"
#include "pixmap.h" #include "pixmap.h"
#include "region.h" #include "region.h"
#include "window.h" #include "window.h"
@ -53,51 +52,28 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_SCREENSAVER_ACCESS 12 #define XACE_SCREENSAVER_ACCESS 12
#define XACE_AUTH_AVAIL 13 #define XACE_AUTH_AVAIL 13
#define XACE_KEY_AVAIL 14 #define XACE_KEY_AVAIL 14
#define XACE_NUM_HOOKS 15 #define XACE_AUDIT_BEGIN 15
#define XACE_AUDIT_END 16
#define XACE_NUM_HOOKS 17
extern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; extern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS];
/* Entry point for hook functions. Called by Xserver. /* Entry point for hook functions. Called by Xserver.
* Required by libdbe and libextmod * Required by libdbe and libextmod
*/ */
extern _X_EXPORT int XaceHook(int /*hook */ , extern _X_EXPORT int XaceHook(
... /*appropriate args for hook */ int /*hook*/,
); ... /*appropriate args for hook*/
);
/* determine whether any callbacks are present for the XACE hook */
extern _X_EXPORT int XaceHookIsSet(int hook);
/* Special-cased hook functions /* Special-cased hook functions
*/ */
int XaceHookDispatch0(ClientPtr client, int major); extern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major);
#define XaceHookDispatch(c, m) \
((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \
XaceHookDispatch0((c), (m)) : \
Success)
extern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, extern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin,
PropertyPtr *ppProp, PropertyPtr *ppProp, Mask access_mode);
Mask access_mode); extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr,
extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel, Selection **ppSel, Mask access_mode);
Mask access_mode); extern _X_EXPORT void XaceHookAuditEnd(ClientPtr ptr, int result);
/* needs to be exported for in-tree modsetting, but not part of public API */
_X_EXPORT int XaceHookResourceAccess(ClientPtr client, XID id, RESTYPE rtype, void *res,
RESTYPE ptype, void *parent, Mask access_mode);
int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode);
int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win,
xEventPtr ev, int count);
int XaceHookReceiveAccess(ClientPtr client, WindowPtr win, xEventPtr ev, int count);
int XaceHookClientAccess(ClientPtr client, ClientPtr target, Mask access_mode);
int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext);
int XaceHookServerAccess(ClientPtr client, Mask access_mode);
int XaceHookScreenAccess(ClientPtr client, ScreenPtr screen, Mask access_mode);
int XaceHookScreensaverAccess(ClientPtr client, ScreenPtr screen, Mask access_mode);
int XaceHookAuthAvail(ClientPtr client, XID authId);
int XaceHookKeyAvail(xEventPtr ev, DeviceIntPtr dev, int count);
/* Register a callback for a given hook. /* Register a callback for a given hook.
*/ */
@ -117,14 +93,17 @@ extern _X_EXPORT int XaceIsLocal(ClientPtr ptr);
/* From the original Security extension... /* From the original Security extension...
*/ */
extern _X_EXPORT void XaceCensorImage(ClientPtr client, extern _X_EXPORT void XaceCensorImage(
RegionPtr pVisibleRegion, ClientPtr client,
long widthBytesLine, RegionPtr pVisibleRegion,
DrawablePtr pDraw, long widthBytesLine,
int x, int y, int w, int h, DrawablePtr pDraw,
unsigned int format, char *pBuf); int x, int y, int w, int h,
unsigned int format,
char * pBuf
);
#else /* XACE */ #else /* XACE */
/* Default window background */ /* Default window background */
#define XaceBackgroundNoneState(w) None #define XaceBackgroundNoneState(w) None
@ -132,41 +111,21 @@ extern _X_EXPORT void XaceCensorImage(ClientPtr client,
/* Define calls away when XACE is not being built. */ /* Define calls away when XACE is not being built. */
#ifdef __GNUC__ #ifdef __GNUC__
#define XaceHookIsSet(args...) 0 #define XaceHook(args...) Success
#define XaceHookDispatch(args...) Success #define XaceHookDispatch(args...) Success
#define XaceHookPropertyAccess(args...) Success #define XaceHookPropertyAccess(args...) Success
#define XaceHookSelectionAccess(args...) Success #define XaceHookSelectionAccess(args...) Success
#define XaceHookResourceAccess(args...) Success #define XaceHookAuditEnd(args...) { ; }
#define XaceHookDeviceAccess(args...) Success
#define XaceHookSendAccess(args...) Success
#define XaceHookReceiveAccess(args...) Success
#define XaceHookClientAccess(args...) Success
#define XaceHookExtAccess(args...) Success
#define XaceHookServerAccess(args...) Success
#define XaceHookScreenAccess(args...) Success
#define XaceHookScreensaverAccess(args...) Success
#define XaceHookAuthAvail(args...) Success
#define XaceHookKeyAvail(args...) Success
#define XaceCensorImage(args...) { ; } #define XaceCensorImage(args...) { ; }
#else #else
#define XaceHookIsSet(...) 0 #define XaceHook(...) Success
#define XaceHookDispatch(...) Success #define XaceHookDispatch(...) Success
#define XaceHookPropertyAccess(...) Success #define XaceHookPropertyAccess(...) Success
#define XaceHookSelectionAccess(...) Success #define XaceHookSelectionAccess(...) Success
#define XaceHookResourceAccess(...) Success #define XaceHookAuditEnd(...) { ; }
#define XaceHookDeviceAccess(...) Success
#define XaceHookSendAccess(...) Success
#define XaceHookReceiveAccess(...) Success
#define XaceHookClientAccess(...) Success
#define XaceHookExtAccess(...) Success
#define XaceHookServerAccess(...) Success
#define XaceHookScreenAccess(...) Success
#define XaceHookScreensaverAccess(...) Success
#define XaceHookAuthAvail(...) Success
#define XaceHookKeyAvail(...) Success
#define XaceCensorImage(...) { ; } #define XaceCensorImage(...) { ; }
#endif #endif
#endif /* XACE */ #endif /* XACE */
#endif /* _XACE_H */ #endif /* _XACE_H */

View file

@ -40,9 +40,9 @@ typedef struct {
ClientPtr client; ClientPtr client;
XID id; XID id;
RESTYPE rtype; RESTYPE rtype;
void *res; pointer res;
RESTYPE ptype; RESTYPE ptype;
void *parent; pointer parent;
Mask access_mode; Mask access_mode;
int status; int status;
} XaceResourceAccessRec; } XaceResourceAccessRec;
@ -144,4 +144,4 @@ typedef struct {
int requestResult; int requestResult;
} XaceAuditRec; } XaceAuditRec;
#endif /* _XACESTR_H */ #endif /* _XACESTR_H */

View file

@ -26,7 +26,9 @@ from The Open Group.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
@ -36,29 +38,33 @@ from The Open Group.
#include "extnsionst.h" #include "extnsionst.h"
#include "swaprep.h" #include "swaprep.h"
#include <X11/extensions/xcmiscproto.h> #include <X11/extensions/xcmiscproto.h>
#include "extinit_priv.h" #include "modinit.h"
#if HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#elif !defined(UINT32_MAX)
#define UINT32_MAX 0xffffffffU
#endif
static int static int
ProcXCMiscGetVersion(ClientPtr client) ProcXCMiscGetVersion(ClientPtr client)
{ {
xXCMiscGetVersionReply rep = { xXCMiscGetVersionReply rep;
.type = X_Reply, int n;
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = XCMiscMajorVersion,
.minorVersion = XCMiscMinorVersion
};
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq); REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XCMiscMajorVersion;
rep.minorVersion = XCMiscMinorVersion;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swaps(&rep.majorVersion); swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion); swaps(&rep.minorVersion, n);
} }
WriteToClient(client, sizeof(xXCMiscGetVersionReply), &rep); WriteToClient(client, sizeof(xXCMiscGetVersionReply), (char *)&rep);
return Success; return Success;
} }
@ -66,23 +72,22 @@ static int
ProcXCMiscGetXIDRange(ClientPtr client) ProcXCMiscGetXIDRange(ClientPtr client)
{ {
xXCMiscGetXIDRangeReply rep; xXCMiscGetXIDRangeReply rep;
int n;
XID min_id, max_id; XID min_id, max_id;
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq); REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
GetXIDRange(client->index, FALSE, &min_id, &max_id); GetXIDRange(client->index, FALSE, &min_id, &max_id);
rep = (xXCMiscGetXIDRangeReply) { rep.type = X_Reply;
.type = X_Reply, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0, rep.start_id = min_id;
.start_id = min_id, rep.count = max_id - min_id + 1;
.count = max_id - min_id + 1
};
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swapl(&rep.start_id); swapl(&rep.start_id, n);
swapl(&rep.count); swapl(&rep.count, n);
} }
WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), &rep); WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), (char *)&rep);
return Success; return Success;
} }
@ -91,95 +96,112 @@ ProcXCMiscGetXIDList(ClientPtr client)
{ {
REQUEST(xXCMiscGetXIDListReq); REQUEST(xXCMiscGetXIDListReq);
xXCMiscGetXIDListReply rep; xXCMiscGetXIDListReply rep;
int n;
XID *pids; XID *pids;
unsigned int count; unsigned int count;
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq); REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
if (stuff->count > UINT32_MAX / sizeof(XID)) if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc; return BadAlloc;
pids = xallocarray(stuff->count, sizeof(XID)); pids = (XID *)malloc(stuff->count * sizeof(XID));
if (!pids) { if (!pids)
return BadAlloc; {
return BadAlloc;
} }
count = GetXIDList(client, stuff->count, pids); count = GetXIDList(client, stuff->count, pids);
rep = (xXCMiscGetXIDListReply) { rep.type = X_Reply;
.type = X_Reply, rep.sequenceNumber = client->sequence;
.sequenceNumber = client->sequence, rep.length = count;
.length = count, rep.count = count;
.count = count
};
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swapl(&rep.length); swapl(&rep.length, n);
swapl(&rep.count); swapl(&rep.count, n);
} }
WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep); WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *)&rep);
if (count) { if (count)
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; {
WriteSwappedDataToClient(client, count * sizeof(XID), pids); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
} }
free(pids); free(pids);
return Success; return Success;
} }
static int static int
ProcXCMiscDispatch(ClientPtr client) ProcXCMiscDispatch (ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data)
{
case X_XCMiscGetVersion: case X_XCMiscGetVersion:
return ProcXCMiscGetVersion(client); return ProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange: case X_XCMiscGetXIDRange:
return ProcXCMiscGetXIDRange(client); return ProcXCMiscGetXIDRange(client);
case X_XCMiscGetXIDList: case X_XCMiscGetXIDList:
return ProcXCMiscGetXIDList(client); return ProcXCMiscGetXIDList(client);
default: default:
return BadRequest; return BadRequest;
} }
} }
static int _X_COLD static int
SProcXCMiscGetVersion(ClientPtr client) SProcXCMiscGetVersion(ClientPtr client)
{ {
int n;
REQUEST(xXCMiscGetVersionReq); REQUEST(xXCMiscGetVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq); REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion, n);
return ProcXCMiscGetVersion(client); return ProcXCMiscGetVersion(client);
} }
static int _X_COLD static int
SProcXCMiscGetXIDRange(ClientPtr client)
{
int n;
REQUEST(xReq);
swaps(&stuff->length, n);
return ProcXCMiscGetXIDRange(client);
}
static int
SProcXCMiscGetXIDList(ClientPtr client) SProcXCMiscGetXIDList(ClientPtr client)
{ {
int n;
REQUEST(xXCMiscGetXIDListReq); REQUEST(xXCMiscGetXIDListReq);
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
swapl(&stuff->count); swaps(&stuff->length, n);
swapl(&stuff->count, n);
return ProcXCMiscGetXIDList(client); return ProcXCMiscGetXIDList(client);
} }
static int _X_COLD static int
SProcXCMiscDispatch(ClientPtr client) SProcXCMiscDispatch (ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data)
{
case X_XCMiscGetVersion: case X_XCMiscGetVersion:
return SProcXCMiscGetVersion(client); return SProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange: case X_XCMiscGetXIDRange:
return ProcXCMiscGetXIDRange(client); return SProcXCMiscGetXIDRange(client);
case X_XCMiscGetXIDList: case X_XCMiscGetXIDList:
return SProcXCMiscGetXIDList(client); return SProcXCMiscGetXIDList(client);
default: default:
return BadRequest; return BadRequest;
} }
} }
void void
XCMiscExtensionInit(void) XCMiscExtensionInit(INITARGS)
{ {
AddExtension(XCMiscExtensionName, 0, 0, AddExtension(XCMiscExtensionName, 0, 0,
ProcXCMiscDispatch, SProcXCMiscDispatch, ProcXCMiscDispatch, SProcXCMiscDispatch,
NULL, StandardMinorOpcode); NULL, StandardMinorOpcode);
} }

File diff suppressed because it is too large Load diff

View file

@ -27,6 +27,7 @@
#include <X11/fonts/font.h> #include <X11/fonts/font.h>
extern void XFree86BigfontExtensionInit(void);
extern void XF86BigfontFreeFontShm(FontPtr); extern void XF86BigfontFreeFontShm(FontPtr);
extern void XF86BigfontCleanup(void); extern void XF86BigfontCleanup(void);

File diff suppressed because it is too large Load diff

View file

@ -53,95 +53,87 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define X_SELinuxGetClientContext 22 #define X_SELinuxGetClientContext 22
typedef struct { typedef struct {
CARD8 reqType; CARD8 reqType;
CARD8 SELinuxReqType; CARD8 SELinuxReqType;
CARD16 length; CARD16 length;
CARD8 client_major; CARD8 client_major;
CARD8 client_minor; CARD8 client_minor;
} SELinuxQueryVersionReq; } SELinuxQueryVersionReq;
typedef struct { typedef struct {
CARD8 type; CARD8 type;
CARD8 pad1; CARD8 pad1;
CARD16 sequenceNumber; CARD16 sequenceNumber;
CARD32 length; CARD32 length;
CARD16 server_major; CARD16 server_major;
CARD16 server_minor; CARD16 server_minor;
CARD32 pad2; CARD32 pad2;
CARD32 pad3; CARD32 pad3;
CARD32 pad4; CARD32 pad4;
CARD32 pad5; CARD32 pad5;
CARD32 pad6; CARD32 pad6;
} SELinuxQueryVersionReply; } SELinuxQueryVersionReply;
typedef struct { typedef struct {
CARD8 reqType; CARD8 reqType;
CARD8 SELinuxReqType; CARD8 SELinuxReqType;
CARD16 length; CARD16 length;
CARD32 context_len; CARD32 context_len;
} SELinuxSetCreateContextReq; } SELinuxSetCreateContextReq;
typedef struct { typedef struct {
CARD8 reqType; CARD8 reqType;
CARD8 SELinuxReqType; CARD8 SELinuxReqType;
CARD16 length; CARD16 length;
} SELinuxGetCreateContextReq; } SELinuxGetCreateContextReq;
typedef struct { typedef struct {
CARD8 reqType; CARD8 reqType;
CARD8 SELinuxReqType; CARD8 SELinuxReqType;
CARD16 length; CARD16 length;
CARD32 id; CARD32 id;
CARD32 context_len; CARD32 context_len;
} SELinuxSetContextReq; } SELinuxSetContextReq;
typedef struct { typedef struct {
CARD8 reqType; CARD8 reqType;
CARD8 SELinuxReqType; CARD8 SELinuxReqType;
CARD16 length; CARD16 length;
CARD32 id; CARD32 id;
} SELinuxGetContextReq; } SELinuxGetContextReq;
typedef struct { typedef struct {
CARD8 reqType; CARD8 reqType;
CARD8 SELinuxReqType; CARD8 SELinuxReqType;
CARD16 length; CARD16 length;
CARD32 window; CARD32 window;
CARD32 property; CARD32 property;
} SELinuxGetPropertyContextReq; } SELinuxGetPropertyContextReq;
typedef struct { typedef struct {
CARD8 type; CARD8 type;
CARD8 pad1; CARD8 pad1;
CARD16 sequenceNumber; CARD16 sequenceNumber;
CARD32 length; CARD32 length;
CARD32 context_len; CARD32 context_len;
CARD32 pad2; CARD32 pad2;
CARD32 pad3; CARD32 pad3;
CARD32 pad4; CARD32 pad4;
CARD32 pad5; CARD32 pad5;
CARD32 pad6; CARD32 pad6;
} SELinuxGetContextReply; } SELinuxGetContextReply;
typedef struct { typedef struct {
CARD8 type; CARD8 type;
CARD8 pad1; CARD8 pad1;
CARD16 sequenceNumber; CARD16 sequenceNumber;
CARD32 length; CARD32 length;
CARD32 count; CARD32 count;
CARD32 pad2; CARD32 pad2;
CARD32 pad3; CARD32 pad3;
CARD32 pad4; CARD32 pad4;
CARD32 pad5; CARD32 pad5;
CARD32 pad6; CARD32 pad6;
} SELinuxListItemsReply; } SELinuxListItemsReply;
#ifdef XSELINUX #endif /* _XSELINUX_H */
#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 */

View file

@ -17,16 +17,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "dix/dix_priv.h"
#include "selection.h" #include "selection.h"
#include "inputstr.h" #include "inputstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "propertyst.h" #include "propertyst.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "extinit_priv.h" #include "modinit.h"
#include "xselinuxint.h" #include "xselinuxint.h"
#define CTX_DEV offsetof(SELinuxSubjectRec, dev_create_sid) #define CTX_DEV offsetof(SELinuxSubjectRec, dev_create_sid)
@ -37,27 +37,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define USE_SEL offsetof(SELinuxSubjectRec, sel_use_sid) #define USE_SEL offsetof(SELinuxSubjectRec, sel_use_sid)
typedef struct { typedef struct {
char *octx; security_context_t octx;
char *dctx; security_context_t dctx;
CARD32 octx_len; CARD32 octx_len;
CARD32 dctx_len; CARD32 dctx_len;
CARD32 id; CARD32 id;
} SELinuxListItemRec; } SELinuxListItemRec;
Bool noSELinuxExtension = FALSE;
int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
/* /*
* Extension Dispatch * Extension Dispatch
*/ */
static char * static security_context_t
SELinuxCopyContext(char *ptr, unsigned len) SELinuxCopyContext(char *ptr, unsigned len)
{ {
char *copy = malloc(len + 1); security_context_t copy = malloc(len + 1);
if (!copy) if (!copy)
return NULL; return NULL;
strncpy(copy, ptr, len); strncpy(copy, ptr, len);
copy[len] = '\0'; copy[len] = '\0';
return copy; return copy;
@ -66,48 +63,50 @@ SELinuxCopyContext(char *ptr, unsigned len)
static int static int
ProcSELinuxQueryVersion(ClientPtr client) ProcSELinuxQueryVersion(ClientPtr client)
{ {
SELinuxQueryVersionReply rep = { SELinuxQueryVersionReply rep;
.type = X_Reply,
.sequenceNumber = client->sequence, rep.type = X_Reply;
.server_major = SELINUX_MAJOR_VERSION, rep.length = 0;
.server_minor = SELINUX_MINOR_VERSION rep.sequenceNumber = client->sequence;
}; rep.server_major = SELINUX_MAJOR_VERSION;
rep.server_minor = SELINUX_MINOR_VERSION;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); int n;
swapl(&rep.length); swaps(&rep.sequenceNumber, n);
swaps(&rep.server_major); swapl(&rep.length, n);
swaps(&rep.server_minor); swaps(&rep.server_major, n);
swaps(&rep.server_minor, n);
} }
WriteToClient(client, sizeof(rep), &rep); WriteToClient(client, sizeof(rep), (char *)&rep);
return Success; return Success;
} }
static int static int
SELinuxSendContextReply(ClientPtr client, security_id_t sid) SELinuxSendContextReply(ClientPtr client, security_id_t sid)
{ {
char *ctx = NULL; SELinuxGetContextReply rep;
security_context_t ctx = NULL;
int len = 0; int len = 0;
if (sid) { if (sid) {
if (avc_sid_to_context_raw(sid, &ctx) < 0) if (avc_sid_to_context_raw(sid, &ctx) < 0)
return BadValue; return BadValue;
len = strlen(ctx) + 1; len = strlen(ctx) + 1;
} }
SELinuxGetContextReply rep = { rep.type = X_Reply;
.type = X_Reply, rep.length = bytes_to_int32(len);
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = bytes_to_int32(len), rep.context_len = len;
.context_len = len
};
if (client->swapped) { if (client->swapped) {
swapl(&rep.length); int n;
swaps(&rep.sequenceNumber); swapl(&rep.length, n);
swapl(&rep.context_len); swaps(&rep.sequenceNumber, n);
swapl(&rep.context_len, n);
} }
WriteToClient(client, sizeof(SELinuxGetContextReply), &rep); WriteToClient(client, sizeof(SELinuxGetContextReply), (char *)&rep);
WriteToClient(client, len, ctx); WriteToClient(client, len, ctx);
freecon(ctx); freecon(ctx);
return Success; return Success;
@ -118,7 +117,7 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
{ {
PrivateRec **privPtr = &client->devPrivates; PrivateRec **privPtr = &client->devPrivates;
security_id_t *pSid; security_id_t *pSid;
char *ctx = NULL; security_context_t ctx = NULL;
char *ptr; char *ptr;
int rc; int rc;
@ -126,20 +125,20 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len); REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len);
if (stuff->context_len > 0) { if (stuff->context_len > 0) {
ctx = SELinuxCopyContext((char *) (stuff + 1), stuff->context_len); ctx = SELinuxCopyContext((char *)(stuff + 1), stuff->context_len);
if (!ctx) if (!ctx)
return BadAlloc; return BadAlloc;
} }
ptr = dixLookupPrivate(privPtr, subjectKey); ptr = dixLookupPrivate(privPtr, subjectKey);
pSid = (security_id_t *) (ptr + offset); pSid = (security_id_t *)(ptr + offset);
*pSid = NULL; *pSid = NULL;
rc = Success; rc = Success;
if (stuff->context_len > 0) { if (stuff->context_len > 0) {
if (security_check_context_raw(ctx) < 0 || if (security_check_context_raw(ctx) < 0 ||
avc_context_to_sid_raw(ctx, pSid) < 0) avc_context_to_sid_raw(ctx, pSid) < 0)
rc = BadValue; rc = BadValue;
} }
free(ctx); free(ctx);
@ -155,18 +154,18 @@ ProcSELinuxGetCreateContext(ClientPtr client, unsigned offset)
REQUEST_SIZE_MATCH(SELinuxGetCreateContextReq); REQUEST_SIZE_MATCH(SELinuxGetCreateContextReq);
if (offset == CTX_DEV) if (offset == CTX_DEV)
ptr = dixLookupPrivate(&serverClient->devPrivates, subjectKey); ptr = dixLookupPrivate(&serverClient->devPrivates, subjectKey);
else else
ptr = dixLookupPrivate(&client->devPrivates, subjectKey); ptr = dixLookupPrivate(&client->devPrivates, subjectKey);
pSid = (security_id_t *) (ptr + offset); pSid = (security_id_t *)(ptr + offset);
return SELinuxSendContextReply(client, *pSid); return SELinuxSendContextReply(client, *pSid);
} }
static int static int
ProcSELinuxSetDeviceContext(ClientPtr client) ProcSELinuxSetDeviceContext(ClientPtr client)
{ {
char *ctx; security_context_t ctx;
security_id_t sid; security_id_t sid;
DeviceIntPtr dev; DeviceIntPtr dev;
SELinuxSubjectRec *subj; SELinuxSubjectRec *subj;
@ -177,19 +176,19 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len); REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
if (stuff->context_len < 1) if (stuff->context_len < 1)
return BadLength; return BadLength;
ctx = SELinuxCopyContext((char *) (stuff + 1), stuff->context_len); ctx = SELinuxCopyContext((char *)(stuff + 1), stuff->context_len);
if (!ctx) if (!ctx)
return BadAlloc; return BadAlloc;
rc = dixLookupDevice(&dev, stuff->id, client, DixManageAccess); rc = dixLookupDevice(&dev, stuff->id, client, DixManageAccess);
if (rc != Success) if (rc != Success)
goto out; goto out;
if (security_check_context_raw(ctx) < 0 || if (security_check_context_raw(ctx) < 0 ||
avc_context_to_sid_raw(ctx, &sid) < 0) { avc_context_to_sid_raw(ctx, &sid) < 0) {
rc = BadValue; rc = BadValue;
goto out; goto out;
} }
subj = dixLookupPrivate(&dev->devPrivates, subjectKey); subj = dixLookupPrivate(&dev->devPrivates, subjectKey);
@ -198,7 +197,7 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
obj->sid = sid; obj->sid = sid;
rc = Success; rc = Success;
out: out:
free(ctx); free(ctx);
return rc; return rc;
} }
@ -215,7 +214,7 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
rc = dixLookupDevice(&dev, stuff->id, client, DixGetAttrAccess); rc = dixLookupDevice(&dev, stuff->id, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
subj = dixLookupPrivate(&dev->devPrivates, subjectKey); subj = dixLookupPrivate(&dev->devPrivates, subjectKey);
return SELinuxSendContextReply(client, subj->sid); return SELinuxSendContextReply(client, subj->sid);
@ -234,19 +233,19 @@ ProcSELinuxGetDrawableContext(ClientPtr client)
rc = dixLookupDrawable(&pDraw, stuff->id, client, 0, DixGetAttrAccess); rc = dixLookupDrawable(&pDraw, stuff->id, client, 0, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (pDraw->type == DRAWABLE_PIXMAP) if (pDraw->type == DRAWABLE_PIXMAP)
privatePtr = &((PixmapPtr) pDraw)->devPrivates; privatePtr = &((PixmapPtr)pDraw)->devPrivates;
else else
privatePtr = &((WindowPtr) pDraw)->devPrivates; privatePtr = &((WindowPtr)pDraw)->devPrivates;
obj = dixLookupPrivate(privatePtr, objectKey); obj = dixLookupPrivate(privatePtr, objectKey);
return SELinuxSendContextReply(client, obj->sid); return SELinuxSendContextReply(client, obj->sid);
} }
static int static int
ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey) ProcSELinuxGetPropertyContext(ClientPtr client, pointer privKey)
{ {
WindowPtr pWin; WindowPtr pWin;
PropertyPtr pProp; PropertyPtr pProp;
@ -258,19 +257,19 @@ ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetPropAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetPropAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rc = dixLookupProperty(&pProp, pWin, stuff->property, client, rc = dixLookupProperty(&pProp, pWin, stuff->property, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
obj = dixLookupPrivate(&pProp->devPrivates, privKey); obj = dixLookupPrivate(&pProp->devPrivates, privKey);
return SELinuxSendContextReply(client, obj->sid); return SELinuxSendContextReply(client, obj->sid);
} }
static int static int
ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey) ProcSELinuxGetSelectionContext(ClientPtr client, pointer privKey)
{ {
Selection *pSel; Selection *pSel;
SELinuxObjectRec *obj; SELinuxObjectRec *obj;
@ -281,7 +280,7 @@ ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess); rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
obj = dixLookupPrivate(&pSel->devPrivates, privKey); obj = dixLookupPrivate(&pSel->devPrivates, privKey);
return SELinuxSendContextReply(client, obj->sid); return SELinuxSendContextReply(client, obj->sid);
@ -299,23 +298,23 @@ ProcSELinuxGetClientContext(ClientPtr client)
rc = dixLookupClient(&target, stuff->id, client, DixGetAttrAccess); rc = dixLookupClient(&target, stuff->id, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
subj = dixLookupPrivate(&target->devPrivates, subjectKey); subj = dixLookupPrivate(&target->devPrivates, subjectKey);
return SELinuxSendContextReply(client, subj->sid); return SELinuxSendContextReply(client, subj->sid);
} }
static int static int
SELinuxPopulateItem(SELinuxListItemRec * i, PrivateRec ** privPtr, CARD32 id, SELinuxPopulateItem(SELinuxListItemRec *i, PrivateRec **privPtr, CARD32 id,
int *size) int *size)
{ {
SELinuxObjectRec *obj = dixLookupPrivate(privPtr, objectKey); SELinuxObjectRec *obj = dixLookupPrivate(privPtr, objectKey);
SELinuxObjectRec *data = dixLookupPrivate(privPtr, dataKey); SELinuxObjectRec *data = dixLookupPrivate(privPtr, dataKey);
if (avc_sid_to_context_raw(obj->sid, &i->octx) < 0) if (avc_sid_to_context_raw(obj->sid, &i->octx) < 0)
return BadValue; return BadValue;
if (avc_sid_to_context_raw(data->sid, &i->dctx) < 0) if (avc_sid_to_context_raw(data->sid, &i->dctx) < 0)
return BadValue; return BadValue;
i->id = id; i->id = id;
i->octx_len = bytes_to_int32(strlen(i->octx) + 1); i->octx_len = bytes_to_int32(strlen(i->octx) + 1);
@ -326,71 +325,72 @@ SELinuxPopulateItem(SELinuxListItemRec * i, PrivateRec ** privPtr, CARD32 id,
} }
static void static void
SELinuxFreeItems(SELinuxListItemRec * items, int count) SELinuxFreeItems(SELinuxListItemRec *items, int count)
{ {
int k; int k;
for (k = 0; k < count; k++) { for (k = 0; k < count; k++) {
freecon(items[k].octx); freecon(items[k].octx);
freecon(items[k].dctx); freecon(items[k].dctx);
} }
free(items); free(items);
} }
static int static int
SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items, SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec *items,
int size, int count) int size, int count)
{ {
int rc = BadAlloc, k, pos = 0; int rc, k, n, pos = 0;
CARD32 *buf = calloc(size, sizeof(CARD32)); SELinuxListItemsReply rep;
CARD32 *buf;
buf = calloc(size, sizeof(CARD32));
if (size && !buf) { if (size && !buf) {
goto out; rc = BadAlloc;
goto out;
} }
/* Fill in the buffer */ /* Fill in the buffer */
for (k = 0; k < count; k++) { for (k = 0; k < count; k++) {
buf[pos] = items[k].id; buf[pos] = items[k].id;
if (client->swapped) if (client->swapped)
swapl(buf + pos); swapl(buf + pos, n);
pos++; pos++;
buf[pos] = items[k].octx_len * 4; buf[pos] = items[k].octx_len * 4;
if (client->swapped) if (client->swapped)
swapl(buf + pos); swapl(buf + pos, n);
pos++; pos++;
buf[pos] = items[k].dctx_len * 4; buf[pos] = items[k].dctx_len * 4;
if (client->swapped) if (client->swapped)
swapl(buf + pos); swapl(buf + pos, n);
pos++; pos++;
memcpy((char *) (buf + pos), items[k].octx, strlen(items[k].octx) + 1); memcpy((char *)(buf + pos), items[k].octx, strlen(items[k].octx) + 1);
pos += items[k].octx_len; pos += items[k].octx_len;
memcpy((char *) (buf + pos), items[k].dctx, strlen(items[k].dctx) + 1); memcpy((char *)(buf + pos), items[k].dctx, strlen(items[k].dctx) + 1);
pos += items[k].dctx_len; pos += items[k].dctx_len;
} }
/* Send reply to client */ /* Send reply to client */
SELinuxListItemsReply rep = { rep.type = X_Reply;
.type = X_Reply, rep.length = size;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = size, rep.count = count;
.count = count
};
if (client->swapped) { if (client->swapped) {
swapl(&rep.length); swapl(&rep.length, n);
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swapl(&rep.count); swapl(&rep.count, n);
} }
WriteToClient(client, sizeof(SELinuxListItemsReply), &rep); WriteToClient(client, sizeof(SELinuxListItemsReply), (char *)&rep);
WriteToClient(client, size * 4, buf); WriteToClient(client, size * 4, (char *)buf);
/* Free stuff and return */ /* Free stuff and return */
rc = Success; rc = Success;
free(buf); free(buf);
out: out:
SELinuxFreeItems(items, count); SELinuxFreeItems(items, count);
return rc; return rc;
} }
@ -409,27 +409,27 @@ ProcSELinuxListProperties(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess); rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
/* Count the number of properties and allocate items */ /* Count the number of properties and allocate items */
count = 0; count = 0;
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
count++; count++;
items = calloc(count, sizeof(SELinuxListItemRec)); items = calloc(count, sizeof(SELinuxListItemRec));
if (count && !items) if (count && !items)
return BadAlloc; return BadAlloc;
/* Fill in the items and calculate size */ /* Fill in the items and calculate size */
i = 0; i = 0;
size = 0; size = 0;
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) { for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) {
id = pProp->propertyName; id = pProp->propertyName;
rc = SELinuxPopulateItem(items + i, &pProp->devPrivates, id, &size); rc = SELinuxPopulateItem(items + i, &pProp->devPrivates, id, &size);
if (rc != Success) { if (rc != Success) {
SELinuxFreeItems(items, count); SELinuxFreeItems(items, count);
return rc; return rc;
} }
i++; i++;
} }
return SELinuxSendItemsToClient(client, items, size, count); return SELinuxSendItemsToClient(client, items, size, count);
@ -448,24 +448,22 @@ ProcSELinuxListSelections(ClientPtr client)
/* Count the number of selections and allocate items */ /* Count the number of selections and allocate items */
count = 0; count = 0;
for (pSel = CurrentSelections; pSel; pSel = pSel->next) for (pSel = CurrentSelections; pSel; pSel = pSel->next)
count++; count++;
if (count == 0)
return SELinuxSendItemsToClient(client, NULL, 0, 0);
items = calloc(count, sizeof(SELinuxListItemRec)); items = calloc(count, sizeof(SELinuxListItemRec));
if (!items) if (count && !items)
return BadAlloc; return BadAlloc;
/* Fill in the items and calculate size */ /* Fill in the items and calculate size */
i = 0; i = 0;
size = 0; size = 0;
for (pSel = CurrentSelections; pSel; pSel = pSel->next) { for (pSel = CurrentSelections; pSel; pSel = pSel->next) {
id = pSel->selection; id = pSel->selection;
rc = SELinuxPopulateItem(items + i, &pSel->devPrivates, id, &size); rc = SELinuxPopulateItem(items + i, &pSel->devPrivates, id, &size);
if (rc != Success) { if (rc != Success) {
SELinuxFreeItems(items, count); SELinuxFreeItems(items, count);
return rc; return rc;
} }
i++; i++;
} }
return SELinuxSendItemsToClient(client, items, size, count); return SELinuxSendItemsToClient(client, items, size, count);
@ -477,226 +475,240 @@ ProcSELinuxDispatch(ClientPtr client)
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data) {
case X_SELinuxQueryVersion: case X_SELinuxQueryVersion:
return ProcSELinuxQueryVersion(client); return ProcSELinuxQueryVersion(client);
case X_SELinuxSetDeviceCreateContext: case X_SELinuxSetDeviceCreateContext:
return ProcSELinuxSetCreateContext(client, CTX_DEV); return ProcSELinuxSetCreateContext(client, CTX_DEV);
case X_SELinuxGetDeviceCreateContext: case X_SELinuxGetDeviceCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_DEV); return ProcSELinuxGetCreateContext(client, CTX_DEV);
case X_SELinuxSetDeviceContext: case X_SELinuxSetDeviceContext:
return ProcSELinuxSetDeviceContext(client); return ProcSELinuxSetDeviceContext(client);
case X_SELinuxGetDeviceContext: case X_SELinuxGetDeviceContext:
return ProcSELinuxGetDeviceContext(client); return ProcSELinuxGetDeviceContext(client);
case X_SELinuxSetDrawableCreateContext: case X_SELinuxSetDrawableCreateContext:
return ProcSELinuxSetCreateContext(client, CTX_WIN); return ProcSELinuxSetCreateContext(client, CTX_WIN);
case X_SELinuxGetDrawableCreateContext: case X_SELinuxGetDrawableCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_WIN); return ProcSELinuxGetCreateContext(client, CTX_WIN);
case X_SELinuxGetDrawableContext: case X_SELinuxGetDrawableContext:
return ProcSELinuxGetDrawableContext(client); return ProcSELinuxGetDrawableContext(client);
case X_SELinuxSetPropertyCreateContext: case X_SELinuxSetPropertyCreateContext:
return ProcSELinuxSetCreateContext(client, CTX_PRP); return ProcSELinuxSetCreateContext(client, CTX_PRP);
case X_SELinuxGetPropertyCreateContext: case X_SELinuxGetPropertyCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_PRP); return ProcSELinuxGetCreateContext(client, CTX_PRP);
case X_SELinuxSetPropertyUseContext: case X_SELinuxSetPropertyUseContext:
return ProcSELinuxSetCreateContext(client, USE_PRP); return ProcSELinuxSetCreateContext(client, USE_PRP);
case X_SELinuxGetPropertyUseContext: case X_SELinuxGetPropertyUseContext:
return ProcSELinuxGetCreateContext(client, USE_PRP); return ProcSELinuxGetCreateContext(client, USE_PRP);
case X_SELinuxGetPropertyContext: case X_SELinuxGetPropertyContext:
return ProcSELinuxGetPropertyContext(client, objectKey); return ProcSELinuxGetPropertyContext(client, objectKey);
case X_SELinuxGetPropertyDataContext: case X_SELinuxGetPropertyDataContext:
return ProcSELinuxGetPropertyContext(client, dataKey); return ProcSELinuxGetPropertyContext(client, dataKey);
case X_SELinuxListProperties: case X_SELinuxListProperties:
return ProcSELinuxListProperties(client); return ProcSELinuxListProperties(client);
case X_SELinuxSetSelectionCreateContext: case X_SELinuxSetSelectionCreateContext:
return ProcSELinuxSetCreateContext(client, CTX_SEL); return ProcSELinuxSetCreateContext(client, CTX_SEL);
case X_SELinuxGetSelectionCreateContext: case X_SELinuxGetSelectionCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_SEL); return ProcSELinuxGetCreateContext(client, CTX_SEL);
case X_SELinuxSetSelectionUseContext: case X_SELinuxSetSelectionUseContext:
return ProcSELinuxSetCreateContext(client, USE_SEL); return ProcSELinuxSetCreateContext(client, USE_SEL);
case X_SELinuxGetSelectionUseContext: case X_SELinuxGetSelectionUseContext:
return ProcSELinuxGetCreateContext(client, USE_SEL); return ProcSELinuxGetCreateContext(client, USE_SEL);
case X_SELinuxGetSelectionContext: case X_SELinuxGetSelectionContext:
return ProcSELinuxGetSelectionContext(client, objectKey); return ProcSELinuxGetSelectionContext(client, objectKey);
case X_SELinuxGetSelectionDataContext: case X_SELinuxGetSelectionDataContext:
return ProcSELinuxGetSelectionContext(client, dataKey); return ProcSELinuxGetSelectionContext(client, dataKey);
case X_SELinuxListSelections: case X_SELinuxListSelections:
return ProcSELinuxListSelections(client); return ProcSELinuxListSelections(client);
case X_SELinuxGetClientContext: case X_SELinuxGetClientContext:
return ProcSELinuxGetClientContext(client); return ProcSELinuxGetClientContext(client);
default: default:
return BadRequest; return BadRequest;
} }
} }
static int _X_COLD static int
SProcSELinuxQueryVersion(ClientPtr client) SProcSELinuxQueryVersion(ClientPtr client)
{ {
return ProcSELinuxQueryVersion(client); return ProcSELinuxQueryVersion(client);
} }
static int _X_COLD static int
SProcSELinuxSetCreateContext(ClientPtr client, unsigned offset) SProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
{ {
REQUEST(SELinuxSetCreateContextReq); REQUEST(SELinuxSetCreateContextReq);
int n;
REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq); REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq);
swapl(&stuff->context_len); swapl(&stuff->context_len, n);
return ProcSELinuxSetCreateContext(client, offset); return ProcSELinuxSetCreateContext(client, offset);
} }
static int _X_COLD static int
SProcSELinuxSetDeviceContext(ClientPtr client) SProcSELinuxSetDeviceContext(ClientPtr client)
{ {
REQUEST(SELinuxSetContextReq); REQUEST(SELinuxSetContextReq);
int n;
REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq); REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq);
swapl(&stuff->id); swapl(&stuff->id, n);
swapl(&stuff->context_len); swapl(&stuff->context_len, n);
return ProcSELinuxSetDeviceContext(client); return ProcSELinuxSetDeviceContext(client);
} }
static int _X_COLD static int
SProcSELinuxGetDeviceContext(ClientPtr client) SProcSELinuxGetDeviceContext(ClientPtr client)
{ {
REQUEST(SELinuxGetContextReq); REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq); REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id); swapl(&stuff->id, n);
return ProcSELinuxGetDeviceContext(client); return ProcSELinuxGetDeviceContext(client);
} }
static int _X_COLD static int
SProcSELinuxGetDrawableContext(ClientPtr client) SProcSELinuxGetDrawableContext(ClientPtr client)
{ {
REQUEST(SELinuxGetContextReq); REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq); REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id); swapl(&stuff->id, n);
return ProcSELinuxGetDrawableContext(client); return ProcSELinuxGetDrawableContext(client);
} }
static int _X_COLD static int
SProcSELinuxGetPropertyContext(ClientPtr client, void *privKey) SProcSELinuxGetPropertyContext(ClientPtr client, pointer privKey)
{ {
REQUEST(SELinuxGetPropertyContextReq); REQUEST(SELinuxGetPropertyContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq); REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
swapl(&stuff->window); swapl(&stuff->window, n);
swapl(&stuff->property); swapl(&stuff->property, n);
return ProcSELinuxGetPropertyContext(client, privKey); return ProcSELinuxGetPropertyContext(client, privKey);
} }
static int _X_COLD static int
SProcSELinuxGetSelectionContext(ClientPtr client, void *privKey) SProcSELinuxGetSelectionContext(ClientPtr client, pointer privKey)
{ {
REQUEST(SELinuxGetContextReq); REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq); REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id); swapl(&stuff->id, n);
return ProcSELinuxGetSelectionContext(client, privKey); return ProcSELinuxGetSelectionContext(client, privKey);
} }
static int _X_COLD static int
SProcSELinuxListProperties(ClientPtr client) SProcSELinuxListProperties(ClientPtr client)
{ {
REQUEST(SELinuxGetContextReq); REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq); REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id); swapl(&stuff->id, n);
return ProcSELinuxListProperties(client); return ProcSELinuxListProperties(client);
} }
static int _X_COLD static int
SProcSELinuxGetClientContext(ClientPtr client) SProcSELinuxGetClientContext(ClientPtr client)
{ {
REQUEST(SELinuxGetContextReq); REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq); REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id); swapl(&stuff->id, n);
return ProcSELinuxGetClientContext(client); return ProcSELinuxGetClientContext(client);
} }
static int _X_COLD static int
SProcSELinuxDispatch(ClientPtr client) SProcSELinuxDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
int n;
swaps(&stuff->length, n);
switch (stuff->data) { switch (stuff->data) {
case X_SELinuxQueryVersion: case X_SELinuxQueryVersion:
return SProcSELinuxQueryVersion(client); return SProcSELinuxQueryVersion(client);
case X_SELinuxSetDeviceCreateContext: case X_SELinuxSetDeviceCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_DEV); return SProcSELinuxSetCreateContext(client, CTX_DEV);
case X_SELinuxGetDeviceCreateContext: case X_SELinuxGetDeviceCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_DEV); return ProcSELinuxGetCreateContext(client, CTX_DEV);
case X_SELinuxSetDeviceContext: case X_SELinuxSetDeviceContext:
return SProcSELinuxSetDeviceContext(client); return SProcSELinuxSetDeviceContext(client);
case X_SELinuxGetDeviceContext: case X_SELinuxGetDeviceContext:
return SProcSELinuxGetDeviceContext(client); return SProcSELinuxGetDeviceContext(client);
case X_SELinuxSetDrawableCreateContext: case X_SELinuxSetDrawableCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_WIN); return SProcSELinuxSetCreateContext(client, CTX_WIN);
case X_SELinuxGetDrawableCreateContext: case X_SELinuxGetDrawableCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_WIN); return ProcSELinuxGetCreateContext(client, CTX_WIN);
case X_SELinuxGetDrawableContext: case X_SELinuxGetDrawableContext:
return SProcSELinuxGetDrawableContext(client); return SProcSELinuxGetDrawableContext(client);
case X_SELinuxSetPropertyCreateContext: case X_SELinuxSetPropertyCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_PRP); return SProcSELinuxSetCreateContext(client, CTX_PRP);
case X_SELinuxGetPropertyCreateContext: case X_SELinuxGetPropertyCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_PRP); return ProcSELinuxGetCreateContext(client, CTX_PRP);
case X_SELinuxSetPropertyUseContext: case X_SELinuxSetPropertyUseContext:
return SProcSELinuxSetCreateContext(client, USE_PRP); return SProcSELinuxSetCreateContext(client, USE_PRP);
case X_SELinuxGetPropertyUseContext: case X_SELinuxGetPropertyUseContext:
return ProcSELinuxGetCreateContext(client, USE_PRP); return ProcSELinuxGetCreateContext(client, USE_PRP);
case X_SELinuxGetPropertyContext: case X_SELinuxGetPropertyContext:
return SProcSELinuxGetPropertyContext(client, objectKey); return SProcSELinuxGetPropertyContext(client, objectKey);
case X_SELinuxGetPropertyDataContext: case X_SELinuxGetPropertyDataContext:
return SProcSELinuxGetPropertyContext(client, dataKey); return SProcSELinuxGetPropertyContext(client, dataKey);
case X_SELinuxListProperties: case X_SELinuxListProperties:
return SProcSELinuxListProperties(client); return SProcSELinuxListProperties(client);
case X_SELinuxSetSelectionCreateContext: case X_SELinuxSetSelectionCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_SEL); return SProcSELinuxSetCreateContext(client, CTX_SEL);
case X_SELinuxGetSelectionCreateContext: case X_SELinuxGetSelectionCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_SEL); return ProcSELinuxGetCreateContext(client, CTX_SEL);
case X_SELinuxSetSelectionUseContext: case X_SELinuxSetSelectionUseContext:
return SProcSELinuxSetCreateContext(client, USE_SEL); return SProcSELinuxSetCreateContext(client, USE_SEL);
case X_SELinuxGetSelectionUseContext: case X_SELinuxGetSelectionUseContext:
return ProcSELinuxGetCreateContext(client, USE_SEL); return ProcSELinuxGetCreateContext(client, USE_SEL);
case X_SELinuxGetSelectionContext: case X_SELinuxGetSelectionContext:
return SProcSELinuxGetSelectionContext(client, objectKey); return SProcSELinuxGetSelectionContext(client, objectKey);
case X_SELinuxGetSelectionDataContext: case X_SELinuxGetSelectionDataContext:
return SProcSELinuxGetSelectionContext(client, dataKey); return SProcSELinuxGetSelectionContext(client, dataKey);
case X_SELinuxListSelections: case X_SELinuxListSelections:
return ProcSELinuxListSelections(client); return ProcSELinuxListSelections(client);
case X_SELinuxGetClientContext: case X_SELinuxGetClientContext:
return SProcSELinuxGetClientContext(client); return SProcSELinuxGetClientContext(client);
default: default:
return BadRequest; return BadRequest;
} }
} }
/* /*
* Extension Setup / Teardown * Extension Setup / Teardown
*/ */
static void static void
SELinuxResetProc(ExtensionEntry * extEntry) SELinuxResetProc(ExtensionEntry *extEntry)
{ {
SELinuxFlaskReset(); SELinuxFlaskReset();
SELinuxLabelReset(); SELinuxLabelReset();
} }
void void
SELinuxExtensionInit(void) SELinuxExtensionInit(INITARGS)
{ {
ExtensionEntry *extEntry;
/* Check SELinux mode on system, configuration file, and boolean */ /* Check SELinux mode on system, configuration file, and boolean */
if (!is_selinux_enabled()) { if (!is_selinux_enabled()) {
LogMessage(X_INFO, "SELinux: Disabled on system\n"); LogMessage(X_INFO, "SELinux: Disabled on system\n");
return; return;
} }
if (selinuxEnforcingState == SELINUX_MODE_DISABLED) { if (selinuxEnforcingState == SELINUX_MODE_DISABLED) {
LogMessage(X_INFO, "SELinux: Disabled in configuration file\n"); LogMessage(X_INFO, "SELinux: Disabled in configuration file\n");
return; return;
} }
if (!security_get_boolean_active("xserver_object_manager")) { if (!security_get_boolean_active("xserver_object_manager")) {
LogMessage(X_INFO, "SELinux: Disabled by boolean\n"); LogMessage(X_INFO, "SELinux: Disabled by boolean\n");
return; return;
} }
@ -705,7 +717,10 @@ SELinuxExtensionInit(void)
SELinuxFlaskInit(); SELinuxFlaskInit();
/* Add extension to server */ /* Add extension to server */
AddExtension(SELINUX_EXTENSION_NAME, SELinuxNumberEvents, extEntry = AddExtension(SELINUX_EXTENSION_NAME,
SELinuxNumberErrors, ProcSELinuxDispatch, SELinuxNumberEvents, SELinuxNumberErrors,
SProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode); ProcSELinuxDispatch, SProcSELinuxDispatch,
SELinuxResetProc, StandardMinorOpcode);
AddExtensionAlias("Flask", extEntry);
} }

File diff suppressed because it is too large Load diff

View file

@ -17,12 +17,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <selinux/label.h> #include <selinux/label.h>
#include "dix/registry_priv.h" #include "registry.h"
#include "xselinuxint.h" #include "xselinuxint.h"
/* selection and property atom cache */ /* selection and property atom cache */
@ -42,10 +43,8 @@ static struct selabel_handle *label_hnd;
/* Array of object classes indexed by resource type */ /* Array of object classes indexed by resource type */
SELinuxArrayRec arr_types; SELinuxArrayRec arr_types;
/* Array of event SIDs indexed by event type */ /* Array of event SIDs indexed by event type */
SELinuxArrayRec arr_events; SELinuxArrayRec arr_events;
/* Array of property and selection SID structures */ /* Array of property and selection SID structures */
SELinuxArrayRec arr_atoms; SELinuxArrayRec arr_atoms;
@ -53,21 +52,21 @@ SELinuxArrayRec arr_atoms;
* Dynamic array helpers * Dynamic array helpers
*/ */
static void * static void *
SELinuxArrayGet(SELinuxArrayRec * rec, unsigned key) SELinuxArrayGet(SELinuxArrayRec *rec, unsigned key)
{ {
return (rec->size > key) ? rec->array[key] : 0; return (rec->size > key) ? rec->array[key] : 0;
} }
static int static int
SELinuxArraySet(SELinuxArrayRec * rec, unsigned key, void *val) SELinuxArraySet(SELinuxArrayRec *rec, unsigned key, void *val)
{ {
if (key >= rec->size) { if (key >= rec->size) {
/* Need to increase size of array */ /* Need to increase size of array */
rec->array = reallocarray(rec->array, key + 1, sizeof(val)); rec->array = realloc(rec->array, (key + 1) * sizeof(val));
if (!rec->array) if (!rec->array)
return FALSE; return FALSE;
memset(rec->array + rec->size, 0, (key - rec->size + 1) * sizeof(val)); memset(rec->array + rec->size, 0, (key - rec->size + 1) * sizeof(val));
rec->size = key + 1; rec->size = key + 1;
} }
rec->array[key] = val; rec->array[key] = val;
@ -75,13 +74,12 @@ SELinuxArraySet(SELinuxArrayRec * rec, unsigned key, void *val)
} }
static void static void
SELinuxArrayFree(SELinuxArrayRec * rec, int free_elements) SELinuxArrayFree(SELinuxArrayRec *rec, int free_elements)
{ {
if (free_elements) { if (free_elements) {
unsigned i = rec->size; unsigned i = rec->size;
while (i)
while (i) free(rec->array[--i]);
free(rec->array[--i]);
} }
free(rec->array); free(rec->array);
@ -93,31 +91,29 @@ SELinuxArrayFree(SELinuxArrayRec * rec, int free_elements)
* Looks up a name in the selection or property mappings * Looks up a name in the selection or property mappings
*/ */
static int static int
SELinuxAtomToSIDLookup(Atom atom, SELinuxObjectRec * obj, int map, int polymap) SELinuxAtomToSIDLookup(Atom atom, SELinuxObjectRec *obj, int map, int polymap)
{ {
const char *name = NameForAtom(atom); const char *name = NameForAtom(atom);
char *ctx; security_context_t ctx;
int rc = Success; int rc = Success;
obj->poly = 1; obj->poly = 1;
/* Look in the mappings of names to contexts */ /* Look in the mappings of names to contexts */
if (selabel_lookup_raw(label_hnd, &ctx, name, map) == 0) { if (selabel_lookup_raw(label_hnd, &ctx, name, map) == 0) {
obj->poly = 0; obj->poly = 0;
} } else if (errno != ENOENT) {
else if (errno != ENOENT) { ErrorF("SELinux: a property label lookup failed!\n");
ErrorF("SELinux: a property label lookup failed!\n"); return BadValue;
return BadValue; } else if (selabel_lookup_raw(label_hnd, &ctx, name, polymap) < 0) {
} ErrorF("SELinux: a property label lookup failed!\n");
else if (selabel_lookup_raw(label_hnd, &ctx, name, polymap) < 0) { return BadValue;
ErrorF("SELinux: a property label lookup failed!\n");
return BadValue;
} }
/* Get a SID for context */ /* Get a SID for context */
if (avc_context_to_sid_raw(ctx, &obj->sid) < 0) { if (avc_context_to_sid_raw(ctx, &obj->sid) < 0) {
ErrorF("SELinux: a context_to_SID_raw call failed!\n"); ErrorF("SELinux: a context_to_SID_raw call failed!\n");
rc = BadAlloc; rc = BadAlloc;
} }
freecon(ctx); freecon(ctx);
@ -128,7 +124,7 @@ SELinuxAtomToSIDLookup(Atom atom, SELinuxObjectRec * obj, int map, int polymap)
* Looks up the SID corresponding to the given property or selection atom * Looks up the SID corresponding to the given property or selection atom
*/ */
int int
SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec ** obj_rtn) SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec **obj_rtn)
{ {
SELinuxAtomRec *rec; SELinuxAtomRec *rec;
SELinuxObjectRec *obj; SELinuxObjectRec *obj;
@ -136,35 +132,30 @@ SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec ** obj_rtn)
rec = SELinuxArrayGet(&arr_atoms, atom); rec = SELinuxArrayGet(&arr_atoms, atom);
if (!rec) { if (!rec) {
rec = calloc(1, sizeof(SELinuxAtomRec)); rec = calloc(1, sizeof(SELinuxAtomRec));
if (!rec) if (!rec || !SELinuxArraySet(&arr_atoms, atom, rec))
return BadAlloc; return BadAlloc;
if (!SELinuxArraySet(&arr_atoms, atom, rec)) {
free(rec);
return BadAlloc;
}
} }
if (prop) { if (prop) {
obj = &rec->prp; obj = &rec->prp;
map = SELABEL_X_PROP; map = SELABEL_X_PROP;
polymap = SELABEL_X_POLYPROP; polymap = SELABEL_X_POLYPROP;
} } else {
else { obj = &rec->sel;
obj = &rec->sel; map = SELABEL_X_SELN;
map = SELABEL_X_SELN; polymap = SELABEL_X_POLYSELN;
polymap = SELABEL_X_POLYSELN;
} }
if (!obj->sid) { if (!obj->sid) {
rc = SELinuxAtomToSIDLookup(atom, obj, map, polymap); rc = SELinuxAtomToSIDLookup(atom, obj, map, polymap);
if (rc != Success) if (rc != Success)
goto out; goto out;
} }
*obj_rtn = obj; *obj_rtn = obj;
rc = Success; rc = Success;
out: out:
return rc; return rc;
} }
@ -172,8 +163,8 @@ SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec ** obj_rtn)
* Looks up a SID for a selection/subject pair * Looks up a SID for a selection/subject pair
*/ */
int int
SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec * subj, SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec *subj,
security_id_t * sid_rtn, int *poly_rtn) security_id_t *sid_rtn, int *poly_rtn)
{ {
int rc; int rc;
SELinuxObjectRec *obj; SELinuxObjectRec *obj;
@ -182,26 +173,26 @@ SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec * subj,
/* Get the default context and polyinstantiation bit */ /* Get the default context and polyinstantiation bit */
rc = SELinuxAtomToSID(selection, 0, &obj); rc = SELinuxAtomToSID(selection, 0, &obj);
if (rc != Success) if (rc != Success)
return rc; return rc;
/* Check for an override context next */ /* Check for an override context next */
if (subj->sel_use_sid) { if (subj->sel_use_sid) {
tsid = subj->sel_use_sid; tsid = subj->sel_use_sid;
goto out; goto out;
} }
tsid = obj->sid; tsid = obj->sid;
/* Polyinstantiate if necessary to obtain the final SID */ /* Polyinstantiate if necessary to obtain the final SID */
if (obj->poly && avc_compute_member(subj->sid, obj->sid, if (obj->poly && avc_compute_member(subj->sid, obj->sid,
SECCLASS_X_SELECTION, &tsid) < 0) { SECCLASS_X_SELECTION, &tsid) < 0) {
ErrorF("SELinux: a compute_member call failed!\n"); ErrorF("SELinux: a compute_member call failed!\n");
return BadValue; return BadValue;
} }
out: out:
*sid_rtn = tsid; *sid_rtn = tsid;
if (poly_rtn) if (poly_rtn)
*poly_rtn = obj->poly; *poly_rtn = obj->poly;
return Success; return Success;
} }
@ -209,8 +200,8 @@ SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec * subj,
* Looks up a SID for a property/subject pair * Looks up a SID for a property/subject pair
*/ */
int int
SELinuxPropertyToSID(Atom property, SELinuxSubjectRec * subj, SELinuxPropertyToSID(Atom property, SELinuxSubjectRec *subj,
security_id_t * sid_rtn, int *poly_rtn) security_id_t *sid_rtn, int *poly_rtn)
{ {
int rc; int rc;
SELinuxObjectRec *obj; SELinuxObjectRec *obj;
@ -219,33 +210,34 @@ SELinuxPropertyToSID(Atom property, SELinuxSubjectRec * subj,
/* Get the default context and polyinstantiation bit */ /* Get the default context and polyinstantiation bit */
rc = SELinuxAtomToSID(property, 1, &obj); rc = SELinuxAtomToSID(property, 1, &obj);
if (rc != Success) if (rc != Success)
return rc; return rc;
/* Check for an override context next */ /* Check for an override context next */
if (subj->prp_use_sid) { if (subj->prp_use_sid) {
tsid = subj->prp_use_sid; tsid = subj->prp_use_sid;
goto out; goto out;
} }
/* Perform a transition */ /* Perform a transition */
if (avc_compute_create(subj->sid, obj->sid, SECCLASS_X_PROPERTY, &tsid) < 0) { if (avc_compute_create(subj->sid, obj->sid,
ErrorF("SELinux: a compute_create call failed!\n"); SECCLASS_X_PROPERTY, &tsid) < 0) {
return BadValue; ErrorF("SELinux: a compute_create call failed!\n");
return BadValue;
} }
/* Polyinstantiate if necessary to obtain the final SID */ /* Polyinstantiate if necessary to obtain the final SID */
if (obj->poly) { if (obj->poly) {
tsid2 = tsid; tsid2 = tsid;
if (avc_compute_member(subj->sid, tsid2, if (avc_compute_member(subj->sid, tsid2,
SECCLASS_X_PROPERTY, &tsid) < 0) { SECCLASS_X_PROPERTY, &tsid) < 0) {
ErrorF("SELinux: a compute_member call failed!\n"); ErrorF("SELinux: a compute_member call failed!\n");
return BadValue; return BadValue;
} }
} }
out: out:
*sid_rtn = tsid; *sid_rtn = tsid;
if (poly_rtn) if (poly_rtn)
*poly_rtn = obj->poly; *poly_rtn = obj->poly;
return Success; return Success;
} }
@ -254,58 +246,57 @@ SELinuxPropertyToSID(Atom property, SELinuxSubjectRec * subj,
*/ */
int int
SELinuxEventToSID(unsigned type, security_id_t sid_of_window, SELinuxEventToSID(unsigned type, security_id_t sid_of_window,
SELinuxObjectRec * sid_return) SELinuxObjectRec *sid_return)
{ {
const char *name = LookupEventName(type); const char *name = LookupEventName(type);
security_id_t sid; security_id_t sid;
char *ctx; security_context_t ctx;
type &= 127; type &= 127;
sid = SELinuxArrayGet(&arr_events, type); sid = SELinuxArrayGet(&arr_events, type);
if (!sid) { if (!sid) {
/* Look in the mappings of event names to contexts */ /* Look in the mappings of event names to contexts */
if (selabel_lookup_raw(label_hnd, &ctx, name, SELABEL_X_EVENT) < 0) { if (selabel_lookup_raw(label_hnd, &ctx, name, SELABEL_X_EVENT) < 0) {
ErrorF("SELinux: an event label lookup failed!\n"); ErrorF("SELinux: an event label lookup failed!\n");
return BadValue; return BadValue;
} }
/* Get a SID for context */ /* Get a SID for context */
if (avc_context_to_sid_raw(ctx, &sid) < 0) { if (avc_context_to_sid_raw(ctx, &sid) < 0) {
ErrorF("SELinux: a context_to_SID_raw call failed!\n"); ErrorF("SELinux: a context_to_SID_raw call failed!\n");
freecon(ctx); freecon(ctx);
return BadAlloc; return BadAlloc;
} }
freecon(ctx); freecon(ctx);
/* Cache the SID value */ /* Cache the SID value */
if (!SELinuxArraySet(&arr_events, type, sid)) if (!SELinuxArraySet(&arr_events, type, sid))
return BadAlloc; return BadAlloc;
} }
/* Perform a transition to obtain the final SID */ /* Perform a transition to obtain the final SID */
if (avc_compute_create(sid_of_window, sid, SECCLASS_X_EVENT, if (avc_compute_create(sid_of_window, sid, SECCLASS_X_EVENT,
&sid_return->sid) < 0) { &sid_return->sid) < 0) {
ErrorF("SELinux: a compute_create call failed!\n"); ErrorF("SELinux: a compute_create call failed!\n");
return BadValue; return BadValue;
} }
return Success; return Success;
} }
int int
SELinuxExtensionToSID(const char *name, security_id_t * sid_rtn) SELinuxExtensionToSID(const char *name, security_id_t *sid_rtn)
{ {
char *ctx; security_context_t ctx;
/* Look in the mappings of extension names to contexts */ /* Look in the mappings of extension names to contexts */
if (selabel_lookup_raw(label_hnd, &ctx, name, SELABEL_X_EXT) < 0) { if (selabel_lookup_raw(label_hnd, &ctx, name, SELABEL_X_EXT) < 0) {
ErrorF("SELinux: a property label lookup failed!\n"); ErrorF("SELinux: a property label lookup failed!\n");
return BadValue; return BadValue;
} }
/* Get a SID for context */ /* Get a SID for context */
if (avc_context_to_sid_raw(ctx, sid_rtn) < 0) { if (avc_context_to_sid_raw(ctx, sid_rtn) < 0) {
ErrorF("SELinux: a context_to_SID_raw call failed!\n"); ErrorF("SELinux: a context_to_SID_raw call failed!\n");
freecon(ctx); freecon(ctx);
return BadAlloc; return BadAlloc;
} }
freecon(ctx); freecon(ctx);
return Success; return Success;
@ -321,42 +312,41 @@ SELinuxTypeToClass(RESTYPE type)
tmp = SELinuxArrayGet(&arr_types, type & TypeMask); tmp = SELinuxArrayGet(&arr_types, type & TypeMask);
if (!tmp) { if (!tmp) {
unsigned long class = SECCLASS_X_RESOURCE; unsigned long class = SECCLASS_X_RESOURCE;
if (type & RC_DRAWABLE) if (type & RC_DRAWABLE)
class = SECCLASS_X_DRAWABLE; class = SECCLASS_X_DRAWABLE;
else if (type == X11_RESTYPE_GC) else if (type == RT_GC)
class = SECCLASS_X_GC; class = SECCLASS_X_GC;
else if (type == X11_RESTYPE_FONT) else if (type == RT_FONT)
class = SECCLASS_X_FONT; class = SECCLASS_X_FONT;
else if (type == X11_RESTYPE_CURSOR) else if (type == RT_CURSOR)
class = SECCLASS_X_CURSOR; class = SECCLASS_X_CURSOR;
else if (type == X11_RESTYPE_COLORMAP) else if (type == RT_COLORMAP)
class = SECCLASS_X_COLORMAP; class = SECCLASS_X_COLORMAP;
else { else {
/* Need to do a string lookup */ /* Need to do a string lookup */
const char *str = LookupResourceName(type); const char *str = LookupResourceName(type);
if (!strcmp(str, "PICTURE"))
class = SECCLASS_X_DRAWABLE;
else if (!strcmp(str, "GLYPHSET"))
class = SECCLASS_X_FONT;
}
if (!strcmp(str, "PICTURE")) tmp = (void *)class;
class = SECCLASS_X_DRAWABLE; SELinuxArraySet(&arr_types, type & TypeMask, tmp);
else if (!strcmp(str, "GLYPHSET"))
class = SECCLASS_X_FONT;
}
tmp = (void *) class;
SELinuxArraySet(&arr_types, type & TypeMask, tmp);
} }
return (security_class_t) (unsigned long) tmp; return (security_class_t)(unsigned long)tmp;
} }
char * security_context_t
SELinuxDefaultClientLabel(void) SELinuxDefaultClientLabel(void)
{ {
char *ctx; security_context_t ctx;
if (selabel_lookup_raw(label_hnd, &ctx, "remote", SELABEL_X_CLIENT) < 0) if (selabel_lookup_raw(label_hnd, &ctx, "remote", SELABEL_X_CLIENT) < 0)
FatalError("SELinux: failed to look up remote-client context\n"); FatalError("SELinux: failed to look up remote-client context\n");
return ctx; return ctx;
} }
@ -364,11 +354,11 @@ SELinuxDefaultClientLabel(void)
void void
SELinuxLabelInit(void) SELinuxLabelInit(void)
{ {
struct selinux_opt selabel_option = { SELABEL_OPT_VALIDATE, (char *) 1 }; struct selinux_opt selabel_option = { SELABEL_OPT_VALIDATE, (char *)1 };
label_hnd = selabel_open(SELABEL_CTX_X, &selabel_option, 1); label_hnd = selabel_open(SELABEL_CTX_X, &selabel_option, 1);
if (!label_hnd) if (!label_hnd)
FatalError("SELinux: Failed to open x_contexts mapping in policy\n"); FatalError("SELinux: Failed to open x_contexts mapping in policy\n");
} }
void void

View file

@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dixstruct.h" #include "dixstruct.h"
#include "privates.h" #include "privates.h"
#include "resource.h" #include "resource.h"
#include "registry.h"
#include "inputstr.h" #include "inputstr.h"
#include "xselinux.h" #include "xselinux.h"
@ -62,13 +63,10 @@ typedef struct {
*/ */
extern DevPrivateKeyRec subjectKeyRec; extern DevPrivateKeyRec subjectKeyRec;
#define subjectKey (&subjectKeyRec) #define subjectKey (&subjectKeyRec)
extern DevPrivateKeyRec objectKeyRec; extern DevPrivateKeyRec objectKeyRec;
#define objectKey (&objectKeyRec) #define objectKey (&objectKeyRec)
extern DevPrivateKeyRec dataKeyRec; extern DevPrivateKeyRec dataKeyRec;
#define dataKey (&dataKeyRec) #define dataKey (&dataKeyRec)
/* /*
@ -76,45 +74,45 @@ extern DevPrivateKeyRec dataKeyRec;
*/ */
int int
SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec ** obj_rtn); SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec **obj_rtn);
int int
SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec *subj,
SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec * subj, security_id_t *sid_rtn, int *poly_rtn);
security_id_t * sid_rtn, int *poly_rtn);
int int
SELinuxPropertyToSID(Atom property, SELinuxSubjectRec *subj,
SELinuxPropertyToSID(Atom property, SELinuxSubjectRec * subj, security_id_t *sid_rtn, int *poly_rtn);
security_id_t * sid_rtn, int *poly_rtn);
int int
SELinuxEventToSID(unsigned type, security_id_t sid_of_window, SELinuxEventToSID(unsigned type, security_id_t sid_of_window,
SELinuxObjectRec * sid_return); SELinuxObjectRec *sid_return);
int int
SELinuxExtensionToSID(const char *name, security_id_t * sid_rtn); SELinuxExtensionToSID(const char *name, security_id_t *sid_rtn);
security_class_t SELinuxTypeToClass(RESTYPE type); security_class_t
SELinuxTypeToClass(RESTYPE type);
char *SELinuxDefaultClientLabel(void); security_context_t
SELinuxDefaultClientLabel(void);
void void
SELinuxLabelInit(void); SELinuxLabelInit(void);
void void
SELinuxLabelReset(void); SELinuxLabelReset(void);
/* /*
* Security module functions * Security module functions
*/ */
void void
SELinuxFlaskInit(void); SELinuxFlaskInit(void);
void void
SELinuxFlaskReset(void); SELinuxFlaskReset(void);
/* /*
* Private Flask definitions * Private Flask definitions
@ -141,416 +139,416 @@ void
#ifdef _XSELINUX_NEED_FLASK_MAP #ifdef _XSELINUX_NEED_FLASK_MAP
/* Mapping from DixAccess bits to Flask permissions */ /* Mapping from DixAccess bits to Flask permissions */
static struct security_class_mapping map[] = { static struct security_class_mapping map[] = {
{"x_drawable", { "x_drawable",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"list_property", /* DixListPropAccess */ "list_property", /* DixListPropAccess */
"get_property", /* DixGetPropAccess */ "get_property", /* DixGetPropAccess */
"set_property", /* DixSetPropAccess */ "set_property", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"list_child", /* DixListAccess */ "list_child", /* DixListAccess */
"add_child", /* DixAddAccess */ "add_child", /* DixAddAccess */
"remove_child", /* DixRemoveAccess */ "remove_child", /* DixRemoveAccess */
"hide", /* DixHideAccess */ "hide", /* DixHideAccess */
"show", /* DixShowAccess */ "show", /* DixShowAccess */
"blend", /* DixBlendAccess */ "blend", /* DixBlendAccess */
"override", /* DixGrabAccess */ "override", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"send", /* DixSendAccess */ "send", /* DixSendAccess */
"receive", /* DixReceiveAccess */ "receive", /* DixReceiveAccess */
"", /* DixUseAccess */ "", /* DixUseAccess */
"manage", /* DixManageAccess */ "manage", /* DixManageAccess */
NULL}}, NULL }},
{"x_screen", { "x_screen",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"", /* DixDestroyAccess */ "", /* DixDestroyAccess */
"", /* DixCreateAccess */ "", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"saver_getattr", /* DixListPropAccess */ "saver_getattr", /* DixListPropAccess */
"saver_setattr", /* DixGetPropAccess */ "saver_setattr", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"hide_cursor", /* DixHideAccess */ "hide_cursor", /* DixHideAccess */
"show_cursor", /* DixShowAccess */ "show_cursor", /* DixShowAccess */
"saver_hide", /* DixBlendAccess */ "saver_hide", /* DixBlendAccess */
"saver_show", /* DixGrabAccess */ "saver_show", /* DixGrabAccess */
NULL}}, NULL }},
{"x_gc", { "x_gc",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
NULL}}, NULL }},
{"x_font", { "x_font",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"", /* DixSetAttrAccess */ "", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"add_glyph", /* DixAddAccess */ "add_glyph", /* DixAddAccess */
"remove_glyph", /* DixRemoveAccess */ "remove_glyph", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
NULL}}, NULL }},
{"x_colormap", { "x_colormap",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"", /* DixSetAttrAccess */ "", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"add_color", /* DixAddAccess */ "add_color", /* DixAddAccess */
"remove_color", /* DixRemoveAccess */ "remove_color", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"install", /* DixInstallAccess */ "install", /* DixInstallAccess */
"uninstall", /* DixUninstallAccess */ "uninstall", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
NULL}}, NULL }},
{"x_property", { "x_property",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"write", /* DixBlendAccess */ "write", /* DixBlendAccess */
NULL}}, NULL }},
{"x_selection", { "x_selection",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"", /* DixDestroyAccess */ "", /* DixDestroyAccess */
"setattr", /* DixCreateAccess */ "setattr", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
NULL}}, NULL }},
{"x_cursor", { "x_cursor",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
NULL}}, NULL }},
{"x_client", { "x_client",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"", /* DixCreateAccess */ "", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"", /* DixUseAccess */ "", /* DixUseAccess */
"manage", /* DixManageAccess */ "manage", /* DixManageAccess */
NULL}}, NULL }},
{"x_pointer", { "x_pointer",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"list_property", /* DixListPropAccess */ "list_property", /* DixListPropAccess */
"get_property", /* DixGetPropAccess */ "get_property", /* DixGetPropAccess */
"set_property", /* DixSetPropAccess */ "set_property", /* DixSetPropAccess */
"getfocus", /* DixGetFocusAccess */ "getfocus", /* DixGetFocusAccess */
"setfocus", /* DixSetFocusAccess */ "setfocus", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"add", /* DixAddAccess */ "add", /* DixAddAccess */
"remove", /* DixRemoveAccess */ "remove", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"grab", /* DixGrabAccess */ "grab", /* DixGrabAccess */
"freeze", /* DixFreezeAccess */ "freeze", /* DixFreezeAccess */
"force_cursor", /* DixForceAccess */ "force_cursor", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
"manage", /* DixManageAccess */ "manage", /* DixManageAccess */
"", /* DixDebugAccess */ "", /* DixDebugAccess */
"bell", /* DixBellAccess */ "bell", /* DixBellAccess */
NULL}}, NULL }},
{"x_keyboard", { "x_keyboard",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"destroy", /* DixDestroyAccess */ "destroy", /* DixDestroyAccess */
"create", /* DixCreateAccess */ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"list_property", /* DixListPropAccess */ "list_property", /* DixListPropAccess */
"get_property", /* DixGetPropAccess */ "get_property", /* DixGetPropAccess */
"set_property", /* DixSetPropAccess */ "set_property", /* DixSetPropAccess */
"getfocus", /* DixGetFocusAccess */ "getfocus", /* DixGetFocusAccess */
"setfocus", /* DixSetFocusAccess */ "setfocus", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"add", /* DixAddAccess */ "add", /* DixAddAccess */
"remove", /* DixRemoveAccess */ "remove", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"grab", /* DixGrabAccess */ "grab", /* DixGrabAccess */
"freeze", /* DixFreezeAccess */ "freeze", /* DixFreezeAccess */
"force_cursor", /* DixForceAccess */ "force_cursor", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
"manage", /* DixManageAccess */ "manage", /* DixManageAccess */
"", /* DixDebugAccess */ "", /* DixDebugAccess */
"bell", /* DixBellAccess */ "bell", /* DixBellAccess */
NULL}}, NULL }},
{"x_server", { "x_server",
{"record", /* DixReadAccess */ { "record", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"", /* DixDestroyAccess */ "", /* DixDestroyAccess */
"", /* DixCreateAccess */ "", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */ "getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */ "setattr", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"grab", /* DixGrabAccess */ "grab", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"", /* DixUseAccess */ "", /* DixUseAccess */
"manage", /* DixManageAccess */ "manage", /* DixManageAccess */
"debug", /* DixDebugAccess */ "debug", /* DixDebugAccess */
NULL}}, NULL }},
{"x_extension", { "x_extension",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"", /* DixDestroyAccess */ "", /* DixDestroyAccess */
"", /* DixCreateAccess */ "", /* DixCreateAccess */
"query", /* DixGetAttrAccess */ "query", /* DixGetAttrAccess */
"", /* DixSetAttrAccess */ "", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"", /* DixSendAccess */ "", /* DixSendAccess */
"", /* DixReceiveAccess */ "", /* DixReceiveAccess */
"use", /* DixUseAccess */ "use", /* DixUseAccess */
NULL}}, NULL }},
{"x_event", { "x_event",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"", /* DixDestroyAccess */ "", /* DixDestroyAccess */
"", /* DixCreateAccess */ "", /* DixCreateAccess */
"", /* DixGetAttrAccess */ "", /* DixGetAttrAccess */
"", /* DixSetAttrAccess */ "", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"send", /* DixSendAccess */ "send", /* DixSendAccess */
"receive", /* DixReceiveAccess */ "receive", /* DixReceiveAccess */
NULL}}, NULL }},
{"x_synthetic_event", { "x_synthetic_event",
{"", /* DixReadAccess */ { "", /* DixReadAccess */
"", /* DixWriteAccess */ "", /* DixWriteAccess */
"", /* DixDestroyAccess */ "", /* DixDestroyAccess */
"", /* DixCreateAccess */ "", /* DixCreateAccess */
"", /* DixGetAttrAccess */ "", /* DixGetAttrAccess */
"", /* DixSetAttrAccess */ "", /* DixSetAttrAccess */
"", /* DixListPropAccess */ "", /* DixListPropAccess */
"", /* DixGetPropAccess */ "", /* DixGetPropAccess */
"", /* DixSetPropAccess */ "", /* DixSetPropAccess */
"", /* DixGetFocusAccess */ "", /* DixGetFocusAccess */
"", /* DixSetFocusAccess */ "", /* DixSetFocusAccess */
"", /* DixListAccess */ "", /* DixListAccess */
"", /* DixAddAccess */ "", /* DixAddAccess */
"", /* DixRemoveAccess */ "", /* DixRemoveAccess */
"", /* DixHideAccess */ "", /* DixHideAccess */
"", /* DixShowAccess */ "", /* DixShowAccess */
"", /* DixBlendAccess */ "", /* DixBlendAccess */
"", /* DixGrabAccess */ "", /* DixGrabAccess */
"", /* DixFreezeAccess */ "", /* DixFreezeAccess */
"", /* DixForceAccess */ "", /* DixForceAccess */
"", /* DixInstallAccess */ "", /* DixInstallAccess */
"", /* DixUninstallAccess */ "", /* DixUninstallAccess */
"send", /* DixSendAccess */ "send", /* DixSendAccess */
"receive", /* DixReceiveAccess */ "receive", /* DixReceiveAccess */
NULL}}, NULL }},
{"x_resource", { "x_resource",
{"read", /* DixReadAccess */ { "read", /* DixReadAccess */
"write", /* DixWriteAccess */ "write", /* DixWriteAccess */
"write", /* DixDestroyAccess */ "write", /* DixDestroyAccess */
"write", /* DixCreateAccess */ "write", /* DixCreateAccess */
"read", /* DixGetAttrAccess */ "read", /* DixGetAttrAccess */
"write", /* DixSetAttrAccess */ "write", /* DixSetAttrAccess */
"read", /* DixListPropAccess */ "read", /* DixListPropAccess */
"read", /* DixGetPropAccess */ "read", /* DixGetPropAccess */
"write", /* DixSetPropAccess */ "write", /* DixSetPropAccess */
"read", /* DixGetFocusAccess */ "read", /* DixGetFocusAccess */
"write", /* DixSetFocusAccess */ "write", /* DixSetFocusAccess */
"read", /* DixListAccess */ "read", /* DixListAccess */
"write", /* DixAddAccess */ "write", /* DixAddAccess */
"write", /* DixRemoveAccess */ "write", /* DixRemoveAccess */
"write", /* DixHideAccess */ "write", /* DixHideAccess */
"read", /* DixShowAccess */ "read", /* DixShowAccess */
"read", /* DixBlendAccess */ "read", /* DixBlendAccess */
"write", /* DixGrabAccess */ "write", /* DixGrabAccess */
"write", /* DixFreezeAccess */ "write", /* DixFreezeAccess */
"write", /* DixForceAccess */ "write", /* DixForceAccess */
"write", /* DixInstallAccess */ "write", /* DixInstallAccess */
"write", /* DixUninstallAccess */ "write", /* DixUninstallAccess */
"write", /* DixSendAccess */ "write", /* DixSendAccess */
"read", /* DixReceiveAccess */ "read", /* DixReceiveAccess */
"read", /* DixUseAccess */ "read", /* DixUseAccess */
"write", /* DixManageAccess */ "write", /* DixManageAccess */
"read", /* DixDebugAccess */ "read", /* DixDebugAccess */
"write", /* DixBellAccess */ "write", /* DixBellAccess */
NULL}}, NULL }},
{NULL} { NULL }
}; };
/* x_resource "read" bits from the list above */ /* x_resource "read" bits from the list above */
@ -559,5 +557,5 @@ static struct security_class_mapping map[] = {
DixShowAccess|DixBlendAccess|DixReceiveAccess| \ DixShowAccess|DixBlendAccess|DixReceiveAccess| \
DixUseAccess|DixDebugAccess) DixUseAccess|DixDebugAccess)
#endif /* _XSELINUX_NEED_FLASK_MAP */ #endif /* _XSELINUX_NEED_FLASK_MAP */
#endif /* _XSELINUXINT_H */ #endif /* _XSELINUXINT_H */

View file

@ -26,22 +26,13 @@
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/extensions/xtestproto.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "mi/mipointer_priv.h"
#include "os/client_priv.h"
#include "os/osdep.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
@ -54,18 +45,24 @@
#include "mi.h" #include "mi.h"
#include "xkbsrv.h" #include "xkbsrv.h"
#include "xkbstr.h" #include "xkbstr.h"
#include <X11/extensions/xtestproto.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "mipointer.h" #include "mipointer.h"
#include "xserver-properties.h" #include "xserver-properties.h"
#include "exevents.h"
#include "eventstr.h" #include "eventstr.h"
#include "inpututils.h" #include "inpututils.h"
#include "extinit_priv.h"
/* XTest events are sent during request processing and may be interrupted by #include "modinit.h"
extern int DeviceValuator;
/* XTest events are sent during request processing and may be interruped by
* a SIGIO. We need a separate event list to avoid events overwriting each * a SIGIO. We need a separate event list to avoid events overwriting each
* other's memory. * other's memory */
*/ static InternalEvent* xtest_evlist;
static InternalEvent *xtest_evlist;
/** /**
* xtestpointer * xtestpointer
@ -79,33 +76,34 @@ static InternalEvent *xtest_evlist;
*/ */
DeviceIntPtr xtestpointer, xtestkeyboard; DeviceIntPtr xtestpointer, xtestkeyboard;
#ifdef XINERAMA #ifdef PANORAMIX
#include "panoramiX.h" #include "panoramiX.h"
#include "panoramiXsrv.h" #include "panoramiXsrv.h"
#endif /* XINERAMA */ #endif
static int XTestSwapFakeInput(
ClientPtr /* client */,
xReq * /* req */
);
static int XTestSwapFakeInput(ClientPtr /* client */ ,
xReq * /* req */
);
static int static int
ProcXTestGetVersion(ClientPtr client) ProcXTestGetVersion(ClientPtr client)
{ {
xXTestGetVersionReply rep = { xXTestGetVersionReply rep;
.type = X_Reply, int n;
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = XTestMajorVersion,
.minorVersion = XTestMinorVersion
};
REQUEST_SIZE_MATCH(xXTestGetVersionReq); REQUEST_SIZE_MATCH(xXTestGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XTestMajorVersion;
rep.minorVersion = XTestMinorVersion;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
swaps(&rep.minorVersion); swaps(&rep.minorVersion, n);
} }
WriteToClient(client, sizeof(xXTestGetVersionReply), &rep); WriteToClient(client, sizeof(xXTestGetVersionReply), (char *)&rep);
return Success; return Success;
} }
@ -116,71 +114,37 @@ ProcXTestCompareCursor(ClientPtr client)
xXTestCompareCursorReply rep; xXTestCompareCursorReply rep;
WindowPtr pWin; WindowPtr pWin;
CursorPtr pCursor; CursorPtr pCursor;
int rc; int n, rc;
DeviceIntPtr ptr = PickPointer(client); DeviceIntPtr ptr = PickPointer(client);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq); REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (!ptr)
return BadAccess;
if (stuff->cursor == None) if (stuff->cursor == None)
pCursor = NullCursor; pCursor = NullCursor;
else if (stuff->cursor == XTestCurrentCursor) else if (stuff->cursor == XTestCurrentCursor)
pCursor = GetSpriteCursor(ptr); pCursor = GetSpriteCursor(ptr);
else { else {
rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor, rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
X11_RESTYPE_CURSOR, client, DixReadAccess); client, DixReadAccess);
if (rc != Success) { if (rc != Success)
{
client->errorValue = stuff->cursor; client->errorValue = stuff->cursor;
return rc; return rc;
} }
} }
rep = (xXTestCompareCursorReply) { rep.type = X_Reply;
.type = X_Reply, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0, rep.same = (wCursor(pWin) == pCursor);
.same = (wCursor(pWin) == pCursor)
};
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber, n);
} }
WriteToClient(client, sizeof(xXTestCompareCursorReply), &rep); WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *)&rep);
return Success; 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 static int
ProcXTestFakeInput(ClientPtr client) ProcXTestFakeInput(ClientPtr client)
{ {
@ -190,29 +154,34 @@ ProcXTestFakeInput(ClientPtr client)
DeviceIntPtr dev = NULL; DeviceIntPtr dev = NULL;
WindowPtr root; WindowPtr root;
Bool extension = FALSE; Bool extension = FALSE;
deviceValuator *dv = NULL;
ValuatorMask mask; ValuatorMask mask;
int valuators[MAX_VALUATORS] = { 0 }; int valuators[MAX_VALUATORS] = {0};
int numValuators = 0; int numValuators = 0;
int firstValuator = 0; int firstValuator = 0;
int nevents = 0;
int i;
int base = 0; int base = 0;
int flags = 0; int flags = 0;
int need_ptr_update = 1; int need_ptr_update = 1;
nev = (client->req_len << 2) - sizeof(xReq); nev = (stuff->length << 2) - sizeof(xReq);
if ((nev % sizeof(xEvent)) || !nev) if ((nev % sizeof(xEvent)) || !nev)
return BadLength; return BadLength;
nev /= sizeof(xEvent); nev /= sizeof(xEvent);
UpdateCurrentTime(); UpdateCurrentTime();
ev = (xEvent *) &((xReq *) stuff)[1]; ev = (xEvent *)&((xReq *)stuff)[1];
type = ev->u.u.type & 0177; type = ev->u.u.type & 0177;
if (type >= EXTENSION_EVENT_BASE) { if (type >= EXTENSION_EVENT_BASE)
{
extension = TRUE; extension = TRUE;
/* check device */ /* check device */
rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client, rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client,
DixWriteAccess); DixWriteAccess);
if (rc != Success) { if (rc != Success)
{
client->errorValue = stuff->deviceid & 0177; client->errorValue = stuff->deviceid & 0177;
return rc; return rc;
} }
@ -220,145 +189,144 @@ ProcXTestFakeInput(ClientPtr client)
/* check type */ /* check type */
type -= DeviceValuator; type -= DeviceValuator;
switch (type) { switch (type) {
case XI_DeviceKeyPress: case XI_DeviceKeyPress:
case XI_DeviceKeyRelease: case XI_DeviceKeyRelease:
if (!dev->key) { if (!dev->key)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_DeviceButtonPress:
case XI_DeviceButtonRelease:
if (!dev->button)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_DeviceMotionNotify:
if (!dev->valuator)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_ProximityIn:
case XI_ProximityOut:
if (!dev->proximity)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
default:
client->errorValue = ev->u.u.type; client->errorValue = ev->u.u.type;
return BadValue; return BadValue;
}
break;
case XI_DeviceButtonPress:
case XI_DeviceButtonRelease:
if (!dev->button) {
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_DeviceMotionNotify:
if (!dev->valuator) {
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_ProximityIn:
case XI_ProximityOut:
if (!dev->proximity) {
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
default:
client->errorValue = ev->u.u.type;
return BadValue;
} }
/* check validity */ /* check validity */
if (nev == 1 && type == XI_DeviceMotionNotify) if (nev == 1 && type == XI_DeviceMotionNotify)
return BadLength; /* DevMotion must be followed by DevValuator */ return BadLength; /* DevMotion must be followed by DevValuator */
if (type == XI_DeviceMotionNotify) { if (type == XI_DeviceMotionNotify)
firstValuator = ((deviceValuator *) (ev + 1))->first_valuator; {
if (firstValuator > dev->valuator->numAxes) { firstValuator = ((deviceValuator *)(ev+1))->first_valuator;
if (firstValuator > dev->valuator->numAxes)
{
client->errorValue = ev->u.u.type; client->errorValue = ev->u.u.type;
return BadValue; return BadValue;
} }
if (ev->u.u.detail == xFalse) if (ev->u.u.detail == xFalse)
flags |= POINTER_ABSOLUTE; flags |= POINTER_ABSOLUTE;
} } else
else { {
firstValuator = 0; firstValuator = 0;
flags |= POINTER_ABSOLUTE; flags |= POINTER_ABSOLUTE;
} }
if (nev > 1 && !dev->valuator) { if (nev > 1 && !dev->valuator)
client->errorValue = firstValuator; {
client->errorValue = dv->first_valuator;
return BadValue; return BadValue;
} }
/* check validity of valuator events */ /* check validity of valuator events */
base = firstValuator; base = firstValuator;
for (n = 1; n < nev; n++) { for (n = 1; n < nev; n++)
deviceValuator *dv = (deviceValuator *) (ev + n); {
if (dv->type != DeviceValuator) { dv = (deviceValuator *)(ev + n);
if (dv->type != DeviceValuator)
{
client->errorValue = dv->type; client->errorValue = dv->type;
return BadValue; return BadValue;
} }
if (dv->first_valuator != base) { if (dv->first_valuator != base)
{
client->errorValue = dv->first_valuator; client->errorValue = dv->first_valuator;
return BadValue; return BadValue;
} }
switch (dv->num_valuators) { switch(dv->num_valuators)
case 6: {
valuators[base + 5] = dv->valuator5; case 6: valuators[base + 5] = dv->valuator5;
case 5: case 5: valuators[base + 4] = dv->valuator4;
valuators[base + 4] = dv->valuator4; case 4: valuators[base + 3] = dv->valuator3;
case 4: case 3: valuators[base + 2] = dv->valuator2;
valuators[base + 3] = dv->valuator3; case 2: valuators[base + 1] = dv->valuator1;
case 3: case 1: valuators[base] = dv->valuator0;
valuators[base + 2] = dv->valuator2; break;
case 2: default:
valuators[base + 1] = dv->valuator1; client->errorValue = dv->num_valuators;
case 1: return BadValue;
valuators[base] = dv->valuator0;
break;
default:
client->errorValue = dv->num_valuators;
return BadValue;
} }
base += dv->num_valuators; base += dv->num_valuators;
numValuators += dv->num_valuators; numValuators += dv->num_valuators;
if (firstValuator + numValuators > dev->valuator->numAxes) { if (firstValuator + numValuators > dev->valuator->numAxes)
{
client->errorValue = dv->num_valuators; client->errorValue = dv->num_valuators;
return BadValue; return BadValue;
} }
} }
type = type - XI_DeviceKeyPress + KeyPress; type = type - XI_DeviceKeyPress + KeyPress;
} } else
else { {
if (nev != 1) if (nev != 1)
return BadLength; return BadLength;
switch (type) { switch (type)
case KeyPress: {
case KeyRelease: case KeyPress:
dev = PickKeyboard(client); case KeyRelease:
break; dev = PickKeyboard(client);
case ButtonPress: break;
case ButtonRelease: case ButtonPress:
dev = PickPointer(client); case ButtonRelease:
break; dev = PickPointer(client);
case MotionNotify: break;
dev = PickPointer(client); case MotionNotify:
valuators[0] = ev->u.keyButtonPointer.rootX; dev = PickPointer(client);
valuators[1] = ev->u.keyButtonPointer.rootY; valuators[0] = ev->u.keyButtonPointer.rootX;
numValuators = 2; valuators[1] = ev->u.keyButtonPointer.rootY;
firstValuator = 0; numValuators = 2;
if (ev->u.u.detail == xFalse) firstValuator = 0;
flags = POINTER_ABSOLUTE | POINTER_DESKTOP; if (ev->u.u.detail == xFalse)
break; flags = POINTER_ABSOLUTE | POINTER_SCREEN;
default: break;
client->errorValue = ev->u.u.type; default:
return BadValue; client->errorValue = ev->u.u.type;
return BadValue;
} }
/* Technically the protocol doesn't allow for BadAccess here but
* this can only happen when all MDs are disabled. */
if (!dev)
return BadAccess;
dev = GetXTestDevice(dev); dev = GetXTestDevice(dev);
/* This can only happen if we passed a slave to GetXTestDevice() */
if (!dev)
return BadAccess;
} }
/* If the event has a time set, wait for it to pass */ /* If the event has a time set, wait for it to pass */
if (ev->u.keyButtonPointer.time) { if (ev->u.keyButtonPointer.time)
{
TimeStamp activateTime; TimeStamp activateTime;
CARD32 ms; CARD32 ms;
@ -372,80 +340,96 @@ ProcXTestFakeInput(ClientPtr client)
/* see mbuf.c:QueueDisplayRequest (from the deprecated Multibuffer /* see mbuf.c:QueueDisplayRequest (from the deprecated Multibuffer
* extension) for code similar to this */ * extension) for code similar to this */
if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) { if (!ClientSleepUntil(client, &activateTime, NULL, NULL))
{
return BadAlloc; return BadAlloc;
} }
/* swap the request back so we can simply re-execute it */ /* swap the request back so we can simply re-execute it */
if (client->swapped) { if (client->swapped)
(void) XTestSwapFakeInput(client, (xReq *) stuff); {
(void) XTestSwapFakeInput(client, (xReq *)stuff);
swaps(&stuff->length, n);
} }
ResetCurrentRequest(client); ResetCurrentRequest (client);
client->sequence--; client->sequence--;
return Success; return Success;
} }
switch (type) { switch (type)
case KeyPress: {
case KeyRelease: case KeyPress:
if (!dev->key) case KeyRelease:
return BadDevice; if (!dev->key)
return BadDevice;
if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code ||
ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code) { ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code)
client->errorValue = ev->u.u.detail; {
return BadValue; client->errorValue = ev->u.u.detail;
}
need_ptr_update = 0;
break;
case MotionNotify:
if (!dev->valuator)
return BadDevice;
if (!(extension || ev->u.keyButtonPointer.root == None)) {
rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root,
client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (root->parent) {
client->errorValue = ev->u.keyButtonPointer.root;
return BadValue; return BadValue;
} }
/* Add the root window's offset to the valuators */ need_ptr_update = 0;
if ((flags & POINTER_ABSOLUTE) && firstValuator <= 1 && numValuators > 0) { break;
if (firstValuator == 0) case MotionNotify:
valuators[0] += root->drawable.pScreen->x; if (!dev->valuator)
if (firstValuator + numValuators > 1) return BadDevice;
valuators[1 - firstValuator] += root->drawable.pScreen->y;
if (!(extension || ev->u.keyButtonPointer.root == None))
{
rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root,
client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (root->parent)
{
client->errorValue = ev->u.keyButtonPointer.root;
return BadValue;
}
}
if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse)
{
client->errorValue = ev->u.u.detail;
return BadValue;
} }
}
if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) {
client->errorValue = ev->u.u.detail;
return BadValue;
}
/* FIXME: Xinerama! */ /* FIXME: Xinerama! */
break; break;
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
if (!dev->button) if (!dev->button)
return BadDevice; return BadDevice;
if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons)
client->errorValue = ev->u.u.detail; {
return BadValue; client->errorValue = ev->u.u.detail;
} return BadValue;
break; }
break;
} }
if (screenIsSaved == SCREEN_SAVER_ON) if (screenIsSaved == SCREEN_SAVER_ON)
dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
valuator_mask_set_range(&mask, firstValuator, numValuators, valuators); 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, NULL);
break;
}
if (dev->sendEventsProc) for (i = 0; i < nevents; i++)
(*dev->sendEventsProc) (dev, type, ev->u.u.detail, flags, &mask); mieqProcessDeviceEvent(dev, &xtest_evlist[i], NULL);
if (need_ptr_update) if (need_ptr_update)
miPointerUpdateSprite(dev); miPointerUpdateSprite(dev);
@ -458,7 +442,8 @@ ProcXTestGrabControl(ClientPtr client)
REQUEST(xXTestGrabControlReq); REQUEST(xXTestGrabControlReq);
REQUEST_SIZE_MATCH(xXTestGrabControlReq); REQUEST_SIZE_MATCH(xXTestGrabControlReq);
if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) { if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse))
{
client->errorValue = stuff->impervious; client->errorValue = stuff->impervious;
return BadValue; return BadValue;
} }
@ -470,94 +455,113 @@ ProcXTestGrabControl(ClientPtr client)
} }
static int static int
ProcXTestDispatch(ClientPtr client) ProcXTestDispatch (ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data)
case X_XTestGetVersion: {
return ProcXTestGetVersion(client); case X_XTestGetVersion:
case X_XTestCompareCursor: return ProcXTestGetVersion(client);
return ProcXTestCompareCursor(client); case X_XTestCompareCursor:
case X_XTestFakeInput: return ProcXTestCompareCursor(client);
return ProcXTestFakeInput(client); case X_XTestFakeInput:
case X_XTestGrabControl: return ProcXTestFakeInput(client);
return ProcXTestGrabControl(client); case X_XTestGrabControl:
default: return ProcXTestGrabControl(client);
return BadRequest; default:
return BadRequest;
} }
} }
static int _X_COLD static int
SProcXTestGetVersion(ClientPtr client) SProcXTestGetVersion(ClientPtr client)
{ {
int n;
REQUEST(xXTestGetVersionReq); REQUEST(xXTestGetVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXTestGetVersionReq); REQUEST_SIZE_MATCH(xXTestGetVersionReq);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion, n);
return ProcXTestGetVersion(client); return ProcXTestGetVersion(client);
} }
static int _X_COLD static int
SProcXTestCompareCursor(ClientPtr client) SProcXTestCompareCursor(ClientPtr client)
{ {
int n;
REQUEST(xXTestCompareCursorReq); REQUEST(xXTestCompareCursorReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq); REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
swapl(&stuff->window); swapl(&stuff->window, n);
swapl(&stuff->cursor); swapl(&stuff->cursor, n);
return ProcXTestCompareCursor(client); return ProcXTestCompareCursor(client);
} }
static int _X_COLD static int
XTestSwapFakeInput(ClientPtr client, xReq * req) XTestSwapFakeInput(ClientPtr client, xReq *req)
{ {
int nev; int nev;
xEvent *ev; xEvent *ev;
xEvent sev; xEvent sev;
EventSwapPtr proc; EventSwapPtr proc;
nev = ((client->req_len << 2) - sizeof(xReq)) / sizeof(xEvent); nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) { for (ev = (xEvent *)&req[1]; --nev >= 0; ev++)
int evtype = ev->u.u.type & 0177; {
/* Swap event */ /* Swap event */
proc = EventSwapVector[evtype]; proc = EventSwapVector[ev->u.u.type & 0177];
/* no swapping proc; invalid event type? */ /* no swapping proc; invalid event type? */
if (!proc || proc == NotImplemented || evtype == GenericEvent) { if (!proc || proc == NotImplemented) {
client->errorValue = ev->u.u.type; client->errorValue = ev->u.u.type;
return BadValue; return BadValue;
} }
(*proc) (ev, &sev); (*proc)(ev, &sev);
*ev = sev; *ev = sev;
} }
return Success; return Success;
} }
static int _X_COLD static int
SProcXTestFakeInput(ClientPtr client) SProcXTestFakeInput(ClientPtr client)
{ {
int n; int n;
REQUEST(xReq); REQUEST(xReq);
swaps(&stuff->length, n);
n = XTestSwapFakeInput(client, stuff); n = XTestSwapFakeInput(client, stuff);
if (n != Success) if (n != Success)
return n; return n;
return ProcXTestFakeInput(client); return ProcXTestFakeInput(client);
} }
static int _X_COLD static int
SProcXTestDispatch(ClientPtr client) SProcXTestGrabControl(ClientPtr client)
{
int n;
REQUEST(xXTestGrabControlReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
return ProcXTestGrabControl(client);
}
static int
SProcXTestDispatch (ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data)
case X_XTestGetVersion: {
return SProcXTestGetVersion(client); case X_XTestGetVersion:
case X_XTestCompareCursor: return SProcXTestGetVersion(client);
return SProcXTestCompareCursor(client); case X_XTestCompareCursor:
case X_XTestFakeInput: return SProcXTestCompareCursor(client);
return SProcXTestFakeInput(client); case X_XTestFakeInput:
case X_XTestGrabControl: return SProcXTestFakeInput(client);
return ProcXTestGrabControl(client); case X_XTestGrabControl:
default: return SProcXTestGrabControl(client);
return BadRequest; default:
return BadRequest;
} }
} }
@ -565,22 +569,21 @@ SProcXTestDispatch(ClientPtr client)
* Allocate an virtual slave device for xtest events, this * Allocate an virtual slave device for xtest events, this
* is a slave device to inputInfo master devices * is a slave device to inputInfo master devices
*/ */
void void InitXTestDevices(void)
InitXTestDevices(void)
{ {
if (AllocXTestDevice(serverClient, "Virtual core", if(AllocXTestDevice(serverClient, "Virtual core",
&xtestpointer, &xtestkeyboard, &xtestpointer, &xtestkeyboard,
inputInfo.pointer, inputInfo.keyboard) != Success) inputInfo.pointer, inputInfo.keyboard) != Success)
FatalError("Failed to allocate XTest devices"); FatalError("Failed to allocate XTest devices");
if (ActivateDevice(xtestpointer, TRUE) != Success || if (ActivateDevice(xtestpointer, TRUE) != Success ||
ActivateDevice(xtestkeyboard, TRUE) != Success) ActivateDevice(xtestkeyboard, TRUE) != Success)
FatalError("Failed to activate XTest core devices."); FatalError("Failed to activate XTest core devices.");
if (!EnableDevice(xtestpointer, TRUE) || !EnableDevice(xtestkeyboard, TRUE)) if (!EnableDevice(xtestpointer, TRUE) ||
!EnableDevice(xtestkeyboard, TRUE))
FatalError("Failed to enable XTest core devices."); FatalError("Failed to enable XTest core devices.");
AttachDevice(NULL, xtestpointer, inputInfo.pointer); AttachDevice(NULL, xtestpointer, inputInfo.pointer);
AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard); AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard);
} }
@ -589,7 +592,7 @@ InitXTestDevices(void)
*/ */
static int static int
DeviceSetXTestProperty(DeviceIntPtr dev, Atom property, DeviceSetXTestProperty(DeviceIntPtr dev, Atom property,
XIPropertyValuePtr prop, BOOL checkonly) XIPropertyValuePtr prop, BOOL checkonly)
{ {
if (property == XIGetKnownProperty(XI_PROP_XTEST_DEVICE)) if (property == XIGetKnownProperty(XI_PROP_XTEST_DEVICE))
return BadAccess; return BadAccess;
@ -604,42 +607,36 @@ DeviceSetXTestProperty(DeviceIntPtr dev, Atom property,
* This only creates the pair, Activate/Enable Device * This only creates the pair, Activate/Enable Device
* still need to be called. * still need to be called.
*/ */
int int AllocXTestDevice (ClientPtr client, char* name,
AllocXTestDevice(ClientPtr client, const char *name, DeviceIntPtr* ptr, DeviceIntPtr* keybd,
DeviceIntPtr *ptr, DeviceIntPtr *keybd, DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
{ {
int retval; int retval;
char *xtestname; int len = strlen(name);
char *xtestname = calloc(len + 7, 1 );
char dummy = 1; char dummy = 1;
if (asprintf(&xtestname, "%s XTEST", name) == -1) strncpy( xtestname, name, len);
return BadAlloc; strncat( xtestname, " XTEST", 6 );
retval = retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
AllocDevicePair(client, xtestname, ptr, keybd, CorePointerProc, if ( retval == Success ){
CoreKeyboardProc, FALSE); (*ptr)->xtest_master_id = master_ptr->id;
if (retval == Success) { (*keybd)->xtest_master_id = master_keybd->id;
(*ptr)->xtest_master_id = master_ptr->id;
(*keybd)->xtest_master_id = master_keybd->id;
XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
XA_INTEGER, 8, PropModeReplace, 1, &dummy, XA_INTEGER, 8, PropModeReplace, 1, &dummy,
FALSE); FALSE);
XISetDevicePropertyDeletable(*ptr, XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
FALSE);
XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL);
XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
XA_INTEGER, 8, PropModeReplace, 1, &dummy, XA_INTEGER, 8, PropModeReplace, 1, &dummy,
FALSE); FALSE);
XISetDevicePropertyDeletable(*keybd, XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
FALSE);
XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL);
} }
free(xtestname); free( xtestname );
return retval; return retval;
} }
@ -659,7 +656,7 @@ IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master)
/* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest /* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest
* device */ * device */
if (master) if (master)
return dev->xtest_master_id == master->id; return dev->xtest_master_id == master->id;
return dev->xtest_master_id != 0; return dev->xtest_master_id != 0;
} }
@ -672,7 +669,8 @@ GetXTestDevice(DeviceIntPtr master)
{ {
DeviceIntPtr it; DeviceIntPtr it;
for (it = inputInfo.devices; it; it = it->next) { for (it = inputInfo.devices; it; it = it->next)
{
if (IsXTestDevice(it, master)) if (IsXTestDevice(it, master))
return it; return it;
} }
@ -682,18 +680,18 @@ GetXTestDevice(DeviceIntPtr master)
} }
static void static void
XTestExtensionTearDown(ExtensionEntry * e) XTestExtensionTearDown(ExtensionEntry *e)
{ {
FreeEventList(xtest_evlist, GetMaximumEventsNum()); FreeEventList(xtest_evlist, GetMaximumEventsNum());
xtest_evlist = NULL; xtest_evlist = NULL;
} }
void void
XTestExtensionInit(void) XTestExtensionInit(INITARGS)
{ {
AddExtension(XTestExtensionName, 0, 0, AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch, ProcXTestDispatch, SProcXTestDispatch,
XTestExtensionTearDown, StandardMinorOpcode); XTestExtensionTearDown, StandardMinorOpcode);
xtest_evlist = InitEventList(GetMaximumEventsNum()); xtest_evlist = InitEventList(GetMaximumEventsNum());
} }

File diff suppressed because it is too large Load diff

View file

@ -4,13 +4,13 @@ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved All Rights Reserved
Permission to use, copy, modify, and distribute this software and its Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@ -25,18 +25,18 @@ SOFTWARE.
#ifndef XVDIX_H #ifndef XVDIX_H
#define XVDIX_H #define XVDIX_H
/* /*
** File: ** File:
** **
** xvdix.h --- Xv device independent header file ** xvdix.h --- Xv device independent header file
** **
** Author: ** Author:
** **
** David Carver (Digital Workstation Engineering/Project Athena) ** David Carver (Digital Workstation Engineering/Project Athena)
** **
** Revisions: ** Revisions:
** **
** 29.08.91 Carver ** 29.08.91 Carver
** - removed UnrealizeWindow wrapper unrealizing windows no longer ** - removed UnrealizeWindow wrapper unrealizing windows no longer
** preempts video ** preempts video
** **
** 11.06.91 Carver ** 11.06.91 Carver
@ -55,131 +55,221 @@ SOFTWARE.
#include "scrnintstr.h" #include "scrnintstr.h"
#include <X11/extensions/Xvproto.h> #include <X11/extensions/Xvproto.h>
#ifndef XorgLoader
extern _X_EXPORT unsigned long XvExtensionGeneration;
extern _X_EXPORT unsigned long XvScreenGeneration;
extern _X_EXPORT unsigned long XvResourceGeneration;
extern _X_EXPORT int XvReqCode;
extern _X_EXPORT int XvEventBase;
extern _X_EXPORT int XvErrorBase;
extern _X_EXPORT RESTYPE XvRTPort;
extern _X_EXPORT RESTYPE XvRTEncoding;
extern _X_EXPORT RESTYPE XvRTGrab;
extern _X_EXPORT RESTYPE XvRTVideoNotify;
extern _X_EXPORT RESTYPE XvRTVideoNotifyList;
extern _X_EXPORT RESTYPE XvRTPortNotify;
#endif
typedef struct { typedef struct {
int numerator; int numerator;
int denominator; int denominator;
} XvRationalRec, *XvRationalPtr; } XvRationalRec, *XvRationalPtr;
typedef struct { typedef struct {
char depth; char depth;
unsigned long visual; unsigned long visual;
} XvFormatRec, *XvFormatPtr; } XvFormatRec, *XvFormatPtr;
typedef struct { typedef struct {
unsigned long id; unsigned long id;
ClientPtr client; ClientPtr client;
} XvGrabRec, *XvGrabPtr; } XvGrabRec, *XvGrabPtr;
typedef struct _XvPortNotifyRec *XvPortNotifyPtr; typedef struct _XvVideoNotifyRec {
struct _XvVideoNotifyRec *next;
ClientPtr client;
unsigned long id;
unsigned long mask;
} XvVideoNotifyRec, *XvVideoNotifyPtr;
typedef struct _XvPortNotifyRec {
struct _XvPortNotifyRec *next;
ClientPtr client;
unsigned long id;
} XvPortNotifyRec, *XvPortNotifyPtr;
typedef struct { typedef struct {
int id; int id;
ScreenPtr pScreen; ScreenPtr pScreen;
char *name; char *name;
unsigned short width, height; unsigned short width, height;
XvRationalRec rate; XvRationalRec rate;
} XvEncodingRec, *XvEncodingPtr; } XvEncodingRec, *XvEncodingPtr;
typedef struct _XvAttributeRec { typedef struct _XvAttributeRec {
int flags; int flags;
int min_value; int min_value;
int max_value; int max_value;
char *name; char *name;
} XvAttributeRec, *XvAttributePtr; } XvAttributeRec, *XvAttributePtr;
typedef struct { typedef struct {
int id; int id;
int type; int type;
int byte_order; int byte_order;
char guid[16]; char guid[16];
int bits_per_pixel; int bits_per_pixel;
int format; int format;
int num_planes; int num_planes;
/* for RGB formats only */ /* for RGB formats only */
int depth; int depth;
unsigned int red_mask; unsigned int red_mask;
unsigned int green_mask; unsigned int green_mask;
unsigned int blue_mask; unsigned int blue_mask;
/* for YUV formats only */ /* for YUV formats only */
unsigned int y_sample_bits; unsigned int y_sample_bits;
unsigned int u_sample_bits; unsigned int u_sample_bits;
unsigned int v_sample_bits; unsigned int v_sample_bits;
unsigned int horz_y_period; unsigned int horz_y_period;
unsigned int horz_u_period; unsigned int horz_u_period;
unsigned int horz_v_period; unsigned int horz_v_period;
unsigned int vert_y_period; unsigned int vert_y_period;
unsigned int vert_u_period; unsigned int vert_u_period;
unsigned int vert_v_period; unsigned int vert_v_period;
char component_order[32]; char component_order[32];
int scanline_order; int scanline_order;
} XvImageRec, *XvImagePtr; } XvImageRec, *XvImagePtr;
typedef struct { typedef struct {
unsigned long base_id; unsigned long base_id;
unsigned char type; unsigned char type;
char *name; char *name;
int nEncodings; int nEncodings;
XvEncodingPtr pEncodings; XvEncodingPtr pEncodings;
int nFormats; int nFormats;
XvFormatPtr pFormats; XvFormatPtr pFormats;
int nAttributes; int nAttributes;
XvAttributePtr pAttributes; XvAttributePtr pAttributes;
int nImages; int nImages;
XvImagePtr pImages; XvImagePtr pImages;
int nPorts; int nPorts;
struct _XvPortRec *pPorts; struct _XvPortRec *pPorts;
ScreenPtr pScreen; ScreenPtr pScreen;
int (*ddPutVideo) (DrawablePtr, struct _XvPortRec *, GCPtr, int (* ddAllocatePort)(unsigned long, struct _XvPortRec*,
INT16, INT16, CARD16, CARD16, struct _XvPortRec**);
INT16, INT16, CARD16, CARD16); int (* ddFreePort)(struct _XvPortRec*);
int (*ddPutStill) (DrawablePtr, struct _XvPortRec *, GCPtr, int (* ddPutVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16); INT16, INT16, CARD16, CARD16);
int (*ddGetVideo) (DrawablePtr, struct _XvPortRec *, GCPtr, int (* ddPutStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16); INT16, INT16, CARD16, CARD16);
int (*ddGetStill) (DrawablePtr, struct _XvPortRec *, GCPtr, int (* ddGetVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16); INT16, INT16, CARD16, CARD16);
int (*ddStopVideo) (struct _XvPortRec *, DrawablePtr); int (* ddGetStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
int (*ddSetPortAttribute) (struct _XvPortRec *, Atom, INT32); INT16, INT16, CARD16, CARD16,
int (*ddGetPortAttribute) (struct _XvPortRec *, Atom, INT32 *); INT16, INT16, CARD16, CARD16);
int (*ddQueryBestSize) (struct _XvPortRec *, CARD8, int (* ddStopVideo)(ClientPtr, struct _XvPortRec*, DrawablePtr);
CARD16, CARD16, CARD16, CARD16, int (* ddSetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32);
unsigned int *, unsigned int *); int (* ddGetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32*);
int (*ddPutImage) (DrawablePtr, struct _XvPortRec *, GCPtr, int (* ddQueryBestSize)(ClientPtr, struct _XvPortRec*, CARD8,
INT16, INT16, CARD16, CARD16, CARD16, CARD16,CARD16, CARD16,
INT16, INT16, CARD16, CARD16, unsigned int*, unsigned int*);
XvImagePtr, unsigned char *, Bool, CARD16, CARD16); int (* ddPutImage)(ClientPtr, DrawablePtr, struct _XvPortRec*, GCPtr,
int (*ddQueryImageAttributes) (struct _XvPortRec *, XvImagePtr, INT16, INT16, CARD16, CARD16,
CARD16 *, CARD16 *, int *, int *); INT16, INT16, CARD16, CARD16,
DevUnion devPriv; XvImagePtr, unsigned char*, Bool,
CARD16, CARD16);
int (* ddQueryImageAttributes)(ClientPtr, struct _XvPortRec*, XvImagePtr,
CARD16*, CARD16*, int*, int*);
DevUnion devPriv;
} XvAdaptorRec, *XvAdaptorPtr; } XvAdaptorRec, *XvAdaptorPtr;
typedef struct _XvPortRec { typedef struct _XvPortRec {
unsigned long id; unsigned long id;
XvAdaptorPtr pAdaptor; XvAdaptorPtr pAdaptor;
XvPortNotifyPtr pNotify; XvPortNotifyPtr pNotify;
DrawablePtr pDraw; DrawablePtr pDraw;
ClientPtr client; ClientPtr client;
XvGrabRec grab; XvGrabRec grab;
TimeStamp time; TimeStamp time;
DevUnion devPriv; DevUnion devPriv;
} XvPortRec, *XvPortPtr; } XvPortRec, *XvPortPtr;
#define VALIDATE_XV_PORT(portID, pPort, mode)\
{\
int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\
XvRTPort, client, mode);\
if (rc != Success)\
return rc;\
}
typedef struct { typedef struct {
int version, revision; int version, revision;
int nAdaptors; int nAdaptors;
XvAdaptorPtr pAdaptors; XvAdaptorPtr pAdaptors;
DestroyWindowProcPtr DestroyWindow; DestroyWindowProcPtr DestroyWindow;
DestroyPixmapProcPtr DestroyPixmap; DestroyPixmapProcPtr DestroyPixmap;
CloseScreenProcPtr CloseScreen; CloseScreenProcPtr CloseScreen;
Bool (* ddCloseScreen)(int, ScreenPtr);
int (* ddQueryAdaptors)(ScreenPtr, XvAdaptorPtr*, int*);
DevUnion devPriv;
} XvScreenRec, *XvScreenPtr; } XvScreenRec, *XvScreenPtr;
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
/* Errors */
#define _XvBadPort (XvBadPort+XvErrorBase)
#define _XvBadEncoding (XvBadEncoding+XvErrorBase)
#ifndef XorgLoader
extern _X_EXPORT int ProcXvDispatch(ClientPtr);
extern _X_EXPORT int SProcXvDispatch(ClientPtr);
extern _X_EXPORT void XvExtensionInit(void);
extern _X_EXPORT int XvScreenInit(ScreenPtr); extern _X_EXPORT int XvScreenInit(ScreenPtr);
extern _X_EXPORT DevPrivateKey XvGetScreenKey(void); extern _X_EXPORT DevPrivateKey XvGetScreenKey(void);
extern _X_EXPORT unsigned long XvGetRTPort(void); extern _X_EXPORT unsigned long XvGetRTPort(void);
extern _X_EXPORT int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
extern _X_EXPORT int XvdiVideoStopped(XvPortPtr, int);
extern _X_EXPORT int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
extern _X_EXPORT int XvdiPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
extern _X_EXPORT int XvdiGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
extern _X_EXPORT int XvdiGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
extern _X_EXPORT int XvdiPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char*, Bool,
CARD16, CARD16);
extern _X_EXPORT int XvdiSelectVideoNotify(ClientPtr, DrawablePtr, BOOL);
extern _X_EXPORT int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL);
extern _X_EXPORT int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
extern _X_EXPORT int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
extern _X_EXPORT int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiMatchPort(XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *);
extern _X_EXPORT int XvdiUngrabPort( ClientPtr, XvPortPtr, Time);
#endif /* XorgLoader */
#endif /* XVDIX_H */
#endif /* XVDIX_H */

View file

@ -1,84 +0,0 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#ifndef _XORG_XVDIX_PRIV_H
#include <X11/Xdefs.h>
#include "include/pixmap.h"
#include "include/regionstr.h"
#include "Xext/xvdix.h"
#define VALIDATE_XV_PORT(portID, pPort, mode)\
{\
int rc = dixLookupResourceByType((void **)&(pPort), portID,\
XvRTPort, client, mode);\
if (rc != Success)\
return rc;\
}
/* Errors */
#define _XvBadPort (XvBadPort+XvErrorBase)
typedef struct _XvPortNotifyRec {
struct _XvPortNotifyRec *next;
ClientPtr client;
unsigned long id;
} XvPortNotifyRec, *XvPortNotifyPtr;
extern int XvReqCode;
extern int XvErrorBase;
extern RESTYPE XvRTPort;
/* dispatch functions */
int ProcXvDispatch(ClientPtr);
int SProcXvDispatch(ClientPtr);
void XvFreeAdaptor(XvAdaptorPtr pAdaptor);
void XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region);
int XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff);
int XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff);
int XvdiPutVideo(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort,
GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w,
CARD16 wid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w,
CARD16 drw_h);
int XvdiPutStill(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort,
GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w,
CARD16 vid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w,
CARD16 drw_h);
int XvdiPutImage(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort,
GCPtr pGC, INT16 src_x, INT16 src_y, CARD16 src_w,
CARD16 src_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w,
CARD16 drw_h, XvImagePtr image, unsigned char *data,
Bool sync, CARD16 width, CARD16 height);
int XvdiGetVideo(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort,
GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w,
CARD16 vid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w,
CARD16 drw_h);
int XvdiGetStill(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort,
GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w,
CARD16 vid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w,
CARD16 drw_h);
int XvdiSetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute,
INT32 value);
int XvdiGetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute,
INT32 *p_value);
int XvdiStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw);
int XvdiMatchPort(XvPortPtr pPort, DrawablePtr pDraw);
int XvdiGrabPort(ClientPtr client, XvPortPtr pPort, Time ctime, int *p_result);
int XvdiUngrabPort(ClientPtr client, XvPortPtr pPort, Time ctime);
XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
#endif /* _XORG_XVDIX_PRIV_H */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,90 +5,114 @@
#include "xvdix.h" #include "xvdix.h"
typedef struct { typedef struct {
int num_xvimages; int num_xvimages;
int *xvimage_ids; int *xvimage_ids;
} XvMCImageIDList; } XvMCImageIDList;
typedef struct { typedef struct {
int surface_type_id; int surface_type_id;
int chroma_format; int chroma_format;
int color_description; int color_description;
unsigned short max_width; unsigned short max_width;
unsigned short max_height; unsigned short max_height;
unsigned short subpicture_max_width; unsigned short subpicture_max_width;
unsigned short subpicture_max_height; unsigned short subpicture_max_height;
int mc_type; int mc_type;
int flags; int flags;
XvMCImageIDList *compatible_subpictures; XvMCImageIDList *compatible_subpictures;
} XvMCSurfaceInfoRec, *XvMCSurfaceInfoPtr; } XvMCSurfaceInfoRec, *XvMCSurfaceInfoPtr;
typedef struct { typedef struct {
XID context_id; XID context_id;
ScreenPtr pScreen; ScreenPtr pScreen;
int adapt_num; int adapt_num;
int surface_type_id; int surface_type_id;
unsigned short width; unsigned short width;
unsigned short height; unsigned short height;
CARD32 flags; CARD32 flags;
int refcnt; int refcnt;
void *port_priv; pointer port_priv;
void *driver_priv; pointer driver_priv;
} XvMCContextRec, *XvMCContextPtr; } XvMCContextRec, *XvMCContextPtr;
typedef struct { typedef struct {
XID surface_id; XID surface_id;
int surface_type_id; int surface_type_id;
XvMCContextPtr context; XvMCContextPtr context;
void *driver_priv; pointer driver_priv;
} XvMCSurfaceRec, *XvMCSurfacePtr; } XvMCSurfaceRec, *XvMCSurfacePtr;
typedef struct { typedef struct {
XID subpicture_id; XID subpicture_id;
int xvimage_id; int xvimage_id;
unsigned short width; unsigned short width;
unsigned short height; unsigned short height;
int num_palette_entries; int num_palette_entries;
int entry_bytes; int entry_bytes;
char component_order[4]; char component_order[4];
XvMCContextPtr context; XvMCContextPtr context;
void *driver_priv; pointer driver_priv;
} XvMCSubpictureRec, *XvMCSubpicturePtr; } XvMCSubpictureRec, *XvMCSubpicturePtr;
typedef int (*XvMCCreateContextProcPtr) (XvPortPtr port, typedef int (*XvMCCreateContextProcPtr) (
XvMCContextPtr context, XvPortPtr port,
int *num_priv, CARD32 **priv); XvMCContextPtr context,
int *num_priv,
CARD32 **priv
);
typedef void (*XvMCDestroyContextProcPtr) (XvMCContextPtr context); typedef void (*XvMCDestroyContextProcPtr) (
XvMCContextPtr context
);
typedef int (*XvMCCreateSurfaceProcPtr) (XvMCSurfacePtr surface, typedef int (*XvMCCreateSurfaceProcPtr) (
int *num_priv, CARD32 **priv); XvMCSurfacePtr surface,
int *num_priv,
CARD32 **priv
);
typedef void (*XvMCDestroySurfaceProcPtr) (XvMCSurfacePtr surface); typedef void (*XvMCDestroySurfaceProcPtr) (
XvMCSurfacePtr surface
);
typedef int (*XvMCCreateSubpictureProcPtr) (XvMCSubpicturePtr subpicture, typedef int (*XvMCCreateSubpictureProcPtr) (
int *num_priv, CARD32 **priv); XvMCSubpicturePtr subpicture,
int *num_priv,
CARD32 **priv
);
typedef void (*XvMCDestroySubpictureProcPtr) (
XvMCSubpicturePtr subpicture
);
typedef void (*XvMCDestroySubpictureProcPtr) (XvMCSubpicturePtr subpicture);
typedef struct { typedef struct {
XvAdaptorPtr xv_adaptor; XvAdaptorPtr xv_adaptor;
int num_surfaces; int num_surfaces;
XvMCSurfaceInfoPtr *surfaces; XvMCSurfaceInfoPtr *surfaces;
int num_subpictures; int num_subpictures;
XvImagePtr *subpictures; XvImagePtr *subpictures;
XvMCCreateContextProcPtr CreateContext; XvMCCreateContextProcPtr CreateContext;
XvMCDestroyContextProcPtr DestroyContext; XvMCDestroyContextProcPtr DestroyContext;
XvMCCreateSurfaceProcPtr CreateSurface; XvMCCreateSurfaceProcPtr CreateSurface;
XvMCDestroySurfaceProcPtr DestroySurface; XvMCDestroySurfaceProcPtr DestroySurface;
XvMCCreateSubpictureProcPtr CreateSubpicture; XvMCCreateSubpictureProcPtr CreateSubpicture;
XvMCDestroySubpictureProcPtr DestroySubpicture; XvMCDestroySubpictureProcPtr DestroySubpicture;
} XvMCAdaptorRec, *XvMCAdaptorPtr; } XvMCAdaptorRec, *XvMCAdaptorPtr;
#ifndef XorgLoader
extern _X_EXPORT void XvMCExtensionInit(void);
extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen, extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen,
int num, XvMCAdaptorPtr adapt); int num,
XvMCAdaptorPtr adapt);
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name, extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
const char *busID, int major, int minor,
int patchLevel);
#endif /* _XVMC_H */ extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
char *busID, int major, int minor,
int patchLevel);
#endif
#endif /* _XVMC_H */

108
Xi/Makefile.am Normal file
View file

@ -0,0 +1,108 @@
noinst_LTLIBRARIES = libXi.la
AM_CFLAGS = $(DIX_CFLAGS)
libXi_la_SOURCES = \
allowev.c \
allowev.h \
chgdctl.c \
chgdctl.h \
chgfctl.c \
chgfctl.h \
chgkbd.c \
chgkbd.h \
chgkmap.c \
chgkmap.h \
chgprop.c \
chgprop.h \
chgptr.c \
chgptr.h \
closedev.c \
closedev.h \
devbell.c \
devbell.h \
exevents.c \
exglobals.h \
extinit.c \
getbmap.c \
getbmap.h \
getdctl.c \
getdctl.h \
getfctl.c \
getfctl.h \
getfocus.c \
getfocus.h \
getkmap.c \
getkmap.h \
getmmap.c \
getmmap.h \
getprop.c \
getprop.h \
getselev.c \
getselev.h \
getvers.c \
getvers.h \
grabdev.c \
grabdev.h \
grabdevb.c \
grabdevb.h \
grabdevk.c \
grabdevk.h \
gtmotion.c \
gtmotion.h \
listdev.c \
listdev.h \
opendev.c \
opendev.h \
queryst.c \
queryst.h \
selectev.c \
selectev.h \
sendexev.c \
sendexev.h \
setbmap.c \
setbmap.h \
setdval.c \
setdval.h \
setfocus.c \
setfocus.h \
setmmap.c \
setmmap.h \
setmode.c \
setmode.h \
ungrdev.c \
ungrdev.h \
ungrdevb.c \
ungrdevb.h \
ungrdevk.c \
ungrdevk.h \
xiallowev.c \
xiallowev.h \
xichangecursor.c \
xichangecursor.h \
xichangehierarchy.c \
xichangehierarchy.h \
xigetclientpointer.c \
xigetclientpointer.h \
xigrabdev.c \
xigrabdev.h \
xipassivegrab.h \
xipassivegrab.c \
xiproperty.c \
xiproperty.h \
xiquerydevice.c \
xiquerydevice.h \
xiquerypointer.c \
xiquerypointer.h \
xiqueryversion.c \
xiqueryversion.h \
xiselectev.c \
xiselectev.h \
xisetclientpointer.c \
xisetclientpointer.h \
xisetdevfocus.c \
xisetdevfocus.h \
xiwarppointer.c \
xiwarppointer.h
EXTRA_DIST = stubs.c

View file

@ -50,15 +50,14 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "dix/input_priv.h"
#include "exglobals.h" #include "exglobals.h"
#include "allowev.h" #include "allowev.h"
@ -70,12 +69,15 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXAllowDeviceEvents(ClientPtr client) SProcXAllowDeviceEvents(ClientPtr client)
{ {
char n;
REQUEST(xAllowDeviceEventsReq); REQUEST(xAllowDeviceEventsReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq); REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
swapl(&stuff->time); swapl(&stuff->time, n);
return (ProcXAllowDeviceEvents(client)); return (ProcXAllowDeviceEvents(client));
} }
@ -97,31 +99,31 @@ ProcXAllowDeviceEvents(ClientPtr client)
rc = dixLookupDevice(&thisdev, stuff->deviceid, client, DixGetAttrAccess); rc = dixLookupDevice(&thisdev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
time = ClientTimeToServerTime(stuff->time); time = ClientTimeToServerTime(stuff->time);
switch (stuff->mode) { switch (stuff->mode) {
case ReplayThisDevice: case ReplayThisDevice:
AllowSome(client, time, thisdev, GRAB_STATE_NOT_GRABBED); AllowSome(client, time, thisdev, NOT_GRABBED);
break; break;
case SyncThisDevice: case SyncThisDevice:
AllowSome(client, time, thisdev, GRAB_STATE_FREEZE_NEXT_EVENT); AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT);
break; break;
case AsyncThisDevice: case AsyncThisDevice:
AllowSome(client, time, thisdev, GRAB_STATE_THAWED); AllowSome(client, time, thisdev, THAWED);
break; break;
case AsyncOtherDevices: case AsyncOtherDevices:
AllowSome(client, time, thisdev, GRAB_STATE_THAW_OTHERS); AllowSome(client, time, thisdev, THAW_OTHERS);
break; break;
case SyncAll: case SyncAll:
AllowSome(client, time, thisdev, GRAB_STATE_FREEZE_BOTH_NEXT_EVENT); AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT);
break; break;
case AsyncAll: case AsyncAll:
AllowSome(client, time, thisdev, GRAB_STATE_THAWED_BOTH); AllowSome(client, time, thisdev, THAWED_BOTH);
break; break;
default: default:
client->errorValue = stuff->mode; client->errorValue = stuff->mode;
return BadValue; return BadValue;
} }
return Success; return Success;
} }

View file

@ -30,10 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef ALLOWEV_H #ifndef ALLOWEV_H
#define ALLOWEV_H 1 #define ALLOWEV_H 1
int SProcXAllowDeviceEvents(ClientPtr /* client */ int SProcXAllowDeviceEvents(ClientPtr /* client */
); );
int ProcXAllowDeviceEvents(ClientPtr /* client */ int ProcXAllowDeviceEvents(ClientPtr /* client */
); );
#endif /* ALLOWEV_H */ #endif /* ALLOWEV_H */

View file

@ -50,17 +50,18 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */ #include <X11/extensions/XIproto.h> /* control constants */
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h" #include "XIstubs.h"
#include "exglobals.h" #include "exglobals.h"
#include "exevents.h"
#include "chgdctl.h" #include "chgdctl.h"
/*********************************************************************** /***********************************************************************
@ -70,25 +71,27 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXChangeDeviceControl(ClientPtr client) SProcXChangeDeviceControl(ClientPtr client)
{ {
char n;
xDeviceCtl *ctl; xDeviceCtl *ctl;
REQUEST(xChangeDeviceControlReq); REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); swaps(&stuff->length, n);
swaps(&stuff->control); REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
ctl = (xDeviceCtl *) &stuff[1]; swaps(&stuff->control, n);
swaps(&ctl->control); ctl = (xDeviceCtl*)&stuff[1];
swaps(&ctl->length); swaps(&ctl->control, n);
switch (stuff->control) { swaps(&ctl->length, n);
case DEVICE_ABS_CALIB: switch(stuff->control) {
case DEVICE_ABS_AREA: case DEVICE_ABS_CALIB:
case DEVICE_CORE: case DEVICE_ABS_AREA:
case DEVICE_ENABLE: case DEVICE_CORE:
case DEVICE_RESOLUTION: case DEVICE_ENABLE:
/* hmm. beer. *drool* */ case DEVICE_RESOLUTION:
break; /* hmm. beer. *drool* */
break;
} }
return (ProcXChangeDeviceControl(client)); return (ProcXChangeDeviceControl(client));
@ -111,72 +114,61 @@ ProcXChangeDeviceControl(ClientPtr client)
AxisInfoPtr a; AxisInfoPtr a;
CARD32 *resolution; CARD32 *resolution;
xDeviceEnableCtl *e; xDeviceEnableCtl *e;
devicePresenceNotify dpn;
REQUEST(xChangeDeviceControlReq); REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
len = client->req_len - bytes_to_int32(sizeof(xChangeDeviceControlReq)); len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq));
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success) if (ret != Success)
goto out; goto out;
/* XTest devices are special, none of the below apply to them anyway */ rep.repType = X_Reply;
if (IsXTestDevice(dev, NULL)) { rep.RepType = X_ChangeDeviceControl;
ret = BadMatch; rep.length = 0;
goto out; rep.sequenceNumber = client->sequence;
}
rep = (xChangeDeviceControlReply) {
.repType = X_Reply,
.RepType = X_ChangeDeviceControl,
.sequenceNumber = client->sequence,
.length = 0,
.status = Success,
};
switch (stuff->control) { switch (stuff->control) {
case DEVICE_RESOLUTION: case DEVICE_RESOLUTION:
r = (xDeviceResolutionCtl *) &stuff[1]; r = (xDeviceResolutionCtl *) & stuff[1];
if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) || if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) ||
(len != (len != bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) {
bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) {
ret = BadLength; ret = BadLength;
goto out; goto out;
} }
if (!dev->valuator) { if (!dev->valuator) {
ret = BadMatch; ret = BadMatch;
goto out; goto out;
} }
if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) { if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) {
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
ret = Success; ret = Success;
goto out; goto out;
} }
resolution = (CARD32 *) (r + 1); resolution = (CARD32 *) (r + 1);
if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) { if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
ret = BadValue; ret = BadValue;
goto out; goto out;
} }
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
if (status == Success) { if (status == Success) {
a = &dev->valuator->axes[r->first_valuator]; a = &dev->valuator->axes[r->first_valuator];
for (i = 0; i < r->num_valuators; i++) for (i = 0; i < r->num_valuators; i++)
if (*(resolution + i) < (a + i)->min_resolution || if (*(resolution + i) < (a + i)->min_resolution ||
*(resolution + i) > (a + i)->max_resolution) *(resolution + i) > (a + i)->max_resolution)
return BadValue; return BadValue;
for (i = 0; i < r->num_valuators; i++) for (i = 0; i < r->num_valuators; i++)
(a++)->resolution = *resolution++; (a++)->resolution = *resolution++;
ret = Success; ret = Success;
} } else if (status == DeviceBusy) {
else if (status == DeviceBusy) { rep.status = DeviceBusy;
rep.status = DeviceBusy;
ret = Success; ret = Success;
} } else {
else {
ret = BadMatch; ret = BadMatch;
} }
break; break;
case DEVICE_ABS_CALIB: case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA: case DEVICE_ABS_AREA:
/* Calibration is now done through properties, and never had any effect /* Calibration is now done through properties, and never had any effect
@ -189,16 +181,9 @@ ProcXChangeDeviceControl(ClientPtr client)
ret = BadMatch; ret = BadMatch;
break; break;
case DEVICE_ENABLE: case DEVICE_ENABLE:
e = (xDeviceEnableCtl *) &stuff[1]; e = (xDeviceEnableCtl *)&stuff[1];
if ((len != bytes_to_int32(sizeof(xDeviceEnableCtl)))) {
ret = BadLength;
goto out;
}
if (IsXTestDevice(dev, NULL)) status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e);
status = !Success;
else
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e);
if (status == Success) { if (status == Success) {
if (e->enable) if (e->enable)
@ -206,12 +191,10 @@ ProcXChangeDeviceControl(ClientPtr client)
else else
DisableDevice(dev, TRUE); DisableDevice(dev, TRUE);
ret = Success; ret = Success;
} } else if (status == DeviceBusy) {
else if (status == DeviceBusy) {
rep.status = DeviceBusy; rep.status = DeviceBusy;
ret = Success; ret = Success;
} } else {
else {
ret = BadMatch; ret = BadMatch;
} }
@ -220,15 +203,13 @@ ProcXChangeDeviceControl(ClientPtr client)
ret = BadValue; ret = BadValue;
} }
out: out:
if (ret == Success) { if (ret == Success) {
devicePresenceNotify dpn = { dpn.type = DevicePresenceNotify;
.type = DevicePresenceNotify, dpn.time = currentTime.milliseconds;
.time = currentTime.milliseconds, dpn.devchange = DeviceControlChanged;
.devchange = DeviceControlChanged, dpn.deviceid = dev->id;
.deviceid = dev->id, dpn.control = stuff->control;
.control = stuff->control
};
SendEventToAllWindows(dev, DevicePresenceNotifyMask, SendEventToAllWindows(dev, DevicePresenceNotifyMask,
(xEvent *) &dpn, 1); (xEvent *) &dpn, 1);
@ -245,11 +226,13 @@ ProcXChangeDeviceControl(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXChangeDeviceControl(ClientPtr client, int size, SRepXChangeDeviceControl(ClientPtr client, int size,
xChangeDeviceControlReply * rep) xChangeDeviceControlReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
WriteToClient(client, size, rep); swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,15 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGDCTL_H #ifndef CHGDCTL_H
#define CHGDCTL_H 1 #define CHGDCTL_H 1
int SProcXChangeDeviceControl(ClientPtr /* client */ int SProcXChangeDeviceControl(ClientPtr /* client */
); );
int ProcXChangeDeviceControl(ClientPtr /* client */ int ProcXChangeDeviceControl(ClientPtr /* client */
); );
void SRepXChangeDeviceControl(ClientPtr /* client */ , void SRepXChangeDeviceControl(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xChangeDeviceControlReply * /* rep */ xChangeDeviceControlReply * /* rep */
); );
#endif /* CHGDCTL_H */ #endif /* CHGDCTL_H */

View file

@ -50,11 +50,13 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */ #include <X11/extensions/XIproto.h> /* control constants */
#include "exglobals.h" #include "exglobals.h"
@ -69,12 +71,15 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXChangeFeedbackControl(ClientPtr client) SProcXChangeFeedbackControl(ClientPtr client)
{ {
char n;
REQUEST(xChangeFeedbackControlReq); REQUEST(xChangeFeedbackControlReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
swapl(&stuff->mask); swapl(&stuff->mask, n);
return (ProcXChangeFeedbackControl(client)); return (ProcXChangeFeedbackControl(client));
} }
@ -86,110 +91,108 @@ SProcXChangeFeedbackControl(ClientPtr client)
static int static int
ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
KbdFeedbackPtr k, xKbdFeedbackCtl * f) KbdFeedbackPtr k, xKbdFeedbackCtl * f)
{ {
char n;
KeybdCtrl kctrl; KeybdCtrl kctrl;
int t; int t;
int key = DO_ALL; int key = DO_ALL;
if (client->swapped) { if (client->swapped) {
swaps(&f->length); swaps(&f->length, n);
swaps(&f->pitch); swaps(&f->pitch, n);
swaps(&f->duration); swaps(&f->duration, n);
swapl(&f->led_mask); swapl(&f->led_mask, n);
swapl(&f->led_values); swapl(&f->led_values, n);
} }
kctrl = k->ctrl; kctrl = k->ctrl;
if (mask & DvKeyClickPercent) { if (mask & DvKeyClickPercent) {
t = f->click; t = f->click;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.click; t = defaultKeyboardControl.click;
else if (t < 0 || t > 100) { else if (t < 0 || t > 100) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
kctrl.click = t; kctrl.click = t;
} }
if (mask & DvPercent) { if (mask & DvPercent) {
t = f->percent; t = f->percent;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell; t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) { else if (t < 0 || t > 100) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
kctrl.bell = t; kctrl.bell = t;
} }
if (mask & DvPitch) { if (mask & DvPitch) {
t = f->pitch; t = f->pitch;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_pitch; t = defaultKeyboardControl.bell_pitch;
else if (t < 0) { else if (t < 0) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
kctrl.bell_pitch = t; kctrl.bell_pitch = t;
} }
if (mask & DvDuration) { if (mask & DvDuration) {
t = f->duration; t = f->duration;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_duration; t = defaultKeyboardControl.bell_duration;
else if (t < 0) { else if (t < 0) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
kctrl.bell_duration = t; kctrl.bell_duration = t;
} }
if (mask & DvLed) { if (mask & DvLed) {
kctrl.leds &= ~(f->led_mask); kctrl.leds &= ~(f->led_mask);
kctrl.leds |= (f->led_mask & f->led_values); kctrl.leds |= (f->led_mask & f->led_values);
} }
if (mask & DvKey) { if (mask & DvKey) {
key = (KeyCode) f->key; key = (KeyCode) f->key;
if (key < 8 || key > 255) { if (key < 8 || key > 255) {
client->errorValue = key; client->errorValue = key;
return BadValue; return BadValue;
} }
if (!(mask & DvAutoRepeatMode)) if (!(mask & DvAutoRepeatMode))
return BadMatch; return BadMatch;
} }
if (mask & DvAutoRepeatMode) { if (mask & DvAutoRepeatMode) {
int inx = (key >> 3); int inx = (key >> 3);
int kmask = (1 << (key & 7)); int kmask = (1 << (key & 7));
t = (CARD8) f->auto_repeat_mode; t = (CARD8) f->auto_repeat_mode;
if (t == AutoRepeatModeOff) { if (t == AutoRepeatModeOff) {
if (key == DO_ALL) if (key == DO_ALL)
kctrl.autoRepeat = FALSE; kctrl.autoRepeat = FALSE;
else else
kctrl.autoRepeats[inx] &= ~kmask; kctrl.autoRepeats[inx] &= ~kmask;
} } else if (t == AutoRepeatModeOn) {
else if (t == AutoRepeatModeOn) { if (key == DO_ALL)
if (key == DO_ALL) kctrl.autoRepeat = TRUE;
kctrl.autoRepeat = TRUE; else
else kctrl.autoRepeats[inx] |= kmask;
kctrl.autoRepeats[inx] |= kmask; } else if (t == AutoRepeatModeDefault) {
} if (key == DO_ALL)
else if (t == AutoRepeatModeDefault) { kctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
if (key == DO_ALL) else
kctrl.autoRepeat = defaultKeyboardControl.autoRepeat; kctrl.autoRepeats[inx] &= ~kmask;
else kctrl.autoRepeats[inx] =
kctrl.autoRepeats[inx] &= ~kmask; (kctrl.autoRepeats[inx] & ~kmask) |
kctrl.autoRepeats[inx] = (defaultKeyboardControl.autoRepeats[inx] & kmask);
(kctrl.autoRepeats[inx] & ~kmask) | } else {
(defaultKeyboardControl.autoRepeats[inx] & kmask); client->errorValue = t;
} return BadValue;
else { }
client->errorValue = t;
return BadValue;
}
} }
k->ctrl = kctrl; k->ctrl = kctrl;
@ -205,58 +208,56 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
static int static int
ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
PtrFeedbackPtr p, xPtrFeedbackCtl * f) PtrFeedbackPtr p, xPtrFeedbackCtl * f)
{ {
PtrCtrl pctrl; /* might get BadValue part way through */ char n;
PtrCtrl pctrl; /* might get BadValue part way through */
if (client->swapped) { if (client->swapped) {
swaps(&f->length); swaps(&f->length, n);
swaps(&f->num); swaps(&f->num, n);
swaps(&f->denom); swaps(&f->denom, n);
swaps(&f->thresh); swaps(&f->thresh, n);
} }
pctrl = p->ctrl; pctrl = p->ctrl;
if (mask & DvAccelNum) { if (mask & DvAccelNum) {
int accelNum; int accelNum;
accelNum = f->num; accelNum = f->num;
if (accelNum == -1) if (accelNum == -1)
pctrl.num = defaultPointerControl.num; pctrl.num = defaultPointerControl.num;
else if (accelNum < 0) { else if (accelNum < 0) {
client->errorValue = accelNum; client->errorValue = accelNum;
return BadValue; return BadValue;
} } else
else pctrl.num = accelNum;
pctrl.num = accelNum;
} }
if (mask & DvAccelDenom) { if (mask & DvAccelDenom) {
int accelDenom; int accelDenom;
accelDenom = f->denom; accelDenom = f->denom;
if (accelDenom == -1) if (accelDenom == -1)
pctrl.den = defaultPointerControl.den; pctrl.den = defaultPointerControl.den;
else if (accelDenom <= 0) { else if (accelDenom <= 0) {
client->errorValue = accelDenom; client->errorValue = accelDenom;
return BadValue; return BadValue;
} } else
else pctrl.den = accelDenom;
pctrl.den = accelDenom;
} }
if (mask & DvThreshold) { if (mask & DvThreshold) {
int threshold; int threshold;
threshold = f->thresh; threshold = f->thresh;
if (threshold == -1) if (threshold == -1)
pctrl.threshold = defaultPointerControl.threshold; pctrl.threshold = defaultPointerControl.threshold;
else if (threshold < 0) { else if (threshold < 0) {
client->errorValue = threshold; client->errorValue = threshold;
return BadValue; return BadValue;
} } else
else pctrl.threshold = threshold;
pctrl.threshold = threshold;
} }
p->ctrl = pctrl; p->ctrl = pctrl;
@ -272,12 +273,14 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
static int static int
ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, IntegerFeedbackPtr i, long unsigned int mask, IntegerFeedbackPtr i,
xIntegerFeedbackCtl * f) xIntegerFeedbackCtl * f)
{ {
char n;
if (client->swapped) { if (client->swapped) {
swaps(&f->length); swaps(&f->length, n);
swapl(&f->int_to_display); swapl(&f->int_to_display, n);
} }
i->ctrl.integer_displayed = f->int_to_display; i->ctrl.integer_displayed = f->int_to_display;
@ -293,33 +296,34 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev,
static int static int
ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, StringFeedbackPtr s, long unsigned int mask, StringFeedbackPtr s,
xStringFeedbackCtl * f) xStringFeedbackCtl * f)
{ {
char n;
int i, j; int i, j;
KeySym *syms, *sup_syms; KeySym *syms, *sup_syms;
syms = (KeySym *) (f + 1); syms = (KeySym *) (f + 1);
if (client->swapped) { if (client->swapped) {
swaps(&f->length); /* swapped num_keysyms in calling proc */ swaps(&f->length, n); /* swapped num_keysyms in calling proc */
SwapLongs((CARD32 *) syms, f->num_keysyms); SwapLongs((CARD32 *) syms, f->num_keysyms);
} }
if (f->num_keysyms > s->ctrl.max_symbols) if (f->num_keysyms > s->ctrl.max_symbols)
return BadValue; return BadValue;
sup_syms = s->ctrl.symbols_supported; sup_syms = s->ctrl.symbols_supported;
for (i = 0; i < f->num_keysyms; i++) { for (i = 0; i < f->num_keysyms; i++) {
for (j = 0; j < s->ctrl.num_symbols_supported; j++) for (j = 0; j < s->ctrl.num_symbols_supported; j++)
if (*(syms + i) == *(sup_syms + j)) if (*(syms + i) == *(sup_syms + j))
break; break;
if (j == s->ctrl.num_symbols_supported) if (j == s->ctrl.num_symbols_supported)
return BadMatch; return BadMatch;
} }
s->ctrl.num_symbols_displayed = f->num_keysyms; s->ctrl.num_symbols_displayed = f->num_keysyms;
for (i = 0; i < f->num_keysyms; i++) for (i = 0; i < f->num_keysyms; i++)
*(s->ctrl.symbols_displayed + i) = *(syms + i); *(s->ctrl.symbols_displayed + i) = *(syms + i);
(*s->CtrlProc) (dev, &s->ctrl); (*s->CtrlProc) (dev, &s->ctrl);
return Success; return Success;
} }
@ -332,50 +336,51 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
static int static int
ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, BellFeedbackPtr b, long unsigned int mask, BellFeedbackPtr b,
xBellFeedbackCtl * f) xBellFeedbackCtl * f)
{ {
char n;
int t; int t;
BellCtrl bctrl; /* might get BadValue part way through */ BellCtrl bctrl; /* might get BadValue part way through */
if (client->swapped) { if (client->swapped) {
swaps(&f->length); swaps(&f->length, n);
swaps(&f->pitch); swaps(&f->pitch, n);
swaps(&f->duration); swaps(&f->duration, n);
} }
bctrl = b->ctrl; bctrl = b->ctrl;
if (mask & DvPercent) { if (mask & DvPercent) {
t = f->percent; t = f->percent;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell; t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) { else if (t < 0 || t > 100) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
bctrl.percent = t; bctrl.percent = t;
} }
if (mask & DvPitch) { if (mask & DvPitch) {
t = f->pitch; t = f->pitch;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_pitch; t = defaultKeyboardControl.bell_pitch;
else if (t < 0) { else if (t < 0) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
bctrl.pitch = t; bctrl.pitch = t;
} }
if (mask & DvDuration) { if (mask & DvDuration) {
t = f->duration; t = f->duration;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_duration; t = defaultKeyboardControl.bell_duration;
else if (t < 0) { else if (t < 0) {
client->errorValue = t; client->errorValue = t;
return BadValue; return BadValue;
} }
bctrl.duration = t; bctrl.duration = t;
} }
b->ctrl = bctrl; b->ctrl = bctrl;
(*b->CtrlProc) (dev, &b->ctrl); (*b->CtrlProc) (dev, &b->ctrl);
@ -390,24 +395,25 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
static int static int
ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
LedFeedbackPtr l, xLedFeedbackCtl * f) LedFeedbackPtr l, xLedFeedbackCtl * f)
{ {
LedCtrl lctrl; /* might get BadValue part way through */ char n;
LedCtrl lctrl; /* might get BadValue part way through */
if (client->swapped) { if (client->swapped) {
swaps(&f->length); swaps(&f->length, n);
swapl(&f->led_values); swapl(&f->led_values, n);
swapl(&f->led_mask); swapl(&f->led_mask, n);
} }
f->led_mask &= l->ctrl.led_mask; /* set only supported leds */ f->led_mask &= l->ctrl.led_mask; /* set only supported leds */
f->led_values &= l->ctrl.led_mask; /* set only supported leds */ f->led_values &= l->ctrl.led_mask; /* set only supported leds */
if (mask & DvLed) { if (mask & DvLed) {
lctrl.led_mask = f->led_mask; lctrl.led_mask = f->led_mask;
lctrl.led_values = f->led_values; lctrl.led_values = f->led_values;
(*l->CtrlProc) (dev, &lctrl); (*l->CtrlProc) (dev, &lctrl);
l->ctrl.led_values &= ~(f->led_mask); /* zero changed leds */ l->ctrl.led_values &= ~(f->led_mask); /* zero changed leds */
l->ctrl.led_values |= (f->led_mask & f->led_values); /* OR in set leds */ l->ctrl.led_values |= (f->led_mask & f->led_values); /* OR in set leds */
} }
return Success; return Success;
@ -435,83 +441,78 @@ ProcXChangeFeedbackControl(ClientPtr client)
REQUEST(xChangeFeedbackControlReq); REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
len = client->req_len - bytes_to_int32(sizeof(xChangeFeedbackControlReq)); len = stuff->length - bytes_to_int32(sizeof(xChangeFeedbackControlReq));
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
switch (stuff->feedbackid) { switch (stuff->feedbackid) {
case KbdFeedbackClass: case KbdFeedbackClass:
if (len != bytes_to_int32(sizeof(xKbdFeedbackCtl))) if (len != bytes_to_int32(sizeof(xKbdFeedbackCtl)))
return BadLength; return BadLength;
for (k = dev->kbdfeed; k; k = k->next) for (k = dev->kbdfeed; k; k = k->next)
if (k->ctrl.id == ((xKbdFeedbackCtl *) &stuff[1])->id) if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id)
return ChangeKbdFeedback(client, dev, stuff->mask, k, return ChangeKbdFeedback(client, dev, stuff->mask, k,
(xKbdFeedbackCtl *) &stuff[1]); (xKbdFeedbackCtl *) & stuff[1]);
break; break;
case PtrFeedbackClass: case PtrFeedbackClass:
if (len != bytes_to_int32(sizeof(xPtrFeedbackCtl))) if (len != bytes_to_int32(sizeof(xPtrFeedbackCtl)))
return BadLength; return BadLength;
for (p = dev->ptrfeed; p; p = p->next) for (p = dev->ptrfeed; p; p = p->next)
if (p->ctrl.id == ((xPtrFeedbackCtl *) &stuff[1])->id) if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id)
return ChangePtrFeedback(client, dev, stuff->mask, p, return ChangePtrFeedback(client, dev, stuff->mask, p,
(xPtrFeedbackCtl *) &stuff[1]); (xPtrFeedbackCtl *) & stuff[1]);
break; break;
case StringFeedbackClass: case StringFeedbackClass:
{ {
xStringFeedbackCtl *f; char n;
xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeFeedbackControlReq, if (client->swapped) {
sizeof(xStringFeedbackCtl)); swaps(&f->num_keysyms, n);
f = ((xStringFeedbackCtl *) &stuff[1]); }
if (client->swapped) { if (len != (bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
if (len < bytes_to_int32(sizeof(xStringFeedbackCtl))) return BadLength;
return BadLength;
swaps(&f->num_keysyms);
}
if (len !=
(bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
return BadLength;
for (s = dev->stringfeed; s; s = s->next) for (s = dev->stringfeed; s; s = s->next)
if (s->ctrl.id == ((xStringFeedbackCtl *) &stuff[1])->id) if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id)
return ChangeStringFeedback(client, dev, stuff->mask, s, return ChangeStringFeedback(client, dev, stuff->mask, s,
(xStringFeedbackCtl *) &stuff[1]); (xStringFeedbackCtl *) & stuff[1]);
break; break;
} }
case IntegerFeedbackClass: case IntegerFeedbackClass:
if (len != bytes_to_int32(sizeof(xIntegerFeedbackCtl))) if (len != bytes_to_int32(sizeof(xIntegerFeedbackCtl)))
return BadLength; return BadLength;
for (i = dev->intfeed; i; i = i->next) for (i = dev->intfeed; i; i = i->next)
if (i->ctrl.id == ((xIntegerFeedbackCtl *) &stuff[1])->id) if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id)
return ChangeIntegerFeedback(client, dev, stuff->mask, i, return ChangeIntegerFeedback(client, dev, stuff->mask, i,
(xIntegerFeedbackCtl *) & (xIntegerFeedbackCtl *)&stuff[1]);
stuff[1]); break;
break;
case LedFeedbackClass: case LedFeedbackClass:
if (len != bytes_to_int32(sizeof(xLedFeedbackCtl))) if (len != bytes_to_int32(sizeof(xLedFeedbackCtl)))
return BadLength; return BadLength;
for (l = dev->leds; l; l = l->next) for (l = dev->leds; l; l = l->next)
if (l->ctrl.id == ((xLedFeedbackCtl *) &stuff[1])->id) if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id)
return ChangeLedFeedback(client, dev, stuff->mask, l, return ChangeLedFeedback(client, dev, stuff->mask, l,
(xLedFeedbackCtl *) &stuff[1]); (xLedFeedbackCtl *) & stuff[1]);
break; break;
case BellFeedbackClass: case BellFeedbackClass:
if (len != bytes_to_int32(sizeof(xBellFeedbackCtl))) if (len != bytes_to_int32(sizeof(xBellFeedbackCtl)))
return BadLength; return BadLength;
for (b = dev->bell; b; b = b->next) for (b = dev->bell; b; b = b->next)
if (b->ctrl.id == ((xBellFeedbackCtl *) &stuff[1])->id) if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id)
return ChangeBellFeedback(client, dev, stuff->mask, b, return ChangeBellFeedback(client, dev, stuff->mask, b,
(xBellFeedbackCtl *) &stuff[1]); (xBellFeedbackCtl *) & stuff[1]);
break; break;
default: default:
break; break;
} }
return BadMatch; return BadMatch;
} }

View file

@ -30,10 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGFCTL_H #ifndef CHGFCTL_H
#define CHGFCTL_H 1 #define CHGFCTL_H 1
int SProcXChangeFeedbackControl(ClientPtr /* client */ int SProcXChangeFeedbackControl(ClientPtr /* client */
); );
int ProcXChangeFeedbackControl(ClientPtr /* client */ int ProcXChangeFeedbackControl(ClientPtr /* client */
); );
#endif /* CHGFCTL_H */ #endif /* CHGFCTL_H */

View file

@ -50,9 +50,11 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "XIstubs.h" #include "XIstubs.h"
@ -69,6 +71,25 @@ SOFTWARE.
* This procedure changes the keyboard device. * This procedure changes the keyboard device.
* *
*/ */
int
SProcXChangeKeyboardDevice(ClientPtr client)
{
char n;
REQUEST(xChangeKeyboardDeviceReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
return (ProcXChangeKeyboardDevice(client));
}
/***********************************************************************
*
* This procedure is invoked to swap the request bytes if the server and
* client have a different byte order.
*
*/
int int
ProcXChangeKeyboardDevice(ClientPtr client) ProcXChangeKeyboardDevice(ClientPtr client)
{ {

View file

@ -30,7 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGKBD_H #ifndef CHGKBD_H
#define CHGKBD_H 1 #define CHGKBD_H 1
int ProcXChangeKeyboardDevice(ClientPtr /* client */ int SProcXChangeKeyboardDevice(ClientPtr /* client */
); );
#endif /* CHGKBD_H */ int ProcXChangeKeyboardDevice(ClientPtr /* client */
);
#endif /* CHGKBD_H */

View file

@ -50,14 +50,14 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "dix/exevents_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h" #include "exglobals.h"
#include "chgkmap.h" #include "chgkmap.h"
@ -69,12 +69,14 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXChangeDeviceKeyMapping(ClientPtr client) SProcXChangeDeviceKeyMapping(ClientPtr client)
{ {
char n;
unsigned int count; unsigned int count;
REQUEST(xChangeDeviceKeyMappingReq); REQUEST(xChangeDeviceKeyMappingReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
count = stuff->keyCodes * stuff->keySymsPerKeyCode; count = stuff->keyCodes * stuff->keySymsPerKeyCode;
REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32)); REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
@ -104,12 +106,12 @@ ProcXChangeDeviceKeyMapping(ClientPtr client)
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success) if (ret != Success)
return ret; return ret;
len = client->req_len - bytes_to_int32(sizeof(xChangeDeviceKeyMappingReq)); len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceKeyMappingReq));
ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify, ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify,
stuff->firstKeyCode, stuff->keyCodes, stuff->firstKeyCode, stuff->keyCodes,
stuff->keySymsPerKeyCode, (KeySym *) &stuff[1]); stuff->keySymsPerKeyCode, (KeySym *) & stuff[1]);
return ret; return ret;
} }

View file

@ -30,10 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGKMAP_H #ifndef CHGKMAP_H
#define CHGKMAP_H 1 #define CHGKMAP_H 1
int SProcXChangeDeviceKeyMapping(ClientPtr /* client */ int SProcXChangeDeviceKeyMapping(ClientPtr /* client */
); );
int ProcXChangeDeviceKeyMapping(ClientPtr /* client */ int ProcXChangeDeviceKeyMapping(ClientPtr /* client */
); );
#endif /* CHGKMAP_H */ #endif /* CHGKMAP_H */

View file

@ -50,18 +50,18 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h"
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h"
#include "exevents.h" #include "exevents.h"
#include "exglobals.h" #include "exglobals.h"
#include "chgprop.h" #include "chgprop.h"
#include "grabdev.h" #include "grabdev.h"
@ -71,15 +71,18 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXChangeDeviceDontPropagateList(ClientPtr client) SProcXChangeDeviceDontPropagateList(ClientPtr client)
{ {
char n;
REQUEST(xChangeDeviceDontPropagateListReq); REQUEST(xChangeDeviceDontPropagateListReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
swapl(&stuff->window); swapl(&stuff->window, n);
swaps(&stuff->count); swaps(&stuff->count, n);
REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq, REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq,
stuff->count * sizeof(CARD32)); stuff->count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->count); SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
return (ProcXChangeDeviceDontPropagateList(client)); return (ProcXChangeDeviceDontPropagateList(client));
} }
@ -101,40 +104,39 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client)
REQUEST(xChangeDeviceDontPropagateListReq); REQUEST(xChangeDeviceDontPropagateListReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
if (client->req_len != if (stuff->length != bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) +
bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) + stuff->count)
stuff->count) return BadLength;
return BadLength;
rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (stuff->mode != AddToList && stuff->mode != DeleteFromList) { if (stuff->mode != AddToList && stuff->mode != DeleteFromList) {
client->errorValue = stuff->window; client->errorValue = stuff->window;
return BadMode; return BadMode;
} }
if ((rc = CreateMaskFromList(client, (XEventClass *) &stuff[1], if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->count, tmp, NULL, stuff->count, tmp, NULL,
X_ChangeDeviceDontPropagateList)) != Success) X_ChangeDeviceDontPropagateList)) != Success)
return rc; return rc;
others = wOtherInputMasks(pWin); others = wOtherInputMasks(pWin);
if (!others && stuff->mode == DeleteFromList) if (!others && stuff->mode == DeleteFromList)
return Success; return Success;
for (i = 0; i < EMASKSIZE; i++) { for (i = 0; i < EMASKSIZE; i++) {
if (tmp[i].mask == 0) if (tmp[i].mask == 0)
continue; continue;
if (stuff->mode == DeleteFromList) if (stuff->mode == DeleteFromList)
tmp[i].mask = (others->dontPropagateMask[i] & ~tmp[i].mask); tmp[i].mask = (others->dontPropagateMask[i] & ~tmp[i].mask);
else if (others) else if (others)
tmp[i].mask |= others->dontPropagateMask[i]; tmp[i].mask |= others->dontPropagateMask[i];
if (DeviceEventSuppressForWindow(pWin, client, tmp[i].mask, i) != if (DeviceEventSuppressForWindow(pWin, client, tmp[i].mask, i) !=
Success) Success)
return BadClass; return BadClass;
} }
return Success; return Success;

View file

@ -30,10 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGPROP_H #ifndef CHGPROP_H
#define CHGPROP_H 1 #define CHGPROP_H 1
int SProcXChangeDeviceDontPropagateList(ClientPtr /* client */ int SProcXChangeDeviceDontPropagateList(ClientPtr /* client */
); );
int ProcXChangeDeviceDontPropagateList(ClientPtr /* client */ int ProcXChangeDeviceDontPropagateList(ClientPtr /* client */
); );
#endif /* CHGPROP_H */ #endif /* CHGPROP_H */

View file

@ -50,14 +50,16 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "XIstubs.h" #include "XIstubs.h"
#include "windowstr.h" /* window structure */ #include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */ #include "scrnintstr.h" /* screen structure */
#include "dixevents.h" #include "dixevents.h"
#include "exevents.h" #include "exevents.h"
@ -65,6 +67,24 @@ SOFTWARE.
#include "chgptr.h" #include "chgptr.h"
/***********************************************************************
*
* This procedure is invoked to swap the request bytes if the server and
* client have a different byte order.
*
*/
int
SProcXChangePointerDevice(ClientPtr client)
{
char n;
REQUEST(xChangePointerDeviceReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
return (ProcXChangePointerDevice(client));
}
/*********************************************************************** /***********************************************************************
* *
* This procedure changes the device used as the X pointer. * This procedure changes the device used as the X pointer.

View file

@ -30,10 +30,19 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGPTR_H #ifndef CHGPTR_H
#define CHGPTR_H 1 #define CHGPTR_H 1
int ProcXChangePointerDevice(ClientPtr /* client */ int SProcXChangePointerDevice(ClientPtr /* client */
); );
void DeleteFocusClassDeviceStruct(DeviceIntPtr /* dev */ int ProcXChangePointerDevice(ClientPtr /* client */
); );
#endif /* CHGPTR_H */ void DeleteFocusClassDeviceStruct(DeviceIntPtr /* dev */
);
void SendEventToAllWindows(DeviceIntPtr /* dev */ ,
Mask /* mask */ ,
xEvent * /* ev */ ,
int /* count */
);
#endif /* CHGPTR_H */

View file

@ -50,11 +50,13 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */ #include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */ #include "scrnintstr.h" /* screen structure */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "XIstubs.h" #include "XIstubs.h"
@ -62,6 +64,23 @@ SOFTWARE.
#include "closedev.h" #include "closedev.h"
/***********************************************************************
*
* This procedure closes an input device.
*
*/
int
SProcXCloseDevice(ClientPtr client)
{
char n;
REQUEST(xCloseDeviceReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCloseDeviceReq);
return (ProcXCloseDevice(client));
}
/*********************************************************************** /***********************************************************************
* *
* Clear out event selections and passive grabs from a window for the * Clear out event selections and passive grabs from a window for the
@ -77,21 +96,21 @@ DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
GrabPtr grab, next; GrabPtr grab, next;
if ((pOthers = wOtherInputMasks(pWin)) != 0) if ((pOthers = wOtherInputMasks(pWin)) != 0)
for (others = pOthers->inputClients; others; others = others->next) for (others = pOthers->inputClients; others; others = others->next)
if (SameClient(others, client)) if (SameClient(others, client))
others->mask[dev->id] = NoEventMask; others->mask[dev->id] = NoEventMask;
for (grab = wPassiveGrabs(pWin); grab; grab = next) { for (grab = wPassiveGrabs(pWin); grab; grab = next) {
next = grab->next; next = grab->next;
if ((grab->device == dev) && if ((grab->device == dev) &&
(client->clientAsMask == CLIENT_BITS(grab->resource))) (client->clientAsMask == CLIENT_BITS(grab->resource)))
FreeResource(grab->resource, X11_RESTYPE_NONE); FreeResource(grab->resource, RT_NONE);
} }
} }
/*********************************************************************** /***********************************************************************
* *
* Walk through the window tree, deleting event selections for this client * Walk througth the window tree, deleting event selections for this client
* from this device from all windows. * from this device from all windows.
* *
*/ */
@ -102,10 +121,10 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
WindowPtr p2; WindowPtr p2;
while (p1) { while (p1) {
p2 = p1->firstChild; p2 = p1->firstChild;
DeleteDeviceEvents(dev, p1, client); DeleteDeviceEvents(dev, p1, client);
DeleteEventsFromChildren(dev, p2, client); DeleteEventsFromChildren(dev, p2, client);
p1 = p1->nextSib; p1 = p1->nextSib;
} }
} }
@ -127,20 +146,20 @@ ProcXCloseDevice(ClientPtr client)
rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess); rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client)) if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client))
(*d->deviceGrab.DeactivateGrab) (d); /* release active grab */ (*d->deviceGrab.DeactivateGrab) (d); /* release active grab */
/* Remove event selections from all windows for events from this device /* Remove event selections from all windows for events from this device
* and selected by this client. * and selected by this client.
* Delete passive grabs from all windows for this device. */ * Delete passive grabs from all windows for this device. */
for (i = 0; i < screenInfo.numScreens; i++) { for (i = 0; i < screenInfo.numScreens; i++) {
pWin = screenInfo.screens[i]->root; pWin = screenInfo.screens[i]->root;
DeleteDeviceEvents(d, pWin, client); DeleteDeviceEvents(d, pWin, client);
p1 = pWin->firstChild; p1 = pWin->firstChild;
DeleteEventsFromChildren(d, p1, client); DeleteEventsFromChildren(d, p1, client);
} }
return Success; return Success;

View file

@ -30,7 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CLOSEDEV_H #ifndef CLOSEDEV_H
#define CLOSEDEV_H 1 #define CLOSEDEV_H 1
int ProcXCloseDevice(ClientPtr /* client */ int SProcXCloseDevice(ClientPtr /* client */
); );
#endif /* CLOSEDEV_H */ int ProcXCloseDevice(ClientPtr /* client */
);
#endif /* CLOSEDEV_H */

View file

@ -50,15 +50,34 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "devbell.h" #include "devbell.h"
/***********************************************************************
*
* This procedure is invoked to swap the request bytes if the server and
* client have a different byte order.
*
*/
int
SProcXDeviceBell(ClientPtr client)
{
char n;
REQUEST(xDeviceBellReq);
swaps(&stuff->length, n);
return (ProcXDeviceBell(client));
}
/*********************************************************************** /***********************************************************************
* *
* This procedure rings a bell on an extension device. * This procedure rings a bell on an extension device.
@ -74,7 +93,7 @@ ProcXDeviceBell(ClientPtr client)
int rc, base; int rc, base;
int newpercent; int newpercent;
CARD8 class; CARD8 class;
void *ctrl; pointer ctrl;
BellProcPtr proc; BellProcPtr proc;
REQUEST(xDeviceBellReq); REQUEST(xDeviceBellReq);
@ -82,51 +101,48 @@ ProcXDeviceBell(ClientPtr client)
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixBellAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixBellAccess);
if (rc != Success) { if (rc != Success) {
client->errorValue = stuff->deviceid; client->errorValue = stuff->deviceid;
return rc; return rc;
} }
if (stuff->percent < -100 || stuff->percent > 100) { if (stuff->percent < -100 || stuff->percent > 100) {
client->errorValue = stuff->percent; client->errorValue = stuff->percent;
return BadValue; return BadValue;
} }
if (stuff->feedbackclass == KbdFeedbackClass) { if (stuff->feedbackclass == KbdFeedbackClass) {
for (k = dev->kbdfeed; k; k = k->next) for (k = dev->kbdfeed; k; k = k->next)
if (k->ctrl.id == stuff->feedbackid) if (k->ctrl.id == stuff->feedbackid)
break; break;
if (!k) { if (!k) {
client->errorValue = stuff->feedbackid; client->errorValue = stuff->feedbackid;
return BadValue; return BadValue;
} }
base = k->ctrl.bell; base = k->ctrl.bell;
proc = k->BellProc; proc = k->BellProc;
ctrl = (void *) &(k->ctrl); ctrl = (pointer) & (k->ctrl);
class = KbdFeedbackClass; class = KbdFeedbackClass;
} } else if (stuff->feedbackclass == BellFeedbackClass) {
else if (stuff->feedbackclass == BellFeedbackClass) { for (b = dev->bell; b; b = b->next)
for (b = dev->bell; b; b = b->next) if (b->ctrl.id == stuff->feedbackid)
if (b->ctrl.id == stuff->feedbackid) break;
break; if (!b) {
if (!b) { client->errorValue = stuff->feedbackid;
client->errorValue = stuff->feedbackid; return BadValue;
return BadValue; }
} base = b->ctrl.percent;
base = b->ctrl.percent; proc = b->BellProc;
proc = b->BellProc; ctrl = (pointer) & (b->ctrl);
ctrl = (void *) &(b->ctrl); class = BellFeedbackClass;
class = BellFeedbackClass; } else {
} client->errorValue = stuff->feedbackclass;
else { return BadValue;
client->errorValue = stuff->feedbackclass;
return BadValue;
} }
newpercent = (base * stuff->percent) / 100; newpercent = (base * stuff->percent) / 100;
if (stuff->percent < 0) if (stuff->percent < 0)
newpercent = base + newpercent; newpercent = base + newpercent;
else else
newpercent = base - newpercent + stuff->percent; newpercent = base - newpercent + stuff->percent;
if (proc == NULL)
return BadValue;
(*proc) (newpercent, dev, ctrl, class); (*proc) (newpercent, dev, ctrl, class);
return Success; return Success;
} }

View file

@ -30,7 +30,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef DEVBELL_H #ifndef DEVBELL_H
#define DEVBELL_H 1 #define DEVBELL_H 1
int ProcXDeviceBell(ClientPtr /* client */ int SProcXDeviceBell(ClientPtr /* client */
); );
#endif /* DEVBELL_H */ int ProcXDeviceBell(ClientPtr /* client */
);
#endif /* DEVBELL_H */

File diff suppressed because it is too large Load diff

View file

@ -44,6 +44,7 @@ extern int DeviceBusy;
extern int BadClass; extern int BadClass;
/* Note: only the ones needed in files other than extinit.c are declared */ /* Note: only the ones needed in files other than extinit.c are declared */
extern const Mask DevicePointerMotionMask;
extern const Mask DevicePointerMotionHintMask; extern const Mask DevicePointerMotionHintMask;
extern const Mask DeviceFocusChangeMask; extern const Mask DeviceFocusChangeMask;
extern const Mask DeviceStateNotifyMask; extern const Mask DeviceStateNotifyMask;
@ -55,6 +56,8 @@ extern const Mask DevicePresenceNotifyMask;
extern const Mask DevicePropertyNotifyMask; extern const Mask DevicePropertyNotifyMask;
extern const Mask XIAllMasks; extern const Mask XIAllMasks;
extern Mask PropagateMask[];
extern int DeviceValuator; extern int DeviceValuator;
extern int DeviceKeyPress; extern int DeviceKeyPress;
extern int DeviceKeyRelease; extern int DeviceKeyRelease;
@ -76,7 +79,6 @@ extern int DevicePropertyNotify;
extern RESTYPE RT_INPUTCLIENT; extern RESTYPE RT_INPUTCLIENT;
extern DevPrivateKeyRec XIClientPrivateKeyRec; extern DevPrivateKeyRec XIClientPrivateKeyRec;
#define XIClientPrivateKey (&XIClientPrivateKeyRec) #define XIClientPrivateKey (&XIClientPrivateKeyRec)
#endif /* EXGLOBALS_H */ #endif /* EXGLOBALS_H */

File diff suppressed because it is too large Load diff

View file

@ -50,15 +50,33 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "getbmap.h" #include "getbmap.h"
/***********************************************************************
*
* This procedure gets the button mapping for the specified device.
*
*/
int
SProcXGetDeviceButtonMapping(ClientPtr client)
{
char n;
REQUEST(xGetDeviceButtonMappingReq);
swaps(&stuff->length, n);
return (ProcXGetDeviceButtonMapping(client));
}
/*********************************************************************** /***********************************************************************
* *
* This procedure gets the button mapping for the specified device. * This procedure gets the button mapping for the specified device.
@ -76,26 +94,24 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
REQUEST(xGetDeviceButtonMappingReq); REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq); REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
rep = (xGetDeviceButtonMappingReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetDeviceButtonMapping;
.RepType = X_GetDeviceButtonMapping, rep.nElts = 0;
.sequenceNumber = client->sequence, rep.length = 0;
.nElts = 0, rep.sequenceNumber = client->sequence;
.length = 0
};
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
b = dev->button; b = dev->button;
if (b == NULL) if (b == NULL)
return BadMatch; return BadMatch;
rep.nElts = b->numButtons; rep.nElts = b->numButtons;
rep.length = bytes_to_int32(rep.nElts); rep.length = bytes_to_int32(rep.nElts);
WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
WriteToClient(client, rep.nElts, &b->map[1]); (void)WriteToClient(client, rep.nElts, (char *)&b->map[1]);
return Success; return Success;
} }
@ -106,11 +122,13 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXGetDeviceButtonMapping(ClientPtr client, int size, SRepXGetDeviceButtonMapping(ClientPtr client, int size,
xGetDeviceButtonMappingReply * rep) xGetDeviceButtonMappingReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
WriteToClient(client, size, rep); swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,12 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETBMAP_H #ifndef GETBMAP_H
#define GETBMAP_H 1 #define GETBMAP_H 1
int ProcXGetDeviceButtonMapping(ClientPtr /* client */ int SProcXGetDeviceButtonMapping(ClientPtr /* client */
);
int ProcXGetDeviceButtonMapping(ClientPtr /* client */
); );
void SRepXGetDeviceButtonMapping(ClientPtr /* client */ , void SRepXGetDeviceButtonMapping(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetDeviceButtonMappingReply * /* rep */ xGetDeviceButtonMappingReply * /* rep */
); );
#endif /* GETBMAP_H */ #endif /* GETBMAP_H */

View file

@ -50,9 +50,11 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
@ -66,12 +68,15 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXGetDeviceControl(ClientPtr client) SProcXGetDeviceControl(ClientPtr client)
{ {
char n;
REQUEST(xGetDeviceControlReq); REQUEST(xGetDeviceControlReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetDeviceControlReq); REQUEST_SIZE_MATCH(xGetDeviceControlReq);
swaps(&stuff->control); swaps(&stuff->control, n);
return (ProcXGetDeviceControl(client)); return (ProcXGetDeviceControl(client));
} }
@ -83,8 +88,9 @@ SProcXGetDeviceControl(ClientPtr client)
static void static void
CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
int length) int length)
{ {
char n;
AxisInfoPtr a; AxisInfoPtr a;
xDeviceResolutionState *r; xDeviceResolutionState *r;
int i, *iptr; int i, *iptr;
@ -94,27 +100,27 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
r->length = length; r->length = length;
r->num_valuators = v->numAxes; r->num_valuators = v->numAxes;
buf += sizeof(xDeviceResolutionState); buf += sizeof(xDeviceResolutionState);
iptr = (int *) buf; iptr = (int *)buf;
for (i = 0, a = v->axes; i < v->numAxes; i++, a++) for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->resolution; *iptr++ = a->resolution;
for (i = 0, a = v->axes; i < v->numAxes; i++, a++) for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->min_resolution; *iptr++ = a->min_resolution;
for (i = 0, a = v->axes; i < v->numAxes; i++, a++) for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->max_resolution; *iptr++ = a->max_resolution;
if (client->swapped) { if (client->swapped) {
swaps(&r->control); swaps(&r->control, n);
swaps(&r->length); swaps(&r->length, n);
swapl(&r->num_valuators); swapl(&r->num_valuators, n);
iptr = (int *) buf; iptr = (int *)buf;
for (i = 0; i < (3 * v->numAxes); i++, iptr++) { for (i = 0; i < (3 * v->numAxes); i++, iptr++) {
swapl(iptr); swapl(iptr, n);
} }
} }
} }
static void static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf)
{ {
char n;
xDeviceCoreState *c = (xDeviceCoreState *) buf; xDeviceCoreState *c = (xDeviceCoreState *) buf;
c->control = DEVICE_CORE; c->control = DEVICE_CORE;
@ -123,14 +129,15 @@ CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf)
c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer); c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer);
if (client->swapped) { if (client->swapped) {
swaps(&c->control); swaps(&c->control, n);
swaps(&c->length); swaps(&c->length, n);
swaps(&c->status, n);
} }
} }
static void static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
{ {
char n;
xDeviceEnableState *e = (xDeviceEnableState *) buf; xDeviceEnableState *e = (xDeviceEnableState *) buf;
e->control = DEVICE_ENABLE; e->control = DEVICE_ENABLE;
@ -138,8 +145,9 @@ CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
e->enable = dev->enabled; e->enable = dev->enabled;
if (client->swapped) { if (client->swapped) {
swaps(&e->control); swaps(&e->control, n);
swaps(&e->length); swaps(&e->length, n);
swaps(&e->enable, n);
} }
} }
@ -150,12 +158,14 @@ CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
* *
*/ */
void _X_COLD void
SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep) SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
WriteToClient(client, size, rep); swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
} }
/*********************************************************************** /***********************************************************************
@ -177,22 +187,20 @@ ProcXGetDeviceControl(ClientPtr client)
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rep = (xGetDeviceControlReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetDeviceControl;
.RepType = X_GetDeviceControl, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0
};
switch (stuff->control) { switch (stuff->control) {
case DEVICE_RESOLUTION: case DEVICE_RESOLUTION:
if (!dev->valuator) if (!dev->valuator)
return BadMatch; return BadMatch;
total_length = sizeof(xDeviceResolutionState) + total_length = sizeof(xDeviceResolutionState) +
(3 * sizeof(int) * dev->valuator->numAxes); (3 * sizeof(int) * dev->valuator->numAxes);
break; break;
case DEVICE_ABS_CALIB: case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA: case DEVICE_ABS_AREA:
return BadMatch; return BadMatch;
@ -203,18 +211,18 @@ ProcXGetDeviceControl(ClientPtr client)
total_length = sizeof(xDeviceEnableState); total_length = sizeof(xDeviceEnableState);
break; break;
default: default:
return BadValue; return BadValue;
} }
buf = (char *) malloc(total_length); buf = (char *)malloc(total_length);
if (!buf) if (!buf)
return BadAlloc; return BadAlloc;
savbuf = buf; savbuf = buf;
switch (stuff->control) { switch (stuff->control) {
case DEVICE_RESOLUTION: case DEVICE_RESOLUTION:
CopySwapDeviceResolution(client, dev->valuator, buf, total_length); CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
break; break;
case DEVICE_CORE: case DEVICE_CORE:
CopySwapDeviceCore(client, dev, buf); CopySwapDeviceCore(client, dev, buf);
break; break;
@ -222,7 +230,7 @@ ProcXGetDeviceControl(ClientPtr client)
CopySwapDeviceEnable(client, dev, buf); CopySwapDeviceEnable(client, dev, buf);
break; break;
default: default:
break; break;
} }
rep.length = bytes_to_int32(total_length); rep.length = bytes_to_int32(total_length);

View file

@ -30,15 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETDCTL_H #ifndef GETDCTL_H
#define GETDCTL_H 1 #define GETDCTL_H 1
int SProcXGetDeviceControl(ClientPtr /* client */ int SProcXGetDeviceControl(ClientPtr /* client */
); );
int ProcXGetDeviceControl(ClientPtr /* client */ int ProcXGetDeviceControl(ClientPtr /* client */
); );
void SRepXGetDeviceControl(ClientPtr /* client */ , void SRepXGetDeviceControl(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetDeviceControlReply * /* rep */ xGetDeviceControlReply * /* rep */
); );
#endif /* GETDCTL_H */ #endif /* GETDCTL_H */

View file

@ -50,15 +50,34 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "getfctl.h" #include "getfctl.h"
/***********************************************************************
*
* This procedure gets the control attributes for an extension device,
* for clients on machines with a different byte ordering than the server.
*
*/
int
SProcXGetFeedbackControl(ClientPtr client)
{
char n;
REQUEST(xGetFeedbackControlReq);
swaps(&stuff->length, n);
return (ProcXGetFeedbackControl(client));
}
/*********************************************************************** /***********************************************************************
* *
* This procedure copies KbdFeedbackClass data, swapping if necessary. * This procedure copies KbdFeedbackClass data, swapping if necessary.
@ -69,6 +88,7 @@ static void
CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
{ {
int i; int i;
char n;
xKbdFeedbackState *k2; xKbdFeedbackState *k2;
k2 = (xKbdFeedbackState *) * buf; k2 = (xKbdFeedbackState *) * buf;
@ -80,16 +100,15 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
k2->pitch = k->ctrl.bell_pitch; k2->pitch = k->ctrl.bell_pitch;
k2->duration = k->ctrl.bell_duration; k2->duration = k->ctrl.bell_duration;
k2->led_mask = k->ctrl.leds; k2->led_mask = k->ctrl.leds;
k2->led_values = k->ctrl.leds;
k2->global_auto_repeat = k->ctrl.autoRepeat; k2->global_auto_repeat = k->ctrl.autoRepeat;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
k2->auto_repeats[i] = k->ctrl.autoRepeats[i]; k2->auto_repeats[i] = k->ctrl.autoRepeats[i];
if (client->swapped) { if (client->swapped) {
swaps(&k2->length); swaps(&k2->length, n);
swaps(&k2->pitch); swaps(&k2->pitch, n);
swaps(&k2->duration); swaps(&k2->duration, n);
swapl(&k2->led_mask); swapl(&k2->led_mask, n);
swapl(&k2->led_values); swapl(&k2->led_values, n);
} }
*buf += sizeof(xKbdFeedbackState); *buf += sizeof(xKbdFeedbackState);
} }
@ -103,6 +122,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
static void static void
CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
{ {
char n;
xPtrFeedbackState *p2; xPtrFeedbackState *p2;
p2 = (xPtrFeedbackState *) * buf; p2 = (xPtrFeedbackState *) * buf;
@ -113,10 +133,10 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
p2->accelDenom = p->ctrl.den; p2->accelDenom = p->ctrl.den;
p2->threshold = p->ctrl.threshold; p2->threshold = p->ctrl.threshold;
if (client->swapped) { if (client->swapped) {
swaps(&p2->length); swaps(&p2->length, n);
swaps(&p2->accelNum); swaps(&p2->accelNum, n);
swaps(&p2->accelDenom); swaps(&p2->accelDenom, n);
swaps(&p2->threshold); swaps(&p2->threshold, n);
} }
*buf += sizeof(xPtrFeedbackState); *buf += sizeof(xPtrFeedbackState);
} }
@ -130,6 +150,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
static void static void
CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
{ {
char n;
xIntegerFeedbackState *i2; xIntegerFeedbackState *i2;
i2 = (xIntegerFeedbackState *) * buf; i2 = (xIntegerFeedbackState *) * buf;
@ -140,10 +161,10 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
i2->min_value = i->ctrl.min_value; i2->min_value = i->ctrl.min_value;
i2->max_value = i->ctrl.max_value; i2->max_value = i->ctrl.max_value;
if (client->swapped) { if (client->swapped) {
swaps(&i2->length); swaps(&i2->length, n);
swapl(&i2->resolution); swapl(&i2->resolution, n);
swapl(&i2->min_value); swapl(&i2->min_value, n);
swapl(&i2->max_value); swapl(&i2->max_value, n);
} }
*buf += sizeof(xIntegerFeedbackState); *buf += sizeof(xIntegerFeedbackState);
} }
@ -158,28 +179,29 @@ static void
CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
{ {
int i; int i;
char n;
xStringFeedbackState *s2; xStringFeedbackState *s2;
KeySym *kptr; KeySym *kptr;
s2 = (xStringFeedbackState *) * buf; s2 = (xStringFeedbackState *) * buf;
s2->class = StringFeedbackClass; s2->class = StringFeedbackClass;
s2->length = sizeof(xStringFeedbackState) + s2->length = sizeof(xStringFeedbackState) +
s->ctrl.num_symbols_supported * sizeof(KeySym); s->ctrl.num_symbols_supported * sizeof(KeySym);
s2->id = s->ctrl.id; s2->id = s->ctrl.id;
s2->max_symbols = s->ctrl.max_symbols; s2->max_symbols = s->ctrl.max_symbols;
s2->num_syms_supported = s->ctrl.num_symbols_supported; s2->num_syms_supported = s->ctrl.num_symbols_supported;
*buf += sizeof(xStringFeedbackState); *buf += sizeof(xStringFeedbackState);
kptr = (KeySym *) (*buf); kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++) for (i = 0; i < s->ctrl.num_symbols_supported; i++)
*kptr++ = *(s->ctrl.symbols_supported + i); *kptr++ = *(s->ctrl.symbols_supported + i);
if (client->swapped) { if (client->swapped) {
swaps(&s2->length); swaps(&s2->length, n);
swaps(&s2->max_symbols); swaps(&s2->max_symbols, n);
swaps(&s2->num_syms_supported); swaps(&s2->num_syms_supported, n);
kptr = (KeySym *) (*buf); kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++, kptr++) { for (i = 0; i < s->ctrl.num_symbols_supported; i++, kptr++) {
swapl(kptr); swapl(kptr, n);
} }
} }
*buf += (s->ctrl.num_symbols_supported * sizeof(KeySym)); *buf += (s->ctrl.num_symbols_supported * sizeof(KeySym));
} }
@ -193,6 +215,7 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
static void static void
CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
{ {
char n;
xLedFeedbackState *l2; xLedFeedbackState *l2;
l2 = (xLedFeedbackState *) * buf; l2 = (xLedFeedbackState *) * buf;
@ -202,9 +225,9 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
l2->led_values = l->ctrl.led_values; l2->led_values = l->ctrl.led_values;
l2->led_mask = l->ctrl.led_mask; l2->led_mask = l->ctrl.led_mask;
if (client->swapped) { if (client->swapped) {
swaps(&l2->length); swaps(&l2->length, n);
swapl(&l2->led_values); swapl(&l2->led_values, n);
swapl(&l2->led_mask); swapl(&l2->led_mask, n);
} }
*buf += sizeof(xLedFeedbackState); *buf += sizeof(xLedFeedbackState);
} }
@ -218,6 +241,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
static void static void
CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf) CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
{ {
char n;
xBellFeedbackState *b2; xBellFeedbackState *b2;
b2 = (xBellFeedbackState *) * buf; b2 = (xBellFeedbackState *) * buf;
@ -228,9 +252,9 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
b2->pitch = b->ctrl.pitch; b2->pitch = b->ctrl.pitch;
b2->duration = b->ctrl.duration; b2->duration = b->ctrl.duration;
if (client->swapped) { if (client->swapped) {
swaps(&b2->length); swaps(&b2->length, n);
swaps(&b2->pitch); swaps(&b2->pitch, n);
swaps(&b2->duration); swaps(&b2->duration, n);
} }
*buf += sizeof(xBellFeedbackState); *buf += sizeof(xBellFeedbackState);
} }
@ -242,14 +266,16 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
* *
*/ */
void _X_COLD void
SRepXGetFeedbackControl(ClientPtr client, int size, SRepXGetFeedbackControl(ClientPtr client, int size,
xGetFeedbackControlReply * rep) xGetFeedbackControlReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
swaps(&rep->num_feedbacks); swaps(&rep->sequenceNumber, n);
WriteToClient(client, size, rep); swapl(&rep->length, n);
swaps(&rep->num_feedbacks, n);
WriteToClient(client, size, (char *)rep);
} }
/*********************************************************************** /***********************************************************************
@ -277,62 +303,60 @@ ProcXGetFeedbackControl(ClientPtr client)
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rep = (xGetFeedbackControlReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetFeedbackControl;
.RepType = X_GetFeedbackControl, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0, rep.num_feedbacks = 0;
.num_feedbacks = 0
};
for (k = dev->kbdfeed; k; k = k->next) { for (k = dev->kbdfeed; k; k = k->next) {
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xKbdFeedbackState); total_length += sizeof(xKbdFeedbackState);
} }
for (p = dev->ptrfeed; p; p = p->next) { for (p = dev->ptrfeed; p; p = p->next) {
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xPtrFeedbackState); total_length += sizeof(xPtrFeedbackState);
} }
for (s = dev->stringfeed; s; s = s->next) { for (s = dev->stringfeed; s; s = s->next) {
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xStringFeedbackState) + total_length += sizeof(xStringFeedbackState) +
(s->ctrl.num_symbols_supported * sizeof(KeySym)); (s->ctrl.num_symbols_supported * sizeof(KeySym));
} }
for (i = dev->intfeed; i; i = i->next) { for (i = dev->intfeed; i; i = i->next) {
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xIntegerFeedbackState); total_length += sizeof(xIntegerFeedbackState);
} }
for (l = dev->leds; l; l = l->next) { for (l = dev->leds; l; l = l->next) {
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xLedFeedbackState); total_length += sizeof(xLedFeedbackState);
} }
for (b = dev->bell; b; b = b->next) { for (b = dev->bell; b; b = b->next) {
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xBellFeedbackState); total_length += sizeof(xBellFeedbackState);
} }
if (total_length == 0) if (total_length == 0)
return BadMatch; return BadMatch;
buf = (char *) malloc(total_length); buf = (char *)malloc(total_length);
if (!buf) if (!buf)
return BadAlloc; return BadAlloc;
savbuf = buf; savbuf = buf;
for (k = dev->kbdfeed; k; k = k->next) for (k = dev->kbdfeed; k; k = k->next)
CopySwapKbdFeedback(client, k, &buf); CopySwapKbdFeedback(client, k, &buf);
for (p = dev->ptrfeed; p; p = p->next) for (p = dev->ptrfeed; p; p = p->next)
CopySwapPtrFeedback(client, p, &buf); CopySwapPtrFeedback(client, p, &buf);
for (s = dev->stringfeed; s; s = s->next) for (s = dev->stringfeed; s; s = s->next)
CopySwapStringFeedback(client, s, &buf); CopySwapStringFeedback(client, s, &buf);
for (i = dev->intfeed; i; i = i->next) for (i = dev->intfeed; i; i = i->next)
CopySwapIntegerFeedback(client, i, &buf); CopySwapIntegerFeedback(client, i, &buf);
for (l = dev->leds; l; l = l->next) for (l = dev->leds; l; l = l->next)
CopySwapLedFeedback(client, l, &buf); CopySwapLedFeedback(client, l, &buf);
for (b = dev->bell; b; b = b->next) for (b = dev->bell; b; b = b->next)
CopySwapBellFeedback(client, b, &buf); CopySwapBellFeedback(client, b, &buf);
rep.length = bytes_to_int32(total_length); rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep); WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep);

View file

@ -30,12 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETFCTL_H #ifndef GETFCTL_H
#define GETFCTL_H 1 #define GETFCTL_H 1
int ProcXGetFeedbackControl(ClientPtr /* client */ int SProcXGetFeedbackControl(ClientPtr /* client */
);
int ProcXGetFeedbackControl(ClientPtr /* client */
); );
void SRepXGetFeedbackControl(ClientPtr /* client */ , void SRepXGetFeedbackControl(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetFeedbackControlReply * /* rep */ xGetFeedbackControlReply * /* rep */
); );
#endif /* GETFCTL_H */ #endif /* GETFCTL_H */

View file

@ -50,16 +50,34 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "windowstr.h" /* focus struct */ #include "windowstr.h" /* focus struct */
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "getfocus.h" #include "getfocus.h"
/***********************************************************************
*
* This procedure gets the focus for a device.
*
*/
int
SProcXGetDeviceFocus(ClientPtr client)
{
char n;
REQUEST(xGetDeviceFocusReq);
swaps(&stuff->length, n);
return (ProcXGetDeviceFocus(client));
}
/*********************************************************************** /***********************************************************************
* *
* This procedure gets the focus for a device. * This procedure gets the focus for a device.
@ -79,27 +97,25 @@ ProcXGetDeviceFocus(ClientPtr client)
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetFocusAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetFocusAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (!dev->focus) if (!dev->focus)
return BadDevice; return BadDevice;
rep = (xGetDeviceFocusReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetDeviceFocus;
.RepType = X_GetDeviceFocus, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0
};
focus = dev->focus; focus = dev->focus;
if (focus->win == NoneWin) if (focus->win == NoneWin)
rep.focus = None; rep.focus = None;
else if (focus->win == PointerRootWin) else if (focus->win == PointerRootWin)
rep.focus = PointerRoot; rep.focus = PointerRoot;
else if (focus->win == FollowKeyboardWin) else if (focus->win == FollowKeyboardWin)
rep.focus = FollowKeyboard; rep.focus = FollowKeyboard;
else else
rep.focus = focus->win->drawable.id; rep.focus = focus->win->drawable.id;
rep.time = focus->time.milliseconds; rep.time = focus->time.milliseconds;
rep.revertTo = focus->revert; rep.revertTo = focus->revert;
@ -114,12 +130,14 @@ ProcXGetDeviceFocus(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXGetDeviceFocus(ClientPtr client, int size, xGetDeviceFocusReply * rep) SRepXGetDeviceFocus(ClientPtr client, int size, xGetDeviceFocusReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
swapl(&rep->focus); swaps(&rep->sequenceNumber, n);
swapl(&rep->time); swapl(&rep->length, n);
WriteToClient(client, size, rep); swapl(&rep->focus, n);
swapl(&rep->time, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,12 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETFOCUS_H #ifndef GETFOCUS_H
#define GETFOCUS_H 1 #define GETFOCUS_H 1
int ProcXGetDeviceFocus(ClientPtr /* client */ int SProcXGetDeviceFocus(ClientPtr /* client */
);
int ProcXGetDeviceFocus(ClientPtr /* client */
); );
void SRepXGetDeviceFocus(ClientPtr /* client */ , void SRepXGetDeviceFocus(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetDeviceFocusReply * /* rep */ xGetDeviceFocusReply * /* rep */
); );
#endif /* GETFOCUS_H */ #endif /* GETFOCUS_H */

View file

@ -50,9 +50,11 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
@ -62,6 +64,23 @@ SOFTWARE.
#include "getkmap.h" #include "getkmap.h"
/***********************************************************************
*
* This procedure gets the key mapping for an extension device,
* for clients on machines with a different byte ordering than the server.
*
*/
int
SProcXGetDeviceKeyMapping(ClientPtr client)
{
char n;
REQUEST(xGetDeviceKeyMappingReq);
swaps(&stuff->length, n);
return (ProcXGetDeviceKeyMapping(client));
}
/*********************************************************************** /***********************************************************************
* *
* Get the device key mapping. * Get the device key mapping.
@ -82,33 +101,31 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (dev->key == NULL) if (dev->key == NULL)
return BadMatch; return BadMatch;
xkb = dev->key->xkbInfo->desc; xkb = dev->key->xkbInfo->desc;
if (stuff->firstKeyCode < xkb->min_key_code || if (stuff->firstKeyCode < xkb->min_key_code ||
stuff->firstKeyCode > xkb->max_key_code) { stuff->firstKeyCode > xkb->max_key_code) {
client->errorValue = stuff->firstKeyCode; client->errorValue = stuff->firstKeyCode;
return BadValue; return BadValue;
} }
if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) { if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) {
client->errorValue = stuff->count; client->errorValue = stuff->count;
return BadValue; return BadValue;
} }
syms = XkbGetCoreMap(dev); syms = XkbGetCoreMap(dev);
if (!syms) if (!syms)
return BadAlloc; return BadAlloc;
rep = (xGetDeviceKeyMappingReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetDeviceKeyMapping;
.RepType = X_GetDeviceKeyMapping, rep.sequenceNumber = client->sequence;
.sequenceNumber = client->sequence, rep.keySymsPerKeyCode = syms->mapWidth;
.keySymsPerKeyCode = syms->mapWidth, rep.length = (syms->mapWidth * stuff->count); /* KeySyms are 4 bytes */
.length = (syms->mapWidth * stuff->count) /* KeySyms are 4 bytes */
};
WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
@ -129,11 +146,13 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXGetDeviceKeyMapping(ClientPtr client, int size, SRepXGetDeviceKeyMapping(ClientPtr client, int size,
xGetDeviceKeyMappingReply * rep) xGetDeviceKeyMappingReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
WriteToClient(client, size, rep); swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,12 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETKMAP_H #ifndef GETKMAP_H
#define GETKMAP_H 1 #define GETKMAP_H 1
int ProcXGetDeviceKeyMapping(ClientPtr /* client */ int SProcXGetDeviceKeyMapping(ClientPtr /* client */
);
int ProcXGetDeviceKeyMapping(ClientPtr /* client */
); );
void SRepXGetDeviceKeyMapping(ClientPtr /* client */ , void SRepXGetDeviceKeyMapping(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetDeviceKeyMappingReply * /* rep */ xGetDeviceKeyMappingReply * /* rep */
); );
#endif /* GETKMAP_H */ #endif /* GETKMAP_H */

View file

@ -50,15 +50,34 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* Request macro */ #include <X11/extensions/XIproto.h> /* Request macro */
#include "exglobals.h" #include "exglobals.h"
#include "getmmap.h" #include "getmmap.h"
/***********************************************************************
*
* This procedure gets the modifier mapping for an extension device,
* for clients on machines with a different byte ordering than the server.
*
*/
int
SProcXGetDeviceModifierMapping(ClientPtr client)
{
char n;
REQUEST(xGetDeviceModifierMappingReq);
swaps(&stuff->length, n);
return (ProcXGetDeviceModifierMapping(client));
}
/*********************************************************************** /***********************************************************************
* *
* Get the device Modifier mapping. * Get the device Modifier mapping.
@ -78,23 +97,21 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success) if (ret != Success)
return ret; return ret;
ret = generate_modkeymap(client, dev, &modkeymap, &max_keys_per_mod); ret = generate_modkeymap(client, dev, &modkeymap, &max_keys_per_mod);
if (ret != Success) if (ret != Success)
return ret; return ret;
rep = (xGetDeviceModifierMappingReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetDeviceModifierMapping;
.RepType = X_GetDeviceModifierMapping, rep.numKeyPerModifier = max_keys_per_mod;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.numKeyPerModifier = max_keys_per_mod,
/* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
.length = max_keys_per_mod << 1 rep.length = max_keys_per_mod << 1;
};
WriteReplyToClient(client, sizeof(xGetDeviceModifierMappingReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceModifierMappingReply), &rep);
WriteToClient(client, max_keys_per_mod * 8, modkeymap); WriteToClient(client, max_keys_per_mod * 8, (char *) modkeymap);
free(modkeymap); free(modkeymap);
@ -108,11 +125,13 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXGetDeviceModifierMapping(ClientPtr client, int size, SRepXGetDeviceModifierMapping(ClientPtr client, int size,
xGetDeviceModifierMappingReply * rep) xGetDeviceModifierMappingReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
WriteToClient(client, size, rep); swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,12 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETMMAP_H #ifndef GETMMAP_H
#define GETMMAP_H 1 #define GETMMAP_H 1
int ProcXGetDeviceModifierMapping(ClientPtr /* client */ int SProcXGetDeviceModifierMapping(ClientPtr /* client */
);
int ProcXGetDeviceModifierMapping(ClientPtr /* client */
); );
void SRepXGetDeviceModifierMapping(ClientPtr /* client */ , void SRepXGetDeviceModifierMapping(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetDeviceModifierMappingReply * /* rep */ xGetDeviceModifierMappingReply * /* rep */
); );
#endif /* GETMMAP_H */ #endif /* GETMMAP_H */

View file

@ -50,17 +50,17 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structs */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structs */
#include "exglobals.h" #include "exglobals.h"
#include "swaprep.h" #include "swaprep.h"
#include "getprop.h" #include "getprop.h"
extern XExtEventInfo EventInfo[]; extern XExtEventInfo EventInfo[];
@ -72,12 +72,15 @@ extern int ExtEventIndex;
* *
*/ */
int _X_COLD int
SProcXGetDeviceDontPropagateList(ClientPtr client) SProcXGetDeviceDontPropagateList(ClientPtr client)
{ {
char n;
REQUEST(xGetDeviceDontPropagateListReq); REQUEST(xGetDeviceDontPropagateListReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq); REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
swapl(&stuff->window); swapl(&stuff->window, n);
return (ProcXGetDeviceDontPropagateList(client)); return (ProcXGetDeviceDontPropagateList(client));
} }
@ -100,41 +103,38 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
REQUEST(xGetDeviceDontPropagateListReq); REQUEST(xGetDeviceDontPropagateListReq);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq); REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
rep = (xGetDeviceDontPropagateListReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetDeviceDontPropagateList;
.RepType = X_GetDeviceDontPropagateList, rep.sequenceNumber = client->sequence;
.sequenceNumber = client->sequence, rep.length = 0;
.length = 0, rep.count = 0;
.count = 0
};
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if ((others = wOtherInputMasks(pWin)) != 0) { if ((others = wOtherInputMasks(pWin)) != 0) {
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
ClassFromMask(NULL, others->dontPropagateMask[i], i, &count, COUNT); ClassFromMask(NULL, others->dontPropagateMask[i], i,
if (count) { &count, COUNT);
rep.count = count; if (count) {
buf = xallocarray(rep.count, sizeof(XEventClass)); rep.count = count;
if (buf == NULL) buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass));
return BadAlloc; rep.length = bytes_to_int32(rep.count * sizeof(XEventClass));
rep.length = bytes_to_int32(rep.count * sizeof(XEventClass));
tbuf = buf; tbuf = buf;
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
tbuf = ClassFromMask(tbuf, others->dontPropagateMask[i], i, tbuf = ClassFromMask(tbuf, others->dontPropagateMask[i], i,
NULL, CREATE); NULL, CREATE);
} }
} }
WriteReplyToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep);
if (count) { if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf); WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf);
free(buf); free(buf);
} }
return Success; return Success;
} }
@ -147,23 +147,23 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
*/ */
XEventClass XEventClass
* ClassFromMask(XEventClass * buf, Mask mask, int maskndx, CARD16 *count, * ClassFromMask(XEventClass * buf, Mask mask, int maskndx, CARD16 * count,
int mode) int mode)
{ {
int i, j; int i, j;
int id = maskndx; int id = maskndx;
Mask tmask = 0x80000000; Mask tmask = 0x80000000;
for (i = 0; i < 32; i++, tmask >>= 1) for (i = 0; i < 32; i++, tmask >>= 1)
if (tmask & mask) { if (tmask & mask) {
for (j = 0; j < ExtEventIndex; j++) for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].mask == tmask) { if (EventInfo[j].mask == tmask) {
if (mode == COUNT) if (mode == COUNT)
(*count)++; (*count)++;
else else
*buf++ = (id << 8) | EventInfo[j].type; *buf++ = (id << 8) | EventInfo[j].type;
} }
} }
return buf; return buf;
} }
@ -174,12 +174,14 @@ XEventClass
* *
*/ */
void _X_COLD void
SRepXGetDeviceDontPropagateList(ClientPtr client, int size, SRepXGetDeviceDontPropagateList(ClientPtr client, int size,
xGetDeviceDontPropagateListReply * rep) xGetDeviceDontPropagateListReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
swaps(&rep->count); swaps(&rep->sequenceNumber, n);
WriteToClient(client, size, rep); swapl(&rep->length, n);
swaps(&rep->count, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,22 +30,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETPROP_H #ifndef GETPROP_H
#define GETPROP_H 1 #define GETPROP_H 1
int SProcXGetDeviceDontPropagateList(ClientPtr /* client */ int SProcXGetDeviceDontPropagateList(ClientPtr /* client */
); );
int ProcXGetDeviceDontPropagateList(ClientPtr /* client */ int ProcXGetDeviceDontPropagateList(ClientPtr /* client */
); );
XEventClass *ClassFromMask(XEventClass * /* buf */ , XEventClass *ClassFromMask(XEventClass * /* buf */ ,
Mask /* mask */ , Mask /* mask */ ,
int /* maskndx */ , int /* maskndx */ ,
CARD16 * /* count */ , CARD16 * /* count */ ,
int /* mode */ int /* mode */
); );
void SRepXGetDeviceDontPropagateList(ClientPtr /* client */ , void SRepXGetDeviceDontPropagateList(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetDeviceDontPropagateListReply * /* rep */ xGetDeviceDontPropagateListReply * /* rep */
); );
#endif /* GETPROP_H */ #endif /* GETPROP_H */

View file

@ -50,17 +50,17 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "inputstr.h" /* DeviceIntPtr */
#include "dix/dix_priv.h" #include "windowstr.h" /* window struct */
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window struct */
#include "exglobals.h" #include "exglobals.h"
#include "swaprep.h" #include "swaprep.h"
#include "getprop.h" #include "getprop.h"
#include "getselev.h" #include "getselev.h"
@ -70,12 +70,15 @@ SOFTWARE.
* *
*/ */
int _X_COLD int
SProcXGetSelectedExtensionEvents(ClientPtr client) SProcXGetSelectedExtensionEvents(ClientPtr client)
{ {
char n;
REQUEST(xGetSelectedExtensionEventsReq); REQUEST(xGetSelectedExtensionEventsReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq); REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
swapl(&stuff->window); swapl(&stuff->window, n);
return (ProcXGetSelectedExtensionEvents(client)); return (ProcXGetSelectedExtensionEvents(client));
} }
@ -101,56 +104,54 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
REQUEST(xGetSelectedExtensionEventsReq); REQUEST(xGetSelectedExtensionEventsReq);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq); REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
rep = (xGetSelectedExtensionEventsReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GetSelectedExtensionEvents;
.RepType = X_GetSelectedExtensionEvents, rep.length = 0;
.sequenceNumber = client->sequence, rep.sequenceNumber = client->sequence;
.length = 0, rep.this_client_count = 0;
.this_client_count = 0, rep.all_clients_count = 0;
.all_clients_count = 0
};
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if ((pOthers = wOtherInputMasks(pWin)) != 0) { if ((pOthers = wOtherInputMasks(pWin)) != 0) {
for (others = pOthers->inputClients; others; others = others->next) for (others = pOthers->inputClients; others; others = others->next)
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
ClassFromMask(NULL, others->mask[i], i, ClassFromMask(NULL, others->mask[i], i,
&rep.all_clients_count, COUNT); &rep.all_clients_count, COUNT);
for (others = pOthers->inputClients; others; others = others->next) for (others = pOthers->inputClients; others; others = others->next)
if (SameClient(others, client)) { if (SameClient(others, client)) {
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
ClassFromMask(NULL, others->mask[i], i, ClassFromMask(NULL, others->mask[i], i,
&rep.this_client_count, COUNT); &rep.this_client_count, COUNT);
break; break;
} }
total_length = (rep.all_clients_count + rep.this_client_count) * total_length = (rep.all_clients_count + rep.this_client_count) *
sizeof(XEventClass); sizeof(XEventClass);
rep.length = bytes_to_int32(total_length); rep.length = bytes_to_int32(total_length);
buf = (XEventClass *) malloc(total_length); buf = (XEventClass *) malloc(total_length);
tclient = buf; tclient = buf;
aclient = buf + rep.this_client_count; aclient = buf + rep.this_client_count;
if (others) if (others)
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
tclient = tclient =
ClassFromMask(tclient, others->mask[i], i, NULL, CREATE); ClassFromMask(tclient, others->mask[i], i, NULL, CREATE);
for (others = pOthers->inputClients; others; others = others->next) for (others = pOthers->inputClients; others; others = others->next)
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
aclient = aclient =
ClassFromMask(aclient, others->mask[i], i, NULL, CREATE); ClassFromMask(aclient, others->mask[i], i, NULL, CREATE);
} }
WriteReplyToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep); WriteReplyToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep);
if (total_length) { if (total_length) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, total_length, buf); WriteSwappedDataToClient(client, total_length, buf);
} }
free(buf); free(buf);
return Success; return Success;
@ -163,13 +164,15 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXGetSelectedExtensionEvents(ClientPtr client, int size, SRepXGetSelectedExtensionEvents(ClientPtr client, int size,
xGetSelectedExtensionEventsReply * rep) xGetSelectedExtensionEventsReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
swaps(&rep->this_client_count); swaps(&rep->sequenceNumber, n);
swaps(&rep->all_clients_count); swapl(&rep->length, n);
WriteToClient(client, size, rep); swaps(&rep->this_client_count, n);
swaps(&rep->all_clients_count, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,15 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETSELEV_H #ifndef GETSELEV_H
#define GETSELEV_H 1 #define GETSELEV_H 1
int SProcXGetSelectedExtensionEvents(ClientPtr /* client */ int SProcXGetSelectedExtensionEvents(ClientPtr /* client */
); );
int ProcXGetSelectedExtensionEvents(ClientPtr /* client */ int ProcXGetSelectedExtensionEvents(ClientPtr /* client */
); );
void SRepXGetSelectedExtensionEvents(ClientPtr /* client */ , void SRepXGetSelectedExtensionEvents(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetSelectedExtensionEventsReply * /* rep */ xGetSelectedExtensionEventsReply * /* rep */
); );
#endif /* GETSELEV_H */ #endif /* GETSELEV_H */

View file

@ -50,9 +50,11 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exevents.h" #include "exevents.h"
@ -68,12 +70,15 @@ XExtensionVersion XIVersion;
* *
*/ */
int _X_COLD int
SProcXGetExtensionVersion(ClientPtr client) SProcXGetExtensionVersion(ClientPtr client)
{ {
char n;
REQUEST(xGetExtensionVersionReq); REQUEST(xGetExtensionVersionReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq); REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
swaps(&stuff->nbytes); swaps(&stuff->nbytes, n);
return (ProcXGetExtensionVersion(client)); return (ProcXGetExtensionVersion(client));
} }
@ -91,19 +96,18 @@ ProcXGetExtensionVersion(ClientPtr client)
REQUEST(xGetExtensionVersionReq); REQUEST(xGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq); REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
if (client->req_len != bytes_to_int32(sizeof(xGetExtensionVersionReq) + if (stuff->length != bytes_to_int32(sizeof(xGetExtensionVersionReq) +
stuff->nbytes)) stuff->nbytes))
return BadLength; return BadLength;
rep = (xGetExtensionVersionReply) { memset(&rep, 0, sizeof(xGetExtensionVersionReply));
.repType = X_Reply, rep.repType = X_Reply;
.RepType = X_GetExtensionVersion, rep.RepType = X_GetExtensionVersion;
.sequenceNumber = client->sequence, rep.length = 0;
.length = 0, rep.sequenceNumber = client->sequence;
.major_version = XIVersion.major_version, rep.present = TRUE;
.minor_version = XIVersion.minor_version, rep.major_version = XIVersion.major_version;
.present = TRUE rep.minor_version = XIVersion.minor_version;
};
WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep); WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep);
@ -117,13 +121,15 @@ ProcXGetExtensionVersion(ClientPtr client)
* *
*/ */
void _X_COLD void
SRepXGetExtensionVersion(ClientPtr client, int size, SRepXGetExtensionVersion(ClientPtr client, int size,
xGetExtensionVersionReply * rep) xGetExtensionVersionReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
swaps(&rep->major_version); swaps(&rep->sequenceNumber, n);
swaps(&rep->minor_version); swapl(&rep->length, n);
WriteToClient(client, size, rep); swaps(&rep->major_version, n);
swaps(&rep->minor_version, n);
WriteToClient(client, size, (char *)rep);
} }

View file

@ -30,15 +30,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETVERS_H #ifndef GETVERS_H
#define GETVERS_H 1 #define GETVERS_H 1
int SProcXGetExtensionVersion(ClientPtr /* client */ int SProcXGetExtensionVersion(ClientPtr /* client */
); );
int ProcXGetExtensionVersion(ClientPtr /* client */ int ProcXGetExtensionVersion(ClientPtr /* client */
); );
void SRepXGetExtensionVersion(ClientPtr /* client */ , void SRepXGetExtensionVersion(ClientPtr /* client */ ,
int /* size */ , int /* size */ ,
xGetExtensionVersionReply * /* rep */ xGetExtensionVersionReply * /* rep */
); );
#endif /* GETVERS_H */ #endif /* GETVERS_H */

View file

@ -50,14 +50,16 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */ #include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "dixevents.h" /* GrabDevice */ #include "dixevents.h" /* GrabDevice */
#include "grabdev.h" #include "grabdev.h"
@ -70,20 +72,21 @@ extern int ExtEventIndex;
* *
*/ */
int _X_COLD int
SProcXGrabDevice(ClientPtr client) SProcXGrabDevice(ClientPtr client)
{ {
char n;
REQUEST(xGrabDeviceReq); REQUEST(xGrabDeviceReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
swapl(&stuff->grabWindow, n);
swapl(&stuff->time, n);
swaps(&stuff->event_count, n);
swapl(&stuff->grabWindow); if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
swapl(&stuff->time); return BadLength;
swaps(&stuff->event_count);
if (client->req_len !=
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
return (ProcXGrabDevice(client)); return (ProcXGrabDevice(client));
@ -107,35 +110,33 @@ ProcXGrabDevice(ClientPtr client)
REQUEST(xGrabDeviceReq); REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
if (client->req_len != if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) return BadLength;
return BadLength;
rep = (xGrabDeviceReply) { rep.repType = X_Reply;
.repType = X_Reply, rep.RepType = X_GrabDevice;
.RepType = X_GrabDevice, rep.sequenceNumber = client->sequence;
.sequenceNumber = client->sequence, rep.length = 0;
.length = 0,
};
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if ((rc = CreateMaskFromList(client, (XEventClass *) &stuff[1], if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->event_count, tmp, dev, stuff->event_count, tmp, dev,
X_GrabDevice)) != Success) X_GrabDevice)) != Success)
return rc; return rc;
mask.xi = tmp[stuff->deviceid].mask; mask.xi = tmp[stuff->deviceid].mask;
rc = GrabDevice(client, dev, stuff->other_devices_mode, rc = GrabDevice(client, dev, stuff->other_devices_mode,
stuff->this_device_mode, stuff->grabWindow, stuff->this_device_mode, stuff->grabWindow,
stuff->ownerEvents, stuff->time, stuff->ownerEvents, stuff->time,
&mask, XI, None, None, &rep.status); &mask, GRABTYPE_XI, None, None,
&rep.status);
if (rc != Success) if (rc != Success)
return rc; return rc;
WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep); WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
return Success; return Success;
@ -151,7 +152,7 @@ ProcXGrabDevice(ClientPtr client)
* set when XI starts up) and binary OR's the device's mask to whatever the * set when XI starts up) and binary OR's the device's mask to whatever the
* event mask for the given event type was. * event mask for the given event type was.
* If an error occurs, it is sent to the client. Errors are generated if * If an error occurs, it is sent to the client. Errors are generated if
* - if the device given in the event class is invalid * - if the device given in the event classs is invalid
* - if the device in the class list is not the device given as parameter (no * - if the device in the class list is not the device given as parameter (no
* error if parameter is NULL) * error if parameter is NULL)
* *
@ -167,31 +168,34 @@ ProcXGrabDevice(ClientPtr client)
int int
CreateMaskFromList(ClientPtr client, XEventClass * list, int count, CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
struct tmask *mask, DeviceIntPtr dev, int req) struct tmask *mask, DeviceIntPtr dev, int req)
{ {
int rc, i, j; int rc, i, j;
int device; int device;
DeviceIntPtr tdev; DeviceIntPtr tdev;
memset(mask, 0, EMASKSIZE * sizeof(struct tmask)); for (i = 0; i < EMASKSIZE; i++) {
mask[i].mask = 0;
mask[i].dev = NULL;
}
for (i = 0; i < count; i++, list++) { for (i = 0; i < count; i++, list++) {
device = *list >> 8; device = *list >> 8;
if (device > 255) if (device > 255)
return BadClass; return BadClass;
rc = dixLookupDevice(&tdev, device, client, DixUseAccess); rc = dixLookupDevice(&tdev, device, client, DixUseAccess);
if (rc != BadDevice && rc != Success) if (rc != BadDevice && rc != Success)
return rc; return rc;
if (rc == BadDevice || (dev != NULL && tdev != dev)) if (rc == BadDevice || (dev != NULL && tdev != dev))
return BadClass; return BadClass;
for (j = 0; j < ExtEventIndex; j++) for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].type == (*list & 0xff)) { if (EventInfo[j].type == (*list & 0xff)) {
mask[device].mask |= EventInfo[j].mask; mask[device].mask |= EventInfo[j].mask;
mask[device].dev = (void *) tdev; mask[device].dev = (Pointer) tdev;
break; break;
} }
} }
return Success; return Success;
} }
@ -203,10 +207,12 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
* *
*/ */
void _X_COLD void
SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep) SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep)
{ {
swaps(&rep->sequenceNumber); char n;
swapl(&rep->length);
WriteToClient(client, size, rep); swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
} }

Some files were not shown because too many files have changed in this diff Show more