diff options
| author | Jim Blandy | 1991-08-16 16:09:27 +0000 |
|---|---|---|
| committer | Jim Blandy | 1991-08-16 16:09:27 +0000 |
| commit | 60fb3ee151af0f5b797fca0a1ce5475373622e85 (patch) | |
| tree | 1a4cdd5723f85226943b032a2889ee4b23ab640d /src | |
| parent | 4d6cebd8752bff9f6faaaf189303f36c072894d0 (diff) | |
| download | emacs-60fb3ee151af0f5b797fca0a1ce5475373622e85.tar.gz emacs-60fb3ee151af0f5b797fca0a1ce5475373622e85.zip | |
*** empty log message ***
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 326 | ||||
| -rw-r--r-- | src/xterm.c | 26 |
2 files changed, 155 insertions, 197 deletions
diff --git a/src/xfns.c b/src/xfns.c index 38d4293fe52..1cecae8f2b2 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -51,9 +51,10 @@ static XrmDatabase xrdb; | |||
| 51 | 51 | ||
| 52 | /* The class of Emacs screens. */ | 52 | /* The class of Emacs screens. */ |
| 53 | #define SCREEN_CLASS "Screen" | 53 | #define SCREEN_CLASS "Screen" |
| 54 | Lisp_Object screen_class; | ||
| 54 | 55 | ||
| 55 | /* Title name and application name for X stuff. */ | 56 | /* Title name and application name for X stuff. */ |
| 56 | extern char *id_name; | 57 | extern char *x_id_name; |
| 57 | extern Lisp_Object invocation_name; | 58 | extern Lisp_Object invocation_name; |
| 58 | 59 | ||
| 59 | /* The background and shape of the mouse pointer, and shape when not | 60 | /* The background and shape of the mouse pointer, and shape when not |
| @@ -1333,12 +1334,11 @@ key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".") | |||
| 1333 | if (NULL (name) != NULL (class)) | 1334 | if (NULL (name) != NULL (class)) |
| 1334 | error ("x-get-resource: must specify both NAME and CLASS or neither"); | 1335 | error ("x-get-resource: must specify both NAME and CLASS or neither"); |
| 1335 | 1336 | ||
| 1336 | name_key = (char *) alloca (XSTRING (invocation_name)->size + 1 | ||
| 1337 | + (NULL (name) ? 0 : XSTRING (name)->size + 1) | ||
| 1338 | + XSTRING (attribute)->size + 1); | ||
| 1339 | |||
| 1340 | if (NULL (name)) | 1337 | if (NULL (name)) |
| 1341 | { | 1338 | { |
| 1339 | name_key = (char *) alloca (XSTRING (invocation_name)->size + 1 | ||
| 1340 | + XSTRING (attribute)->size + 1); | ||
| 1341 | |||
| 1342 | sprintf (name_key, "%s.%s", | 1342 | sprintf (name_key, "%s.%s", |
| 1343 | XSTRING (invocation_name)->data, | 1343 | XSTRING (invocation_name)->data, |
| 1344 | XSTRING (attribute)->data); | 1344 | XSTRING (attribute)->data); |
| @@ -1346,6 +1346,10 @@ key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".") | |||
| 1346 | } | 1346 | } |
| 1347 | else | 1347 | else |
| 1348 | { | 1348 | { |
| 1349 | name_key = (char *) alloca (XSTRING (invocation_name)->size + 1 | ||
| 1350 | + XSTRING (name)->size + 1 | ||
| 1351 | + XSTRING (attribute)->size + 1); | ||
| 1352 | |||
| 1349 | class_key = (char *) alloca (sizeof (EMACS_CLASS) | 1353 | class_key = (char *) alloca (sizeof (EMACS_CLASS) |
| 1350 | + XSTRING (class)->size + 1); | 1354 | + XSTRING (class)->size + 1); |
| 1351 | 1355 | ||
| @@ -1368,12 +1372,12 @@ key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".") | |||
| 1368 | 1372 | ||
| 1369 | #else /* X10 */ | 1373 | #else /* X10 */ |
| 1370 | 1374 | ||
| 1371 | DEFUN ("x-get-default", Fx_get_default, Sx_get_default, 1, 2, 0, | 1375 | DEFUN ("x-get-default", Fx_get_default, Sx_get_default, 1, 1, 0, |
| 1372 | "Get X default ATTRIBUTE from the system, or nil if no default.\n\ | 1376 | "Get X default ATTRIBUTE from the system, or nil if no default.\n\ |
| 1373 | Value is a string (when not nil) and ATTRIBUTE is also a string.\n\ | 1377 | Value is a string (when not nil) and ATTRIBUTE is also a string.\n\ |
| 1374 | The defaults are specified in the file `~/.Xdefaults'.") | 1378 | The defaults are specified in the file `~/.Xdefaults'.") |
| 1375 | (arg, name) | 1379 | (arg) |
| 1376 | Lisp_Object arg, name; | 1380 | Lisp_Object arg; |
| 1377 | { | 1381 | { |
| 1378 | register unsigned char *value; | 1382 | register unsigned char *value; |
| 1379 | 1383 | ||
| @@ -1393,56 +1397,84 @@ The defaults are specified in the file `~/.Xdefaults'.") | |||
| 1393 | return (Qnil); | 1397 | return (Qnil); |
| 1394 | } | 1398 | } |
| 1395 | 1399 | ||
| 1396 | #define Fx_get_resource Fx_get_default | 1400 | #define Fx_get_resource(attribute, name, class) Fx_get_default(attribute) |
| 1397 | 1401 | ||
| 1398 | #endif /* X10 */ | 1402 | #endif /* X10 */ |
| 1399 | 1403 | ||
| 1404 | /* Types we might convert a resource string into. */ | ||
| 1405 | enum resource_types | ||
| 1406 | { | ||
| 1407 | number, boolean, string, | ||
| 1408 | }; | ||
| 1409 | |||
| 1400 | /* Return the value of parameter PARAM. | 1410 | /* Return the value of parameter PARAM. |
| 1401 | First search ALIST, then the X defaults database. | 1411 | |
| 1402 | If XPROPNAME starts with `#', convert the X default to an integer; | 1412 | First search ALIST, then Vdefault_screen_alist, then the X defaults |
| 1403 | otherwise, to a string. | 1413 | database, using SCREEN_NAME as the subcomponent of emacs and |
| 1404 | If no X-default is specified, return nil. */ | 1414 | ATTRIBUTE as the attribute name. |
| 1415 | |||
| 1416 | Convert the resource to the type specified by desired_type. | ||
| 1417 | |||
| 1418 | If no default is specified, return nil. */ | ||
| 1405 | 1419 | ||
| 1406 | static Lisp_Object | 1420 | static Lisp_Object |
| 1407 | x_get_arg (alist, param, screen_name, xpropname) | 1421 | x_get_arg (alist, param, screen_name, attribute, type) |
| 1408 | Lisp_Object alist, param, screen_name; | 1422 | Lisp_Object alist, param, screen_name; |
| 1409 | char *xpropname; | 1423 | char *attribute; |
| 1424 | enum resource_types type; | ||
| 1410 | { | 1425 | { |
| 1411 | register Lisp_Object tem; | 1426 | register Lisp_Object tem; |
| 1412 | 1427 | ||
| 1413 | tem = Fassq (param, alist); | 1428 | tem = Fassq (param, alist); |
| 1414 | if (EQ (tem, Qnil)) | 1429 | if (EQ (tem, Qnil)) |
| 1415 | tem = Fassq (param, Vdefault_screen_alist); | 1430 | tem = Fassq (param, Vdefault_screen_alist); |
| 1416 | if (EQ (tem, Qnil)) | 1431 | if (EQ (tem, Qnil) && attribute) |
| 1417 | { | 1432 | { |
| 1418 | if (xpropname == 0) | 1433 | Lisp_Object sterile_name; |
| 1419 | return tem; | ||
| 1420 | 1434 | ||
| 1421 | if (*xpropname == '#') | 1435 | /* Build a version of screen name that is safe to use as a |
| 1422 | { | 1436 | component name. */ |
| 1423 | tem = Fx_get_resource (build_string (xpropname + 1), | 1437 | if (XTYPE (screen_name) == Lisp_String) |
| 1424 | screen_name, SCREEN_CLASS); | 1438 | { |
| 1425 | if (EQ (tem, Qnil)) | 1439 | sterile_name = make_uninit_string (XSTRING (screen_name)->size); |
| 1426 | return Qnil; | ||
| 1427 | return make_number (atoi (XSTRING (tem)->data)); | ||
| 1428 | } | ||
| 1429 | 1440 | ||
| 1430 | if (*xpropname == '?') | 1441 | for (i = 0; i < XSTRING (sterile_name)->size; i++) |
| 1431 | { | ||
| 1432 | tem = Fx_get_resource (build_string (xpropname + 1), | ||
| 1433 | screen_name, SCREEN_CLASS); | ||
| 1434 | if (XTYPE (tem) == Lisp_String) | ||
| 1435 | { | 1442 | { |
| 1436 | tem = Fdowncase (tem); | 1443 | int c = XSTRING (screen_name)->data[i]; |
| 1437 | if (!strcmp (XSTRING (tem)->data, "on") | 1444 | if (c == ':' || c == '.' || c == '*' || isspace (c)) |
| 1438 | || !strcmp (XSTRING (tem)->data, "true")) | 1445 | c = '_'; |
| 1439 | return Qt; | 1446 | XSTRING (sterile_name)->data[i] = c; |
| 1440 | } | 1447 | } |
| 1441 | return Qnil; | 1448 | } |
| 1442 | } | 1449 | else |
| 1450 | sterile_name = Qnil; | ||
| 1443 | 1451 | ||
| 1444 | return Fx_get_resource (build_string (xpropname), | 1452 | tem = Fx_get_resource (build_string (attribute), |
| 1445 | screen_name, SCREEN_CLASS); | 1453 | sterile_name, |
| 1454 | (NULL (sterile_name) ? Qnil : screen_class)); | ||
| 1455 | |||
| 1456 | if (NULL (tem)) | ||
| 1457 | return Qnil; | ||
| 1458 | |||
| 1459 | switch (type) | ||
| 1460 | { | ||
| 1461 | case number: | ||
| 1462 | return make_number (atoi (XSTRING (tem)->data)); | ||
| 1463 | |||
| 1464 | case boolean: | ||
| 1465 | tem = Fdowncase (tem); | ||
| 1466 | if (!strcmp (XSTRING (tem)->data, "on") | ||
| 1467 | || !strcmp (XSTRING (tem)->data, "true")) | ||
| 1468 | return Qt; | ||
| 1469 | else | ||
| 1470 | return Qnil; | ||
| 1471 | |||
| 1472 | case string: | ||
| 1473 | return tem; | ||
| 1474 | |||
| 1475 | default: | ||
| 1476 | abort (); | ||
| 1477 | } | ||
| 1446 | } | 1478 | } |
| 1447 | return Fcdr (tem); | 1479 | return Fcdr (tem); |
| 1448 | } | 1480 | } |
| @@ -1454,17 +1486,18 @@ x_get_arg (alist, param, screen_name, xpropname) | |||
| 1454 | If that is not found either, use the value DEFLT. */ | 1486 | If that is not found either, use the value DEFLT. */ |
| 1455 | 1487 | ||
| 1456 | static Lisp_Object | 1488 | static Lisp_Object |
| 1457 | x_default_parameter (s, alist, propname, deflt, xprop) | 1489 | x_default_parameter (s, alist, propname, deflt, xprop, type) |
| 1458 | struct screen *s; | 1490 | struct screen *s; |
| 1459 | Lisp_Object alist; | 1491 | Lisp_Object alist; |
| 1460 | char *propname; | 1492 | char *propname; |
| 1461 | Lisp_Object deflt; | 1493 | Lisp_Object deflt; |
| 1462 | char *xprop; | 1494 | char *xprop; |
| 1495 | enum resource_types type; | ||
| 1463 | { | 1496 | { |
| 1464 | Lisp_Object propsym = intern (propname); | 1497 | Lisp_Object propsym = intern (propname); |
| 1465 | Lisp_Object tem; | 1498 | Lisp_Object tem; |
| 1466 | 1499 | ||
| 1467 | tem = x_get_arg (alist, propsym, s->name, xprop); | 1500 | tem = x_get_arg (alist, propsym, s->name, xprop, type); |
| 1468 | if (EQ (tem, Qnil)) | 1501 | if (EQ (tem, Qnil)) |
| 1469 | tem = deflt; | 1502 | tem = deflt; |
| 1470 | store_screen_param (s, propsym, tem); | 1503 | store_screen_param (s, propsym, tem); |
| @@ -1551,8 +1584,8 @@ x_figure_window_size (s, parms) | |||
| 1551 | s->display.x->top_pos = 1; | 1584 | s->display.x->top_pos = 1; |
| 1552 | s->display.x->left_pos = 1; | 1585 | s->display.x->left_pos = 1; |
| 1553 | 1586 | ||
| 1554 | tem0 = x_get_arg (parms, intern ("height"), s->name, 0); | 1587 | tem0 = x_get_arg (parms, intern ("height"), s->name, 0, 0); |
| 1555 | tem1 = x_get_arg (parms, intern ("width"), s->name, 0); | 1588 | tem1 = x_get_arg (parms, intern ("width"), s->name, 0, 0); |
| 1556 | if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil)) | 1589 | if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil)) |
| 1557 | { | 1590 | { |
| 1558 | CHECK_NUMBER (tem0, 0); | 1591 | CHECK_NUMBER (tem0, 0); |
| @@ -1569,8 +1602,8 @@ x_figure_window_size (s, parms) | |||
| 1569 | s->display.x->pixel_height = (FONT_HEIGHT (s->display.x->font) * s->height | 1602 | s->display.x->pixel_height = (FONT_HEIGHT (s->display.x->font) * s->height |
| 1570 | + 2 * s->display.x->internal_border_width); | 1603 | + 2 * s->display.x->internal_border_width); |
| 1571 | 1604 | ||
| 1572 | tem0 = x_get_arg (parms, intern ("top"), s->name, 0); | 1605 | tem0 = x_get_arg (parms, intern ("top"), s->name, 0, 0); |
| 1573 | tem1 = x_get_arg (parms, intern ("left"), s->name, 0); | 1606 | tem1 = x_get_arg (parms, intern ("left"), s->name, 0, 0); |
| 1574 | if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil)) | 1607 | if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil)) |
| 1575 | { | 1608 | { |
| 1576 | CHECK_NUMBER (tem0, 0); | 1609 | CHECK_NUMBER (tem0, 0); |
| @@ -1643,7 +1676,7 @@ x_window (s) | |||
| 1643 | screen_visual, /* set in Fx_open_connection */ | 1676 | screen_visual, /* set in Fx_open_connection */ |
| 1644 | attribute_mask, &attributes); | 1677 | attribute_mask, &attributes); |
| 1645 | 1678 | ||
| 1646 | class_hints.res_name = id_name; | 1679 | class_hints.res_name = s->name; |
| 1647 | class_hints.res_class = EMACS_CLASS; | 1680 | class_hints.res_class = EMACS_CLASS; |
| 1648 | XSetClassHint (x_current_display, s->display.x->window_desc, &class_hints); | 1681 | XSetClassHint (x_current_display, s->display.x->window_desc, &class_hints); |
| 1649 | 1682 | ||
| @@ -1669,8 +1702,8 @@ x_icon (s, parms) | |||
| 1669 | 1702 | ||
| 1670 | /* Set the position of the icon. Note that twm groups all | 1703 | /* Set the position of the icon. Note that twm groups all |
| 1671 | icons in an icon window. */ | 1704 | icons in an icon window. */ |
| 1672 | tem0 = x_get_arg (parms, intern ("icon-left"), s->name, 0); | 1705 | tem0 = x_get_arg (parms, intern ("icon-left"), s->name, 0, 0); |
| 1673 | tem1 = x_get_arg (parms, intern ("icon-top"), s->name, 0); | 1706 | tem1 = x_get_arg (parms, intern ("icon-top"), s->name, 0, 0); |
| 1674 | if (!EQ (tem0, Qnil) && !EQ (tem1, Qnil)) | 1707 | if (!EQ (tem0, Qnil) && !EQ (tem1, Qnil)) |
| 1675 | { | 1708 | { |
| 1676 | CHECK_NUMBER (tem0, 0); | 1709 | CHECK_NUMBER (tem0, 0); |
| @@ -1687,7 +1720,7 @@ x_icon (s, parms) | |||
| 1687 | } | 1720 | } |
| 1688 | 1721 | ||
| 1689 | /* Start up iconic or window? */ | 1722 | /* Start up iconic or window? */ |
| 1690 | tem0 = x_get_arg (parms, intern ("iconic-startup"), s->name, 0); | 1723 | tem0 = x_get_arg (parms, intern ("iconic-startup"), s->name, 0, 0); |
| 1691 | if (!EQ (tem0, Qnil)) | 1724 | if (!EQ (tem0, Qnil)) |
| 1692 | hints.initial_state = IconicState; | 1725 | hints.initial_state = IconicState; |
| 1693 | else | 1726 | else |
| @@ -1811,20 +1844,13 @@ be shared by the new screen.") | |||
| 1811 | if (x_current_display == 0) | 1844 | if (x_current_display == 0) |
| 1812 | error ("X windows are not in use or not initialized"); | 1845 | error ("X windows are not in use or not initialized"); |
| 1813 | 1846 | ||
| 1814 | name = Fassq (intern ("name"), parms); | 1847 | name = x_get_arg (parms, intern ("name"), Qnil, "Title", string); |
| 1815 | if (NULL (name)) | 1848 | if (NULL (name)) |
| 1816 | name = build_string (id_name); | 1849 | name = build_string (x_id_name); |
| 1817 | else | 1850 | if (XTYPE (name) != Lisp_String) |
| 1818 | { | 1851 | error ("x-create-screen: name parameter must be a string"); |
| 1819 | if (XTYPE (name) != Lisp_Cons) | ||
| 1820 | /* Fassq should always return nil or a cons! */ | ||
| 1821 | abort (); | ||
| 1822 | name = XCONS (name)->cdr; | ||
| 1823 | if (XTYPE (name) != Lisp_String) | ||
| 1824 | error ("x-create-screen: name parameter must be a string."); | ||
| 1825 | } | ||
| 1826 | 1852 | ||
| 1827 | tem = x_get_arg (parms, intern ("minibuffer"), name, 0); | 1853 | tem = x_get_arg (parms, intern ("minibuffer"), name, 0, 0); |
| 1828 | if (EQ (tem, intern ("none"))) | 1854 | if (EQ (tem, intern ("none"))) |
| 1829 | s = make_screen_without_minibuffer (Qnil); | 1855 | s = make_screen_without_minibuffer (Qnil); |
| 1830 | else if (EQ (tem, intern ("only"))) | 1856 | else if (EQ (tem, intern ("only"))) |
| @@ -1849,23 +1875,23 @@ be shared by the new screen.") | |||
| 1849 | /* Extract the window parameters from the supplied values | 1875 | /* Extract the window parameters from the supplied values |
| 1850 | that are needed to determine window geometry. */ | 1876 | that are needed to determine window geometry. */ |
| 1851 | x_default_parameter (s, parms, "font", | 1877 | x_default_parameter (s, parms, "font", |
| 1852 | build_string ("9x15"), "font"); | 1878 | build_string ("9x15"), "font", string); |
| 1853 | x_default_parameter (s, parms, "background-color", | 1879 | x_default_parameter (s, parms, "background-color", |
| 1854 | build_string ("white"), "background"); | 1880 | build_string ("white"), "background", string); |
| 1855 | x_default_parameter (s, parms, "border-width", | 1881 | x_default_parameter (s, parms, "border-width", |
| 1856 | make_number (2), "#BorderWidth"); | 1882 | make_number (2), "BorderWidth", number); |
| 1857 | x_default_parameter (s, parms, "internal-border-width", | 1883 | x_default_parameter (s, parms, "internal-border-width", |
| 1858 | make_number (4), "#InternalBorderWidth"); | 1884 | make_number (4), "InternalBorderWidth", number); |
| 1859 | 1885 | ||
| 1860 | /* Also do the stuff which must be set before the window exists. */ | 1886 | /* Also do the stuff which must be set before the window exists. */ |
| 1861 | x_default_parameter (s, parms, "foreground-color", | 1887 | x_default_parameter (s, parms, "foreground-color", |
| 1862 | build_string ("black"), "foreground"); | 1888 | build_string ("black"), "foreground", string); |
| 1863 | x_default_parameter (s, parms, "mouse-color", | 1889 | x_default_parameter (s, parms, "mouse-color", |
| 1864 | build_string ("black"), "mouse"); | 1890 | build_string ("black"), "mouse", string); |
| 1865 | x_default_parameter (s, parms, "cursor-color", | 1891 | x_default_parameter (s, parms, "cursor-color", |
| 1866 | build_string ("black"), "cursor"); | 1892 | build_string ("black"), "cursor", string); |
| 1867 | x_default_parameter (s, parms, "border-color", | 1893 | x_default_parameter (s, parms, "border-color", |
| 1868 | build_string ("black"), "border"); | 1894 | build_string ("black"), "border", string); |
| 1869 | 1895 | ||
| 1870 | /* Need to do icon type, auto-raise, auto-lower. */ | 1896 | /* Need to do icon type, auto-raise, auto-lower. */ |
| 1871 | 1897 | ||
| @@ -1887,19 +1913,17 @@ be shared by the new screen.") | |||
| 1887 | x_wm_set_size_hint (s, window_prompting); | 1913 | x_wm_set_size_hint (s, window_prompting); |
| 1888 | UNBLOCK_INPUT; | 1914 | UNBLOCK_INPUT; |
| 1889 | 1915 | ||
| 1890 | tem = x_get_arg (parms, intern ("unsplittable"), name, 0); | 1916 | tem = x_get_arg (parms, intern ("unsplittable"), name, 0, 0); |
| 1891 | s->no_split = minibuffer_only || EQ (tem, Qt); | 1917 | s->no_split = minibuffer_only || EQ (tem, Qt); |
| 1892 | 1918 | ||
| 1893 | /* Now handle the rest of the parameters. */ | 1919 | /* Now handle the rest of the parameters. */ |
| 1894 | x_default_parameter (s, parms, "name", | ||
| 1895 | build_string (id_name), "Title"); | ||
| 1896 | x_default_parameter (s, parms, "horizontal-scroll-bar", | 1920 | x_default_parameter (s, parms, "horizontal-scroll-bar", |
| 1897 | Qnil, "?HScrollBar"); | 1921 | Qnil, "?HScrollBar", string); |
| 1898 | x_default_parameter (s, parms, "vertical-scroll-bar", | 1922 | x_default_parameter (s, parms, "vertical-scroll-bar", |
| 1899 | Qnil, "?VScrollBar"); | 1923 | Qnil, "?VScrollBar", string); |
| 1900 | 1924 | ||
| 1901 | /* Make the window appear on the screen and enable display. */ | 1925 | /* Make the window appear on the screen and enable display. */ |
| 1902 | if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), name, 0), Qt)) | 1926 | if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), name, 0, 0), Qt)) |
| 1903 | x_make_screen_visible (s); | 1927 | x_make_screen_visible (s); |
| 1904 | 1928 | ||
| 1905 | return screen; | 1929 | return screen; |
| @@ -1920,7 +1944,7 @@ be shared by the new screen.") | |||
| 1920 | 1944 | ||
| 1921 | name = Fassq (intern ("name"), parms); | 1945 | name = Fassq (intern ("name"), parms); |
| 1922 | 1946 | ||
| 1923 | tem = x_get_arg (parms, intern ("minibuffer"), name, 0); | 1947 | tem = x_get_arg (parms, intern ("minibuffer"), name, 0, 0); |
| 1924 | if (EQ (tem, intern ("none"))) | 1948 | if (EQ (tem, intern ("none"))) |
| 1925 | s = make_screen_without_minibuffer (Qnil); | 1949 | s = make_screen_without_minibuffer (Qnil); |
| 1926 | else if (EQ (tem, intern ("only"))) | 1950 | else if (EQ (tem, intern ("only"))) |
| @@ -1957,34 +1981,34 @@ be shared by the new screen.") | |||
| 1957 | /* Extract some window parameters from the supplied values. | 1981 | /* Extract some window parameters from the supplied values. |
| 1958 | These are the parameters that affect window geometry. */ | 1982 | These are the parameters that affect window geometry. */ |
| 1959 | 1983 | ||
| 1960 | tem = x_get_arg (parms, intern ("font"), name, "BodyFont"); | 1984 | tem = x_get_arg (parms, intern ("font"), name, "BodyFont", string); |
| 1961 | if (EQ (tem, Qnil)) | 1985 | if (EQ (tem, Qnil)) |
| 1962 | tem = build_string ("9x15"); | 1986 | tem = build_string ("9x15"); |
| 1963 | x_set_font (s, tem); | 1987 | x_set_font (s, tem); |
| 1964 | x_default_parameter (s, parms, "border-color", | 1988 | x_default_parameter (s, parms, "border-color", |
| 1965 | build_string ("black"), "Border"); | 1989 | build_string ("black"), "Border", string); |
| 1966 | x_default_parameter (s, parms, "background-color", | 1990 | x_default_parameter (s, parms, "background-color", |
| 1967 | build_string ("white"), "Background"); | 1991 | build_string ("white"), "Background", string); |
| 1968 | x_default_parameter (s, parms, "foreground-color", | 1992 | x_default_parameter (s, parms, "foreground-color", |
| 1969 | build_string ("black"), "Foreground"); | 1993 | build_string ("black"), "Foreground", string); |
| 1970 | x_default_parameter (s, parms, "mouse-color", | 1994 | x_default_parameter (s, parms, "mouse-color", |
| 1971 | build_string ("black"), "Mouse"); | 1995 | build_string ("black"), "Mouse", string); |
| 1972 | x_default_parameter (s, parms, "cursor-color", | 1996 | x_default_parameter (s, parms, "cursor-color", |
| 1973 | build_string ("black"), "Cursor"); | 1997 | build_string ("black"), "Cursor", string); |
| 1974 | x_default_parameter (s, parms, "border-width", | 1998 | x_default_parameter (s, parms, "border-width", |
| 1975 | make_number (2), "#BorderWidth"); | 1999 | make_number (2), "BorderWidth", number); |
| 1976 | x_default_parameter (s, parms, "internal-border-width", | 2000 | x_default_parameter (s, parms, "internal-border-width", |
| 1977 | make_number (4), "#InternalBorderWidth"); | 2001 | make_number (4), "InternalBorderWidth", number); |
| 1978 | x_default_parameter (s, parms, "auto-raise", | 2002 | x_default_parameter (s, parms, "auto-raise", |
| 1979 | Qnil, "?AutoRaise"); | 2003 | Qnil, "AutoRaise", boolean); |
| 1980 | 2004 | ||
| 1981 | hscroll = x_get_arg (parms, intern ("horizontal-scroll-bar"), name, 0); | 2005 | hscroll = x_get_arg (parms, intern ("horizontal-scroll-bar"), name, 0, 0); |
| 1982 | vscroll = x_get_arg (parms, intern ("vertical-scroll-bar"), name, 0); | 2006 | vscroll = x_get_arg (parms, intern ("vertical-scroll-bar"), name, 0, 0); |
| 1983 | 2007 | ||
| 1984 | if (s->display.x->internal_border_width < 0) | 2008 | if (s->display.x->internal_border_width < 0) |
| 1985 | s->display.x->internal_border_width = 0; | 2009 | s->display.x->internal_border_width = 0; |
| 1986 | 2010 | ||
| 1987 | tem = x_get_arg (parms, intern ("window-id"), name, 0); | 2011 | tem = x_get_arg (parms, intern ("window-id"), name, 0, 0); |
| 1988 | if (!EQ (tem, Qnil)) | 2012 | if (!EQ (tem, Qnil)) |
| 1989 | { | 2013 | { |
| 1990 | WINDOWINFO_TYPE wininfo; | 2014 | WINDOWINFO_TYPE wininfo; |
| @@ -2012,29 +2036,29 @@ be shared by the new screen.") | |||
| 2012 | } | 2036 | } |
| 2013 | else | 2037 | else |
| 2014 | { | 2038 | { |
| 2015 | tem = x_get_arg (parms, intern ("parent-id"), name, 0); | 2039 | tem = x_get_arg (parms, intern ("parent-id"), name, 0, 0); |
| 2016 | if (!EQ (tem, Qnil)) | 2040 | if (!EQ (tem, Qnil)) |
| 2017 | { | 2041 | { |
| 2018 | CHECK_STRING (tem, 0); | 2042 | CHECK_STRING (tem, 0); |
| 2019 | parent = (Window) atoi (XSTRING (tem)->data); | 2043 | parent = (Window) atoi (XSTRING (tem)->data); |
| 2020 | } | 2044 | } |
| 2021 | s->display.x->parent_desc = parent; | 2045 | s->display.x->parent_desc = parent; |
| 2022 | tem = x_get_arg (parms, intern ("height"), name, 0); | 2046 | tem = x_get_arg (parms, intern ("height"), name, 0, 0); |
| 2023 | if (EQ (tem, Qnil)) | 2047 | if (EQ (tem, Qnil)) |
| 2024 | { | 2048 | { |
| 2025 | tem = x_get_arg (parms, intern ("width"), name, 0); | 2049 | tem = x_get_arg (parms, intern ("width"), name, 0, 0); |
| 2026 | if (EQ (tem, Qnil)) | 2050 | if (EQ (tem, Qnil)) |
| 2027 | { | 2051 | { |
| 2028 | tem = x_get_arg (parms, intern ("top"), name, 0); | 2052 | tem = x_get_arg (parms, intern ("top"), name, 0, 0); |
| 2029 | if (EQ (tem, Qnil)) | 2053 | if (EQ (tem, Qnil)) |
| 2030 | tem = x_get_arg (parms, intern ("left"), name, 0); | 2054 | tem = x_get_arg (parms, intern ("left"), name, 0, 0); |
| 2031 | } | 2055 | } |
| 2032 | } | 2056 | } |
| 2033 | /* Now TEM is nil if no edge or size was specified. | 2057 | /* Now TEM is nil if no edge or size was specified. |
| 2034 | In that case, we must do rubber-banding. */ | 2058 | In that case, we must do rubber-banding. */ |
| 2035 | if (EQ (tem, Qnil)) | 2059 | if (EQ (tem, Qnil)) |
| 2036 | { | 2060 | { |
| 2037 | tem = x_get_arg (parms, intern ("geometry"), name, 0); | 2061 | tem = x_get_arg (parms, intern ("geometry"), name, 0, 0); |
| 2038 | x_rubber_band (s, | 2062 | x_rubber_band (s, |
| 2039 | &s->display.x->left_pos, &s->display.x->top_pos, | 2063 | &s->display.x->left_pos, &s->display.x->top_pos, |
| 2040 | &width, &height, | 2064 | &width, &height, |
| @@ -2047,25 +2071,25 @@ be shared by the new screen.") | |||
| 2047 | { | 2071 | { |
| 2048 | /* Here if at least one edge or size was specified. | 2072 | /* Here if at least one edge or size was specified. |
| 2049 | Demand that they all were specified, and use them. */ | 2073 | Demand that they all were specified, and use them. */ |
| 2050 | tem = x_get_arg (parms, intern ("height"), name, 0); | 2074 | tem = x_get_arg (parms, intern ("height"), name, 0, 0); |
| 2051 | if (EQ (tem, Qnil)) | 2075 | if (EQ (tem, Qnil)) |
| 2052 | error ("Height not specified"); | 2076 | error ("Height not specified"); |
| 2053 | CHECK_NUMBER (tem, 0); | 2077 | CHECK_NUMBER (tem, 0); |
| 2054 | height = XINT (tem); | 2078 | height = XINT (tem); |
| 2055 | 2079 | ||
| 2056 | tem = x_get_arg (parms, intern ("width"), name, 0); | 2080 | tem = x_get_arg (parms, intern ("width"), name, 0, 0); |
| 2057 | if (EQ (tem, Qnil)) | 2081 | if (EQ (tem, Qnil)) |
| 2058 | error ("Width not specified"); | 2082 | error ("Width not specified"); |
| 2059 | CHECK_NUMBER (tem, 0); | 2083 | CHECK_NUMBER (tem, 0); |
| 2060 | width = XINT (tem); | 2084 | width = XINT (tem); |
| 2061 | 2085 | ||
| 2062 | tem = x_get_arg (parms, intern ("top"), name, 0); | 2086 | tem = x_get_arg (parms, intern ("top"), name, 0, 0); |
| 2063 | if (EQ (tem, Qnil)) | 2087 | if (EQ (tem, Qnil)) |
| 2064 | error ("Top position not specified"); | 2088 | error ("Top position not specified"); |
| 2065 | CHECK_NUMBER (tem, 0); | 2089 | CHECK_NUMBER (tem, 0); |
| 2066 | s->display.x->left_pos = XINT (tem); | 2090 | s->display.x->left_pos = XINT (tem); |
| 2067 | 2091 | ||
| 2068 | tem = x_get_arg (parms, intern ("left"), name, 0); | 2092 | tem = x_get_arg (parms, intern ("left"), name, 0, 0); |
| 2069 | if (EQ (tem, Qnil)) | 2093 | if (EQ (tem, Qnil)) |
| 2070 | error ("Left position not specified"); | 2094 | error ("Left position not specified"); |
| 2071 | CHECK_NUMBER (tem, 0); | 2095 | CHECK_NUMBER (tem, 0); |
| @@ -2106,15 +2130,16 @@ be shared by the new screen.") | |||
| 2106 | XStoreName (XDISPLAY s->display.x->window_desc, XSTRING (s->name)->data); | 2130 | XStoreName (XDISPLAY s->display.x->window_desc, XSTRING (s->name)->data); |
| 2107 | /* Now override the defaults with all the rest of the specified | 2131 | /* Now override the defaults with all the rest of the specified |
| 2108 | parms. */ | 2132 | parms. */ |
| 2109 | tem = x_get_arg (parms, intern ("unsplittable"), name, 0); | 2133 | tem = x_get_arg (parms, intern ("unsplittable"), name, 0, 0); |
| 2110 | s->no_split = minibuffer_only || EQ (tem, Qt); | 2134 | s->no_split = minibuffer_only || EQ (tem, Qt); |
| 2111 | 2135 | ||
| 2112 | /* Do not create an icon window if the caller says not to */ | 2136 | /* Do not create an icon window if the caller says not to */ |
| 2113 | if (!EQ (x_get_arg (parms, intern ("suppress-icon"), name, 0), Qt) | 2137 | if (!EQ (x_get_arg (parms, intern ("suppress-icon"), name, 0, 0), Qt) |
| 2114 | || s->display.x->parent_desc != ROOT_WINDOW) | 2138 | || s->display.x->parent_desc != ROOT_WINDOW) |
| 2115 | { | 2139 | { |
| 2116 | x_text_icon (s, iconidentity); | 2140 | x_text_icon (s, iconidentity); |
| 2117 | x_default_parameter (s, parms, "icon-type", Qnil, "?BitmapIcon"); | 2141 | x_default_parameter (s, parms, "icon-type", Qnil, |
| 2142 | "BitmapIcon", boolean); | ||
| 2118 | } | 2143 | } |
| 2119 | 2144 | ||
| 2120 | /* Tell the X server the previously set values of the | 2145 | /* Tell the X server the previously set values of the |
| @@ -2139,7 +2164,7 @@ be shared by the new screen.") | |||
| 2139 | 2164 | ||
| 2140 | /* Make the window appear on the screen and enable display. */ | 2165 | /* Make the window appear on the screen and enable display. */ |
| 2141 | 2166 | ||
| 2142 | if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), name, 0), Qt)) | 2167 | if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), name, 0, 0), Qt)) |
| 2143 | x_make_window_visible (s); | 2168 | x_make_window_visible (s); |
| 2144 | SCREEN_GARBAGED (s); | 2169 | SCREEN_GARBAGED (s); |
| 2145 | 2170 | ||
| @@ -3423,101 +3448,6 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e", | |||
| 3423 | } | 3448 | } |
| 3424 | } | 3449 | } |
| 3425 | 3450 | ||
| 3426 | static Cursor grabbed_cursor; | ||
| 3427 | |||
| 3428 | DEFUN ("x-grab-pointer", Fx_grab_pointer, Sx_grab_pointer, 0, 2, 0, | ||
| 3429 | "Grab the pointer and restrict it to its current window. If optional\n\ | ||
| 3430 | SHAPE is non-nil, change the pointer shape to that. If second optional\n\ | ||
| 3431 | argument MOUSE-ONLY is non-nil, ignore keyboard events during the grab.") | ||
| 3432 | (shape, ignore_keyboard) | ||
| 3433 | Lisp_Object shape, ignore_keyboard; | ||
| 3434 | { | ||
| 3435 | Window w; | ||
| 3436 | int pointer_mode, result; | ||
| 3437 | |||
| 3438 | BLOCK_INPUT; | ||
| 3439 | if (! NULL (ignore_keyboard)) | ||
| 3440 | pointer_mode = GrabModeSync; | ||
| 3441 | else | ||
| 3442 | pointer_mode = GrabModeAsync; | ||
| 3443 | |||
| 3444 | if (! NULL (shape)) | ||
| 3445 | { | ||
| 3446 | CHECK_NUMBER (shape, 0); | ||
| 3447 | grabbed_cursor = XCreateFontCursor (x_current_display, XINT (shape)); | ||
| 3448 | } | ||
| 3449 | |||
| 3450 | /* Determine which window to confine the mouse to. */ | ||
| 3451 | if (EQ (Vmouse_screen_part, Qtext_part) || EQ (Vmouse_screen_part, Qmodeline_part)) | ||
| 3452 | { | ||
| 3453 | w = x_focus_screen->display.x->window_desc; | ||
| 3454 | } | ||
| 3455 | else if (EQ (Vmouse_screen_part, Qvscrollbar_part) | ||
| 3456 | || EQ (Vmouse_screen_part, Qvslider_part)) | ||
| 3457 | { | ||
| 3458 | w = x_focus_screen->display.x->v_scrollbar; | ||
| 3459 | } | ||
| 3460 | else if (EQ (Vmouse_screen_part, Qvthumbup_part)) | ||
| 3461 | { | ||
| 3462 | w = x_focus_screen->display.x->v_thumbup; | ||
| 3463 | } | ||
| 3464 | else if (EQ (Vmouse_screen_part, Qvthumbdown_part)) | ||
| 3465 | { | ||
| 3466 | w = x_focus_screen->display.x->v_thumbdown; | ||
| 3467 | } | ||
| 3468 | else if (EQ (Vmouse_screen_part, Qhscrollbar_part) | ||
| 3469 | || EQ (Vmouse_screen_part, Qhslider_part)) | ||
| 3470 | { | ||
| 3471 | w = x_focus_screen->display.x->h_scrollbar; | ||
| 3472 | } | ||
| 3473 | else if (EQ (Vmouse_screen_part, Qhthumbleft_part)) | ||
| 3474 | { | ||
| 3475 | w = x_focus_screen->display.x->h_thumbleft; | ||
| 3476 | } | ||
| 3477 | else if (EQ (Vmouse_screen_part, Qhthumbright_part)) | ||
| 3478 | { | ||
| 3479 | w = x_focus_screen->display.x->h_thumbright; | ||
| 3480 | } | ||
| 3481 | else | ||
| 3482 | abort (); | ||
| 3483 | |||
| 3484 | result = XGrabPointer (x_current_display, w, | ||
| 3485 | False, | ||
| 3486 | ButtonMotionMask | ButtonPressMask | ||
| 3487 | | ButtonReleaseMask | PointerMotionHintMask, | ||
| 3488 | GrabModeAsync, /* Keep pointer events flowing */ | ||
| 3489 | pointer_mode, /* Stall keyboard events */ | ||
| 3490 | w, /* Stay in this window */ | ||
| 3491 | grabbed_cursor, | ||
| 3492 | CurrentTime); | ||
| 3493 | if (result == GrabSuccess) | ||
| 3494 | { | ||
| 3495 | UNBLOCK_INPUT; | ||
| 3496 | return Qt; | ||
| 3497 | } | ||
| 3498 | |||
| 3499 | XFreeCursor (x_current_display, grabbed_cursor); | ||
| 3500 | UNBLOCK_INPUT; | ||
| 3501 | return Qnil; | ||
| 3502 | } | ||
| 3503 | |||
| 3504 | DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, Sx_ungrab_pointer, 0, 0, 0, | ||
| 3505 | "Release the pointer.") | ||
| 3506 | () | ||
| 3507 | { | ||
| 3508 | BLOCK_INPUT; | ||
| 3509 | XUngrabPointer (x_current_display, CurrentTime); | ||
| 3510 | |||
| 3511 | if (! ((int) grabbed_cursor)) | ||
| 3512 | { | ||
| 3513 | XFreeCursor (x_current_display, grabbed_cursor); | ||
| 3514 | grabbed_cursor = (Cursor) 0; | ||
| 3515 | } | ||
| 3516 | |||
| 3517 | UNBLOCK_INPUT; | ||
| 3518 | return Qnil; | ||
| 3519 | } | ||
| 3520 | |||
| 3521 | /* Offset in buffer of character under the pointer, or 0. */ | 3451 | /* Offset in buffer of character under the pointer, or 0. */ |
| 3522 | int mouse_buffer_offset; | 3452 | int mouse_buffer_offset; |
| 3523 | 3453 | ||
| @@ -4407,6 +4337,8 @@ syms_of_xfns () | |||
| 4407 | Fput (Qundefined_color, Qerror_message, | 4337 | Fput (Qundefined_color, Qerror_message, |
| 4408 | build_string ("Undefined color")); | 4338 | build_string ("Undefined color")); |
| 4409 | 4339 | ||
| 4340 | screen_class = make_pure_string (SCREEN_CLASS, sizeof (SCREEN_CLASS)-1); | ||
| 4341 | |||
| 4410 | DEFVAR_INT ("mouse-x-position", &x_mouse_x, | 4342 | DEFVAR_INT ("mouse-x-position", &x_mouse_x, |
| 4411 | "The X coordinate of the mouse position, in characters."); | 4343 | "The X coordinate of the mouse position, in characters."); |
| 4412 | x_mouse_x = Qnil; | 4344 | x_mouse_x = Qnil; |
diff --git a/src/xterm.c b/src/xterm.c index 96f3cfaed67..06d54c9a62e 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -161,6 +161,7 @@ static FONT_TYPE *icon_font_info; | |||
| 161 | /* Stuff for dealing with the main icon title. */ | 161 | /* Stuff for dealing with the main icon title. */ |
| 162 | 162 | ||
| 163 | extern Lisp_Object Vcommand_line_args; | 163 | extern Lisp_Object Vcommand_line_args; |
| 164 | char *hostname, *x_id_name; | ||
| 164 | Lisp_Object invocation_name; | 165 | Lisp_Object invocation_name; |
| 165 | 166 | ||
| 166 | /* This is the X connection that we are using. */ | 167 | /* This is the X connection that we are using. */ |
| @@ -3583,11 +3584,36 @@ x_term_init (display_name) | |||
| 3583 | 3584 | ||
| 3584 | #ifdef HAVE_X11 | 3585 | #ifdef HAVE_X11 |
| 3585 | { | 3586 | { |
| 3587 | int hostname_size = MAXHOSTNAMELEN + 1; | ||
| 3588 | |||
| 3589 | hostname = (char *) xmalloc (hostname_size); | ||
| 3590 | |||
| 3586 | #if 0 | 3591 | #if 0 |
| 3587 | XSetAfterFunction (x_current_display, x_trace_wire); | 3592 | XSetAfterFunction (x_current_display, x_trace_wire); |
| 3588 | #endif | 3593 | #endif |
| 3589 | 3594 | ||
| 3590 | invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args)); | 3595 | invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args)); |
| 3596 | |||
| 3597 | /* Try to get the host name; if the buffer is too short, try | ||
| 3598 | again. Apparently, the only indication gethostname gives of | ||
| 3599 | whether the buffer was large enough is the presence or absence | ||
| 3600 | of a '\0' in the string. Eech. */ | ||
| 3601 | for (;;) | ||
| 3602 | { | ||
| 3603 | gethostname (hostname, hostname_size - 1); | ||
| 3604 | hostname[hostname_size - 1] = '\0'; | ||
| 3605 | |||
| 3606 | /* Was the buffer large enough for gethostname to store the '\0'? */ | ||
| 3607 | if (strlen (hostname) < hostname_size - 1) | ||
| 3608 | break; | ||
| 3609 | |||
| 3610 | hostname_size <<= 1; | ||
| 3611 | hostname = (char *) xrealloc (hostname, hostname_size); | ||
| 3612 | } | ||
| 3613 | x_id_name = (char *) xmalloc (XSTRING (invocation_name)->size | ||
| 3614 | + strlen (hostname) | ||
| 3615 | + 2); | ||
| 3616 | sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname); | ||
| 3591 | } | 3617 | } |
| 3592 | 3618 | ||
| 3593 | dup2 (ConnectionNumber (x_current_display), 0); | 3619 | dup2 (ConnectionNumber (x_current_display), 0); |