Mercurial > hg > xemacs-beta
comparison src/device-x.c @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | 6240c7796c7a |
children | bbff43aa5eb7 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
37 #include "xmu.h" | 37 #include "xmu.h" |
38 #include "glyphs-x.h" | 38 #include "glyphs-x.h" |
39 #include "objects-x.h" | 39 #include "objects-x.h" |
40 | 40 |
41 #include "buffer.h" | 41 #include "buffer.h" |
42 #include "elhash.h" | |
42 #include "events.h" | 43 #include "events.h" |
43 #include "faces.h" | 44 #include "faces.h" |
44 #include "frame.h" | 45 #include "frame.h" |
45 #include "redisplay.h" | 46 #include "redisplay.h" |
46 #include "sysdep.h" | 47 #include "sysdep.h" |
326 int argc; | 327 int argc; |
327 char **argv; | 328 char **argv; |
328 CONST char *app_class; | 329 CONST char *app_class; |
329 CONST char *app_name; | 330 CONST char *app_name; |
330 CONST char *disp_name; | 331 CONST char *disp_name; |
331 Arg xargs[6]; | |
332 Cardinal numargs; | |
333 Visual *visual = NULL; | 332 Visual *visual = NULL; |
334 int depth = 8; /* shut up the compiler */ | 333 int depth = 8; /* shut up the compiler */ |
335 Colormap cmap; | 334 Colormap cmap; |
336 int screen; | 335 int screen; |
337 | 336 |
385 XtDisplayInitialize (Xt_app_con, dpy, compute_x_app_name (argc, argv), | 384 XtDisplayInitialize (Xt_app_con, dpy, compute_x_app_name (argc, argv), |
386 app_class, emacs_options, | 385 app_class, emacs_options, |
387 XtNumber (emacs_options), &argc, argv); | 386 XtNumber (emacs_options), &argc, argv); |
388 speed_up_interrupts (); | 387 speed_up_interrupts (); |
389 | 388 |
390 screen = DefaultScreen(dpy); | 389 screen = DefaultScreen (dpy); |
391 if (NILP (Vdefault_x_device)) | 390 if (NILP (Vdefault_x_device)) |
392 Vdefault_x_device = device; | 391 Vdefault_x_device = device; |
393 | 392 |
394 #ifdef MULE | 393 #ifdef MULE |
395 #if defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET) | 394 #if defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET) |
398 data-directory/app-defaults/$LANG/Emacs. | 397 data-directory/app-defaults/$LANG/Emacs. |
399 This is in addition to the standard app-defaults files, and | 398 This is in addition to the standard app-defaults files, and |
400 does not override resources defined elsewhere */ | 399 does not override resources defined elsewhere */ |
401 CONST char *data_dir; | 400 CONST char *data_dir; |
402 char *path; | 401 char *path; |
403 XrmDatabase db = XtDatabase (dpy); /* ### XtScreenDatabase(dpy) ? */ | 402 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */ |
404 CONST char *locale = XrmLocaleOfDatabase (db); | 403 CONST char *locale = XrmLocaleOfDatabase (db); |
405 | 404 |
406 if (STRINGP (Vx_app_defaults_directory) && | 405 if (STRINGP (Vx_app_defaults_directory) && |
407 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) | 406 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) |
408 { | 407 { |
432 /* colons and periods can't appear in individual elements of resource | 431 /* colons and periods can't appear in individual elements of resource |
433 strings */ | 432 strings */ |
434 | 433 |
435 XtGetApplicationNameAndClass (dpy, (char **) &app_name, (char **) &app_class); | 434 XtGetApplicationNameAndClass (dpy, (char **) &app_name, (char **) &app_class); |
436 /* search for a matching visual if requested by the user, or setup the display default */ | 435 /* search for a matching visual if requested by the user, or setup the display default */ |
437 numargs = 0; | |
438 { | 436 { |
439 char *buf1 = (char *)alloca (strlen (app_name) + 17); | 437 char *buf1 = (char *)alloca (strlen (app_name) + 17); |
440 char *buf2 = (char *)alloca (strlen (app_class) + 17); | 438 char *buf2 = (char *)alloca (strlen (app_class) + 17); |
441 char *type; | 439 char *type; |
442 XrmValue value; | 440 XrmValue value; |
443 | 441 |
444 sprintf (buf1, "%s.emacsVisual", app_name); | 442 sprintf (buf1, "%s.emacsVisual", app_name); |
445 sprintf (buf2, "%s.EmacsVisual", app_class); | 443 sprintf (buf2, "%s.EmacsVisual", app_class); |
446 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True) | 444 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True) |
447 { | 445 { |
448 int cnt = 0, vis_class= PseudoColor; | 446 int cnt = 0, vis_class = PseudoColor; |
449 XVisualInfo vinfo; | 447 XVisualInfo vinfo; |
450 char *res, *str = (char*)value.addr; | 448 char *res, *str = (char*)value.addr; |
451 | 449 |
452 if (strncmp(str, "StaticGray", 10) == 0) cnt = 10, vis_class = StaticGray; | 450 #define CHECK_VIS_CLASS(class) \ |
453 else if (strncmp(str, "StaticColor", 11) == 0) cnt = 11, vis_class = StaticColor; | 451 else if (strncmp (str, #class, sizeof (#class) - 1) == 0) \ |
454 else if (strncmp(str, "TrueColor", 9) == 0) cnt = 9, vis_class = TrueColor; | 452 cnt = sizeof (#class) - 1, vis_class = class |
455 else if (strncmp(str, "GrayScale", 9) == 0) cnt = 9, vis_class = GrayScale; | 453 |
456 else if (strncmp(str, "PseudoColor", 11) == 0) cnt = 11, vis_class = PseudoColor; | 454 if (1) |
457 else if (strncmp(str, "DirectColor", 11) == 0) cnt = 11, vis_class = DirectColor; | 455 ; |
456 CHECK_VIS_CLASS (StaticGray); | |
457 CHECK_VIS_CLASS (StaticColor); | |
458 CHECK_VIS_CLASS (TrueColor); | |
459 CHECK_VIS_CLASS (GrayScale); | |
460 CHECK_VIS_CLASS (PseudoColor); | |
461 CHECK_VIS_CLASS (DirectColor); | |
462 | |
458 if (cnt) | 463 if (cnt) |
459 { | 464 { |
460 res = str + cnt; | 465 res = str + cnt; |
461 depth = atoi(res); | 466 depth = atoi (res); |
462 if (depth == 0) | 467 if (depth == 0) |
463 { | 468 { |
464 stderr_out("Invalid Depth specification in %s... ignoring...\n",(char*)str); | 469 stderr_out ("Invalid Depth specification in %s... ignoring...\n", str); |
465 } | 470 } |
466 else | 471 else |
467 { | 472 { |
468 if (XMatchVisualInfo(dpy, screen, depth, vis_class, &vinfo)) | 473 if (XMatchVisualInfo (dpy, screen, depth, vis_class, &vinfo)) |
469 { | 474 { |
470 visual = vinfo.visual; | 475 visual = vinfo.visual; |
471 } | 476 } |
472 else | 477 else |
473 { | 478 { |
474 stderr_out("Can't match the requested visual %s... using defaults\n",str); | 479 stderr_out ("Can't match the requested visual %s... using defaults\n", str); |
475 } | 480 } |
476 } | 481 } |
477 } | 482 } |
478 else | 483 else |
479 { | 484 { |
480 stderr_out("Invalid Visual specification in %s... ignoring.\n",(char*)str); | 485 stderr_out( "Invalid Visual specification in %s... ignoring.\n", str); |
481 } | 486 } |
482 } | 487 } |
483 if (visual == NULL) | 488 if (visual == NULL) |
484 { | 489 { |
485 visual = DefaultVisual(dpy, screen); | 490 visual = DefaultVisual (dpy, screen); |
486 depth = DefaultDepth(dpy, screen); | 491 depth = DefaultDepth (dpy, screen); |
487 } | 492 } |
488 | 493 |
489 /* If we've got the same visual as the default and it's PseudoColor, | 494 /* If we've got the same visual as the default and it's PseudoColor, |
490 check to see if the user specified that we need a private colormap */ | 495 check to see if the user specified that we need a private colormap */ |
491 if (visual == DefaultVisual(dpy, screen)) | 496 if (visual == DefaultVisual (dpy, screen)) |
492 { | 497 { |
493 sprintf (buf1, "%s.privateColormap", app_name); | 498 sprintf (buf1, "%s.privateColormap", app_name); |
494 sprintf (buf2, "%s.PrivateColormap", app_class); | 499 sprintf (buf2, "%s.PrivateColormap", app_class); |
495 if ((visual->class == PseudoColor) && | 500 if ((visual->class == PseudoColor) && |
496 (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)) | 501 (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)) |
497 { | 502 { |
498 cmap = XCopyColormapAndFree(dpy, DefaultColormap(dpy, screen)); | 503 cmap = XCopyColormapAndFree (dpy, DefaultColormap (dpy, screen)); |
499 } | 504 } |
500 else | 505 else |
501 { | 506 { |
502 cmap = DefaultColormap(dpy, screen); | 507 cmap = DefaultColormap (dpy, screen); |
503 } | 508 } |
504 } | 509 } |
505 else | 510 else |
506 { | 511 { |
507 /* We have to create a matching colormap anyway... | 512 /* We have to create a matching colormap anyway... |
508 ### think about using standard colormaps (need the Xmu libs?) */ | 513 ### think about using standard colormaps (need the Xmu libs?) */ |
509 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone); | 514 cmap = XCreateColormap (dpy, RootWindow(dpy, screen), visual, AllocNone); |
510 XInstallColormap(dpy, cmap); | 515 XInstallColormap (dpy, cmap); |
511 } | 516 } |
512 } | 517 } |
513 XtSetArg(xargs[numargs],XtNvisual, visual); numargs++; | 518 |
514 XtSetArg(xargs[numargs],XtNdepth, depth); numargs++; | 519 DEVICE_X_VISUAL (d) = visual; |
515 XtSetArg(xargs[numargs],XtNcolormap, cmap); numargs++; | |
516 DEVICE_X_VISUAL (d) = visual; | |
517 DEVICE_X_COLORMAP (d) = cmap; | 520 DEVICE_X_COLORMAP (d) = cmap; |
518 DEVICE_X_DEPTH (d) = depth; | 521 DEVICE_X_DEPTH (d) = depth; |
519 | |
520 validify_resource_component ((char *) XSTRING_DATA (DEVICE_NAME (d)), | 522 validify_resource_component ((char *) XSTRING_DATA (DEVICE_NAME (d)), |
521 XSTRING_LENGTH (DEVICE_NAME (d))); | 523 XSTRING_LENGTH (DEVICE_NAME (d))); |
522 app_shell = XtAppCreateShell (NULL, app_class, | 524 |
523 applicationShellWidgetClass, | 525 { |
524 dpy, xargs, numargs); | 526 Arg al[3]; |
527 XtSetArg (al[0], XtNvisual, visual); | |
528 XtSetArg (al[1], XtNdepth, depth); | |
529 XtSetArg (al[2], XtNcolormap, cmap); | |
530 | |
531 app_shell = XtAppCreateShell (NULL, app_class, | |
532 applicationShellWidgetClass, | |
533 dpy, al, countof (al)); | |
534 } | |
525 | 535 |
526 DEVICE_XT_APP_SHELL (d) = app_shell; | 536 DEVICE_XT_APP_SHELL (d) = app_shell; |
537 | |
527 #ifdef HAVE_XIM | 538 #ifdef HAVE_XIM |
528 XIM_init_device(d); | 539 XIM_init_device(d); |
529 #endif /* HAVE_XIM */ | 540 #endif /* HAVE_XIM */ |
530 | 541 |
531 /* Realize the app_shell so that its window exists for GC creation purposes, | 542 /* Realize the app_shell so that its window exists for GC creation purposes, |
532 and set it to the size of the root window for child placement purposes */ | 543 and set it to the size of the root window for child placement purposes */ |
533 { | 544 { |
534 Screen *scrn = ScreenOfDisplay(dpy, screen); | 545 Arg al[5]; |
535 int screen_width, screen_height; | 546 XtSetArg (al[0], XtNmappedWhenManaged, False); |
536 screen_width = WidthOfScreen(scrn); | 547 XtSetArg (al[1], XtNx, 0); |
537 screen_height = HeightOfScreen(scrn); | 548 XtSetArg (al[2], XtNy, 0); |
538 numargs = 0; | 549 XtSetArg (al[3], XtNwidth, WidthOfScreen (ScreenOfDisplay (dpy, screen))); |
539 XtSetArg (xargs[numargs], XtNmappedWhenManaged, False); numargs++; | 550 XtSetArg (al[4], XtNheight, HeightOfScreen (ScreenOfDisplay (dpy, screen))); |
540 XtSetArg (xargs[numargs], XtNx, 0); numargs++; | 551 XtSetValues (app_shell, al, countof (al)); |
541 XtSetArg (xargs[numargs], XtNy, 0); numargs++; | |
542 XtSetArg (xargs[numargs], XtNwidth, screen_width); numargs++; | |
543 XtSetArg (xargs[numargs], XtNheight, screen_height); numargs++; | |
544 XtSetValues (app_shell, xargs, numargs); | |
545 XtRealizeWidget (app_shell); | 552 XtRealizeWidget (app_shell); |
546 } | 553 } |
554 | |
547 #ifdef HAVE_SESSION | 555 #ifdef HAVE_SESSION |
548 { | 556 { |
549 int new_argc; | 557 int new_argc; |
550 char **new_argv; | 558 char **new_argv; |
551 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv); | 559 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv); |
591 } | 599 } |
592 | 600 |
593 static void | 601 static void |
594 x_mark_device (struct device *d, void (*markobj) (Lisp_Object)) | 602 x_mark_device (struct device *d, void (*markobj) (Lisp_Object)) |
595 { | 603 { |
596 ((markobj) (DEVICE_X_WM_COMMAND_FRAME (d))); | 604 markobj (DEVICE_X_WM_COMMAND_FRAME (d)); |
597 ((markobj) (DEVICE_X_DATA (d)->x_keysym_map_hashtable)); | 605 markobj (DEVICE_X_DATA (d)->x_keysym_map_hash_table); |
598 } | 606 } |
599 | 607 |
600 | 608 |
601 /************************************************************************/ | 609 /************************************************************************/ |
602 /* closing an X connection */ | 610 /* closing an X connection */ |
634 free_gc_cache (DEVICE_X_GC_CACHE (d)); | 642 free_gc_cache (DEVICE_X_GC_CACHE (d)); |
635 if (DEVICE_X_DATA (d)->x_modifier_keymap) | 643 if (DEVICE_X_DATA (d)->x_modifier_keymap) |
636 XFreeModifiermap (DEVICE_X_DATA (d)->x_modifier_keymap); | 644 XFreeModifiermap (DEVICE_X_DATA (d)->x_modifier_keymap); |
637 if (DEVICE_X_DATA (d)->x_keysym_map) | 645 if (DEVICE_X_DATA (d)->x_keysym_map) |
638 XFree ((char *) DEVICE_X_DATA (d)->x_keysym_map); | 646 XFree ((char *) DEVICE_X_DATA (d)->x_keysym_map); |
647 | |
648 if (DEVICE_XT_APP_SHELL (d)) | |
649 { | |
650 XtDestroyWidget (DEVICE_XT_APP_SHELL (d)); | |
651 DEVICE_XT_APP_SHELL (d) = NULL; | |
652 } | |
639 | 653 |
640 XtCloseDisplay (display); | 654 XtCloseDisplay (display); |
641 DEVICE_X_DISPLAY (d) = 0; | 655 DEVICE_X_DISPLAY (d) = 0; |
642 #ifdef FREE_CHECKING | 656 #ifdef FREE_CHECKING |
643 if (checking_free) | 657 if (checking_free) |
913 if (d) | 927 if (d) |
914 enqueue_magic_eval_event (io_error_delete_device, dev); | 928 enqueue_magic_eval_event (io_error_delete_device, dev); |
915 DEVICE_X_BEING_DELETED (d) = 1; | 929 DEVICE_X_BEING_DELETED (d) = 1; |
916 Fthrow (Qtop_level, Qnil); | 930 Fthrow (Qtop_level, Qnil); |
917 | 931 |
918 RETURN_NOT_REACHED (0); | 932 return 0; /* not reached */ |
919 } | 933 } |
920 | 934 |
921 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /* | 935 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /* |
922 With a true arg, make the connection to the X server synchronous. | 936 With a true arg, make the connection to the X server synchronous. |
923 With false, make it asynchronous. Synchronous connections are much slower, | 937 With false, make it asynchronous. Synchronous connections are much slower, |
1446 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext); | 1460 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext); |
1447 | 1461 |
1448 return XStringToKeysym (keysym_ext) ? Qt : Qnil; | 1462 return XStringToKeysym (keysym_ext) ? Qt : Qnil; |
1449 } | 1463 } |
1450 | 1464 |
1451 DEFUN ("x-keysym-hashtable", Fx_keysym_hashtable, 0, 1, 0, /* | 1465 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* |
1452 Return a hashtable which contains a hash key for all keysyms which | 1466 Return a hash table which contains a hash key for all keysyms which |
1453 name keys on the keyboard. See `x-keysym-on-keyboard-p'. | 1467 name keys on the keyboard. See `x-keysym-on-keyboard-p'. |
1454 */ | 1468 */ |
1455 (device)) | 1469 (device)) |
1456 { | 1470 { |
1457 struct device *d = decode_device (device); | 1471 struct device *d = decode_device (device); |
1458 if (!DEVICE_X_P (d)) | 1472 if (!DEVICE_X_P (d)) |
1459 signal_simple_error ("Not an X device", device); | 1473 signal_simple_error ("Not an X device", device); |
1460 | 1474 |
1461 return DEVICE_X_DATA (d)->x_keysym_map_hashtable; | 1475 return DEVICE_X_DATA (d)->x_keysym_map_hash_table; |
1462 } | 1476 } |
1463 | 1477 |
1464 DEFUN ("x-keysym-on-keyboard-sans-modifiers-p", Fx_keysym_on_keyboard_sans_modifiers_p, | 1478 DEFUN ("x-keysym-on-keyboard-sans-modifiers-p", Fx_keysym_on_keyboard_sans_modifiers_p, |
1465 1, 2, 0, /* | 1479 1, 2, 0, /* |
1466 Return true if KEYSYM names a key on the keyboard of DEVICE. | 1480 Return true if KEYSYM names a key on the keyboard of DEVICE. |
1478 struct device *d = decode_device (device); | 1492 struct device *d = decode_device (device); |
1479 if (!DEVICE_X_P (d)) | 1493 if (!DEVICE_X_P (d)) |
1480 signal_simple_error ("Not an X device", device); | 1494 signal_simple_error ("Not an X device", device); |
1481 | 1495 |
1482 return (EQ (Qsans_modifiers, | 1496 return (EQ (Qsans_modifiers, |
1483 Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASHTABLE (d), Qnil)) ? | 1497 Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil)) ? |
1484 Qt : Qnil); | 1498 Qt : Qnil); |
1485 } | 1499 } |
1486 | 1500 |
1487 | 1501 |
1488 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /* | 1502 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /* |
1500 { | 1514 { |
1501 struct device *d = decode_device (device); | 1515 struct device *d = decode_device (device); |
1502 if (!DEVICE_X_P (d)) | 1516 if (!DEVICE_X_P (d)) |
1503 signal_simple_error ("Not an X device", device); | 1517 signal_simple_error ("Not an X device", device); |
1504 | 1518 |
1505 return (NILP (Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASHTABLE (d), Qnil)) ? | 1519 return (NILP (Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil)) ? |
1506 Qnil : Qt); | 1520 Qnil : Qt); |
1507 } | 1521 } |
1508 | 1522 |
1509 | 1523 |
1510 /************************************************************************/ | 1524 /************************************************************************/ |
1652 DEFSUBR (Fx_display_visual_class); | 1666 DEFSUBR (Fx_display_visual_class); |
1653 DEFSUBR (Fx_display_visual_depth); | 1667 DEFSUBR (Fx_display_visual_depth); |
1654 DEFSUBR (Fx_server_vendor); | 1668 DEFSUBR (Fx_server_vendor); |
1655 DEFSUBR (Fx_server_version); | 1669 DEFSUBR (Fx_server_version); |
1656 DEFSUBR (Fx_valid_keysym_name_p); | 1670 DEFSUBR (Fx_valid_keysym_name_p); |
1657 DEFSUBR (Fx_keysym_hashtable); | 1671 DEFSUBR (Fx_keysym_hash_table); |
1658 DEFSUBR (Fx_keysym_on_keyboard_p); | 1672 DEFSUBR (Fx_keysym_on_keyboard_p); |
1659 DEFSUBR (Fx_keysym_on_keyboard_sans_modifiers_p); | 1673 DEFSUBR (Fx_keysym_on_keyboard_sans_modifiers_p); |
1660 | 1674 |
1661 DEFSUBR (Fx_grab_pointer); | 1675 DEFSUBR (Fx_grab_pointer); |
1662 DEFSUBR (Fx_ungrab_pointer); | 1676 DEFSUBR (Fx_ungrab_pointer); |