~ubuntu-branches/ubuntu/maverick/xorg-server/maverick-security

« back to all changes in this revision

Viewing changes to mi/mipointer.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2010-08-05 11:25:14 UTC
  • mfrom: (1.1.35 upstream) (0.1.14 experimental)
  • Revision ID: james.westby@ubuntu.com-20100805112514-q4efdgj3nblevos2
Tags: 2:1.8.99.905-1ubuntu1
* Merge from (unreleased) Debian experimental.  Remaining Ubuntu changes:
  - rules, control:
    + Disable SELinux, libaudit-dev is not in main yet (LP 406226).
      Drop libaudit-dev from build-deps.
  - rules: Enable xcsecurity (LP 247537).
  - local/xvfb-run*: Add correct docs about error codes (LP 328205)
  - rules: Add --with-extra-module-dir to support GL alternatives.
  - control: Xvfb depends on xauth, x11-xkb-utils. (LP 500102)
  - rules, local/64-xorg-xkb.rules: Don't use keyboard-configuration
    until it's available.
  - control: Update some versioned Breaks for Ubuntu versions.
  - debian/patches:
    + 100_rethrow_signals.patch:
      When aborting, re-raise signals for apport
    + 109_fix-swcursor-crash.patch:
      Avoid dereferencing null pointer while reloading cursors during
      resume. (LP 371405)
    + 111_armel-drv-fallbacks.patch:
      Add support for armel driver fallbacks.
    + 121_only_switch_vt_when_active.diff:
      Add a check to prevent the X server from changing the VT when killing
      GDM from the console.
    + 122_xext_fix_card32_overflow_in_xauth.patch:
      Fix server crash when “xauth generate” is called with large timeout.
    + 157_check_null_modes.patch, 162_null_crtc_in_rotation.patch,
      166_nullptr_xinerama_keyrepeat.patch, 167_nullptr_xisbread.patch
      169_mipointer_nullptr_checks.patch,
      172_cwgetbackingpicture_nullptr_check.patch:
      Fix various segfaults in xserver by checking pointers for NULL
      values before dereferencing them.
    + 165_man_xorg_conf_no_device_ident.patch
      Correct man page
    + 168_glibc_trace_to_stderr.patch:
      Report abort traces to stderr instead of terminal
    + 184_virtual_devices_autodetect.patch:
      Use vesa for qemu device, which is not supported by cirrus
    + 187_edid_quirk_hp_nc8430.patch:
      Quirk for another LPL monitor (LP 380009)
    + 188_default_primary_to_first_busid.patch:
      Pick the first device and carry on (LP 459512)
    + 189_xserver_1.5.0_bg_none_root.patch:
      Create a root window with no background.
    + 190_cache-xkbcomp_output_for_fast_start_up.patch:
      Cache keyboard settings.
    + 191-Xorg-add-an-extra-module-path.patch:
      Add support for the alternatives module path.
    + 197_xvfb-randr.patch:
      Adds xrandr support to xvfb. (LP 516123)
    + 198_nohwaccess.patch:
      Adds a -nohwaccess argument to make X not access the hardware
      ports directly.
    + 200_randr-null.patch:
      Clarify a pointer initialization.
* Update changelog entries for 1.8.1.902-1 which became 1.8.99.904-1
* Drop 196_xvfbscreeninit-handling.patch: it's semantically empty, and now 
  doesn't apply.  Merge remaining #include change into 197_xvfb-randr.patch
