Mercurial > hg > xemacs-beta
comparison src/event-Xt.c @ 219:262b8bb4a523 r20-4b8
Import from CVS: tag r20-4b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:09:35 +0200 |
parents | 78478c60bfcd |
children | 157b30c96d03 |
comparison
equal
deleted
inserted
replaced
218:c9f226976f56 | 219:262b8bb4a523 |
---|---|
46 | 46 |
47 #include "xintrinsicp.h" /* CoreP.h needs this */ | 47 #include "xintrinsicp.h" /* CoreP.h needs this */ |
48 #include <X11/CoreP.h> /* Numerous places access the fields of | 48 #include <X11/CoreP.h> /* Numerous places access the fields of |
49 a core widget directly. We could | 49 a core widget directly. We could |
50 use XtGetValues(), but ... */ | 50 use XtGetValues(), but ... */ |
51 #include <X11/ShellP.h> | |
52 | |
51 #ifdef HAVE_XIM | 53 #ifdef HAVE_XIM |
52 #ifdef XIM_MOTIF | 54 #ifdef XIM_MOTIF |
53 #include <Xm/Xm.h> | 55 #include <Xm/Xm.h> |
54 #endif | 56 #endif |
55 #include "lstream.h" | 57 #include "lstream.h" |
2660 toVal->addr = (XPointer)&static_val; \ | 2662 toVal->addr = (XPointer)&static_val; \ |
2661 } \ | 2663 } \ |
2662 toVal->size = sizeof(type); \ | 2664 toVal->size = sizeof(type); \ |
2663 return True /* Caller supplies `;' */ | 2665 return True /* Caller supplies `;' */ |
2664 | 2666 |
2667 /* JH: We use this because I think there's a possibility this | |
2668 is called before the device is properly set up, in which case | |
2669 I don't want to abort. */ | |
2670 extern struct device *get_device_from_display_1 (Display *dpy); | |
2671 | |
2665 static | 2672 static |
2666 Boolean EmacsXtCvtStringToPixel ( | 2673 Boolean EmacsXtCvtStringToPixel ( |
2667 Display *dpy, | 2674 Display *dpy, |
2668 XrmValuePtr args, | 2675 XrmValuePtr args, |
2669 Cardinal *num_args, | 2676 Cardinal *num_args, |
2672 XtPointer *closure_ret) | 2679 XtPointer *closure_ret) |
2673 { | 2680 { |
2674 String str = (String)fromVal->addr; | 2681 String str = (String)fromVal->addr; |
2675 XColor screenColor; | 2682 XColor screenColor; |
2676 XColor exactColor; | 2683 XColor exactColor; |
2677 Screen *screen; | 2684 Screen *screen; |
2678 Colormap colormap; | 2685 Colormap colormap; |
2686 Visual *visual; | |
2687 struct device *d; | |
2679 Status status; | 2688 Status status; |
2680 String params[1]; | 2689 String params[1]; |
2681 Cardinal num_params = 1; | 2690 Cardinal num_params = 1; |
2682 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); | 2691 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); |
2683 | 2692 |
2708 /* if (pd->rv) done(Pixel, WhitePixelOfScreen(screen)) else */ | 2717 /* if (pd->rv) done(Pixel, WhitePixelOfScreen(screen)) else */ |
2709 done(Pixel, BlackPixelOfScreen(screen)); | 2718 done(Pixel, BlackPixelOfScreen(screen)); |
2710 } | 2719 } |
2711 | 2720 |
2712 /* Originally called XAllocNamedColor() here. */ | 2721 /* Originally called XAllocNamedColor() here. */ |
2713 status = XParseColor (DisplayOfScreen(screen), colormap, (char*)str, | 2722 if ((d = get_device_from_display_1(dpy))) { |
2714 &screenColor); | 2723 visual = DEVICE_X_VISUAL(d); |
2715 if (status) { | 2724 if (colormap != DEVICE_X_COLORMAP(d)) { |
2716 status = allocate_nearest_color (DisplayOfScreen(screen), colormap, | 2725 XtAppWarningMsg(the_app_con, "wierdColormap", "cvtStringToPixel", |
2717 &screenColor); | 2726 "XtToolkitWarning", |
2727 "The colormap passed to cvtStringToPixel doesn't match the one registerd to the device.\n", | |
2728 NULL, 0); | |
2729 status = XAllocNamedColor(dpy, colormap, (char*)str, &screenColor, &exactColor); | |
2730 } else { | |
2731 status = XParseColor (dpy, colormap, (char*)str, &screenColor); | |
2732 if (status) { | |
2733 status = allocate_nearest_color (dpy, colormap, visual, &screenColor); | |
2734 } | |
2735 } | |
2736 } else { | |
2737 /* We haven't set up this device totally yet, so just punt */ | |
2738 status = XAllocNamedColor(dpy, colormap, (char*)str, &screenColor, &exactColor); | |
2718 } | 2739 } |
2719 | |
2720 if (status == 0) { | 2740 if (status == 0) { |
2721 params[0] = str; | 2741 params[0] = str; |
2722 /* Server returns a specific error code but Xlib discards it. Ugh */ | 2742 /* Server returns a specific error code but Xlib discards it. Ugh */ |
2723 if (XLookupColor(DisplayOfScreen(screen), colormap, (char*) str, | 2743 if (XLookupColor(DisplayOfScreen(screen), colormap, (char*) str, |
2724 &exactColor, &screenColor)) { | 2744 &exactColor, &screenColor)) { |
2827 the_Xt_timeout_blocktype = Blocktype_new (struct Xt_timeout_blocktype); | 2847 the_Xt_timeout_blocktype = Blocktype_new (struct Xt_timeout_blocktype); |
2828 | 2848 |
2829 last_quit_check_signal_tick_count = 0; | 2849 last_quit_check_signal_tick_count = 0; |
2830 } | 2850 } |
2831 | 2851 |
2852 /* This mess is a hack that patches the shell widget to treat visual inheritance | |
2853 the same as colormap and depth inheritance */ | |
2854 | |
2855 static XtInitProc orig_shell_init_proc; | |
2856 | |
2857 static void ShellVisualPatch(Widget wanted, Widget new, | |
2858 ArgList args, Cardinal *num_args) | |
2859 { | |
2860 Widget p; | |
2861 ShellWidget w = (ShellWidget) new; | |
2862 | |
2863 /* first, call the original setup */ | |
2864 (*orig_shell_init_proc)(wanted, new, args, num_args); | |
2865 | |
2866 /* if the visual isn't explicitly set, grab it from the nearest shell ancestor */ | |
2867 if (w->shell.visual == CopyFromParent) { | |
2868 p = XtParent(w); | |
2869 while (p && !XtIsShell(p)) p = XtParent(p); | |
2870 if (p) w->shell.visual = ((ShellWidget)p)->shell.visual; | |
2871 } | |
2872 } | |
2873 | |
2832 void | 2874 void |
2833 init_event_Xt_late (void) /* called when already initialized */ | 2875 init_event_Xt_late (void) /* called when already initialized */ |
2834 { | 2876 { |
2835 timeout_id_tick = 1; | 2877 timeout_id_tick = 1; |
2836 pending_timeouts = 0; | 2878 pending_timeouts = 0; |
2867 EmacsXtCvtStringToXIMStyles, | 2909 EmacsXtCvtStringToXIMStyles, |
2868 NULL, 0, | 2910 NULL, 0, |
2869 XtCacheByDisplay, EmacsFreeXIMStyles); | 2911 XtCacheByDisplay, EmacsFreeXIMStyles); |
2870 #endif /* XIM_XLIB */ | 2912 #endif /* XIM_XLIB */ |
2871 | 2913 |
2872 } | 2914 /* insert the visual inheritance patch/hack described above */ |
2915 orig_shell_init_proc = shellClassRec.core_class.initialize; | |
2916 shellClassRec.core_class.initialize = ShellVisualPatch; | |
2917 | |
2918 } |