/[qemacs]/qemacs/x11.c
ViewVC logotype

Diff of /qemacs/x11.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by chqrlie, Mon May 9 09:10:38 2005 UTC revision 1.5 by chqrlie, Wed May 11 12:01:32 2005 UTC
# Line 60  static XIC xic; /* X11 input context */ Line 60  static XIC xic; /* X11 input context */
60  static Pixmap dbuffer;  static Pixmap dbuffer;
61  static int shm_use;  static int shm_use;
62  #ifdef CONFIG_XFT  #ifdef CONFIG_XFT
63  static XftDraw          *renderDraw;  static XftDraw          *renderDraw;
64  #endif  #endif
65  #ifdef CONFIG_XV  #ifdef CONFIG_XV
66  static unsigned int xv_nb_formats, xv_nb_adaptors, xv_port, xv_format, xv_open_count;  static unsigned int xv_nb_formats, xv_nb_adaptors, xv_port, xv_format, xv_open_count;
# Line 99  static int font_ptsize = 0; Line 99  static int font_ptsize = 0;
99  static void update_reset(void)  static void update_reset(void)
100  {  {
101      int i;      int i;
102      for(i=0;i<UPDATE_MAX_REGIONS;i++)      for (i = 0; i < UPDATE_MAX_REGIONS; i++)
103          css_set_rect(update_rects + i, 0, 0, 0, 0);          css_set_rect(update_rects + i, 0, 0, 0, 0);
104      update_nb = 0;      update_nb = 0;
105  }  }
# Line 139  static void update_rect(int x1, int y1, Line 139  static void update_rect(int x1, int y1,
139      dmin = MAXINT;      dmin = MAXINT;
140      r2 = update_rects;      r2 = update_rects;
141      r1 = NULL;      r1 = NULL;
142      for(i=0;i<update_nb;i++) {      for (i = 0; i < update_nb; i++) {
143          d = rect_dist(r2, &r);          d = rect_dist(r2, &r);
144          if (d < dmin) {          if (d < dmin) {
145              dmin = d;              dmin = d;
# Line 267  static int term_init(QEditScreen *s, int Line 267  static int term_init(QEditScreen *s, int
267      /* Tell other applications about this window */      /* Tell other applications about this window */
268    
269      XSetStandardProperties(display, window,      XSetStandardProperties(display, window,
270                             "qemacs", "qemacs",                             "qemacs", "qemacs",
271                             None, NULL, 0, &hint);                             None, NULL, 0, &hint);
272    
273      /* Map window. */      /* Map window. */
274    
# Line 276  static int term_init(QEditScreen *s, int Line 276  static int term_init(QEditScreen *s, int
276    
277      /* Wait for map. */      /* Wait for map. */
278      while (1) {      while (1) {
279          XEvent xev;          XEvent xev;
280          XNextEvent(display, &xev);          XNextEvent(display, &xev);
281          if (xev.type == MapNotify && xev.xmap.event == window)          if (xev.type == MapNotify && xev.xmap.event == window)
282              break;              break;
283      }      }
284      event_mask = KeyPressMask | ButtonPressMask | ButtonReleaseMask |      event_mask = KeyPressMask | ButtonPressMask | ButtonReleaseMask |
285          ButtonMotionMask | ExposureMask | StructureNotifyMask;          ButtonMotionMask | ExposureMask | StructureNotifyMask;
# Line 340  static int term_init(QEditScreen *s, int Line 340  static int term_init(QEditScreen *s, int
340              shm_use = 1;              shm_use = 1;
341      }      }
342      /* compute bitmap format */      /* compute bitmap format */
343      switch(visual_depth) {      switch (visual_depth) {
344      case 15:      case 15:
345          s->bitmap_format = QEBITMAP_FORMAT_RGB555;          s->bitmap_format = QEBITMAP_FORMAT_RGB555;
346          break;          break;
# Line 394  static void xv_init(QEditScreen *s) Line 394  static void xv_init(QEditScreen *s)
394   found:   found:
395            
396      xv_fo = XvListImageFormats(display, xv_port, &xv_nb_formats);      xv_fo = XvListImageFormats(display, xv_port, &xv_nb_formats);
397      for(i = 0; i < xv_nb_formats; i++) {      for (i = 0; i < xv_nb_formats; i++) {
398          XvImageFormatValues *fo = &xv_fo[i];          XvImageFormatValues *fo = &xv_fo[i];
399  #if 0  #if 0
400          printf("Xvideo image format: 0x%x (%c%c%c%c) %s\n",          printf("Xvideo image format: 0x%x (%c%c%c%c) %s\n",
# Line 448  static unsigned long get_x11_color(QECol Line 448  static unsigned long get_x11_color(QECol
448      r = (color >> 16) & 0xff;      r = (color >> 16) & 0xff;
449      g = (color >> 8) & 0xff;      g = (color >> 8) & 0xff;
450      b = (color) & 0xff;      b = (color) & 0xff;
451      switch(visual_depth) {      switch (visual_depth) {
452      case 15:      case 15:
453          return ((((r) >> 3) << 10) | (((g) >> 3) << 5) | ((b) >> 3));          return ((((r) >> 3) << 10) | (((g) >> 3) << 5) | ((b) >> 3));
454      case 16:      case 16:
# Line 525  static QEFont *term_open_font(QEditScree Line 525  static QEFont *term_open_font(QEditScree
525          return NULL;          return NULL;
526    
527    
528      switch(style & QE_FAMILY_MASK) {      switch (style & QE_FAMILY_MASK) {
529      default:      default:
530      case QE_FAMILY_FIXED:      case QE_FAMILY_FIXED:
531          family = font_family_str;          family = font_family_str;
# Line 664  static QEFont *term_open_font(QEditScree Line 664  static QEFont *term_open_font(QEditScree
664      /* take the nth font number in family list */      /* take the nth font number in family list */
665      font_fallback = (style & QE_FAMILY_FALLBACK_MASK) >> QE_FAMILY_FALLBACK_SHIFT;      font_fallback = (style & QE_FAMILY_FALLBACK_MASK) >> QE_FAMILY_FALLBACK_SHIFT;
666      p = family_list;      p = family_list;
667      for(i=0;i<font_fallback;i++) {      for (i = 0; i < font_fallback; i++) {
668          p = strchr(p, ',');          p = strchr(p, ',');
669          if (!p) {          if (!p) {
670              /* no font found */              /* no font found */
# Line 679  static QEFont *term_open_font(QEditScree Line 679  static QEFont *term_open_font(QEditScree
679      else      else
680          pstrncpy(family, sizeof(family), p, p1 - p);          pstrncpy(family, sizeof(family), p, p1 - p);
681  #if 0  #if 0
682      for(i=0;i<2;i++) {      for (i = 0; i < 2; i++) {
683          char buf1[32];          char buf1[32];
684          if (i == 0)          if (i == 0)
685              snprintf(buf1, sizeof(buf1), "%d", size * 10);              snprintf(buf1, sizeof(buf1), "%d", size * 10);
# Line 707  static QEFont *term_open_font(QEditScree Line 707  static QEFont *term_open_font(QEditScree
707      /* iterate thru each font and select closer one */      /* iterate thru each font and select closer one */
708      found = 0;      found = 0;
709      dist_min = MAXINT;      dist_min = MAXINT;
710      for(i=0;i<count;i++) {      for (i = 0; i < count; i++) {
711          dist = 0;          dist = 0;
712          p = list[i] + 1;          p = list[i] + 1;
713          get_entry(NULL, 0, &p);          get_entry(NULL, 0, &p);
# Line 772  static XCharStruct *get_char_struct(QEFo Line 772  static XCharStruct *get_char_struct(QEFo
772      int b1, b2;      int b1, b2;
773      XCharStruct *cs;      XCharStruct *cs;
774    
775        if (!xfont)
776            return NULL;
777    
778      if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) {      if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) {
779          if (cc > xfont->max_char_or_byte2)          if (cc > xfont->max_char_or_byte2)
780              return NULL;              return NULL;
# Line 817  static XCharStruct *handle_fallback(QEdi Line 820  static XCharStruct *handle_fallback(QEdi
820    
821    
822      /* fallback case */      /* fallback case */
823      fallback_count = 1;      for (fallback_count = 1; fallback_count < 5; fallback_count++) {
     for(;;) {  
824          font1 = select_font(s, font->style |          font1 = select_font(s, font->style |
825                              (fallback_count << QE_FAMILY_FALLBACK_SHIFT),                              (fallback_count << QE_FAMILY_FALLBACK_SHIFT),
826                              font->size);                              font->size);
827          if (!font1)          if (!font1)
828              break;              break;
829          cs = get_char_struct(font1, cc);          cs = get_char_struct(font1, cc);
# Line 829  static XCharStruct *handle_fallback(QEdi Line 831  static XCharStruct *handle_fallback(QEdi
831              *out_font = font1;              *out_font = font1;
832              return cs;              return cs;
833          }          }
         fallback_count++;  
834      }      }
835            
836      /* really no glyph : use default char in current font */      /* really no glyph : use default char in current font */
# Line 851  static void term_text_metrics(QEditScree Line 852  static void term_text_metrics(QEditScree
852      metrics->font_ascent = font->ascent;      metrics->font_ascent = font->ascent;
853      metrics->font_descent = font->descent;      metrics->font_descent = font->descent;
854      x = 0;      x = 0;
855      for(i=0;i<len;i++) {      for (i = 0; i < len; i++) {
856          cc = str[i];          cc = str[i];
857          cs = get_char_struct(font, cc);          cs = get_char_struct(font, cc);
858          if (cs) {          if (cs) {
# Line 974  static void term_flush(QEditScreen *s) Line 975  static void term_flush(QEditScreen *s)
975      int i, w, h;      int i, w, h;
976    
977      r = update_rects;      r = update_rects;
978      for(i=0;i<update_nb;i++) {      for (i = 0; i < update_nb; i++) {
979          if (r->x1 < 0)          if (r->x1 < 0)
980              r->x1 = 0;              r->x1 = 0;
981          if (r->x2 > s->width)          if (r->x2 > s->width)
# Line 1012  static void x11_full_screen(QEditScreen Line 1013  static void x11_full_screen(QEditScreen
1013      if (full_screen) {      if (full_screen) {
1014          if ((attr.width != screen_width || attr.height != screen_height)) {          if ((attr.width != screen_width || attr.height != screen_height)) {
1015              /* store current window position and size */              /* store current window position and size */
1016              XTranslateCoordinates(display, window, attr.root, 0, 0,              XTranslateCoordinates(display, window, attr.root, 0, 0,
1017                                    &last_window_x, &last_window_y, &win);                                    &last_window_x, &last_window_y, &win);
1018              last_window_width = attr.width;              last_window_width = attr.width;
1019              last_window_height = attr.height;              last_window_height = attr.height;
# Line 1074  static void term_selection_request(QEdit Line 1075  static void term_selection_request(QEdit
1075      b = new_yank_buffer();      b = new_yank_buffer();
1076            
1077      nread = 0;      nread = 0;
1078      for(;;) {      for (;;) {
1079          if ((XGetWindowProperty (display, w, prop,          if ((XGetWindowProperty (display, w, prop,
1080                                   nread/4, 4096, True,                                   nread/4, 4096, True,
1081                                   AnyPropertyType, &actual_type, &actual_fmt,                                   AnyPropertyType, &actual_type, &actual_fmt,
# Line 1112  static void selection_send(XSelectionReq Line 1113  static void selection_send(XSelectionReq
1113      ev.xselection.display   = rq->display;      ev.xselection.display   = rq->display;
1114      ev.xselection.requestor = rq->requestor;      ev.xselection.requestor = rq->requestor;
1115      ev.xselection.selection = rq->selection;      ev.xselection.selection = rq->selection;
1116      ev.xselection.target           = rq->target;      ev.xselection.target           = rq->target;
1117      ev.xselection.time      = rq->time;      ev.xselection.time      = rq->time;
1118    
1119      if (rq->target == xa_targets) {      if (rq->target == xa_targets) {
1120          unsigned int target_list[2];          unsigned int target_list[2];
1121    
1122          /* indicate which are supported types */          /* indicate which are supported types */
1123          target_list[0] = xa_targets;          target_list[0] = xa_targets;
1124          target_list[1] = XA_STRING;          target_list[1] = XA_STRING;
1125    
1126          XChangeProperty (display, rq->requestor, rq->property,          XChangeProperty (display, rq->requestor, rq->property,
1127                           xa_targets, 8*sizeof(target_list[0]), PropModeReplace,                           xa_targets, 8*sizeof(target_list[0]), PropModeReplace,
1128                           (char *)target_list,                           (char *)target_list,
1129                           sizeof(target_list)/sizeof(target_list[0]));                           sizeof(target_list)/sizeof(target_list[0]));
1130      } else if (rq->target == XA_STRING) {      } else if (rq->target == XA_STRING) {
1131          /* get qemacs yank buffer */          /* get qemacs yank buffer */
1132                
# Line 1169  static void x11_handle_event(void *opaqu Line 1170  static void x11_handle_event(void *opaqu
1170      int shift, ctrl, meta, len, key;      int shift, ctrl, meta, len, key;
1171      QEEvent ev1, *ev = &ev1;      QEEvent ev1, *ev = &ev1;
1172    
1173      for(;;) {      for (;;) {
1174          if (!XPending(display))          if (!XPending(display))
1175              return;              return;
1176          XNextEvent(display, &xev);          XNextEvent(display, &xev);
1177          switch(xev.type) {          switch (xev.type) {
1178          case ConfigureNotify:          case ConfigureNotify:
1179              {              {
1180                  int w, h;                  int w, h;
# Line 1198  static void x11_handle_event(void *opaqu Line 1199  static void x11_handle_event(void *opaqu
1199                      ev->button_event.type = QE_BUTTON_RELEASE_EVENT;                      ev->button_event.type = QE_BUTTON_RELEASE_EVENT;
1200                  ev->button_event.x = xe->x;                  ev->button_event.x = xe->x;
1201                  ev->button_event.y = xe->y;                  ev->button_event.y = xe->y;
1202                  switch(xe->button) {                  switch (xe->button) {
1203                  case Button1:                  case Button1:
1204                      ev->button_event.button = QE_BUTTON_LEFT;                      ev->button_event.button = QE_BUTTON_LEFT;
1205                      break;                      break;
# Line 1262  static void x11_handle_event(void *opaqu Line 1263  static void x11_handle_event(void *opaqu
1263              meta = (xev.xkey.state & Mod1Mask);              meta = (xev.xkey.state & Mod1Mask);
1264    
1265              if (ctrl) {              if (ctrl) {
1266                  switch(keysym) {                  switch (keysym) {
1267                  case XK_Right:                  case XK_Right:
1268                      key = KEY_CTRL_RIGHT;                      key = KEY_CTRL_RIGHT;
1269                      goto got_key;                      goto got_key;
# Line 1283  static void x11_handle_event(void *opaqu Line 1284  static void x11_handle_event(void *opaqu
1284                      break;                      break;
1285                  }                  }
1286              } else if (meta) {              } else if (meta) {
1287                  switch(keysym) {                  switch (keysym) {
1288                  case XK_BackSpace:                  case XK_BackSpace:
1289                      key = KEY_META(KEY_DEL);                      key = KEY_META(KEY_DEL);
1290                      goto got_key;                      goto got_key;
# Line 1295  static void x11_handle_event(void *opaqu Line 1296  static void x11_handle_event(void *opaqu
1296                      break;                      break;
1297                  }                  }
1298              } else {              } else {
1299                  switch(keysym) {                  switch (keysym) {
1300                  case XK_F1:                  case XK_F1:
1301                  case XK_F2:                  case XK_F2:
1302                  case XK_F3:                  case XK_F3:
# Line 1426  static int x11_bmp_alloc(QEditScreen *s, Line 1427  static int x11_bmp_alloc(QEditScreen *s,
1427          b->format = s->bitmap_format;          b->format = s->bitmap_format;
1428      }      }
1429    
1430      switch(xb->type) {      switch (xb->type) {
1431      default:      default:
1432      case BMP_PIXMAP:      case BMP_PIXMAP:
1433          xb->u.pixmap = XCreatePixmap(display, window,          xb->u.pixmap = XCreatePixmap(display, window,
# Line 1514  static void x11_bmp_free(QEditScreen *s, Line 1515  static void x11_bmp_free(QEditScreen *s,
1515  {  {
1516      X11Bitmap *xb = b->priv_data;      X11Bitmap *xb = b->priv_data;
1517    
1518      switch(xb->type) {      switch (xb->type) {
1519      case BMP_PIXMAP:      case BMP_PIXMAP:
1520          XFreePixmap(display, xb->u.pixmap);          XFreePixmap(display, xb->u.pixmap);
1521          break;          break;
# Line 1555  static void x11_bmp_draw(QEditScreen *s, Line 1556  static void x11_bmp_draw(QEditScreen *s,
1556      /* XXX: handle clipping ? */      /* XXX: handle clipping ? */
1557      update_rect(dst_x, dst_y, dst_x + dst_w, dst_y + dst_h);      update_rect(dst_x, dst_y, dst_x + dst_w, dst_y + dst_h);
1558    
1559      switch(xb->type) {      switch (xb->type) {
1560      case BMP_PIXMAP:      case BMP_PIXMAP:
1561          XCopyArea(display, xb->u.pixmap, dbuffer, gc,          XCopyArea(display, xb->u.pixmap, dbuffer, gc,
1562                    0, 0, b->width, b->height, dst_x, dst_y);                    0, 0, b->width, b->height, dst_x, dst_y);
# Line 1595  static void x11_bmp_lock(QEditScreen *s, Line 1596  static void x11_bmp_lock(QEditScreen *s,
1596      pict->width = w1;      pict->width = w1;
1597      pict->height = h1;      pict->height = h1;
1598      pict->format = b->format;      pict->format = b->format;
1599      switch(xb->type) {      switch (xb->type) {
1600      case BMP_PIXMAP:      case BMP_PIXMAP:
1601          {          {
1602              XImage *ximage;              XImage *ximage;
# Line 1623  static void x11_bmp_lock(QEditScreen *s, Line 1624  static void x11_bmp_lock(QEditScreen *s,
1624          {          {
1625              XvImage *xvimage = xb->u.xvimage;              XvImage *xvimage = xb->u.xvimage;
1626              int i, xx, yy, j;              int i, xx, yy, j;
1627              for(i=0;i<3;i++) {              for (i = 0; i < 3; i++) {
1628                  xx = x1;                  xx = x1;
1629                  yy = y1;                  yy = y1;
1630                  j = i;                  j = i;
# Line 1646  static void x11_bmp_unlock(QEditScreen * Line 1647  static void x11_bmp_unlock(QEditScreen *
1647  {  {
1648      X11Bitmap *xb = b->priv_data;      X11Bitmap *xb = b->priv_data;
1649      int ret;      int ret;
1650      switch(xb->type) {      switch (xb->type) {
1651      case BMP_PIXMAP:      case BMP_PIXMAP:
1652          ret = XPutImage(display, xb->u.pixmap, gc_pixmap, xb->ximage_lock,          ret = XPutImage(display, xb->u.pixmap, gc_pixmap, xb->ximage_lock,
1653                    0, 0, xb->x_lock, xb->y_lock,                    0, 0, xb->x_lock, xb->y_lock,

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26