* New upstream version will start correctly when no outputs are connected,
  as long as the video driver can dynamically resize the framebuffer
  (true for all KMS drivers) (LP: #337889)
* New upstream version fixes crash on non-admin logout with KDE (LP: #569879)
* Refresh 111_armel-drv-fallbacks.patch to fix the build on armel

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
# include   "dixstruct.h"
41
41
# include   "inputstr.h"
42
42
 
43
 
static int miPointerScreenKeyIndex;
44
 
DevPrivateKey miPointerScreenKey = &miPointerScreenKeyIndex;
 
43
DevPrivateKeyRec miPointerScreenKeyRec;
45
44
 
46
45
#define GetScreenPrivate(s) ((miPointerScreenPtr) \
47
46
    dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
48
47
#define SetupScreen(s)  miPointerScreenPtr  pScreenPriv = GetScreenPrivate(s)
49
48
 
50
 
static int miPointerPrivKeyIndex;
51
 
static DevPrivateKey miPointerPrivKey = &miPointerPrivKeyIndex;
 
49
DevPrivateKeyRec miPointerPrivKeyRec;
52
50
 
53
51
#define MIPOINTER(dev) \
54
52
    ((!IsMaster(dev) && !dev->u.master) ? \
63
61
                                   CursorPtr pCursor);
64
62
static void miPointerConstrainCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
65
63
                                     BoxPtr pBox); 
66
 
static void miPointerPointerNonInterestBox(DeviceIntPtr pDev, 
67
 
                                           ScreenPtr pScreen, BoxPtr pBox);
68
64
static void miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen,
69
65
                                  CursorPtr pCursor, BoxPtr pHotBox, 
70
66
                                  BoxPtr pTopLeftBox);
77
73
static Bool miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
78
74
static void miPointerDeviceCleanup(DeviceIntPtr pDev,
79
75
                                   ScreenPtr pScreen);
 
76
static void miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
80
77
 
81
78
static EventList* events; /* for WarpPointer MotionNotifies */
82
79
 
88
85
{
89
86
    miPointerScreenPtr  pScreenPriv;
90
87
 
91
 
    pScreenPriv = xalloc (sizeof (miPointerScreenRec));
 
88
    if (!dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0))
 
89
        return FALSE;
 
90
 
 
91
    if (!dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0))
 
92
        return FALSE;
 
93
 
 
94
    pScreenPriv = malloc(sizeof (miPointerScreenRec));
92
95
    if (!pScreenPriv)
93
96
        return FALSE;
94
97
    pScreenPriv->spriteFuncs = spriteFuncs;
115
118
    pScreen->UnrealizeCursor = miPointerUnrealizeCursor;
116
119
    pScreen->SetCursorPosition = miPointerSetCursorPosition;
117
120
    pScreen->RecolorCursor = miRecolorCursor;
118
 
    pScreen->PointerNonInterestBox = miPointerPointerNonInterestBox;
119
121
    pScreen->DeviceCursorInitialize = miPointerDeviceInitialize;
120
122
    pScreen->DeviceCursorCleanup = miPointerDeviceCleanup;
121
123
 
154
156
#endif
155
157
 
156
158
    pScreen->CloseScreen = pScreenPriv->CloseScreen;
157
 
    xfree ((pointer) pScreenPriv);
 
159
    free((pointer) pScreenPriv);
158
160
    FreeEventList(events, GetMaximumEventsNum());
159
161
    events = NULL;
160
162
    return (*pScreen->CloseScreen) (index, pScreen);
211
213
 
212
214
/*ARGSUSED*/
213
215
static void
214
 
miPointerPointerNonInterestBox (DeviceIntPtr    pDev,
215
 
                                ScreenPtr       pScreen,
216
 
                                BoxPtr          pBox)
217
 
{
218
 
    /* until DIX uses this, this will remain a stub */
219
 
}
220
 
 
221
 
/*ARGSUSED*/
222
 
static void
223
216
miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
224
217
                      BoxPtr pHotBox, BoxPtr pTopLeftBox)
