103 Commits

Author SHA1 Message Date
pelya
95e445912d Compilation fixes for Xsdl 2012-04-24 15:12:24 +03:00
pelya
e6cef9e7aa Added back SDL backend, did not try to compile it yet 2012-04-24 15:12:24 +03:00
Michal Suchanek
240cd0675b Avoid crash on button events on device without valuators.
Backport of 2416ee4a01.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-17 09:55:07 +10:00
Jeremy Huddleston
db9620c022 XQuartz: Fix the filename of our log file
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit fb55f8f790)
2012-03-13 00:08:08 -07:00
Jeremy Huddleston
42234f3cdb XQuartz: Short-circuit activateX:
This also avoids a deadlock when calling activateX: before the server
thread has initialized

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit cb6a32da27)
2012-02-24 11:33:24 -08:00
Jeremy Huddleston
53069ffd86 XQuartz: Actually install the new locales
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 1562c4a1ca)
2012-02-24 11:33:14 -08:00
Jeremy Huddleston
4b75e41221 XQuartz: Build fix for possible conflict of BOOL type
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit d53235af85)
2012-02-19 14:58:28 -08:00
Jeremy Huddleston
fb6c043833 XQuartz: Release all buttons and keys when deactivating
http://xquartz.macosforge.org/trac/ticket/486

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 85cecd9811)
2012-02-19 14:58:14 -08:00
Jeremy Huddleston
9138bbabcd XQuartz: Toggle off fullscreen mode when XQuartz is hidden
http://xquartz.macosforge.org/trac/ticket/478

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 47b457541b)
2012-02-19 14:58:07 -08:00
Jeremy Huddleston
fdca9c4d49 XQuartz: Localization Updates
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit c2ba3f339f)
2012-02-19 14:57:59 -08:00
Alan Coopersmith
7773e74660 Assign ids to more tags in Xserver-Dtrace.xml
Keeps xsltproc from adding random-number id tags to html output so that
it's easier to see real changes vs. different random numbers.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Dew <marcoz@osource.org>
(cherry picked from commit 58d3d46d6c)
2012-02-10 15:51:35 -08:00
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
1770 changed files with 321008 additions and 315475 deletions

View File

@@ -1,33 +0,0 @@
branches:
except:
- /travis.*/
version: '{build}'
skip_tags: true
clone_depth: 8
environment:
CYGWIN_MIRROR: http://cygwin.mirror.constant.com
CACHE: C:\cache
matrix:
- BUILD: i686-pc-cygwin
- BUILD: x86_64-pc-cygwin
install:
- if "%BUILD%"=="x86_64-pc-cygwin" set SETUP=setup-x86_64.exe && set CYGWIN_ROOT=C:\cygwin64
- if "%BUILD%"=="i686-pc-cygwin" set SETUP=setup-x86.exe && set CYGWIN_ROOT=C:\cygwin
- curl -fsSL https://gist.githubusercontent.com/jon-turney/0338af595313f598bfab15a0ac0df847/raw/bd0eeca6be899e7846aa988fbcf15e4e12f5f842/zp_libtool_cleanlafiles.sh -o %CYGWIN_ROOT%\etc\postinstall\zp_libtool_cleanlafiles.sh
- echo Updating Cygwin and installing build prerequisites
- '%CYGWIN_ROOT%\%SETUP% -qnNdO -R "%CYGWIN_ROOT%" -s "%CYGWIN_MIRROR%" -l "%CACHE%" -g -P "meson,binutils,bison,bzip2,diffutils,fileutils,findutils,flex,gawk,gcc-core,make,patch,pkg-config,python3,sed,tar,xorgproto,windowsdriproto,libdmx-devel,libfontenc-devel,libfreetype-devel,libGL-devel,libpixman1-devel,libX11-devel,libXRes-devel,libXau-devel,libXaw-devel,libXdmcp-devel,libXext-devel,libXfont2-devel,libXi-devel,libXinerama-devel,libXmu-devel,libXpm-devel,libXrender-devel,libXtst-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,libxkbfile-devel,zlib,font-util,khronos-opengl-registry,python3-lxml,xorg-util-macros,xtrans,xkbcomp,xkeyboard-config,libnettle-devel,libepoxy-devel,libtirpc-devel"'
- echo Install done
cache:
- C:\cache
build_script:
- SET PATH=%CYGWIN_ROOT%/bin
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; meson setup --prefix=/usr -Dxv=false -Dxf86bigfont=true -Ddmx=true -Dxephyr=true -Dxnest=true -Dxvfb=true -Dxwin=true -Dxorg=true -Dhal=false -Dudev=false -Dpciaccess=false -Dint10=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"'
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"'
artifacts:
- path: staging
deploy: off

View File

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

1
.gitignore vendored
View File

@@ -41,7 +41,6 @@ mkinstalldirs
py-compile
stamp-h?
symlink-tree
test-driver
texinfo.tex
ylwrap

View File

@@ -1,13 +0,0 @@
image: docker:latest
services:
- docker:dind
before_script:
- echo FROM nwnk/xserver-travis-rawhide:v5 > Dockerfile
- echo ADD . /root >> Dockerfile
- echo WORKDIR /root >> Dockerfile
- docker build -t withgit .
job:
script:
- docker run --volume $HOME/.ccache:/root/.ccache withgit ./test/scripts/build-travis-deps.sh

View File

@@ -1,29 +0,0 @@
language: c
cache: ccache
branches:
except:
- /appveyor.*/
matrix:
include:
- os: linux
dist: trusty
services: docker
env: DISTRO=rawhide:v5
- os: osx
osx_image: xcode9.2
env: DISTRO=xcode9.2
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache ; fi
before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull nwnk/xserver-travis-$DISTRO ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo FROM nwnk/xserver-travis-$DISTRO > Dockerfile ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo ADD . /root >> Dockerfile ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build -t withgit . ; fi
script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run --volume $HOME/.ccache:/root/.ccache withgit /bin/sh -c "cd /root && ./test/scripts/build-travis-deps.sh" ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./test/scripts/build-travis-osx.sh ; fi
- ccache -s

48
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
Chroboczek sorts before Intel Corporation sorts before Daniel Stone).
Copyright © 2011 Dave Airlie
Copyright © 2000-2001 Juliusz Chroboczek
Copyright © 1998 Egbert Eich
Copyright © 2006-2007 Intel Corporation
@@ -21,7 +20,6 @@ Copyright © 1999 Keith Packard
Copyright © 2007-2009 Red Hat, Inc.
Copyright © 2005-2008 Daniel Stone
Copyright © 2006-2009 Simon Thum
Copyright © 2003-2008, 2013 Geert Uytterhoeven
Copyright © 2006 Luc Verhaegen
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.
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 © 2007 Red Hat, Inc.
@@ -1258,6 +1233,27 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Copyright © 2004 PillowElephantBadgerBankPond
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of PillowElephantBadgerBankPond not be used in
advertising or publicity pertaining to distribution of the software without
specific, written prior permission. PillowElephantBadgerBankPond makes no
representations about the suitability of this software for any purpose. It
is provided "as is" without express or implied warranty.
PillowElephantBadgerBankPond DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL PillowElephantBadgerBankPond BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
Permission to use, copy, modify, and distribute this software for any
@@ -1813,7 +1809,7 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
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.
This code is derived from software contributed to Berkeley by

View File

@@ -1,6 +1,4 @@
AUTOMAKE_OPTIONS=nostdinc
# Required for automake < 1.14
ACLOCAL_AMFLAGS = -I m4
if COMPOSITE
@@ -19,22 +17,6 @@ if RECORD
RECORD_DIR=record
endif
if DRI3
DRI3_DIR=dri3
endif
if PRESENT
PRESENT_DIR=present
endif
if PSEUDORAMIX
PSEUDORAMIX_DIR=pseudoramiX
endif
if GLAMOR
GLAMOR_DIR=glamor
endif
SUBDIRS = \
doc \
man \
@@ -49,17 +31,13 @@ SUBDIRS = \
render \
Xi \
xkb \
$(PSEUDORAMIX_DIR) \
$(DBE_DIR) \
$(RECORD_DIR) \
xfixes \
damageext \
$(COMPOSITE_DIR) \
$(GLX_DIR) \
$(PRESENT_DIR) \
$(DRI3_DIR) \
exa \
$(GLAMOR_DIR) \
config \
hw \
test
@@ -99,7 +77,6 @@ DIST_SUBDIRS = \
Xext \
miext \
os \
pseudoramiX \
randr \
render \
Xi \
@@ -111,105 +88,10 @@ DIST_SUBDIRS = \
composite \
glx \
exa \
glamor \
config \
dri3 \
present \
hw \
test
# gross hack
relink: all
$(AM_V_at)$(MAKE) -C hw relink
install-headers: Makefile
+find . -name Makefile | while read m; do \
if grep -q install-sdkHEADERS $$m; then \
(cd `dirname "$$m"` && make install-sdkHEADERS) \
fi \
done
distcheck-hook:
cd $(srcdir) && \
meson setup _distcheck_build && \
meson configure _distcheck_build && \
ninja -C _distcheck_build && \
rm -rf _distcheck_build && \
cd -
EXTRA_DIST += \
meson_options.txt \
include/xorg-config.h.meson.in \
include/xwin-config.h.meson.in \
hw/xfree86/loader/symbol-test.c \
hw/xfree86/common/xf86Build.sh \
composite/meson.build \
config/meson.build \
damageext/meson.build \
dbe/meson.build \
dix/meson.build \
dri3/meson.build \
exa/meson.build \
fb/meson.build \
glamor/meson.build \
glx/meson.build \
hw/dmx/config/meson.build \
hw/dmx/examples/meson.build \
hw/dmx/glxProxy/meson.build \
hw/dmx/input/meson.build \
hw/dmx/meson.build \
hw/kdrive/ephyr/meson.build \
hw/kdrive/meson.build \
hw/kdrive/src/meson.build \
hw/meson.build \
hw/vfb/meson.build \
hw/xfree86/common/meson.build \
hw/xfree86/ddc/meson.build \
hw/xfree86/dixmods/meson.build \
hw/xfree86/dri2/meson.build \
hw/xfree86/dri/meson.build \
hw/xfree86/drivers/modesetting/meson.build \
hw/xfree86/exa/meson.build \
hw/xfree86/fbdevhw/meson.build \
hw/xfree86/glamor_egl/meson.build \
hw/xfree86/i2c/meson.build \
hw/xfree86/int10/meson.build \
hw/xfree86/loader/meson.build \
hw/xfree86/meson.build \
hw/xfree86/modes/meson.build \
hw/xfree86/os-support/meson.build \
hw/xfree86/parser/meson.build \
hw/xfree86/ramdac/meson.build \
hw/xfree86/shadowfb/meson.build \
hw/xfree86/vbe/meson.build \
hw/xfree86/vgahw/meson.build \
hw/xfree86/x86emu/meson.build \
hw/xfree86/xkb/meson.build \
hw/xnest/meson.build \
hw/xquartz/meson.build \
hw/xwayland/meson.build \
hw/xwin/dri/meson.build \
hw/xwin/glx/meson.build \
hw/xwin/meson.build \
hw/xwin/winclipboard/meson.build \
include/meson.build \
meson.build \
miext/damage/meson.build \
miext/shadow/meson.build \
miext/sync/meson.build \
mi/meson.build \
os/meson.build \
present/meson.build \
pseudoramiX/meson.build \
randr/meson.build \
record/meson.build \
render/meson.build \
test/bigreq/meson.build \
test/bigreq/request-length.c \
test/meson.build \
test/sync/meson.build \
test/sync/sync.c \
Xext/meson.build \
xfixes/meson.build \
Xi/meson.build \
xkb/meson.build

16
README
View File

@@ -11,12 +11,12 @@ 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
http://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
http://lists.freedesktop.org/mailman/listinfo/xorg
Please submit bug reports to the Xorg bugzilla:
@@ -26,19 +26,13 @@ The master development code repository can be found at:
git://anongit.freedesktop.org/git/xorg/xserver
https://cgit.freedesktop.org/xorg/xserver
http://cgit.freedesktop.org/xorg/xserver
For patch submission instructions, see:
https://www.x.org/wiki/Development/Documentation/SubmittingPatches
http://www.x.org/wiki/Development/Documentation/SubmittingPatches
For more information on the git code manager, see:
https://wiki.x.org/wiki/GitPage
http://wiki.x.org/wiki/GitPage
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,4 +1,16 @@
noinst_LTLIBRARIES = libXext.la libXvidmode.la
# 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)
@@ -6,7 +18,7 @@ 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
# Sources always included in libXextbuiltin.la & libXext.la
BUILTIN_SRCS = \
bigreq.c \
geext.c \
@@ -18,7 +30,10 @@ BUILTIN_SRCS = \
syncsrv.h \
xcmisc.c \
xtest.c
BUILTIN_LIBS =
# 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
@@ -31,19 +46,19 @@ endif
# XVideo extension
XV_SRCS = xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h
if XV
BUILTIN_SRCS += $(XV_SRCS)
MODULE_SRCS += $(XV_SRCS)
endif
# XResource extension: lets clients get data about per-client resource usage
RES_SRCS = hashtable.c hashtable.h xres.c
RES_SRCS = xres.c
if RES
BUILTIN_SRCS += $(RES_SRCS)
MODULE_SRCS += $(RES_SRCS)
endif
# MIT ScreenSaver extension
SCREENSAVER_SRCS = saver.c
if SCREENSAVER
BUILTIN_SRCS += $(SCREENSAVER_SRCS)
MODULE_SRCS += $(SCREENSAVER_SRCS)
endif
# Xinerama extension: making multiple video devices act as one virtual screen
@@ -69,8 +84,8 @@ endif
# requires X-ACE extension
XSELINUX_SRCS = xselinux_ext.c xselinux_hooks.c xselinux_label.c xselinux.h xselinuxint.h
if XSELINUX
BUILTIN_SRCS += $(XSELINUX_SRCS)
BUILTIN_LIBS += $(SELINUX_LIBS)
MODULE_SRCS += $(XSELINUX_SRCS)
MODULE_LIBS += $(SELINUX_LIBS)
endif
# Security extension: multi-level security to protect clients from each other
@@ -88,16 +103,20 @@ endif
# DPMS extension
DPMS_SRCS = dpms.c dpmsproc.h
if DPMSExtension
BUILTIN_SRCS += $(DPMS_SRCS)
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)
libXext_la_LIBADD = $(BUILTIN_LIBS)
libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS)
libXext_la_LIBADD = $(MODULE_LIBS)
# XVidMode extension
libXvidmode_la_SOURCES = vidmode.c
if XORG
libXextbuiltin_la_SOURCES = $(BUILTIN_SRCS)
libXextmodule_la_SOURCES = $(MODULE_SRCS)
libXextmodule_la_LIBADD = $(MODULE_LIBS)
endif
EXTRA_DIST = \
$(MITSHM_SRCS) \

View File

@@ -38,37 +38,39 @@ from The Open Group.
#include "extnsionst.h"
#include <X11/extensions/bigreqsproto.h>
#include "opaque.h"
#include "extinit.h"
#include "modinit.h"
void BigReqExtensionInit(INITARGS);
static int
ProcBigReqDispatch (ClientPtr client)
{
REQUEST(xBigReqEnableReq);
xBigReqEnableReply rep;
int n;
if (client->swapped) {
swaps(&stuff->length);
swaps(&stuff->length, n);
}
if (stuff->brReqType != X_BigReqEnable)
return BadRequest;
REQUEST_SIZE_MATCH(xBigReqEnableReq);
client->big_requests = TRUE;
rep = (xBigReqEnableReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.max_request_size = maxBigRequestSize
};
memset(&rep, 0, sizeof(xBigReqEnableReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.max_request_size = maxBigRequestSize;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.max_request_size);
swaps(&rep.sequenceNumber, n);
swapl(&rep.max_request_size, n);
}
WriteToClient(client, sizeof(xBigReqEnableReply), &rep);
WriteToClient(client, sizeof(xBigReqEnableReply), (char *)&rep);
return Success;
}
void
BigReqExtensionInit(void)
BigReqExtensionInit(INITARGS)
{
AddExtension(XBigReqExtensionName, 0, 0,
ProcBigReqDispatch, ProcBigReqDispatch,

View File

@@ -39,99 +39,28 @@ Equipment Corporation.
#include "opaque.h"
#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h"
#include "extinit.h"
#include "scrnintstr.h"
#include "windowstr.h"
CARD16 DPMSPowerLevel = 0;
Bool DPMSDisabledSwitch = FALSE;
CARD32 DPMSStandbyTime = -1;
CARD32 DPMSSuspendTime = -1;
CARD32 DPMSOffTime = -1;
Bool DPMSEnabled;
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;
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);
return Success;
}
#include "modinit.h"
static int
ProcDPMSGetVersion(ClientPtr client)
{
/* REQUEST(xDPMSGetVersionReq); */
xDPMSGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = DPMSMajorVersion,
.minorVersion = DPMSMinorVersion
};
xDPMSGetVersionReply rep;
int n;
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = DPMSMajorVersion;
rep.minorVersion = DPMSMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swaps(&rep.sequenceNumber, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xDPMSGetVersionReply), &rep);
WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *)&rep);
return Success;
}
@@ -139,19 +68,20 @@ static int
ProcDPMSCapable(ClientPtr client)
{
/* REQUEST(xDPMSCapableReq); */
xDPMSCapableReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.capable = TRUE
};
xDPMSCapableReply rep;
int n;
REQUEST_SIZE_MATCH(xDPMSCapableReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.capable = DPMSCapableFlag;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.sequenceNumber, n);
}
WriteToClient(client, sizeof(xDPMSCapableReply), &rep);
WriteToClient(client, sizeof(xDPMSCapableReply), (char *)&rep);
return Success;
}
@@ -159,24 +89,25 @@ static int
ProcDPMSGetTimeouts(ClientPtr client)
{
/* REQUEST(xDPMSGetTimeoutsReq); */
xDPMSGetTimeoutsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.standby = DPMSStandbyTime / MILLI_PER_SECOND,
.suspend = DPMSSuspendTime / MILLI_PER_SECOND,
.off = DPMSOffTime / MILLI_PER_SECOND
};
xDPMSGetTimeoutsReply rep;
int n;
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) {
swaps(&rep.sequenceNumber);
swaps(&rep.standby);
swaps(&rep.suspend);
swaps(&rep.off);
swaps(&rep.sequenceNumber, n);
swaps(&rep.standby, n);
swaps(&rep.suspend, n);
swaps(&rep.off, n);
}
WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), &rep);
WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *)&rep);
return Success;
}
@@ -187,11 +118,13 @@ ProcDPMSSetTimeouts(ClientPtr client)
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;
}
if ((stuff->suspend != 0) && (stuff->suspend < stuff->standby)) {
if ((stuff->suspend != 0)&&(stuff->suspend < stuff->standby))
{
client->errorValue = stuff->suspend;
return BadValue;
}
@@ -211,9 +144,11 @@ ProcDPMSEnable(ClientPtr client)
REQUEST_SIZE_MATCH(xDPMSEnableReq);
if (DPMSCapableFlag) {
DPMSEnabled = TRUE;
if (!was_enabled)
SetScreenSaverTimer();
}
return Success;
}
@@ -244,7 +179,8 @@ ProcDPMSForceLevel(ClientPtr client)
if (stuff->level != DPMSModeOn &&
stuff->level != DPMSModeStandby &&
stuff->level != DPMSModeSuspend && stuff->level != DPMSModeOff) {
stuff->level != DPMSModeSuspend &&
stuff->level != DPMSModeOff) {
client->errorValue = stuff->level;
return BadValue;
}
@@ -258,21 +194,22 @@ static int
ProcDPMSInfo(ClientPtr client)
{
/* REQUEST(xDPMSInfoReq); */
xDPMSInfoReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.power_level = DPMSPowerLevel,
.state = DPMSEnabled
};
xDPMSInfoReply rep;
int n;
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) {
swaps(&rep.sequenceNumber);
swaps(&rep.power_level);
swaps(&rep.sequenceNumber, n);
swaps(&rep.power_level, n);
}
WriteToClient(client, sizeof(xDPMSInfoReply), &rep);
WriteToClient(client, sizeof(xDPMSInfoReply), (char *)&rep);
return Success;
}
@@ -281,7 +218,8 @@ ProcDPMSDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_DPMSGetVersion:
return ProcDPMSGetVersion(client);
case X_DPMSCapable:
@@ -303,105 +241,114 @@ ProcDPMSDispatch(ClientPtr client)
}
}
static int _X_COLD
static int
SProcDPMSGetVersion(ClientPtr client)
{
int n;
REQUEST(xDPMSGetVersionReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion, n);
return ProcDPMSGetVersion(client);
}
static int _X_COLD
static int
SProcDPMSCapable(ClientPtr client)
{
REQUEST(xDPMSCapableReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSCapableReq);
return ProcDPMSCapable(client);
}
static int _X_COLD
static int
SProcDPMSGetTimeouts(ClientPtr client)
{
REQUEST(xDPMSGetTimeoutsReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
return ProcDPMSGetTimeouts(client);
}
static int _X_COLD
static int
SProcDPMSSetTimeouts(ClientPtr client)
{
REQUEST(xDPMSSetTimeoutsReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
swaps(&stuff->standby);
swaps(&stuff->suspend);
swaps(&stuff->off);
swaps(&stuff->standby, n);
swaps(&stuff->suspend, n);
swaps(&stuff->off, n);
return ProcDPMSSetTimeouts(client);
}
static int _X_COLD
static int
SProcDPMSEnable(ClientPtr client)
{
REQUEST(xDPMSEnableReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSEnableReq);
return ProcDPMSEnable(client);
}
static int _X_COLD
static int
SProcDPMSDisable(ClientPtr client)
{
REQUEST(xDPMSDisableReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSDisableReq);
return ProcDPMSDisable(client);
}
static int _X_COLD
static int
SProcDPMSForceLevel(ClientPtr client)
{
REQUEST(xDPMSForceLevelReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
swaps(&stuff->level);
swaps(&stuff->level, n);
return ProcDPMSForceLevel(client);
}
static int _X_COLD
static int
SProcDPMSInfo(ClientPtr client)
{
REQUEST(xDPMSInfoReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDPMSInfoReq);
return ProcDPMSInfo(client);
}
static int _X_COLD
static int
SProcDPMSDispatch (ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_DPMSGetVersion:
return SProcDPMSGetVersion(client);
case X_DPMSCapable:
@@ -423,29 +370,10 @@ SProcDPMSDispatch(ClientPtr client)
}
}
static void
DPMSCloseDownExtension(ExtensionEntry *e)
{
DPMSSet(serverClient, DPMSModeOn);
}
void
DPMSExtensionInit(void)
DPMSExtensionInit(INITARGS)
{
#define CONDITIONALLY_SET_DPMS_TIMEOUT(_timeout_value_) \
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();
if (DPMSEnabled)
AddExtension(DPMSExtensionName, 0, 0,
ProcDPMSDispatch, SProcDPMSDispatch,
DPMSCloseDownExtension, StandardMinorOpcode);
NULL, StandardMinorOpcode);
}

View File

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

@@ -32,10 +32,11 @@
#include "geint.h"
#include "geext.h"
#include "protocol-versions.h"
#include "extinit.h"
DevPrivateKeyRec GEClientPrivateKeyRec;
int RT_GECLIENT = 0;
GEExtension GEExtensions[MAXEXTENSIONS];
/* Major available requests */
@@ -47,6 +48,7 @@ static const int version_requests[] = {
/* Forward declarations */
static void SGEGenericEvent(xEvent* from, xEvent* to);
#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
#define EXT_MASK(ext) ((ext) & 0x7F)
/************************************************************/
@@ -56,64 +58,65 @@ static void SGEGenericEvent(xEvent *from, xEvent *to);
static int
ProcGEQueryVersion(ClientPtr client)
{
int n;
GEClientInfoPtr pGEClient = GEGetClient(client);
xGEQueryVersionReply rep;
REQUEST(xGEQueryVersionReq);
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
rep = (xGEQueryVersionReply) {
.repType = X_Reply,
.RepType = X_GEQueryVersion,
.sequenceNumber = client->sequence,
.length = 0,
rep.repType = X_Reply;
rep.RepType = X_GEQueryVersion;
rep.length = 0;
rep.sequenceNumber = client->sequence;
/* return the supported version by the server */
.majorVersion = SERVER_GE_MAJOR_VERSION,
.minorVersion = SERVER_GE_MINOR_VERSION
};
rep.majorVersion = SERVER_GE_MAJOR_VERSION;
rep.minorVersion = SERVER_GE_MINOR_VERSION;
/* Remember version the client requested */
pGEClient->major_version = stuff->majorVersion;
pGEClient->minor_version = stuff->minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
if (client->swapped)
{
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xGEQueryVersionReply), &rep);
WriteToClient(client, sizeof(xGEQueryVersionReply), (char*)&rep);
return Success;
}
static int (*ProcGEVector[GENumberRequests]) (ClientPtr) = {
int (*ProcGEVector[GENumberRequests])(ClientPtr) = {
/* Version 1.0 */
ProcGEQueryVersion,
ProcGEQueryVersion
};
/************************************************************/
/* swapped request handlers */
/************************************************************/
static int _X_COLD
static int
SProcGEQueryVersion(ClientPtr client)
{
int n;
REQUEST(xGEQueryVersionReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion, n);
return(*ProcGEVector[stuff->ReqType])(client);
}
static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = {
int (*SProcGEVector[GENumberRequests])(ClientPtr) = {
/* Version 1.0 */
SProcGEQueryVersion
};
/************************************************************/
/* callbacks */
/************************************************************/
@@ -123,10 +126,9 @@ static int
ProcGEDispatch(ClientPtr client)
{
GEClientInfoPtr pGEClient = GEGetClient(client);
REQUEST(xGEReq);
if (pGEClient->major_version >= ARRAY_SIZE(version_requests))
if (pGEClient->major_version >= NUM_VERSION_REQUESTS)
return BadRequest;
if (stuff->ReqType > version_requests[pGEClient->major_version])
return BadRequest;
@@ -135,7 +137,7 @@ ProcGEDispatch(ClientPtr client)
}
/* dispatch swapped requests */
static int _X_COLD
static int
SProcGEDispatch(ClientPtr client)
{
REQUEST(xGEReq);
@@ -144,10 +146,30 @@ SProcGEDispatch(ClientPtr client)
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. */
static void
GEResetProc(ExtensionEntry *extEntry)
{
DeleteCallback(&ClientStateCallback, GEClientCallback, 0);
EventSwapVector[GenericEvent] = NotImplemented;
}
@@ -158,13 +180,14 @@ GEResetProc(ExtensionEntry * extEntry)
* written on the wire, this one calls the registered swap function to do the
* work.
*/
static void _X_COLD
static void
SGEGenericEvent(xEvent* from, xEvent* to)
{
xGenericEvent* gefrom = (xGenericEvent*)from;
xGenericEvent* geto = (xGenericEvent*)to;
if ((gefrom->extension & 0x7f) > MAXEXTENSIONS) {
if ((gefrom->extension & 0x7f) > MAXEXTENSIONS)
{
ErrorF("GE: Invalid extension offset for event.\n");
return;
}
@@ -182,19 +205,23 @@ GEExtensionInit(void)
{
ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey
(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
if (!dixRegisterPrivateKey(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n");
if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))
{
FatalError("GEExtensionInit: register client callback failed.\n");
}
if((extEntry = AddExtension(GE_NAME,
0, GENumberErrors,
ProcGEDispatch, SProcGEDispatch,
GEResetProc, StandardMinorOpcode)) != 0) {
GEResetProc, StandardMinorOpcode)) != 0)
{
memset(GEExtensions, 0, sizeof(GEExtensions));
EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent;
}
else {
} else {
FatalError("GEInit: AddExtensions failed.\n");
}
@@ -222,6 +249,7 @@ GERegisterExtension(int extension,
GEExtensions[EXT_MASK(extension)].evswap = ev_swap;
}
/* Sets type and extension field for a generic event. This is just an
* auxiliary function, extensions could do it manually too.
*/
@@ -232,3 +260,4 @@ GEInitEvent(xGenericEvent *ev, int extension)
ev->extension = extension;
ev->length = 0;
}

View File

@@ -40,6 +40,7 @@ typedef struct _GEExtension {
void (*evswap)(xGenericEvent* from, xGenericEvent* to);
} GEExtension, *GEExtensionPtr;
/* All registered extensions and their handling functions. */
extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS];
@@ -69,13 +70,14 @@ extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS];
GEEXT(ev) == (ext) && \
GEV(ev)->evtype == (ev_type))
/* Interface for other extensions */
extern _X_EXPORT void GERegisterExtension(int extension,
void (*ev_dispatch) (xGenericEvent
*from,
xGenericEvent
*to));
extern _X_EXPORT void GERegisterExtension(
int extension,
void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to));
extern _X_EXPORT void GEInitEvent(xGenericEvent* ev, int extension);
extern _X_EXPORT void GEExtensionInit(void);
#endif /* _GEEXT_H_ */

View File

@@ -37,8 +37,7 @@
#include "extnsionst.h"
#include <X11/extensions/geproto.h>
extern DevPrivateKeyRec GEClientPrivateKeyRec;
extern _X_EXPORT DevPrivateKeyRec GEClientPrivateKeyRec;
#define GEClientPrivateKey (&GEClientPrivateKeyRec)
typedef struct _GEClientInfo {
@@ -48,4 +47,7 @@ typedef struct _GEClientInfo {
#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey)))
extern _X_EXPORT int (*ProcGEVector[/*GENumRequests*/])(ClientPtr);
extern _X_EXPORT int (*SProcGEVector[/*GENumRequests*/])(ClientPtr);
#endif /* _GEINT_H_ */

View File

@@ -1,298 +0,0 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#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) & ~((~0) << 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 initalizes 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',
'geint.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'
hdrs_xext += ['xace.h', 'xacestr.h']
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,
)
install_data(hdrs_xext, install_dir: xorgsdkdir)

View File

@@ -53,17 +53,19 @@ Equipment Corporation.
#include "servermd.h"
#include "resource.h"
#include "picturestr.h"
#ifdef XFIXES
#include "xfixesint.h"
#include "damageextint.h"
#endif
#ifdef COMPOSITE
#include "compint.h"
#endif
#include "extinit.h"
#include "modinit.h"
#include "protocol-versions.h"
#ifdef GLXPROXY
extern VisualPtr glxMatchVisual(ScreenPtr pScreen,
VisualPtr pVisual, ScreenPtr pMatchScreen);
VisualPtr pVisual,
ScreenPtr pMatchScreen);
#endif
/*
@@ -74,7 +76,7 @@ int PanoramiXPixWidth = 0;
int PanoramiXPixHeight = 0;
int PanoramiXNumScreens = 0;
_X_EXPORT RegionRec PanoramiXScreenRegion = { {0, 0, 0, 0}, NULL };
static RegionRec PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL};
static int PanoramiXNumDepths;
static DepthPtr PanoramiXDepths;
@@ -105,20 +107,17 @@ static void PanoramiXResetProc(ExtensionEntry *);
#include "panoramiXh.h"
int (*SavedProcVector[256]) (ClientPtr client) = {
NULL,};
int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
static DevPrivateKeyRec PanoramiXGCKeyRec;
#define PanoramiXGCKey (&PanoramiXGCKeyRec)
static DevPrivateKeyRec PanoramiXScreenKeyRec;
#define PanoramiXScreenKey (&PanoramiXScreenKeyRec)
typedef struct {
DDXPointRec clipOrg;
DDXPointRec patOrg;
const GCFuncs *wrapFuncs;
GCFuncs *wrapFuncs;
} PanoramiXGCRec, *PanoramiXGCPtr;
typedef struct {
@@ -130,11 +129,11 @@ static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
static void XineramaChangeGC(GCPtr, unsigned long);
static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
static void XineramaDestroyGC(GCPtr);
static void XineramaChangeClip(GCPtr, int, void *, int);
static void XineramaChangeClip(GCPtr, int, pointer, int);
static void XineramaDestroyClip(GCPtr);
static void XineramaCopyClip(GCPtr, GCPtr);
static const GCFuncs XineramaGCFuncs = {
static GCFuncs XineramaGCFuncs = {
XineramaValidateGC, XineramaChangeGC, XineramaCopyGC, XineramaDestroyGC,
XineramaChangeClip, XineramaDestroyClip, XineramaCopyClip
};
@@ -148,8 +147,9 @@ static const GCFuncs XineramaGCFuncs = {
pGCPriv->wrapFuncs = (pGC)->funcs;\
(pGC)->funcs = &XineramaGCFuncs;
static Bool
XineramaCloseScreen(ScreenPtr pScreen)
XineramaCloseScreen (int i, ScreenPtr pScreen)
{
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
@@ -160,9 +160,9 @@ XineramaCloseScreen(ScreenPtr pScreen)
if (pScreen->myNum == 0)
RegionUninit(&PanoramiXScreenRegion);
free(pScreenPriv);
free((pointer) pScreenPriv);
return (*pScreen->CloseScreen) (pScreen);
return (*pScreen->CloseScreen) (i, pScreen);
}
static Bool
@@ -192,8 +192,11 @@ XineramaCreateGC(GCPtr pGC)
}
static void
XineramaValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
XineramaValidateGC(
GCPtr pGC,
unsigned long changes,
DrawablePtr pDraw
){
Xinerama_GC_FUNC_PROLOGUE (pGC);
if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) {
@@ -222,8 +225,7 @@ XineramaValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
pGC->patOrg.y = new_val;
changes |= GCTileStipYOrigin;
}
}
else {
} else {
if(pGC->clipOrg.x != pGCPriv->clipOrg.x) {
pGC->clipOrg.x = pGCPriv->clipOrg.x;
changes |= GCClipXOrigin;
@@ -255,8 +257,10 @@ XineramaDestroyGC(GCPtr pGC)
}
static void
XineramaChangeGC(GCPtr pGC, unsigned long mask)
{
XineramaChangeGC (
GCPtr pGC,
unsigned long mask
){
Xinerama_GC_FUNC_PROLOGUE (pGC);
if(mask & GCTileStipXOrigin)
@@ -273,11 +277,13 @@ XineramaChangeGC(GCPtr pGC, unsigned long mask)
}
static void
XineramaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
XineramaCopyGC (
GCPtr pGCSrc,
unsigned long mask,
GCPtr pGCDst
){
PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr)
dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey);
Xinerama_GC_FUNC_PROLOGUE (pGCDst);
if(mask & GCTileStipXOrigin)
@@ -294,8 +300,12 @@ XineramaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
}
static void
XineramaChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
{
XineramaChangeClip (
GCPtr pGC,
int type,
pointer pvalue,
int nrects
){
Xinerama_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
Xinerama_GC_FUNC_EPILOGUE (pGC);
@@ -318,7 +328,7 @@ XineramaDestroyClip(GCPtr pGC)
}
int
XineramaDeleteResource(void *data, XID id)
XineramaDeleteResource(pointer data, XID id)
{
free(data);
return 1;
@@ -330,7 +340,7 @@ typedef struct {
} PanoramiXSearchData;
static Bool
XineramaFindIDByScrnum(void *resource, XID id, void *privdata)
XineramaFindIDByScrnum(pointer resource, XID id, pointer privdata)
{
PanoramiXRes *res = (PanoramiXRes*)resource;
PanoramiXSearchData *data = (PanoramiXSearchData*)privdata;
@@ -342,7 +352,7 @@ PanoramiXRes *
PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
{
PanoramiXSearchData data;
void *val;
pointer val;
if(!screen) {
dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess);
@@ -378,8 +388,7 @@ XineramaRegisterConnectionBlockCallback(void (*func) (void))
return TRUE;
}
static void
XineramaInitData(void)
static void XineramaInitData(ScreenPtr pScreen)
{
int i, w, h;
@@ -388,7 +397,7 @@ XineramaInitData(void)
BoxRec TheBox;
RegionRec ScreenRegion;
ScreenPtr pScreen = screenInfo.screens[i];
pScreen = screenInfo.screens[i];
TheBox.x1 = pScreen->x;
TheBox.x2 = TheBox.x1 + pScreen->width;
@@ -402,12 +411,10 @@ XineramaInitData(void)
}
PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
PanoramiXPixHeight =
screenInfo.screens[0]->y + screenInfo.screens[0]->height;
PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height;
FOR_NSCREENS_FORWARD_SKIP(i) {
ScreenPtr pScreen = screenInfo.screens[i];
pScreen = screenInfo.screens[i];
w = pScreen->x + pScreen->width;
h = pScreen->y + pScreen->height;
@@ -418,11 +425,10 @@ XineramaInitData(void)
}
}
void
XineramaReinitData(void)
void XineramaReinitData(ScreenPtr pScreen)
{
RegionUninit(&PanoramiXScreenRegion);
XineramaInitData();
XineramaInitData(pScreen);
}
/*
@@ -432,8 +438,7 @@ XineramaReinitData(void)
* Initialize global variables.
*/
void
PanoramiXExtensionInit(void)
void PanoramiXExtensionInit(int argc, char *argv[])
{
int i;
Bool success = FALSE;
@@ -449,8 +454,7 @@ PanoramiXExtensionInit(void)
return;
}
if (!dixRegisterPrivateKey
(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
if (!dixRegisterPrivateKey(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
@@ -500,7 +504,8 @@ PanoramiXExtensionInit(void)
"XineramaPixmap");
if (XRT_PIXMAP)
XRT_PIXMAP |= XRC_DRAWABLE;
XRT_GC = CreateNewResourceType(XineramaDeleteResource, "XineramaGC");
XRT_GC = CreateNewResourceType(XineramaDeleteResource,
"XineramaGC");
XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource,
"XineramaColormap");
@@ -520,7 +525,7 @@ PanoramiXExtensionInit(void)
return;
}
XineramaInitData();
XineramaInitData(pScreen);
/*
* Put our processes into the ProcVector
@@ -582,19 +587,21 @@ PanoramiXExtensionInit(void)
ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor;
PanoramiXRenderInit ();
#ifdef XFIXES
PanoramiXFixesInit ();
PanoramiXDamageInit();
#endif
#ifdef COMPOSITE
PanoramiXCompositeInit ();
#endif
}
Bool
PanoramiXCreateConnectionBlock(void)
extern Bool CreateConnectionBlock(void);
Bool PanoramiXCreateConnectionBlock(void)
{
int i, j, length;
Bool disable_backing_store = FALSE;
Bool disableBackingStore = FALSE;
int old_width, old_height;
float width_mult, height_mult;
xWindowRoot *root;
@@ -618,12 +625,11 @@ PanoramiXCreateConnectionBlock(void)
ErrorF("Xinerama error: Root window depths differ\n");
return FALSE;
}
if (pScreen->backingStoreSupport !=
screenInfo.screens[0]->backingStoreSupport)
disable_backing_store = TRUE;
if(pScreen->backingStoreSupport != screenInfo.screens[0]->backingStoreSupport)
disableBackingStore = TRUE;
}
if (disable_backing_store) {
if (disableBackingStore) {
for (i = 0; i < screenInfo.numScreens; i++) {
pScreen = screenInfo.screens[i];
pScreen->backingStoreSupport = NotUseful;
@@ -656,7 +662,9 @@ PanoramiXCreateConnectionBlock(void)
visual->visualID = PanoramiXDepths[i].vids[j];
for (pVisual = PanoramiXVisuals;
pVisual->vid != visual->visualID; pVisual++);
pVisual->vid != visual->visualID;
pVisual++)
;
visual->class = pVisual->class;
visual->bitsPerRGB = pVisual->bitsPerRGBValue;
@@ -691,9 +699,9 @@ PanoramiXCreateConnectionBlock(void)
root->mmHeight *= height_mult;
while(ConnectionCallbackList) {
void *tmp;
pointer tmp;
tmp = (void *) ConnectionCallbackList;
tmp = (pointer)ConnectionCallbackList;
(*ConnectionCallbackList->func)();
ConnectionCallbackList = ConnectionCallbackList->next;
free(tmp);
@@ -747,10 +755,14 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth)
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
PanoramiXDepths = reallocarray(PanoramiXDepths,
PanoramiXNumDepths, sizeof(DepthRec));
PanoramiXDepths = realloc(PanoramiXDepths,
PanoramiXNumDepths * sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if(pDepth->numVids)
PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids);
else
PanoramiXDepths[j].vids = NULL;
}
@@ -785,16 +797,13 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
PanoramiXVisuals = reallocarray(PanoramiXVisuals,
PanoramiXNumVisuals, sizeof(VisualRec));
PanoramiXVisuals = realloc(PanoramiXVisuals,
PanoramiXNumVisuals * sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
for (k = 0; k < PanoramiXNumDepths; k++) {
if (PanoramiXDepths[k].depth == pVisual->nplanes) {
PanoramiXDepths[k].vids = reallocarray(PanoramiXDepths[k].vids,
PanoramiXDepths[k].numVids + 1,
sizeof(VisualID));
PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid;
PanoramiXDepths[k].numVids++;
break;
@@ -828,15 +837,14 @@ PanoramiXConsolidate(void)
saver->type = XRT_WINDOW;
FOR_NSCREENS(i) {
ScreenPtr scr = screenInfo.screens[i];
root->info[i].id = scr->root->drawable.id;
ScreenPtr pScreen = screenInfo.screens[i];
root->info[i].id = pScreen->root->drawable.id;
root->u.win.class = InputOutput;
root->u.win.root = TRUE;
saver->info[i].id = scr->screensaver.wid;
saver->info[i].id = pScreen->screensaver.wid;
saver->u.win.class = InputOutput;
saver->u.win.root = TRUE;
defmap->info[i].id = scr->defColormap;
defmap->info[i].id = pScreen->defColormap;
}
AddResource(root->info[0].id, XRT_WINDOW, root);
@@ -876,47 +884,46 @@ PanoramiXTranslateVisualID(int screen, VisualID orig)
return 0;
}
/*
* PanoramiXResetProc()
* Exit, deallocating as needed.
*/
static void
PanoramiXResetProc(ExtensionEntry * extEntry)
static void PanoramiXResetProc(ExtensionEntry* extEntry)
{
int i;
PanoramiXRenderReset ();
#ifdef XFIXES
PanoramiXFixesReset ();
PanoramiXDamageReset();
#ifdef COMPOSITE
PanoramiXCompositeReset ();
#endif
screenInfo.numScreens = PanoramiXNumScreens;
for (i = 256; i--; )
ProcVector[i] = SavedProcVector[i];
}
int
ProcPanoramiXQueryVersion (ClientPtr client)
{
/* REQUEST(xPanoramiXQueryVersionReq); */
xPanoramiXQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_PANORAMIX_MAJOR_VERSION,
.minorVersion = SERVER_PANORAMIX_MINOR_VERSION
};
xPanoramiXQueryVersionReply rep;
register int n;
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = SERVER_PANORAMIX_MAJOR_VERSION;
rep.minorVersion = SERVER_PANORAMIX_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), &rep);
WriteToClient(client, sizeof (xPanoramiXQueryVersionReply), (char *)&rep);
return Success;
}
@@ -926,26 +933,24 @@ ProcPanoramiXGetState(ClientPtr client)
REQUEST(xPanoramiXGetStateReq);
WindowPtr pWin;
xPanoramiXGetStateReply rep;
int rc;
int n, rc;
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetStateReply) {
.type = X_Reply,
.state = !noPanoramiXExtension,
.sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window
};
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.state = !noPanoramiXExtension;
rep.window = stuff->window;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.window, n);
}
WriteToClient(client, sizeof(xPanoramiXGetStateReply), &rep);
WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
return Success;
}
@@ -956,26 +961,24 @@ ProcPanoramiXGetScreenCount(ClientPtr client)
REQUEST(xPanoramiXGetScreenCountReq);
WindowPtr pWin;
xPanoramiXGetScreenCountReply rep;
int rc;
int n, rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetScreenCountReply) {
.type = X_Reply,
.ScreenCount = PanoramiXNumScreens,
.sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window
};
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.ScreenCount = PanoramiXNumScreens;
rep.window = stuff->window;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.window, n);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), &rep);
WriteToClient (client, sizeof (xPanoramiXGetScreenCountReply), (char *) &rep);
return Success;
}
@@ -985,39 +988,37 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
REQUEST(xPanoramiXGetScreenSizeReq);
WindowPtr pWin;
xPanoramiXGetScreenSizeReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
int n, rc;
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetScreenSizeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
/* screen dimensions */
.width = screenInfo.screens[stuff->screen]->width,
.height = screenInfo.screens[stuff->screen]->height,
.window = stuff->window,
.screen = stuff->screen
};
rep.width = screenInfo.screens[stuff->screen]->width;
rep.height = screenInfo.screens[stuff->screen]->height;
rep.window = stuff->window;
rep.screen = stuff->screen;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.width);
swapl(&rep.height);
swapl(&rep.window);
swapl(&rep.screen);
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.width, n);
swapl (&rep.height, n);
swapl (&rep.window, n);
swapl (&rep.screen, n);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), &rep);
WriteToClient (client, sizeof (xPanoramiXGetScreenSizeReply), (char *) &rep);
return Success;
}
int
ProcXineramaIsActive(ClientPtr client)
{
@@ -1026,47 +1027,48 @@ ProcXineramaIsActive(ClientPtr client)
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep = (xXineramaIsActiveReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
#if 1
{
/* The following hack fools clients into thinking that Xinerama
* is disabled even though it is not. */
.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack
#else
.state = !noPanoramiXExtension;
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.state);
rep.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack;
}
WriteToClient(client, sizeof(xXineramaIsActiveReply), &rep);
#else
rep.state = !noPanoramiXExtension;
#endif
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.state, n);
}
WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
return Success;
}
int
ProcXineramaQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
xXineramaQueryScreensReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(number * sz_XineramaScreenInfo),
.number = number
};
xXineramaQueryScreensReply rep;
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.number);
int n;
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.number, n);
}
WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep);
WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
if(!noPanoramiXExtension) {
xXineramaScreenInfo scratch;
@@ -1079,23 +1081,25 @@ ProcXineramaQueryScreens(ClientPtr client)
scratch.height = screenInfo.screens[i]->height;
if(client->swapped) {
swaps(&scratch.x_org);
swaps(&scratch.y_org);
swaps(&scratch.width);
swaps(&scratch.height);
int n;
swaps (&scratch.x_org, n);
swaps (&scratch.y_org, n);
swaps (&scratch.width, n);
swaps (&scratch.height, n);
}
WriteToClient(client, sz_XineramaScreenInfo, &scratch);
WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
}
}
return Success;
}
static int
ProcPanoramiXDispatch (ClientPtr client)
{ REQUEST(xReq);
switch (stuff->data)
{
REQUEST(xReq);
switch (stuff->data) {
case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:
@@ -1112,6 +1116,7 @@ ProcPanoramiXDispatch(ClientPtr client)
return BadRequest;
}
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
#define SHIFT_L(v,s) (v) << (s)
#define SHIFT_R(v,s) (v) >> (s)
@@ -1129,25 +1134,28 @@ CopyBits(char *dst, int shiftL, char *src, int bytes)
while(bytes--) {
*dst |= SHIFT_L(*src, shiftL);
*(dst + 1) |= SHIFT_R(*src, shiftR);
dst++;
src++;
dst++; src++;
}
}
/* Caution. This doesn't support 2 and 4 bpp formats. We expect
1 bpp and planar data to be already cleared when presented
to this function */
void
XineramaGetImageData(DrawablePtr *pDrawables,
XineramaGetImageData(
DrawablePtr *pDrawables,
int left,
int top,
int width,
int height,
unsigned int format,
unsigned long planemask,
char *data, int pitch, Bool isRoot)
{
char *data,
int pitch,
Bool isRoot
){
RegionRec SrcRegion, ScreenRegion, GrabRegion;
BoxRec SrcBox, *pbox;
int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
@@ -1174,7 +1182,6 @@ XineramaGetImageData(DrawablePtr *pDrawables,
FOR_NSCREENS(i) {
BoxRec TheBox;
ScreenPtr pScreen;
pDraw = pDrawables[i];
pScreen = pDraw->pScreen;
@@ -1191,14 +1198,11 @@ XineramaGetImageData(DrawablePtr *pDrawables,
if(inOut == rgnIN) {
(*pScreen->GetImage)(pDraw,
SrcBox.x1 - pDraw->x -
screenInfo.screens[i]->x,
SrcBox.y1 - pDraw->y -
screenInfo.screens[i]->y, width, height,
format, planemask, data);
SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x,
SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y,
width, height, format, planemask, data);
break;
}
else if (inOut == rgnOUT)
} else if (inOut == rgnOUT)
continue;
nbox = RegionNumRects(&GrabRegion);
@@ -1214,7 +1218,6 @@ XineramaGetImageData(DrawablePtr *pDrawables,
if(sizeNeeded > size) {
char *tmpdata = ScratchMem;
ScratchMem = realloc(ScratchMem, sizeNeeded);
if(ScratchMem)
size = sizeNeeded;
@@ -1245,13 +1248,13 @@ XineramaGetImageData(DrawablePtr *pDrawables,
/* clean up the edge */
if(leftover) {
int mask = (1 << leftover) - 1;
for(j = h, k = w; j--; k += ScratchPitch)
ScratchMem[k] &= mask;
}
for(j = 0, index = (pitch * y) + x, index2 = 0; j < h;
j++, index += pitch, index2 += ScratchPitch) {
j++, index += pitch, index2 += ScratchPitch)
{
if(w) {
if(!shift)
memcpy(data + index, ScratchMem + index2, w);
@@ -1265,12 +1268,10 @@ XineramaGetImageData(DrawablePtr *pDrawables,
SHIFT_L(ScratchMem[index2 + w], shift);
if((shift + leftover) > 8)
data[index + w + 1] |=
SHIFT_R(ScratchMem[index2 + w],
(8 - shift));
SHIFT_R(ScratchMem[index2 + w],(8 - shift));
}
}
}
else {
} else {
j = BitsPerPixel(depth) >> 3;
x = (pbox->x1 - SrcBox.x1) * j;
y = pbox->y1 - SrcBox.y1;

View File

@@ -26,6 +26,7 @@ Equipment Corporation.
******************************************************************/
/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */
/*

View File

@@ -47,75 +47,84 @@ Equipment Corporation.
#include "globals.h"
#include "panoramiXh.h"
static int _X_COLD
static int
SProcPanoramiXQueryVersion (ClientPtr client)
{
REQUEST(xPanoramiXQueryVersionReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length,n);
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
return ProcPanoramiXQueryVersion(client);
}
static int _X_COLD
static int
SProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
int n;
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
swapl(&stuff->window);
swapl (&stuff->window, n);
return ProcPanoramiXGetState(client);
}
static int _X_COLD
static int
SProcPanoramiXGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
int n;
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
swapl(&stuff->window);
swapl (&stuff->window, n);
return ProcPanoramiXGetScreenCount(client);
}
static int _X_COLD
static int
SProcPanoramiXGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
int n;
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
swapl(&stuff->window);
swapl(&stuff->screen);
swapl (&stuff->window, n);
swapl (&stuff->screen, n);
return ProcPanoramiXGetScreenSize(client);
}
static int _X_COLD
static int
SProcXineramaIsActive(ClientPtr client)
{
REQUEST(xXineramaIsActiveReq);
int n;
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
return ProcXineramaIsActive(client);
}
static int _X_COLD
static int
SProcXineramaQueryScreens(ClientPtr client)
{
REQUEST(xXineramaQueryScreensReq);
int n;
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
return ProcXineramaQueryScreens(client);
}
int _X_COLD
int
SProcPanoramiXDispatch (ClientPtr client)
{ REQUEST(xReq);
switch (stuff->data)
{
REQUEST(xReq);
switch (stuff->data) {
case X_PanoramiXQueryVersion:
return SProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:

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 PanoramiXPixWidth;
extern _X_EXPORT int PanoramiXPixHeight;
extern _X_EXPORT RegionRec PanoramiXScreenRegion;
extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig);
extern _X_EXPORT void PanoramiXConsolidate(void);
extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void);
extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int);
extern _X_EXPORT Bool
XineramaRegisterConnectionBlockCallback(void (*func) (void));
extern _X_EXPORT int XineramaDeleteResource(void *, XID);
extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
extern _X_EXPORT int XineramaDeleteResource(pointer, XID);
extern _X_EXPORT void XineramaReinitData(void);
extern _X_EXPORT void XineramaReinitData(ScreenPtr);
extern _X_EXPORT RESTYPE XRC_DRAWABLE;
extern _X_EXPORT RESTYPE XRT_WINDOW;
@@ -40,17 +38,21 @@ extern _X_EXPORT RESTYPE XRT_PICTURE;
typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr);
extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr;
extern _X_EXPORT void XineramaGetImageData(DrawablePtr *pDrawables,
extern _X_EXPORT void XineramaGetImageData(
DrawablePtr *pDrawables,
int left,
int top,
int width,
int height,
unsigned int format,
unsigned long planemask,
char *data, int pitch, Bool isRoot);
char *data,
int pitch,
Bool isRoot
);
static inline void
panoramix_setup_ids(PanoramiXRes * resource, ClientPtr client, XID base_id)
static inline void panoramix_setup_ids(PanoramiXRes *resource,
ClientPtr client, XID base_id)
{
int j;

File diff suppressed because it is too large Load Diff

View File

@@ -38,7 +38,7 @@ in this Software without prior written authorization from The Open Group.
#include "xacestr.h"
#include "securitysrv.h"
#include <X11/extensions/securproto.h>
#include "extinit.h"
#include "modinit.h"
#include "protocol-versions.h"
/* Extension stuff */
@@ -52,21 +52,20 @@ static CallbackListPtr SecurityValidateGroupCallback = NULL;
/* Private state record */
static DevPrivateKeyRec stateKeyRec;
#define stateKey (&stateKeyRec)
/* This is what we store as client security state */
typedef struct {
unsigned int haveState :1;
unsigned int live :1;
unsigned int trustLevel :2;
int haveState;
unsigned int trustLevel;
XID authId;
} SecurityStateRec;
/* The only extensions that untrusted clients have access to */
static const char *SecurityTrustedExtensions[] = {
/* Extensions that untrusted clients shouldn't have access to */
static char *SecurityTrustedExtensions[] = {
"XC-MISC",
"BIG-REQUESTS",
"XpExtension",
NULL
};
@@ -85,6 +84,7 @@ static const Mask SecurityDeviceMask =
static const Mask SecurityServerMask = DixGetAttrAccess | DixGrabAccess;
static const Mask SecurityClientMask = DixGetAttrAccess;
/* SecurityAudit
*
* Arguments:
@@ -98,8 +98,7 @@ static const Mask SecurityClientMask = DixGetAttrAccess;
*/
static void
_X_ATTRIBUTE_PRINTF(1, 2)
SecurityAudit(const char *format, ...)
SecurityAudit(char *format, ...)
{
va_list args;
@@ -141,7 +140,6 @@ SecurityLabelInitial(void)
state = dixLookupPrivate(&serverClient->devPrivates, stateKey);
state->trustLevel = XSecurityClientTrusted;
state->haveState = TRUE;
state->live = FALSE;
}
/*
@@ -153,6 +151,7 @@ SecurityLookupRequestName(ClientPtr client)
return LookupRequestName(client->majorOp, client->minorOp);
}
/* SecurityDeleteAuthorization
*
* Arguments:
@@ -166,19 +165,21 @@ SecurityLookupRequestName(ClientPtr client)
*/
static int
SecurityDeleteAuthorization(void *value, XID id)
SecurityDeleteAuthorization(
pointer value,
XID id)
{
SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
unsigned short name_len, data_len;
const char *name;
char *data;
char *name, *data;
int status;
int i;
OtherClientsPtr pEventClient;
/* Remove the auth using the os layer auth manager */
status = AuthorizationFromID(pAuth->id, &name_len, &name, &data_len, &data);
status = AuthorizationFromID(pAuth->id, &name_len, &name,
&data_len, &data);
assert(status);
status = RemoveAuthorization(name_len, name, data_len, data);
assert(status);
@@ -186,17 +187,16 @@ SecurityDeleteAuthorization(void *value, XID id)
/* free the auth timer if there is one */
if (pAuth->timer)
TimerFree(pAuth->timer);
if (pAuth->timer) TimerFree(pAuth->timer);
/* send revoke events */
while ((pEventClient = pAuth->eventClients)) {
while ((pEventClient = pAuth->eventClients))
{
/* send revocation event event */
xSecurityAuthorizationRevokedEvent are = {
.type = SecurityEventBase + XSecurityAuthorizationRevoked,
.authId = pAuth->id
};
xSecurityAuthorizationRevokedEvent are;
are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
are.authId = pAuth->id;
WriteEventsToClient(rClient(pEventClient), 1, (xEvent *)&are);
FreeResource(pEventClient->resource, RT_NONE);
}
@@ -206,28 +206,33 @@ SecurityDeleteAuthorization(void *value, XID id)
for (i = 1; i<currentMaxClients; i++)
if (clients[i]) {
SecurityStateRec *state;
state = dixLookupPrivate(&clients[i]->devPrivates, stateKey);
if (state->haveState && state->authId == pAuth->id)
CloseDownClient(clients[i]);
}
SecurityAudit("revoked authorization ID %lu\n", (unsigned long)pAuth->id);
SecurityAudit("revoked authorization ID %d\n", pAuth->id);
free(pAuth);
return Success;
} /* SecurityDeleteAuthorization */
/* resource delete function for RTEventClient */
static int
SecurityDeleteAuthorizationEventClient(void *value, XID id)
SecurityDeleteAuthorizationEventClient(
pointer value,
XID id)
{
OtherClientsPtr pEventClient, prev = NULL;
SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
for (pEventClient = pAuth->eventClients;
pEventClient; pEventClient = pEventClient->next) {
if (pEventClient->resource == id) {
pEventClient;
pEventClient = pEventClient->next)
{
if (pEventClient->resource == id)
{
if (prev)
prev->next = pEventClient->next;
else
@@ -237,9 +242,11 @@ SecurityDeleteAuthorizationEventClient(void *value, XID id)
}
prev = pEventClient;
}
/*NOTREACHED*/ return -1; /* make compiler happy */
/*NOTREACHED*/
return -1; /* make compiler happy */
} /* SecurityDeleteAuthorizationEventClient */
/* SecurityComputeAuthorizationTimeout
*
* Arguments:
@@ -255,7 +262,8 @@ SecurityDeleteAuthorizationEventClient(void *value, XID id)
*/
static CARD32
SecurityComputeAuthorizationTimeout(SecurityAuthorizationPtr pAuth,
SecurityComputeAuthorizationTimeout(
SecurityAuthorizationPtr pAuth,
unsigned int seconds)
{
/* maxSecs is the number of full seconds that can be expressed in
@@ -263,11 +271,13 @@ SecurityComputeAuthorizationTimeout(SecurityAuthorizationPtr pAuth,
*/
CARD32 maxSecs = (CARD32)(~0) / (CARD32)MILLI_PER_SECOND;
if (seconds > maxSecs) { /* only come here if we want to wait more than 49 days */
if (seconds > maxSecs)
{ /* only come here if we want to wait more than 49 days */
pAuth->secondsRemaining = seconds - maxSecs;
return maxSecs * MILLI_PER_SECOND;
}
else { /* by far the common case */
else
{ /* by far the common case */
pAuth->secondsRemaining = 0;
return seconds * MILLI_PER_SECOND;
}
@@ -293,17 +303,22 @@ SecurityComputeAuthorizationTimeout(SecurityAuthorizationPtr pAuth,
*/
static CARD32
SecurityAuthorizationExpired(OsTimerPtr timer, CARD32 time, void *pval)
SecurityAuthorizationExpired(
OsTimerPtr timer,
CARD32 time,
pointer pval)
{
SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)pval;
assert(pAuth->timer == timer);
if (pAuth->secondsRemaining) {
if (pAuth->secondsRemaining)
{
return SecurityComputeAuthorizationTimeout(pAuth,
pAuth->secondsRemaining);
}
else {
else
{
FreeResource(pAuth->id, RT_NONE);
return 0;
}
@@ -323,50 +338,59 @@ SecurityAuthorizationExpired(OsTimerPtr timer, CARD32 time, void *pval)
*/
static void
SecurityStartAuthorizationTimer(SecurityAuthorizationPtr pAuth)
SecurityStartAuthorizationTimer(
SecurityAuthorizationPtr pAuth)
{
pAuth->timer = TimerSet(pAuth->timer, 0,
SecurityComputeAuthorizationTimeout(pAuth,
pAuth->timeout),
SecurityComputeAuthorizationTimeout(pAuth, pAuth->timeout),
SecurityAuthorizationExpired, pAuth);
} /* SecurityStartAuthorizationTimer */
/* Proc functions all take a client argument, execute the request in
* client->requestBuffer, and return a protocol error status.
*/
static int
ProcSecurityQueryVersion(ClientPtr client)
ProcSecurityQueryVersion(
ClientPtr client)
{
/* REQUEST(xSecurityQueryVersionReq); */
xSecurityQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SECURITY_MAJOR_VERSION,
.minorVersion = SERVER_SECURITY_MINOR_VERSION
};
xSecurityQueryVersionReply rep;
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.majorVersion = SERVER_SECURITY_MAJOR_VERSION;
rep.minorVersion = SERVER_SECURITY_MINOR_VERSION;
if(client->swapped)
{
char n;
swaps(&rep.sequenceNumber, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, SIZEOF(xSecurityQueryVersionReply), &rep);
(void)WriteToClient(client, SIZEOF(xSecurityQueryVersionReply),
(char *)&rep);
return Success;
} /* ProcSecurityQueryVersion */
static int
SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
ClientPtr client, Mask mask)
SecurityEventSelectForAuthorization(
SecurityAuthorizationPtr pAuth,
ClientPtr client,
Mask mask)
{
OtherClients *pEventClient;
for (pEventClient = pAuth->eventClients;
pEventClient; pEventClient = pEventClient->next) {
if (SameClient(pEventClient, client)) {
pEventClient;
pEventClient = pEventClient->next)
{
if (SameClient(pEventClient, client))
{
if (mask == 0)
FreeResource(pEventClient->resource, RT_NONE);
else
@@ -381,7 +405,9 @@ SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
pEventClient->mask = mask;
pEventClient->resource = FakeClientID(client->index);
pEventClient->next = pAuth->eventClients;
if (!AddResource(pEventClient->resource, RTEventClient, (void *) pAuth)) {
if (!AddResource(pEventClient->resource, RTEventClient,
(pointer)pAuth))
{
free(pEventClient);
return BadAlloc;
}
@@ -390,8 +416,10 @@ SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
return Success;
} /* SecurityEventSelectForAuthorization */
static int
ProcSecurityGenerateAuthorization(ClientPtr client)
ProcSecurityGenerateAuthorization(
ClientPtr client)
{
REQUEST(xSecurityGenerateAuthorizationReq);
int len; /* request length in CARD32s*/
@@ -422,23 +450,27 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
return BadLength;
/* check valuemask */
if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes) {
if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes)
{
client->errorValue = stuff->valueMask;
return BadValue;
}
/* check timeout */
timeout = 60;
if (stuff->valueMask & XSecurityTimeout) {
if (stuff->valueMask & XSecurityTimeout)
{
timeout = *values++;
}
/* check trustLevel */
trustLevel = XSecurityClientUntrusted;
if (stuff->valueMask & XSecurityTrustLevel) {
if (stuff->valueMask & XSecurityTrustLevel)
{
trustLevel = *values++;
if (trustLevel != XSecurityClientTrusted &&
trustLevel != XSecurityClientUntrusted) {
trustLevel != XSecurityClientUntrusted)
{
client->errorValue = trustLevel;
return BadValue;
}
@@ -446,18 +478,20 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* check group */
group = None;
if (stuff->valueMask & XSecurityGroup) {
if (stuff->valueMask & XSecurityGroup)
{
group = *values++;
if (SecurityValidateGroupCallback) {
if (SecurityValidateGroupCallback)
{
SecurityValidateGroupInfoRec vgi;
vgi.group = group;
vgi.valid = FALSE;
CallCallbacks(&SecurityValidateGroupCallback, (void *) &vgi);
CallCallbacks(&SecurityValidateGroupCallback, (pointer)&vgi);
/* if nobody said they recognized it, it's an error */
if (!vgi.valid) {
if (!vgi.valid)
{
client->errorValue = group;
return BadValue;
}
@@ -466,9 +500,11 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* check event mask */
eventMask = 0;
if (stuff->valueMask & XSecurityEventMask) {
if (stuff->valueMask & XSecurityEventMask)
{
eventMask = *values++;
if (eventMask & ~XSecurityAllEventMasks) {
if (eventMask & ~XSecurityAllEventMasks)
{
client->errorValue = eventMask;
return BadValue;
}
@@ -482,7 +518,8 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname,
stuff->nbytesAuthData, protodata,
&authdata_len, &pAuthdata);
if ((XID) ~0L == authId) {
if ((XID) ~0L == authId)
{
err = SecurityErrorBase + XSecurityBadAuthorizationProtocol;
goto bailout;
}
@@ -495,7 +532,8 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* associate additional information with this auth ID */
pAuth = malloc(sizeof(SecurityAuthorizationRec));
if (!pAuth) {
if (!pAuth)
{
err = BadAlloc;
goto bailout;
}
@@ -512,13 +550,15 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
pAuth->eventClients = NULL;
/* handle event selection */
if (eventMask) {
if (eventMask)
{
err = SecurityEventSelectForAuthorization(pAuth, client, eventMask);
if (err != Success)
goto bailout;
}
if (!AddResource(authId, SecurityAuthorizationResType, pAuth)) {
if (!AddResource(authId, SecurityAuthorizationResType, pAuth))
{
err = BadAlloc;
goto bailout;
}
@@ -530,28 +570,28 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* tell client the auth id and data */
rep = (xSecurityGenerateAuthorizationReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(authdata_len),
.authId = authId,
.dataLength = authdata_len
};
rep.type = X_Reply;
rep.length = bytes_to_int32(authdata_len);
rep.sequenceNumber = client->sequence;
rep.authId = authId;
rep.dataLength = authdata_len;
if (client->swapped) {
swapl(&rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.authId);
swaps(&rep.dataLength);
if (client->swapped)
{
char n;
swapl(&rep.length, n);
swaps(&rep.sequenceNumber, n);
swapl(&rep.authId, n);
swaps(&rep.dataLength, n);
}
WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply), &rep);
WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply),
(char *)&rep);
WriteToClient(client, authdata_len, pAuthdata);
SecurityAudit
("client %d generated authorization %lu trust %d timeout %lu group %lu events %lu\n",
client->index, (unsigned long)pAuth->id, pAuth->trustLevel, (unsigned long)pAuth->timeout,
(unsigned long)pAuth->group, (unsigned long)eventMask);
SecurityAudit("client %d generated authorization %d trust %d timeout %d group %d events %d\n",
client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
pAuth->group, eventMask);
/* the request succeeded; don't call RemoveAuthorization or free pAuth */
return Success;
@@ -566,7 +606,8 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
} /* ProcSecurityGenerateAuthorization */
static int
ProcSecurityRevokeAuthorization(ClientPtr client)
ProcSecurityRevokeAuthorization(
ClientPtr client)
{
REQUEST(xSecurityRevokeAuthorizationReq);
SecurityAuthorizationPtr pAuth;
@@ -574,7 +615,7 @@ ProcSecurityRevokeAuthorization(ClientPtr client)
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
rc = dixLookupResourceByType((void **) &pAuth, stuff->authId,
rc = dixLookupResourceByType((pointer *)&pAuth, stuff->authId,
SecurityAuthorizationResType, client,
DixDestroyAccess);
if (rc != Success)
@@ -584,12 +625,15 @@ ProcSecurityRevokeAuthorization(ClientPtr client)
return Success;
} /* ProcSecurityRevokeAuthorization */
static int
ProcSecurityDispatch(ClientPtr client)
ProcSecurityDispatch(
ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_SecurityQueryVersion:
return ProcSecurityQueryVersion(client);
case X_SecurityGenerateAuthorization:
@@ -601,31 +645,36 @@ ProcSecurityDispatch(ClientPtr client)
}
} /* ProcSecurityDispatch */
static int _X_COLD
SProcSecurityQueryVersion(ClientPtr client)
static int
SProcSecurityQueryVersion(
ClientPtr client)
{
REQUEST(xSecurityQueryVersionReq);
char n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion,n);
return ProcSecurityQueryVersion(client);
} /* SProcSecurityQueryVersion */
static int _X_COLD
SProcSecurityGenerateAuthorization(ClientPtr client)
static int
SProcSecurityGenerateAuthorization(
ClientPtr client)
{
REQUEST(xSecurityGenerateAuthorizationReq);
char n;
CARD32 *values;
unsigned long nvalues;
int values_offset;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
swaps(&stuff->nbytesAuthProto);
swaps(&stuff->nbytesAuthData);
swapl(&stuff->valueMask);
swaps(&stuff->nbytesAuthProto, n);
swaps(&stuff->nbytesAuthData, n);
swapl(&stuff->valueMask, n);
values_offset = bytes_to_int32(stuff->nbytesAuthProto) +
bytes_to_int32(stuff->nbytesAuthData);
if (values_offset >
@@ -637,23 +686,29 @@ SProcSecurityGenerateAuthorization(ClientPtr client)
return ProcSecurityGenerateAuthorization(client);
} /* SProcSecurityGenerateAuthorization */
static int _X_COLD
SProcSecurityRevokeAuthorization(ClientPtr client)
static int
SProcSecurityRevokeAuthorization(
ClientPtr client)
{
REQUEST(xSecurityRevokeAuthorizationReq);
char n;
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
swapl(&stuff->authId);
swapl(&stuff->authId, n);
return ProcSecurityRevokeAuthorization(client);
} /* SProcSecurityRevokeAuthorization */
static int _X_COLD
SProcSecurityDispatch(ClientPtr client)
static int
SProcSecurityDispatch(
ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_SecurityQueryVersion:
return SProcSecurityQueryVersion(client);
case X_SecurityGenerateAuthorization:
@@ -665,8 +720,9 @@ SProcSecurityDispatch(ClientPtr client)
}
} /* SProcSecurityDispatch */
static void _X_COLD
SwapSecurityAuthorizationRevokedEvent(xSecurityAuthorizationRevokedEvent * from,
static void
SwapSecurityAuthorizationRevokedEvent(
xSecurityAuthorizationRevokedEvent *from,
xSecurityAuthorizationRevokedEvent *to)
{
to->type = from->type;
@@ -692,7 +748,7 @@ SwapSecurityAuthorizationRevokedEvent(xSecurityAuthorizationRevokedEvent * from,
*/
static void
SecurityDevice(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceDeviceAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -736,7 +792,7 @@ SecurityDevice(CallbackListPtr *pcbl, void *unused, void *calldata)
*/
static void
SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceResourceAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -776,15 +832,16 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
return;
}
SecurityAudit("Security: denied client %d access %lx to resource 0x%lx "
SecurityAudit("Security: denied client %d access %x to resource 0x%x "
"of client %d on request %s\n", rec->client->index,
(unsigned long)requested, (unsigned long)rec->id, cid,
requested, rec->id, cid,
SecurityLookupRequestName(rec->client));
rec->status = BadAccess; /* deny access */
}
static void
SecurityExtension(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceExtAccessRec *rec = calldata;
SecurityStateRec *subj;
@@ -807,7 +864,7 @@ SecurityExtension(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SecurityServer(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityServer(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceServerAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -826,7 +883,7 @@ SecurityServer(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SecurityClient(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityClient(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceClientAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -845,7 +902,7 @@ SecurityClient(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SecurityProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XacePropertyAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -858,16 +915,16 @@ SecurityProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
SecurityAudit("Security: denied client %d access to property %s "
"(atom 0x%x) window 0x%lx of client %d on request %s\n",
"(atom 0x%x) window 0x%x of client %d on request %s\n",
rec->client->index, NameForAtom(name), name,
(unsigned long)rec->pWin->drawable.id, wClient(rec->pWin)->index,
rec->pWin->drawable.id, wClient(rec->pWin)->index,
SecurityLookupRequestName(rec->client));
rec->status = BadAccess;
}
}
static void
SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
SecuritySend(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceSendAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -887,10 +944,10 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
rec->events[i].u.u.type != ClientMessage) {
SecurityAudit("Security: denied client %d from sending event "
"of type %s to window 0x%lx of client %d\n",
"of type %s to window 0x%x of client %d\n",
rec->client->index,
LookupEventName(rec->events[i].u.u.type),
(unsigned long)rec->pWin->drawable.id,
rec->pWin->drawable.id,
wClient(rec->pWin)->index);
rec->status = BadAccess;
return;
@@ -899,7 +956,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityReceive(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceReceiveAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
@@ -911,8 +968,8 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
return;
SecurityAudit("Security: denied client %d from receiving an event "
"sent to window 0x%lx of client %d\n",
rec->client->index, (unsigned long)rec->pWin->drawable.id,
"sent to window 0x%x of client %d\n",
rec->client->index, rec->pWin->drawable.id,
wClient(rec->pWin)->index);
rec->status = BadAccess;
}
@@ -940,7 +997,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
*/
static void
SecurityClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
NewClientInfoRec *pci = calldata;
SecurityStateRec *state;
@@ -954,18 +1011,16 @@ SecurityClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
state->trustLevel = XSecurityClientTrusted;
state->authId = None;
state->haveState = TRUE;
state->live = FALSE;
break;
case ClientStateRunning:
state->authId = AuthorizationIDOfClient(pci->client);
rc = dixLookupResourceByType((void **) &pAuth, state->authId,
rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
SecurityAuthorizationResType, serverClient,
DixGetAttrAccess);
if (rc == Success) {
/* it is a generated authorization */
pAuth->refcnt++;
state->live = TRUE;
if (pAuth->refcnt == 1 && pAuth->timer)
TimerCancel(pAuth->timer);
@@ -975,13 +1030,12 @@ SecurityClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
case ClientStateGone:
case ClientStateRetained:
rc = dixLookupResourceByType((void **) &pAuth, state->authId,
rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
SecurityAuthorizationResType, serverClient,
DixGetAttrAccess);
if (rc == Success && state->live) {
if (rc == Success) {
/* it is a generated authorization */
pAuth->refcnt--;
state->live = FALSE;
if (pAuth->refcnt == 0)
SecurityStartAuthorizationTimer(pAuth);
}
@@ -1004,7 +1058,8 @@ SecurityClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
*/
static void
SecurityResetProc(ExtensionEntry * extEntry)
SecurityResetProc(
ExtensionEntry *extEntry)
{
/* Unregister callbacks */
DeleteCallback(&ClientStateCallback, SecurityClientState, NULL);
@@ -1020,6 +1075,7 @@ SecurityResetProc(ExtensionEntry * extEntry)
XaceDeleteCallback(XACE_SERVER_ACCESS, SecurityServer, NULL);
}
/* SecurityExtensionInit
*
* Arguments: none.
@@ -1031,7 +1087,7 @@ SecurityResetProc(ExtensionEntry * extEntry)
*/
void
SecurityExtensionInit(void)
SecurityExtensionInit(INITARGS)
{
ExtensionEntry *extEntry;
int ret = TRUE;
@@ -1050,8 +1106,7 @@ SecurityExtensionInit(void)
RTEventClient |= RC_NEVERRETAIN;
/* Allocate the private storage */
if (!dixRegisterPrivateKey
(stateKey, PRIVATE_CLIENT, sizeof(SecurityStateRec)))
if (!dixRegisterPrivateKey(stateKey, PRIVATE_CLIENT, sizeof(SecurityStateRec)))
FatalError("SecurityExtensionSetup: Can't allocate client private.\n");
/* Register callbacks */
@@ -1082,8 +1137,7 @@ SecurityExtensionInit(void)
EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] =
(EventSwapPtr)SwapSecurityAuthorizationRevokedEvent;
SetResourceTypeErrorValue(SecurityAuthorizationResType,
SecurityErrorBase + XSecurityBadAuthorization);
SetResourceTypeErrorValue(SecurityAuthorizationResType, SecurityErrorBase + XSecurityBadAuthorization);
/* Label objects that were created before we could register ourself */
SecurityLabelInitial();

View File

@@ -51,6 +51,7 @@ from The Open Group.
# undef NEED_UNDEF_Display
#endif
#include "input.h" /* for DeviceIntPtr */
#include "property.h" /* for PropertyPtr */
#include "pixmap.h" /* for DrawablePtr */

View File

@@ -44,19 +44,23 @@ in this Software without prior written authorization from The Open Group.
#include <X11/extensions/shapeproto.h>
#include "regionstr.h"
#include "gcstruct.h"
#include "extinit.h"
#include "modinit.h"
#include "protocol-versions.h"
typedef RegionPtr (*CreateDftPtr) (WindowPtr /* pWin */
typedef RegionPtr (*CreateDftPtr)(
WindowPtr /* pWin */
);
static int ShapeFreeClient(void * /* data */ ,
static int ShapeFreeClient(
pointer /* data */,
XID /* id */
);
static int ShapeFreeEvents(void * /* data */ ,
static int ShapeFreeEvents(
pointer /* data */,
XID /* id */
);
static void SShapeNotifyEvent(xShapeNotifyEvent * /* from */ ,
static void SShapeNotifyEvent(
xShapeNotifyEvent * /* from */,
xShapeNotifyEvent * /* to */
);
@@ -64,6 +68,7 @@ static void SShapeNotifyEvent(xShapeNotifyEvent * /* from */ ,
* externally by the Xfixes extension and are now defined in window.h
*/
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
@@ -98,15 +103,20 @@ typedef struct _ShapeEvent {
****************/
static int
RegionOperate(ClientPtr client,
RegionOperate (
ClientPtr client,
WindowPtr pWin,
int kind,
RegionPtr *destRgnp,
RegionPtr srcRgn, int op, int xoff, int yoff, CreateDftPtr create)
RegionPtr srcRgn,
int op,
int xoff, int yoff,
CreateDftPtr create)
{
if (srcRgn && (xoff || yoff))
RegionTranslate(srcRgn, xoff, yoff);
if (!pWin->parent) {
if (!pWin->parent)
{
if (srcRgn)
RegionDestroy(srcRgn);
return Success;
@@ -135,8 +145,7 @@ RegionOperate(ClientPtr client,
return Success;
}
}
else
switch (op) {
else switch (op) {
case ShapeSet:
if (*destRgnp)
RegionDestroy(*destRgnp);
@@ -204,23 +213,23 @@ CreateClipShape(WindowPtr pWin)
static int
ProcShapeQueryVersion (ClientPtr client)
{
xShapeQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SHAPE_MAJOR_VERSION,
.minorVersion = SERVER_SHAPE_MINOR_VERSION
};
xShapeQueryVersionReply rep;
int n;
REQUEST_SIZE_MATCH (xShapeQueryVersionReq);
memset(&rep, 0, sizeof(xShapeQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = SERVER_SHAPE_MAJOR_VERSION;
rep.minorVersion = SERVER_SHAPE_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xShapeQueryVersionReply), &rep);
WriteToClient(client, sizeof (xShapeQueryVersionReply), (char *)&rep);
return Success;
}
@@ -233,7 +242,6 @@ static int
ProcShapeRectangles (ClientPtr client)
{
WindowPtr pWin;
REQUEST(xShapeRectanglesReq);
xRectangle *prects;
int nrects, ctype, rc;
@@ -261,7 +269,8 @@ ProcShapeRectangles(ClientPtr client)
return BadValue;
}
if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
(stuff->ordering != YXSorted) && (stuff->ordering != YXBanded)) {
(stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
{
client->errorValue = stuff->ordering;
return BadValue;
}
@@ -298,7 +307,8 @@ ProcShapeRectangles(ClientPtr client)
#ifdef PANORAMIX
static int
ProcPanoramiXShapeRectangles(ClientPtr client)
ProcPanoramiXShapeRectangles(
ClientPtr client)
{
REQUEST(xShapeRectanglesReq);
PanoramiXRes *win;
@@ -306,7 +316,7 @@ ProcPanoramiXShapeRectangles(ClientPtr client)
REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess);
if (result != Success)
return result;
@@ -314,23 +324,23 @@ ProcPanoramiXShapeRectangles(ClientPtr client)
FOR_NSCREENS(j) {
stuff->dest = win->info[j].id;
result = ProcShapeRectangles (client);
if (result != Success)
break;
if (result != Success) break;
}
return result;
}
#endif
/**************
* ProcShapeMask
**************/
static int
ProcShapeMask (ClientPtr client)
{
WindowPtr pWin;
ScreenPtr pScreen;
REQUEST(xShapeMaskReq);
RegionPtr srcRgn;
RegionPtr *destRgn;
@@ -361,8 +371,8 @@ ProcShapeMask(ClientPtr client)
if (stuff->src == None)
srcRgn = 0;
else {
rc = dixLookupResourceByType((void **) &pPixmap, stuff->src,
RT_PIXMAP, client, DixReadAccess);
rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->src, RT_PIXMAP,
client, DixReadAccess);
if (rc != Success)
return rc;
if (pPixmap->drawable.pScreen != pScreen ||
@@ -396,7 +406,8 @@ ProcShapeMask(ClientPtr client)
#ifdef PANORAMIX
static int
ProcPanoramiXShapeMask(ClientPtr client)
ProcPanoramiXShapeMask(
ClientPtr client)
{
REQUEST(xShapeMaskReq);
PanoramiXRes *win, *pmap;
@@ -404,18 +415,17 @@ ProcPanoramiXShapeMask(ClientPtr client)
REQUEST_SIZE_MATCH (xShapeMaskReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess);
if (result != Success)
return result;
if(stuff->src != None) {
result = dixLookupResourceByType((void **) &pmap, stuff->src,
result = dixLookupResourceByType((pointer *)&pmap, stuff->src,
XRT_PIXMAP, client, DixReadAccess);
if (result != Success)
return result;
}
else
} else
pmap = NULL;
FOR_NSCREENS(j) {
@@ -423,13 +433,13 @@ ProcPanoramiXShapeMask(ClientPtr client)
if(pmap)
stuff->src = pmap->info[j].id;
result = ProcShapeMask (client);
if (result != Success)
break;
if (result != Success) break;
}
return result;
}
#endif
/************
* ProcShapeCombine
************/
@@ -438,7 +448,6 @@ static int
ProcShapeCombine (ClientPtr client)
{
WindowPtr pSrcWin, pDestWin;
REQUEST(xShapeCombineReq);
RegionPtr srcRgn;
RegionPtr *destRgn;
@@ -489,7 +498,8 @@ ProcShapeCombine(ClientPtr client)
client->errorValue = stuff->srcKind;
return BadValue;
}
if (pSrcWin->drawable.pScreen != pDestWin->drawable.pScreen) {
if (pSrcWin->drawable.pScreen != pDestWin->drawable.pScreen)
{
return BadMatch;
}
@@ -497,8 +507,7 @@ ProcShapeCombine(ClientPtr client)
tmp = RegionCreate((BoxPtr) 0, 0);
RegionCopy(tmp, srcRgn);
srcRgn = tmp;
}
else
} else
srcRgn = (*createSrc) (pSrcWin);
if (!pDestWin->optional)
@@ -522,9 +531,11 @@ ProcShapeCombine(ClientPtr client)
stuff->xOff, stuff->yOff, createDefault);
}
#ifdef PANORAMIX
static int
ProcPanoramiXShapeCombine(ClientPtr client)
ProcPanoramiXShapeCombine(
ClientPtr client)
{
REQUEST(xShapeCombineReq);
PanoramiXRes *win, *win2;
@@ -532,12 +543,12 @@ ProcPanoramiXShapeCombine(ClientPtr client)
REQUEST_AT_LEAST_SIZE (xShapeCombineReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess);
if (result != Success)
return result;
result = dixLookupResourceByType((void **) &win2, stuff->src, XRT_WINDOW,
result = dixLookupResourceByType((pointer *)&win2, stuff->src, XRT_WINDOW,
client, DixReadAccess);
if (result != Success)
return result;
@@ -546,8 +557,7 @@ ProcPanoramiXShapeCombine(ClientPtr client)
stuff->dest = win->info[j].id;
stuff->src = win2->info[j].id;
result = ProcShapeCombine (client);
if (result != Success)
break;
if (result != Success) break;
}
return result;
}
@@ -561,7 +571,6 @@ static int
ProcShapeOffset (ClientPtr client)
{
WindowPtr pWin;
REQUEST(xShapeOffsetReq);
RegionPtr srcRgn;
int rc;
@@ -585,7 +594,8 @@ ProcShapeOffset(ClientPtr client)
client->errorValue = stuff->destKind;
return BadValue;
}
if (srcRgn) {
if (srcRgn)
{
RegionTranslate(srcRgn, stuff->xOff, stuff->yOff);
(*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind);
}
@@ -593,9 +603,11 @@ ProcShapeOffset(ClientPtr client)
return Success;
}
#ifdef PANORAMIX
static int
ProcPanoramiXShapeOffset(ClientPtr client)
ProcPanoramiXShapeOffset(
ClientPtr client)
{
REQUEST(xShapeOffsetReq);
PanoramiXRes *win;
@@ -603,7 +615,7 @@ ProcPanoramiXShapeOffset(ClientPtr client)
REQUEST_AT_LEAST_SIZE (xShapeOffsetReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess);
if (result != Success)
return result;
@@ -611,13 +623,13 @@ ProcPanoramiXShapeOffset(ClientPtr client)
FOR_NSCREENS(j) {
stuff->dest = win->info[j].id;
result = ProcShapeOffset (client);
if (result != Success)
break;
if(result != Success) break;
}
return result;
}
#endif
static int
ProcShapeQueryExtents (ClientPtr client)
{
@@ -625,26 +637,24 @@ ProcShapeQueryExtents(ClientPtr client)
WindowPtr pWin;
xShapeQueryExtentsReply rep;
BoxRec extents, *pExtents;
int rc;
int n, rc;
RegionPtr region;
REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xShapeQueryExtentsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.boundingShaped = (wBoundingShape(pWin) != 0),
.clipShaped = (wClipShape(pWin) != 0)
};
memset(&rep, 0, sizeof(xShapeQueryExtentsReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.boundingShaped = (wBoundingShape(pWin) != 0);
rep.clipShaped = (wClipShape(pWin) != 0);
if ((region = wBoundingShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = RegionExtents(region);
extents = *pExtents;
}
else {
} else {
extents.x1 = -wBorderWidth (pWin);
extents.y1 = -wBorderWidth (pWin);
extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
@@ -658,8 +668,7 @@ ProcShapeQueryExtents(ClientPtr client)
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = RegionExtents(region);
extents = *pExtents;
}
else {
} else {
extents.x1 = 0;
extents.y1 = 0;
extents.x2 = pWin->drawable.width;
@@ -670,23 +679,24 @@ ProcShapeQueryExtents(ClientPtr client)
rep.widthClipShape = extents.x2 - extents.x1;
rep.heightClipShape = extents.y2 - extents.y1;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.xBoundingShape);
swaps(&rep.yBoundingShape);
swaps(&rep.widthBoundingShape);
swaps(&rep.heightBoundingShape);
swaps(&rep.xClipShape);
swaps(&rep.yClipShape);
swaps(&rep.widthClipShape);
swaps(&rep.heightClipShape);
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.xBoundingShape, n);
swaps(&rep.yBoundingShape, n);
swaps(&rep.widthBoundingShape, n);
swaps(&rep.heightBoundingShape, n);
swaps(&rep.xClipShape, n);
swaps(&rep.yClipShape, n);
swaps(&rep.widthClipShape, n);
swaps(&rep.heightClipShape, n);
}
WriteToClient(client, sizeof(xShapeQueryExtentsReply), &rep);
WriteToClient(client, sizeof (xShapeQueryExtentsReply), (char *)&rep);
return Success;
}
/*ARGSUSED*/ static int
ShapeFreeClient(void *data, XID id)
/*ARGSUSED*/
static int
ShapeFreeClient (pointer data, XID id)
{
ShapeEventPtr pShapeEvent;
WindowPtr pWin;
@@ -695,25 +705,27 @@ ShapeFreeClient(void *data, XID id)
pShapeEvent = (ShapeEventPtr) data;
pWin = pShapeEvent->window;
rc = dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
ShapeEventType, serverClient, DixReadAccess);
if (rc == Success) {
pPrev = 0;
for (pCur = *pHead; pCur && pCur != pShapeEvent; pCur=pCur->next)
pPrev = pCur;
if (pCur) {
if (pCur)
{
if (pPrev)
pPrev->next = pShapeEvent->next;
else
*pHead = pShapeEvent->next;
}
}
free((void *) pShapeEvent);
free((pointer) pShapeEvent);
return 1;
}
/*ARGSUSED*/ static int
ShapeFreeEvents(void *data, XID id)
/*ARGSUSED*/
static int
ShapeFreeEvents (pointer data, XID id)
{
ShapeEventPtr *pHead, pCur, pNext;
@@ -721,9 +733,9 @@ ShapeFreeEvents(void *data, XID id)
for (pCur = *pHead; pCur; pCur = pNext) {
pNext = pCur->next;
FreeResource (pCur->clientResource, ClientType);
free((void *) pCur);
free((pointer) pCur);
}
free((void *) pHead);
free((pointer) pHead);
return 1;
}
@@ -740,7 +752,7 @@ ProcShapeSelectInput(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success)
return rc;
rc = dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
ShapeEventType, client, DixWriteAccess);
if (rc != Success && rc != BadValue)
return rc;
@@ -751,7 +763,9 @@ ProcShapeSelectInput(ClientPtr client)
/* check for existing entry. */
for (pShapeEvent = *pHead;
pShapeEvent; pShapeEvent = pShapeEvent->next) {
pShapeEvent;
pShapeEvent = pShapeEvent->next)
{
if (pShapeEvent->client == client)
return Success;
}
@@ -770,19 +784,20 @@ ProcShapeSelectInput(ClientPtr client)
*/
clientResource = FakeClientID (client->index);
pNewShapeEvent->clientResource = clientResource;
if (!AddResource(clientResource, ClientType, (void *) pNewShapeEvent))
if (!AddResource (clientResource, ClientType, (pointer)pNewShapeEvent))
return BadAlloc;
/*
* create a resource to contain a void *to the list
* create a resource to contain a pointer to the list
* of clients selecting input. This must be indirect as
* the list may be arbitrarily rearranged which cannot be
* done through the resource database.
*/
if (!pHead) {
if (!pHead)
{
pHead = malloc(sizeof (ShapeEventPtr));
if (!pHead ||
!AddResource(pWin->drawable.id, ShapeEventType,
(void *) pHead)) {
!AddResource (pWin->drawable.id, ShapeEventType, (pointer)pHead))
{
FreeResource (clientResource, RT_NONE);
return BadAlloc;
}
@@ -795,8 +810,7 @@ ProcShapeSelectInput(ClientPtr client)
/* delete the interest */
if (pHead) {
pNewShapeEvent = 0;
for (pShapeEvent = *pHead; pShapeEvent;
pShapeEvent = pShapeEvent->next) {
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
if (pShapeEvent->client == client)
break;
pNewShapeEvent = pShapeEvent;
@@ -826,12 +840,13 @@ void
SendShapeNotify (WindowPtr pWin, int which)
{
ShapeEventPtr *pHead, pShapeEvent;
xShapeNotifyEvent se;
BoxRec extents;
RegionPtr region;
BYTE shaped;
int rc;
rc = dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
ShapeEventType, serverClient, DixReadAccess);
if (rc != Success)
return;
@@ -841,8 +856,7 @@ SendShapeNotify(WindowPtr pWin, int which)
if (region) {
extents = *RegionExtents(region);
shaped = xTrue;
}
else {
} else {
extents.x1 = -wBorderWidth (pWin);
extents.y1 = -wBorderWidth (pWin);
extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
@@ -855,8 +869,7 @@ SendShapeNotify(WindowPtr pWin, int which)
if (region) {
extents = *RegionExtents(region);
shaped = xTrue;
}
else {
} else {
extents.x1 = 0;
extents.y1 = 0;
extents.x2 = pWin->drawable.width;
@@ -869,8 +882,7 @@ SendShapeNotify(WindowPtr pWin, int which)
if (region) {
extents = *RegionExtents(region);
shaped = xTrue;
}
else {
} else {
extents.x1 = -wBorderWidth (pWin);
extents.y1 = -wBorderWidth (pWin);
extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
@@ -881,19 +893,16 @@ SendShapeNotify(WindowPtr pWin, int which)
default:
return;
}
UpdateCurrentTimeIf();
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
xShapeNotifyEvent se = {
.type = ShapeNotify + ShapeEventBase,
.kind = which,
.window = pWin->drawable.id,
.x = extents.x1,
.y = extents.y1,
.width = extents.x2 - extents.x1,
.height = extents.y2 - extents.y1,
.time = currentTime.milliseconds,
.shaped = shaped
};
se.type = ShapeNotify + ShapeEventBase;
se.kind = which;
se.window = pWin->drawable.id;
se.x = extents.x1;
se.y = extents.y1;
se.width = extents.x2 - extents.x1;
se.height = extents.y2 - extents.y1;
se.time = currentTime.milliseconds;
se.shaped = shaped;
WriteEventsToClient (pShapeEvent->client, 1, (xEvent *) &se);
}
}
@@ -906,35 +915,37 @@ ProcShapeInputSelected(ClientPtr client)
ShapeEventPtr pShapeEvent, *pHead;
int enabled, rc;
xShapeInputSelectedReply rep;
int n;
REQUEST_SIZE_MATCH (xShapeInputSelectedReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rc = dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
ShapeEventType, client, DixReadAccess);
if (rc != Success && rc != BadValue)
return rc;
enabled = xFalse;
if (pHead) {
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
for (pShapeEvent = *pHead;
pShapeEvent;
pShapeEvent = pShapeEvent->next)
{
if (pShapeEvent->client == client) {
enabled = xTrue;
break;
}
}
}
rep = (xShapeInputSelectedReply) {
.type = X_Reply,
.enabled = enabled,
.sequenceNumber = client->sequence,
.length = 0
};
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.enabled = enabled;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
}
WriteToClient(client, sizeof(xShapeInputSelectedReply), &rep);
WriteToClient (client, sizeof (xShapeInputSelectedReply), (char *) &rep);
return Success;
}
@@ -947,6 +958,7 @@ ProcShapeGetRectangles(ClientPtr client)
xRectangle *rects;
int nrects, i, rc;
RegionPtr region;
int n;
REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
@@ -991,13 +1003,11 @@ ProcShapeGetRectangles(ClientPtr client)
rects->height = pWin->drawable.height + wBorderWidth (pWin);
break;
}
}
else {
} else {
BoxPtr box;
nrects = RegionNumRects(region);
box = RegionRects(region);
rects = xallocarray(nrects, sizeof(xRectangle));
rects = malloc(nrects * sizeof (xRectangle));
if (!rects && nrects)
return BadAlloc;
for (i = 0; i < nrects; i++, box++) {
@@ -1007,21 +1017,19 @@ ProcShapeGetRectangles(ClientPtr client)
rects[i].height = box->y2 - box->y1;
}
}
rep = (xShapeGetRectanglesReply) {
.type = X_Reply,
.ordering = YXBanded,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(nrects * sizeof(xRectangle)),
.nrects = nrects
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = bytes_to_int32(nrects * sizeof (xRectangle));
rep.ordering = YXBanded;
rep.nrects = nrects;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.nrects);
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.nrects, n);
SwapShorts ((short *)rects, (unsigned long)nrects * 4);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, nrects * sizeof(xRectangle), rects);
WriteToClient (client, sizeof (rep), (char *) &rep);
WriteToClient (client, nrects * sizeof (xRectangle), (char *) rects);
free(rects);
return Success;
}
@@ -1074,7 +1082,7 @@ ProcShapeDispatch(ClientPtr client)
}
}
static void _X_COLD
static void
SShapeNotifyEvent(xShapeNotifyEvent *from, xShapeNotifyEvent *to)
{
to->type = from->type;
@@ -1089,114 +1097,124 @@ SShapeNotifyEvent(xShapeNotifyEvent * from, xShapeNotifyEvent * to)
to->shaped = from->shaped;
}
static int _X_COLD
static int
SProcShapeQueryVersion (ClientPtr client)
{
int n;
REQUEST (xShapeQueryVersionReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
return ProcShapeQueryVersion (client);
}
static int _X_COLD
static int
SProcShapeRectangles (ClientPtr client)
{
char n;
REQUEST (xShapeRectanglesReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl (&stuff->dest, n);
swaps (&stuff->xOff, n);
swaps (&stuff->yOff, n);
SwapRestS(stuff);
return ProcShapeRectangles (client);
}
static int _X_COLD
static int
SProcShapeMask (ClientPtr client)
{
char n;
REQUEST (xShapeMaskReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xShapeMaskReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl(&stuff->src);
swapl (&stuff->dest, n);
swaps (&stuff->xOff, n);
swaps (&stuff->yOff, n);
swapl (&stuff->src, n);
return ProcShapeMask (client);
}
static int _X_COLD
static int
SProcShapeCombine (ClientPtr client)
{
char n;
REQUEST (xShapeCombineReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xShapeCombineReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl(&stuff->src);
swapl (&stuff->dest, n);
swaps (&stuff->xOff, n);
swaps (&stuff->yOff, n);
swapl (&stuff->src, n);
return ProcShapeCombine (client);
}
static int _X_COLD
static int
SProcShapeOffset (ClientPtr client)
{
char n;
REQUEST (xShapeOffsetReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xShapeOffsetReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl (&stuff->dest, n);
swaps (&stuff->xOff, n);
swaps (&stuff->yOff, n);
return ProcShapeOffset (client);
}
static int _X_COLD
static int
SProcShapeQueryExtents (ClientPtr client)
{
char n;
REQUEST (xShapeQueryExtentsReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
swapl(&stuff->window);
swapl (&stuff->window, n);
return ProcShapeQueryExtents (client);
}
static int _X_COLD
static int
SProcShapeSelectInput (ClientPtr client)
{
char n;
REQUEST (xShapeSelectInputReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xShapeSelectInputReq);
swapl(&stuff->window);
swapl (&stuff->window, n);
return ProcShapeSelectInput (client);
}
static int _X_COLD
static int
SProcShapeInputSelected (ClientPtr client)
{
int n;
REQUEST (xShapeInputSelectedReq);
swaps(&stuff->length);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xShapeInputSelectedReq);
swapl(&stuff->window);
swapl (&stuff->window, n);
return ProcShapeInputSelected (client);
}
static int _X_COLD
static int
SProcShapeGetRectangles (ClientPtr client)
{
REQUEST(xShapeGetRectanglesReq);
swaps(&stuff->length);
char n;
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
swapl(&stuff->window);
swapl (&stuff->window, n);
return ProcShapeGetRectangles (client);
}
static int _X_COLD
static int
SProcShapeDispatch (ClientPtr client)
{
REQUEST(xReq);
@@ -1234,7 +1252,8 @@ ShapeExtensionInit(void)
if (ClientType && ShapeEventType &&
(extEntry = AddExtension(SHAPENAME, ShapeNumberEvents, 0,
ProcShapeDispatch, SProcShapeDispatch,
NULL, StandardMinorOpcode))) {
NULL, StandardMinorOpcode)))
{
ShapeEventBase = extEntry->eventBase;
EventSwapVector[ShapeEventBase] = (EventSwapPtr) SShapeNotifyEvent;
}

File diff suppressed because it is too large Load Diff

View File

@@ -56,30 +56,6 @@ typedef struct _ShmFuncs {
void (* PutImage)(XSHM_PUT_IMAGE_ARGS);
} ShmFuncs, *ShmFuncsPtr;
#if XTRANS_SEND_FDS
#define SHM_FD_PASSING 1
#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
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs);

View File

@@ -45,11 +45,12 @@ typedef struct _Sertafied {
TimeStamp revive;
ClientPtr pClient;
XID id;
void (*notifyFunc) (ClientPtr /* client */ ,
void * /* closure */
void (*notifyFunc)(
ClientPtr /* client */,
pointer /* closure */
);
void *closure;
pointer closure;
} SertafiedRec, *SertafiedPtr;
static SertafiedPtr pPending;
@@ -57,26 +58,35 @@ static RESTYPE SertafiedResType;
static Bool BlockHandlerRegistered;
static int SertafiedGeneration;
static void ClientAwaken(ClientPtr /* client */ ,
void * /* closure */
static void ClientAwaken(
ClientPtr /* client */,
pointer /* closure */
);
static int SertafiedDelete(void * /* value */ ,
static int SertafiedDelete(
pointer /* value */,
XID /* id */
);
static void SertafiedBlockHandler(void *data,
void *timeout);
static void SertafiedWakeupHandler(void *data,
int i);
static void SertafiedBlockHandler(
pointer /* data */,
OSTimePtr /* wt */,
pointer /* LastSelectMask */
);
static void SertafiedWakeupHandler(
pointer /* data */,
int /* i */,
pointer /* LastSelectMask */
);
int
ClientSleepUntil (ClientPtr client,
TimeStamp *revive,
void (*notifyFunc) (ClientPtr, void *), void *closure)
void (*notifyFunc)(ClientPtr, pointer),
pointer closure)
{
SertafiedPtr pRequest, pReq, pPrev;
if (SertafiedGeneration != serverGeneration) {
if (SertafiedGeneration != serverGeneration)
{
SertafiedResType = CreateNewResourceType (SertafiedDelete,
"ClientSleep");
if (!SertafiedResType)
@@ -91,24 +101,27 @@ ClientSleepUntil(ClientPtr client,
pRequest->revive = *revive;
pRequest->id = FakeClientID (client->index);
pRequest->closure = closure;
if (!BlockHandlerRegistered) {
if (!BlockHandlerRegistered)
{
if (!RegisterBlockAndWakeupHandlers (SertafiedBlockHandler,
SertafiedWakeupHandler,
(void *) 0)) {
(pointer) 0))
{
free(pRequest);
return FALSE;
}
BlockHandlerRegistered = TRUE;
}
pRequest->notifyFunc = 0;
if (!AddResource(pRequest->id, SertafiedResType, (void *) pRequest))
if (!AddResource (pRequest->id, SertafiedResType, (pointer) pRequest))
return FALSE;
if (!notifyFunc)
notifyFunc = ClientAwaken;
pRequest->notifyFunc = notifyFunc;
/* Insert into time-ordered queue, with earliest activation time coming first. */
pPrev = 0;
for (pReq = pPending; pReq; pReq = pReq->next) {
for (pReq = pPending; pReq; pReq = pReq->next)
{
if (CompareTimeStamps (pReq->revive, *revive) == LATER)
break;
pPrev = pReq;
@@ -123,21 +136,23 @@ ClientSleepUntil(ClientPtr client,
}
static void
ClientAwaken(ClientPtr client, void *closure)
ClientAwaken (ClientPtr client, pointer closure)
{
if (!client->clientGone)
AttendClient (client);
}
static int
SertafiedDelete(void *value, XID id)
SertafiedDelete (pointer value, XID id)
{
SertafiedPtr pRequest = (SertafiedPtr)value;
SertafiedPtr pReq, pPrev;
pPrev = 0;
for (pReq = pPending; pReq; pPrev = pReq, pReq = pReq->next)
if (pReq == pRequest) {
if (pReq == pRequest)
{
if (pPrev)
pPrev->next = pReq->next;
else
@@ -151,7 +166,7 @@ SertafiedDelete(void *value, XID id)
}
static void
SertafiedBlockHandler(void *data, void *wt)
SertafiedBlockHandler (pointer data, OSTimePtr wt, pointer LastSelectMask)
{
SertafiedPtr pReq, pNext;
unsigned long delay;
@@ -163,7 +178,8 @@ SertafiedBlockHandler(void *data, void *wt)
now.months = currentTime.months;
if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
now.months++;
for (pReq = pPending; pReq; pReq = pNext) {
for (pReq = pPending; pReq; pReq = pNext)
{
pNext = pReq->next;
if (CompareTimeStamps (pReq->revive, now) == LATER)
break;
@@ -183,7 +199,7 @@ SertafiedBlockHandler(void *data, void *wt)
}
static void
SertafiedWakeupHandler(void *data, int i)
SertafiedWakeupHandler (pointer data, int i, pointer LastSelectMask)
{
SertafiedPtr pReq, pNext;
TimeStamp now;
@@ -192,15 +208,18 @@ SertafiedWakeupHandler(void *data, int i)
now.months = currentTime.months;
if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
now.months++;
for (pReq = pPending; pReq; pReq = pNext) {
for (pReq = pPending; pReq; pReq = pNext)
{
pNext = pReq->next;
if (CompareTimeStamps (pReq->revive, now) == LATER)
break;
FreeResource (pReq->id, RT_NONE);
}
if (!pPending) {
if (!pPending)
{
RemoveBlockAndWakeupHandlers (SertafiedBlockHandler,
SertafiedWakeupHandler, (void *) 0);
SertafiedWakeupHandler,
(pointer) 0);
BlockHandlerRegistered = FALSE;
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -44,3 +44,4 @@ extern _X_EXPORT int
} while (0)
#endif /* _SYNCSDK_H_ */

View File

@@ -51,7 +51,6 @@ PERFORMANCE OF THIS SOFTWARE.
#ifndef _SYNCSRV_H_
#define _SYNCSRV_H_
#include "list.h"
#include "misync.h"
#include "misyncstr.h"
@@ -66,27 +65,25 @@ typedef enum {
XSyncCounterUnrestricted
} 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 {
SyncCounter *pCounter;
char *name;
int64_t resolution;
int64_t bracket_greater;
int64_t bracket_less;
CARD64 resolution;
CARD64 bracket_greater;
CARD64 bracket_less;
SyncCounterType counterType; /* how can this counter change */
SyncSystemCounterQueryValue QueryValue;
SyncSystemCounterBracketValues BracketValues;
void *private;
struct xorg_list entry;
void (*QueryValue)(
pointer /*pCounter*/,
CARD64 * /*freshvalue*/
);
void (*BracketValues)(
pointer /*pCounter*/,
CARD64 * /*lessthan*/,
CARD64 * /*greaterthan*/
);
} SysCounterInfo;
typedef struct _SyncAlarmClientList {
ClientPtr client;
XID delete_id;
@@ -97,7 +94,7 @@ typedef struct _SyncAlarm {
SyncTrigger trigger;
ClientPtr client;
XSyncAlarm alarm_id;
int64_t delta;
CARD64 delta;
int events;
int state;
SyncAlarmClientList *pEventClients;
@@ -111,7 +108,7 @@ typedef struct {
typedef struct {
SyncTrigger trigger;
int64_t event_threshold;
CARD64 event_threshold;
SyncAwaitHeader *pHeader;
} SyncAwait;
@@ -120,32 +117,30 @@ typedef union {
SyncAwait await;
} SyncAwaitUnion;
extern SyncCounter* SyncCreateSystemCounter(const char *name,
int64_t initial_value,
int64_t resolution,
SyncCounterType counterType,
SyncSystemCounterQueryValue QueryValue,
SyncSystemCounterBracketValues BracketValues
extern pointer SyncCreateSystemCounter(
char * /* name */,
CARD64 /* inital_value */,
CARD64 /* resolution */,
SyncCounterType /* change characterization */,
void (* /*QueryValue*/ ) (
pointer /* pCounter */,
CARD64 * /* pValue_return */), /* XXX prototype */
void (* /*BracketValues*/) (
pointer /* pCounter */,
CARD64 * /* pbracket_less */,
CARD64 * /* pbracket_greater */)
);
extern void SyncChangeCounter(SyncCounter *pCounter,
int64_t new_value);
extern void SyncChangeCounter(
SyncCounter * /* pCounter*/,
CARD64 /* new_value */
);
extern void SyncDestroySystemCounter(void *pCounter);
extern void SyncDestroySystemCounter(
pointer pCounter
);
extern SyncCounter *SyncInitDeviceIdleTime(DeviceIntPtr dev);
extern void SyncRemoveDeviceIdleTime(SyncCounter *counter);
int
SyncCreateFenceFromFD(ClientPtr client, DrawablePtr pDraw, XID id, int fd, BOOL initially_triggered);
int
SyncFDFromFence(ClientPtr client, DrawablePtr pDraw, SyncFence *fence);
void
SyncDeleteTriggerFromSyncObject(SyncTrigger * pTrigger);
int
SyncAddTriggerToSyncObject(SyncTrigger * pTrigger);
extern void InitServertime(void);
extern void SyncExtensionInit(void);
#endif /* _SYNCSRV_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -29,25 +29,38 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "gcstruct.h"
#include "xacestr.h"
#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.
*/
#undef XaceHookDispatch
int
XaceHookDispatch(ClientPtr client, int major)
int XaceHookDispatch(ClientPtr client, int major)
{
/* Call the audit begin callback, there is no return value. */
XaceAuditRec rec = { client, 0 };
CallCallbacks(&XaceHooks[XACE_AUDIT_BEGIN], &rec);
if (major < 128) {
/* Call the core dispatch hook */
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 erec = { client, ext, DixUseAccess, Success };
XaceExtAccessRec rec = { client, ext, DixUseAccess, Success };
if (ext)
CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &erec);
CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &rec);
/* On error, pretend extension doesn't exist */
return (erec.status == Success) ? Success : BadRequest;
return (rec.status == Success) ? Success : BadRequest;
}
}
int
XaceHookPropertyAccess(ClientPtr client, WindowPtr pWin,
int XaceHookPropertyAccess(ClientPtr client, WindowPtr pWin,
PropertyPtr *ppProp, Mask access_mode)
{
XacePropertyAccessRec rec = { client, pWin, ppProp, access_mode, Success };
@@ -55,18 +68,24 @@ XaceHookPropertyAccess(ClientPtr client, WindowPtr pWin,
return rec.status;
}
int
XaceHookSelectionAccess(ClientPtr client, Selection ** ppSel, Mask access_mode)
int XaceHookSelectionAccess(ClientPtr client,
Selection **ppSel, Mask access_mode)
{
XaceSelectionAccessRec rec = { client, ppSel, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_SELECTION_ACCESS], &rec);
return rec.status;
}
void XaceHookAuditEnd(ClientPtr ptr, int result)
{
XaceAuditRec rec = { ptr, result };
/* call callbacks, there is no return value. */
CallCallbacks(&XaceHooks[XACE_AUDIT_END], &rec);
}
/* Entry point for hook functions. Called by Xserver.
*/
int
XaceHook(int hook, ...)
int XaceHook(int hook, ...)
{
union {
XaceResourceAccessRec res;
@@ -93,16 +112,16 @@ XaceHook(int hook, ...)
* the arguments and integer return parameter, or in some cases just
* sets calldata directly to a single argument (with no return result)
*/
switch (hook) {
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, void *);
u.res.res = va_arg(ap, pointer);
u.res.ptype = va_arg(ap, RESTYPE);
u.res.parent = va_arg(ap, void *);
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;
@@ -110,7 +129,6 @@ XaceHook(int hook, ...)
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;
@@ -118,20 +136,16 @@ XaceHook(int hook, ...)
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;
@@ -139,13 +153,11 @@ XaceHook(int hook, ...)
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 */
@@ -154,7 +166,6 @@ XaceHook(int hook, ...)
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;
@@ -163,20 +174,17 @@ XaceHook(int hook, ...)
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);
@@ -189,21 +197,6 @@ XaceHook(int hook, ...)
return prv ? *prv : 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
XaceHookIsSet(int hook)
{
if (hook < 0 || hook >= XACE_NUM_HOOKS)
return 0;
return XaceHooks[hook] != NULL;
}
/* XaceCensorImage
*
* Called after pScreen->GetImage to prevent pieces or trusted windows from
@@ -225,28 +218,32 @@ XaceHookIsSet(int hook)
* region of the window will be destroyed (overwritten) in pBuf.
*/
void
XaceCensorImage(ClientPtr client,
XaceCensorImage(
ClientPtr client,
RegionPtr pVisibleRegion,
long widthBytesLine,
DrawablePtr pDraw,
int x, int y, int w, int h, unsigned int format, char *pBuf)
int x, int y, int w, int h,
unsigned int format,
char *pBuf)
{
RegionRec imageRegion; /* region representing x,y,w,h */
RegionRec censorRegion; /* region to obliterate */
BoxRec imageBox;
int nRects;
imageBox.x1 = pDraw->x + x;
imageBox.y1 = pDraw->y + y;
imageBox.x2 = pDraw->x + x + w;
imageBox.y2 = pDraw->y + y + h;
imageBox.x1 = x;
imageBox.y1 = y;
imageBox.x2 = x + w;
imageBox.y2 = y + h;
RegionInit(&imageRegion, &imageBox, 1);
RegionNull(&censorRegion);
/* censorRegion = imageRegion - visibleRegion */
RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion);
nRects = RegionNumRects(&censorRegion);
if (nRects > 0) { /* we have something to censor */
if (nRects > 0)
{ /* we have something to censor */
GCPtr pScratchGC = NULL;
PixmapPtr pPix = NULL;
xRectangle *pRects = NULL;
@@ -259,12 +256,16 @@ XaceCensorImage(ClientPtr client,
/* convert region to list-of-rectangles for PolyFillRect */
pRects = malloc(nRects * sizeof(xRectangle));
if (!pRects) {
if (!pRects)
{
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;
i < nRects;
i++, pBox++)
{
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;
@@ -272,21 +273,24 @@ XaceCensorImage(ClientPtr client,
/* use pBuf as a fake pixmap */
if (format == ZPixmap) {
if (format == ZPixmap)
{
depth = pDraw->depth;
bitsPerPixel = pDraw->bitsPerPixel;
}
pPix = GetScratchPixmapHeader(pDraw->pScreen, w, h,
depth, bitsPerPixel,
widthBytesLine, (void *) pBuf);
if (!pPix) {
widthBytesLine, (pointer)pBuf);
if (!pPix)
{
failed = TRUE;
goto failSafe;
}
pScratchGC = GetScratchGC(depth, pPix->drawable.pScreen);
if (!pScratchGC) {
if (!pScratchGC)
{
failed = TRUE;
goto failSafe;
}
@@ -296,17 +300,16 @@ XaceCensorImage(ClientPtr client,
pScratchGC, nRects, pRects);
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.
*/
memset(pBuf, 0, (int)(widthBytesLine * h));
}
free(pRects);
if (pScratchGC)
FreeScratchGC(pScratchGC);
if (pPix)
FreeScratchPixmapHeader(pPix);
if (pScratchGC) FreeScratchGC(pScratchGC);
if (pPix) FreeScratchPixmapHeader(pPix);
}
RegionUninit(&imageRegion);
RegionUninit(&censorRegion);
@@ -315,14 +318,14 @@ XaceCensorImage(ClientPtr client,
/*
* Xtrans wrappers for use by modules
*/
int
XaceGetConnectionNumber(ClientPtr client)
int XaceGetConnectionNumber(ClientPtr client)
{
return GetClientFd(client);
XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn;
return _XSERVTransGetConnectionNumber(ci);
}
int
XaceIsLocal(ClientPtr client)
int XaceIsLocal(ClientPtr client)
{
return ClientIsLocal(client);
XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn;
return _XSERVTransIsLocal(ci);
}

View File

@@ -52,33 +52,28 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_SCREENSAVER_ACCESS 12
#define XACE_AUTH_AVAIL 13
#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];
/* Entry point for hook functions. Called by Xserver.
* Required by libdbe and libextmod
*/
extern _X_EXPORT int XaceHook(int /*hook */ ,
extern _X_EXPORT int XaceHook(
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
*/
extern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major);
#define XaceHookDispatch(c, m) \
((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \
XaceHookDispatch((c), (m)) : \
Success)
extern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin,
PropertyPtr *ppProp,
Mask access_mode);
extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel,
Mask access_mode);
PropertyPtr *ppProp, Mask access_mode);
extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr,
Selection **ppSel, Mask access_mode);
extern _X_EXPORT void XaceHookAuditEnd(ClientPtr ptr, int result);
/* Register a callback for a given hook.
*/
@@ -98,12 +93,15 @@ extern _X_EXPORT int XaceIsLocal(ClientPtr ptr);
/* From the original Security extension...
*/
extern _X_EXPORT void XaceCensorImage(ClientPtr client,
extern _X_EXPORT void XaceCensorImage(
ClientPtr client,
RegionPtr pVisibleRegion,
long widthBytesLine,
DrawablePtr pDraw,
int x, int y, int w, int h,
unsigned int format, char *pBuf);
unsigned int format,
char * pBuf
);
#else /* XACE */
@@ -114,17 +112,17 @@ extern _X_EXPORT void XaceCensorImage(ClientPtr client,
#ifdef __GNUC__
#define XaceHook(args...) Success
#define XaceHookIsSet(args...) 0
#define XaceHookDispatch(args...) Success
#define XaceHookPropertyAccess(args...) Success
#define XaceHookSelectionAccess(args...) Success
#define XaceHookAuditEnd(args...) { ; }
#define XaceCensorImage(args...) { ; }
#else
#define XaceHook(...) Success
#define XaceHookIsSet(...) 0
#define XaceHookDispatch(...) Success
#define XaceHookPropertyAccess(...) Success
#define XaceHookSelectionAccess(...) Success
#define XaceHookAuditEnd(...) { ; }
#define XaceCensorImage(...) { ; }
#endif

View File

@@ -40,9 +40,9 @@ typedef struct {
ClientPtr client;
XID id;
RESTYPE rtype;
void *res;
pointer res;
RESTYPE ptype;
void *parent;
pointer parent;
Mask access_mode;
int status;
} XaceResourceAccessRec;

View File

@@ -38,29 +38,33 @@ from The Open Group.
#include "extnsionst.h"
#include "swaprep.h"
#include <X11/extensions/xcmiscproto.h>
#include "extinit.h"
#include "modinit.h"
#if HAVE_STDINT_H
#include <stdint.h>
#elif !defined(UINT32_MAX)
#define UINT32_MAX 0xffffffffU
#endif
static int
ProcXCMiscGetVersion(ClientPtr client)
{
xXCMiscGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = XCMiscMajorVersion,
.minorVersion = XCMiscMinorVersion
};
xXCMiscGetVersionReply rep;
int n;
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XCMiscMajorVersion;
rep.minorVersion = XCMiscMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swaps(&rep.sequenceNumber, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xXCMiscGetVersionReply), &rep);
WriteToClient(client, sizeof(xXCMiscGetVersionReply), (char *)&rep);
return Success;
}
@@ -68,23 +72,22 @@ static int
ProcXCMiscGetXIDRange(ClientPtr client)
{
xXCMiscGetXIDRangeReply rep;
int n;
XID min_id, max_id;
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
GetXIDRange(client->index, FALSE, &min_id, &max_id);
rep = (xXCMiscGetXIDRangeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.start_id = min_id,
.count = max_id - min_id + 1
};
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.start_id = min_id;
rep.count = max_id - min_id + 1;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.start_id);
swapl(&rep.count);
swaps(&rep.sequenceNumber, n);
swapl(&rep.start_id, n);
swapl(&rep.count, n);
}
WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), &rep);
WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), (char *)&rep);
return Success;
}
@@ -93,6 +96,7 @@ ProcXCMiscGetXIDList(ClientPtr client)
{
REQUEST(xXCMiscGetXIDListReq);
xXCMiscGetXIDListReply rep;
int n;
XID *pids;
unsigned int count;
@@ -101,24 +105,24 @@ ProcXCMiscGetXIDList(ClientPtr client)
if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc;
pids = xallocarray(stuff->count, sizeof(XID));
if (!pids) {
pids = (XID *)malloc(stuff->count * sizeof(XID));
if (!pids)
{
return BadAlloc;
}
count = GetXIDList(client, stuff->count, pids);
rep = (xXCMiscGetXIDListReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = count,
.count = count
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = count;
rep.count = count;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.count);
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.count, n);
}
WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep);
if (count) {
WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *)&rep);
if (count)
{
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
}
@@ -130,7 +134,8 @@ static int
ProcXCMiscDispatch (ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_XCMiscGetVersion:
return ProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange:
@@ -142,43 +147,46 @@ ProcXCMiscDispatch(ClientPtr client)
}
}
static int _X_COLD
static int
SProcXCMiscGetVersion(ClientPtr client)
{
int n;
REQUEST(xXCMiscGetVersionReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
swaps(&stuff->majorVersion, n);
swaps(&stuff->minorVersion, n);
return ProcXCMiscGetVersion(client);
}
static int _X_COLD
static int
SProcXCMiscGetXIDRange(ClientPtr client)
{
int n;
REQUEST(xReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return ProcXCMiscGetXIDRange(client);
}
static int _X_COLD
static int
SProcXCMiscGetXIDList(ClientPtr client)
{
int n;
REQUEST(xXCMiscGetXIDListReq);
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
swaps(&stuff->length);
swapl(&stuff->count);
swaps(&stuff->length, n);
swapl(&stuff->count, n);
return ProcXCMiscGetXIDList(client);
}
static int _X_COLD
static int
SProcXCMiscDispatch (ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_XCMiscGetVersion:
return SProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange:
@@ -191,7 +199,7 @@ SProcXCMiscDispatch(ClientPtr client)
}
void
XCMiscExtensionInit(void)
XCMiscExtensionInit(INITARGS)
{
AddExtension(XCMiscExtensionName, 0, 0,
ProcXCMiscDispatch, SProcXCMiscDispatch,

View File

@@ -40,6 +40,13 @@
#include <sys/types.h>
#ifdef HAS_SHM
#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2)
/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */
/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers):
Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define
PAGE_SIZE. It is defined in <asm/page.h>. */
#include <asm/page.h>
#endif
#ifdef SVR4
#include <sys/sysmacros.h>
#endif
@@ -64,15 +71,16 @@
#include "gcstruct.h"
#include "dixfontstr.h"
#include "extnsionst.h"
#include "extinit.h"
#include "protocol-versions.h"
#include <X11/extensions/xf86bigfproto.h>
#include "xf86bigfontsrv.h"
static void XF86BigfontResetProc(ExtensionEntry * /* extEntry */
static void XF86BigfontResetProc(
ExtensionEntry * /* extEntry */
);
#ifdef HAS_SHM
/* A random signature, transmitted to the clients so they can verify that the
@@ -89,8 +97,11 @@ static Bool badSysCall = FALSE;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
#include <sys/signal.h>
static void
SigSysHandler(int signo)
SigSysHandler(
int signo)
{
badSysCall = TRUE;
}
@@ -102,19 +113,21 @@ CheckForShmSyscall(void)
int shmid = -1;
/* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
oldHandler = OsSignal(SIGSYS, SigSysHandler);
oldHandler = signal(SIGSYS, SigSysHandler);
badSysCall = FALSE;
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
if (shmid != -1) {
if (shmid != -1)
{
/* Successful allocation - clean up */
shmctl(shmid, IPC_RMID, NULL);
}
else {
else
{
/* Allocation failed */
badSysCall = TRUE;
}
OsSignal(SIGSYS, oldHandler);
signal(SIGSYS, oldHandler);
return !badSysCall;
}
@@ -145,7 +158,8 @@ typedef struct _ShmDesc {
static ShmDescPtr ShmList = (ShmDescPtr) NULL;
static ShmDescPtr
shmalloc(unsigned int size)
shmalloc(
unsigned int size)
{
ShmDescPtr pDesc;
int shmid;
@@ -192,8 +206,7 @@ shmalloc(unsigned int size)
pDesc->shmid = shmid;
pDesc->attach_addr = addr;
if (ShmList)
ShmList->prev = &pDesc->next;
if (ShmList) ShmList->prev = &pDesc->next;
pDesc->next = ShmList;
pDesc->prev = &ShmList;
ShmList = pDesc;
@@ -202,15 +215,15 @@ shmalloc(unsigned int size)
}
static void
shmdealloc(ShmDescPtr pDesc)
shmdealloc(
ShmDescPtr pDesc)
{
#ifndef EARLY_REMOVE
shmctl(pDesc->shmid, IPC_RMID, (void *) 0);
#endif
shmdt(pDesc->attach_addr);
if (pDesc->next)
pDesc->next->prev = pDesc->prev;
if (pDesc->next) pDesc->next->prev = pDesc->prev;
*pDesc->prev = pDesc->next;
free(pDesc);
}
@@ -219,7 +232,8 @@ shmdealloc(ShmDescPtr pDesc)
/* Called when a font is closed. */
void
XF86BigfontFreeFontShm(FontPtr pFont)
XF86BigfontFreeFontShm(
FontPtr pFont)
{
#ifdef HAS_SHM
ShmDescPtr pDesc;
@@ -248,7 +262,8 @@ XF86BigfontCleanup(void)
/* Called when a server generation dies. */
static void
XF86BigfontResetProc(ExtensionEntry * extEntry)
XF86BigfontResetProc(
ExtensionEntry* extEntry)
{
/* This function is normally called from CloseDownExtensions(), called
* from main(). It will be followed by a call to FreeAllResources(),
@@ -261,53 +276,62 @@ XF86BigfontResetProc(ExtensionEntry * extEntry)
XF86BigfontCleanup();
}
/* ========== Handling of extension specific requests ========== */
static int
ProcXF86BigfontQueryVersion(ClientPtr client)
ProcXF86BigfontQueryVersion(
ClientPtr client)
{
xXF86BigfontQueryVersionReply reply;
REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
reply = (xXF86BigfontQueryVersionReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION,
.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION,
.uid = geteuid(),
.gid = getegid(),
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION;
reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION;
reply.uid = geteuid();
reply.gid = getegid();
#ifdef HAS_SHM
.signature = signature,
.capabilities = (client->local && !client->swapped)
? XF86Bigfont_CAP_LocalShm : 0
reply.signature = signature;
#else
.signature = 0,
.capabilities = 0
reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */
#endif
};
reply.capabilities =
#ifdef HAS_SHM
(LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
#else
0
#endif
; /* may add more bits here in future versions */
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swaps(&reply.majorVersion);
swaps(&reply.minorVersion);
swapl(&reply.uid);
swapl(&reply.gid);
swapl(&reply.signature);
char tmp;
swaps(&reply.sequenceNumber, tmp);
swapl(&reply.length, tmp);
swaps(&reply.majorVersion, tmp);
swaps(&reply.minorVersion, tmp);
swapl(&reply.uid, tmp);
swapl(&reply.gid, tmp);
swapl(&reply.signature, tmp);
}
WriteToClient(client, sizeof(xXF86BigfontQueryVersionReply), &reply);
WriteToClient(client,
sizeof(xXF86BigfontQueryVersionReply), (char *)&reply);
return Success;
}
static void
swapCharInfo(xCharInfo * pCI)
swapCharInfo(
xCharInfo *pCI)
{
swaps(&pCI->leftSideBearing);
swaps(&pCI->rightSideBearing);
swaps(&pCI->characterWidth);
swaps(&pCI->ascent);
swaps(&pCI->descent);
swaps(&pCI->attributes);
char tmp;
swaps(&pCI->leftSideBearing, tmp);
swaps(&pCI->rightSideBearing, tmp);
swaps(&pCI->characterWidth, tmp);
swaps(&pCI->ascent, tmp);
swaps(&pCI->descent, tmp);
swaps(&pCI->attributes, tmp);
}
/* static CARD32 hashCI (xCharInfo *p); */
@@ -318,17 +342,16 @@ swapCharInfo(xCharInfo * pCI)
(p->ascent << 11) + (p->descent << 6)) ^ p->attributes)
static int
ProcXF86BigfontQueryFont(ClientPtr client)
ProcXF86BigfontQueryFont(
ClientPtr client)
{
FontPtr pFont;
REQUEST(xXF86BigfontQueryFontReq);
CARD32 stuff_flags;
xCharInfo* pmax;
xCharInfo* pmin;
int nCharInfos;
int shmid;
#ifdef HAS_SHM
ShmDescPtr pDesc = NULL;
#else
@@ -344,8 +367,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
#else
switch (client->req_len) {
case 2: /* client with version 1.0 libX11 */
stuff_flags = (client->local &&
!client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
break;
case 3: /* client with version 1.1 libX11 */
stuff_flags = stuff->flags;
@@ -354,8 +376,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
return BadLength;
}
#endif
if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) !=
Success)
if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success)
return BadFont; /* procotol spec says only error is BadFont */
pmax = FONTINKMAX(pFont);
@@ -381,18 +402,16 @@ ProcXF86BigfontQueryFont(ClientPtr client)
pCI = (xCharInfo *) pDesc->attach_addr;
if (stuff_flags & XF86Bigfont_FLAGS_Shm)
shmid = pDesc->shmid;
}
else {
} else {
if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
+ sizeof(CARD32));
if (pDesc) {
pCI = (xCharInfo *) pDesc->attach_addr;
shmid = pDesc->shmid;
}
else {
} else {
#endif
pCI = xallocarray(nCharInfos, sizeof(xCharInfo));
pCI = malloc(nCharInfos * sizeof(xCharInfo));
if (!pCI)
return BadAlloc;
#ifdef HAS_SHM
@@ -404,18 +423,18 @@ ProcXF86BigfontQueryFont(ClientPtr client)
int ninfos = 0;
int ncols = pFont->info.lastCol - pFont->info.firstCol + 1;
int row;
for (row = pFont->info.firstRow;
row <= pFont->info.lastRow && ninfos < nCharInfos; row++) {
row <= pFont->info.lastRow && ninfos < nCharInfos;
row++) {
unsigned char chars[512];
xCharInfo* tmpCharInfos[256];
unsigned long count;
int col;
unsigned long i;
i = 0;
for (col = pFont->info.firstCol;
col <= pFont->info.lastCol; col++) {
col <= pFont->info.lastCol;
col++) {
chars[i++] = row;
chars[i++] = col;
}
@@ -430,7 +449,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
#ifdef HAS_SHM
if (pDesc && !badSysCall) {
*(CARD32 *)(pCI + nCharInfos) = signature;
if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) {
if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
shmdealloc(pDesc);
return BadAlloc;
}
@@ -454,10 +473,9 @@ ProcXF86BigfontQueryFont(ClientPtr client)
if (hashModulus > nCharInfos+1)
hashModulus = nCharInfos+1;
tmp = xallocarray(4 * nCharInfos + 1, sizeof(CARD16));
tmp = malloc((4*nCharInfos+1) * sizeof(CARD16));
if (!tmp) {
if (!pDesc)
free(pCI);
if (!pDesc) free(pCI);
return BadAlloc;
}
pIndex2UniqIndex = tmp;
@@ -481,9 +499,9 @@ ProcXF86BigfontQueryFont(ClientPtr client)
for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) {
xCharInfo* p = &pCI[NextIndex];
CARD32 hashCode = hashCI(p) % hashModulus;
for (i = pHash2UniqIndex[hashCode];
i != (CARD16) (-1); i = pUniqIndex2NextUniqIndex[i]) {
i != (CARD16)(-1);
i = pUniqIndex2NextUniqIndex[i]) {
j = pUniqIndex2Index[i];
if (pCI[j].leftSideBearing == p->leftSideBearing
&& pCI[j].rightSideBearing == p->rightSideBearing
@@ -496,8 +514,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
if (i != (CARD16)(-1)) {
/* Found *p at Index j, UniqIndex i */
pIndex2UniqIndex[NextIndex] = i;
}
else {
} else {
/* Allocate a new entry in the Uniq table */
if (hashModulus <= 2*NextUniqIndex
&& hashModulus < nCharInfos+1) {
@@ -513,8 +530,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
j = pUniqIndex2Index[i];
p = &pCI[j];
hashCode = hashCI(p) % hashModulus;
pUniqIndex2NextUniqIndex[i] =
pHash2UniqIndex[hashCode];
pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
pHash2UniqIndex[hashCode] = i;
}
p = &pCI[NextIndex];
@@ -534,21 +550,19 @@ ProcXF86BigfontQueryFont(ClientPtr client)
{
int nfontprops = pFont->info.nprops;
int rlength = sizeof(xXF86BigfontQueryFontReply)
int rlength =
sizeof(xXF86BigfontQueryFontReply)
+ nfontprops * sizeof(xFontProp)
+ (nCharInfos > 0 && shmid == -1
? nUniqCharInfos * sizeof(xCharInfo)
+ (nCharInfos+1)/2 * 2 * sizeof(CARD16)
: 0);
xXF86BigfontQueryFontReply *reply = calloc(1, rlength);
xXF86BigfontQueryFontReply* reply = malloc(rlength);
char* p;
if (!reply) {
if (nCharInfos > 0) {
if (shmid == -1)
free(pIndex2UniqIndex);
if (!pDesc)
free(pCI);
if (shmid == -1) free(pIndex2UniqIndex);
if (!pDesc) free(pCI);
}
return BadAlloc;
}
@@ -572,34 +586,36 @@ ProcXF86BigfontQueryFont(ClientPtr client)
reply->shmid = shmid;
reply->shmsegoffset = 0;
if (client->swapped) {
swaps(&reply->sequenceNumber);
swapl(&reply->length);
char tmp;
swaps(&reply->sequenceNumber, tmp);
swapl(&reply->length, tmp);
swapCharInfo(&reply->minBounds);
swapCharInfo(&reply->maxBounds);
swaps(&reply->minCharOrByte2);
swaps(&reply->maxCharOrByte2);
swaps(&reply->defaultChar);
swaps(&reply->nFontProps);
swaps(&reply->fontAscent);
swaps(&reply->fontDescent);
swapl(&reply->nCharInfos);
swapl(&reply->nUniqCharInfos);
swapl(&reply->shmid);
swapl(&reply->shmsegoffset);
swaps(&reply->minCharOrByte2, tmp);
swaps(&reply->maxCharOrByte2, tmp);
swaps(&reply->defaultChar, tmp);
swaps(&reply->nFontProps, tmp);
swaps(&reply->fontAscent, tmp);
swaps(&reply->fontDescent, tmp);
swapl(&reply->nCharInfos, tmp);
swapl(&reply->nUniqCharInfos, tmp);
swapl(&reply->shmid, tmp);
swapl(&reply->shmsegoffset, tmp);
}
p = (char*) &reply[1];
{
FontPropPtr pFP;
xFontProp* prFP;
int i;
for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p;
i < nfontprops; i++, pFP++, prFP++) {
i < nfontprops;
i++, pFP++, prFP++) {
prFP->name = pFP->name;
prFP->value = pFP->value;
if (client->swapped) {
swapl(&prFP->name);
swapl(&prFP->value);
char tmp;
swapl(&prFP->name, tmp);
swapl(&prFP->value, tmp);
}
}
p = (char*) prFP;
@@ -608,7 +624,6 @@ ProcXF86BigfontQueryFont(ClientPtr client)
xCharInfo* pci;
CARD16* ps;
int i, j;
pci = (xCharInfo*) p;
for (i = 0; i < nUniqCharInfos; i++, pci++) {
*pci = pCI[pUniqIndex2Index[i]];
@@ -619,24 +634,24 @@ ProcXF86BigfontQueryFont(ClientPtr client)
for (j = 0; j < nCharInfos; j++, ps++) {
*ps = pIndex2UniqIndex[j];
if (client->swapped) {
swaps(ps);
char tmp;
swaps(ps, tmp);
}
}
}
WriteToClient(client, rlength, reply);
WriteToClient(client, rlength, (char *)reply);
free(reply);
if (nCharInfos > 0) {
if (shmid == -1)
free(pIndex2UniqIndex);
if (!pDesc)
free(pCI);
if (shmid == -1) free(pIndex2UniqIndex);
if (!pDesc) free(pCI);
}
return Success;
}
}
static int
ProcXF86BigfontDispatch(ClientPtr client)
ProcXF86BigfontDispatch(
ClientPtr client)
{
REQUEST(xReq);
@@ -650,28 +665,33 @@ ProcXF86BigfontDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcXF86BigfontQueryVersion(ClientPtr client)
static int
SProcXF86BigfontQueryVersion(
ClientPtr client)
{
REQUEST(xXF86BigfontQueryVersionReq);
char tmp;
swaps(&stuff->length);
swaps(&stuff->length, tmp);
return ProcXF86BigfontQueryVersion(client);
}
static int _X_COLD
SProcXF86BigfontQueryFont(ClientPtr client)
static int
SProcXF86BigfontQueryFont(
ClientPtr client)
{
REQUEST(xXF86BigfontQueryFontReq);
char tmp;
swaps(&stuff->length);
swaps(&stuff->length, tmp);
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
swapl(&stuff->id);
swapl(&stuff->id, tmp);
return ProcXF86BigfontQueryFont(client);
}
static int _X_COLD
SProcXF86BigfontDispatch(ClientPtr client)
static int
SProcXF86BigfontDispatch(
ClientPtr client)
{
REQUEST(xReq);
@@ -693,7 +713,8 @@ XFree86BigfontExtensionInit(void)
XF86BigfontNumberErrors,
ProcXF86BigfontDispatch,
SProcXF86BigfontDispatch,
XF86BigfontResetProc, StandardMinorOpcode)) {
XF86BigfontResetProc,
StandardMinorOpcode)) {
#ifdef HAS_SHM
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
/*
@@ -703,8 +724,7 @@ XFree86BigfontExtensionInit(void)
* when shared memory support is not functional.
*/
if (!CheckForShmSyscall()) {
ErrorF(XF86BIGFONTNAME
" extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
return;
}
#endif
@@ -714,7 +734,7 @@ XFree86BigfontExtensionInit(void)
+ (unsigned int) (65536.0/(RAND_MAX+1.0) * rand());
/* fprintf(stderr, "signature = 0x%08X\n", signature); */
FontShmdescIndex = xfont2_allocate_font_private_index();
FontShmdescIndex = AllocateFontPrivateIndex();
#if !defined(CSRG_BASED) && !defined(__CYGWIN__)
pagesize = SHMLBA;

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "windowstr.h"
#include "propertyst.h"
#include "extnsionst.h"
#include "extinit.h"
#include "modinit.h"
#include "xselinuxint.h"
#define CTX_DEV offsetof(SELinuxSubjectRec, dev_create_sid)
@@ -44,6 +44,7 @@ typedef struct {
CARD32 id;
} SELinuxListItemRec;
/*
* Extension Dispatch
*/
@@ -52,7 +53,6 @@ static security_context_t
SELinuxCopyContext(char *ptr, unsigned len)
{
security_context_t copy = malloc(len + 1);
if (!copy)
return NULL;
strncpy(copy, ptr, len);
@@ -63,20 +63,21 @@ SELinuxCopyContext(char *ptr, unsigned len)
static int
ProcSELinuxQueryVersion(ClientPtr client)
{
SELinuxQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.server_major = SELINUX_MAJOR_VERSION,
.server_minor = SELINUX_MINOR_VERSION
};
SELinuxQueryVersionReply rep;
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.server_major = SELINUX_MAJOR_VERSION;
rep.server_minor = SELINUX_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
int n;
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.server_major, n);
swaps(&rep.server_minor, n);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, sizeof(rep), (char *)&rep);
return Success;
}
@@ -93,20 +94,19 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
len = strlen(ctx) + 1;
}
rep = (SELinuxGetContextReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(len),
.context_len = len
};
rep.type = X_Reply;
rep.length = bytes_to_int32(len);
rep.sequenceNumber = client->sequence;
rep.context_len = len;
if (client->swapped) {
swapl(&rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.context_len);
int n;
swapl(&rep.length, n);
swaps(&rep.sequenceNumber, n);
swapl(&rep.context_len, n);
}
WriteToClient(client, sizeof(SELinuxGetContextReply), &rep);
WriteToClient(client, sizeof(SELinuxGetContextReply), (char *)&rep);
WriteToClient(client, len, ctx);
freecon(ctx);
return Success;
@@ -245,7 +245,7 @@ ProcSELinuxGetDrawableContext(ClientPtr client)
}
static int
ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
ProcSELinuxGetPropertyContext(ClientPtr client, pointer privKey)
{
WindowPtr pWin;
PropertyPtr pProp;
@@ -269,7 +269,7 @@ ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
}
static int
ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
ProcSELinuxGetSelectionContext(ClientPtr client, pointer privKey)
{
Selection *pSel;
SELinuxObjectRec *obj;
@@ -328,7 +328,6 @@ static void
SELinuxFreeItems(SELinuxListItemRec *items, int count)
{
int k;
for (k = 0; k < count; k++) {
freecon(items[k].octx);
freecon(items[k].dctx);
@@ -340,7 +339,7 @@ static int
SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec *items,
int size, int count)
{
int rc, k, pos = 0;
int rc, k, n, pos = 0;
SELinuxListItemsReply rep;
CARD32 *buf;
@@ -354,17 +353,17 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
for (k = 0; k < count; k++) {
buf[pos] = items[k].id;
if (client->swapped)
swapl(buf + pos);
swapl(buf + pos, n);
pos++;
buf[pos] = items[k].octx_len * 4;
if (client->swapped)
swapl(buf + pos);
swapl(buf + pos, n);
pos++;
buf[pos] = items[k].dctx_len * 4;
if (client->swapped)
swapl(buf + pos);
swapl(buf + pos, n);
pos++;
memcpy((char *)(buf + pos), items[k].octx, strlen(items[k].octx) + 1);
@@ -374,21 +373,19 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
}
/* Send reply to client */
rep = (SELinuxListItemsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = size,
.count = count
};
rep.type = X_Reply;
rep.length = size;
rep.sequenceNumber = client->sequence;
rep.count = count;
if (client->swapped) {
swapl(&rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.count);
swapl(&rep.length, n);
swaps(&rep.sequenceNumber, n);
swapl(&rep.count, n);
}
WriteToClient(client, sizeof(SELinuxListItemsReply), &rep);
WriteToClient(client, size * 4, buf);
WriteToClient(client, sizeof(SELinuxListItemsReply), (char *)&rep);
WriteToClient(client, size * 4, (char *)buf);
/* Free stuff and return */
rc = Success;
@@ -528,100 +525,109 @@ ProcSELinuxDispatch(ClientPtr client)
}
}
static int _X_COLD
static int
SProcSELinuxQueryVersion(ClientPtr client)
{
return ProcSELinuxQueryVersion(client);
}
static int _X_COLD
static int
SProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
{
REQUEST(SELinuxSetCreateContextReq);
int n;
REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq);
swapl(&stuff->context_len);
swapl(&stuff->context_len, n);
return ProcSELinuxSetCreateContext(client, offset);
}
static int _X_COLD
static int
SProcSELinuxSetDeviceContext(ClientPtr client)
{
REQUEST(SELinuxSetContextReq);
int n;
REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq);
swapl(&stuff->id);
swapl(&stuff->context_len);
swapl(&stuff->id, n);
swapl(&stuff->context_len, n);
return ProcSELinuxSetDeviceContext(client);
}
static int _X_COLD
static int
SProcSELinuxGetDeviceContext(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
swapl(&stuff->id, n);
return ProcSELinuxGetDeviceContext(client);
}
static int _X_COLD
static int
SProcSELinuxGetDrawableContext(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
swapl(&stuff->id, n);
return ProcSELinuxGetDrawableContext(client);
}
static int _X_COLD
SProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
static int
SProcSELinuxGetPropertyContext(ClientPtr client, pointer privKey)
{
REQUEST(SELinuxGetPropertyContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
swapl(&stuff->window);
swapl(&stuff->property);
swapl(&stuff->window, n);
swapl(&stuff->property, n);
return ProcSELinuxGetPropertyContext(client, privKey);
}
static int _X_COLD
SProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
static int
SProcSELinuxGetSelectionContext(ClientPtr client, pointer privKey)
{
REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
swapl(&stuff->id, n);
return ProcSELinuxGetSelectionContext(client, privKey);
}
static int _X_COLD
static int
SProcSELinuxListProperties(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
swapl(&stuff->id, n);
return ProcSELinuxListProperties(client);
}
static int _X_COLD
static int
SProcSELinuxGetClientContext(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
int n;
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
swapl(&stuff->id, n);
return ProcSELinuxGetClientContext(client);
}
static int _X_COLD
static int
SProcSELinuxDispatch(ClientPtr client)
{
REQUEST(xReq);
int n;
swaps(&stuff->length);
swaps(&stuff->length, n);
switch (stuff->data) {
case X_SELinuxQueryVersion:
@@ -675,6 +681,7 @@ SProcSELinuxDispatch(ClientPtr client)
}
}
/*
* Extension Setup / Teardown
*/
@@ -687,7 +694,7 @@ SELinuxResetProc(ExtensionEntry * extEntry)
}
void
SELinuxExtensionInit(void)
SELinuxExtensionInit(INITARGS)
{
ExtensionEntry *extEntry;
@@ -714,4 +721,6 @@ SELinuxExtensionInit(void)
SELinuxNumberEvents, SELinuxNumberErrors,
ProcSELinuxDispatch, SProcSELinuxDispatch,
SELinuxResetProc, StandardMinorOpcode);
AddExtensionAlias("Flask", extEntry);
}

View File

@@ -41,9 +41,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "extnsionst.h"
#include "xacestr.h"
#include "client.h"
#include "../os/osdep.h"
#define _XSELINUX_NEED_FLASK_MAP
#include "xselinuxint.h"
/* structure passed to auditing callback */
typedef struct {
ClientPtr client; /* client */
@@ -73,10 +75,11 @@ static Atom atom_client_ctx;
static security_id_t unlabeled_sid;
/* forward declarations */
static void SELinuxScreen(CallbackListPtr *, void *, void *);
static void SELinuxScreen(CallbackListPtr *, pointer, pointer);
/* "true" pointer value for use as callback data */
static void *truep = (void *) 1;
static pointer truep = (pointer)1;
/*
* Performs an SELinux permission check.
@@ -130,12 +133,11 @@ SELinuxLabelClient(ClientPtr client)
/* Get cached command name if CLIENTIDS is enabled. */
const char *cmdname = GetClientCmdName(client);
Bool cached = (cmdname != NULL);
/* If CLIENTIDS is disabled, figure out the command name from
* scratch. */
if (!cmdname) {
if (!cmdname)
{
pid_t pid = DetermineClientPid(client);
if (pid != -1)
DetermineClientCmd(pid, &cmdname, NULL);
}
@@ -170,7 +172,7 @@ SELinuxLabelInitial(void)
SELinuxSubjectRec *subj;
SELinuxObjectRec *obj;
security_context_t ctx;
void *unused;
pointer unused;
/* Do the serverClient */
subj = dixLookupPrivate(&serverClient->devPrivates, subjectKey);
@@ -226,10 +228,8 @@ SELinuxLabelResource(XaceResourceAccessRec * rec, SELinuxSubjectRec * subj,
/* Use the SID of the parent object in the labeling operation */
PrivateRec **privatePtr = DEVPRIV_AT(rec->parent, offset);
SELinuxObjectRec *pobj = dixLookupPrivate(privatePtr, objectKey);
tsid = pobj->sid;
}
else {
} else {
/* Use the SID of the subject */
tsid = subj->sid;
}
@@ -243,13 +243,16 @@ SELinuxLabelResource(XaceResourceAccessRec * rec, SELinuxSubjectRec * subj,
return Success;
}
/*
* Libselinux Callbacks
*/
static int
SELinuxAudit(void *auditdata,
security_class_t class, char *msgbuf, size_t msgbufsize)
security_class_t class,
char *msgbuf,
size_t msgbufsize)
{
SELinuxAuditRec *audit = auditdata;
ClientPtr client = audit->client;
@@ -293,9 +296,6 @@ SELinuxAudit(void *auditdata,
audit->extension ? audit->extension : "");
}
static int
SELinuxLog(int type, const char *fmt, ...) _X_ATTRIBUTE_PRINTF(2, 3);
static int
SELinuxLog(int type, const char *fmt, ...)
{
@@ -318,7 +318,6 @@ SELinuxLog(int type, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(buf, MAX_AUDIT_MESSAGE_LENGTH, fmt, ap);
rc = audit_log_user_avc_message(audit_fd, aut, buf, NULL, NULL, NULL, 0);
(void) rc;
va_end(ap);
LogMessageVerb(X_WARNING, 0, "%s", buf);
return 0;
@@ -329,7 +328,7 @@ SELinuxLog(int type, const char *fmt, ...)
*/
static void
SELinuxDevice(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceDeviceAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -344,15 +343,13 @@ SELinuxDevice(CallbackListPtr *pcbl, void *unused, void *calldata)
/* If this is a new object that needs labeling, do it now */
if (rec->access_mode & DixCreateAccess) {
SELinuxSubjectRec *dsubj;
dsubj = dixLookupPrivate(&rec->dev->devPrivates, subjectKey);
if (subj->dev_create_sid) {
/* Label the device with the create context */
obj->sid = subj->dev_create_sid;
dsubj->sid = subj->dev_create_sid;
}
else {
} else {
/* Label the device directly with the process SID */
obj->sid = subj->sid;
dsubj->sid = subj->sid;
@@ -366,7 +363,7 @@ SELinuxDevice(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxSend(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxSend(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceSendAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -408,7 +405,7 @@ SELinuxSend(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxReceive(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceReceiveAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -446,7 +443,7 @@ SELinuxReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxExtension(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceExtAccessRec *rec = calldata;
SELinuxSubjectRec *subj, *serv;
@@ -479,7 +476,7 @@ SELinuxExtension(CallbackListPtr *pcbl, void *unused, void *calldata)
}
/* Perform the security check */
auditdata.extension = (char *) rec->ext->name;
auditdata.extension = rec->ext->name;
rc = SELinuxDoCheck(subj, obj, SECCLASS_X_EXTENSION, rec->access_mode,
&auditdata);
if (rc != Success)
@@ -487,7 +484,7 @@ SELinuxExtension(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxSelection(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxSelection(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceSelectionAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -547,7 +544,7 @@ SELinuxSelection(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XacePropertyAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -611,7 +608,7 @@ SELinuxProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxResource(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceResourceAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -631,8 +628,7 @@ SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
class = SECCLASS_X_RESOURCE;
privatePtr = &clients[CLIENT_ID(rec->id)]->devPrivates;
obj = dixLookupPrivate(privatePtr, objectKey);
}
else {
} else {
/* Yes: use the SID from the resource object itself */
class = SELinuxTypeToClass(rec->rtype);
privatePtr = DEVPRIV_AT(rec->res, offset);
@@ -670,7 +666,7 @@ SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxScreen(CallbackListPtr *pcbl, void *is_saver, void *calldata)
SELinuxScreen(CallbackListPtr *pcbl, pointer is_saver, pointer calldata)
{
XaceScreenAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -702,7 +698,7 @@ SELinuxScreen(CallbackListPtr *pcbl, void *is_saver, void *calldata)
}
static void
SELinuxClient(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxClient(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceClientAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -720,7 +716,7 @@ SELinuxClient(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxServer(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxServer(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
XaceServerAccessRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -737,12 +733,13 @@ SELinuxServer(CallbackListPtr *pcbl, void *unused, void *calldata)
rec->status = rc;
}
/*
* DIX Callbacks
*/
static void
SELinuxClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
NewClientInfoRec *pci = calldata;
@@ -757,7 +754,7 @@ SELinuxClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
}
static void
SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxResourceState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
ResourceStateInfoRec *rec = calldata;
SELinuxSubjectRec *subj;
@@ -775,7 +772,6 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
if (subj->sid) {
security_context_t ctx;
int rc = avc_sid_to_context_raw(subj->sid, &ctx);
if (rc < 0)
FatalError("SELinux: Failed to get security context!\n");
rc = dixChangeWindowProperty(serverClient,
@@ -784,8 +780,7 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
if (rc != Success)
FatalError("SELinux: Failed to set label property on window!\n");
freecon(ctx);
}
else
} else
FatalError("SELinux: Unexpected unlabeled client found\n");
obj = dixLookupPrivate(&pWin->devPrivates, objectKey);
@@ -793,7 +788,6 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
if (obj->sid) {
security_context_t ctx;
int rc = avc_sid_to_context_raw(obj->sid, &ctx);
if (rc < 0)
FatalError("SELinux: Failed to get security context!\n");
rc = dixChangeWindowProperty(serverClient,
@@ -802,16 +796,22 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
if (rc != Success)
FatalError("SELinux: Failed to set label property on window!\n");
freecon(ctx);
}
else
} else
FatalError("SELinux: Unexpected unlabeled window found\n");
}
static int netlink_fd;
static void
SELinuxNetlinkNotify(int fd, int ready, void *data)
SELinuxBlockHandler(void *data, struct timeval **tv, void *read_mask)
{
}
static void
SELinuxWakeupHandler(void *data, int err, void *read_mask)
{
if (FD_ISSET(netlink_fd, (fd_set *)read_mask))
avc_netlink_check_nb();
}
@@ -838,7 +838,9 @@ SELinuxFlaskReset(void)
/* Tear down SELinux stuff */
audit_close(audit_fd);
avc_netlink_release_fd();
RemoveNotifyFd(netlink_fd);
RemoveBlockAndWakeupHandlers(SELinuxBlockHandler, SELinuxWakeupHandler,
NULL);
RemoveGeneralSocket(netlink_fd);
avc_destroy();
}
@@ -866,13 +868,11 @@ SELinuxFlaskInit(void)
/* Set up SELinux stuff */
selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback)SELinuxLog);
selinux_set_callback(SELINUX_CB_AUDIT,
(union selinux_callback) SELinuxAudit);
selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback)SELinuxAudit);
if (selinux_set_mapping(map) < 0) {
if (errno == EINVAL) {
ErrorF
("SELinux: Invalid object class mapping, disabling SELinux support.\n");
ErrorF("SELinux: Invalid object class mapping, disabling SELinux support.\n");
return;
}
FatalError("SELinux: Failed to set up security class mapping\n");
@@ -893,12 +893,9 @@ SELinuxFlaskInit(void)
FatalError("SELinux: Failed to open the system audit log\n");
/* Allocate private storage */
if (!dixRegisterPrivateKey
(subjectKey, PRIVATE_XSELINUX, sizeof(SELinuxSubjectRec)) ||
!dixRegisterPrivateKey(objectKey, PRIVATE_XSELINUX,
sizeof(SELinuxObjectRec)) ||
!dixRegisterPrivateKey(dataKey, PRIVATE_XSELINUX,
sizeof(SELinuxObjectRec)))
if (!dixRegisterPrivateKey(subjectKey, PRIVATE_XSELINUX, sizeof(SELinuxSubjectRec)) ||
!dixRegisterPrivateKey(objectKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)) ||
!dixRegisterPrivateKey(dataKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)))
FatalError("SELinux: Failed to allocate private storage.\n");
/* Create atoms for doing window labeling */
@@ -910,7 +907,9 @@ SELinuxFlaskInit(void)
FatalError("SELinux: Failed to create atom\n");
netlink_fd = avc_netlink_acquire_fd();
SetNotifyFd(netlink_fd, SELinuxNetlinkNotify, X_NOTIFY_READ, NULL);
AddGeneralSocket(netlink_fd);
RegisterBlockAndWakeupHandlers(SELinuxBlockHandler, SELinuxWakeupHandler,
NULL);
/* Register callbacks */
ret &= AddCallback(&ClientStateCallback, SELinuxClientState, NULL);

View File

@@ -43,10 +43,8 @@ static struct selabel_handle *label_hnd;
/* Array of object classes indexed by resource type */
SELinuxArrayRec arr_types;
/* Array of event SIDs indexed by event type */
SELinuxArrayRec arr_events;
/* Array of property and selection SID structures */
SELinuxArrayRec arr_atoms;
@@ -64,7 +62,7 @@ SELinuxArraySet(SELinuxArrayRec * rec, unsigned key, void *val)
{
if (key >= rec->size) {
/* 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)
return FALSE;
memset(rec->array + rec->size, 0, (key - rec->size + 1) * sizeof(val));
@@ -80,7 +78,6 @@ SELinuxArrayFree(SELinuxArrayRec * rec, int free_elements)
{
if (free_elements) {
unsigned i = rec->size;
while (i)
free(rec->array[--i]);
}
@@ -105,12 +102,10 @@ SELinuxAtomToSIDLookup(Atom atom, SELinuxObjectRec * obj, int map, int polymap)
/* Look in the mappings of names to contexts */
if (selabel_lookup_raw(label_hnd, &ctx, name, map) == 0) {
obj->poly = 0;
}
else if (errno != ENOENT) {
} else if (errno != ENOENT) {
ErrorF("SELinux: a property label lookup failed!\n");
return BadValue;
}
else if (selabel_lookup_raw(label_hnd, &ctx, name, polymap) < 0) {
} else if (selabel_lookup_raw(label_hnd, &ctx, name, polymap) < 0) {
ErrorF("SELinux: a property label lookup failed!\n");
return BadValue;
}
@@ -146,8 +141,7 @@ SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec ** obj_rtn)
obj = &rec->prp;
map = SELABEL_X_PROP;
polymap = SELABEL_X_POLYPROP;
}
else {
} else {
obj = &rec->sel;
map = SELABEL_X_SELN;
polymap = SELABEL_X_POLYSELN;
@@ -225,7 +219,8 @@ SELinuxPropertyToSID(Atom property, SELinuxSubjectRec * subj,
}
/* Perform a transition */
if (avc_compute_create(subj->sid, obj->sid, SECCLASS_X_PROPERTY, &tsid) < 0) {
if (avc_compute_create(subj->sid, obj->sid,
SECCLASS_X_PROPERTY, &tsid) < 0) {
ErrorF("SELinux: a compute_create call failed!\n");
return BadValue;
}
@@ -256,7 +251,6 @@ SELinuxEventToSID(unsigned type, security_id_t sid_of_window,
const char *name = LookupEventName(type);
security_id_t sid;
security_context_t ctx;
type &= 127;
sid = SELinuxArrayGet(&arr_events, type);
@@ -333,7 +327,6 @@ SELinuxTypeToClass(RESTYPE type)
else {
/* Need to do a string lookup */
const char *str = LookupResourceName(type);
if (!strcmp(str, "PICTURE"))
class = SECCLASS_X_DRAWABLE;
else if (!strcmp(str, "GLYPHSET"))

View File

@@ -63,13 +63,10 @@ typedef struct {
*/
extern DevPrivateKeyRec subjectKeyRec;
#define subjectKey (&subjectKeyRec)
extern DevPrivateKeyRec objectKeyRec;
#define objectKey (&objectKeyRec)
extern DevPrivateKeyRec dataKeyRec;
#define dataKey (&dataKeyRec)
/*
@@ -80,26 +77,25 @@ int
SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec **obj_rtn);
int
SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec *subj,
security_id_t *sid_rtn, int *poly_rtn);
int
SELinuxPropertyToSID(Atom property, SELinuxSubjectRec *subj,
security_id_t *sid_rtn, int *poly_rtn);
int
SELinuxEventToSID(unsigned type, security_id_t sid_of_window,
SELinuxObjectRec *sid_return);
int
SELinuxExtensionToSID(const char *name, security_id_t *sid_rtn);
security_class_t SELinuxTypeToClass(RESTYPE type);
security_class_t
SELinuxTypeToClass(RESTYPE type);
security_context_t SELinuxDefaultClientLabel(void);
security_context_t
SELinuxDefaultClientLabel(void);
void
SELinuxLabelInit(void);
@@ -117,6 +113,7 @@ void
void
SELinuxFlaskReset(void);
/*
* Private Flask definitions
*/

View File

@@ -55,7 +55,9 @@
#include "eventstr.h"
#include "inpututils.h"
#include "extinit.h"
#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
@@ -79,28 +81,29 @@ DeviceIntPtr xtestpointer, xtestkeyboard;
#include "panoramiXsrv.h"
#endif
static int XTestSwapFakeInput(ClientPtr /* client */ ,
static int XTestSwapFakeInput(
ClientPtr /* client */,
xReq * /* req */
);
static int
ProcXTestGetVersion(ClientPtr client)
{
xXTestGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = XTestMajorVersion,
.minorVersion = XTestMinorVersion
};
xXTestGetVersionReply rep;
int n;
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XTestMajorVersion;
rep.minorVersion = XTestMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.minorVersion);
swaps(&rep.sequenceNumber, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xXTestGetVersionReply), &rep);
WriteToClient(client, sizeof(xXTestGetVersionReply), (char *)&rep);
return Success;
}
@@ -111,39 +114,34 @@ ProcXTestCompareCursor(ClientPtr client)
xXTestCompareCursorReply rep;
WindowPtr pWin;
CursorPtr pCursor;
int rc;
int n, rc;
DeviceIntPtr ptr = PickPointer(client);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (!ptr)
return BadAccess;
if (stuff->cursor == None)
pCursor = NullCursor;
else if (stuff->cursor == XTestCurrentCursor)
pCursor = GetSpriteCursor(ptr);
else {
rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor,
RT_CURSOR, client, DixReadAccess);
if (rc != Success) {
rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
client, DixReadAccess);
if (rc != Success)
{
client->errorValue = stuff->cursor;
return rc;
}
}
rep = (xXTestCompareCursorReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.same = (wCursor(pWin) == pCursor)
};
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.same = (wCursor(pWin) == pCursor);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.sequenceNumber, n);
}
WriteToClient(client, sizeof(xXTestCompareCursorReply), &rep);
WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *)&rep);
return Success;
}
@@ -156,6 +154,7 @@ ProcXTestFakeInput(ClientPtr client)
DeviceIntPtr dev = NULL;
WindowPtr root;
Bool extension = FALSE;
deviceValuator *dv = NULL;
ValuatorMask mask;
int valuators[MAX_VALUATORS] = {0};
int numValuators = 0;
@@ -174,13 +173,15 @@ ProcXTestFakeInput(ClientPtr client)
ev = (xEvent *)&((xReq *)stuff)[1];
type = ev->u.u.type & 0177;
if (type >= EXTENSION_EVENT_BASE) {
if (type >= EXTENSION_EVENT_BASE)
{
extension = TRUE;
/* check device */
rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client,
DixWriteAccess);
if (rc != Success) {
if (rc != Success)
{
client->errorValue = stuff->deviceid & 0177;
return rc;
}
@@ -190,27 +191,31 @@ ProcXTestFakeInput(ClientPtr client)
switch (type) {
case XI_DeviceKeyPress:
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) {
if (!dev->button)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_DeviceMotionNotify:
if (!dev->valuator) {
if (!dev->valuator)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
break;
case XI_ProximityIn:
case XI_ProximityOut:
if (!dev->proximity) {
if (!dev->proximity)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
@@ -224,51 +229,53 @@ ProcXTestFakeInput(ClientPtr client)
if (nev == 1 && type == XI_DeviceMotionNotify)
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) {
if (firstValuator > dev->valuator->numAxes)
{
client->errorValue = ev->u.u.type;
return BadValue;
}
if (ev->u.u.detail == xFalse)
flags |= POINTER_ABSOLUTE;
}
else {
} else
{
firstValuator = 0;
flags |= POINTER_ABSOLUTE;
}
if (nev > 1 && !dev->valuator) {
client->errorValue = firstValuator;
return BadValue;
}
/* check validity of valuator events */
base = firstValuator;
for (n = 1; n < nev; n++) {
deviceValuator *dv = (deviceValuator *) (ev + n);
if (dv->type != DeviceValuator) {
client->errorValue = dv->type;
return BadValue;
}
if (dv->first_valuator != base) {
if (nev > 1 && !dev->valuator)
{
client->errorValue = dv->first_valuator;
return BadValue;
}
switch (dv->num_valuators) {
case 6:
valuators[base + 5] = dv->valuator5;
case 5:
valuators[base + 4] = dv->valuator4;
case 4:
valuators[base + 3] = dv->valuator3;
case 3:
valuators[base + 2] = dv->valuator2;
case 2:
valuators[base + 1] = dv->valuator1;
case 1:
valuators[base] = dv->valuator0;
/* check validity of valuator events */
base = firstValuator;
for (n = 1; n < nev; n++)
{
dv = (deviceValuator *)(ev + n);
if (dv->type != DeviceValuator)
{
client->errorValue = dv->type;
return BadValue;
}
if (dv->first_valuator != base)
{
client->errorValue = dv->first_valuator;
return BadValue;
}
switch(dv->num_valuators)
{
case 6: valuators[base + 5] = dv->valuator5;
case 5: valuators[base + 4] = dv->valuator4;
case 4: valuators[base + 3] = dv->valuator3;
case 3: valuators[base + 2] = dv->valuator2;
case 2: valuators[base + 1] = dv->valuator1;
case 1: valuators[base] = dv->valuator0;
break;
default:
client->errorValue = dv->num_valuators;
@@ -278,18 +285,20 @@ ProcXTestFakeInput(ClientPtr client)
base += dv->num_valuators;
numValuators += dv->num_valuators;
if (firstValuator + numValuators > dev->valuator->numAxes) {
if (firstValuator + numValuators > dev->valuator->numAxes)
{
client->errorValue = dv->num_valuators;
return BadValue;
}
}
type = type - XI_DeviceKeyPress + KeyPress;
}
else {
} else
{
if (nev != 1)
return BadLength;
switch (type) {
switch (type)
{
case KeyPress:
case KeyRelease:
dev = PickKeyboard(client);
@@ -305,24 +314,19 @@ ProcXTestFakeInput(ClientPtr client)
numValuators = 2;
firstValuator = 0;
if (ev->u.u.detail == xFalse)
flags = POINTER_ABSOLUTE | POINTER_DESKTOP;
flags = POINTER_ABSOLUTE | POINTER_SCREEN;
break;
default:
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);
}
/* If the event has a time set, wait for it to pass */
if (ev->u.keyButtonPointer.time) {
if (ev->u.keyButtonPointer.time)
{
TimeStamp activateTime;
CARD32 ms;
@@ -336,27 +340,31 @@ ProcXTestFakeInput(ClientPtr client)
/* see mbuf.c:QueueDisplayRequest (from the deprecated Multibuffer
* extension) for code similar to this */
if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) {
if (!ClientSleepUntil(client, &activateTime, NULL, NULL))
{
return BadAlloc;
}
/* swap the request back so we can simply re-execute it */
if (client->swapped) {
if (client->swapped)
{
(void) XTestSwapFakeInput(client, (xReq *)stuff);
swaps(&stuff->length);
swaps(&stuff->length, n);
}
ResetCurrentRequest (client);
client->sequence--;
return Success;
}
switch (type) {
switch (type)
{
case KeyPress:
case KeyRelease:
if (!dev->key)
return BadDevice;
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;
}
@@ -367,25 +375,20 @@ ProcXTestFakeInput(ClientPtr client)
if (!dev->valuator)
return BadDevice;
if (!(extension || ev->u.keyButtonPointer.root == None)) {
if (!(extension || ev->u.keyButtonPointer.root == None))
{
rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root,
client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (root->parent) {
if (root->parent)
{
client->errorValue = ev->u.keyButtonPointer.root;
return BadValue;
}
/* Add the root window's offset to the valuators */
if ((flags & POINTER_ABSOLUTE) && firstValuator <= 1 && numValuators > 0) {
if (firstValuator == 0)
valuators[0] += root->drawable.pScreen->x;
if (firstValuator < 2 && firstValuator + numValuators > 1)
valuators[1 - firstValuator] += root->drawable.pScreen->y;
}
}
if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) {
if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse)
{
client->errorValue = ev->u.u.detail;
return BadValue;
}
@@ -398,7 +401,8 @@ ProcXTestFakeInput(ClientPtr client)
if (!dev->button)
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;
}
@@ -420,13 +424,12 @@ ProcXTestFakeInput(ClientPtr client)
break;
case KeyPress:
case KeyRelease:
nevents =
GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail);
nevents = GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail, NULL);
break;
}
for (i = 0; i < nevents; i++)
mieqProcessDeviceEvent(dev, &xtest_evlist[i], miPointerGetScreen(inputInfo.pointer));
mieqProcessDeviceEvent(dev, &xtest_evlist[i], NULL);
if (need_ptr_update)
miPointerUpdateSprite(dev);
@@ -439,7 +442,8 @@ ProcXTestGrabControl(ClientPtr client)
REQUEST(xXTestGrabControlReq);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) {
if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse))
{
client->errorValue = stuff->impervious;
return BadValue;
}
@@ -454,7 +458,8 @@ static int
ProcXTestDispatch (ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_XTestGetVersion:
return ProcXTestGetVersion(client);
case X_XTestCompareCursor:
@@ -468,30 +473,32 @@ ProcXTestDispatch(ClientPtr client)
}
}
static int _X_COLD
static int
SProcXTestGetVersion(ClientPtr client)
{
int n;
REQUEST(xXTestGetVersionReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
swaps(&stuff->minorVersion);
swaps(&stuff->minorVersion, n);
return ProcXTestGetVersion(client);
}
static int _X_COLD
static int
SProcXTestCompareCursor(ClientPtr client)
{
int n;
REQUEST(xXTestCompareCursorReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
swapl(&stuff->window);
swapl(&stuff->cursor);
swapl(&stuff->window, n);
swapl(&stuff->cursor, n);
return ProcXTestCompareCursor(client);
}
static int _X_COLD
static int
XTestSwapFakeInput(ClientPtr client, xReq *req)
{
int nev;
@@ -500,7 +507,8 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
EventSwapPtr proc;
nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
for (ev = (xEvent *)&req[1]; --nev >= 0; ev++)
{
/* Swap event */
proc = EventSwapVector[ev->u.u.type & 0177];
/* no swapping proc; invalid event type? */
@@ -514,35 +522,36 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
return Success;
}
static int _X_COLD
static int
SProcXTestFakeInput(ClientPtr client)
{
int n;
REQUEST(xReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
n = XTestSwapFakeInput(client, stuff);
if (n != Success)
return n;
return ProcXTestFakeInput(client);
}
static int _X_COLD
static int
SProcXTestGrabControl(ClientPtr client)
{
int n;
REQUEST(xXTestGrabControlReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
return ProcXTestGrabControl(client);
}
static int _X_COLD
static int
SProcXTestDispatch (ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
switch (stuff->data)
{
case X_XTestGetVersion:
return SProcXTestGetVersion(client);
case X_XTestCompareCursor:
@@ -560,8 +569,7 @@ SProcXTestDispatch(ClientPtr client)
* Allocate an virtual slave device for xtest events, this
* is a slave device to inputInfo master devices
*/
void
InitXTestDevices(void)
void InitXTestDevices(void)
{
if(AllocXTestDevice(serverClient, "Virtual core",
&xtestpointer, &xtestkeyboard,
@@ -571,11 +579,11 @@ InitXTestDevices(void)
if (ActivateDevice(xtestpointer, TRUE) != Success ||
ActivateDevice(xtestkeyboard, TRUE) != Success)
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.");
AttachDevice(NULL, xtestpointer, inputInfo.pointer);
AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard);
}
@@ -599,21 +607,19 @@ DeviceSetXTestProperty(DeviceIntPtr dev, Atom property,
* This only creates the pair, Activate/Enable Device
* still need to be called.
*/
int
AllocXTestDevice(ClientPtr client, const char *name,
int AllocXTestDevice (ClientPtr client, char* name,
DeviceIntPtr* ptr, DeviceIntPtr* keybd,
DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
{
int retval;
char *xtestname;
int len = strlen(name);
char *xtestname = calloc(len + 7, 1 );
char dummy = 1;
if (asprintf(&xtestname, "%s XTEST", name) == -1)
return BadAlloc;
strncpy( xtestname, name, len);
strncat( xtestname, " XTEST", 6 );
retval =
AllocDevicePair(client, xtestname, ptr, keybd, CorePointerProc,
CoreKeyboardProc, FALSE);
retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
if ( retval == Success ){
(*ptr)->xtest_master_id = master_ptr->id;
(*keybd)->xtest_master_id = master_keybd->id;
@@ -621,16 +627,12 @@ AllocXTestDevice(ClientPtr client, const char *name,
XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
XA_INTEGER, 8, PropModeReplace, 1, &dummy,
FALSE);
XISetDevicePropertyDeletable(*ptr,
XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
FALSE);
XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL);
XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
XA_INTEGER, 8, PropModeReplace, 1, &dummy,
FALSE);
XISetDevicePropertyDeletable(*keybd,
XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
FALSE);
XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL);
}
@@ -667,7 +669,8 @@ GetXTestDevice(DeviceIntPtr master)
{
DeviceIntPtr it;
for (it = inputInfo.devices; it; it = it->next) {
for (it = inputInfo.devices; it; it = it->next)
{
if (IsXTestDevice(it, master))
return it;
}
@@ -684,7 +687,7 @@ XTestExtensionTearDown(ExtensionEntry * e)
}
void
XTestExtensionInit(void)
XTestExtensionInit(INITARGS)
{
AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,

File diff suppressed because it is too large Load Diff

View File

@@ -55,6 +55,7 @@ SOFTWARE.
#include "scrnintstr.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;
@@ -69,6 +70,7 @@ extern _X_EXPORT RESTYPE XvRTGrab;
extern _X_EXPORT RESTYPE XvRTVideoNotify;
extern _X_EXPORT RESTYPE XvRTVideoNotifyList;
extern _X_EXPORT RESTYPE XvRTPortNotify;
#endif
typedef struct {
int numerator;
@@ -157,29 +159,33 @@ typedef struct {
int nPorts;
struct _XvPortRec *pPorts;
ScreenPtr pScreen;
int (*ddPutVideo) (DrawablePtr, struct _XvPortRec *, GCPtr,
int (* ddAllocatePort)(unsigned long, struct _XvPortRec*,
struct _XvPortRec**);
int (* ddFreePort)(struct _XvPortRec*);
int (* ddPutVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
int (*ddPutStill) (DrawablePtr, struct _XvPortRec *, GCPtr,
int (* ddPutStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
int (*ddGetVideo) (DrawablePtr, struct _XvPortRec *, GCPtr,
int (* ddGetVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
int (*ddGetStill) (DrawablePtr, struct _XvPortRec *, GCPtr,
int (* ddGetStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
int (*ddStopVideo) (struct _XvPortRec *, DrawablePtr);
int (*ddSetPortAttribute) (struct _XvPortRec *, Atom, INT32);
int (*ddGetPortAttribute) (struct _XvPortRec *, Atom, INT32 *);
int (*ddQueryBestSize) (struct _XvPortRec *, CARD8,
int (* ddStopVideo)(ClientPtr, struct _XvPortRec*, DrawablePtr);
int (* ddSetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32);
int (* ddGetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32*);
int (* ddQueryBestSize)(ClientPtr, struct _XvPortRec*, CARD8,
CARD16, CARD16,CARD16, CARD16,
unsigned int*, unsigned int*);
int (*ddPutImage) (DrawablePtr, struct _XvPortRec *, GCPtr,
int (* ddPutImage)(ClientPtr, DrawablePtr, struct _XvPortRec*, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
int (*ddQueryImageAttributes) (struct _XvPortRec *, XvImagePtr,
XvImagePtr, unsigned char*, Bool,
CARD16, CARD16);
int (* ddQueryImageAttributes)(ClientPtr, struct _XvPortRec*, XvImagePtr,
CARD16*, CARD16*, int*, int*);
DevUnion devPriv;
} XvAdaptorRec, *XvAdaptorPtr;
@@ -197,7 +203,7 @@ typedef struct _XvPortRec {
#define VALIDATE_XV_PORT(portID, pPort, mode)\
{\
int rc = dixLookupResourceByType((void **)&(pPort), portID,\
int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\
XvRTPort, client, mode);\
if (rc != Success)\
return rc;\
@@ -210,6 +216,9 @@ typedef struct {
DestroyWindowProcPtr DestroyWindow;
DestroyPixmapProcPtr DestroyPixmap;
CloseScreenProcPtr CloseScreen;
Bool (* ddCloseScreen)(int, ScreenPtr);
int (* ddQueryAdaptors)(ScreenPtr, XvAdaptorPtr*, int*);
DevUnion devPriv;
} XvScreenRec, *XvScreenPtr;
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
@@ -223,16 +232,16 @@ typedef struct {
#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 DevPrivateKey XvGetScreenKey(void);
extern _X_EXPORT unsigned long XvGetRTPort(void);
extern _X_EXPORT void XvFreeAdaptor(XvAdaptorPtr pAdaptor);
extern void _X_EXPORT XvFillColorKey(DrawablePtr pDraw, CARD32 key,
RegionPtr region);
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,
@@ -256,7 +265,11 @@ 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 */

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,6 @@
#include "resource.h"
#include "scrnintstr.h"
#include "extnsionst.h"
#include "extinit.h"
#include "servermd.h"
#include <X11/Xfuncproto.h>
#include "xvdix.h"
@@ -29,14 +28,17 @@
#include <sys/shm.h>
#endif /* HAS_XVMCSHM */
#define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48
static DevPrivateKeyRec XvMCScreenKeyRec;
#define XvMCScreenKey (&XvMCScreenKeyRec)
static Bool XvMCInUse;
unsigned long XvMCGeneration = 0;
int XvMCReqCode;
int XvMCEventBase;
@@ -44,8 +46,6 @@ static RESTYPE XvMCRTContext;
static RESTYPE XvMCRTSurface;
static RESTYPE XvMCRTSubpicture;
int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = NULL;
typedef struct {
int num_adaptors;
XvMCAdaptorPtr adaptors;
@@ -60,8 +60,9 @@ typedef struct {
#define XVMC_GET_PRIVATE(pScreen) \
(XvMCScreenPtr)(dixLookupPrivate(&(pScreen)->devPrivates, XvMCScreenKey))
static int
XvMCDestroyContextRes(void *data, XID id)
XvMCDestroyContextRes(pointer data, XID id)
{
XvMCContextPtr pContext = (XvMCContextPtr)data;
@@ -69,7 +70,6 @@ XvMCDestroyContextRes(void *data, XID id)
if(!pContext->refcnt) {
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
(*pScreenPriv->adaptors[pContext->adapt_num].DestroyContext)(pContext);
free(pContext);
}
@@ -78,7 +78,7 @@ XvMCDestroyContextRes(void *data, XID id)
}
static int
XvMCDestroySurfaceRes(void *data, XID id)
XvMCDestroySurfaceRes(pointer data, XID id)
{
XvMCSurfacePtr pSurface = (XvMCSurfacePtr)data;
XvMCContextPtr pContext = pSurface->context;
@@ -87,13 +87,14 @@ XvMCDestroySurfaceRes(void *data, XID id)
(*pScreenPriv->adaptors[pContext->adapt_num].DestroySurface)(pSurface);
free(pSurface);
XvMCDestroyContextRes((void *) pContext, pContext->context_id);
XvMCDestroyContextRes((pointer)pContext, pContext->context_id);
return Success;
}
static int
XvMCDestroySubpictureRes(void *data, XID id)
XvMCDestroySubpictureRes(pointer data, XID id)
{
XvMCSubpicturePtr pSubpict = (XvMCSubpicturePtr)data;
XvMCContextPtr pContext = pSubpict->context;
@@ -102,7 +103,7 @@ XvMCDestroySubpictureRes(void *data, XID id)
(*pScreenPriv->adaptors[pContext->adapt_num].DestroySubpicture)(pSubpict);
free(pSubpict);
XvMCDestroyContextRes((void *) pContext, pContext->context_id);
XvMCDestroyContextRes((pointer)pContext, pContext->context_id);
return Success;
}
@@ -110,21 +111,19 @@ XvMCDestroySubpictureRes(void *data, XID id)
static int
ProcXvMCQueryVersion(ClientPtr client)
{
xvmcQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.major = SERVER_XVMC_MAJOR_VERSION,
.minor = SERVER_XVMC_MINOR_VERSION
};
xvmcQueryVersionReply rep;
/* REQUEST(xvmcQueryVersionReq); */
REQUEST_SIZE_MATCH(xvmcQueryVersionReq);
WriteToClient(client, sizeof(xvmcQueryVersionReply), &rep);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.major = SERVER_XVMC_MAJOR_VERSION;
rep.minor = SERVER_XVMC_MINOR_VERSION;
WriteToClient(client, sizeof(xvmcQueryVersionReply), (char*)&rep);
return Success;
}
static int
ProcXvMCListSurfaceTypes(ClientPtr client)
{
@@ -135,8 +134,6 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
xvmcSurfaceInfo info;
XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface;
int num_surfaces;
REQUEST(xvmcListSurfaceTypesReq);
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
@@ -144,7 +141,6 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
if(XvMCInUse) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for(i = 0; i < pScreenPriv->num_adaptors; i++) {
if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
@@ -155,17 +151,14 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
}
}
num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
rep = (xvmcListSurfaceTypesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num = num_surfaces,
.length = bytes_to_int32(num_surfaces * sizeof(xvmcSurfaceInfo)),
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num = (adaptor) ? adaptor->num_surfaces : 0;
rep.length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo));
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep);
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char*)&rep);
for (i = 0; i < num_surfaces; i++) {
for(i = 0; i < rep.num; i++) {
surface = adaptor->surfaces[i];
info.surface_type_id = surface->surface_type_id;
info.chroma_format = surface->chroma_format;
@@ -175,7 +168,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
info.subpicture_max_height = surface->subpicture_max_height;
info.mc_type = surface->mc_type;
info.flags = surface->flags;
WriteToClient(client, sizeof(xvmcSurfaceInfo), &info);
WriteToClient(client, sizeof(xvmcSurfaceInfo), (char*)&info);
}
return Success;
@@ -194,7 +187,6 @@ ProcXvMCCreateContext(ClientPtr client)
XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface = NULL;
xvmcCreateContextReply rep;
REQUEST(xvmcCreateContextReq);
REQUEST_SIZE_MATCH(xvmcCreateContextReq);
@@ -227,8 +219,8 @@ ProcXvMCCreateContext(ClientPtr client)
}
/* adaptor doesn't support this suface_type_id */
if (!surface)
return BadMatch;
if(!surface) return BadMatch;
if((stuff->width > surface->max_width) ||
(stuff->height > surface->max_height))
@@ -238,6 +230,7 @@ ProcXvMCCreateContext(ClientPtr client)
return BadAlloc;
}
pContext->pScreen = pScreen;
pContext->adapt_num = adapt_num;
pContext->context_id = stuff->context_id;
@@ -253,23 +246,18 @@ ProcXvMCCreateContext(ClientPtr client)
free(pContext);
return result;
}
if (!AddResource(pContext->context_id, XvMCRTContext, pContext)) {
free(data);
return BadAlloc;
}
rep = (xvmcCreateContextReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = dwords,
.width_actual = pContext->width,
.height_actual = pContext->height,
.flags_return = pContext->flags
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.width_actual = pContext->width;
rep.height_actual = pContext->height;
rep.flags_return = pContext->flags;
rep.length = dwords;
WriteToClient(client, sizeof(xvmcCreateContextReply), &rep);
WriteToClient(client, sizeof(xvmcCreateContextReply), (char*)&rep);
if(dwords)
WriteToClient(client, dwords << 2, data);
WriteToClient(client, dwords << 2, (char*)data);
AddResource(pContext->context_id, XvMCRTContext, pContext);
free(data);
@@ -279,9 +267,8 @@ ProcXvMCCreateContext(ClientPtr client)
static int
ProcXvMCDestroyContext(ClientPtr client)
{
void *val;
pointer val;
int rc;
REQUEST(xvmcDestroyContextReq);
REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
@@ -305,11 +292,10 @@ ProcXvMCCreateSurface(ClientPtr client)
XvMCSurfacePtr pSurface;
XvMCScreenPtr pScreenPriv;
xvmcCreateSurfaceReply rep;
REQUEST(xvmcCreateSurfaceReq);
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
result = dixLookupResourceByType((void **) &pContext, stuff->context_id,
result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
XvMCRTContext, client, DixUseAccess);
if (result != Success)
return result;
@@ -323,29 +309,22 @@ ProcXvMCCreateSurface(ClientPtr client)
pSurface->surface_type_id = pContext->surface_type_id;
pSurface->context = pContext;
result =
(*pScreenPriv->adaptors[pContext->adapt_num].CreateSurface) (pSurface,
&dwords,
&data);
result = (*pScreenPriv->adaptors[pContext->adapt_num].CreateSurface)(
pSurface, &dwords, &data);
if(result != Success) {
free(pSurface);
return result;
}
if (!AddResource(pSurface->surface_id, XvMCRTSurface, pSurface)) {
free(data);
return BadAlloc;
}
rep = (xvmcCreateSurfaceReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = dwords
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = dwords;
WriteToClient(client, sizeof(xvmcCreateSurfaceReply), &rep);
WriteToClient(client, sizeof(xvmcCreateSurfaceReply), (char*)&rep);
if(dwords)
WriteToClient(client, dwords << 2, data);
WriteToClient(client, dwords << 2, (char*)data);
AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
free(data);
@@ -357,9 +336,8 @@ ProcXvMCCreateSurface(ClientPtr client)
static int
ProcXvMCDestroySurface(ClientPtr client)
{
void *val;
pointer val;
int rc;
REQUEST(xvmcDestroySurfaceReq);
REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
@@ -385,11 +363,10 @@ ProcXvMCCreateSubpicture(ClientPtr client)
xvmcCreateSubpictureReply rep;
XvMCAdaptorPtr adaptor;
XvMCSurfaceInfoPtr surface = NULL;
REQUEST(xvmcCreateSubpictureReq);
REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
result = dixLookupResourceByType((void **) &pContext, stuff->context_id,
result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
XvMCRTContext, client, DixUseAccess);
if (result != Success)
return result;
@@ -406,23 +383,19 @@ ProcXvMCCreateSubpicture(ClientPtr client)
}
}
if (!surface)
return BadMatch;
if(!surface) return BadMatch;
/* make sure this surface supports that xvimage format */
if (!surface->compatible_subpictures)
return BadMatch;
if(!surface->compatible_subpictures) return BadMatch;
for(i = 0; i < surface->compatible_subpictures->num_xvimages; i++) {
if (surface->compatible_subpictures->xvimage_ids[i] ==
stuff->xvimage_id) {
if(surface->compatible_subpictures->xvimage_ids[i] == stuff->xvimage_id) {
image_supported = TRUE;
break;
}
}
if (!image_supported)
return BadMatch;
if(!image_supported) return BadMatch;
/* make sure the size is OK */
if((stuff->width > surface->subpicture_max_width) ||
@@ -444,36 +417,30 @@ ProcXvMCCreateSubpicture(ClientPtr client)
pSubpicture->component_order[3] = 0;
pSubpicture->context = pContext;
result =
(*pScreenPriv->adaptors[pContext->adapt_num].
CreateSubpicture) (pSubpicture, &dwords, &data);
result = (*pScreenPriv->adaptors[pContext->adapt_num].CreateSubpicture)(
pSubpicture, &dwords, &data);
if(result != Success) {
free(pSubpicture);
return result;
}
if (!AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture)) {
free(data);
return BadAlloc;
}
rep = (xvmcCreateSubpictureReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = dwords,
.width_actual = pSubpicture->width,
.height_actual = pSubpicture->height,
.num_palette_entries = pSubpicture->num_palette_entries,
.entry_bytes = pSubpicture->entry_bytes,
.component_order[0] = pSubpicture->component_order[0],
.component_order[1] = pSubpicture->component_order[1],
.component_order[2] = pSubpicture->component_order[2],
.component_order[3] = pSubpicture->component_order[3]
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.width_actual = pSubpicture->width;
rep.height_actual = pSubpicture->height;
rep.num_palette_entries = pSubpicture->num_palette_entries;
rep.entry_bytes = pSubpicture->entry_bytes;
rep.component_order[0] = pSubpicture->component_order[0];
rep.component_order[1] = pSubpicture->component_order[1];
rep.component_order[2] = pSubpicture->component_order[2];
rep.component_order[3] = pSubpicture->component_order[3];
rep.length = dwords;
WriteToClient(client, sizeof(xvmcCreateSubpictureReply), &rep);
WriteToClient(client, sizeof(xvmcCreateSubpictureReply), (char*)&rep);
if(dwords)
WriteToClient(client, dwords << 2, data);
WriteToClient(client, dwords << 2, (char*)data);
AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
free(data);
@@ -485,9 +452,8 @@ ProcXvMCCreateSubpicture(ClientPtr client)
static int
ProcXvMCDestroySubpicture(ClientPtr client)
{
void *val;
pointer val;
int rc;
REQUEST(xvmcDestroySubpictureReq);
REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
@@ -501,6 +467,7 @@ ProcXvMCDestroySubpicture(ClientPtr client)
return Success;
}
static int
ProcXvMCListSubpictureTypes(ClientPtr client)
{
@@ -513,7 +480,6 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
xvImageFormatInfo info;
XvImagePtr pImage;
int i, j;
REQUEST(xvmcListSubpictureTypesReq);
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
@@ -534,8 +500,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
}
}
if (!adaptor)
return BadMatch;
if(!adaptor) return BadMatch;
for(i = 0; i < adaptor->num_surfaces; i++) {
if(adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
@@ -544,32 +509,29 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
}
}
if (!surface)
return BadMatch;
if(!surface) return BadMatch;
rep = (xvmcListSubpictureTypesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num = 0
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num = 0;
if(surface->compatible_subpictures)
rep.num = surface->compatible_subpictures->num_xvimages;
rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), &rep);
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char*)&rep);
for(i = 0; i < rep.num; i++) {
pImage = NULL;
for(j = 0; j < adaptor->num_subpictures; j++) {
if(surface->compatible_subpictures->xvimage_ids[i] ==
adaptor->subpictures[j]->id) {
adaptor->subpictures[j]->id)
{
pImage = adaptor->subpictures[j];
break;
}
}
if (!pImage)
return BadImplementation;
if(!pImage) return BadImplementation;
info.id = pImage->id;
info.type = pImage->type;
@@ -593,7 +555,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
info.vert_v_period = pImage->vert_v_period;
memcpy(&info.comp_order, pImage->component_order, 32);
info.scanline_order = pImage->scanline_order;
WriteToClient(client, sizeof(xvImageFormatInfo), &info);
WriteToClient(client, sizeof(xvImageFormatInfo), (char*)&info);
}
return Success;
@@ -619,16 +581,13 @@ ProcXvMCGetDRInfo(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
pScreenPriv = XVMC_GET_PRIVATE(pScreen);
rep = (xvmcGetDRInfoReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.major = pScreenPriv->major,
.minor = pScreenPriv->minor,
.patchLevel = pScreenPriv->patchLevel,
.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1),
.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1),
.isLocal = 1
};
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.major = pScreenPriv->major;
rep.minor = pScreenPriv->minor;
rep.patchLevel = pScreenPriv->patchLevel;
rep.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1);
rep.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1);
rep.length = rep.nameLen + rep.busIDLen;
rep.nameLen <<=2;
@@ -639,6 +598,7 @@ ProcXvMCGetDRInfo(ClientPtr client)
* segment she prepared for us.
*/
rep.isLocal = 1;
#ifdef HAS_XVMCSHM
patternP = (CARD32 *)shmat( stuff->shmKey, NULL, SHM_RDONLY );
if ( -1 != (long) patternP) {
@@ -660,14 +620,18 @@ ProcXvMCGetDRInfo(ClientPtr client)
}
#endif /* HAS_XVMCSHM */
WriteToClient(client, sizeof(xvmcGetDRInfoReply), &rep);
WriteToClient(client, sizeof(xvmcGetDRInfoReply),
(char*)&rep);
if (rep.length) {
WriteToClient(client, rep.nameLen, pScreenPriv->clientDriverName);
WriteToClient(client, rep.busIDLen, pScreenPriv->busID);
WriteToClient(client, rep.nameLen,
pScreenPriv->clientDriverName);
WriteToClient(client, rep.busIDLen,
pScreenPriv->busID);
}
return Success;
}
int (*ProcXvMCVector[xvmcNumRequest])(ClientPtr) = {
ProcXvMCQueryVersion,
ProcXvMCListSurfaceTypes,
@@ -677,7 +641,9 @@ ProcXvMCQueryVersion,
ProcXvMCDestroySurface,
ProcXvMCCreateSubpicture,
ProcXvMCDestroySubpicture,
ProcXvMCListSubpictureTypes, ProcXvMCGetDRInfo};
ProcXvMCListSubpictureTypes,
ProcXvMCGetDRInfo
};
static int
ProcXvMCDispatch (ClientPtr client)
@@ -690,7 +656,7 @@ ProcXvMCDispatch(ClientPtr client)
return BadRequest;
}
static int _X_COLD
static int
SProcXvMCDispatch (ClientPtr client)
{
/* We only support local */
@@ -721,21 +687,17 @@ XvMCExtensionInit(void)
ProcXvMCDispatch, SProcXvMCDispatch,
NULL, StandardMinorOpcode);
if (!extEntry)
return;
if(!extEntry) return;
XvMCReqCode = extEntry->base;
XvMCEventBase = extEntry->eventBase;
SetResourceTypeErrorValue(XvMCRTContext,
extEntry->errorBase + XvMCBadContext);
SetResourceTypeErrorValue(XvMCRTSurface,
extEntry->errorBase + XvMCBadSurface);
SetResourceTypeErrorValue(XvMCRTSubpicture,
extEntry->errorBase + XvMCBadSubpicture);
SetResourceTypeErrorValue(XvMCRTContext, extEntry->errorBase + XvMCBadContext);
SetResourceTypeErrorValue(XvMCRTSurface, extEntry->errorBase + XvMCBadSurface);
SetResourceTypeErrorValue(XvMCRTSubpicture, extEntry->errorBase + XvMCBadSubpicture);
}
static Bool
XvMCCloseScreen(ScreenPtr pScreen)
XvMCCloseScreen (int i, ScreenPtr pScreen)
{
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
@@ -743,9 +705,10 @@ XvMCCloseScreen(ScreenPtr pScreen)
free(pScreenPriv);
return (*pScreen->CloseScreen) (pScreen);
return (*pScreen->CloseScreen)(i, pScreen);
}
int
XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
{
@@ -775,8 +738,7 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
return Success;
}
XvImagePtr
XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
{
XvImagePtr pImage = NULL;
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
@@ -797,8 +759,7 @@ XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
}
}
if (!adaptor)
return NULL;
if(!adaptor) return NULL;
for(i = 0; i < adaptor->num_subpictures; i++) {
if(adaptor->subpictures[i]->id == id) {
@@ -811,15 +772,19 @@ XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
}
int
xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name,
const char *busID, int major, int minor, int patchLevel)
xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
char *busID, int major, int minor,
int patchLevel)
{
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
strlcpy(pScreenPriv->clientDriverName, name, DR_CLIENT_DRIVER_NAME_SIZE);
strlcpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
strncpy(pScreenPriv->clientDriverName, name,
DR_CLIENT_DRIVER_NAME_SIZE);
strncpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
pScreenPriv->major = major;
pScreenPriv->minor = minor;
pScreenPriv->patchLevel = patchLevel;
pScreenPriv->clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE-1] = 0;
pScreenPriv->busID[DR_BUSID_SIZE-1] = 0;
return Success;
}

View File

@@ -31,17 +31,18 @@ typedef struct {
unsigned short height;
CARD32 flags;
int refcnt;
void *port_priv;
void *driver_priv;
pointer port_priv;
pointer driver_priv;
} XvMCContextRec, *XvMCContextPtr;
typedef struct {
XID surface_id;
int surface_type_id;
XvMCContextPtr context;
void *driver_priv;
pointer driver_priv;
} XvMCSurfaceRec, *XvMCSurfacePtr;
typedef struct {
XID subpicture_id;
int xvimage_id;
@@ -51,24 +52,40 @@ typedef struct {
int entry_bytes;
char component_order[4];
XvMCContextPtr context;
void *driver_priv;
pointer driver_priv;
} XvMCSubpictureRec, *XvMCSubpicturePtr;
typedef int (*XvMCCreateContextProcPtr) (XvPortPtr port,
typedef int (*XvMCCreateContextProcPtr) (
XvPortPtr port,
XvMCContextPtr context,
int *num_priv, CARD32 **priv);
int *num_priv,
CARD32 **priv
);
typedef void (*XvMCDestroyContextProcPtr) (XvMCContextPtr context);
typedef void (*XvMCDestroyContextProcPtr) (
XvMCContextPtr context
);
typedef int (*XvMCCreateSurfaceProcPtr) (XvMCSurfacePtr surface,
int *num_priv, CARD32 **priv);
typedef int (*XvMCCreateSurfaceProcPtr) (
XvMCSurfacePtr surface,
int *num_priv,
CARD32 **priv
);
typedef void (*XvMCDestroySurfaceProcPtr) (XvMCSurfacePtr surface);
typedef void (*XvMCDestroySurfaceProcPtr) (
XvMCSurfacePtr surface
);
typedef int (*XvMCCreateSubpictureProcPtr) (XvMCSubpicturePtr subpicture,
int *num_priv, CARD32 **priv);
typedef int (*XvMCCreateSubpictureProcPtr) (
XvMCSubpicturePtr subpicture,
int *num_priv,
CARD32 **priv
);
typedef void (*XvMCDestroySubpictureProcPtr) (
XvMCSubpicturePtr subpicture
);
typedef void (*XvMCDestroySubpictureProcPtr) (XvMCSubpicturePtr subpicture);
typedef struct {
XvAdaptorPtr xv_adaptor;
@@ -84,15 +101,18 @@ typedef struct {
XvMCDestroySubpictureProcPtr DestroySubpicture;
} XvMCAdaptorRec, *XvMCAdaptorPtr;
extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr);
#ifndef XorgLoader
extern _X_EXPORT void XvMCExtensionInit(void);
extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen,
int num, XvMCAdaptorPtr adapt);
int num,
XvMCAdaptorPtr adapt);
extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name,
const char *busID, int major, int minor,
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
char *busID, int major, int minor,
int patchLevel);
#endif
#endif /* _XVMC_H */

View File

@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = libXi.la libXistubs.la
noinst_LTLIBRARIES = libXi.la
AM_CFLAGS = $(DIX_CFLAGS)
@@ -78,8 +78,6 @@ libXi_la_SOURCES = \
ungrdevk.h \
xiallowev.c \
xiallowev.h \
xibarriers.c \
xibarriers.h \
xichangecursor.c \
xichangecursor.h \
xichangehierarchy.c \
@@ -107,5 +105,4 @@ libXi_la_SOURCES = \
xiwarppointer.c \
xiwarppointer.h
libXistubs_la_SOURCES = \
stubs.c
EXTRA_DIST = stubs.c

View File

@@ -69,13 +69,15 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXAllowDeviceEvents(ClientPtr client)
{
char n;
REQUEST(xAllowDeviceEventsReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
swapl(&stuff->time);
swapl(&stuff->time, n);
return (ProcXAllowDeviceEvents(client));
}

View File

@@ -71,18 +71,19 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXChangeDeviceControl(ClientPtr client)
{
char n;
xDeviceCtl *ctl;
REQUEST(xChangeDeviceControlReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
swaps(&stuff->control);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
swaps(&stuff->control, n);
ctl = (xDeviceCtl*)&stuff[1];
swaps(&ctl->control);
swaps(&ctl->length);
swaps(&ctl->control, n);
swaps(&ctl->length, n);
switch(stuff->control) {
case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA:
@@ -113,35 +114,26 @@ ProcXChangeDeviceControl(ClientPtr client)
AxisInfoPtr a;
CARD32 *resolution;
xDeviceEnableCtl *e;
devicePresenceNotify dpn;
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq));
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
goto out;
/* XTest devices are special, none of the below apply to them anyway */
if (IsXTestDevice(dev, NULL)) {
ret = BadMatch;
goto out;
}
rep = (xChangeDeviceControlReply) {
.repType = X_Reply,
.RepType = X_ChangeDeviceControl,
.sequenceNumber = client->sequence,
.length = 0,
.status = Success,
};
rep.repType = X_Reply;
rep.RepType = X_ChangeDeviceControl;
rep.length = 0;
rep.sequenceNumber = client->sequence;
switch (stuff->control) {
case DEVICE_RESOLUTION:
r = (xDeviceResolutionCtl *) & stuff[1];
if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) ||
(len !=
bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) {
(len != bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) {
ret = BadLength;
goto out;
}
@@ -170,12 +162,10 @@ ProcXChangeDeviceControl(ClientPtr client)
(a++)->resolution = *resolution++;
ret = Success;
}
else if (status == DeviceBusy) {
} else if (status == DeviceBusy) {
rep.status = DeviceBusy;
ret = Success;
}
else {
} else {
ret = BadMatch;
}
break;
@@ -192,14 +182,7 @@ ProcXChangeDeviceControl(ClientPtr client)
break;
case DEVICE_ENABLE:
e = (xDeviceEnableCtl *)&stuff[1];
if ((len != bytes_to_int32(sizeof(xDeviceEnableCtl)))) {
ret = BadLength;
goto out;
}
if (IsXTestDevice(dev, NULL))
status = !Success;
else
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e);
if (status == Success) {
@@ -208,12 +191,10 @@ ProcXChangeDeviceControl(ClientPtr client)
else
DisableDevice(dev, TRUE);
ret = Success;
}
else if (status == DeviceBusy) {
} else if (status == DeviceBusy) {
rep.status = DeviceBusy;
ret = Success;
}
else {
} else {
ret = BadMatch;
}
@@ -224,13 +205,11 @@ ProcXChangeDeviceControl(ClientPtr client)
out:
if (ret == Success) {
devicePresenceNotify dpn = {
.type = DevicePresenceNotify,
.time = currentTime.milliseconds,
.devchange = DeviceControlChanged,
.deviceid = dev->id,
.control = stuff->control
};
dpn.type = DevicePresenceNotify;
dpn.time = currentTime.milliseconds;
dpn.devchange = DeviceControlChanged;
dpn.deviceid = dev->id;
dpn.control = stuff->control;
SendEventToAllWindows(dev, DevicePresenceNotifyMask,
(xEvent *) &dpn, 1);
@@ -247,11 +226,13 @@ ProcXChangeDeviceControl(ClientPtr client)
*
*/
void _X_COLD
void
SRepXChangeDeviceControl(ClientPtr client, int size,
xChangeDeviceControlReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -71,13 +71,15 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXChangeFeedbackControl(ClientPtr client)
{
char n;
REQUEST(xChangeFeedbackControlReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
swapl(&stuff->mask);
swapl(&stuff->mask, n);
return (ProcXChangeFeedbackControl(client));
}
@@ -91,16 +93,17 @@ static int
ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
KbdFeedbackPtr k, xKbdFeedbackCtl * f)
{
char n;
KeybdCtrl kctrl;
int t;
int key = DO_ALL;
if (client->swapped) {
swaps(&f->length);
swaps(&f->pitch);
swaps(&f->duration);
swapl(&f->led_mask);
swapl(&f->led_values);
swaps(&f->length, n);
swaps(&f->pitch, n);
swaps(&f->duration, n);
swapl(&f->led_mask, n);
swapl(&f->led_values, n);
}
kctrl = k->ctrl;
@@ -173,14 +176,12 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.autoRepeat = FALSE;
else
kctrl.autoRepeats[inx] &= ~kmask;
}
else if (t == AutoRepeatModeOn) {
} else if (t == AutoRepeatModeOn) {
if (key == DO_ALL)
kctrl.autoRepeat = TRUE;
else
kctrl.autoRepeats[inx] |= kmask;
}
else if (t == AutoRepeatModeDefault) {
} else if (t == AutoRepeatModeDefault) {
if (key == DO_ALL)
kctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
else
@@ -188,8 +189,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.autoRepeats[inx] =
(kctrl.autoRepeats[inx] & ~kmask) |
(defaultKeyboardControl.autoRepeats[inx] & kmask);
}
else {
} else {
client->errorValue = t;
return BadValue;
}
@@ -210,13 +210,14 @@ static int
ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
PtrFeedbackPtr p, xPtrFeedbackCtl * f)
{
char n;
PtrCtrl pctrl; /* might get BadValue part way through */
if (client->swapped) {
swaps(&f->length);
swaps(&f->num);
swaps(&f->denom);
swaps(&f->thresh);
swaps(&f->length, n);
swaps(&f->num, n);
swaps(&f->denom, n);
swaps(&f->thresh, n);
}
pctrl = p->ctrl;
@@ -229,8 +230,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
else if (accelNum < 0) {
client->errorValue = accelNum;
return BadValue;
}
else
} else
pctrl.num = accelNum;
}
@@ -243,8 +243,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
else if (accelDenom <= 0) {
client->errorValue = accelDenom;
return BadValue;
}
else
} else
pctrl.den = accelDenom;
}
@@ -257,8 +256,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
else if (threshold < 0) {
client->errorValue = threshold;
return BadValue;
}
else
} else
pctrl.threshold = threshold;
}
@@ -278,9 +276,11 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, IntegerFeedbackPtr i,
xIntegerFeedbackCtl * f)
{
char n;
if (client->swapped) {
swaps(&f->length);
swapl(&f->int_to_display);
swaps(&f->length, n);
swapl(&f->int_to_display, n);
}
i->ctrl.integer_displayed = f->int_to_display;
@@ -299,12 +299,13 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, StringFeedbackPtr s,
xStringFeedbackCtl * f)
{
char n;
int i, j;
KeySym *syms, *sup_syms;
syms = (KeySym *) (f + 1);
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);
}
@@ -338,13 +339,14 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, BellFeedbackPtr b,
xBellFeedbackCtl * f)
{
char n;
int t;
BellCtrl bctrl; /* might get BadValue part way through */
if (client->swapped) {
swaps(&f->length);
swaps(&f->pitch);
swaps(&f->duration);
swaps(&f->length, n);
swaps(&f->pitch, n);
swaps(&f->duration, n);
}
bctrl = b->ctrl;
@@ -395,12 +397,13 @@ static int
ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
LedFeedbackPtr l, xLedFeedbackCtl * f)
{
char n;
LedCtrl lctrl; /* might get BadValue part way through */
if (client->swapped) {
swaps(&f->length);
swapl(&f->led_values);
swapl(&f->led_mask);
swaps(&f->length, n);
swapl(&f->led_values, n);
swapl(&f->led_mask, n);
}
f->led_mask &= l->ctrl.led_mask; /* set only supported leds */
@@ -464,15 +467,13 @@ ProcXChangeFeedbackControl(ClientPtr client)
break;
case StringFeedbackClass:
{
char n;
xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]);
if (client->swapped) {
if (len < bytes_to_int32(sizeof(xStringFeedbackCtl)))
return BadLength;
swaps(&f->num_keysyms);
swaps(&f->num_keysyms, n);
}
if (len !=
(bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
if (len != (bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
return BadLength;
for (s = dev->stringfeed; s; s = s->next)
@@ -488,8 +489,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
for (i = dev->intfeed; i; i = i->next)
if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id)
return ChangeIntegerFeedback(client, dev, stuff->mask, i,
(xIntegerFeedbackCtl *) &
stuff[1]);
(xIntegerFeedbackCtl *)&stuff[1]);
break;
case LedFeedbackClass:
if (len != bytes_to_int32(sizeof(xLedFeedbackCtl)))
@@ -515,3 +515,4 @@ ProcXChangeFeedbackControl(ClientPtr client)
return BadMatch;
}

View File

@@ -72,11 +72,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXChangeKeyboardDevice(ClientPtr client)
{
char n;
REQUEST(xChangeKeyboardDeviceReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
return (ProcXChangeKeyboardDevice(client));
}

View File

@@ -69,13 +69,14 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXChangeDeviceKeyMapping(ClientPtr client)
{
char n;
unsigned int count;
REQUEST(xChangeDeviceKeyMappingReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
count = stuff->keyCodes * stuff->keySymsPerKeyCode;
REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));

View File

@@ -71,14 +71,16 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXChangeDeviceDontPropagateList(ClientPtr client)
{
char n;
REQUEST(xChangeDeviceDontPropagateListReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
swapl(&stuff->window);
swaps(&stuff->count);
swapl(&stuff->window, n);
swaps(&stuff->count, n);
REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq,
stuff->count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
@@ -102,8 +104,7 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client)
REQUEST(xChangeDeviceDontPropagateListReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
if (stuff->length !=
bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) +
if (stuff->length != bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) +
stuff->count)
return BadLength;

View File

@@ -74,11 +74,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXChangePointerDevice(ClientPtr client)
{
char n;
REQUEST(xChangePointerDeviceReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
return (ProcXChangePointerDevice(client));
}

View File

@@ -39,4 +39,10 @@ int ProcXChangePointerDevice(ClientPtr /* client */
void DeleteFocusClassDeviceStruct(DeviceIntPtr /* dev */
);
void SendEventToAllWindows(DeviceIntPtr /* dev */ ,
Mask /* mask */ ,
xEvent * /* ev */ ,
int /* count */
);
#endif /* CHGPTR_H */

View File

@@ -70,11 +70,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXCloseDevice(ClientPtr client)
{
char n;
REQUEST(xCloseDeviceReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCloseDeviceReq);
return (ProcXCloseDevice(client));
}

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXDeviceBell(ClientPtr client)
{
char n;
REQUEST(xDeviceBellReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXDeviceBell(client));
}
@@ -91,7 +93,7 @@ ProcXDeviceBell(ClientPtr client)
int rc, base;
int newpercent;
CARD8 class;
void *ctrl;
pointer ctrl;
BellProcPtr proc;
REQUEST(xDeviceBellReq);
@@ -117,10 +119,9 @@ ProcXDeviceBell(ClientPtr client)
}
base = k->ctrl.bell;
proc = k->BellProc;
ctrl = (void *) &(k->ctrl);
ctrl = (pointer) & (k->ctrl);
class = KbdFeedbackClass;
}
else if (stuff->feedbackclass == BellFeedbackClass) {
} else if (stuff->feedbackclass == BellFeedbackClass) {
for (b = dev->bell; b; b = b->next)
if (b->ctrl.id == stuff->feedbackid)
break;
@@ -130,10 +131,9 @@ ProcXDeviceBell(ClientPtr client)
}
base = b->ctrl.percent;
proc = b->BellProc;
ctrl = (void *) &(b->ctrl);
ctrl = (pointer) & (b->ctrl);
class = BellFeedbackClass;
}
else {
} else {
client->errorValue = stuff->feedbackclass;
return BadValue;
}
@@ -142,8 +142,7 @@ ProcXDeviceBell(ClientPtr client)
newpercent = base + newpercent;
else
newpercent = base - newpercent + stuff->percent;
if (proc == NULL)
return BadValue;
(*proc) (newpercent, dev, ctrl, class);
return Success;
}

File diff suppressed because it is too large Load Diff

View File

@@ -79,7 +79,6 @@ extern int DevicePropertyNotify;
extern RESTYPE RT_INPUTCLIENT;
extern DevPrivateKeyRec XIClientPrivateKeyRec;
#define XIClientPrivateKey (&XIClientPrivateKeyRec)
#endif /* EXGLOBALS_H */

View File

@@ -49,6 +49,8 @@ SOFTWARE.
* Dispatch routines and initialization routines for the X input extension.
*
*/
#define ARRAY_SIZE(_a) (sizeof((_a)) / sizeof((_a)[0]))
#define NUMTYPES 15
#ifdef HAVE_DIX_CONFIG_H
@@ -122,7 +124,7 @@ SOFTWARE.
#include "xiqueryversion.h"
#include "xisetclientpointer.h"
#include "xiwarppointer.h"
#include "xibarriers.h"
/* Masks for XI events have to be aligned with core event (partially anyway).
* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery
@@ -149,35 +151,38 @@ const Mask ChangeDeviceNotifyMask = (1L << 16);
const Mask DeviceButtonGrabMask = (1L << 17);
const Mask DeviceOwnerGrabButtonMask = (1L << 17);
const Mask DevicePresenceNotifyMask = (1L << 18);
const Mask DevicePropertyNotifyMask = (1L << 19);
const Mask XIAllMasks = (1L << 20) - 1;
const Mask DeviceEnterWindowMask = (1L << 18);
const Mask DeviceLeaveWindowMask = (1L << 19);
const Mask DevicePropertyNotifyMask = (1L << 20);
const Mask XIAllMasks = (1L << 21) - 1;
int ExtEventIndex;
Mask ExtExclusiveMasks[EMASKSIZE];
static struct dev_type {
static struct dev_type
{
Atom type;
const char *name;
char *name;
} dev_type[] = {
{0, XI_KEYBOARD},
{0, XI_MOUSE},
{0, XI_TABLET},
{0, XI_TOUCHSCREEN},
{0, XI_TOUCHPAD},
{0, XI_BARCODE},
{0, XI_BUTTONBOX},
{0, XI_KNOB_BOX},
{0, XI_ONE_KNOB},
{0, XI_NINE_KNOB},
{0, XI_TRACKBALL},
{0, XI_QUADRATURE},
{0, XI_ID_MODULE},
{0, XI_SPACEBALL},
{0, XI_DATAGLOVE},
{0, XI_EYETRACKER},
{0, XI_CURSORKEYS},
{0, XI_FOOTMOUSE}
};
{
0, XI_KEYBOARD}, {
0, XI_MOUSE}, {
0, XI_TABLET}, {
0, XI_TOUCHSCREEN}, {
0, XI_TOUCHPAD}, {
0, XI_BARCODE}, {
0, XI_BUTTONBOX}, {
0, XI_KNOB_BOX}, {
0, XI_ONE_KNOB}, {
0, XI_NINE_KNOB}, {
0, XI_TRACKBALL}, {
0, XI_QUADRATURE}, {
0, XI_ID_MODULE}, {
0, XI_SPACEBALL}, {
0, XI_DATAGLOVE}, {
0, XI_EYETRACKER}, {
0, XI_CURSORKEYS}, {
0, XI_FOOTMOUSE}};
CARD8 event_base[numInputClasses];
XExtEventInfo EventInfo[32];
@@ -252,8 +257,7 @@ static int (*ProcIVector[]) (ClientPtr) = {
ProcXIChangeProperty, /* 57 */
ProcXIDeleteProperty, /* 58 */
ProcXIGetProperty, /* 59 */
ProcXIGetSelectedEvents, /* 60 */
ProcXIBarrierReleasePointer /* 61 */
ProcXIGetSelectedEvents /* 60 */
};
/* For swapped clients */
@@ -318,8 +322,7 @@ static int (*SProcIVector[]) (ClientPtr) = {
SProcXIChangeProperty, /* 57 */
SProcXIDeleteProperty, /* 58 */
SProcXIGetProperty, /* 59 */
SProcXIGetSelectedEvents, /* 60 */
SProcXIBarrierReleasePointer /* 61 */
SProcXIGetSelectedEvents /* 60 */
};
/*****************************************************************
@@ -364,7 +367,8 @@ RESTYPE RT_INPUTCLIENT;
extern XExtensionVersion XIVersion;
Mask PropagateMask[EMASKSIZE];
Mask PropagateMask[MAXDEVICES];
/*****************************************************************
*
@@ -380,6 +384,20 @@ DevPrivateKeyRec XIClientPrivateKeyRec;
*
*/
static void
XIClientCallback(CallbackListPtr *list,
pointer closure,
pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec*)data;
ClientPtr pClient = clientinfo->client;
XIClientPtr pXIClient;
pXIClient = dixLookupPrivate(&pClient->devPrivates, XIClientPrivateKey);
pXIClient->major_version = 0;
pXIClient->minor_version = 0;
}
/*************************************************************************
*
* ProcIDispatch - main dispatch routine for requests to this extension.
@@ -394,7 +412,6 @@ ProcIDispatch(ClientPtr client)
if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
return BadRequest;
UpdateCurrentTimeIf();
return (*ProcIVector[stuff->data])(client);
}
@@ -407,14 +424,13 @@ ProcIDispatch(ClientPtr client)
*
*/
static int _X_COLD
static int
SProcIDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
return BadRequest;
UpdateCurrentTimeIf();
return (*SProcIVector[stuff->data])(client);
}
@@ -425,11 +441,10 @@ SProcIDispatch(ClientPtr client)
*
*/
static void _X_COLD
static void
SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
{
/* All we look at is the type field */
/* This is common to all replies */
{ /* This is common to all replies */
if (rep->RepType == X_GetExtensionVersion)
SRepXGetExtensionVersion(client, len,
(xGetExtensionVersionReply *) rep);
@@ -481,8 +496,7 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
SRepXChangeDeviceControl(client, len,
(xChangeDeviceControlReply *) rep);
else if (rep->RepType == X_ListDeviceProperties)
SRepXListDeviceProperties(client, len,
(xListDevicePropertiesReply *) rep);
SRepXListDeviceProperties(client, len, (xListDevicePropertiesReply*)rep);
else if (rep->RepType == X_GetDeviceProperty)
SRepXGetDeviceProperty(client, len, (xGetDevicePropertyReply *) rep);
else if (rep->RepType == X_XIQueryPointer)
@@ -519,39 +533,43 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
static void
SEventDeviceValuator(deviceValuator * from, deviceValuator * to)
{
char n;
int i;
INT32 *ip B32;
*to = *from;
swaps(&to->sequenceNumber);
swaps(&to->device_state);
swaps(&to->sequenceNumber, n);
swaps(&to->device_state, n);
ip = &to->valuator0;
for (i = 0; i < 6; i++) {
swapl(ip + i);
swapl((ip + i), n); /* macro - braces are required */
}
}
static void
SEventFocus(deviceFocus * from, deviceFocus * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->time);
swapl(&to->window);
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
swapl(&to->window, n);
}
static void
SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
{
int i;
char n;
INT32 *ip B32;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->time);
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
ip = &to->valuator0;
for (i = 0; i < 3; i++) {
swapl(ip + i);
swapl((ip + i), n); /* macro - braces are required */
}
}
@@ -559,80 +577,93 @@ static void
SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from,
deviceKeyStateNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swaps(&to->sequenceNumber, n);
}
static void
SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from,
deviceButtonStateNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swaps(&to->sequenceNumber, n);
}
static void
SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->time);
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
}
static void
SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->time);
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
}
static void
SDevicePresenceNotifyEvent(devicePresenceNotify * from,
devicePresenceNotify * to)
SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->time);
swaps(&to->control);
swaps(&to->sequenceNumber,n);
swapl(&to->time, n);
swaps(&to->control, n);
}
static void
SDevicePropertyNotifyEvent(devicePropertyNotify * from,
devicePropertyNotify * to)
SDevicePropertyNotifyEvent (devicePropertyNotify *from, devicePropertyNotify *to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->time);
swapl(&to->atom);
swaps(&to->sequenceNumber,n);
swapl(&to->time, n);
swapl(&to->atom, n);
}
static void
SDeviceLeaveNotifyEvent (xXILeaveEvent *from, xXILeaveEvent *to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->time);
swapl(&to->root);
swapl(&to->event);
swapl(&to->child);
swapl(&to->root_x);
swapl(&to->root_y);
swapl(&to->event_x);
swapl(&to->event_y);
swaps(&to->sourceid);
swaps(&to->buttons_len);
swapl(&to->mods.base_mods);
swapl(&to->mods.latched_mods);
swapl(&to->mods.locked_mods);
swaps(&to->sequenceNumber,n);
swapl(&to->length, n);
swaps(&to->evtype, n);
swaps(&to->deviceid, n);
swapl(&to->time, n);
swapl(&to->root, n);
swapl(&to->event, n);
swapl(&to->child, n);
swapl(&to->root_x, n);
swapl(&to->root_y, n);
swapl(&to->event_x, n);
swapl(&to->event_y, n);
swaps(&to->sourceid, n);
swaps(&to->buttons_len, n);
swapl(&to->mods.base_mods, n);
swapl(&to->mods.latched_mods, n);
swapl(&to->mods.locked_mods, n);
}
static void
SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to)
{
char n;
int i, j;
xXIAnyInfo *any;
@@ -640,229 +671,195 @@ SDeviceChangedEvent(xXIDeviceChangedEvent * from, xXIDeviceChangedEvent * to)
memcpy(&to[1], &from[1], from->length * 4);
any = (xXIAnyInfo*)&to[1];
for (i = 0; i < to->num_classes; i++) {
for (i = 0; i < to->num_classes; i++)
{
int length = any->length;
switch (any->type) {
switch(any->type)
{
case KeyClass:
{
xXIKeyInfo *ki = (xXIKeyInfo*)any;
uint32_t *key = (uint32_t*)&ki[1];
for (j = 0; j < ki->num_keycodes; j++, key++)
swapl(key);
swaps(&ki->num_keycodes);
swapl(key, n);
swaps(&ki->num_keycodes, n);
}
break;
case ButtonClass:
{
xXIButtonInfo *bi = (xXIButtonInfo*)any;
Atom *labels = (Atom*)((char*)bi + sizeof(xXIButtonInfo) +
pad_to_int32(bits_to_bytes
(bi->num_buttons)));
pad_to_int32(bits_to_bytes(bi->num_buttons)));
for (j = 0; j < bi->num_buttons; j++)
swapl(&labels[j]);
swaps(&bi->num_buttons);
swapl(&labels[j], n);
swaps(&bi->num_buttons, n);
}
break;
case ValuatorClass:
{
xXIValuatorInfo* ai = (xXIValuatorInfo*)any;
swapl(&ai->label);
swapl(&ai->min.integral);
swapl(&ai->min.frac);
swapl(&ai->max.integral);
swapl(&ai->max.frac);
swapl(&ai->resolution);
swaps(&ai->number);
swapl(&ai->label, n);
swapl(&ai->min.integral, n);
swapl(&ai->min.frac, n);
swapl(&ai->max.integral, n);
swapl(&ai->max.frac, n);
swapl(&ai->resolution, n);
swaps(&ai->number, n);
}
break;
}
swaps(&any->type);
swaps(&any->length);
swaps(&any->sourceid);
swaps(&any->type, n);
swaps(&any->length, n);
swaps(&any->sourceid, n);
any = (xXIAnyInfo*)((char*)any + length * 4);
}
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->time);
swaps(&to->num_classes);
swaps(&to->sourceid);
swaps(&to->sequenceNumber, n);
swapl(&to->length, n);
swaps(&to->evtype, n);
swaps(&to->deviceid, n);
swapl(&to->time, n);
swaps(&to->num_classes, n);
swaps(&to->sourceid, n);
}
static void
SDeviceEvent(xXIDeviceEvent * from, xXIDeviceEvent * to)
static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to)
{
int i;
char n;
char *ptr;
char *vmask;
memcpy(to, from, sizeof(xEvent) + from->length * 4);
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->time);
swapl(&to->detail);
swapl(&to->root);
swapl(&to->event);
swapl(&to->child);
swapl(&to->root_x);
swapl(&to->root_y);
swapl(&to->event_x);
swapl(&to->event_y);
swaps(&to->buttons_len);
swaps(&to->valuators_len);
swaps(&to->sourceid);
swapl(&to->mods.base_mods);
swapl(&to->mods.latched_mods);
swapl(&to->mods.locked_mods);
swapl(&to->mods.effective_mods);
swapl(&to->flags);
swaps(&to->sequenceNumber, n);
swapl(&to->length, n);
swaps(&to->evtype, n);
swaps(&to->deviceid, n);
swapl(&to->time, n);
swapl(&to->detail, n);
swapl(&to->root, n);
swapl(&to->event, n);
swapl(&to->child, n);
swapl(&to->root_x, n);
swapl(&to->root_y, n);
swapl(&to->event_x, n);
swapl(&to->event_y, n);
swaps(&to->buttons_len, n);
swaps(&to->valuators_len, n);
swaps(&to->sourceid, n);
swapl(&to->mods.base_mods, n);
swapl(&to->mods.latched_mods, n);
swapl(&to->mods.locked_mods, n);
swapl(&to->mods.effective_mods, n);
swapl(&to->flags, n);
ptr = (char*)(&to[1]);
ptr += from->buttons_len * 4;
vmask = ptr; /* valuator mask */
ptr += from->valuators_len * 4;
for (i = 0; i < from->valuators_len * 32; i++) {
if (BitIsOn(vmask, i)) {
swapl(((uint32_t *) ptr));
for (i = 0; i < from->valuators_len * 32; i++)
{
if (BitIsOn(vmask, i))
{
swapl(((uint32_t*)ptr), n);
ptr += 4;
swapl(((uint32_t *) ptr));
swapl(((uint32_t*)ptr), n);
ptr += 4;
}
}
}
static void
SDeviceHierarchyEvent(xXIHierarchyEvent * from, xXIHierarchyEvent * to)
static void SDeviceHierarchyEvent(xXIHierarchyEvent *from,
xXIHierarchyEvent *to)
{
int i;
char n;
xXIHierarchyInfo *info;
*to = *from;
memcpy(&to[1], &from[1], from->length * 4);
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->time);
swapl(&to->flags);
swaps(&to->num_info);
swaps(&to->sequenceNumber, n);
swapl(&to->length, n);
swaps(&to->evtype, n);
swaps(&to->deviceid, n);
swapl(&to->time, n);
swapl(&to->flags, n);
swaps(&to->num_info, n);
info = (xXIHierarchyInfo*)&to[1];
for (i = 0; i < from->num_info; i++) {
swaps(&info->deviceid);
swaps(&info->attachment);
for (i = 0; i< from->num_info; i++)
{
swaps(&info->deviceid, n);
swaps(&info->attachment, n);
info++;
}
}
static void
SXIPropertyEvent(xXIPropertyEvent * from, xXIPropertyEvent * to)
static void SXIPropertyEvent(xXIPropertyEvent *from, xXIPropertyEvent *to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->property);
swaps(&to->sequenceNumber, n);
swapl(&to->length, n);
swaps(&to->evtype, n);
swaps(&to->deviceid, n);
swapl(&to->property, n);
}
static void
SRawEvent(xXIRawEvent * from, xXIRawEvent * to)
static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to)
{
char n;
int i;
FP3232 *values;
unsigned char *mask;
memcpy(to, from, sizeof(xEvent) + from->length * 4);
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->time);
swapl(&to->detail);
swaps(&to->sequenceNumber, n);
swapl(&to->length, n);
swaps(&to->evtype, n);
swaps(&to->deviceid, n);
swapl(&to->time, n);
swapl(&to->detail, n);
mask = (unsigned char*)&to[1];
values = (FP3232*)(mask + from->valuators_len * 4);
for (i = 0; i < from->valuators_len * 4 * 8; i++) {
if (BitIsOn(mask, i)) {
for (i = 0; i < from->valuators_len * 4 * 8; i++)
{
if (BitIsOn(mask, i))
{
/* for each bit set there are two FP3232 values on the wire, in
* the order abcABC for data and data_raw. Here we swap as if
* they were in aAbBcC order because it's easier and really
* doesn't matter.
*/
swapl(&values->integral);
swapl(&values->frac);
swapl(&values->integral, n);
swapl(&values->frac, n);
values++;
swapl(&values->integral);
swapl(&values->frac);
swapl(&values->integral, n);
swapl(&values->frac, n);
values++;
}
}
swaps(&to->valuators_len);
swaps(&to->valuators_len, n);
}
static void
STouchOwnershipEvent(xXITouchOwnershipEvent * from, xXITouchOwnershipEvent * to)
{
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swaps(&to->deviceid);
swapl(&to->time);
swaps(&to->sourceid);
swapl(&to->touchid);
swapl(&to->flags);
swapl(&to->root);
swapl(&to->event);
swapl(&to->child);
}
static void
SBarrierEvent(xXIBarrierEvent * from,
xXIBarrierEvent * to) {
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
swapl(&to->time);
swaps(&to->deviceid);
swaps(&to->sourceid);
swapl(&to->event);
swapl(&to->root);
swapl(&to->root_x);
swapl(&to->root_y);
swapl(&to->dx.integral);
swapl(&to->dx.frac);
swapl(&to->dy.integral);
swapl(&to->dy.frac);
swapl(&to->dtime);
swapl(&to->barrier);
swapl(&to->eventid);
}
/** Event swapping function for XI2 events. */
void _X_COLD
void
XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
{
switch (from->evtype) {
switch(from->evtype)
{
case XI_Enter:
case XI_Leave:
case XI_FocusIn:
@@ -874,41 +871,26 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
(xXIDeviceChangedEvent*)to);
break;
case XI_HierarchyChanged:
SDeviceHierarchyEvent((xXIHierarchyEvent *) from,
(xXIHierarchyEvent *) to);
SDeviceHierarchyEvent((xXIHierarchyEvent*)from, (xXIHierarchyEvent*)to);
break;
case XI_PropertyEvent:
SXIPropertyEvent((xXIPropertyEvent *) from, (xXIPropertyEvent *) to);
SXIPropertyEvent((xXIPropertyEvent*)from,
(xXIPropertyEvent*)to);
break;
case XI_Motion:
case XI_KeyPress:
case XI_KeyRelease:
case XI_ButtonPress:
case XI_ButtonRelease:
case XI_TouchBegin:
case XI_TouchUpdate:
case XI_TouchEnd:
SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to);
break;
case XI_TouchOwnership:
STouchOwnershipEvent((xXITouchOwnershipEvent *) from,
(xXITouchOwnershipEvent *) to);
break;
case XI_RawMotion:
case XI_RawKeyPress:
case XI_RawKeyRelease:
case XI_RawButtonPress:
case XI_RawButtonRelease:
case XI_RawTouchBegin:
case XI_RawTouchUpdate:
case XI_RawTouchEnd:
SRawEvent((xXIRawEvent*)from, (xXIRawEvent*)to);
break;
case XI_BarrierHit:
case XI_BarrierLeave:
SBarrierEvent((xXIBarrierEvent *) from,
(xXIBarrierEvent *) to);
break;
default:
ErrorF("[Xi] Unknown event type to swap. This is a bug.\n");
break;
@@ -1094,7 +1076,8 @@ RestoreExtensionEvents(void)
IEventBase = 0;
for (i = 0; i < ExtEventIndex - 1; i++) {
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128)) {
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
{
for (j = 0; j < MAXDEVICES; j++)
SetMaskForEvent(j, 0, EventInfo[i].type);
}
@@ -1158,13 +1141,9 @@ IResetProc(ExtensionEntry * unused)
EventSwapVector[DevicePresenceNotify] = NotImplemented;
EventSwapVector[DevicePropertyNotify] = NotImplemented;
RestoreExtensionEvents();
free(xi_all_devices.name);
free(xi_all_master_devices.name);
XIBarrierReset();
}
/***********************************************************************
*
* Assign an id and type to an input device.
@@ -1172,7 +1151,7 @@ IResetProc(ExtensionEntry * unused)
*/
void
AssignTypeAndName(DeviceIntPtr dev, Atom type, const char *name)
AssignTypeAndName(DeviceIntPtr dev, Atom type, char *name)
{
dev->xinput_type = type;
dev->name = strdup(name);
@@ -1202,7 +1181,7 @@ MakeDeviceTypeAtoms(void)
*/
#define DO_SWAP(func,type) func ((type *)from, (type *)to)
static void _X_COLD
static void
SEventIDispatch(xEvent * from, xEvent * to)
{
int type = from->u.u.type & 0177;
@@ -1212,36 +1191,29 @@ SEventIDispatch(xEvent *from, xEvent *to)
else if (type == DeviceKeyPress) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceKeyRelease) {
} else if (type == DeviceKeyRelease) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceButtonPress) {
} else if (type == DeviceButtonPress) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceButtonRelease) {
} else if (type == DeviceButtonRelease) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceMotionNotify) {
} else if (type == DeviceMotionNotify) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceFocusIn)
} else if (type == DeviceFocusIn)
DO_SWAP(SEventFocus, deviceFocus);
else if (type == DeviceFocusOut)
DO_SWAP(SEventFocus, deviceFocus);
else if (type == ProximityIn) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == ProximityOut) {
} else if (type == ProximityOut) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceStateNotify)
} else if (type == DeviceStateNotify)
DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
else if (type == DeviceKeyStateNotify)
DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
@@ -1276,18 +1248,16 @@ void
XInputExtensionInit(void)
{
ExtensionEntry *extEntry;
XExtensionVersion thisversion = { XI_Present,
SERVER_XI_MAJOR_VERSION,
SERVER_XI_MINOR_VERSION,
};
if (!dixRegisterPrivateKey
(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
FatalError("Cannot request private for XI.\n");
if (!XIBarrierInit())
FatalError("Could not initialize barriers.\n");
if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))
FatalError("Failed to add callback to XI.\n");
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
SProcIDispatch, IResetProc, StandardMinorOpcode);
@@ -1321,19 +1291,20 @@ XInputExtensionInit(void)
GERegisterExtension(IReqCode, XI2EventSwap);
memset(&xi_all_devices, 0, sizeof(xi_all_devices));
memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices));
xi_all_devices.id = XIAllDevices;
xi_all_devices.name = strdup("XIAllDevices");
xi_all_devices.name = "XIAllDevices";
xi_all_master_devices.id = XIAllMasterDevices;
xi_all_master_devices.name = strdup("XIAllMasterDevices");
xi_all_master_devices.name = "XIAllMasterDevices";
inputInfo.all_devices = &xi_all_devices;
inputInfo.all_master_devices = &xi_all_master_devices;
XIResetProperties();
}
else {
} else {
FatalError("IExtensionInit: AddExtensions failed\n");
}
}

View File

@@ -67,11 +67,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetDeviceButtonMapping(ClientPtr client)
{
char n;
REQUEST(xGetDeviceButtonMappingReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXGetDeviceButtonMapping(client));
}
@@ -92,13 +94,11 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
rep = (xGetDeviceButtonMappingReply) {
.repType = X_Reply,
.RepType = X_GetDeviceButtonMapping,
.sequenceNumber = client->sequence,
.nElts = 0,
.length = 0
};
rep.repType = X_Reply;
rep.RepType = X_GetDeviceButtonMapping;
rep.nElts = 0;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
@@ -111,7 +111,7 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
rep.nElts = b->numButtons;
rep.length = bytes_to_int32(rep.nElts);
WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
WriteToClient(client, rep.nElts, &b->map[1]);
(void)WriteToClient(client, rep.nElts, (char *)&b->map[1]);
return Success;
}
@@ -122,11 +122,13 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetDeviceButtonMapping(ClientPtr client, int size,
xGetDeviceButtonMappingReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -68,13 +68,15 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetDeviceControl(ClientPtr client)
{
char n;
REQUEST(xGetDeviceControlReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
swaps(&stuff->control);
swaps(&stuff->control, n);
return (ProcXGetDeviceControl(client));
}
@@ -88,6 +90,7 @@ static void
CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
int length)
{
char n;
AxisInfoPtr a;
xDeviceResolutionState *r;
int i, *iptr;
@@ -105,19 +108,19 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->max_resolution;
if (client->swapped) {
swaps(&r->control);
swaps(&r->length);
swapl(&r->num_valuators);
swaps(&r->control, n);
swaps(&r->length, n);
swapl(&r->num_valuators, n);
iptr = (int *)buf;
for (i = 0; i < (3 * v->numAxes); i++, iptr++) {
swapl(iptr);
swapl(iptr, n);
}
}
}
static void
CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf)
static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
{
char n;
xDeviceCoreState *c = (xDeviceCoreState *) buf;
c->control = DEVICE_CORE;
@@ -126,14 +129,15 @@ CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf)
c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer);
if (client->swapped) {
swaps(&c->control);
swaps(&c->length);
swaps(&c->control, n);
swaps(&c->length, n);
swaps(&c->status, n);
}
}
static void
CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
{
char n;
xDeviceEnableState *e = (xDeviceEnableState *) buf;
e->control = DEVICE_ENABLE;
@@ -141,8 +145,9 @@ CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
e->enable = dev->enabled;
if (client->swapped) {
swaps(&e->control);
swaps(&e->length);
swaps(&e->control, n);
swaps(&e->length, n);
swaps(&e->enable, n);
}
}
@@ -153,12 +158,14 @@ CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
*
*/
void _X_COLD
void
SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}
/***********************************************************************
@@ -182,12 +189,10 @@ ProcXGetDeviceControl(ClientPtr client)
if (rc != Success)
return rc;
rep = (xGetDeviceControlReply) {
.repType = X_Reply,
.RepType = X_GetDeviceControl,
.sequenceNumber = client->sequence,
.length = 0
};
rep.repType = X_Reply;
rep.RepType = X_GetDeviceControl;
rep.length = 0;
rep.sequenceNumber = client->sequence;
switch (stuff->control) {
case DEVICE_RESOLUTION:

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetFeedbackControl(ClientPtr client)
{
char n;
REQUEST(xGetFeedbackControlReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXGetFeedbackControl(client));
}
@@ -86,6 +88,7 @@ static void
CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
{
int i;
char n;
xKbdFeedbackState *k2;
k2 = (xKbdFeedbackState *) * buf;
@@ -101,11 +104,11 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
for (i = 0; i < 32; i++)
k2->auto_repeats[i] = k->ctrl.autoRepeats[i];
if (client->swapped) {
swaps(&k2->length);
swaps(&k2->pitch);
swaps(&k2->duration);
swapl(&k2->led_mask);
swapl(&k2->led_values);
swaps(&k2->length, n);
swaps(&k2->pitch, n);
swaps(&k2->duration, n);
swapl(&k2->led_mask, n);
swapl(&k2->led_values, n);
}
*buf += sizeof(xKbdFeedbackState);
}
@@ -119,6 +122,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
static void
CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
{
char n;
xPtrFeedbackState *p2;
p2 = (xPtrFeedbackState *) * buf;
@@ -129,10 +133,10 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
p2->accelDenom = p->ctrl.den;
p2->threshold = p->ctrl.threshold;
if (client->swapped) {
swaps(&p2->length);
swaps(&p2->accelNum);
swaps(&p2->accelDenom);
swaps(&p2->threshold);
swaps(&p2->length, n);
swaps(&p2->accelNum, n);
swaps(&p2->accelDenom, n);
swaps(&p2->threshold, n);
}
*buf += sizeof(xPtrFeedbackState);
}
@@ -146,6 +150,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
static void
CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
{
char n;
xIntegerFeedbackState *i2;
i2 = (xIntegerFeedbackState *) * buf;
@@ -156,10 +161,10 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
i2->min_value = i->ctrl.min_value;
i2->max_value = i->ctrl.max_value;
if (client->swapped) {
swaps(&i2->length);
swapl(&i2->resolution);
swapl(&i2->min_value);
swapl(&i2->max_value);
swaps(&i2->length, n);
swapl(&i2->resolution, n);
swapl(&i2->min_value, n);
swapl(&i2->max_value, n);
}
*buf += sizeof(xIntegerFeedbackState);
}
@@ -174,6 +179,7 @@ static void
CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
{
int i;
char n;
xStringFeedbackState *s2;
KeySym *kptr;
@@ -189,12 +195,12 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
for (i = 0; i < s->ctrl.num_symbols_supported; i++)
*kptr++ = *(s->ctrl.symbols_supported + i);
if (client->swapped) {
swaps(&s2->length);
swaps(&s2->max_symbols);
swaps(&s2->num_syms_supported);
swaps(&s2->length, n);
swaps(&s2->max_symbols, n);
swaps(&s2->num_syms_supported, n);
kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++, kptr++) {
swapl(kptr);
swapl(kptr, n);
}
}
*buf += (s->ctrl.num_symbols_supported * sizeof(KeySym));
@@ -209,6 +215,7 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
static void
CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
{
char n;
xLedFeedbackState *l2;
l2 = (xLedFeedbackState *) * buf;
@@ -218,9 +225,9 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
l2->led_values = l->ctrl.led_values;
l2->led_mask = l->ctrl.led_mask;
if (client->swapped) {
swaps(&l2->length);
swapl(&l2->led_values);
swapl(&l2->led_mask);
swaps(&l2->length, n);
swapl(&l2->led_values, n);
swapl(&l2->led_mask, n);
}
*buf += sizeof(xLedFeedbackState);
}
@@ -234,6 +241,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
static void
CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
{
char n;
xBellFeedbackState *b2;
b2 = (xBellFeedbackState *) * buf;
@@ -244,9 +252,9 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
b2->pitch = b->ctrl.pitch;
b2->duration = b->ctrl.duration;
if (client->swapped) {
swaps(&b2->length);
swaps(&b2->pitch);
swaps(&b2->duration);
swaps(&b2->length, n);
swaps(&b2->pitch, n);
swaps(&b2->duration, n);
}
*buf += sizeof(xBellFeedbackState);
}
@@ -258,14 +266,16 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
*
*/
void _X_COLD
void
SRepXGetFeedbackControl(ClientPtr client, int size,
xGetFeedbackControlReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->num_feedbacks);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->num_feedbacks, n);
WriteToClient(client, size, (char *)rep);
}
/***********************************************************************
@@ -295,13 +305,11 @@ ProcXGetFeedbackControl(ClientPtr client)
if (rc != Success)
return rc;
rep = (xGetFeedbackControlReply) {
.repType = X_Reply,
.RepType = X_GetFeedbackControl,
.sequenceNumber = client->sequence,
.length = 0,
.num_feedbacks = 0
};
rep.repType = X_Reply;
rep.RepType = X_GetFeedbackControl;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.num_feedbacks = 0;
for (k = dev->kbdfeed; k; k = k->next) {
rep.num_feedbacks++;

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetDeviceFocus(ClientPtr client)
{
char n;
REQUEST(xGetDeviceFocusReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXGetDeviceFocus(client));
}
@@ -99,12 +101,10 @@ ProcXGetDeviceFocus(ClientPtr client)
if (!dev->focus)
return BadDevice;
rep = (xGetDeviceFocusReply) {
.repType = X_Reply,
.RepType = X_GetDeviceFocus,
.sequenceNumber = client->sequence,
.length = 0
};
rep.repType = X_Reply;
rep.RepType = X_GetDeviceFocus;
rep.length = 0;
rep.sequenceNumber = client->sequence;
focus = dev->focus;
@@ -130,12 +130,14 @@ ProcXGetDeviceFocus(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetDeviceFocus(ClientPtr client, int size, xGetDeviceFocusReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swapl(&rep->focus);
swapl(&rep->time);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swapl(&rep->focus, n);
swapl(&rep->time, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -71,11 +71,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetDeviceKeyMapping(ClientPtr client)
{
char n;
REQUEST(xGetDeviceKeyMappingReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXGetDeviceKeyMapping(client));
}
@@ -119,13 +121,11 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
if (!syms)
return BadAlloc;
rep = (xGetDeviceKeyMappingReply) {
.repType = X_Reply,
.RepType = X_GetDeviceKeyMapping,
.sequenceNumber = client->sequence,
.keySymsPerKeyCode = syms->mapWidth,
.length = (syms->mapWidth * stuff->count) /* KeySyms are 4 bytes */
};
rep.repType = X_Reply;
rep.RepType = X_GetDeviceKeyMapping;
rep.sequenceNumber = client->sequence;
rep.keySymsPerKeyCode = syms->mapWidth;
rep.length = (syms->mapWidth * stuff->count); /* KeySyms are 4 bytes */
WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
@@ -146,11 +146,13 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetDeviceKeyMapping(ClientPtr client, int size,
xGetDeviceKeyMappingReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetDeviceModifierMapping(ClientPtr client)
{
char n;
REQUEST(xGetDeviceModifierMappingReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXGetDeviceModifierMapping(client));
}
@@ -101,17 +103,15 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
if (ret != Success)
return ret;
rep = (xGetDeviceModifierMappingReply) {
.repType = X_Reply,
.RepType = X_GetDeviceModifierMapping,
.sequenceNumber = client->sequence,
.numKeyPerModifier = max_keys_per_mod,
rep.repType = X_Reply;
rep.RepType = X_GetDeviceModifierMapping;
rep.numKeyPerModifier = max_keys_per_mod;
rep.sequenceNumber = client->sequence;
/* 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);
WriteToClient(client, max_keys_per_mod * 8, modkeymap);
WriteToClient(client, max_keys_per_mod * 8, (char *) modkeymap);
free(modkeymap);
@@ -125,11 +125,13 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetDeviceModifierMapping(ClientPtr client, int size,
xGetDeviceModifierMappingReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -72,13 +72,15 @@ extern int ExtEventIndex;
*
*/
int _X_COLD
int
SProcXGetDeviceDontPropagateList(ClientPtr client)
{
char n;
REQUEST(xGetDeviceDontPropagateListReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
swapl(&stuff->window);
swapl(&stuff->window, n);
return (ProcXGetDeviceDontPropagateList(client));
}
@@ -101,13 +103,11 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
REQUEST(xGetDeviceDontPropagateListReq);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
rep = (xGetDeviceDontPropagateListReply) {
.repType = X_Reply,
.RepType = X_GetDeviceDontPropagateList,
.sequenceNumber = client->sequence,
.length = 0,
.count = 0
};
rep.repType = X_Reply;
rep.RepType = X_GetDeviceDontPropagateList;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.count = 0;
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
@@ -115,10 +115,11 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
if ((others = wOtherInputMasks(pWin)) != 0) {
for (i = 0; i < EMASKSIZE; i++)
ClassFromMask(NULL, others->dontPropagateMask[i], i, &count, COUNT);
ClassFromMask(NULL, others->dontPropagateMask[i], i,
&count, COUNT);
if (count) {
rep.count = count;
buf = xallocarray(rep.count, sizeof(XEventClass));
buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass));
rep.length = bytes_to_int32(rep.count * sizeof(XEventClass));
tbuf = buf;
@@ -173,12 +174,14 @@ XEventClass
*
*/
void _X_COLD
void
SRepXGetDeviceDontPropagateList(ClientPtr client, int size,
xGetDeviceDontPropagateListReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->count);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->count, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -70,13 +70,15 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetSelectedExtensionEvents(ClientPtr client)
{
char n;
REQUEST(xGetSelectedExtensionEventsReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
swapl(&stuff->window);
swapl(&stuff->window, n);
return (ProcXGetSelectedExtensionEvents(client));
}
@@ -102,14 +104,12 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
REQUEST(xGetSelectedExtensionEventsReq);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
rep = (xGetSelectedExtensionEventsReply) {
.repType = X_Reply,
.RepType = X_GetSelectedExtensionEvents,
.sequenceNumber = client->sequence,
.length = 0,
.this_client_count = 0,
.all_clients_count = 0
};
rep.repType = X_Reply;
rep.RepType = X_GetSelectedExtensionEvents;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.this_client_count = 0;
rep.all_clients_count = 0;
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
@@ -164,13 +164,15 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetSelectedExtensionEvents(ClientPtr client, int size,
xGetSelectedExtensionEventsReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->this_client_count);
swaps(&rep->all_clients_count);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->this_client_count, n);
swaps(&rep->all_clients_count, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -70,13 +70,15 @@ XExtensionVersion XIVersion;
*
*/
int _X_COLD
int
SProcXGetExtensionVersion(ClientPtr client)
{
char n;
REQUEST(xGetExtensionVersionReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
swaps(&stuff->nbytes);
swaps(&stuff->nbytes, n);
return (ProcXGetExtensionVersion(client));
}
@@ -98,15 +100,14 @@ ProcXGetExtensionVersion(ClientPtr client)
stuff->nbytes))
return BadLength;
rep = (xGetExtensionVersionReply) {
.repType = X_Reply,
.RepType = X_GetExtensionVersion,
.sequenceNumber = client->sequence,
.length = 0,
.major_version = XIVersion.major_version,
.minor_version = XIVersion.minor_version,
.present = TRUE
};
memset(&rep, 0, sizeof(xGetExtensionVersionReply));
rep.repType = X_Reply;
rep.RepType = X_GetExtensionVersion;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.present = TRUE;
rep.major_version = XIVersion.major_version;
rep.minor_version = XIVersion.minor_version;
WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep);
@@ -120,13 +121,15 @@ ProcXGetExtensionVersion(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetExtensionVersion(ClientPtr client, int size,
xGetExtensionVersionReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->major_version);
swaps(&rep->minor_version);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swaps(&rep->major_version, n);
swaps(&rep->minor_version, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -72,18 +72,19 @@ extern int ExtEventIndex;
*
*/
int _X_COLD
int
SProcXGrabDevice(ClientPtr client)
{
REQUEST(xGrabDeviceReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
swapl(&stuff->grabWindow);
swapl(&stuff->time);
swaps(&stuff->event_count);
char n;
if (stuff->length !=
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
REQUEST(xGrabDeviceReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
swapl(&stuff->grabWindow, n);
swapl(&stuff->time, n);
swaps(&stuff->event_count, n);
if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
@@ -109,16 +110,13 @@ ProcXGrabDevice(ClientPtr client)
REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
if (stuff->length !=
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
rep = (xGrabDeviceReply) {
.repType = X_Reply,
.RepType = X_GrabDevice,
.sequenceNumber = client->sequence,
.length = 0,
};
rep.repType = X_Reply;
rep.RepType = X_GrabDevice;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
if (rc != Success)
@@ -134,7 +132,8 @@ ProcXGrabDevice(ClientPtr client)
rc = GrabDevice(client, dev, stuff->other_devices_mode,
stuff->this_device_mode, stuff->grabWindow,
stuff->ownerEvents, stuff->time,
&mask, XI, None, None, &rep.status);
&mask, GRABTYPE_XI, None, None,
&rep.status);
if (rc != Success)
return rc;
@@ -175,7 +174,10 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
int device;
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++) {
device = *list >> 8;
@@ -191,7 +193,7 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].type == (*list & 0xff)) {
mask[device].mask |= EventInfo[j].mask;
mask[device].dev = (void *) tdev;
mask[device].dev = (Pointer) tdev;
break;
}
}
@@ -205,10 +207,12 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
*
*/
void _X_COLD
void
SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -71,15 +71,17 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGrabDeviceButton(ClientPtr client)
{
char n;
REQUEST(xGrabDeviceButtonReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
swaps(&stuff->event_count);
swapl(&stuff->grabWindow, n);
swaps(&stuff->modifiers, n);
swaps(&stuff->event_count, n);
REQUEST_FIXED_SIZE(xGrabDeviceButtonReq,
stuff->event_count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
@@ -122,8 +124,7 @@ ProcXGrabDeviceButton(ClientPtr client)
return ret;
if (mdev->key == NULL)
return BadMatch;
}
else {
} else {
mdev = PickKeyboard(client);
ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess);
if (ret != Success)
@@ -137,17 +138,17 @@ ProcXGrabDeviceButton(ClientPtr client)
X_GrabDeviceButton)) != Success)
return ret;
param = (GrabParameters) {
.grabtype = XI,
.ownerEvents = stuff->ownerEvents,
.this_device_mode = stuff->this_device_mode,
.other_devices_mode = stuff->other_devices_mode,
.grabWindow = stuff->grabWindow,
.modifiers = stuff->modifiers
};
memset(&param, 0, sizeof(param));
param.grabtype = GRABTYPE_XI;
param.ownerEvents = stuff->ownerEvents;
param.this_device_mode = stuff->this_device_mode;
param.other_devices_mode = stuff->other_devices_mode;
param.grabWindow = stuff->grabWindow;
param.modifiers = stuff->modifiers;
mask.xi = tmp[stuff->grabbed_device].mask;
ret = GrabButton(client, dev, mdev, stuff->button, &param, XI, &mask);
ret = GrabButton(client, dev, mdev, stuff->button, &param,
GRABTYPE_XI, &mask);
return ret;
}

View File

@@ -71,15 +71,17 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGrabDeviceKey(ClientPtr client)
{
char n;
REQUEST(xGrabDeviceKeyReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
swaps(&stuff->event_count);
swapl(&stuff->grabWindow, n);
swaps(&stuff->modifiers, n);
swaps(&stuff->event_count, n);
REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
return (ProcXGrabDeviceKey(client));
@@ -105,8 +107,7 @@ ProcXGrabDeviceKey(ClientPtr client)
REQUEST(xGrabDeviceKeyReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
if (stuff->length !=
bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count)
if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count)
return BadLength;
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
@@ -120,8 +121,7 @@ ProcXGrabDeviceKey(ClientPtr client)
return ret;
if (mdev->key == NULL)
return BadMatch;
}
else {
} else {
mdev = PickKeyboard(client);
ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess);
if (ret != Success)
@@ -135,17 +135,17 @@ ProcXGrabDeviceKey(ClientPtr client)
X_GrabDeviceKey)) != Success)
return ret;
param = (GrabParameters) {
.grabtype = XI,
.ownerEvents = stuff->ownerEvents,
.this_device_mode = stuff->this_device_mode,
.other_devices_mode = stuff->other_devices_mode,
.grabWindow = stuff->grabWindow,
.modifiers = stuff->modifiers
};
memset(&param, 0, sizeof(param));
param.grabtype = GRABTYPE_XI;
param.ownerEvents = stuff->ownerEvents;
param.this_device_mode = stuff->this_device_mode;
param.other_devices_mode = stuff->other_devices_mode;
param.grabWindow = stuff->grabWindow;
param.modifiers = stuff->modifiers;
mask.xi = tmp[stuff->grabbed_device].mask;
ret = GrabKey(client, dev, mdev, stuff->key, &param, XI, &mask);
ret = GrabKey(client, dev, mdev, stuff->key, &param, GRABTYPE_XI, &mask);
return ret;
}

View File

@@ -68,14 +68,16 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXGetDeviceMotionEvents(ClientPtr client)
{
char n;
REQUEST(xGetDeviceMotionEventsReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
swapl(&stuff->start);
swapl(&stuff->stop);
swapl(&stuff->start, n);
swapl(&stuff->stop, n);
return (ProcXGetDeviceMotionEvents(client));
}
@@ -110,15 +112,13 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
if (dev->valuator->motionHintWindow)
MaybeStopDeviceHint(dev, client);
axes = v->numAxes;
rep = (xGetDeviceMotionEventsReply) {
.repType = X_Reply,
.RepType = X_GetDeviceMotionEvents,
.sequenceNumber = client->sequence,
.length = 0,
.nEvents = 0,
.axes = axes,
.mode = Absolute /* XXX we don't do relative at the moment */
};
rep.repType = X_Reply;
rep.RepType = X_GetDeviceMotionEvents;
rep.sequenceNumber = client->sequence;
rep.nEvents = 0;
rep.axes = axes;
rep.mode = Absolute; /* XXX we don't do relative at the moment */
rep.length = 0;
start = ClientTimeToServerTime(stuff->start);
stop = ClientTimeToServerTime(stuff->stop);
if (CompareTimeStamps(start, stop) == LATER ||
@@ -143,13 +143,15 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
if (nEvents) {
if (client->swapped) {
char n;
bufptr = coords;
for (i = 0; i < nEvents * (axes + 1); i++) {
swapl(bufptr);
swapl(bufptr, n);
bufptr++;
}
}
WriteToClient(client, length * 4, coords);
WriteToClient(client, length * 4, (char *)coords);
}
free(coords);
return Success;
@@ -162,12 +164,14 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
*
*/
void _X_COLD
void
SRepXGetDeviceMotionEvents(ClientPtr client, int size,
xGetDeviceMotionEventsReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swapl(&rep->nEvents);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
swapl(&rep->nEvents, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -68,17 +68,20 @@ SOFTWARE.
#include "listdev.h"
/***********************************************************************
*
* This procedure lists the input devices available to the server.
*
*/
int _X_COLD
int
SProcXListInputDevices(ClientPtr client)
{
char n;
REQUEST(xListInputDevicesReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXListInputDevices(client));
}
@@ -119,16 +122,15 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
*/
static void
CopyDeviceName(char **namebuf, const char *name)
CopyDeviceName(char **namebuf, char *name)
{
char *nameptr = *namebuf;
char *nameptr = (char *)*namebuf;
if (name) {
*nameptr++ = strlen(name);
strcpy(nameptr, name);
*namebuf += (strlen(name) + 1);
}
else {
} else {
*nameptr++ = 0;
*namebuf += 1;
}
@@ -143,6 +145,7 @@ CopyDeviceName(char **namebuf, const char *name)
static void
CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
{
char n;
xButtonInfoPtr b2;
b2 = (xButtonInfoPtr) * buf;
@@ -150,7 +153,7 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
b2->length = sizeof(xButtonInfo);
b2->num_buttons = b->numButtons;
if (client && client->swapped) {
swaps(&b2->num_buttons);
swaps(&b2->num_buttons, n); /* macro - braces are required */
}
*buf += sizeof(xButtonInfo);
}
@@ -162,8 +165,10 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
*/
static void
CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf)
CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
char **buf)
{
char n;
xDeviceInfoPtr dev;
dev = (xDeviceInfoPtr) * buf;
@@ -183,7 +188,7 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf)
dev->use = IsXExtensionDevice;
if (client->swapped) {
swapl(&dev->type);
swapl(&dev->type, n); /* macro - braces are required */
}
*buf += sizeof(xDeviceInfo);
}
@@ -197,6 +202,7 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf)
static void
CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
{
char n;
xKeyInfoPtr k2;
k2 = (xKeyInfoPtr) * buf;
@@ -206,7 +212,7 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
k2->max_keycode = k->xkbInfo->desc->max_key_code;
k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
if (client && client->swapped) {
swaps(&k2->num_keys);
swaps(&k2->num_keys, n);
}
*buf += sizeof(xKeyInfo);
}
@@ -227,6 +233,7 @@ static int
CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
{
int i, j, axes, t_axes;
char n;
ValuatorClassPtr v = dev->valuator;
xValuatorInfoPtr v2;
AxisInfo *a;
@@ -244,7 +251,7 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
v2->mode = valuator_get_mode(dev, 0);
v2->motion_buffer_size = v->numMotionEvents;
if (client && client->swapped) {
swapl(&v2->motion_buffer_size);
swapl(&v2->motion_buffer_size, n);
}
*buf += sizeof(xValuatorInfo);
a = v->axes + (VPC * i);
@@ -254,9 +261,9 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
a2->max_value = a->max_value;
a2->resolution = a->resolution;
if (client && client->swapped) {
swapl(&a2->min_value);
swapl(&a2->max_value);
swapl(&a2->resolution);
swapl(&a2->min_value, n);
swapl(&a2->max_value, n);
swapl(&a2->resolution, n);
}
a2++;
a++;
@@ -279,7 +286,8 @@ CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes,
(*num_classes)++;
}
if (dev->valuator != NULL) {
(*num_classes) += CopySwapValuatorClass(client, dev, classbuf);
(*num_classes) +=
CopySwapValuatorClass(client, dev, classbuf);
}
}
@@ -308,15 +316,16 @@ static Bool
ShouldSkipDevice(ClientPtr client, DeviceIntPtr d)
{
/* don't send master devices other than VCP/VCK */
if (!IsMaster(d) || d == inputInfo.pointer ||d == inputInfo.keyboard) {
if (!IsMaster(d) || d == inputInfo.pointer || d == inputInfo.keyboard)
{
int rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
if (rc == Success)
return FALSE;
}
return TRUE;
}
/***********************************************************************
*
* This procedure lists the input devices available to the server.
@@ -342,12 +351,11 @@ ProcXListInputDevices(ClientPtr client)
REQUEST_SIZE_MATCH(xListInputDevicesReq);
rep = (xListInputDevicesReply) {
.repType = X_Reply,
.RepType = X_ListInputDevices,
.sequenceNumber = client->sequence,
.length = 0
};
memset(&rep, 0, sizeof(xListInputDevicesReply));
rep.repType = X_Reply;
rep.RepType = X_ListInputDevices;
rep.length = 0;
rep.sequenceNumber = client->sequence;
/* allocate space for saving skip value */
skip = calloc(sizeof(Bool), inputInfo.numDevices);
@@ -413,10 +421,12 @@ ProcXListInputDevices(ClientPtr client)
*
*/
void _X_COLD
void
SRepXListInputDevices(ClientPtr client, int size, xListInputDevicesReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -1,67 +0,0 @@
srcs_xi = [
'allowev.c',
'chgdctl.c',
'chgfctl.c',
'chgkbd.c',
'chgkmap.c',
'chgprop.c',
'chgptr.c',
'closedev.c',
'devbell.c',
'exevents.c',
'extinit.c',
'getbmap.c',
'getdctl.c',
'getfctl.c',
'getfocus.c',
'getkmap.c',
'getmmap.c',
'getprop.c',
'getselev.c',
'getvers.c',
'grabdev.c',
'grabdevb.c',
'grabdevk.c',
'gtmotion.c',
'listdev.c',
'opendev.c',
'queryst.c',
'selectev.c',
'sendexev.c',
'setbmap.c',
'setdval.c',
'setfocus.c',
'setmmap.c',
'setmode.c',
'ungrdev.c',
'ungrdevb.c',
'ungrdevk.c',
'xiallowev.c',
'xibarriers.c',
'xichangecursor.c',
'xichangehierarchy.c',
'xigetclientpointer.c',
'xigrabdev.c',
'xipassivegrab.c',
'xiproperty.c',
'xiquerydevice.c',
'xiquerypointer.c',
'xiqueryversion.c',
'xiselectev.c',
'xisetclientpointer.c',
'xisetdevfocus.c',
'xiwarppointer.c',
]
libxserver_xi = static_library('libxserver_xi',
srcs_xi,
include_directories: inc,
dependencies: common_dep,
)
srcs_xi_stubs = ['stubs.c']
libxserver_xi_stubs = static_library('libxserver_xi_stubs',
srcs_xi_stubs,
include_directories: inc,
dependencies: common_dep,
)

View File

@@ -73,11 +73,13 @@ extern CARD8 event_base[];
*
*/
int _X_COLD
int
SProcXOpenDevice(ClientPtr client)
{
char n;
REQUEST(xOpenDeviceReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXOpenDevice(client));
}
@@ -107,8 +109,7 @@ ProcXOpenDevice(ClientPtr client)
break;
if (dev == NULL)
return BadDevice;
}
else if (status != Success)
} else if (status != Success)
return status;
if (IsMaster(dev))
@@ -117,6 +118,10 @@ ProcXOpenDevice(ClientPtr client)
if (status != Success)
return status;
memset(&rep, 0, sizeof(xOpenDeviceReply));
rep.repType = X_Reply;
rep.RepType = X_OpenDevice;
rep.sequenceNumber = client->sequence;
if (dev->key != NULL) {
evbase[j].class = KeyClass;
evbase[j++].event_type_base = event_base[KeyClass];
@@ -144,15 +149,10 @@ ProcXOpenDevice(ClientPtr client)
}
evbase[j].class = OtherClass;
evbase[j++].event_type_base = event_base[OtherClass];
rep = (xOpenDeviceReply) {
.repType = X_Reply,
.RepType = X_OpenDevice,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(j * sizeof(xInputClassInfo)),
.num_classes = j
};
rep.length = bytes_to_int32(j * sizeof(xInputClassInfo));
rep.num_classes = j;
WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep);
WriteToClient(client, j * sizeof(xInputClassInfo), evbase);
WriteToClient(client, j * sizeof(xInputClassInfo), (char *)evbase);
return Success;
}
@@ -163,10 +163,12 @@ ProcXOpenDevice(ClientPtr client)
*
*/
void _X_COLD
void
SRepXOpenDevice(ClientPtr client, int size, xOpenDeviceReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -53,11 +53,13 @@ from The Open Group.
*
*/
int _X_COLD
int
SProcXQueryDeviceState(ClientPtr client)
{
char n;
REQUEST(xQueryDeviceStateReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXQueryDeviceState(client));
}
@@ -70,6 +72,7 @@ SProcXQueryDeviceState(ClientPtr client)
int
ProcXQueryDeviceState(ClientPtr client)
{
char n;
int rc, i;
int num_classes = 0;
int total_length = 0;
@@ -87,6 +90,11 @@ ProcXQueryDeviceState(ClientPtr client)
REQUEST(xQueryDeviceStateReq);
REQUEST_SIZE_MATCH(xQueryDeviceStateReq);
rep.repType = X_Reply;
rep.RepType = X_QueryDeviceState;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (rc != Success && rc != BadAccess)
return rc;
@@ -144,27 +152,21 @@ ProcXQueryDeviceState(ClientPtr client)
tv->length = sizeof(xValuatorState) + v->numAxes * 4;
tv->num_valuators = v->numAxes;
tv->mode = valuator_get_mode(dev, 0);
tv->mode |= (dev->proximity &&
!dev->proximity->in_proximity) ? OutOfProximity : 0;
tv->mode |= (dev->proximity && !dev->proximity->in_proximity) ? OutOfProximity : 0;
buf += sizeof(xValuatorState);
for (i = 0, values = v->axisVal; i < v->numAxes; i++) {
if (rc != BadAccess)
*((int *)buf) = *values;
values++;
if (client->swapped) {
swapl((int *) buf);
swapl((int *)buf, n); /* macro - braces needed */
}
buf += sizeof(int);
}
}
rep = (xQueryDeviceStateReply) {
.repType = X_Reply,
.RepType = X_QueryDeviceState,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(total_length),
.num_classes = num_classes
};
rep.num_classes = num_classes;
rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xQueryDeviceStateReply), &rep);
if (total_length > 0)
WriteToClient(client, total_length, savbuf);
@@ -179,10 +181,12 @@ ProcXQueryDeviceState(ClientPtr client)
*
*/
void _X_COLD
void
SRepXQueryDeviceState(ClientPtr client, int size, xQueryDeviceStateReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -50,6 +50,7 @@ SOFTWARE.
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -119,15 +120,18 @@ HandleDevicePresenceMask(ClientPtr client, WindowPtr win,
*
*/
int _X_COLD
int
SProcXSelectExtensionEvent(ClientPtr client)
{
char n;
REQUEST(xSelectExtensionEventReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
swapl(&stuff->window);
swaps(&stuff->count);
REQUEST_FIXED_SIZE(xSelectExtensionEventReq, stuff->count * sizeof(CARD32));
swapl(&stuff->window, n);
swaps(&stuff->count, n);
REQUEST_FIXED_SIZE(xSelectExtensionEventReq,
stuff->count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
return (ProcXSelectExtensionEvent(client));
@@ -150,8 +154,7 @@ ProcXSelectExtensionEvent(ClientPtr client)
REQUEST(xSelectExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
if (stuff->length !=
bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count)
if (stuff->length != bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count)
return BadLength;
ret = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);

View File

@@ -73,39 +73,31 @@ extern int lastEvent; /* Defined in extension.c */
*
*/
int _X_COLD
int
SProcXSendExtensionEvent(ClientPtr client)
{
char n;
CARD32 *p;
int i;
xEvent eventT = { .u.u.type = 0 };
xEvent eventT;
xEvent *eventP;
EventSwapPtr proc;
REQUEST(xSendExtensionEventReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
swapl(&stuff->destination);
swaps(&stuff->count);
swapl(&stuff->destination, n);
swaps(&stuff->count, n);
if (stuff->length !=
bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
bytes_to_int32(stuff->num_events * sizeof(xEvent)))
return BadLength;
eventP = (xEvent *) & stuff[1];
for (i = 0; i < stuff->num_events; i++, eventP++) {
if (eventP->u.u.type == GenericEvent) {
client->errorValue = eventP->u.u.type;
return BadValue;
}
proc = EventSwapVector[eventP->u.u.type & 0177];
/* no swapping proc; invalid event type? */
if (proc == NotImplemented) {
client->errorValue = eventP->u.u.type;
if (proc == NotImplemented) /* no swapping proc; invalid event type? */
return BadValue;
}
(*proc) (eventP, &eventT);
*eventP = eventT;
}
@@ -125,7 +117,7 @@ SProcXSendExtensionEvent(ClientPtr client)
int
ProcXSendExtensionEvent(ClientPtr client)
{
int ret, i;
int ret;
DeviceIntPtr dev;
xEvent *first;
XEventClass *list;
@@ -134,8 +126,7 @@ ProcXSendExtensionEvent(ClientPtr client)
REQUEST(xSendExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
if (stuff->length !=
bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
(stuff->num_events * bytes_to_int32(sizeof(xEvent))))
return BadLength;
@@ -143,19 +134,14 @@ ProcXSendExtensionEvent(ClientPtr client)
if (ret != Success)
return ret;
if (stuff->num_events == 0)
return ret;
/* The client's event type must be one defined by an extension. */
first = ((xEvent *) & stuff[1]);
for (i = 0; i < stuff->num_events; i++) {
if (!((EXTENSION_EVENT_BASE <= first[i].u.u.type) &&
(first[i].u.u.type < lastEvent))) {
client->errorValue = first[i].u.u.type;
if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
(first->u.u.type < lastEvent))) {
client->errorValue = first->u.u.type;
return BadValue;
}
}
list = (XEventClass *) (first + stuff->num_events);
if ((ret = CreateMaskFromList(client, list, stuff->count, tmp, dev,

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXSetDeviceButtonMapping(ClientPtr client)
{
char n;
REQUEST(xSetDeviceButtonMappingReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXSetDeviceButtonMapping(client));
}
@@ -100,17 +102,13 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
if (ret != Success)
return ret;
rep = (xSetDeviceButtonMappingReply) {
.repType = X_Reply,
.RepType = X_SetDeviceButtonMapping,
.sequenceNumber = client->sequence,
.length = 0,
.status = MappingSuccess
};
rep.repType = X_Reply;
rep.RepType = X_SetDeviceButtonMapping;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.status = MappingSuccess;
ret =
ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length,
client);
ret = ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length, client);
if (ret == -1)
return BadValue;
else if (ret == MappingBusy)
@@ -130,11 +128,13 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
*
*/
void _X_COLD
void
SRepXSetDeviceButtonMapping(ClientPtr client, int size,
xSetDeviceButtonMappingReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXSetDeviceValuators(ClientPtr client)
{
char n;
REQUEST(xSetDeviceValuatorsReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXSetDeviceValuators(client));
}
@@ -92,13 +94,11 @@ ProcXSetDeviceValuators(ClientPtr client)
REQUEST(xSetDeviceValuatorsReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
rep = (xSetDeviceValuatorsReply) {
.repType = X_Reply,
.RepType = X_SetDeviceValuators,
.sequenceNumber = client->sequence,
.length = 0,
.status = Success
};
rep.repType = X_Reply;
rep.RepType = X_SetDeviceValuators;
rep.length = 0;
rep.status = Success;
rep.sequenceNumber = client->sequence;
if (stuff->length != bytes_to_int32(sizeof(xSetDeviceValuatorsReq)) +
stuff->num_valuators)
@@ -110,9 +110,6 @@ ProcXSetDeviceValuators(ClientPtr client)
if (dev->valuator == NULL)
return BadMatch;
if (IsXTestDevice(dev, NULL))
return BadMatch;
if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes)
return BadValue;
@@ -137,11 +134,13 @@ ProcXSetDeviceValuators(ClientPtr client)
*
*/
void _X_COLD
void
SRepXSetDeviceValuators(ClientPtr client, int size,
xSetDeviceValuatorsReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -71,14 +71,16 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXSetDeviceFocus(ClientPtr client)
{
char n;
REQUEST(xSetDeviceFocusReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
swapl(&stuff->focus);
swapl(&stuff->time);
swapl(&stuff->focus, n);
swapl(&stuff->time, n);
return (ProcXSetDeviceFocus(client));
}

View File

@@ -70,11 +70,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXSetDeviceModifierMapping(ClientPtr client)
{
char n;
REQUEST(xSetDeviceModifierMappingReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXSetDeviceModifierMapping(client));
}
@@ -98,12 +100,10 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
(stuff->numKeyPerModifier << 1))
return BadLength;
rep = (xSetDeviceModifierMappingReply) {
.repType = X_Reply,
.RepType = X_SetDeviceModifierMapping,
.sequenceNumber = client->sequence,
.length = 0
};
rep.repType = X_Reply;
rep.RepType = X_SetDeviceModifierMapping;
rep.length = 0;
rep.sequenceNumber = client->sequence;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
@@ -136,11 +136,13 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
*
*/
void _X_COLD
void
SRepXSetDeviceModifierMapping(ClientPtr client, int size,
xSetDeviceModifierMappingReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -68,11 +68,13 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXSetDeviceMode(ClientPtr client)
{
char n;
REQUEST(xSetDeviceModeReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXSetDeviceMode(client));
}
@@ -92,22 +94,16 @@ ProcXSetDeviceMode(ClientPtr client)
REQUEST(xSetDeviceModeReq);
REQUEST_SIZE_MATCH(xSetDeviceModeReq);
rep = (xSetDeviceModeReply) {
.repType = X_Reply,
.RepType = X_SetDeviceMode,
.sequenceNumber = client->sequence,
.length = 0
};
rep.repType = X_Reply;
rep.RepType = X_SetDeviceMode;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (dev->valuator == NULL)
return BadMatch;
if (IsXTestDevice(dev, NULL))
return BadMatch;
if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
rep.status = AlreadyGrabbed;
else
@@ -115,7 +111,8 @@ ProcXSetDeviceMode(ClientPtr client)
if (rep.status == Success)
valuator_set_mode(dev, VALUATOR_MODE_ALL_AXES, stuff->mode);
else if (rep.status != AlreadyGrabbed) {
else if (rep.status != AlreadyGrabbed)
{
switch(rep.status) {
case BadMatch:
case BadImplementation:
@@ -138,10 +135,12 @@ ProcXSetDeviceMode(ClientPtr client)
*
*/
void _X_COLD
void
SRepXSetDeviceMode(ClientPtr client, int size, xSetDeviceModeReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@@ -112,11 +112,13 @@ SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
*/
int
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control)
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
xDeviceCtl * control)
{
return BadMatch;
}
/****************************************************************************
*
* Caller: configAddDevice (and others)
@@ -140,20 +142,5 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
*/
void
DeleteInputDeviceRequest(DeviceIntPtr dev)
{
RemoveDevice(dev, TRUE);
}
/****************************************************************************
*
* Caller: configRemoveDevice (and others)
*
* Remove any traces of the input device specified in config_info.
* This is only necessary if the ddx keeps information around beyond
* the NewInputDeviceRequest/DeleteInputDeviceRequest
*
*/
void
RemoveInputDeviceTraces(const char *config_info)
{
}

View File

@@ -67,13 +67,15 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXUngrabDevice(ClientPtr client)
{
char n;
REQUEST(xUngrabDeviceReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xUngrabDeviceReq);
swapl(&stuff->time);
swapl(&stuff->time, n);
return (ProcXUngrabDevice(client));
}
@@ -102,7 +104,7 @@ ProcXUngrabDevice(ClientPtr client)
time = ClientTimeToServerTime(stuff->time);
if ((CompareTimeStamps(time, currentTime) != LATER) &&
(CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) &&
(grab) && SameClient(grab, client) && grab->grabtype == XI)
(grab) && SameClient(grab, client) && grab->grabtype == GRABTYPE_XI)
(*dev->deviceGrab.DeactivateGrab) (dev);
return Success;
}

View File

@@ -73,14 +73,16 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXUngrabDeviceButton(ClientPtr client)
{
char n;
REQUEST(xUngrabDeviceButtonReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
swapl(&stuff->grabWindow, n);
swaps(&stuff->modifiers, n);
return (ProcXUngrabDeviceButton(client));
}
@@ -96,7 +98,7 @@ ProcXUngrabDeviceButton(ClientPtr client)
DeviceIntPtr dev;
DeviceIntPtr mdev;
WindowPtr pWin;
GrabPtr temporaryGrab;
GrabRec temporaryGrab;
int rc;
REQUEST(xUngrabDeviceButtonReq);
@@ -115,8 +117,7 @@ ProcXUngrabDeviceButton(ClientPtr client)
return BadDevice;
if (mdev->key == NULL)
return BadMatch;
}
else
} else
mdev = PickKeyboard(client);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
@@ -127,23 +128,17 @@ ProcXUngrabDeviceButton(ClientPtr client)
(stuff->modifiers & ~AllModifiersMask))
return BadValue;
temporaryGrab = AllocGrab(NULL);
if (!temporaryGrab)
return BadAlloc;
temporaryGrab.resource = client->clientAsMask;
temporaryGrab.device = dev;
temporaryGrab.window = pWin;
temporaryGrab.type = DeviceButtonPress;
temporaryGrab.grabtype = GRABTYPE_XI;
temporaryGrab.modifierDevice = mdev;
temporaryGrab.modifiersDetail.exact = stuff->modifiers;
temporaryGrab.modifiersDetail.pMask = NULL;
temporaryGrab.detail.exact = stuff->button;
temporaryGrab.detail.pMask = NULL;
temporaryGrab->resource = client->clientAsMask;
temporaryGrab->device = dev;
temporaryGrab->window = pWin;
temporaryGrab->type = DeviceButtonPress;
temporaryGrab->grabtype = XI;
temporaryGrab->modifierDevice = mdev;
temporaryGrab->modifiersDetail.exact = stuff->modifiers;
temporaryGrab->modifiersDetail.pMask = NULL;
temporaryGrab->detail.exact = stuff->button;
temporaryGrab->detail.pMask = NULL;
DeletePassiveGrabFromList(temporaryGrab);
FreeGrab(temporaryGrab);
DeletePassiveGrabFromList(&temporaryGrab);
return Success;
}

View File

@@ -75,14 +75,16 @@ SOFTWARE.
*
*/
int _X_COLD
int
SProcXUngrabDeviceKey(ClientPtr client)
{
char n;
REQUEST(xUngrabDeviceKeyReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
swapl(&stuff->grabWindow, n);
swaps(&stuff->modifiers, n);
return (ProcXUngrabDeviceKey(client));
}
@@ -98,7 +100,7 @@ ProcXUngrabDeviceKey(ClientPtr client)
DeviceIntPtr dev;
DeviceIntPtr mdev;
WindowPtr pWin;
GrabPtr temporaryGrab;
GrabRec temporaryGrab;
int rc;
REQUEST(xUngrabDeviceKeyReq);
@@ -117,8 +119,7 @@ ProcXUngrabDeviceKey(ClientPtr client)
return BadDevice;
if (mdev->key == NULL)
return BadMatch;
}
else
} else
mdev = PickKeyboard(client);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
@@ -134,22 +135,17 @@ ProcXUngrabDeviceKey(ClientPtr client)
(stuff->modifiers & ~AllModifiersMask))
return BadValue;
temporaryGrab = AllocGrab(NULL);
if (!temporaryGrab)
return BadAlloc;
temporaryGrab.resource = client->clientAsMask;
temporaryGrab.device = dev;
temporaryGrab.window = pWin;
temporaryGrab.type = DeviceKeyPress;
temporaryGrab.grabtype = GRABTYPE_XI;
temporaryGrab.modifierDevice = mdev;
temporaryGrab.modifiersDetail.exact = stuff->modifiers;
temporaryGrab.modifiersDetail.pMask = NULL;
temporaryGrab.detail.exact = stuff->key;
temporaryGrab.detail.pMask = NULL;
temporaryGrab->resource = client->clientAsMask;
temporaryGrab->device = dev;
temporaryGrab->window = pWin;
temporaryGrab->type = DeviceKeyPress;
temporaryGrab->grabtype = XI;
temporaryGrab->modifierDevice = mdev;
temporaryGrab->modifiersDetail.exact = stuff->modifiers;
temporaryGrab->modifiersDetail.pMask = NULL;
temporaryGrab->detail.exact = stuff->key;
temporaryGrab->detail.pMask = NULL;
DeletePassiveGrabFromList(temporaryGrab);
FreeGrab(temporaryGrab);
DeletePassiveGrabFromList(&temporaryGrab);
return Success;
}

View File

@@ -35,31 +35,22 @@
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "mi.h"
#include "eventstr.h"
#include <X11/extensions/XI2.h>
#include <X11/extensions/XI2proto.h>
#include "exglobals.h" /* BadDevice */
#include "exevents.h"
#include "xiallowev.h"
int _X_COLD
int
SProcXIAllowEvents(ClientPtr client)
{
char n;
REQUEST(xXIAllowEventsReq);
REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq);
swaps(&stuff->length);
swaps(&stuff->deviceid);
swapl(&stuff->time);
if (stuff->length > 3) {
xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq *) stuff;
REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
swapl(&req_xi22->touchid);
swapl(&req_xi22->grab_window);
}
swaps(&stuff->length, n);
swaps(&stuff->deviceid, n);
swapl(&stuff->time, n);
return ProcXIAllowEvents(client);
}
@@ -70,21 +61,9 @@ ProcXIAllowEvents(ClientPtr client)
TimeStamp time;
DeviceIntPtr dev;
int ret = Success;
XIClientPtr xi_client;
Bool have_xi22 = FALSE;
REQUEST(xXI2_2AllowEventsReq);
xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
if (version_compare(xi_client->major_version,
xi_client->minor_version, 2, 2) >= 0) {
REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
have_xi22 = TRUE;
}
else {
REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq);
}
REQUEST(xXIAllowEventsReq);
REQUEST_SIZE_MATCH(xXIAllowEventsReq);
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success)
@@ -114,23 +93,6 @@ ProcXIAllowEvents(ClientPtr client)
if (IsMaster(dev))
AllowSome(client, time, dev, THAWED_BOTH);
break;
case XIRejectTouch:
case XIAcceptTouch:
{
int rc;
WindowPtr win;
if (!have_xi22)
return BadValue;
rc = dixLookupWindow(&win, stuff->grab_window, client, DixReadAccess);
if (rc != Success)
return rc;
ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
stuff->grab_window, &client->errorValue);
}
break;
default:
client->errorValue = stuff->mode;
ret = BadValue;
@@ -138,3 +100,4 @@ ProcXIAllowEvents(ClientPtr client)
return ret;
}

View File

@@ -1,939 +0,0 @@
/*
* Copyright 2012 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "xibarriers.h"
#include "scrnintstr.h"
#include "cursorstr.h"
#include "dixevents.h"
#include "servermd.h"
#include "mipointer.h"
#include "inputstr.h"
#include "windowstr.h"
#include "xace.h"
#include "list.h"
#include "exglobals.h"
#include "eventstr.h"
#include "mi.h"
RESTYPE PointerBarrierType;
static DevPrivateKeyRec BarrierScreenPrivateKeyRec;
#define BarrierScreenPrivateKey (&BarrierScreenPrivateKeyRec)
typedef struct PointerBarrierClient *PointerBarrierClientPtr;
struct PointerBarrierDevice {
struct xorg_list entry;
int deviceid;
Time last_timestamp;
int barrier_event_id;
int release_event_id;
Bool hit;
Bool seen;
};
struct PointerBarrierClient {
XID id;
ScreenPtr screen;
Window window;
struct PointerBarrier barrier;
struct xorg_list entry;
/* num_devices/device_ids are devices the barrier applies to */
int num_devices;
int *device_ids; /* num_devices */
/* per_device keeps track of devices actually blocked by barriers */
struct xorg_list per_device;
};
typedef struct _BarrierScreen {
struct xorg_list barriers;
} BarrierScreenRec, *BarrierScreenPtr;
#define GetBarrierScreen(s) ((BarrierScreenPtr)dixLookupPrivate(&(s)->devPrivates, BarrierScreenPrivateKey))
#define GetBarrierScreenIfSet(s) GetBarrierScreen(s)
#define SetBarrierScreen(s,p) dixSetPrivate(&(s)->devPrivates, BarrierScreenPrivateKey, p)
static struct PointerBarrierDevice *AllocBarrierDevice(void)
{
struct PointerBarrierDevice *pbd = NULL;
pbd = malloc(sizeof(struct PointerBarrierDevice));
if (!pbd)
return NULL;
pbd->deviceid = -1; /* must be set by caller */
pbd->barrier_event_id = 1;
pbd->release_event_id = 0;
pbd->hit = FALSE;
pbd->seen = FALSE;
xorg_list_init(&pbd->entry);
return pbd;
}
static void FreePointerBarrierClient(struct PointerBarrierClient *c)
{
struct PointerBarrierDevice *pbd = NULL, *tmp = NULL;
xorg_list_for_each_entry_safe(pbd, tmp, &c->per_device, entry) {
free(pbd);
}
free(c);
}
static struct PointerBarrierDevice *GetBarrierDevice(struct PointerBarrierClient *c, int deviceid)
{
struct PointerBarrierDevice *pbd = NULL;
xorg_list_for_each_entry(pbd, &c->per_device, entry) {
if (pbd->deviceid == deviceid)
break;
}
BUG_WARN(!pbd);
return pbd;
}
static BOOL
barrier_is_horizontal(const struct PointerBarrier *barrier)
{
return barrier->y1 == barrier->y2;
}
static BOOL
barrier_is_vertical(const struct PointerBarrier *barrier)
{
return barrier->x1 == barrier->x2;
}
/**
* @return The set of barrier movement directions the movement vector
* x1/y1 → x2/y2 represents.
*/
int
barrier_get_direction(int x1, int y1, int x2, int y2)
{
int direction = 0;
/* which way are we trying to go */
if (x2 > x1)
direction |= BarrierPositiveX;
if (x2 < x1)
direction |= BarrierNegativeX;
if (y2 > y1)
direction |= BarrierPositiveY;
if (y2 < y1)
direction |= BarrierNegativeY;
return direction;
}
/**
* Test if the barrier may block movement in the direction defined by
* x1/y1 → x2/y2. This function only tests whether the directions could be
* blocked, it does not test if the barrier actually blocks the movement.
*
* @return TRUE if the barrier blocks the direction of movement or FALSE
* otherwise.
*/
BOOL
barrier_is_blocking_direction(const struct PointerBarrier * barrier,
int direction)
{
/* Barriers define which way is ok, not which way is blocking */
return (barrier->directions & direction) != direction;
}
static BOOL
inside_segment(int v, int v1, int v2)
{
if (v1 < 0 && v2 < 0) /* line */
return TRUE;
else if (v1 < 0) /* ray */
return v <= v2;
else if (v2 < 0) /* ray */
return v >= v1;
else /* line segment */
return v >= v1 && v <= v2;
}
#define T(v, a, b) (((float)v) - (a)) / ((b) - (a))
#define F(t, a, b) ((t) * ((a) - (b)) + (a))
/**
* Test if the movement vector x1/y1 → x2/y2 is intersecting with the
* barrier. A movement vector with the startpoint or endpoint adjacent to
* the barrier itself counts as intersecting.
*
* @param x1 X start coordinate of movement vector
* @param y1 Y start coordinate of movement vector
* @param x2 X end coordinate of movement vector
* @param y2 Y end coordinate of movement vector
* @param[out] distance The distance between the start point and the
* intersection with the barrier (if applicable).
* @return TRUE if the barrier intersects with the given vector
*/
BOOL
barrier_is_blocking(const struct PointerBarrier * barrier,
int x1, int y1, int x2, int y2, double *distance)
{
if (barrier_is_vertical(barrier)) {
float t, y;
t = T(barrier->x1, x1, x2);
if (t < 0 || t > 1)
return FALSE;
/* Edge case: moving away from barrier. */
if (x2 > x1 && t == 0)
return FALSE;
y = F(t, y1, y2);
if (!inside_segment(y, barrier->y1, barrier->y2))
return FALSE;
*distance = sqrt((pow(y - y1, 2) + pow(barrier->x1 - x1, 2)));
return TRUE;
}
else {
float t, x;
t = T(barrier->y1, y1, y2);
if (t < 0 || t > 1)
return FALSE;
/* Edge case: moving away from barrier. */
if (y2 > y1 && t == 0)
return FALSE;
x = F(t, x1, x2);
if (!inside_segment(x, barrier->x1, barrier->x2))
return FALSE;
*distance = sqrt((pow(x - x1, 2) + pow(barrier->y1 - y1, 2)));
return TRUE;
}
}
#define HIT_EDGE_EXTENTS 2
static BOOL
barrier_inside_hit_box(struct PointerBarrier *barrier, int x, int y)
{
int x1, x2, y1, y2;
int dir;
x1 = barrier->x1;
x2 = barrier->x2;
y1 = barrier->y1;
y2 = barrier->y2;
dir = ~(barrier->directions);
if (barrier_is_vertical(barrier)) {
if (dir & BarrierPositiveX)
x1 -= HIT_EDGE_EXTENTS;
if (dir & BarrierNegativeX)
x2 += HIT_EDGE_EXTENTS;
}
if (barrier_is_horizontal(barrier)) {
if (dir & BarrierPositiveY)
y1 -= HIT_EDGE_EXTENTS;
if (dir & BarrierNegativeY)
y2 += HIT_EDGE_EXTENTS;
}
return x >= x1 && x <= x2 && y >= y1 && y <= y2;
}
static BOOL
barrier_blocks_device(struct PointerBarrierClient *client,
DeviceIntPtr dev)
{
int i;
int master_id;
/* Clients with no devices are treated as
* if they specified XIAllDevices. */
if (client->num_devices == 0)
return TRUE;
master_id = GetMaster(dev, POINTER_OR_FLOAT)->id;
for (i = 0; i < client->num_devices; i++) {
int device_id = client->device_ids[i];
if (device_id == XIAllDevices ||
device_id == XIAllMasterDevices ||
device_id == master_id)
return TRUE;
}
return FALSE;
}
/**
* Find the nearest barrier client that is blocking movement from x1/y1 to x2/y2.
*
* @param dir Only barriers blocking movement in direction dir are checked
* @param x1 X start coordinate of movement vector
* @param y1 Y start coordinate of movement vector
* @param x2 X end coordinate of movement vector
* @param y2 Y end coordinate of movement vector
* @return The barrier nearest to the movement origin that blocks this movement.
*/
static struct PointerBarrierClient *
barrier_find_nearest(BarrierScreenPtr cs, DeviceIntPtr dev,
int dir,
int x1, int y1, int x2, int y2)
{
struct PointerBarrierClient *c, *nearest = NULL;
double min_distance = INT_MAX; /* can't get higher than that in X anyway */
xorg_list_for_each_entry(c, &cs->barriers, entry) {
struct PointerBarrier *b = &c->barrier;
struct PointerBarrierDevice *pbd;
double distance;
pbd = GetBarrierDevice(c, dev->id);
if (pbd->seen)
continue;
if (!barrier_is_blocking_direction(b, dir))
continue;
if (!barrier_blocks_device(c, dev))
continue;
if (barrier_is_blocking(b, x1, y1, x2, y2, &distance)) {
if (min_distance > distance) {
min_distance = distance;
nearest = c;
}
}
}
return nearest;
}
/**
* Clamp to the given barrier given the movement direction specified in dir.
*
* @param barrier The barrier to clamp to
* @param dir The movement direction
* @param[out] x The clamped x coordinate.
* @param[out] y The clamped x coordinate.
*/
void
barrier_clamp_to_barrier(struct PointerBarrier *barrier, int dir, int *x,
int *y)
{
if (barrier_is_vertical(barrier)) {
if ((dir & BarrierNegativeX) & ~barrier->directions)
*x = barrier->x1;
if ((dir & BarrierPositiveX) & ~barrier->directions)
*x = barrier->x1 - 1;
}
if (barrier_is_horizontal(barrier)) {
if ((dir & BarrierNegativeY) & ~barrier->directions)
*y = barrier->y1;
if ((dir & BarrierPositiveY) & ~barrier->directions)
*y = barrier->y1 - 1;
}
}
void
input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
int current_x, int current_y,
int dest_x, int dest_y,
int *out_x, int *out_y,
int *nevents, InternalEvent* events)
{
/* Clamped coordinates here refer to screen edge clamping. */
BarrierScreenPtr cs = GetBarrierScreen(screen);
int x = dest_x,
y = dest_y;
int dir;
struct PointerBarrier *nearest = NULL;
PointerBarrierClientPtr c;
Time ms = GetTimeInMillis();
BarrierEvent ev = {
.header = ET_Internal,
.type = 0,
.length = sizeof (BarrierEvent),
.time = ms,
.deviceid = dev->id,
.sourceid = dev->id,
.dx = dest_x - current_x,
.dy = dest_y - current_y,
.root = screen->root->drawable.id,
};
InternalEvent *barrier_events = events;
DeviceIntPtr master;
if (nevents)
*nevents = 0;
if (xorg_list_is_empty(&cs->barriers) || IsFloating(dev))
goto out;
/**
* This function is only called for slave devices, but pointer-barriers
* are for master-devices only. Flip the device to the master here,
* continue with that.
*/
master = GetMaster(dev, MASTER_POINTER);
/* How this works:
* Given the origin and the movement vector, get the nearest barrier
* to the origin that is blocking the movement.
* Clamp to that barrier.
* Then, check from the clamped intersection to the original
* destination, again finding the nearest barrier and clamping.
*/
dir = barrier_get_direction(current_x, current_y, x, y);
while (dir != 0) {
int new_sequence;
struct PointerBarrierDevice *pbd;
c = barrier_find_nearest(cs, master, dir, current_x, current_y, x, y);
if (!c)
break;
nearest = &c->barrier;
pbd = GetBarrierDevice(c, master->id);
new_sequence = !pbd->hit;
pbd->seen = TRUE;
pbd->hit = TRUE;
if (pbd->barrier_event_id == pbd->release_event_id)
continue;
ev.type = ET_BarrierHit;
barrier_clamp_to_barrier(nearest, dir, &x, &y);
if (barrier_is_vertical(nearest)) {
dir &= ~(BarrierNegativeX | BarrierPositiveX);
current_x = x;
}
else if (barrier_is_horizontal(nearest)) {
dir &= ~(BarrierNegativeY | BarrierPositiveY);
current_y = y;
}
ev.flags = 0;
ev.event_id = pbd->barrier_event_id;
ev.barrierid = c->id;
ev.dt = new_sequence ? 0 : ms - pbd->last_timestamp;
ev.window = c->window;
pbd->last_timestamp = ms;
/* root x/y is filled in later */
barrier_events->barrier_event = ev;
barrier_events++;
*nevents += 1;
}
xorg_list_for_each_entry(c, &cs->barriers, entry) {
struct PointerBarrierDevice *pbd;
int flags = 0;
pbd = GetBarrierDevice(c, master->id);
pbd->seen = FALSE;
if (!pbd->hit)
continue;
if (barrier_inside_hit_box(&c->barrier, x, y))
continue;
pbd->hit = FALSE;
ev.type = ET_BarrierLeave;
if (pbd->barrier_event_id == pbd->release_event_id)
flags |= XIBarrierPointerReleased;
ev.flags = flags;
ev.event_id = pbd->barrier_event_id;
ev.barrierid = c->id;
ev.dt = ms - pbd->last_timestamp;
ev.window = c->window;
pbd->last_timestamp = ms;
/* root x/y is filled in later */
barrier_events->barrier_event = ev;
barrier_events++;
*nevents += 1;
/* If we've left the hit box, this is the
* start of a new event ID. */
pbd->barrier_event_id++;
}
out:
*out_x = x;
*out_y = y;
}
static void
sort_min_max(INT16 *a, INT16 *b)
{
INT16 A, B;
if (*a < 0 || *b < 0)
return;
A = *a;
B = *b;
*a = min(A, B);
*b = max(A, B);
}
static int
CreatePointerBarrierClient(ClientPtr client,
xXFixesCreatePointerBarrierReq * stuff,
PointerBarrierClientPtr *client_out)
{
WindowPtr pWin;
ScreenPtr screen;
BarrierScreenPtr cs;
int err;
int size;
int i;
struct PointerBarrierClient *ret;
CARD16 *in_devices;
DeviceIntPtr dev;
size = sizeof(*ret) + sizeof(DeviceIntPtr) * stuff->num_devices;
ret = malloc(size);
if (!ret) {
return BadAlloc;
}
xorg_list_init(&ret->per_device);
err = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
if (err != Success) {
client->errorValue = stuff->window;
goto error;
}
screen = pWin->drawable.pScreen;
cs = GetBarrierScreen(screen);
ret->screen = screen;
ret->window = stuff->window;
ret->num_devices = stuff->num_devices;
if (ret->num_devices > 0)
ret->device_ids = (int*)&ret[1];
else
ret->device_ids = NULL;
in_devices = (CARD16 *) &stuff[1];
for (i = 0; i < stuff->num_devices; i++) {
int device_id = in_devices[i];
DeviceIntPtr device;
if ((err = dixLookupDevice (&device, device_id,
client, DixReadAccess))) {
client->errorValue = device_id;
goto error;
}
if (!IsMaster (device)) {
client->errorValue = device_id;
err = BadDevice;
goto error;
}
ret->device_ids[i] = device_id;
}
/* Alloc one per master pointer, they're the ones that can be blocked */
xorg_list_init(&ret->per_device);
nt_list_for_each_entry(dev, inputInfo.devices, next) {
struct PointerBarrierDevice *pbd;
if (dev->type != MASTER_POINTER)
continue;
pbd = AllocBarrierDevice();
if (!pbd) {
err = BadAlloc;
goto error;
}
pbd->deviceid = dev->id;
xorg_list_add(&pbd->entry, &ret->per_device);
}
ret->id = stuff->barrier;
ret->barrier.x1 = stuff->x1;
ret->barrier.x2 = stuff->x2;
ret->barrier.y1 = stuff->y1;
ret->barrier.y2 = stuff->y2;
sort_min_max(&ret->barrier.x1, &ret->barrier.x2);
sort_min_max(&ret->barrier.y1, &ret->barrier.y2);
ret->barrier.directions = stuff->directions & 0x0f;
if (barrier_is_horizontal(&ret->barrier))
ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX);
if (barrier_is_vertical(&ret->barrier))
ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY);
xorg_list_add(&ret->entry, &cs->barriers);
*client_out = ret;
return Success;
error:
*client_out = NULL;
FreePointerBarrierClient(ret);
return err;
}
static int
BarrierFreeBarrier(void *data, XID id)
{
struct PointerBarrierClient *c;
Time ms = GetTimeInMillis();
DeviceIntPtr dev = NULL;
ScreenPtr screen;
c = container_of(data, struct PointerBarrierClient, barrier);
screen = c->screen;
for (dev = inputInfo.devices; dev; dev = dev->next) {
struct PointerBarrierDevice *pbd;
int root_x, root_y;
BarrierEvent ev = {
.header = ET_Internal,
.type = ET_BarrierLeave,
.length = sizeof (BarrierEvent),
.time = ms,
/* .deviceid */
.sourceid = 0,
.barrierid = c->id,
.window = c->window,
.root = screen->root->drawable.id,
.dx = 0,
.dy = 0,
/* .root_x */
/* .root_y */
/* .dt */
/* .event_id */
.flags = XIBarrierPointerReleased,
};
if (dev->type != MASTER_POINTER)
continue;
pbd = GetBarrierDevice(c, dev->id);
if (!pbd->hit)
continue;
ev.deviceid = dev->id;
ev.event_id = pbd->barrier_event_id;
ev.dt = ms - pbd->last_timestamp;
GetSpritePosition(dev, &root_x, &root_y);
ev.root_x = root_x;
ev.root_y = root_y;
mieqEnqueue(dev, (InternalEvent *) &ev);
}
xorg_list_del(&c->entry);
FreePointerBarrierClient(c);
return Success;
}
static void add_master_func(void *res, XID id, void *devid)
{
struct PointerBarrier *b;
struct PointerBarrierClient *barrier;
struct PointerBarrierDevice *pbd;
int *deviceid = devid;
b = res;
barrier = container_of(b, struct PointerBarrierClient, barrier);
pbd = AllocBarrierDevice();
pbd->deviceid = *deviceid;
xorg_list_add(&pbd->entry, &barrier->per_device);
}
static void remove_master_func(void *res, XID id, void *devid)
{
struct PointerBarrierDevice *pbd;
struct PointerBarrierClient *barrier;
struct PointerBarrier *b;
DeviceIntPtr dev;
int *deviceid = devid;
int rc;
Time ms = GetTimeInMillis();
rc = dixLookupDevice(&dev, *deviceid, serverClient, DixSendAccess);
if (rc != Success)
return;
b = res;
barrier = container_of(b, struct PointerBarrierClient, barrier);
pbd = GetBarrierDevice(barrier, *deviceid);
if (pbd->hit) {
BarrierEvent ev = {
.header = ET_Internal,
.type =ET_BarrierLeave,
.length = sizeof (BarrierEvent),
.time = ms,
.deviceid = *deviceid,
.sourceid = 0,
.dx = 0,
.dy = 0,
.root = barrier->screen->root->drawable.id,
.window = barrier->window,
.dt = ms - pbd->last_timestamp,
.flags = XIBarrierPointerReleased,
.event_id = pbd->barrier_event_id,
.barrierid = barrier->id,
};
mieqEnqueue(dev, (InternalEvent *) &ev);
}
xorg_list_del(&pbd->entry);
free(pbd);
}
void XIBarrierNewMasterDevice(ClientPtr client, int deviceid)
{
FindClientResourcesByType(client, PointerBarrierType, add_master_func, &deviceid);
}
void XIBarrierRemoveMasterDevice(ClientPtr client, int deviceid)
{
FindClientResourcesByType(client, PointerBarrierType, remove_master_func, &deviceid);
}
int
XICreatePointerBarrier(ClientPtr client,
xXFixesCreatePointerBarrierReq * stuff)
{
int err;
struct PointerBarrierClient *barrier;
struct PointerBarrier b;
b.x1 = stuff->x1;
b.x2 = stuff->x2;
b.y1 = stuff->y1;
b.y2 = stuff->y2;
if (!barrier_is_horizontal(&b) && !barrier_is_vertical(&b))
return BadValue;
/* no 0-sized barriers */
if (barrier_is_horizontal(&b) && barrier_is_vertical(&b))
return BadValue;
/* no infinite barriers on the wrong axis */
if (barrier_is_horizontal(&b) && (b.y1 < 0 || b.y2 < 0))
return BadValue;
if (barrier_is_vertical(&b) && (b.x1 < 0 || b.x2 < 0))
return BadValue;
if ((err = CreatePointerBarrierClient(client, stuff, &barrier)))
return err;
if (!AddResource(stuff->barrier, PointerBarrierType, &barrier->barrier))
return BadAlloc;
return Success;
}
int
XIDestroyPointerBarrier(ClientPtr client,
xXFixesDestroyPointerBarrierReq * stuff)
{
int err;
void *barrier;
err = dixLookupResourceByType((void **) &barrier, stuff->barrier,
PointerBarrierType, client, DixDestroyAccess);
if (err != Success) {
client->errorValue = stuff->barrier;
return err;
}
if (CLIENT_ID(stuff->barrier) != client->index)
return BadAccess;
FreeResource(stuff->barrier, RT_NONE);
return Success;
}
int _X_COLD
SProcXIBarrierReleasePointer(ClientPtr client)
{
xXIBarrierReleasePointerInfo *info;
REQUEST(xXIBarrierReleasePointerReq);
int i;
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
swapl(&stuff->num_barriers);
if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
return BadLength;
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
info = (xXIBarrierReleasePointerInfo*) &stuff[1];
for (i = 0; i < stuff->num_barriers; i++, info++) {
swaps(&info->deviceid);
swapl(&info->barrier);
swapl(&info->eventid);
}
return (ProcXIBarrierReleasePointer(client));
}
int
ProcXIBarrierReleasePointer(ClientPtr client)
{
int i;
int err;
struct PointerBarrierClient *barrier;
struct PointerBarrier *b;
xXIBarrierReleasePointerInfo *info;
REQUEST(xXIBarrierReleasePointerReq);
REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
return BadLength;
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
info = (xXIBarrierReleasePointerInfo*) &stuff[1];
for (i = 0; i < stuff->num_barriers; i++, info++) {
struct PointerBarrierDevice *pbd;
DeviceIntPtr dev;
CARD32 barrier_id, event_id;
_X_UNUSED CARD32 device_id;
barrier_id = info->barrier;
event_id = info->eventid;
err = dixLookupDevice(&dev, info->deviceid, client, DixReadAccess);
if (err != Success) {
client->errorValue = BadDevice;
return err;
}
err = dixLookupResourceByType((void **) &b, barrier_id,
PointerBarrierType, client, DixReadAccess);
if (err != Success) {
client->errorValue = barrier_id;
return err;
}
if (CLIENT_ID(barrier_id) != client->index)
return BadAccess;
barrier = container_of(b, struct PointerBarrierClient, barrier);
pbd = GetBarrierDevice(barrier, dev->id);
if (pbd->barrier_event_id == event_id)
pbd->release_event_id = event_id;
}
return Success;
}
Bool
XIBarrierInit(void)
{
int i;
if (!dixRegisterPrivateKey(&BarrierScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
BarrierScreenPtr cs;
cs = (BarrierScreenPtr) calloc(1, sizeof(BarrierScreenRec));
if (!cs)
return FALSE;
xorg_list_init(&cs->barriers);
SetBarrierScreen(pScreen, cs);
}
PointerBarrierType = CreateNewResourceType(BarrierFreeBarrier,
"XIPointerBarrier");
return PointerBarrierType;
}
void
XIBarrierReset(void)
{
int i;
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
BarrierScreenPtr cs = GetBarrierScreen(pScreen);
free(cs);
SetBarrierScreen(pScreen, NULL);
}
}

View File

@@ -1,48 +0,0 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _XIBARRIERS_H_
#define _XIBARRIERS_H_
#include "resource.h"
extern _X_EXPORT RESTYPE PointerBarrierType;
struct PointerBarrier {
INT16 x1, x2, y1, y2;
CARD32 directions;
};
int
barrier_get_direction(int, int, int, int);
BOOL
barrier_is_blocking(const struct PointerBarrier *, int, int, int, int,
double *);
BOOL
barrier_is_blocking_direction(const struct PointerBarrier *, int);
void
barrier_clamp_to_barrier(struct PointerBarrier *barrier, int dir, int *x,
int *y);
#include <xfixesint.h>
int
XICreatePointerBarrier(ClientPtr client,
xXFixesCreatePointerBarrierReq * stuff);
int
XIDestroyPointerBarrier(ClientPtr client,
xXFixesDestroyPointerBarrierReq * stuff);
Bool XIBarrierInit(void);
void XIBarrierReset(void);
int SProcXIBarrierReleasePointer(ClientPtr client);
int ProcXIBarrierReleasePointer(ClientPtr client);
void XIBarrierNewMasterDevice(ClientPtr client, int deviceid);
void XIBarrierRemoveMasterDevice(ClientPtr client, int deviceid);
#endif /* _XIBARRIERS_H_ */

View File

@@ -53,20 +53,21 @@
*
*/
int _X_COLD
int
SProcXIChangeCursor(ClientPtr client)
{
char n;
REQUEST(xXIChangeCursorReq);
swaps(&stuff->length, n);
swapl(&stuff->win, n);
swapl(&stuff->cursor, n);
swaps(&stuff->deviceid, n);
REQUEST_SIZE_MATCH(xXIChangeCursorReq);
swaps(&stuff->length);
swapl(&stuff->win);
swapl(&stuff->cursor);
swaps(&stuff->deviceid);
return (ProcXIChangeCursor(client));
}
int
ProcXIChangeCursor(ClientPtr client)
int ProcXIChangeCursor(ClientPtr client)
{
int rc;
WindowPtr pWin = NULL;
@@ -83,20 +84,23 @@ ProcXIChangeCursor(ClientPtr client)
if (!IsMaster(pDev) || !IsPointerDevice(pDev))
return BadDevice;
if (stuff->win != None) {
if (stuff->win != None)
{
rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess);
if (rc != Success)
return rc;
}
if (stuff->cursor == None) {
if (stuff->cursor == None)
{
if (pWin == pWin->drawable.pScreen->root)
pCursor = rootCursor;
else
pCursor = (CursorPtr)None;
}
else {
rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor,
else
{
rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor,
RT_CURSOR, client, DixUseAccess);
if (rc != Success)
return rc;
@@ -106,3 +110,4 @@ ProcXIChangeCursor(ClientPtr client)
return Success;
}

View File

@@ -30,6 +30,7 @@
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -52,13 +53,11 @@
#include "xkbsrv.h"
#include "xichangehierarchy.h"
#include "xibarriers.h"
/**
* Send the current state of the device hierarchy to all clients.
*/
void
XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
{
xXIHierarchyEvent *ev;
xXIHierarchyInfo *info;
@@ -81,7 +80,8 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
ev->num_info = inputInfo.numDevices;
info = (xXIHierarchyInfo*)&ev[1];
for (dev = inputInfo.devices; dev; dev = dev->next) {
for (dev = inputInfo.devices; dev; dev = dev->next)
{
info->deviceid = dev->id;
info->enabled = dev->enabled;
info->use = GetDeviceUse(dev, &info->attachment);
@@ -89,7 +89,8 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
ev->flags |= info->flags;
info++;
}
for (dev = inputInfo.off_devices; dev; dev = dev->next) {
for (dev = inputInfo.off_devices; dev; dev = dev->next)
{
info->deviceid = dev->id;
info->enabled = dev->enabled;
info->use = GetDeviceUse(dev, &info->attachment);
@@ -98,8 +99,11 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
info++;
}
for (i = 0; i < MAXDEVICES; i++) {
if (flags[i] & (XIMasterRemoved | XISlaveRemoved)) {
for (i = 0; i < MAXDEVICES; i++)
{
if (flags[i] & (XIMasterRemoved | XISlaveRemoved))
{
info->deviceid = i;
info->enabled = FALSE;
info->flags = flags[i];
@@ -115,11 +119,11 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
memset(&dummyDev, 0, sizeof(dummyDev));
dummyDev.id = XIAllDevices;
dummyDev.type = SLAVE;
SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8),
(xEvent *) ev, 1);
SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), (xEvent*)ev, 1);
free(ev);
}
/***********************************************************************
*
* This procedure allows a client to change the device hierarchy through
@@ -127,11 +131,12 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
*
*/
int _X_COLD
SProcXIChangeHierarchy(ClientPtr client)
int SProcXIChangeHierarchy(ClientPtr client)
{
char n;
REQUEST(xXIChangeHierarchyReq);
swaps(&stuff->length);
swaps(&stuff->length, n);
return (ProcXIChangeHierarchy(client));
}
@@ -143,10 +148,6 @@ add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
int rc;
name = calloc(c->name_len + 1, sizeof(char));
if (name == NULL) {
rc = BadAlloc;
goto unwind;
}
strncpy(name, (char*)&c[1], c->name_len);
rc = AllocDevicePair(client, name, &ptr, &keybd,
@@ -159,7 +160,8 @@ add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
/* Allocate virtual slave devices for xtest events */
rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, ptr, keybd);
if (rc != Success) {
if (rc != Success)
{
DeleteInputDeviceRequest(ptr);
DeleteInputDeviceRequest(keybd);
goto unwind;
@@ -175,7 +177,8 @@ add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
flags[XTestptr->id] |= XISlaveAdded;
flags[XTestkeybd->id] |= XISlaveAdded;
if (c->enable) {
if (c->enable)
{
EnableDevice(ptr, FALSE);
EnableDevice(keybd, FALSE);
flags[ptr->id] |= XIDeviceEnabled;
@@ -194,9 +197,6 @@ add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
flags[XTestptr->id] |= XISlaveAttached;
flags[XTestkeybd->id] |= XISlaveAttached;
for (int i = 0; i < currentMaxClients; i++)
XIBarrierNewMasterDevice(clients[i], ptr->id);
unwind:
free(name);
return rc;
@@ -207,39 +207,44 @@ disable_clientpointer(DeviceIntPtr dev)
{
int i;
for (i = 0; i < currentMaxClients; i++) {
for (i = 0; i < currentMaxClients; i++)
{
ClientPtr client = clients[i];
if (client && client->clientPtr == dev)
client->clientPtr = NULL;
}
}
static int
remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
int flags[MAXDEVICES])
{
DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd;
int rc = Success;
if (r->return_mode != XIAttachToMaster && r->return_mode != XIFloating)
if (r->return_mode != XIAttachToMaster &&
r->return_mode != XIFloating)
return BadValue;
rc = dixLookupDevice(&ptr, r->deviceid, client, DixDestroyAccess);
if (rc != Success)
goto unwind;
if (!IsMaster(ptr)) {
if (!IsMaster(ptr))
{
client->errorValue = r->deviceid;
rc = BadDevice;
goto unwind;
}
/* XXX: For now, don't allow removal of VCP, VCK */
if (ptr == inputInfo.pointer ||ptr == inputInfo.keyboard) {
if (ptr == inputInfo.pointer || ptr == inputInfo.keyboard)
{
rc = BadDevice;
goto unwind;
}
ptr = GetMaster(ptr, MASTER_POINTER);
rc = dixLookupDevice(&ptr, ptr->id, client, DixDestroyAccess);
if (rc != Success)
@@ -255,7 +260,8 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
goto unwind;
XTestkeybd = GetXTestDevice(keybd);
rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, DixDestroyAccess);
rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client,
DixDestroyAccess);
if (rc != Success)
goto unwind;
@@ -263,14 +269,18 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
/* Disabling sends the devices floating, reattach them if
* desired. */
if (r->return_mode == XIAttachToMaster) {
DeviceIntPtr attached, newptr, newkeybd;
if (r->return_mode == XIAttachToMaster)
{
DeviceIntPtr attached,
newptr,
newkeybd;
rc = dixLookupDevice(&newptr, r->return_pointer, client, DixAddAccess);
if (rc != Success)
goto unwind;
if (!IsMaster(newptr)) {
if (!IsMaster(newptr))
{
client->errorValue = r->return_pointer;
rc = BadDevice;
goto unwind;
@@ -281,19 +291,23 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
if (!IsMaster(newkeybd)) {
if (!IsMaster(newkeybd))
{
client->errorValue = r->return_keyboard;
rc = BadDevice;
goto unwind;
}
for (attached = inputInfo.devices; attached; attached = attached->next) {
for (attached = inputInfo.devices; attached; attached = attached->next)
{
if (!IsMaster(attached)) {
if (GetMaster(attached, MASTER_ATTACHED) == ptr) {
if (GetMaster(attached, MASTER_ATTACHED) == ptr)
{
AttachDevice(client, attached, newptr);
flags[attached->id] |= XISlaveAttached;
}
if (GetMaster(attached, MASTER_ATTACHED) == keybd) {
if (GetMaster(attached, MASTER_ATTACHED) == keybd)
{
AttachDevice(client, attached, newkeybd);
flags[attached->id] |= XISlaveAttached;
}
@@ -301,8 +315,11 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
}
}
for (int i = 0; i < currentMaxClients; i++)
XIBarrierRemoveMasterDevice(clients[i], ptr->id);
/* can't disable until we removed pairing */
keybd->spriteInfo->paired = NULL;
ptr->spriteInfo->paired = NULL;
XTestptr->spriteInfo->paired = NULL;
XTestkeybd->spriteInfo->paired = NULL;
/* disable the remove the devices, XTest devices must be done first
else the sprites they rely on will be destroyed */
@@ -315,15 +332,14 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
flags[keybd->id] |= XIDeviceDisabled;
flags[ptr->id] |= XIDeviceDisabled;
flags[XTestptr->id] |= XISlaveRemoved;
flags[XTestkeybd->id] |= XISlaveRemoved;
flags[keybd->id] |= XIMasterRemoved;
flags[ptr->id] |= XIMasterRemoved;
RemoveDevice(XTestptr, FALSE);
RemoveDevice(XTestkeybd, FALSE);
RemoveDevice(keybd, FALSE);
RemoveDevice(ptr, FALSE);
flags[XTestptr->id] |= XISlaveRemoved;
flags[XTestkeybd->id] |= XISlaveRemoved;
flags[keybd->id] |= XIMasterRemoved;
flags[ptr->id] |= XIMasterRemoved;
unwind:
return rc;
@@ -339,14 +355,16 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo * c, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
if (IsMaster(dev)) {
if (IsMaster(dev))
{
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
}
/* Don't allow changes to XTest Devices, these are fixed */
if (IsXTestDevice(dev, NULL)) {
if (IsXTestDevice(dev, NULL))
{
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
@@ -361,7 +379,8 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo * c, int flags[MAXDEVICES])
}
static int
attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES])
attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
int flags[MAXDEVICES])
{
DeviceIntPtr dev;
DeviceIntPtr newmaster;
@@ -371,14 +390,16 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
if (IsMaster(dev)) {
if (IsMaster(dev))
{
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
}
/* Don't allow changes to XTest Devices, these are fixed */
if (IsXTestDevice(dev, NULL)) {
if (IsXTestDevice(dev, NULL))
{
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
@@ -387,14 +408,16 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES])
rc = dixLookupDevice(&newmaster, c->new_master, client, DixAddAccess);
if (rc != Success)
goto unwind;
if (!IsMaster(newmaster)) {
if (!IsMaster(newmaster))
{
client->errorValue = c->new_master;
rc = BadDevice;
goto unwind;
}
if (!((IsPointerDevice(newmaster) && IsPointerDevice(dev)) ||
(IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev)))) {
(IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev))))
{
rc = BadDevice;
goto unwind;
}
@@ -407,13 +430,16 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES])
return rc;
}
#define SWAPIF(cmd) if (client->swapped) { cmd; }
int
ProcXIChangeHierarchy(ClientPtr client)
{
xXIAnyHierarchyChangeInfo *any;
size_t len; /* length of data remaining in request */
int required_len = sizeof(xXIChangeHierarchyReq);
char n;
int rc = Success;
int flags[MAXDEVICES] = {0};
@@ -423,44 +449,22 @@ ProcXIChangeHierarchy(ClientPtr client)
if (!stuff->num_changes)
return rc;
len = ((size_t)stuff->length << 2) - sizeof(xXIChangeHierarchyReq);
any = (xXIAnyHierarchyChangeInfo*)&stuff[1];
while (stuff->num_changes--) {
if (len < sizeof(xXIAnyHierarchyChangeInfo)) {
rc = BadLength;
goto unwind;
}
while(stuff->num_changes--)
{
SWAPIF(swapl(&any->type, n));
SWAPIF(swaps(&any->length, n));
SWAPIF(swaps(&any->type));
SWAPIF(swaps(&any->length));
if (len < ((size_t)any->length << 2))
required_len += any->length;
if ((stuff->length * 4) < required_len)
return BadLength;
#define CHANGE_SIZE_MATCH(type) \
do { \
if ((len < sizeof(type)) || (any->length != (sizeof(type) >> 2))) { \
rc = BadLength; \
goto unwind; \
} \
} while(0)
switch (any->type) {
switch(any->type)
{
case XIAddMaster:
{
xXIAddMasterInfo* c = (xXIAddMasterInfo*)any;
/* Variable length, due to appended name string */
if (len < sizeof(xXIAddMasterInfo)) {
rc = BadLength;
goto unwind;
}
SWAPIF(swaps(&c->name_len));
if (c->name_len > (len - sizeof(xXIAddMasterInfo))) {
rc = BadLength;
goto unwind;
}
SWAPIF(swaps(&c->name_len, n));
rc = add_master(client, c, flags);
if (rc != Success)
@@ -471,7 +475,6 @@ ProcXIChangeHierarchy(ClientPtr client)
{
xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any;
CHANGE_SIZE_MATCH(xXIRemoveMasterInfo);
rc = remove_master(client, r, flags);
if (rc != Success)
goto unwind;
@@ -481,7 +484,6 @@ ProcXIChangeHierarchy(ClientPtr client)
{
xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any;
CHANGE_SIZE_MATCH(xXIDetachSlaveInfo);
rc = detach_slave(client, c, flags);
if (rc != Success)
goto unwind;
@@ -491,7 +493,6 @@ ProcXIChangeHierarchy(ClientPtr client)
{
xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any;
CHANGE_SIZE_MATCH(xXIAttachSlaveInfo);
rc = attach_slave(client, c, flags);
if (rc != Success)
goto unwind;
@@ -499,7 +500,6 @@ ProcXIChangeHierarchy(ClientPtr client)
break;
}
len -= any->length * 4;
any = (xXIAnyHierarchyChangeInfo*)((char*)any + any->length * 4);
}
@@ -508,3 +508,4 @@ ProcXIChangeHierarchy(ClientPtr client)
XISendDeviceHierarchyEvent(flags);
return rc;
}

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