Mercurial > hg > xemacs-beta
comparison src/frame-x.c @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | b82b59fe008d |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
489 static void | 489 static void |
490 x_smash_bastardly_shell_position (Widget shell) | 490 x_smash_bastardly_shell_position (Widget shell) |
491 { | 491 { |
492 /* Naturally those bastards who wrote Xt couldn't be bothered | 492 /* Naturally those bastards who wrote Xt couldn't be bothered |
493 to learn about race conditions and such. We can't trust | 493 to learn about race conditions and such. We can't trust |
494 the X and Y values to have any resemblance of correctness, | 494 the X and Y values to have any semblance of correctness, |
495 so we smash the right values in place. */ | 495 so we smash the right values in place. */ |
496 | 496 |
497 /* We might be called before we've actually realized the window (if | 497 /* We might be called before we've actually realized the window (if |
498 we're checking for the minibuffer resource). This will bomb in | 498 we're checking for the minibuffer resource). This will bomb in |
499 that case so we don't bother calling it. */ | 499 that case so we don't bother calling it. */ |
507 { | 507 { |
508 Widget shell = FRAME_X_SHELL_WIDGET (f); | 508 Widget shell = FRAME_X_SHELL_WIDGET (f); |
509 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); | 509 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); |
510 Widget gw = (Widget) w; | 510 Widget gw = (Widget) w; |
511 | 511 |
512 #define FROB(propprop, value) \ | 512 #define FROB(propprop, value) \ |
513 do { \ | 513 do { \ |
514 if (EQ (property, propprop)) \ | 514 if (EQ (property, propprop)) \ |
515 { \ | 515 { \ |
516 return (value); \ | 516 return (value); \ |
517 } \ | 517 } \ |
518 } while (0) | 518 } while (0) |
519 | 519 |
520 if (EQ (property, Qleft) || EQ (property, Qtop)) | 520 if (EQ (property, Qleft) || EQ (property, Qtop)) |
521 x_smash_bastardly_shell_position (shell); | 521 x_smash_bastardly_shell_position (shell); |
522 FROB (Qleft, make_int (shell->core.x)); | 522 FROB (Qleft, make_int (shell->core.x)); |
571 Lisp_Object result = Qnil; | 571 Lisp_Object result = Qnil; |
572 Widget shell = FRAME_X_SHELL_WIDGET (f); | 572 Widget shell = FRAME_X_SHELL_WIDGET (f); |
573 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); | 573 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); |
574 Widget gw = (Widget) w; | 574 Widget gw = (Widget) w; |
575 | 575 |
576 #define FROB(propprop, value) \ | 576 #define FROB(propprop, value) \ |
577 do { \ | 577 do { \ |
578 Lisp_Object temtem = (value); \ | 578 Lisp_Object temtem = (value); \ |
579 if (!NILP (temtem)) \ | 579 if (!NILP (temtem)) \ |
580 /* backwards order; we reverse it below */ \ | 580 /* backwards order; we reverse it below */ \ |
581 result = Fcons (temtem, Fcons (propprop, result)); \ | 581 result = Fcons (temtem, Fcons (propprop, result)); \ |
582 } while (0) | 582 } while (0) |
583 | 583 |
584 x_smash_bastardly_shell_position (shell); | 584 x_smash_bastardly_shell_position (shell); |
585 FROB (Qleft, make_int (shell->core.x)); | 585 FROB (Qleft, make_int (shell->core.x)); |
586 FROB (Qtop, make_int (shell->core.y)); | 586 FROB (Qtop, make_int (shell->core.y)); |
606 return result; | 606 return result; |
607 } | 607 } |
608 | 608 |
609 | 609 |
610 /* Functions called only from `x_set_frame_properties' to set | 610 /* Functions called only from `x_set_frame_properties' to set |
611 ** individual properties. */ | 611 individual properties. */ |
612 | |
613 static void | |
614 x_set_frame_text_value (struct frame *f, Bufbyte *value, | |
615 String Xt_resource_name, | |
616 String Xt_resource_encoding_name) | |
617 { | |
618 Atom encoding = XA_STRING; | |
619 String new_XtValue = (String) value; | |
620 String old_XtValue; | |
621 Bufbyte *ptr; | |
622 Arg av[2]; | |
623 | |
624 /* ### Caching is device-independent - belongs in update_frame_title. */ | |
625 XtSetArg (av[0], Xt_resource_name, &old_XtValue); | |
626 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | |
627 if (!old_XtValue || strcmp (new_XtValue, old_XtValue)) | |
628 { | |
629 XtSetArg (av[0], Xt_resource_name, new_XtValue); | |
630 XtSetArg (av[1], Xt_resource_encoding_name, encoding); | |
631 XtSetValues (FRAME_X_SHELL_WIDGET (f), av, 2); | |
632 } | |
633 } | |
612 | 634 |
613 static void | 635 static void |
614 x_set_title_from_char (struct frame *f, char *name) | 636 x_set_title_from_bufbyte (struct frame *f, Bufbyte *name) |
615 { | 637 { |
616 CONST char *old_name = 0; | 638 x_set_frame_text_value (f, name, XtNtitle, XtNtitleEncoding); |
617 CONST char *new_name; | 639 } |
618 Arg av[1]; | 640 |
619 | 641 static void |
620 GET_C_CHARPTR_EXT_CTEXT_DATA_ALLOCA (name, new_name); | 642 x_set_icon_name_from_bufbyte (struct frame *f, Bufbyte *name) |
621 XtSetArg (av[0], XtNtitle, &old_name); | 643 { |
622 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | 644 x_set_frame_text_value (f, name, XtNiconName, XtNiconNameEncoding); |
623 if (!old_name || strcmp (new_name, old_name)) | |
624 { | |
625 XtSetArg (av[0], XtNtitle, new_name); | |
626 XtSetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | |
627 } | |
628 } | |
629 | |
630 static void | |
631 x_set_icon_name_from_char (struct frame *f, char *name) | |
632 { | |
633 CONST char *old_name = 0; | |
634 CONST char *new_name; | |
635 Arg av[1]; | |
636 | |
637 GET_C_CHARPTR_EXT_CTEXT_DATA_ALLOCA (name, new_name); | |
638 XtSetArg (av[0], XtNiconName, &old_name); | |
639 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | |
640 if (!old_name || strcmp (new_name, old_name)) | |
641 { | |
642 XtSetArg (av[0], XtNiconName, new_name); | |
643 XtSetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | |
644 } | |
645 } | 645 } |
646 | 646 |
647 /* Set the initial frame size as specified. This function is used | 647 /* Set the initial frame size as specified. This function is used |
648 when the frame's widgets have not yet been realized. In this | 648 when the frame's widgets have not yet been realized. In this |
649 case, it is not sufficient just to set the width and height of | 649 case, it is not sufficient just to set the width and height of |
939 | 939 |
940 void | 940 void |
941 x_cde_transfer_callback (Widget widget, XtPointer clientData, | 941 x_cde_transfer_callback (Widget widget, XtPointer clientData, |
942 XtPointer callData) | 942 XtPointer callData) |
943 { | 943 { |
944 char *filePath; | 944 char *filePath, *buf, *data; |
945 int ii; | 945 int ii; |
946 Lisp_Object path = Qnil; | 946 Lisp_Object path = Qnil; |
947 Lisp_Object frame = Qnil; | 947 Lisp_Object frame = Qnil; |
948 struct gcpro gcpro1, gcpro2; | 948 struct gcpro gcpro1, gcpro2; |
949 | 949 |
963 filePath = transferInfo->dropData->data.files[ii]; | 963 filePath = transferInfo->dropData->data.files[ii]; |
964 path = make_string (filePath, strlen (filePath)); | 964 path = make_string (filePath, strlen (filePath)); |
965 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); | 965 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); |
966 } | 966 } |
967 } | 967 } |
968 | 968 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) |
969 { | |
970 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) | |
971 { | |
972 filePath = transferInfo->dropData->data.buffers[ii].name; | |
973 path = (filePath != NULL) ? | |
974 make_string (filePath, strlen (filePath)) : Qnil; | |
975 buf = transferInfo->dropData->data.buffers[ii].bp; | |
976 data = make_string (buf, transferInfo->dropData->data.buffers[ii].size); | |
977 va_run_hook_with_args(Qdrag_and_drop_functions, 3, frame, path, data); | |
978 } | |
979 } | |
980 | |
969 UNGCPRO; | 981 UNGCPRO; |
970 return; | 982 return; |
971 } | 983 } |
972 #endif | 984 #endif |
985 | |
986 #ifdef HAVE_OFFIX_DND | |
987 #include <OffiX/DragAndDrop.h> | |
988 | |
989 void | |
990 x_offix_drop_event_handler (Widget widget, XtPointer data, XEvent *event, | |
991 Boolean *b) | |
992 { | |
993 int i, len, Type; | |
994 unsigned char *Data; | |
995 unsigned long Size; | |
996 | |
997 Lisp_Object path = Qnil; | |
998 Lisp_Object frame = Qnil; | |
999 | |
1000 struct gcpro gcpro1, gcpro2; | |
1001 | |
1002 Type = DndDataType (event); | |
1003 if ((Type != DndFile) && (Type != DndFiles) && (Type != DndExe)) | |
1004 return; | |
1005 DndGetData (&Data, &Size); | |
1006 | |
1007 GCPRO2 (path, frame); | |
1008 | |
1009 frame = make_frame ((struct frame *) data); | |
1010 | |
1011 if (Type == DndFiles) | |
1012 { | |
1013 while (*Data) | |
1014 { | |
1015 len = strlen ((char*) Data); | |
1016 path = make_string ((char*) Data, len); | |
1017 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); | |
1018 Data += len+1; | |
1019 } | |
1020 } | |
1021 else | |
1022 { | |
1023 path = make_string ((char*) Data, strlen (Data)); | |
1024 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); | |
1025 } | |
1026 | |
1027 UNGCPRO; | |
1028 return; | |
1029 } | |
1030 #endif /* HAVE_OFFIX_DND */ | |
973 | 1031 |
974 | 1032 |
975 /************************************************************************/ | 1033 /************************************************************************/ |
976 /* widget creation */ | 1034 /* widget creation */ |
977 /************************************************************************/ | 1035 /************************************************************************/ |
1468 } | 1526 } |
1469 else | 1527 else |
1470 #endif | 1528 #endif |
1471 { | 1529 { |
1472 XtSetArg (av[ac], XtNinput, True); ac++; | 1530 XtSetArg (av[ac], XtNinput, True); ac++; |
1473 XtSetArg (av[ac], XtNminWidthCells, 10); ac++; | 1531 XtSetArg (av[ac], (String) XtNminWidthCells, 10); ac++; |
1474 XtSetArg (av[ac], XtNminHeightCells, 1); ac++; | 1532 XtSetArg (av[ac], (String) XtNminHeightCells, 1); ac++; |
1475 } | 1533 } |
1476 | 1534 |
1477 if (!NILP (parent)) | 1535 if (!NILP (parent)) |
1478 { | 1536 { |
1479 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent)); | 1537 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent)); |
1505 (XtPointer) f); | 1563 (XtPointer) f); |
1506 | 1564 |
1507 /* Create the text area */ | 1565 /* Create the text area */ |
1508 ac = 0; | 1566 ac = 0; |
1509 XtSetArg (av[ac], XtNborderWidth, 0); ac++; /* should this be settable? */ | 1567 XtSetArg (av[ac], XtNborderWidth, 0); ac++; /* should this be settable? */ |
1510 XtSetArg (av[ac], XtNemacsFrame, f); ac++; | 1568 XtSetArg (av[ac], (String) XtNemacsFrame, f); ac++; |
1511 text = XtCreateWidget (name, | 1569 text = XtCreateWidget (name, |
1512 emacsFrameClass, | 1570 emacsFrameClass, |
1513 container, av, ac); | 1571 container, av, ac); |
1514 FRAME_X_TEXT_WIDGET (f) = text; | 1572 FRAME_X_TEXT_WIDGET (f) = text; |
1515 | 1573 |
1629 dnd_transfer_cb_rec[0].closure = (XtPointer) f; | 1687 dnd_transfer_cb_rec[0].closure = (XtPointer) f; |
1630 dnd_transfer_cb_rec[1].callback = NULL; | 1688 dnd_transfer_cb_rec[1].callback = NULL; |
1631 dnd_transfer_cb_rec[1].closure = NULL; | 1689 dnd_transfer_cb_rec[1].closure = NULL; |
1632 | 1690 |
1633 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f), | 1691 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f), |
1634 DtDND_FILENAME_TRANSFER, | 1692 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER, |
1635 XmDROP_COPY, | 1693 XmDROP_COPY, dnd_transfer_cb_rec, |
1636 dnd_transfer_cb_rec, | 1694 DtNtextIsBuffer, True, |
1637 DtNpreserveRegistration, False, | 1695 DtNpreserveRegistration, False, |
1638 NULL); | 1696 NULL); |
1697 } | |
1698 #endif | |
1699 | |
1700 #ifdef HAVE_OFFIX_DND | |
1701 { | |
1702 DndInitialize (FRAME_X_SHELL_WIDGET (f)); | |
1703 DndRegisterDropWidget (FRAME_X_TEXT_WIDGET (f), | |
1704 x_offix_drop_event_handler, | |
1705 (XtPointer) f); | |
1706 | |
1639 } | 1707 } |
1640 #endif | 1708 #endif |
1641 | 1709 |
1642 /* Do a stupid property change to force the server to generate a | 1710 /* Do a stupid property change to force the server to generate a |
1643 propertyNotify event so that the event_stream server timestamp will | 1711 propertyNotify event so that the event_stream server timestamp will |
1852 | 1920 |
1853 (set-frame-position (selected-frame) -50 -50) | 1921 (set-frame-position (selected-frame) -50 -50) |
1854 | 1922 |
1855 doesn't put the frame where you expect it to: | 1923 doesn't put the frame where you expect it to: |
1856 i.e. it's closer to the lower-right corner than | 1924 i.e. it's closer to the lower-right corner than |
1857 ) it should be, and it appears that the size of | 1925 it should be, and it appears that the size of |
1858 the WM decorations was not taken into account. | 1926 the WM decorations was not taken into account. |
1859 This is *not* a problem with this function. | 1927 This is *not* a problem with this function. |
1860 Both mwm and twm have bugs in handling this | 1928 Both mwm and twm have bugs in handling this |
1861 situation. (mwm ignores the window gravity | 1929 situation. (mwm ignores the window gravity |
1862 and always assumes NorthWest, except the first | 1930 and always assumes NorthWest, except the first |
2221 CONSOLE_HAS_METHOD (x, set_frame_position); | 2289 CONSOLE_HAS_METHOD (x, set_frame_position); |
2222 CONSOLE_HAS_METHOD (x, frame_property); | 2290 CONSOLE_HAS_METHOD (x, frame_property); |
2223 CONSOLE_HAS_METHOD (x, internal_frame_property_p); | 2291 CONSOLE_HAS_METHOD (x, internal_frame_property_p); |
2224 CONSOLE_HAS_METHOD (x, frame_properties); | 2292 CONSOLE_HAS_METHOD (x, frame_properties); |
2225 CONSOLE_HAS_METHOD (x, set_frame_properties); | 2293 CONSOLE_HAS_METHOD (x, set_frame_properties); |
2226 CONSOLE_HAS_METHOD (x, set_title_from_char); | 2294 CONSOLE_HAS_METHOD (x, set_title_from_bufbyte); |
2227 CONSOLE_HAS_METHOD (x, set_icon_name_from_char); | 2295 CONSOLE_HAS_METHOD (x, set_icon_name_from_bufbyte); |
2228 CONSOLE_HAS_METHOD (x, frame_visible_p); | 2296 CONSOLE_HAS_METHOD (x, frame_visible_p); |
2229 CONSOLE_HAS_METHOD (x, frame_totally_visible_p); | 2297 CONSOLE_HAS_METHOD (x, frame_totally_visible_p); |
2230 CONSOLE_HAS_METHOD (x, frame_iconified_p); | 2298 CONSOLE_HAS_METHOD (x, frame_iconified_p); |
2231 CONSOLE_HAS_METHOD (x, set_frame_pointer); | 2299 CONSOLE_HAS_METHOD (x, set_frame_pointer); |
2232 CONSOLE_HAS_METHOD (x, set_frame_icon); | 2300 CONSOLE_HAS_METHOD (x, set_frame_icon); |