Mercurial > hg > xemacs-beta
comparison src/frame-x.c @ 20:859a2309aef8 r19-15b93
Import from CVS: tag r19-15b93
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:50:05 +0200 |
parents | 0293115a14e9 |
children | ec9a17fef872 |
comparison
equal
deleted
inserted
replaced
19:ac1f612d5250 | 20:859a2309aef8 |
---|---|
484 XGetWindowAttributes (d, w, &xwa); | 484 XGetWindowAttributes (d, w, &xwa); |
485 *x = xwa.x; | 485 *x = xwa.x; |
486 *y = xwa.y; | 486 *y = xwa.y; |
487 } | 487 } |
488 | 488 |
489 #if 0 | |
489 static void | 490 static void |
490 x_smash_bastardly_shell_position (Widget shell) | 491 x_smash_bastardly_shell_position (Widget shell) |
491 { | 492 { |
492 /* Naturally those bastards who wrote Xt couldn't be bothered | 493 /* Naturally those bastards who wrote Xt couldn't be bothered |
493 to learn about race conditions and such. We can't trust | 494 to learn about race conditions and such. We can't trust |
499 that case so we don't bother calling it. */ | 500 that case so we don't bother calling it. */ |
500 if (XtWindow (shell)) | 501 if (XtWindow (shell)) |
501 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), | 502 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), |
502 &shell->core.x, &shell->core.y); | 503 &shell->core.x, &shell->core.y); |
503 } | 504 } |
505 #endif /* 0 */ | |
504 | 506 |
505 static Lisp_Object | 507 static Lisp_Object |
506 x_frame_property (struct frame *f, Lisp_Object property) | 508 x_frame_property (struct frame *f, Lisp_Object property) |
507 { | 509 { |
508 Widget shell = FRAME_X_SHELL_WIDGET (f); | 510 Widget shell = FRAME_X_SHELL_WIDGET (f); |
510 Widget gw = (Widget) w; | 512 Widget gw = (Widget) w; |
511 | 513 |
512 #define FROB(propprop, value) \ | 514 #define FROB(propprop, value) \ |
513 do { \ | 515 do { \ |
514 if (EQ (property, propprop)) \ | 516 if (EQ (property, propprop)) \ |
515 { \ | 517 return (value); \ |
516 return (value); \ | |
517 } \ | |
518 } while (0) | 518 } while (0) |
519 | 519 |
520 #if 0 | |
520 if (EQ (property, Qleft) || EQ (property, Qtop)) | 521 if (EQ (property, Qleft) || EQ (property, Qtop)) |
521 x_smash_bastardly_shell_position (shell); | 522 x_smash_bastardly_shell_position (shell); |
523 #endif | |
524 if (EQ (property, Qleft) || EQ (property, Qtop)) | |
525 { | |
526 Position x, y; | |
527 if (!XtWindow(shell)) | |
528 return make_int (0); | |
529 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), &x, &y); | |
530 FROB (Qleft, make_int (x)); | |
531 FROB (Qtop, make_int (y)); | |
532 } | |
533 #if 0 | |
522 FROB (Qleft, make_int (shell->core.x)); | 534 FROB (Qleft, make_int (shell->core.x)); |
523 FROB (Qtop, make_int (shell->core.y)); | 535 FROB (Qtop, make_int (shell->core.y)); |
536 #endif | |
524 FROB (Qborder_width, make_int (w->core.border_width)); | 537 FROB (Qborder_width, make_int (w->core.border_width)); |
525 FROB (Qinternal_border_width, | 538 FROB (Qinternal_border_width, |
526 make_int (w->emacs_frame.internal_border_width)); | 539 make_int (w->emacs_frame.internal_border_width)); |
527 FROB (Qborder_color, color_to_string (gw, w->core.border_pixel)); | 540 FROB (Qborder_color, color_to_string (gw, w->core.border_pixel)); |
528 #ifdef HAVE_TOOLBARS | 541 #ifdef HAVE_TOOLBARS |
532 color_to_string (gw, w->emacs_frame.bottom_toolbar_shadow_pixel)); | 545 color_to_string (gw, w->emacs_frame.bottom_toolbar_shadow_pixel)); |
533 FROB (Qbackground_toolbar_color, | 546 FROB (Qbackground_toolbar_color, |
534 color_to_string (gw, w->emacs_frame.background_toolbar_pixel)); | 547 color_to_string (gw, w->emacs_frame.background_toolbar_pixel)); |
535 FROB (Qtoolbar_shadow_thickness, | 548 FROB (Qtoolbar_shadow_thickness, |
536 make_int (w->emacs_frame.toolbar_shadow_thickness)); | 549 make_int (w->emacs_frame.toolbar_shadow_thickness)); |
537 #endif | 550 #endif /* HAVE_TOOLBARS */ |
538 FROB (Qinter_line_space, make_int (w->emacs_frame.interline)); | 551 FROB (Qinter_line_space, make_int (w->emacs_frame.interline)); |
539 FROB (Qwindow_id, Fx_window_id (make_frame (f))); | 552 FROB (Qwindow_id, Fx_window_id (make_frame (f))); |
540 | 553 |
541 #undef FROB | 554 #undef FROB |
542 | 555 |
544 } | 557 } |
545 | 558 |
546 static int | 559 static int |
547 x_internal_frame_property_p (struct frame *f, Lisp_Object property) | 560 x_internal_frame_property_p (struct frame *f, Lisp_Object property) |
548 { | 561 { |
549 if (EQ (property, Qleft) | 562 return EQ (property, Qleft) |
550 || EQ (property, Qtop) | 563 || EQ (property, Qtop) |
551 || EQ (property, Qborder_width) | 564 || EQ (property, Qborder_width) |
552 || EQ (property, Qinternal_border_width) | 565 || EQ (property, Qinternal_border_width) |
553 || EQ (property, Qborder_color) | 566 || EQ (property, Qborder_color) |
554 #ifdef HAVE_TOOLBARS | 567 #ifdef HAVE_TOOLBARS |
555 || EQ (property, Qtop_toolbar_shadow_color) | 568 || EQ (property, Qtop_toolbar_shadow_color) |
556 || EQ (property, Qbottom_toolbar_shadow_color) | 569 || EQ (property, Qbottom_toolbar_shadow_color) |
557 || EQ (property, Qbackground_toolbar_color) | 570 || EQ (property, Qbackground_toolbar_color) |
558 || EQ (property, Qtoolbar_shadow_thickness) | 571 || EQ (property, Qtoolbar_shadow_thickness) |
559 #endif | 572 #endif |
560 || EQ (property, Qinter_line_space) | 573 || EQ (property, Qinter_line_space) |
561 || EQ (property, Qwindow_id) | 574 || EQ (property, Qwindow_id) |
562 || STRINGP (property)) | 575 || STRINGP (property); |
563 return 1; | |
564 | |
565 return 0; | |
566 } | 576 } |
567 | 577 |
568 static Lisp_Object | 578 static Lisp_Object |
569 x_frame_properties (struct frame *f) | 579 x_frame_properties (struct frame *f) |
570 { | 580 { |
571 Lisp_Object result = Qnil; | 581 Lisp_Object result = Qnil; |
572 Widget shell = FRAME_X_SHELL_WIDGET (f); | 582 Widget shell = FRAME_X_SHELL_WIDGET (f); |
573 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); | 583 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); |
574 Widget gw = (Widget) w; | 584 Widget gw = (Widget) w; |
585 Position x, y; | |
575 | 586 |
576 #define FROB(propprop, value) \ | 587 #define FROB(propprop, value) \ |
577 do { \ | 588 do { \ |
578 Lisp_Object temtem = (value); \ | 589 Lisp_Object temtem = (value); \ |
579 if (!NILP (temtem)) \ | 590 if (!NILP (temtem)) \ |
580 /* backwards order; we reverse it below */ \ | 591 /* backwards order; we reverse it below */ \ |
581 result = Fcons (temtem, Fcons (propprop, result)); \ | 592 result = Fcons (temtem, Fcons (propprop, result)); \ |
582 } while (0) | 593 } while (0) |
583 | 594 |
595 #if 0 | |
584 x_smash_bastardly_shell_position (shell); | 596 x_smash_bastardly_shell_position (shell); |
585 FROB (Qleft, make_int (shell->core.x)); | 597 FROB (Qleft, make_int (shell->core.x)); |
586 FROB (Qtop, make_int (shell->core.y)); | 598 FROB (Qtop, make_int (shell->core.y)); |
599 #endif | |
600 if (!XtWindow(shell)) | |
601 x = y = 0; | |
602 else | |
603 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), &x, &y); | |
604 | |
605 FROB (Qleft, make_int (x)); | |
606 FROB (Qtop, make_int (y)); | |
607 | |
587 FROB (Qborder_width, make_int (w->core.border_width)); | 608 FROB (Qborder_width, make_int (w->core.border_width)); |
588 FROB (Qinternal_border_width, | 609 FROB (Qinternal_border_width, |
589 make_int (w->emacs_frame.internal_border_width)); | 610 make_int (w->emacs_frame.internal_border_width)); |
590 FROB (Qborder_color, color_to_string (gw, w->core.border_pixel)); | 611 FROB (Qborder_color, color_to_string (gw, w->core.border_pixel)); |
591 #ifdef HAVE_TOOLBARS | 612 #ifdef HAVE_TOOLBARS |
595 color_to_string (gw, w->emacs_frame.bottom_toolbar_shadow_pixel)); | 616 color_to_string (gw, w->emacs_frame.bottom_toolbar_shadow_pixel)); |
596 FROB (Qbackground_toolbar_color, | 617 FROB (Qbackground_toolbar_color, |
597 color_to_string (gw, w->emacs_frame.background_toolbar_pixel)); | 618 color_to_string (gw, w->emacs_frame.background_toolbar_pixel)); |
598 FROB (Qtoolbar_shadow_thickness, | 619 FROB (Qtoolbar_shadow_thickness, |
599 make_int (w->emacs_frame.toolbar_shadow_thickness)); | 620 make_int (w->emacs_frame.toolbar_shadow_thickness)); |
600 #endif | 621 #endif /* HAVE_TOOLBARS */ |
601 FROB (Qinter_line_space, make_int (w->emacs_frame.interline)); | 622 FROB (Qinter_line_space, make_int (w->emacs_frame.interline)); |
602 FROB (Qwindow_id, Fx_window_id (make_frame (f))); | 623 FROB (Qwindow_id, Fx_window_id (make_frame (f))); |
603 | 624 |
604 #undef FROB | 625 #undef FROB |
605 | 626 |
616 String Xt_resource_encoding_name) | 637 String Xt_resource_encoding_name) |
617 { | 638 { |
618 Atom encoding = XA_STRING; | 639 Atom encoding = XA_STRING; |
619 String new_XtValue = (String) value; | 640 String new_XtValue = (String) value; |
620 String old_XtValue = NULL; | 641 String old_XtValue = NULL; |
621 Bufbyte *ptr; | |
622 Arg av[2]; | 642 Arg av[2]; |
623 | 643 |
624 /* ### Caching is device-independent - belongs in update_frame_title. */ | 644 /* ### Caching is device-independent - belongs in update_frame_title. */ |
625 XtSetArg (av[0], Xt_resource_name, &old_XtValue); | 645 XtSetArg (av[0], Xt_resource_name, &old_XtValue); |
626 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | 646 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); |
692 */ | 712 */ |
693 | 713 |
694 static void | 714 static void |
695 x_set_frame_properties (struct frame *f, Lisp_Object plist) | 715 x_set_frame_properties (struct frame *f, Lisp_Object plist) |
696 { | 716 { |
697 int x = 0, y = 0; | 717 Position x, y; |
698 Dimension width = 0, height = 0; | 718 Dimension width = 0, height = 0; |
699 Bool width_specified_p = False; | 719 Bool width_specified_p = False; |
700 Bool height_specified_p = False; | 720 Bool height_specified_p = False; |
701 Bool x_position_specified_p = False; | 721 Bool x_position_specified_p = False; |
702 Bool y_position_specified_p = False; | 722 Bool y_position_specified_p = False; |
779 } | 799 } |
780 /* Further kludge the x/y. */ | 800 /* Further kludge the x/y. */ |
781 if (!strcmp ((char *) XSTRING_DATA (str), "x")) | 801 if (!strcmp ((char *) XSTRING_DATA (str), "x")) |
782 { | 802 { |
783 CHECK_INT (val); | 803 CHECK_INT (val); |
784 x = XINT (val); | 804 x = (Position) XINT (val); |
785 x_position_specified_p = True; | 805 x_position_specified_p = True; |
786 continue; | 806 continue; |
787 } | 807 } |
788 if (!strcmp ((char *) XSTRING_DATA (str), "y")) | 808 if (!strcmp ((char *) XSTRING_DATA (str), "y")) |
789 { | 809 { |
790 CHECK_INT (val); | 810 CHECK_INT (val); |
791 y = XINT (val); | 811 y = (Position) XINT (val); |
792 y_position_specified_p = True; | 812 y_position_specified_p = True; |
793 continue; | 813 continue; |
794 } | 814 } |
795 /* Have you figured out by now that this entire function is | 815 /* Have you figured out by now that this entire function is |
796 one gigantic kludge? */ | 816 one gigantic kludge? */ |
835 || !strcmp ((char *) XSTRING_DATA (str), | 855 || !strcmp ((char *) XSTRING_DATA (str), |
836 "scrollBarHeight")) | 856 "scrollBarHeight")) |
837 { | 857 { |
838 x_update_frame_scrollbars (f); | 858 x_update_frame_scrollbars (f); |
839 } | 859 } |
840 #endif | 860 #endif /* HAVE_SCROLLBARS */ |
841 } | 861 } |
842 } | 862 } |
843 | 863 |
844 /* Kludge kludge kludge. We need to deal with the size and position | 864 /* Kludge kludge kludge. We need to deal with the size and position |
845 specially. */ | 865 specially. */ |
852 width = FRAME_WIDTH (f); | 872 width = FRAME_WIDTH (f); |
853 if (!height_specified_p) | 873 if (!height_specified_p) |
854 height = FRAME_HEIGHT (f); | 874 height = FRAME_HEIGHT (f); |
855 | 875 |
856 /* Kludge kludge kludge kludge. */ | 876 /* Kludge kludge kludge kludge. */ |
857 if (!x_position_specified_p) | 877 if (position_specified_p && |
858 x = (int) (FRAME_X_SHELL_WIDGET (f)->core.x); | 878 (!x_position_specified_p || !y_position_specified_p)) |
859 if (!y_position_specified_p) | 879 { |
860 y = (int) (FRAME_X_SHELL_WIDGET (f)->core.y); | 880 Position dummy; |
881 Widget shell = FRAME_X_SHELL_WIDGET (f); | |
882 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), | |
883 (x_position_specified_p ? &dummy : &x), | |
884 (y_position_specified_p ? &dummy : &y)); | |
885 #if 0 | |
886 x = (int) (FRAME_X_SHELL_WIDGET (f)->core.x); | |
887 y = (int) (FRAME_X_SHELL_WIDGET (f)->core.y); | |
888 #endif | |
889 } | |
861 | 890 |
862 if (!f->init_finished) | 891 if (!f->init_finished) |
863 { | 892 { |
864 int flags = (size_specified_p ? WidthValue | HeightValue : 0) | | 893 int flags = (size_specified_p ? WidthValue | HeightValue : 0) | |
865 (position_specified_p ? XValue | YValue : 0) | | 894 (position_specified_p ? |
866 (x < 0 ? XNegative : 0) | (y < 0 ? YNegative : 0); | 895 XValue | YValue | (x < 0 ? XNegative : 0) | (y < 0 ? YNegative : 0) |
896 : 0); | |
867 if (size_specified_p | 897 if (size_specified_p |
868 || position_specified_p | 898 || position_specified_p |
869 || internal_border_width_specified) | 899 || internal_border_width_specified) |
870 x_set_initial_frame_size (f, flags, x, y, width, height); | 900 x_set_initial_frame_size (f, flags, x, y, width, height); |
871 } | 901 } |
935 | 965 |
936 #ifdef HAVE_CDE | 966 #ifdef HAVE_CDE |
937 #include <Dt/Dt.h> | 967 #include <Dt/Dt.h> |
938 #include <Dt/Dnd.h> | 968 #include <Dt/Dnd.h> |
939 | 969 |
970 static Widget CurrentDragWidget = NULL; | |
971 | |
972 static void | |
973 x_cde_destroy_callback (Widget widget, XtPointer clientData, | |
974 XtPointer callData) | |
975 { | |
976 xfree (clientData); | |
977 CurrentDragWidget = NULL; | |
978 } | |
979 | |
980 static void | |
981 x_cde_convert_callback (Widget widget, XtPointer clientData, | |
982 XtPointer callData) | |
983 { | |
984 DtDndConvertCallbackStruct *convertInfo = | |
985 (DtDndConvertCallbackStruct *) callData; | |
986 char *textdata = (char *) clientData; | |
987 | |
988 if(convertInfo == NULL) | |
989 { | |
990 return; | |
991 } | |
992 | |
993 if((convertInfo->dragData->protocol != DtDND_BUFFER_TRANSFER) || | |
994 (convertInfo->reason != DtCR_DND_CONVERT_DATA)) | |
995 { | |
996 return; | |
997 } | |
998 | |
999 convertInfo->dragData->data.buffers[0].bp = XtNewString(textdata); | |
1000 convertInfo->dragData->data.buffers[0].size = strlen(textdata); | |
1001 convertInfo->dragData->data.buffers[0].name = NULL; | |
1002 convertInfo->dragData->numItems = 1; | |
1003 convertInfo->status = DtDND_SUCCESS; | |
1004 } | |
1005 | |
1006 | |
1007 static XtCallbackRec dnd_convert_cb_rec[2]; | |
1008 static XtCallbackRec dnd_destroy_cb_rec[2]; | |
1009 static int drag_not_done = 0; | |
1010 | |
1011 static Lisp_Object | |
1012 abort_current_drag(Lisp_Object arg) | |
1013 { | |
1014 if(CurrentDragWidget && drag_not_done) | |
1015 { | |
1016 XmDragCancel(CurrentDragWidget); | |
1017 CurrentDragWidget = NULL; | |
1018 } | |
1019 return arg; | |
1020 } | |
1021 | |
1022 DEFUN ("cde-start-drag-internal", Fcde_start_drag_internal, 1, 1, 0, /* | |
1023 Start a CDE drag from a buffer. | |
1024 */ | |
1025 (text)) | |
1026 { | |
1027 if (STRINGP (text)) | |
1028 { | |
1029 struct frame *f = decode_x_frame (Fselected_frame (Qnil)); | |
1030 XEvent event; | |
1031 Widget Wuh = FRAME_X_TEXT_WIDGET (f); | |
1032 char *Ctext; | |
1033 Display *display = XtDisplayOfObject (Wuh); | |
1034 Window root_window, child_window; | |
1035 int root_x, root_y, win_x, win_y; | |
1036 unsigned int keys_and_buttons; | |
1037 | |
1038 if (XQueryPointer (display, RootWindow (display, DefaultScreen (display)), | |
1039 &root_window, &child_window, &root_x, &root_y, | |
1040 &win_x, &win_y, &keys_and_buttons) == False) | |
1041 return Qnil; | |
1042 | |
1043 Ctext = xstrdup ((char *) XSTRING_DATA (text)); | |
1044 | |
1045 /* | |
1046 * Eek - XEmacs doesn't keep the old X event around so we have to | |
1047 * build a dummy event. This is a truly gross hack. | |
1048 */ | |
1049 | |
1050 event.xbutton.type = ButtonPress; | |
1051 event.xbutton.send_event = False; | |
1052 event.xbutton.display = XtDisplayOfObject(Wuh); | |
1053 event.xbutton.window = XtWindowOfObject(Wuh); | |
1054 event.xbutton.root = XRootWindow(event.xkey.display, 0); | |
1055 event.xbutton.subwindow = 0; | |
1056 event.xbutton.time = 0; | |
1057 event.xbutton.x = win_x; | |
1058 event.xbutton.y = win_y; | |
1059 event.xbutton.x_root = root_x; | |
1060 event.xbutton.y_root = root_y; | |
1061 event.xbutton.state = 0; | |
1062 event.xbutton.button = 1; | |
1063 event.xkey.same_screen = True; | |
1064 | |
1065 dnd_convert_cb_rec[0].callback = x_cde_convert_callback; | |
1066 dnd_convert_cb_rec[0].closure = (XtPointer) Ctext; | |
1067 dnd_convert_cb_rec[1].callback = NULL; | |
1068 dnd_convert_cb_rec[1].closure = NULL; | |
1069 | |
1070 dnd_destroy_cb_rec[0].callback = x_cde_destroy_callback; | |
1071 dnd_destroy_cb_rec[0].closure = (XtPointer) Ctext; | |
1072 dnd_destroy_cb_rec[1].callback = NULL; | |
1073 dnd_destroy_cb_rec[1].closure = NULL; | |
1074 | |
1075 CurrentDragWidget = | |
1076 DtDndDragStart (Wuh, &event, DtDND_BUFFER_TRANSFER, 1, XmDROP_COPY, | |
1077 dnd_convert_cb_rec, | |
1078 dnd_destroy_cb_rec, | |
1079 NULL, 0); | |
1080 return Qt; | |
1081 } | |
1082 return Qnil; | |
1083 } | |
1084 | |
940 void | 1085 void |
941 x_cde_transfer_callback (Widget widget, XtPointer clientData, | 1086 x_cde_transfer_callback (Widget widget, XtPointer clientData, |
942 XtPointer callData) | 1087 XtPointer callData) |
943 { | 1088 { |
944 char *filePath, *buf; | 1089 char *filePath, *buf; |
945 int ii; | 1090 int ii; |
946 Lisp_Object data = Qnil; | 1091 Lisp_Object path = Qnil; |
947 Lisp_Object path = Qnil; | |
948 Lisp_Object frame = Qnil; | 1092 Lisp_Object frame = Qnil; |
949 struct gcpro gcpro1, gcpro2; | 1093 Lisp_Object data = Qnil; |
1094 struct gcpro gcpro1, gcpro2, gcpro3; | |
950 | 1095 |
951 DtDndTransferCallbackStruct *transferInfo = | 1096 DtDndTransferCallbackStruct *transferInfo = |
952 (DtDndTransferCallbackStruct *) callData; | 1097 (DtDndTransferCallbackStruct *) callData; |
953 | 1098 |
954 if (transferInfo == NULL) | 1099 if (transferInfo == NULL) |
955 return; | 1100 return; |
956 | 1101 |
957 GCPRO2 (path, frame); | 1102 GCPRO3 (path, frame, data); |
958 | 1103 |
959 frame = make_frame ((struct frame *) clientData); | 1104 frame = make_frame ((struct frame *) clientData); |
960 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER) | 1105 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER) |
961 { | 1106 { |
962 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) | 1107 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) |
963 { | 1108 { |
964 filePath = transferInfo->dropData->data.files[ii]; | 1109 filePath = transferInfo->dropData->data.files[ii]; |
1110 /* ### Mule-izing required */ | |
965 path = make_string ((Bufbyte *)filePath, strlen (filePath)); | 1111 path = make_string ((Bufbyte *)filePath, strlen (filePath)); |
966 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); | 1112 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); |
967 } | 1113 } |
968 } | 1114 } |
969 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) | 1115 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) |
970 { | 1116 { |
1117 int speccount = specpdl_depth(); | |
1118 | |
1119 record_unwind_protect(abort_current_drag, Qnil); | |
1120 drag_not_done = 1; | |
971 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) | 1121 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) |
972 { | 1122 { |
973 filePath = transferInfo->dropData->data.buffers[ii].name; | 1123 filePath = transferInfo->dropData->data.buffers[ii].name; |
974 path = (filePath != NULL) ? | 1124 /* ### Mule-izing required */ |
975 make_string ((Bufbyte *)filePath, strlen (filePath)) : Qnil; | 1125 path = (filePath == NULL) ? Qnil |
1126 : make_string ((Bufbyte *)filePath, strlen (filePath)); | |
976 buf = transferInfo->dropData->data.buffers[ii].bp; | 1127 buf = transferInfo->dropData->data.buffers[ii].bp; |
977 data = make_string ((Bufbyte *)buf, | 1128 data = make_string ((Bufbyte *)buf, |
978 transferInfo->dropData->data.buffers[ii].size); | 1129 transferInfo->dropData->data.buffers[ii].size); |
979 va_run_hook_with_args(Qdrag_and_drop_functions, 3, frame, path, data); | 1130 va_run_hook_with_args(Qdrag_and_drop_functions, 3, frame, path, |
1131 data); | |
980 } | 1132 } |
1133 drag_not_done = 0; | |
1134 unbind_to(speccount, Qnil); | |
981 } | 1135 } |
982 | 1136 |
983 UNGCPRO; | 1137 UNGCPRO; |
984 return; | 1138 return; |
985 } | 1139 } |
986 #endif | 1140 #endif /* HAVE_CDE */ |
987 | 1141 |
988 #ifdef HAVE_OFFIX_DND | 1142 #ifdef HAVE_OFFIX_DND |
989 #include <OffiX/DragAndDrop.h> | 1143 #include <OffiX/DragAndDrop.h> |
990 | 1144 |
991 void | 1145 void |
1398 scrollbar_placement == XtBOTTOM_LEFT); | 1552 scrollbar_placement == XtBOTTOM_LEFT); |
1399 f->scrollbar_on_top = (scrollbar_placement == XtTOP_LEFT || | 1553 f->scrollbar_on_top = (scrollbar_placement == XtTOP_LEFT || |
1400 scrollbar_placement == XtTOP_RIGHT); | 1554 scrollbar_placement == XtTOP_RIGHT); |
1401 f->scrollbar_y_offset = topbreadth + textbord; | 1555 f->scrollbar_y_offset = topbreadth + textbord; |
1402 } | 1556 } |
1403 #endif | 1557 #endif /* HAVE_SCROLLBARS */ |
1404 | 1558 |
1405 /* finally the text area */ | 1559 /* finally the text area */ |
1406 XtConfigureWidget (text, text_x, text_y, | 1560 XtConfigureWidget (text, text_x, text_y, |
1407 width - 2*textbord, | 1561 width - 2*textbord, |
1408 height - text_y - 2*textbord, | 1562 height - text_y - 2*textbord, |
1421 XtWidgetGeometry req, repl; | 1575 XtWidgetGeometry req, repl; |
1422 int mask = emst->request_mode & (CWWidth | CWHeight); | 1576 int mask = emst->request_mode & (CWWidth | CWHeight); |
1423 | 1577 |
1424 x_get_layout_sizes (f, &topbreadth); | 1578 x_get_layout_sizes (f, &topbreadth); |
1425 | 1579 |
1426 /* strip away menubar from suggested size, and ask the text widget | 1580 /* Strip away menubar from suggested size, and ask the text widget |
1427 what size it wants to be */ | 1581 what size it wants to be. */ |
1428 req.request_mode = mask; | 1582 req.request_mode = mask; |
1429 if (mask & CWWidth) | 1583 if (mask & CWWidth) |
1430 req.width = emst->proposed_width - 2*textbord; | 1584 req.width = emst->proposed_width - 2*textbord; |
1431 if (mask & CWHeight) | 1585 if (mask & CWHeight) |
1432 req.height = emst->proposed_height - topbreadth - 2*textbord; | 1586 req.height = emst->proposed_height - topbreadth - 2*textbord; |
1433 XtQueryGeometry (text, &req, &repl); | 1587 XtQueryGeometry (text, &req, &repl); |
1434 | 1588 |
1435 /* Now add the menubar back again */ | 1589 /* Now add the menubar back again */ |
1436 emst->proposed_width = repl.width + 2*textbord; | 1590 emst->proposed_width = repl.width + 2*textbord; |
1437 emst->proposed_height = repl.height + topbreadth + 2*textbord; | 1591 emst->proposed_height = repl.height + topbreadth + 2*textbord; |
1438 } | 1592 } |
1439 | 1593 |
1440 /* Creates the widgets for a frame. | 1594 /* Creates the widgets for a frame. |
1441 lisp_window_id is a Lisp description of an X window or Xt | 1595 lisp_window_id is a Lisp description of an X window or Xt |
1525 if (window_id) | 1679 if (window_id) |
1526 { | 1680 { |
1527 XtSetArg (av[ac], XtNwindow, window_id); ac++; | 1681 XtSetArg (av[ac], XtNwindow, window_id); ac++; |
1528 } | 1682 } |
1529 else | 1683 else |
1530 #endif | 1684 #endif /* EXTERNAL_WIDGET */ |
1531 { | 1685 { |
1532 XtSetArg (av[ac], XtNinput, True); ac++; | 1686 XtSetArg (av[ac], XtNinput, True); ac++; |
1533 XtSetArg (av[ac], (String) XtNminWidthCells, 10); ac++; | 1687 XtSetArg (av[ac], (String) XtNminWidthCells, 10); ac++; |
1534 XtSetArg (av[ac], (String) XtNminHeightCells, 1); ac++; | 1688 XtSetArg (av[ac], (String) XtNminHeightCells, 1); ac++; |
1535 } | 1689 } |
1579 FRAME_X_TOP_WIDGETS (f)[0] = menubar = FRAME_X_MENUBAR_WIDGET (f); | 1733 FRAME_X_TOP_WIDGETS (f)[0] = menubar = FRAME_X_MENUBAR_WIDGET (f); |
1580 FRAME_X_NUM_TOP_WIDGETS (f) = 1; | 1734 FRAME_X_NUM_TOP_WIDGETS (f) = 1; |
1581 | 1735 |
1582 if (menubar_visible) | 1736 if (menubar_visible) |
1583 XtManageChild (menubar); | 1737 XtManageChild (menubar); |
1584 #endif | 1738 #endif /* HAVE_MENUBARS */ |
1585 XtManageChild (text); | 1739 XtManageChild (text); |
1586 XtManageChild (container); | 1740 XtManageChild (container); |
1587 } | 1741 } |
1588 | 1742 |
1589 /* We used to call XtPopup() in x_popup_frame, but that doesn't give | 1743 /* We used to call XtPopup() in x_popup_frame, but that doesn't give |
1624 | 1778 |
1625 #ifdef HAVE_CDE | 1779 #ifdef HAVE_CDE |
1626 /* Does this have to be non-automatic? */ | 1780 /* Does this have to be non-automatic? */ |
1627 /* hack frame to respond to dnd messages */ | 1781 /* hack frame to respond to dnd messages */ |
1628 static XtCallbackRec dnd_transfer_cb_rec[2]; | 1782 static XtCallbackRec dnd_transfer_cb_rec[2]; |
1629 #endif | 1783 #endif /* HAVE_CDE */ |
1630 | 1784 |
1631 /* create the windows for the specified frame and display them. | 1785 /* create the windows for the specified frame and display them. |
1632 Note that the widgets have already been created, and any | 1786 Note that the widgets have already been created, and any |
1633 necessary geometry calculations have already been done. */ | 1787 necessary geometry calculations have already been done. */ |
1634 static void | 1788 static void |
1679 XtAddEventHandler (shell_widget, /* the shell widget in question */ | 1833 XtAddEventHandler (shell_widget, /* the shell widget in question */ |
1680 (EventMask) NoEventMask,/* OR with existing mask */ | 1834 (EventMask) NoEventMask,/* OR with existing mask */ |
1681 True, /* called on non-maskable events? */ | 1835 True, /* called on non-maskable events? */ |
1682 _XEditResCheckMessages, /* the handler */ | 1836 _XEditResCheckMessages, /* the handler */ |
1683 NULL); | 1837 NULL); |
1684 #endif | 1838 #endif /* HACK_EDITRES */ |
1685 | 1839 |
1686 #ifdef HAVE_CDE | 1840 #ifdef HAVE_CDE |
1687 { | 1841 { |
1688 dnd_transfer_cb_rec[0].callback = x_cde_transfer_callback; | 1842 dnd_transfer_cb_rec[0].callback = x_cde_transfer_callback; |
1689 dnd_transfer_cb_rec[0].closure = (XtPointer) f; | 1843 dnd_transfer_cb_rec[0].closure = (XtPointer) f; |
1695 XmDROP_COPY, dnd_transfer_cb_rec, | 1849 XmDROP_COPY, dnd_transfer_cb_rec, |
1696 DtNtextIsBuffer, True, | 1850 DtNtextIsBuffer, True, |
1697 DtNpreserveRegistration, False, | 1851 DtNpreserveRegistration, False, |
1698 NULL); | 1852 NULL); |
1699 } | 1853 } |
1700 #endif | 1854 #endif /* HAVE_CDE */ |
1701 | 1855 |
1702 #ifdef HAVE_OFFIX_DND | 1856 #ifdef HAVE_OFFIX_DND |
1703 { | 1857 { |
1704 DndInitialize (FRAME_X_SHELL_WIDGET (f)); | 1858 DndInitialize (FRAME_X_SHELL_WIDGET (f)); |
1705 DndRegisterDropWidget (FRAME_X_TEXT_WIDGET (f), | 1859 DndRegisterDropWidget (FRAME_X_TEXT_WIDGET (f), |
1844 x_get_frame_parent (struct frame *f) | 1998 x_get_frame_parent (struct frame *f) |
1845 { | 1999 { |
1846 Widget parentwid = 0; | 2000 Widget parentwid = 0; |
1847 Arg av[1]; | 2001 Arg av[1]; |
1848 | 2002 |
2003 /* We may be passed a dangling deleted frame */ | |
2004 /* I do not know how to test for this. -sb */ | |
1849 XtSetArg (av[0], XtNtransientFor, &parentwid); | 2005 XtSetArg (av[0], XtNtransientFor, &parentwid); |
1850 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); | 2006 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); |
1851 /* find the frame whose wid is parentwid */ | 2007 /* find the frame whose wid is parentwid */ |
1852 if (parentwid) | 2008 if (parentwid) |
1853 { | 2009 { |
1860 } | 2016 } |
1861 } | 2017 } |
1862 return Qnil; | 2018 return Qnil; |
1863 } | 2019 } |
1864 | 2020 |
1865 DEFUN ("x-window-id", Fx_window_id, Sx_window_id, 0, 1, 0 /* | 2021 DEFUN ("x-window-id", Fx_window_id, 0, 1, 0, /* |
1866 Get the ID of the X11 window. | 2022 Get the ID of the X11 window. |
1867 This gives us a chance to manipulate the Emacs window from within a | 2023 This gives us a chance to manipulate the Emacs window from within a |
1868 different program. Since the ID is an unsigned long, we return it as | 2024 different program. Since the ID is an unsigned long, we return it as |
1869 a string. | 2025 a string. |
1870 */ ) | 2026 */ |
1871 (frame) | 2027 (frame)) |
1872 Lisp_Object frame; | |
1873 { | 2028 { |
1874 char str[255]; | 2029 char str[255]; |
1875 struct frame *f = decode_x_frame (frame); | 2030 struct frame *f = decode_x_frame (frame); |
1876 | 2031 |
1877 sprintf (str, "%lu", XtWindow (FRAME_X_TEXT_WIDGET (f))); | 2032 sprintf (str, "%lu", XtWindow (FRAME_X_TEXT_WIDGET (f))); |
1886 static void | 2041 static void |
1887 x_set_frame_position (struct frame *f, int xoff, int yoff) | 2042 x_set_frame_position (struct frame *f, int xoff, int yoff) |
1888 { | 2043 { |
1889 Widget w = FRAME_X_SHELL_WIDGET (f); | 2044 Widget w = FRAME_X_SHELL_WIDGET (f); |
1890 Display *dpy = XtDisplay (w); | 2045 Display *dpy = XtDisplay (w); |
1891 Dimension frame_w = DisplayWidth (dpy, DefaultScreen (dpy)); | 2046 Dimension frame_w = DisplayWidth (dpy, DefaultScreen (dpy)); |
1892 Dimension frame_h = DisplayHeight (dpy, DefaultScreen (dpy)); | 2047 Dimension frame_h = DisplayHeight (dpy, DefaultScreen (dpy)); |
1893 Dimension shell_w, shell_h, shell_bord; | 2048 Dimension shell_w, shell_h, shell_bord; |
1894 int win_gravity; | 2049 int win_gravity; |
1895 | 2050 |
1896 XtVaGetValues (w, | 2051 XtVaGetValues (w, |
1897 XtNwidth, &shell_w, | 2052 XtNwidth, &shell_w, |
1898 XtNheight, &shell_h, | 2053 XtNheight, &shell_h, |
1899 XtNborderWidth, &shell_bord, | 2054 XtNborderWidth, &shell_bord, |
1900 0); | 2055 0); |
1901 | 2056 |
1902 win_gravity = | 2057 win_gravity = |
1903 xoff >= 0 && yoff >= 0 ? NorthWestGravity : | 2058 xoff >= 0 && yoff >= 0 ? NorthWestGravity : |
1916 XtVaSetValues (w, | 2071 XtVaSetValues (w, |
1917 XtNwinGravity, win_gravity, | 2072 XtNwinGravity, win_gravity, |
1918 XtNx, xoff, | 2073 XtNx, xoff, |
1919 XtNy, yoff, | 2074 XtNy, yoff, |
1920 0); | 2075 0); |
2076 | |
1921 /* Sometimes you will find that | 2077 /* Sometimes you will find that |
1922 | 2078 |
1923 (set-frame-position (selected-frame) -50 -50) | 2079 (set-frame-position (selected-frame) -50 -50) |
1924 | 2080 |
1925 doesn't put the frame where you expect it to: | 2081 doesn't put the frame where you expect it to: i.e. it's closer to |
1926 i.e. it's closer to the lower-right corner than | 2082 the lower-right corner than it should be, and it appears that the |
1927 it should be, and it appears that the size of | 2083 size of the WM decorations was not taken into account. This is |
1928 the WM decorations was not taken into account. | 2084 *not* a problem with this function. Both mwm and twm have bugs |
1929 This is *not* a problem with this function. | 2085 in handling this situation. (mwm ignores the window gravity and |
1930 Both mwm and twm have bugs in handling this | 2086 always assumes NorthWest, except the first time you map the |
1931 situation. (mwm ignores the window gravity | 2087 window; twm gets things almost right, but forgets to account for |
1932 and always assumes NorthWest, except the first | 2088 the border width of the top-level window.) This function does |
1933 time you map the window; twm gets things almost | 2089 what it's supposed to according to the ICCCM, and I'm not about |
1934 right, but forgets to account for the border | 2090 to hack around window-manager bugs. */ |
1935 width of the top-level window.) This function | |
1936 does what it's supposed to according to the ICCCM, | |
1937 and I'm not about to hack around window-manager | |
1938 bugs. */ | |
1939 | 2091 |
1940 #if 0 | 2092 #if 0 |
1941 /* This is not necessary under either mwm or twm */ | 2093 /* This is not necessary under either mwm or twm */ |
1942 x_wm_mark_shell_position_user_specified (w); | 2094 x_wm_mark_shell_position_user_specified (w); |
1943 #endif | 2095 #endif |
2265 { | 2417 { |
2266 defsymbol (&Qwindow_id, "window-id"); | 2418 defsymbol (&Qwindow_id, "window-id"); |
2267 defsymbol (&Qpopup, "popup"); | 2419 defsymbol (&Qpopup, "popup"); |
2268 defsymbol (&Qx_resource_name, "x-resource-name"); | 2420 defsymbol (&Qx_resource_name, "x-resource-name"); |
2269 | 2421 |
2270 defsubr (&Sx_window_id); | 2422 DEFSUBR (Fx_window_id); |
2423 #ifdef HAVE_CDE | |
2424 DEFSUBR (Fcde_start_drag_internal); | |
2425 #endif | |
2271 } | 2426 } |
2272 | 2427 |
2273 void | 2428 void |
2274 console_type_create_frame_x (void) | 2429 console_type_create_frame_x (void) |
2275 { | 2430 { |