comparison src/xfns.c @ 9022:10fa443c671a

(Fx_create_frame): Rename menuBarLines resource to menuBar. (x_figure_window_size): Decode (- N), (+ N) for position. (x_set_frame_parameters): Handle (+ N) and (- N). Preserve negative positions properly too. [USE_X_TOOLKIT] (x_window): Let xneg, yneg specify whether to negate left and top. (Fx_parse_geometry): Handle [XY]Negative with positive number or negative number without [XY]Negative.
author Richard M. Stallman <rms@gnu.org>
date Fri, 23 Sep 1994 18:20:31 +0000
parents 7b805f79f3b4
children 948e8acb6990
comparison
equal deleted inserted replaced
9021:e0709ca0418a 9022:10fa443c671a
461 461
462 /* Record in these vectors all the parms specified. */ 462 /* Record in these vectors all the parms specified. */
463 Lisp_Object *parms; 463 Lisp_Object *parms;
464 Lisp_Object *values; 464 Lisp_Object *values;
465 int i; 465 int i;
466 int left_no_change = 0, top_no_change = 0;
466 467
467 i = 0; 468 i = 0;
468 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) 469 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
469 i++; 470 i++;
470 471
517 } 518 }
518 } 519 }
519 520
520 /* Don't die if just one of these was set. */ 521 /* Don't die if just one of these was set. */
521 if (EQ (left, Qunbound)) 522 if (EQ (left, Qunbound))
522 XSET (left, Lisp_Int, f->display.x->left_pos); 523 {
524 left_no_change = 1;
525 if (f->display.x->left_pos < 0)
526 left = Fcons (Qplus, Fcons (make_number (f->display.x->left_pos), Qnil));
527 else
528 XSET (left, Lisp_Int, f->display.x->left_pos);
529 }
523 if (EQ (top, Qunbound)) 530 if (EQ (top, Qunbound))
524 XSET (top, Lisp_Int, f->display.x->top_pos); 531 {
532 top_no_change = 1;
533 if (f->display.x->top_pos < 0)
534 top = Fcons (Qplus, Fcons (make_number (f->display.x->top_pos), Qnil));
535 else
536 XSET (top, Lisp_Int, f->display.x->top_pos);
537 }
525 538
526 /* Don't die if just one of these was set. */ 539 /* Don't die if just one of these was set. */
527 if (EQ (width, Qunbound)) 540 if (EQ (width, Qunbound))
528 XSET (width, Lisp_Int, FRAME_WIDTH (f)); 541 XSET (width, Lisp_Int, FRAME_WIDTH (f));
529 if (EQ (height, Qunbound)) 542 if (EQ (height, Qunbound))
547 if ((NUMBERP (width) && XINT (width) != FRAME_WIDTH (f)) 560 if ((NUMBERP (width) && XINT (width) != FRAME_WIDTH (f))
548 || (NUMBERP (height) && XINT (height) != FRAME_HEIGHT (f))) 561 || (NUMBERP (height) && XINT (height) != FRAME_HEIGHT (f)))
549 Fset_frame_size (frame, width, height); 562 Fset_frame_size (frame, width, height);
550 563
551 if ((!NILP (left) || !NILP (top)) 564 if ((!NILP (left) || !NILP (top))
565 && ! (left_no_change && top_no_change)
552 && ! (NUMBERP (left) && XINT (left) == f->display.x->left_pos 566 && ! (NUMBERP (left) && XINT (left) == f->display.x->left_pos
553 && NUMBERP (top) && XINT (top) == f->display.x->top_pos)) 567 && NUMBERP (top) && XINT (top) == f->display.x->top_pos))
554 { 568 {
555 int leftpos = (NUMBERP (left) ? XINT (left) : 0); 569 int leftpos = 0;
556 int toppos = (NUMBERP (top) ? XINT (top) : 0); 570 int toppos = 0;
571
572 /* Record the signs. */
573 f->display.x->size_hint_flags &= ~ (XNegative | YNegative);
574 if (EQ (left, Qminus))
575 f->display.x->size_hint_flags |= XNegative;
576 else if (INTEGERP (left))
577 {
578 leftpos = XINT (left);
579 if (leftpos < 0)
580 f->display.x->size_hint_flags |= XNegative;
581 }
582 else if (CONSP (left) && EQ (XCONS (left)->car, Qminus)
583 && CONSP (XCONS (left)->cdr)
584 && INTEGERP (XCONS (XCONS (left)->cdr)->car))
585 {
586 leftpos = - XINT (XCONS (XCONS (left)->cdr)->car);
587 f->display.x->size_hint_flags |= XNegative;
588 }
589 else if (CONSP (left) && EQ (XCONS (left)->car, Qplus)
590 && CONSP (XCONS (left)->cdr)
591 && INTEGERP (XCONS (XCONS (left)->cdr)->car))
592 {
593 leftpos = XINT (XCONS (XCONS (left)->cdr)->car);
594 }
595
596 if (EQ (top, Qminus))
597 f->display.x->size_hint_flags |= YNegative;
598 else if (INTEGERP (top))
599 {
600 toppos = XINT (top);
601 if (toppos < 0)
602 f->display.x->size_hint_flags |= YNegative;
603 }
604 else if (CONSP (top) && EQ (XCONS (top)->car, Qminus)
605 && CONSP (XCONS (top)->cdr)
606 && INTEGERP (XCONS (XCONS (top)->cdr)->car))
607 {
608 toppos = - XINT (XCONS (XCONS (top)->cdr)->car);
609 f->display.x->size_hint_flags |= YNegative;
610 }
611 else if (CONSP (top) && EQ (XCONS (top)->car, Qplus)
612 && CONSP (XCONS (top)->cdr)
613 && INTEGERP (XCONS (XCONS (top)->cdr)->car))
614 {
615 toppos = XINT (XCONS (XCONS (top)->cdr)->car);
616 }
617
557 618
558 /* Store the numeric value of the position. */ 619 /* Store the numeric value of the position. */
559 f->display.x->top_pos = toppos; 620 f->display.x->top_pos = toppos;
560 f->display.x->left_pos = leftpos; 621 f->display.x->left_pos = leftpos;
561 622
562 /* Record the signs. */
563 f->display.x->size_hint_flags &= ~ (XNegative | YNegative);
564 if (EQ (left, Qminus) || (NUMBERP (left) && XINT (left) < 0))
565 f->display.x->size_hint_flags |= XNegative;
566 if (EQ (top, Qminus) || (NUMBERP (top) && XINT (top) < 0))
567 f->display.x->size_hint_flags |= YNegative;
568 f->display.x->win_gravity = NorthWestGravity; 623 f->display.x->win_gravity = NorthWestGravity;
569 624
570 /* Actually set that position, and convert to absolute. */ 625 /* Actually set that position, and convert to absolute. */
571 x_set_offset (f, leftpos, toppos, 0); 626 x_set_offset (f, leftpos, toppos, 0);
572 } 627 }
1592 1647
1593 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0, 1648 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
1594 "Parse an X-style geometry string STRING.\n\ 1649 "Parse an X-style geometry string STRING.\n\
1595 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\ 1650 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
1596 The properties returned may include `top', `left', `height', and `width'.\n\ 1651 The properties returned may include `top', `left', `height', and `width'.\n\
1597 The value of `left' or `top' may be an integer or `-'.\n\ 1652 The value of `left' or `top' may be an integer,\n\
1598 `-' means \"minus zero\".") 1653 or a list (+ N) meaning N pixels relative to top/left corner,\n\
1654 or a list (- N) meaning -N pixels relative to bottom/right corner.")
1599 (string) 1655 (string)
1600 Lisp_Object string; 1656 Lisp_Object string;
1601 { 1657 {
1602 int geometry, x, y; 1658 int geometry, x, y;
1603 unsigned int width, height; 1659 unsigned int width, height;
1616 result = Qnil; 1672 result = Qnil;
1617 if (geometry & XValue) 1673 if (geometry & XValue)
1618 { 1674 {
1619 Lisp_Object element; 1675 Lisp_Object element;
1620 1676
1621 if (x == 0 && (geometry & XNegative)) 1677 if (x >= 0 && (geometry & XNegative))
1622 element = Fcons (Qleft, Qminus); 1678 element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
1679 else if (x < 0 && ! (geometry & XNegative))
1680 element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
1623 else 1681 else
1624 element = Fcons (Qleft, make_number (x)); 1682 element = Fcons (Qleft, make_number (x));
1625 result = Fcons (element, result); 1683 result = Fcons (element, result);
1626 } 1684 }
1627 1685
1628 if (geometry & YValue) 1686 if (geometry & YValue)
1629 { 1687 {
1630 Lisp_Object element; 1688 Lisp_Object element;
1631 1689
1632 if (y == 0 && (geometry & YNegative)) 1690 if (y >= 0 && (geometry & YNegative))
1633 element = Fcons (Qtop, Qminus); 1691 element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
1692 else if (y < 0 && ! (geometry & YNegative))
1693 element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
1634 else 1694 else
1635 element = Fcons (Qtop, make_number (y)); 1695 element = Fcons (Qtop, make_number (y));
1636 result = Fcons (element, result); 1696 result = Fcons (element, result);
1637 } 1697 }
1638 1698
1708 if (EQ (tem0, Qminus)) 1768 if (EQ (tem0, Qminus))
1709 { 1769 {
1710 f->display.x->top_pos = 0; 1770 f->display.x->top_pos = 0;
1711 window_prompting |= YNegative; 1771 window_prompting |= YNegative;
1712 } 1772 }
1773 else if (CONSP (tem0) && EQ (XCONS (tem0)->car, Qminus)
1774 && CONSP (XCONS (tem0)->cdr)
1775 && INTEGERP (XCONS (XCONS (tem0)->cdr)->car))
1776 {
1777 f->display.x->top_pos = - XINT (XCONS (XCONS (tem0)->cdr)->car);
1778 window_prompting |= YNegative;
1779 }
1780 else if (CONSP (tem0) && EQ (XCONS (tem0)->car, Qplus)
1781 && CONSP (XCONS (tem0)->cdr)
1782 && INTEGERP (XCONS (XCONS (tem0)->cdr)->car))
1783 {
1784 f->display.x->top_pos = XINT (XCONS (XCONS (tem0)->cdr)->car);
1785 }
1713 else if (EQ (tem0, Qunbound)) 1786 else if (EQ (tem0, Qunbound))
1714 f->display.x->top_pos = 0; 1787 f->display.x->top_pos = 0;
1715 else 1788 else
1716 { 1789 {
1717 CHECK_NUMBER (tem0, 0); 1790 CHECK_NUMBER (tem0, 0);
1722 1795
1723 if (EQ (tem1, Qminus)) 1796 if (EQ (tem1, Qminus))
1724 { 1797 {
1725 f->display.x->left_pos = 0; 1798 f->display.x->left_pos = 0;
1726 window_prompting |= XNegative; 1799 window_prompting |= XNegative;
1800 }
1801 else if (CONSP (tem1) && EQ (XCONS (tem1)->car, Qminus)
1802 && CONSP (XCONS (tem1)->cdr)
1803 && INTEGERP (XCONS (XCONS (tem1)->cdr)->car))
1804 {
1805 f->display.x->left_pos = - XINT (XCONS (XCONS (tem1)->cdr)->car);
1806 window_prompting |= XNegative;
1807 }
1808 else if (CONSP (tem1) && EQ (XCONS (tem1)->car, Qplus)
1809 && CONSP (XCONS (tem1)->cdr)
1810 && INTEGERP (XCONS (XCONS (tem1)->cdr)->car))
1811 {
1812 f->display.x->left_pos = XINT (XCONS (XCONS (tem1)->cdr)->car);
1727 } 1813 }
1728 else if (EQ (tem1, Qunbound)) 1814 else if (EQ (tem1, Qunbound))
1729 f->display.x->left_pos = 0; 1815 f->display.x->left_pos = 0;
1730 else 1816 else
1731 { 1817 {
1905 { 1991 {
1906 int left = f->display.x->left_pos; 1992 int left = f->display.x->left_pos;
1907 int xneg = window_prompting & XNegative; 1993 int xneg = window_prompting & XNegative;
1908 int top = f->display.x->top_pos; 1994 int top = f->display.x->top_pos;
1909 int yneg = window_prompting & YNegative; 1995 int yneg = window_prompting & YNegative;
1910 if (left < 0) 1996 if (xneg)
1911 left = -left; 1997 left = -left;
1912 if (top < 0) 1998 if (yneg)
1913 top = -top; 1999 top = -top;
1914 sprintf (shell_position, "=%dx%d%c%d%c%d", PIXEL_WIDTH (f), 2000 sprintf (shell_position, "=%dx%d%c%d%c%d", PIXEL_WIDTH (f),
1915 PIXEL_HEIGHT (f) + menubar_size, 2001 PIXEL_HEIGHT (f) + menubar_size,
1916 (xneg ? '-' : '+'), left, 2002 (xneg ? '-' : '+'), left,
1917 (yneg ? '-' : '+'), top); 2003 (yneg ? '-' : '+'), top);
2306 "cursorColor", "Foreground", string); 2392 "cursorColor", "Foreground", string);
2307 x_default_parameter (f, parms, Qborder_color, build_string ("black"), 2393 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
2308 "borderColor", "BorderColor", string); 2394 "borderColor", "BorderColor", string);
2309 2395
2310 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), 2396 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
2311 "menuBarLines", "MenuBarLines", number); 2397 "menuBar", "MenuBar", number);
2312 x_default_parameter (f, parms, Qscroll_bar_width, make_number (12), 2398 x_default_parameter (f, parms, Qscroll_bar_width, make_number (12),
2313 "scrollBarWidth", "ScrollBarWidth", number); 2399 "scrollBarWidth", "ScrollBarWidth", number);
2314 2400
2315 f->display.x->parent_desc = ROOT_WINDOW; 2401 f->display.x->parent_desc = ROOT_WINDOW;
2316 window_prompting = x_figure_window_size (f, parms); 2402 window_prompting = x_figure_window_size (f, parms);