[PATCH] Move event filter initializer out of the structure itself

Jeremy Huddleston jeremyhu at apple.com
Sat Apr 23 00:53:01 PDT 2011


Looks correct (and cleaner) to me.

Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

On Apr 22, 2011, at 10:19 PM, Alan Coopersmith wrote:

> When kept in the structure, it causes the entire MAXDEVICES * 128 masks
> to be stored in the data segment and loaded from the file, and also leads
> to worries about later generations inheriting changes across server reset.
> 
>           text    data     bss     dec     hex filename
> Before:   91837   20528      32  112397   1b70d .libs/events.o
> After:    92277      48   20512  112837   1b8c5 .libs/events.o
> Before: 3013384  122696  163156 3299236  3257a4 Xorg
> After:  3013832  102216  183636 3299684  325964 Xorg
> 
> File size before:       4337008 Xorg
> File size after:        4316568 Xorg
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
> dix/events.c |   17 ++++++++---------
> 1 files changed, 8 insertions(+), 9 deletions(-)
> 
> Barely tested - just made sure the server came up and was able to login.
> Stumbled across this due to it triggering a bug in the Solaris linker when
> building 64-bit SPARC debug binaries of the X server.
> 
> diff --git a/dix/events.c b/dix/events.c
> index 8835c5e..4988cd9 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -346,8 +346,8 @@ extern int DeviceMotionNotify;
> /**
>  * Event masks for each event type.
>  *
> - * One set of filters for each device, but only the first layer
> - * is initialized. The rest is memcpy'd in InitEvents.
> + * One set of filters for each device, initialized by memcpy of
> + * default_filter in InitEvents.
>  *
>  * Filters are used whether a given event may be delivered to a client,
>  * usually in the form of if (window-event-mask & filter); then deliver event.
> @@ -356,7 +356,9 @@ extern int DeviceMotionNotify;
>  * time a button is pressed, the filter is modified to also contain the
>  * matching ButtonXMotion mask.
>  */
> -static Mask filters[MAXDEVICES][128] = {
> +static Mask filters[MAXDEVICES][128];
> +
> +static const Mask default_filter[128] =
> {
> 	NoSuchEvent,		       /* 0 */
> 	NoSuchEvent,		       /* 1 */
> @@ -393,7 +395,7 @@ static Mask filters[MAXDEVICES][128] = {
> 	ColormapChangeMask,	       /* ColormapNotify */
> 	CantBeFiltered,		       /* ClientMessage */
> 	CantBeFiltered		       /* MappingNotify */
> -}};
> +};
> 
> /**
>  * For the given event, return the matching event filter. This filter may then
> @@ -4978,12 +4980,9 @@ InitEvents(void)
>     inputInfo.off_devices = (DeviceIntPtr)NULL;
>     inputInfo.keyboard = (DeviceIntPtr)NULL;
>     inputInfo.pointer = (DeviceIntPtr)NULL;
> -    /* The mask for pointer motion events may have changed in the last server
> -     * generation. See comment above definition of filters. */
> -    filters[0][PointerMotionMask] = MotionNotify;
> -    for (i = 1; i < MAXDEVICES; i++)
> +    for (i = 0; i < MAXDEVICES; i++)
>     {
> -        memcpy(&filters[i], filters[0], sizeof(filters[0]));
> +        memcpy(&filters[i], default_filter, sizeof(default_filter));
>     }
> 
>     syncEvents.replayDev = (DeviceIntPtr)NULL;
> -- 
> 1.7.3.2
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 



More information about the xorg-devel mailing list