225
218
{
252
245
    miPointerPtr pPointer;
253
246
    SetupScreen (pScreen);
254
247
 
255
 
    pPointer = xalloc(sizeof(miPointerRec));
 
248
    pPointer = malloc(sizeof(miPointerRec));
256
249
    if (!pPointer)
257
250
        return FALSE;
258
251
 
270
263
 
271
264
    if (!((*pScreenPriv->spriteFuncs->DeviceCursorInitialize)(pDev, pScreen)))
272
265
    {
273
 
        xfree(pPointer);
 
266
        free(pPointer);
274
267
        return FALSE;
275
268
    }
276
269
 
290
283
        return;
291
284
 
292
285
    (*pScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen);
293
 
    xfree(dixLookupPrivate(&pDev->devPrivates, miPointerPrivKey));
 
286
    free(dixLookupPrivate(&pDev->devPrivates, miPointerPrivKey));
294
287
    dixSetPrivate(&pDev->devPrivates, miPointerPrivKey, NULL);
295
288
}
296
289
 
313
306
    }
314
307
 
315
308
    if (GenerateEvent)
316
 
    {
317
309
        miPointerMove (pDev, pScreen, x, y);
318
 
    }
319
310
    else
320
 
    {
321
 
        /* everything from miPointerMove except the event and history */
322
 
 
323
 
        if (!pScreenPriv->waitForUpdate && pScreen == pPointer->pSpriteScreen)
324
 
        {
325
 
            pPointer->devx = x;
326
 
            pPointer->devy = y;
327
 
            if(pPointer->pCursor && !pPointer->pCursor->bits->emptyMask)
328
 
                (*pScreenPriv->spriteFuncs->MoveCursor) (pDev, pScreen, x, y);
329
 
        }
330
 
        pPointer->x = x;
331
 
        pPointer->y = y;
332
 
        pPointer->pScreen = pScreen;
333
 
    }
 
311
        miPointerMoveNoEvent(pDev, pScreen, x, y);
334
312
 
335
313
    /* Don't call USFS if we use Xinerama, otherwise the root window is
336
314
     * updated to the second screen, and we never receive any events.
460
438
    return (pPointer) ? pPointer->pScreen : NULL;
461
439
}
462
440
 
 
441
/* Controls whether the cursor image should be updated immediately when
 
442
   moved (FALSE) or if something else will be responsible for updating
 
443
   it later (TRUE).  Returns current setting.
 
444
   Caller is responsible for calling OsBlockSignal first.
 
445
*/
 
446
Bool
 
447
miPointerSetWaitForUpdate(ScreenPtr pScreen, Bool wait)
 
448
{
 
449
    SetupScreen(pScreen);
 
450
    Bool prevWait = pScreenPriv->waitForUpdate;
 
451
 
 
452
    pScreenPriv->waitForUpdate = wait;
 
453
    return prevWait;
 
454
}
 
455
 
 
456
 
463
457
/* Move the pointer on the current screen,  and update the sprite. */
464
458
static void
465
 
miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen,
 
459
miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen,
466
460
                int x, int y)
467
461
{
468
462
    miPointerPtr pPointer;
497
491
 
498
492
    miPointerPtr        pPointer; 
499
493
 
 
494
    if (!pDev || !pDev->coreEvents)
 
495
        return;
 
496
 
500
497
    pPointer = MIPOINTER(pDev);
501
498
    pScreen = pPointer->pScreen;
502
499
    if (!pScreen)
503
500
        return;     /* called before ready */
504
501
 
505
 
    if (!pDev || !pDev->coreEvents)
506
 
        return;
507
 
 
508
502
    if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height)
509
503
    {
510
504
        pScreenPriv = GetScreenPrivate (pScreen);
538
532
            pPointer->pScreen == pScreen) 
539
533
        return;
540
534
 
541
 
    miPointerMoved(pDev, pScreen, *x, *y);
 
535
    miPointerMoveNoEvent(pDev, pScreen, *x, *y);
542
536
}
543
537
 
544
538
void
560
554
    int i, nevents;
561
555
    int valuators[2];
562
556
 
563
 
    miPointerMoved(pDev, pScreen, x, y);
 
557
    miPointerMoveNoEvent(pDev, pScreen, x, y);
564
558
 
565
559
    /* generate motion notify */
566
560
    valuators[0] = x;