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

« back to all changes in this revision

Viewing changes to hw/kdrive/ephyr/ephyr.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:
38
38
#include "ephyrglxext.h"
39
39
#endif /* XF86DRI */
40
40
 
 
41
#include "xkbsrv.h"
 
42
 
41
43
extern int KdTsPhyScreen;
42
44
#ifdef GLXEXT
43
45
extern Bool noGlxVisualInit;
73
75
{
74
76
  EphyrPriv     *priv;
75
77
  
76
 
  priv = (EphyrPriv *) xalloc (sizeof (EphyrPriv));
 
78
  priv = (EphyrPriv *) malloc(sizeof (EphyrPriv));
77
79
  if (!priv)
78
80
    return FALSE;
79
81
  
80
82
  if (!ephyrInitialize (card, priv))
81
83
    {
82
 
      xfree (priv);
 
84
      free(priv);
83
85
      return FALSE;
84
86
    }
85
87
  card->driver = priv;
185
187
{
186
188
  EphyrScrPriv *scrpriv;
187
189
  
188
 
  scrpriv = xcalloc (1, sizeof (EphyrScrPriv));
 
190
  scrpriv = calloc(1, sizeof (EphyrScrPriv));
189
191
 
190
192
  if (!scrpriv)
191
193
    return FALSE;
195
197
  if (!ephyrScreenInitialize (screen, scrpriv))
196
198
    {
197
199
      screen->driver = 0;
198
 
      xfree (scrpriv);
 
200
      free(scrpriv);
199
201
      return FALSE;
200
202
    }
201
203
 
343
345
 
344
346
  pRegion = DamageRegion (scrpriv->pDamage);
345
347
 
346
 
  if (REGION_NOTEMPTY (pScreen, pRegion))
 
348
  if (RegionNotEmpty(pRegion))
347
349
    {
348
350
      int           nbox;
349
351
      BoxPtr        pbox;
350
352
 
351
 
      nbox = REGION_NUM_RECTS (pRegion);
352
 
      pbox = REGION_RECTS (pRegion);
 
353
      nbox = RegionNumRects (pRegion);
 
354
      pbox = RegionRects (pRegion);
353
355
 
354
356
      while (nbox--)
355
357
        {
737
739
    if (scrpriv->shadow) {
738
740
        KdShadowFbFree (screen);
739
741
    }
740
 
    xfree(screen->driver);
 
742
    free(screen->driver);
741
743
    screen->driver = NULL;
742
744
}
743
745
 
748
750
void
749
751
ephyrUpdateModifierState(unsigned int state)
750
752
{
751
 
#if 0
752
 
  DeviceIntPtr pkeydev;
753
 
  KeyClassPtr  keyc;
754
 
  int          i;
755
 
  CARD8        mask;
756
 
 
757
 
  pkeydev = inputInfo.keyboard;
758
 
 
759
 
  if (!pkeydev)
760
 
    return;
761
 
  
762
 
/* This is pretty broken.
763
 
 *
764
 
 * What should happen is that focus out should do as a VT switch does in
765
 
 * traditional servers: fake releases for all keys (and buttons too, come
766
 
 * to think of it) currently down.  Then, on focus in, get the state from
767
 
 * the host, and fake keypresses for everything currently down.
768
 
 *
769
 
 * So I'm leaving this broken for a little while.  Sorry, folks.
770
 
 *
771
 
 * -daniels
772
 
 */
773
 
 
774
 
  keyc = pkeydev->key;
775
 
  
 
753
 
 
754
  DeviceIntPtr pDev = inputInfo.keyboard;
 
755
  KeyClassPtr keyc = pDev->key;
 
756
  int i;
 
757
  CARD8 mask;
 
758
  int xkb_state;
 
759
  
 
760
  if (!pDev)
 
761
      return;
 
762
 
 
763
  xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
776
764
  state = state & 0xff;
777
 
  
778
 
  if (keyc->state == state)
 
765
 
 
766
  if (xkb_state == state)
779
767
    return;
780
 
  
781
 
  for (i = 0, mask = 1; i < 8; i++, mask <<= 1) 
782
 
    {
783
 
      int key;
784
768
      
785
 
      /* Modifier is down, but shouldn't be   */
786
 
      if ((keyc->state & mask) && !(state & mask)) 
787
 
        {
788
 
          int count = keyc->modifierKeyCount[i];
789
 
          
790
 
          for (key = 0; key < MAP_LENGTH; key++)
791
 
            if (keyc->xkbInfo->desc->map->modmap[key] & mask)
792
 
              {
793
 
                int bit;
794
 
                BYTE *kptr;
795
 
                
796
 
                kptr = &keyc->down[key >> 3];
797
 
                bit = 1 << (key & 7);
798
 
                
799
 
                if (*kptr & bit && ephyrKbd &&
800
 
                    ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
801
 
                  KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */
802
 
                
803
 
                if (--count == 0)
804
 
                  break;
805
 
              }
806
 
        }
807
 
       
808
 
      /* Modifier shoud be down, but isn't   */
809
 
      if (!(keyc->state & mask) && (state & mask))
810
 
        for (key = 0; key < MAP_LENGTH; key++)
811
 
          if (keyc->xkbInfo->desc->map->modmap[key] & mask)
812
 
            {
813
 
              if (keyc->xkbInfo->desc->map->modmap[key] & mask && ephyrKbd &&
814
 
                  ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
815
 
                  KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */
816
 
              break;
817
 
            }
 
769
  for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
 
770
    int key;
 
771
 
 
772
    /* Modifier is down, but shouldn't be
 
773
     */
 
774
    if ((xkb_state & mask) && !(state & mask)) {
 
775
      int count = keyc->modifierKeyCount[i];
 
776
 
 
777
      for (key = 0; key < MAP_LENGTH; key++)
 
778
        if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
 
779
          if (key_is_down(pDev, key, KEY_PROCESSED))
 
780
                KdEnqueueKeyboardEvent (ephyrKbd, key, TRUE);
 
781
 
 
782
          if (--count == 0)
 
783
            break;
 
784
        }
818
785
    }
819
 
#endif
 
786
 
 
787
    /* Modifier shoud be down, but isn't
 
788
     */
 
789
    if (!(xkb_state & mask) && (state & mask))
 
790
      for (key = 0; key < MAP_LENGTH; key++)
 
791
        if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
 
792
                KdEnqueueKeyboardEvent (ephyrKbd, key, FALSE);
 
793
          break;
 
794
        }
 
795
  }
820
796
}
821
797
 
822
798
static void
897
873
        return;
898
874
    }
899
875
    screen = pair->local->drawable.pScreen;
900
 
    REGION_NULL (screen, &reg);
901
 
    REGION_COPY (screen, &reg, &pair->local->clipList);
 
876
    RegionNull(&reg);
 
877
    RegionCopy(&reg, &pair->local->clipList);
902
878
    screen->WindowExposures (pair->local, &reg, NullRegion);
903
 
    REGION_UNINIT (screen, &reg);
 
879
    RegionUninit(&reg);
904
880
}
905
881
#endif /* XF86DRI */
906
882
 
998
974
          if (!ephyrKbd ||
999
975
              !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
1000
976
              continue;
 
977
          ephyrUpdateModifierState(ev.key_state);
1001
978
          KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
1002
979
          break;
1003
980
 
1023
1000
ephyrCardFini (KdCardInfo *card)
1024
1001
{
1025
1002
  EphyrPriv     *priv = card->driver;
1026
 
  xfree (priv);
 
1003
  free(priv);
1027
1004
}
1028
1005
 
1029
1006
void
1075
1052
MouseInit (KdPointerInfo *pi)
1076
1053
{
1077
1054
    pi->driverPrivate = (EphyrPointerPrivate *)
1078
 
                         xcalloc(sizeof(EphyrPointerPrivate), 1);
 
1055
                         calloc(sizeof(EphyrPointerPrivate), 1);
1079
1056
    ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
1080
1057
    pi->nAxes = 3;
1081
1058
    pi->nButtons = 32;
1082
 
    xfree(pi->name);
 
1059
    free(pi->name);
1083
1060
    pi->name = strdup("Xephyr virtual mouse");
1084
1061
    ephyrMouse = pi;
1085
1062
    return Success;
1121
1098
EphyrKeyboardInit (KdKeyboardInfo *ki)
1122
1099
{
1123
1100
  ki->driverPrivate = (EphyrKbdPrivate *)
1124
 
                       xcalloc(sizeof(EphyrKbdPrivate), 1);
 
1101
                       calloc(sizeof(EphyrKbdPrivate), 1);
1125
1102
  hostx_load_keymap();
1126
1103
  if (!ephyrKeySyms.map) {
1127
1104
      ErrorF("Couldn't load keymap from host\n");
1129
1106
  }
1130
1107
  ki->minScanCode = ephyrKeySyms.minKeyCode;
1131
1108
  ki->maxScanCode = ephyrKeySyms.maxKeyCode;
1132
 
  xfree(ki->name);
 
1109
  free(ki->name);
1133
1110
  ki->name = strdup("Xephyr virtual keyboard");
1134
1111
  ephyrKbd = ki;
1135
1112
  return Success;