diff options
| author | Karl Heuer | 1995-05-25 16:00:51 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-05-25 16:00:51 +0000 |
| commit | b7975ee4094cc2b2e7b2df4833294b63c3ee9608 (patch) | |
| tree | 8da7a2a3368875cfd380510761b60f9d7daf34df /src | |
| parent | b212bc895d4b7d911e0b16921905cb531d57fa14 (diff) | |
| download | emacs-b7975ee4094cc2b2e7b2df4833294b63c3ee9608.tar.gz emacs-b7975ee4094cc2b2e7b2df4833294b63c3ee9608.zip | |
(Fx_get_resource): Major rewrite to make it clearer.
(validate_x_resource_name): Use build_string, not make_string.
(Fx_create_frame): Initially use Vinvocation_name as resource name.
Switch to frame name if frame name is explicit.
(x_display_info_for_name, Fx_open_connection): Add casts.
Initially use Vinvocation_name as resource name.
[USE_X_TOOLKIT] (x_window): Use Vx_resource_name for widget names.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 106 |
1 files changed, 60 insertions, 46 deletions
diff --git a/src/xfns.c b/src/xfns.c index e2b5a9f33f1..80df224b81a 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -1789,7 +1789,9 @@ x_set_scroll_bar_width (f, arg, oldval) | |||
| 1789 | 1789 | ||
| 1790 | /* Subroutines of creating an X frame. */ | 1790 | /* Subroutines of creating an X frame. */ |
| 1791 | 1791 | ||
| 1792 | /* Make sure that Vx_resource_name is set to a reasonable value. */ | 1792 | /* Make sure that Vx_resource_name is set to a reasonable value. |
| 1793 | Fix it up, or set it to `emacs' if it is too hopeless. */ | ||
| 1794 | |||
| 1793 | static void | 1795 | static void |
| 1794 | validate_x_resource_name () | 1796 | validate_x_resource_name () |
| 1795 | { | 1797 | { |
| @@ -1834,7 +1836,7 @@ validate_x_resource_name () | |||
| 1834 | if (good_count == 0 | 1836 | if (good_count == 0 |
| 1835 | || (good_count == 1 && bad_count > 0)) | 1837 | || (good_count == 1 && bad_count > 0)) |
| 1836 | { | 1838 | { |
| 1837 | Vx_resource_name = make_string ("emacs", 5); | 1839 | Vx_resource_name = build_string ("emacs"); |
| 1838 | return; | 1840 | return; |
| 1839 | } | 1841 | } |
| 1840 | 1842 | ||
| @@ -1873,7 +1875,6 @@ and the class is `Emacs.CLASS.SUBCLASS'.") | |||
| 1873 | register char *value; | 1875 | register char *value; |
| 1874 | char *name_key; | 1876 | char *name_key; |
| 1875 | char *class_key; | 1877 | char *class_key; |
| 1876 | Lisp_Object resname; | ||
| 1877 | 1878 | ||
| 1878 | check_x (); | 1879 | check_x (); |
| 1879 | 1880 | ||
| @@ -1888,48 +1889,41 @@ and the class is `Emacs.CLASS.SUBCLASS'.") | |||
| 1888 | error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither"); | 1889 | error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither"); |
| 1889 | 1890 | ||
| 1890 | validate_x_resource_name (); | 1891 | validate_x_resource_name (); |
| 1891 | resname = Vx_resource_name; | ||
| 1892 | 1892 | ||
| 1893 | if (NILP (component)) | 1893 | /* Allocate space for the components, the dots which separate them, |
| 1894 | { | 1894 | and the final '\0'. Make them big enough for the worst case. */ |
| 1895 | /* Allocate space for the components, the dots which separate them, | 1895 | name_key = (char *) alloca (XSTRING (Vx_resource_name)->size |
| 1896 | and the final '\0'. */ | 1896 | + (STRINGP (component) |
| 1897 | name_key = (char *) alloca (XSTRING (resname)->size | 1897 | ? XSTRING (component)->size : 0) |
| 1898 | + XSTRING (attribute)->size | 1898 | + XSTRING (attribute)->size |
| 1899 | + 2); | 1899 | + 3); |
| 1900 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 1900 | |
| 1901 | + XSTRING (class)->size | 1901 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) |
| 1902 | + 2); | 1902 | + XSTRING (class)->size |
| 1903 | 1903 | + (STRINGP (subclass) | |
| 1904 | sprintf (name_key, "%s.%s", | 1904 | ? XSTRING (subclass)->size : 0) |
| 1905 | XSTRING (resname)->data, | 1905 | + 3); |
| 1906 | XSTRING (attribute)->data); | 1906 | |
| 1907 | sprintf (class_key, "%s.%s", | 1907 | /* Start with emacs.FRAMENAME for the name (the specific one) |
| 1908 | EMACS_CLASS, | 1908 | and with `Emacs' for the class key (the general one). */ |
| 1909 | XSTRING (class)->data); | 1909 | strcpy (name_key, XSTRING (Vx_resource_name)->data); |
| 1910 | } | 1910 | strcpy (class_key, EMACS_CLASS); |
| 1911 | else | 1911 | |
| 1912 | strcat (class_key, "."); | ||
| 1913 | strcat (class_key, XSTRING (class)->data); | ||
| 1914 | |||
| 1915 | if (!NILP (component)) | ||
| 1912 | { | 1916 | { |
| 1913 | name_key = (char *) alloca (XSTRING (resname)->size | 1917 | strcat (class_key, "."); |
| 1914 | + XSTRING (component)->size | 1918 | strcat (class_key, XSTRING (subclass)->data); |
| 1915 | + XSTRING (attribute)->size | 1919 | |
| 1916 | + 3); | 1920 | strcat (name_key, "."); |
| 1917 | 1921 | strcat (name_key, XSTRING (component)->data); | |
| 1918 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | ||
| 1919 | + XSTRING (class)->size | ||
| 1920 | + XSTRING (subclass)->size | ||
| 1921 | + 3); | ||
| 1922 | |||
| 1923 | sprintf (name_key, "%s.%s.%s", | ||
| 1924 | XSTRING (resname)->data, | ||
| 1925 | XSTRING (component)->data, | ||
| 1926 | XSTRING (attribute)->data); | ||
| 1927 | sprintf (class_key, "%s.%s.%s", | ||
| 1928 | EMACS_CLASS, | ||
| 1929 | XSTRING (class)->data, | ||
| 1930 | XSTRING (subclass)->data); | ||
| 1931 | } | 1922 | } |
| 1932 | 1923 | ||
| 1924 | strcat (name_key, "."); | ||
| 1925 | strcat (name_key, XSTRING (attribute)->data); | ||
| 1926 | |||
| 1933 | value = x_get_string_resource (check_x_display_info (Qnil)->xrdb, | 1927 | value = x_get_string_resource (check_x_display_info (Qnil)->xrdb, |
| 1934 | name_key, class_key); | 1928 | name_key, class_key); |
| 1935 | 1929 | ||
| @@ -2362,10 +2356,15 @@ x_window (f, window_prompting, minibuffer_only) | |||
| 2362 | 2356 | ||
| 2363 | BLOCK_INPUT; | 2357 | BLOCK_INPUT; |
| 2364 | 2358 | ||
| 2359 | /* Use the resource name as the top-level widget name | ||
| 2360 | for looking up resources. Make a non-Lisp copy | ||
| 2361 | for the window manager, so GC relocation won't bother it. | ||
| 2362 | |||
| 2363 | Elsewhere we specify the window name for the window manager. */ | ||
| 2364 | |||
| 2365 | { | 2365 | { |
| 2366 | char *str | 2366 | char *str = (char *) XSTRING (Vx_resource_name)->data; |
| 2367 | = (STRINGP (f->name) ? (char *)XSTRING (f->name)->data : "emacs"); | 2367 | f->namebuf = (char *) xmalloc (strlen (str) + 1); |
| 2368 | f->namebuf = (char *) xrealloc (f->namebuf, strlen (str) + 1); | ||
| 2369 | strcpy (f->namebuf, str); | 2368 | strcpy (f->namebuf, str); |
| 2370 | } | 2369 | } |
| 2371 | 2370 | ||
| @@ -2472,6 +2471,7 @@ x_window (f, window_prompting, minibuffer_only) | |||
| 2472 | FRAME_X_WINDOW (f) = XtWindow (frame_widget); | 2471 | FRAME_X_WINDOW (f) = XtWindow (frame_widget); |
| 2473 | 2472 | ||
| 2474 | validate_x_resource_name (); | 2473 | validate_x_resource_name (); |
| 2474 | |||
| 2475 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; | 2475 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; |
| 2476 | class_hints.res_class = EMACS_CLASS; | 2476 | class_hints.res_class = EMACS_CLASS; |
| 2477 | XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); | 2477 | XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); |
| @@ -2565,6 +2565,7 @@ x_window (f) | |||
| 2565 | attribute_mask, &attributes); | 2565 | attribute_mask, &attributes); |
| 2566 | 2566 | ||
| 2567 | validate_x_resource_name (); | 2567 | validate_x_resource_name (); |
| 2568 | |||
| 2568 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; | 2569 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; |
| 2569 | class_hints.res_class = EMACS_CLASS; | 2570 | class_hints.res_class = EMACS_CLASS; |
| 2570 | XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); | 2571 | XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); |
| @@ -2756,6 +2757,10 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 2756 | 2757 | ||
| 2757 | check_x (); | 2758 | check_x (); |
| 2758 | 2759 | ||
| 2760 | /* Use this general default value to start with | ||
| 2761 | until we know if this frame has a specified name. */ | ||
| 2762 | Vx_resource_name = Vinvocation_name; | ||
| 2763 | |||
| 2759 | display = x_get_arg (parms, Qdisplay, 0, 0, 0); | 2764 | display = x_get_arg (parms, Qdisplay, 0, 0, 0); |
| 2760 | if (EQ (display, Qunbound)) | 2765 | if (EQ (display, Qunbound)) |
| 2761 | display = Qnil; | 2766 | display = Qnil; |
| @@ -2772,6 +2777,9 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 2772 | && ! NILP (name)) | 2777 | && ! NILP (name)) |
| 2773 | error ("Invalid frame name--not a string or nil"); | 2778 | error ("Invalid frame name--not a string or nil"); |
| 2774 | 2779 | ||
| 2780 | if (STRINGP (name)) | ||
| 2781 | Vx_resource_name = name; | ||
| 2782 | |||
| 2775 | /* See if parent window is specified. */ | 2783 | /* See if parent window is specified. */ |
| 2776 | parent = x_get_arg (parms, Qparent_id, NULL, NULL, number); | 2784 | parent = x_get_arg (parms, Qparent_id, NULL, NULL, number); |
| 2777 | if (EQ (parent, Qunbound)) | 2785 | if (EQ (parent, Qunbound)) |
| @@ -4559,10 +4567,13 @@ x_display_info_for_name (name) | |||
| 4559 | return dpyinfo; | 4567 | return dpyinfo; |
| 4560 | } | 4568 | } |
| 4561 | 4569 | ||
| 4570 | /* Use this general default value to start with. */ | ||
| 4571 | Vx_resource_name = Vinvocation_name; | ||
| 4572 | |||
| 4562 | validate_x_resource_name (); | 4573 | validate_x_resource_name (); |
| 4563 | 4574 | ||
| 4564 | dpyinfo = x_term_init (name, (unsigned char *)0, | 4575 | dpyinfo = x_term_init (name, (unsigned char *)0, |
| 4565 | XSTRING (Vx_resource_name)->data); | 4576 | (char *) XSTRING (Vx_resource_name)->data); |
| 4566 | 4577 | ||
| 4567 | if (dpyinfo == 0) | 4578 | if (dpyinfo == 0) |
| 4568 | error ("X server %s not responding", XSTRING (name)->data); | 4579 | error ("X server %s not responding", XSTRING (name)->data); |
| @@ -4595,12 +4606,15 @@ terminate Emacs if we can't open the connection.") | |||
| 4595 | else | 4606 | else |
| 4596 | xrm_option = (unsigned char *) 0; | 4607 | xrm_option = (unsigned char *) 0; |
| 4597 | 4608 | ||
| 4609 | /* Use this general default value to start with. */ | ||
| 4610 | Vx_resource_name = Vinvocation_name; | ||
| 4611 | |||
| 4598 | validate_x_resource_name (); | 4612 | validate_x_resource_name (); |
| 4599 | 4613 | ||
| 4600 | /* This is what opens the connection and sets x_current_display. | 4614 | /* This is what opens the connection and sets x_current_display. |
| 4601 | This also initializes many symbols, such as those used for input. */ | 4615 | This also initializes many symbols, such as those used for input. */ |
| 4602 | dpyinfo = x_term_init (display, xrm_option, | 4616 | dpyinfo = x_term_init (display, xrm_option, |
| 4603 | XSTRING (Vx_resource_name)->data); | 4617 | (char *) XSTRING (Vx_resource_name)->data); |
| 4604 | 4618 | ||
| 4605 | if (dpyinfo == 0) | 4619 | if (dpyinfo == 0) |
| 4606 | { | 4620 | { |