Mercurial > emacs
comparison src/xterm.c @ 49322:2cbb0b823e83
GTK version
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sun, 19 Jan 2003 21:50:03 +0000 |
parents | f8288cd7d1cd |
children | f5372eee5041 |
comparison
equal
deleted
inserted
replaced
49321:2b92ca3f78f6 | 49322:2cbb0b823e83 |
---|---|
95 #endif | 95 #endif |
96 #ifdef HAVE_UNISTD_H | 96 #ifdef HAVE_UNISTD_H |
97 #include <unistd.h> | 97 #include <unistd.h> |
98 #endif | 98 #endif |
99 | 99 |
100 #ifdef USE_GTK | |
101 #include "gtkutil.h" | |
102 #endif | |
103 | |
100 #ifdef USE_LUCID | 104 #ifdef USE_LUCID |
101 extern int xlwmenu_window_p P_ ((Widget w, Window window)); | 105 extern int xlwmenu_window_p P_ ((Widget w, Window window)); |
102 extern void xlwmenu_redisplay P_ ((Widget)); | 106 extern void xlwmenu_redisplay P_ ((Widget)); |
103 #endif | 107 #endif |
104 | 108 |
105 #ifdef USE_X_TOOLKIT | 109 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
106 | 110 |
107 extern void free_frame_menubar P_ ((struct frame *)); | 111 extern void free_frame_menubar P_ ((struct frame *)); |
108 extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *, | 112 extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *, |
109 int)); | 113 int)); |
110 | 114 #endif |
115 | |
116 #ifdef USE_X_TOOLKIT | |
111 #if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES) | 117 #if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES) |
112 #define HACK_EDITRES | 118 #define HACK_EDITRES |
113 extern void _XEditResCheckMessages (); | 119 extern void _XEditResCheckMessages (); |
114 #endif /* not NO_EDITRES */ | 120 #endif /* not NO_EDITRES */ |
115 | 121 |
136 #endif /* !USE_MOTIF */ | 142 #endif /* !USE_MOTIF */ |
137 #endif /* USE_TOOLKIT_SCROLL_BARS */ | 143 #endif /* USE_TOOLKIT_SCROLL_BARS */ |
138 | 144 |
139 #endif /* USE_X_TOOLKIT */ | 145 #endif /* USE_X_TOOLKIT */ |
140 | 146 |
141 #ifndef USE_X_TOOLKIT | 147 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) |
142 #define x_any_window_to_frame x_window_to_frame | 148 #define x_any_window_to_frame x_window_to_frame |
143 #define x_top_window_to_frame x_window_to_frame | 149 #define x_top_window_to_frame x_window_to_frame |
144 #endif | 150 #endif |
145 | 151 |
146 #ifdef USE_X_TOOLKIT | 152 #ifdef USE_X_TOOLKIT |
518 enum scroll_bar_part *, | 524 enum scroll_bar_part *, |
519 Lisp_Object *, Lisp_Object *, | 525 Lisp_Object *, Lisp_Object *, |
520 unsigned long *)); | 526 unsigned long *)); |
521 static void x_check_fullscreen P_ ((struct frame *)); | 527 static void x_check_fullscreen P_ ((struct frame *)); |
522 static void x_check_fullscreen_move P_ ((struct frame *)); | 528 static void x_check_fullscreen_move P_ ((struct frame *)); |
529 static int handle_one_xevent P_ ((struct x_display_info *, | |
530 XEvent *, | |
531 struct input_event **, | |
532 int *, | |
533 int *)); | |
534 | |
523 | 535 |
524 /* Flush display of frame F, or of all frames if F is null. */ | 536 /* Flush display of frame F, or of all frames if F is null. */ |
525 | 537 |
526 static void | 538 static void |
527 x_flush (f) | 539 x_flush (f) |
4328 int height; | 4340 int height; |
4329 Pixmap pixmap = None; | 4341 Pixmap pixmap = None; |
4330 | 4342 |
4331 height = s->height - 2 * box_line_vwidth; | 4343 height = s->height - 2 * box_line_vwidth; |
4332 | 4344 |
4345 | |
4333 /* Fill background with face under the image. Do it only if row is | 4346 /* Fill background with face under the image. Do it only if row is |
4334 taller than image or if image has a clip mask to reduce | 4347 taller than image or if image has a clip mask to reduce |
4335 flickering. */ | 4348 flickering. */ |
4336 s->stippled_p = s->face->stipple != 0; | 4349 s->stippled_p = s->face->stipple != 0; |
4337 if (height > s->img->height | 4350 if (height > s->img->height |
7072 struct window *w; | 7085 struct window *w; |
7073 Cursor cursor = None; | 7086 Cursor cursor = None; |
7074 struct buffer *b; | 7087 struct buffer *b; |
7075 | 7088 |
7076 /* When a menu is active, don't highlight because this looks odd. */ | 7089 /* When a menu is active, don't highlight because this looks odd. */ |
7077 #ifdef USE_X_TOOLKIT | 7090 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
7078 if (popup_activated ()) | 7091 if (popup_activated ()) |
7079 return; | 7092 return; |
7080 #endif | 7093 #endif |
7081 | 7094 |
7082 if (NILP (Vmouse_highlight) | 7095 if (NILP (Vmouse_highlight) |
8397 | 8410 |
8398 static void | 8411 static void |
8399 x_process_timeouts (timer) | 8412 x_process_timeouts (timer) |
8400 struct atimer *timer; | 8413 struct atimer *timer; |
8401 { | 8414 { |
8402 if (toolkit_scroll_bar_interaction || popup_activated_flag) | 8415 if (toolkit_scroll_bar_interaction || popup_activated ()) |
8403 { | 8416 { |
8404 BLOCK_INPUT; | 8417 BLOCK_INPUT; |
8405 while (XtAppPending (Xt_app_con) & XtIMTimer) | 8418 while (XtAppPending (Xt_app_con) & XtIMTimer) |
8406 XtAppProcessEvent (Xt_app_con, XtIMTimer); | 8419 XtAppProcessEvent (Xt_app_con, XtIMTimer); |
8407 UNBLOCK_INPUT; | 8420 UNBLOCK_INPUT; |
8492 struct scroll_bar *)); | 8505 struct scroll_bar *)); |
8493 static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, | 8506 static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, |
8494 int, int, int)); | 8507 int, int, int)); |
8495 | 8508 |
8496 | 8509 |
8497 /* Id of action hook installed for scroll bars. */ | |
8498 | |
8499 static XtActionHookId action_hook_id; | |
8500 | |
8501 /* Lisp window being scrolled. Set when starting to interact with | 8510 /* Lisp window being scrolled. Set when starting to interact with |
8502 a toolkit scroll bar, reset to nil when ending the interaction. */ | 8511 a toolkit scroll bar, reset to nil when ending the interaction. */ |
8503 | 8512 |
8504 static Lisp_Object window_being_scrolled; | 8513 static Lisp_Object window_being_scrolled; |
8505 | 8514 |
8507 | 8516 |
8508 static int last_scroll_bar_part; | 8517 static int last_scroll_bar_part; |
8509 | 8518 |
8510 /* Whether this is an Xaw with arrow-scrollbars. This should imply | 8519 /* Whether this is an Xaw with arrow-scrollbars. This should imply |
8511 that movements of 1/20 of the screen size are mapped to up/down. */ | 8520 that movements of 1/20 of the screen size are mapped to up/down. */ |
8521 | |
8522 #ifndef USE_GTK | |
8523 /* Id of action hook installed for scroll bars. */ | |
8524 | |
8525 static XtActionHookId action_hook_id; | |
8512 | 8526 |
8513 static Boolean xaw3d_arrow_scroll; | 8527 static Boolean xaw3d_arrow_scroll; |
8514 | 8528 |
8515 /* Whether the drag scrolling maintains the mouse at the top of the | 8529 /* Whether the drag scrolling maintains the mouse at the top of the |
8516 thumb. If not, resizing the thumb needs to be done more carefully | 8530 thumb. If not, resizing the thumb needs to be done more carefully |
8560 | 8574 |
8561 /* Xt timeouts no longer needed. */ | 8575 /* Xt timeouts no longer needed. */ |
8562 toolkit_scroll_bar_interaction = 0; | 8576 toolkit_scroll_bar_interaction = 0; |
8563 } | 8577 } |
8564 } | 8578 } |
8579 #endif /* not USE_GTK */ | |
8565 | 8580 |
8566 /* A vector of windows used for communication between | 8581 /* A vector of windows used for communication between |
8567 x_send_scroll_bar_event and x_scroll_bar_to_input_event. */ | 8582 x_send_scroll_bar_event and x_scroll_bar_to_input_event. */ |
8568 | 8583 |
8569 static struct window **scroll_bar_windows; | 8584 static struct window **scroll_bar_windows; |
8653 f = XFRAME (w->frame); | 8668 f = XFRAME (w->frame); |
8654 | 8669 |
8655 ievent->kind = SCROLL_BAR_CLICK_EVENT; | 8670 ievent->kind = SCROLL_BAR_CLICK_EVENT; |
8656 ievent->frame_or_window = window; | 8671 ievent->frame_or_window = window; |
8657 ievent->arg = Qnil; | 8672 ievent->arg = Qnil; |
8673 #ifdef USE_GTK | |
8674 ievent->timestamp = CurrentTime; | |
8675 #else | |
8658 ievent->timestamp = XtLastTimestampProcessed (FRAME_X_DISPLAY (f)); | 8676 ievent->timestamp = XtLastTimestampProcessed (FRAME_X_DISPLAY (f)); |
8677 #endif | |
8659 ievent->part = ev->data.l[1]; | 8678 ievent->part = ev->data.l[1]; |
8660 ievent->code = ev->data.l[2]; | 8679 ievent->code = ev->data.l[2]; |
8661 ievent->x = make_number ((int) ev->data.l[3]); | 8680 ievent->x = make_number ((int) ev->data.l[3]); |
8662 ievent->y = make_number ((int) ev->data.l[4]); | 8681 ievent->y = make_number ((int) ev->data.l[4]); |
8663 ievent->modifiers = 0; | 8682 ievent->modifiers = 0; |
8747 x_send_scroll_bar_event (bar->window, part, portion, whole); | 8766 x_send_scroll_bar_event (bar->window, part, portion, whole); |
8748 } | 8767 } |
8749 } | 8768 } |
8750 | 8769 |
8751 | 8770 |
8752 #else /* !USE_MOTIF, i.e. Xaw. */ | 8771 #else /* !USE_MOTIF, i.e. Xaw or GTK */ |
8753 | 8772 #ifdef USE_GTK |
8773 /* Scroll bar callback for Gtk scroll bars. WIDGET is the scroll | |
8774 bar adjustment widget. DATA is a pointer to the scroll_bar structure. */ | |
8775 | |
8776 static void | |
8777 xg_scroll_callback (widget, data) | |
8778 GtkWidget *widget; | |
8779 gpointer data; | |
8780 { | |
8781 struct scroll_bar *bar = (struct scroll_bar *) data; | |
8782 gdouble previous; | |
8783 gdouble position; | |
8784 gdouble *p; | |
8785 int diff; | |
8786 | |
8787 int part = -1, whole = 0, portion = 0; | |
8788 GtkAdjustment *adj = GTK_ADJUSTMENT (widget); | |
8789 | |
8790 if (xg_ignore_gtk_scrollbar) return; | |
8791 | |
8792 position = gtk_adjustment_get_value (adj); | |
8793 | |
8794 p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA); | |
8795 if (! p) | |
8796 { | |
8797 p = (gdouble*) xmalloc (sizeof (gdouble)); | |
8798 *p = XG_SB_MIN; | |
8799 g_object_set_data (G_OBJECT (widget), XG_LAST_SB_DATA, p); | |
8800 } | |
8801 | |
8802 previous = *p; | |
8803 *p = position; | |
8804 | |
8805 diff = (int) (position - previous); | |
8806 | |
8807 if (diff == (int) adj->step_increment) | |
8808 { | |
8809 part = scroll_bar_down_arrow; | |
8810 bar->dragging = Qnil; | |
8811 } | |
8812 else if (-diff == (int) adj->step_increment) | |
8813 { | |
8814 part = scroll_bar_up_arrow; | |
8815 bar->dragging = Qnil; | |
8816 } | |
8817 else if (diff == (int) adj->page_increment) | |
8818 { | |
8819 part = scroll_bar_below_handle; | |
8820 bar->dragging = Qnil; | |
8821 } | |
8822 else if (-diff == (int) adj->page_increment) | |
8823 { | |
8824 part = scroll_bar_above_handle; | |
8825 bar->dragging = Qnil; | |
8826 } | |
8827 else | |
8828 { | |
8829 part = scroll_bar_handle; | |
8830 whole = adj->upper - adj->page_size; | |
8831 portion = min (position, whole); | |
8832 bar->dragging = make_number (portion); | |
8833 } | |
8834 | |
8835 if (part >= 0) | |
8836 { | |
8837 xg_ignore_next_thumb = 1; | |
8838 window_being_scrolled = bar->window; | |
8839 last_scroll_bar_part = part; | |
8840 x_send_scroll_bar_event (bar->window, part, portion, whole); | |
8841 } | |
8842 } | |
8843 | |
8844 #else /* not USE_GTK */ | |
8754 | 8845 |
8755 /* Xaw scroll bar callback. Invoked when the thumb is dragged. | 8846 /* Xaw scroll bar callback. Invoked when the thumb is dragged. |
8756 WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the | 8847 WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the |
8757 scroll bar struct. CALL_DATA is a pointer to a float saying where | 8848 scroll bar struct. CALL_DATA is a pointer to a float saying where |
8758 the thumb is. */ | 8849 the thumb is. */ |
8831 bar->dragging = Qnil; | 8922 bar->dragging = Qnil; |
8832 last_scroll_bar_part = part; | 8923 last_scroll_bar_part = part; |
8833 x_send_scroll_bar_event (bar->window, part, position, height); | 8924 x_send_scroll_bar_event (bar->window, part, position, height); |
8834 } | 8925 } |
8835 | 8926 |
8836 | 8927 #endif /* not USE_GTK */ |
8837 #endif /* not USE_MOTIF */ | 8928 #endif /* not USE_MOTIF */ |
8838 | 8929 |
8930 #define SCROLL_BAR_NAME "verticalScrollBar" | |
8839 | 8931 |
8840 /* Create the widget for scroll bar BAR on frame F. Record the widget | 8932 /* Create the widget for scroll bar BAR on frame F. Record the widget |
8841 and X window of the scroll bar in BAR. */ | 8933 and X window of the scroll bar in BAR. */ |
8842 | 8934 |
8935 #ifdef USE_GTK | |
8843 static void | 8936 static void |
8844 x_create_toolkit_scroll_bar (f, bar) | 8937 x_create_toolkit_scroll_bar (f, bar) |
8845 struct frame *f; | 8938 struct frame *f; |
8846 struct scroll_bar *bar; | 8939 struct scroll_bar *bar; |
8847 { | 8940 { |
8941 char *scroll_bar_name = SCROLL_BAR_NAME; | |
8942 | |
8943 BLOCK_INPUT; | |
8944 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback), | |
8945 scroll_bar_name); | |
8946 UNBLOCK_INPUT; | |
8947 } | |
8948 | |
8949 #else /* not USE_GTK */ | |
8950 | |
8951 static void | |
8952 x_create_toolkit_scroll_bar (f, bar) | |
8953 struct frame *f; | |
8954 struct scroll_bar *bar; | |
8955 { | |
8848 Window xwindow; | 8956 Window xwindow; |
8849 Widget widget; | 8957 Widget widget; |
8850 Arg av[20]; | 8958 Arg av[20]; |
8851 int ac = 0; | 8959 int ac = 0; |
8852 char *scroll_bar_name = "verticalScrollBar"; | 8960 char *scroll_bar_name = SCROLL_BAR_NAME; |
8853 unsigned long pixel; | 8961 unsigned long pixel; |
8854 | 8962 |
8855 BLOCK_INPUT; | 8963 BLOCK_INPUT; |
8856 | 8964 |
8857 #ifdef USE_MOTIF | 8965 #ifdef USE_MOTIF |
9020 xwindow = XtWindow (widget); | 9128 xwindow = XtWindow (widget); |
9021 SET_SCROLL_BAR_X_WINDOW (bar, xwindow); | 9129 SET_SCROLL_BAR_X_WINDOW (bar, xwindow); |
9022 | 9130 |
9023 UNBLOCK_INPUT; | 9131 UNBLOCK_INPUT; |
9024 } | 9132 } |
9133 #endif /* not USE_GTK */ | |
9025 | 9134 |
9026 | 9135 |
9027 /* Set the thumb size and position of scroll bar BAR. We are currently | 9136 /* Set the thumb size and position of scroll bar BAR. We are currently |
9028 displaying PORTION out of a whole WHOLE, and our position POSITION. */ | 9137 displaying PORTION out of a whole WHOLE, and our position POSITION. */ |
9029 | 9138 |
9139 #ifdef USE_GTK | |
9140 static void | |
9141 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | |
9142 struct scroll_bar *bar; | |
9143 int portion, position, whole; | |
9144 { | |
9145 xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); | |
9146 } | |
9147 | |
9148 #else /* not USE_GTK */ | |
9030 static void | 9149 static void |
9031 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | 9150 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) |
9032 struct scroll_bar *bar; | 9151 struct scroll_bar *bar; |
9033 int portion, position, whole; | 9152 int portion, position, whole; |
9034 { | 9153 { |
9147 } | 9266 } |
9148 #endif /* !USE_MOTIF */ | 9267 #endif /* !USE_MOTIF */ |
9149 | 9268 |
9150 UNBLOCK_INPUT; | 9269 UNBLOCK_INPUT; |
9151 } | 9270 } |
9271 #endif /* not USE_GTK */ | |
9152 | 9272 |
9153 #endif /* USE_TOOLKIT_SCROLL_BARS */ | 9273 #endif /* USE_TOOLKIT_SCROLL_BARS */ |
9154 | 9274 |
9155 | 9275 |
9156 | 9276 |
9235 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); | 9355 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); |
9236 | 9356 |
9237 /* Map the window/widget. */ | 9357 /* Map the window/widget. */ |
9238 #ifdef USE_TOOLKIT_SCROLL_BARS | 9358 #ifdef USE_TOOLKIT_SCROLL_BARS |
9239 { | 9359 { |
9360 #ifdef USE_GTK | |
9361 xg_update_scrollbar_pos (f, | |
9362 SCROLL_BAR_X_WINDOW (bar), | |
9363 top, | |
9364 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | |
9365 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | |
9366 max (height, 1)); | |
9367 xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar)); | |
9368 #else /* not USE_GTK */ | |
9240 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); | 9369 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); |
9241 XtConfigureWidget (scroll_bar, | 9370 XtConfigureWidget (scroll_bar, |
9242 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | 9371 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, |
9243 top, | 9372 top, |
9244 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | 9373 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, |
9245 max (height, 1), 0); | 9374 max (height, 1), 0); |
9246 XtMapWidget (scroll_bar); | 9375 XtMapWidget (scroll_bar); |
9376 #endif /* not USE_GTK */ | |
9247 } | 9377 } |
9248 #else /* not USE_TOOLKIT_SCROLL_BARS */ | 9378 #else /* not USE_TOOLKIT_SCROLL_BARS */ |
9249 XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); | 9379 XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); |
9250 #endif /* not USE_TOOLKIT_SCROLL_BARS */ | 9380 #endif /* not USE_TOOLKIT_SCROLL_BARS */ |
9251 | 9381 |
9376 { | 9506 { |
9377 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 9507 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
9378 BLOCK_INPUT; | 9508 BLOCK_INPUT; |
9379 | 9509 |
9380 #ifdef USE_TOOLKIT_SCROLL_BARS | 9510 #ifdef USE_TOOLKIT_SCROLL_BARS |
9511 #ifdef USE_GTK | |
9512 xg_remove_scroll_bar (f, SCROLL_BAR_X_WINDOW (bar)); | |
9513 #else /* not USE_GTK */ | |
9381 XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); | 9514 XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); |
9515 #endif /* not USE_GTK */ | |
9382 #else | 9516 #else |
9383 XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); | 9517 XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); |
9384 #endif | 9518 #endif |
9385 | 9519 |
9386 /* Disassociate this scroll bar from its window. */ | 9520 /* Disassociate this scroll bar from its window. */ |
9470 if (height != XINT (bar->height)) | 9604 if (height != XINT (bar->height)) |
9471 mask |= CWHeight; | 9605 mask |= CWHeight; |
9472 | 9606 |
9473 #ifdef USE_TOOLKIT_SCROLL_BARS | 9607 #ifdef USE_TOOLKIT_SCROLL_BARS |
9474 | 9608 |
9609 #ifdef USE_GTK | |
9610 if (mask) | |
9611 xg_update_scrollbar_pos (f, | |
9612 SCROLL_BAR_X_WINDOW (bar), | |
9613 top, | |
9614 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | |
9615 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | |
9616 max (height, 1)); | |
9617 #else /* not USE_GTK */ | |
9618 | |
9475 /* Since toolkit scroll bars are smaller than the space reserved | 9619 /* Since toolkit scroll bars are smaller than the space reserved |
9476 for them on the frame, we have to clear "under" them. */ | 9620 for them on the frame, we have to clear "under" them. */ |
9477 if (width > 0 && height > 0) | 9621 if (width > 0 && height > 0) |
9478 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 9622 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
9479 left, top, width, height, False); | 9623 left, top, width, height, False); |
9480 | |
9481 /* Move/size the scroll bar widget. */ | 9624 /* Move/size the scroll bar widget. */ |
9482 if (mask) | 9625 if (mask) |
9483 XtConfigureWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar), | 9626 XtConfigureWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar), |
9484 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | 9627 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, |
9485 top, | 9628 top, |
9486 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | 9629 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, |
9487 max (height, 1), 0); | 9630 max (height, 1), 0); |
9488 | 9631 |
9632 #endif /* not USE_GTK */ | |
9489 #else /* not USE_TOOLKIT_SCROLL_BARS */ | 9633 #else /* not USE_TOOLKIT_SCROLL_BARS */ |
9490 | 9634 |
9491 /* Clear areas not covered by the scroll bar because of | 9635 /* Clear areas not covered by the scroll bar because of |
9492 VERTICAL_SCROLL_BAR_WIDTH_TRIM. */ | 9636 VERTICAL_SCROLL_BAR_WIDTH_TRIM. */ |
9493 if (VERTICAL_SCROLL_BAR_WIDTH_TRIM) | 9637 if (VERTICAL_SCROLL_BAR_WIDTH_TRIM) |
10068 X_EVENT_NORMAL, | 10212 X_EVENT_NORMAL, |
10069 X_EVENT_GOTO_OUT, | 10213 X_EVENT_GOTO_OUT, |
10070 X_EVENT_DROP | 10214 X_EVENT_DROP |
10071 }; | 10215 }; |
10072 | 10216 |
10217 #ifdef USE_GTK | |
10218 static struct x_display_info *current_dpyinfo; | |
10219 static struct input_event **current_bufp; | |
10220 static int *current_numcharsp; | |
10221 static int current_count; | |
10222 static int current_finish; | |
10223 | |
10224 /* This is the filter function invoked by the GTK event loop. | |
10225 It is invoked before the XEvent is translated to a GdkEvent, | |
10226 so we have a chanse to act on the event before GTK. */ | |
10227 static GdkFilterReturn | |
10228 event_handler_gdk (gxev, ev, data) | |
10229 GdkXEvent *gxev; | |
10230 GdkEvent *ev; | |
10231 gpointer data; | |
10232 { | |
10233 XEvent *xev = (XEvent*)gxev; | |
10234 | |
10235 if (current_numcharsp) | |
10236 current_count += handle_one_xevent (current_dpyinfo, | |
10237 xev, | |
10238 current_bufp, | |
10239 current_numcharsp, | |
10240 ¤t_finish); | |
10241 else | |
10242 x_dispatch_event (xev, GDK_DISPLAY ()); | |
10243 | |
10244 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP) | |
10245 return GDK_FILTER_REMOVE; | |
10246 | |
10247 return GDK_FILTER_CONTINUE; | |
10248 } | |
10249 #endif /* USE_GTK */ | |
10250 | |
10251 | |
10073 /* Handles the XEvent EVENT on display DPYINFO. | 10252 /* Handles the XEvent EVENT on display DPYINFO. |
10074 | 10253 |
10075 *FINISH is X_EVENT_GOTO_OUT if caller should stop reading events. | 10254 *FINISH is X_EVENT_GOTO_OUT if caller should stop reading events. |
10076 *FINISH is zero if caller should continue reading events. | 10255 *FINISH is zero if caller should continue reading events. |
10077 *FINISH is X_EVENT_DROP if event should not be passed to the toolkit. | 10256 *FINISH is X_EVENT_DROP if event should not be passed to the toolkit. |
10078 | 10257 |
10079 Events representing keys are stored in buffer *BUFP_R, | 10258 Events representing keys are stored in buffer *BUFP_R, |
10080 which can hold up to *NUMCHARSP characters. | 10259 which can hold up to *NUMCHARSP characters. |
10081 We return the number of characters stored into the buffer. */ | 10260 We return the number of characters stored into the buffer. */ |
10082 | 10261 |
10083 static int | 10262 static int |
10084 handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish) | 10263 handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish) |
10085 struct x_display_info *dpyinfo; | 10264 struct x_display_info *dpyinfo; |
10086 XEvent *eventp; | 10265 XEvent *eventp; |
10087 /* register */ struct input_event **bufp_r; | 10266 /* register */ struct input_event **bufp_r; |
10095 struct input_event *bufp = *bufp_r; | 10274 struct input_event *bufp = *bufp_r; |
10096 int numchars = *numcharsp; | 10275 int numchars = *numcharsp; |
10097 XEvent event = *eventp; | 10276 XEvent event = *eventp; |
10098 | 10277 |
10099 *finish = X_EVENT_NORMAL; | 10278 *finish = X_EVENT_NORMAL; |
10100 | 10279 |
10101 switch (event.type) | 10280 switch (event.type) |
10102 { | 10281 { |
10103 case ClientMessage: | 10282 case ClientMessage: |
10104 { | 10283 { |
10105 if (event.xclient.message_type | 10284 if (event.xclient.message_type |
10512 goto OTHER; | 10691 goto OTHER; |
10513 | 10692 |
10514 case KeyPress: | 10693 case KeyPress: |
10515 | 10694 |
10516 /* Dispatch KeyPress events when in menu. */ | 10695 /* Dispatch KeyPress events when in menu. */ |
10517 if (popup_activated_flag) | 10696 if (popup_activated ()) |
10518 goto OTHER; | 10697 goto OTHER; |
10698 | |
10519 f = x_any_window_to_frame (dpyinfo, event.xkey.window); | 10699 f = x_any_window_to_frame (dpyinfo, event.xkey.window); |
10520 | 10700 |
10521 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) | 10701 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) |
10522 { | 10702 { |
10523 dpyinfo->mouse_face_hidden = 1; | 10703 dpyinfo->mouse_face_hidden = 1; |
11078 case ConfigureNotify: | 11258 case ConfigureNotify: |
11079 f = x_top_window_to_frame (dpyinfo, event.xconfigure.window); | 11259 f = x_top_window_to_frame (dpyinfo, event.xconfigure.window); |
11080 if (f) | 11260 if (f) |
11081 { | 11261 { |
11082 #ifndef USE_X_TOOLKIT | 11262 #ifndef USE_X_TOOLKIT |
11263 #ifdef USE_GTK | |
11264 xg_resize_widgets (f, event.xconfigure.width, | |
11265 event.xconfigure.height); | |
11266 #else /* not USE_GTK */ | |
11083 /* If there is a pending resize for fullscreen, don't | 11267 /* If there is a pending resize for fullscreen, don't |
11084 do this one, the right one will come later. | 11268 do this one, the right one will come later. |
11085 The toolkit version doesn't seem to need this, but we | 11269 The toolkit version doesn't seem to need this, but we |
11086 need to reset it below. */ | 11270 need to reset it below. */ |
11087 int dont_resize = | 11271 int dont_resize = |
11106 { | 11290 { |
11107 change_frame_size (f, rows, columns, 0, 1, 0); | 11291 change_frame_size (f, rows, columns, 0, 1, 0); |
11108 SET_FRAME_GARBAGED (f); | 11292 SET_FRAME_GARBAGED (f); |
11109 cancel_mouse_face (f); | 11293 cancel_mouse_face (f); |
11110 } | 11294 } |
11295 #endif /* not USE_GTK */ | |
11111 #endif | 11296 #endif |
11112 | 11297 |
11113 f->output_data.x->pixel_width = event.xconfigure.width; | 11298 f->output_data.x->pixel_width = event.xconfigure.width; |
11114 f->output_data.x->pixel_height = event.xconfigure.height; | 11299 f->output_data.x->pixel_height = event.xconfigure.height; |
11115 | 11300 |
11301 #ifdef USE_GTK | |
11302 /* GTK creates windows but doesn't map them. | |
11303 Only get real positions and check fullscreen when mapped. */ | |
11304 if (FRAME_GTK_OUTER_WIDGET (f) | |
11305 && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) | |
11306 { | |
11307 #endif | |
11116 /* What we have now is the position of Emacs's own window. | 11308 /* What we have now is the position of Emacs's own window. |
11117 Convert that to the position of the window manager window. */ | 11309 Convert that to the position of the window manager window. */ |
11118 x_real_positions (f, &f->output_data.x->left_pos, | 11310 x_real_positions (f, &f->output_data.x->left_pos, |
11119 &f->output_data.x->top_pos); | 11311 &f->output_data.x->top_pos); |
11120 | 11312 |
11121 x_check_fullscreen_move(f); | 11313 x_check_fullscreen_move (f); |
11122 if (f->output_data.x->want_fullscreen & FULLSCREEN_WAIT) | 11314 if (f->output_data.x->want_fullscreen & FULLSCREEN_WAIT) |
11123 f->output_data.x->want_fullscreen &= | 11315 f->output_data.x->want_fullscreen &= |
11124 ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH); | 11316 ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH); |
11317 #ifdef USE_GTK | |
11318 } | |
11319 #endif | |
11125 #ifdef HAVE_X_I18N | 11320 #ifdef HAVE_X_I18N |
11126 if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) | 11321 if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) |
11127 xic_set_statusarea (f); | 11322 xic_set_statusarea (f); |
11128 #endif | 11323 #endif |
11129 | 11324 |
11135 x_wm_set_size_hint (f, (long) 0, 0); | 11330 x_wm_set_size_hint (f, (long) 0, 0); |
11136 } | 11331 } |
11137 } | 11332 } |
11138 goto OTHER; | 11333 goto OTHER; |
11139 | 11334 |
11335 case ButtonRelease: | |
11140 case ButtonPress: | 11336 case ButtonPress: |
11141 case ButtonRelease: | |
11142 { | 11337 { |
11143 /* If we decide we want to generate an event to be seen | 11338 /* If we decide we want to generate an event to be seen |
11144 by the rest of Emacs, we put it here. */ | 11339 by the rest of Emacs, we put it here. */ |
11145 struct input_event emacs_event; | 11340 struct input_event emacs_event; |
11146 int tool_bar_p = 0; | 11341 int tool_bar_p = 0; |
11177 } | 11372 } |
11178 | 11373 |
11179 if (!tool_bar_p) | 11374 if (!tool_bar_p) |
11180 if (!dpyinfo->x_focus_frame | 11375 if (!dpyinfo->x_focus_frame |
11181 || f == dpyinfo->x_focus_frame) | 11376 || f == dpyinfo->x_focus_frame) |
11182 construct_mouse_click (&emacs_event, &event, f); | 11377 { |
11378 if (! popup_activated ()) | |
11379 construct_mouse_click (&emacs_event, &event, f); | |
11380 } | |
11183 } | 11381 } |
11184 else | 11382 else |
11185 { | 11383 { |
11186 #ifndef USE_TOOLKIT_SCROLL_BARS | 11384 #ifndef USE_TOOLKIT_SCROLL_BARS |
11187 struct scroll_bar *bar | 11385 struct scroll_bar *bar |
11205 | 11403 |
11206 if (!tool_bar_p) | 11404 if (!tool_bar_p) |
11207 last_tool_bar_item = -1; | 11405 last_tool_bar_item = -1; |
11208 } | 11406 } |
11209 else | 11407 else |
11210 { | 11408 dpyinfo->grabbed &= ~(1 << event.xbutton.button); |
11211 dpyinfo->grabbed &= ~(1 << event.xbutton.button); | |
11212 } | |
11213 | 11409 |
11214 if (numchars >= 1 && emacs_event.kind != NO_EVENT) | 11410 if (numchars >= 1 && emacs_event.kind != NO_EVENT) |
11215 { | 11411 { |
11216 bcopy (&emacs_event, bufp, sizeof (struct input_event)); | 11412 bcopy (&emacs_event, bufp, sizeof (struct input_event)); |
11217 bufp++; | 11413 bufp++; |
11218 count++; | 11414 count++; |
11219 numchars--; | 11415 numchars--; |
11220 } | 11416 } |
11221 | 11417 |
11222 #ifdef USE_X_TOOLKIT | 11418 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
11223 f = x_menubar_window_to_frame (dpyinfo, event.xbutton.window); | 11419 f = x_menubar_window_to_frame (dpyinfo, event.xbutton.window); |
11224 /* For a down-event in the menu bar, | 11420 /* For a down-event in the menu bar, |
11225 don't pass it to Xt right now. | 11421 don't pass it to Xt right now. |
11226 Instead, save it away | 11422 Instead, save it away |
11227 and we will pass it to Xt from kbd_buffer_get_event. | 11423 and we will pass it to Xt from kbd_buffer_get_event. |
11228 That way, we can run some Lisp code first. */ | 11424 That way, we can run some Lisp code first. */ |
11229 if (f && event.type == ButtonPress | 11425 if ( |
11426 #ifdef USE_GTK | |
11427 ! popup_activated () | |
11428 && | |
11429 #endif | |
11430 f && event.type == ButtonPress | |
11230 /* Verify the event is really within the menu bar | 11431 /* Verify the event is really within the menu bar |
11231 and not just sent to it due to grabbing. */ | 11432 and not just sent to it due to grabbing. */ |
11232 && event.xbutton.x >= 0 | 11433 && event.xbutton.x >= 0 |
11233 && event.xbutton.x < f->output_data.x->pixel_width | 11434 && event.xbutton.x < f->output_data.x->pixel_width |
11234 && event.xbutton.y >= 0 | 11435 && event.xbutton.y >= 0 |
11235 && event.xbutton.y < f->output_data.x->menubar_height | 11436 && event.xbutton.y < f->output_data.x->menubar_height |
11236 && event.xbutton.same_screen) | 11437 && event.xbutton.same_screen) |
11237 { | 11438 { |
11238 SET_SAVED_BUTTON_EVENT; | 11439 SET_SAVED_BUTTON_EVENT; |
11239 XSETFRAME (last_mouse_press_frame, f); | 11440 XSETFRAME (last_mouse_press_frame, f); |
11441 #ifdef USE_GTK | |
11442 *finish = X_EVENT_DROP; | |
11443 #endif | |
11240 } | 11444 } |
11241 else if (event.type == ButtonPress) | 11445 else if (event.type == ButtonPress) |
11242 { | 11446 { |
11243 last_mouse_press_frame = Qnil; | 11447 last_mouse_press_frame = Qnil; |
11244 goto OTHER; | 11448 goto OTHER; |
11258 goto OTHER; | 11462 goto OTHER; |
11259 } | 11463 } |
11260 #endif /* USE_MOTIF */ | 11464 #endif /* USE_MOTIF */ |
11261 else | 11465 else |
11262 goto OTHER; | 11466 goto OTHER; |
11263 #endif /* USE_X_TOOLKIT */ | 11467 #endif /* USE_X_TOOLKIT || USE_GTK */ |
11264 } | 11468 } |
11265 break; | 11469 break; |
11266 | 11470 |
11267 case CirculateNotify: | 11471 case CirculateNotify: |
11268 goto OTHER; | 11472 goto OTHER; |
11295 #endif /* USE_X_TOOLKIT */ | 11499 #endif /* USE_X_TOOLKIT */ |
11296 break; | 11500 break; |
11297 } | 11501 } |
11298 | 11502 |
11299 goto ret; | 11503 goto ret; |
11300 | 11504 |
11301 out: | 11505 out: |
11302 *finish = X_EVENT_GOTO_OUT; | 11506 *finish = X_EVENT_GOTO_OUT; |
11303 | 11507 |
11304 ret: | 11508 ret: |
11305 *bufp_r = bufp; | 11509 *bufp_r = bufp; |
11425 BLOCK_INPUT; | 11629 BLOCK_INPUT; |
11426 count += x_session_check_input (bufp, &numchars); | 11630 count += x_session_check_input (bufp, &numchars); |
11427 UNBLOCK_INPUT; | 11631 UNBLOCK_INPUT; |
11428 #endif | 11632 #endif |
11429 | 11633 |
11634 #ifdef USE_GTK | |
11635 /* For GTK we must use the GTK event loop. But XEvents gets passed | |
11636 to our filter function above, and then to the big event switch. | |
11637 We use a bunch of globals to communicate with our filter function, | |
11638 that is kind of ugly, but it works. */ | |
11639 current_dpyinfo = dpyinfo; | |
11640 | |
11641 while (gtk_events_pending ()) | |
11642 { | |
11643 static int nr = 0; | |
11644 current_count = count; | |
11645 current_numcharsp = &numchars; | |
11646 current_bufp = &bufp; | |
11647 | |
11648 gtk_main_iteration (); | |
11649 | |
11650 count = current_count; | |
11651 current_bufp = 0; | |
11652 current_numcharsp = 0; | |
11653 | |
11654 if (current_finish == X_EVENT_GOTO_OUT) | |
11655 goto out; | |
11656 } | |
11657 | |
11658 #else /* not USE_GTK */ | |
11430 while (XPending (dpyinfo->display)) | 11659 while (XPending (dpyinfo->display)) |
11431 { | 11660 { |
11432 int finish; | 11661 int finish; |
11433 | 11662 |
11434 XNextEvent (dpyinfo->display, &event); | 11663 XNextEvent (dpyinfo->display, &event); |
11455 &finish); | 11684 &finish); |
11456 | 11685 |
11457 if (finish == X_EVENT_GOTO_OUT) | 11686 if (finish == X_EVENT_GOTO_OUT) |
11458 goto out; | 11687 goto out; |
11459 } | 11688 } |
11689 #endif /* USE_GTK */ | |
11460 } | 11690 } |
11461 | 11691 |
11462 out:; | 11692 out:; |
11463 | 11693 |
11464 /* On some systems, an X bug causes Emacs to get no more events | 11694 /* On some systems, an X bug causes Emacs to get no more events |
12920 /* We have nothing to do if the current position | 13150 /* We have nothing to do if the current position |
12921 is already for the top-left corner. */ | 13151 is already for the top-left corner. */ |
12922 if (! ((flags & XNegative) || (flags & YNegative))) | 13152 if (! ((flags & XNegative) || (flags & YNegative))) |
12923 return; | 13153 return; |
12924 | 13154 |
12925 #ifdef USE_X_TOOLKIT | 13155 this_window = FRAME_OUTER_WINDOW (f); |
12926 this_window = XtWindow (f->output_data.x->widget); | |
12927 #else | |
12928 this_window = FRAME_X_WINDOW (f); | |
12929 #endif | |
12930 | 13156 |
12931 /* Find the position of the outside upper-left corner of | 13157 /* Find the position of the outside upper-left corner of |
12932 the inner window, with respect to the outer window. | 13158 the inner window, with respect to the outer window. |
12933 But do this only if we will need the results. */ | 13159 But do this only if we will need the results. */ |
12934 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | 13160 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
13055 modified_left += f->output_data.x->border_width; | 13281 modified_left += f->output_data.x->border_width; |
13056 modified_top += f->output_data.x->border_width; | 13282 modified_top += f->output_data.x->border_width; |
13057 } | 13283 } |
13058 #endif | 13284 #endif |
13059 | 13285 |
13060 #ifdef USE_X_TOOLKIT | 13286 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), |
13061 XMoveWindow (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget), | 13287 modified_left, modified_top); |
13062 modified_left, modified_top); | |
13063 #else /* not USE_X_TOOLKIT */ | |
13064 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
13065 modified_left, modified_top); | |
13066 #endif /* not USE_X_TOOLKIT */ | |
13067 UNBLOCK_INPUT; | 13288 UNBLOCK_INPUT; |
13068 } | 13289 } |
13069 | 13290 |
13070 /* Check if we need to resize the frame due to a fullscreen request. | 13291 /* Check if we need to resize the frame due to a fullscreen request. |
13071 If so needed, resize the frame. */ | 13292 If so needed, resize the frame. */ |
13247 int change_gravity; | 13468 int change_gravity; |
13248 int cols, rows; | 13469 int cols, rows; |
13249 { | 13470 { |
13250 BLOCK_INPUT; | 13471 BLOCK_INPUT; |
13251 | 13472 |
13252 #ifdef USE_X_TOOLKIT | 13473 #ifdef USE_GTK |
13474 if (FRAME_GTK_WIDGET (f)) | |
13475 xg_frame_set_char_size (f, cols, rows); | |
13476 else | |
13477 x_set_window_size_1 (f, change_gravity, cols, rows); | |
13478 #elif USE_X_TOOLKIT | |
13253 | 13479 |
13254 if (f->output_data.x->widget != NULL) | 13480 if (f->output_data.x->widget != NULL) |
13255 { | 13481 { |
13256 /* The x and y position of the widget is clobbered by the | 13482 /* The x and y position of the widget is clobbered by the |
13257 call to XtSetValues within EmacsFrameSetCharSize. | 13483 call to XtSetValues within EmacsFrameSetCharSize. |
13443 x_wm_set_window_state (f, NormalState); | 13669 x_wm_set_window_state (f, NormalState); |
13444 #ifdef USE_X_TOOLKIT | 13670 #ifdef USE_X_TOOLKIT |
13445 /* This was XtPopup, but that did nothing for an iconified frame. */ | 13671 /* This was XtPopup, but that did nothing for an iconified frame. */ |
13446 XtMapWidget (f->output_data.x->widget); | 13672 XtMapWidget (f->output_data.x->widget); |
13447 #else /* not USE_X_TOOLKIT */ | 13673 #else /* not USE_X_TOOLKIT */ |
13674 #ifdef USE_GTK | |
13675 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); | |
13676 #else | |
13448 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | 13677 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); |
13678 #endif /* not USE_GTK */ | |
13449 #endif /* not USE_X_TOOLKIT */ | 13679 #endif /* not USE_X_TOOLKIT */ |
13450 #if 0 /* This seems to bring back scroll bars in the wrong places | 13680 #if 0 /* This seems to bring back scroll bars in the wrong places |
13451 if the window configuration has changed. They seem | 13681 if the window configuration has changed. They seem |
13452 to come back ok without this. */ | 13682 to come back ok without this. */ |
13453 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) | 13683 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
13594 program-specified, so that when the window is mapped again, it will be | 13824 program-specified, so that when the window is mapped again, it will be |
13595 placed at the same location, without forcing the user to position it | 13825 placed at the same location, without forcing the user to position it |
13596 by hand again (they have already done that once for this window.) */ | 13826 by hand again (they have already done that once for this window.) */ |
13597 x_wm_set_size_hint (f, (long) 0, 1); | 13827 x_wm_set_size_hint (f, (long) 0, 1); |
13598 | 13828 |
13829 #ifdef USE_GTK | |
13830 if (FRAME_GTK_OUTER_WIDGET (f)) | |
13831 { | |
13832 gtk_widget_hide (FRAME_GTK_OUTER_WIDGET (f)); | |
13833 goto out; | |
13834 } | |
13835 #endif | |
13836 | |
13599 #ifdef HAVE_X11R4 | 13837 #ifdef HAVE_X11R4 |
13600 | 13838 |
13601 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window, | 13839 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window, |
13602 DefaultScreen (FRAME_X_DISPLAY (f)))) | 13840 DefaultScreen (FRAME_X_DISPLAY (f)))) |
13603 { | 13841 { |
13628 | 13866 |
13629 /* Unmap the window ourselves. Cheeky! */ | 13867 /* Unmap the window ourselves. Cheeky! */ |
13630 XUnmapWindow (FRAME_X_DISPLAY (f), window); | 13868 XUnmapWindow (FRAME_X_DISPLAY (f), window); |
13631 #endif /* ! defined (HAVE_X11R4) */ | 13869 #endif /* ! defined (HAVE_X11R4) */ |
13632 | 13870 |
13871 out: | |
13633 /* We can't distinguish this from iconification | 13872 /* We can't distinguish this from iconification |
13634 just by the event that we get from the server. | 13873 just by the event that we get from the server. |
13635 So we can't win using the usual strategy of letting | 13874 So we can't win using the usual strategy of letting |
13636 FRAME_SAMPLE_VISIBILITY set this. So do it by hand, | 13875 FRAME_SAMPLE_VISIBILITY set this. So do it by hand, |
13637 and synchronize with the server to make sure we agree. */ | 13876 and synchronize with the server to make sure we agree. */ |
13666 FRAME_SAMPLE_VISIBILITY (f); | 13905 FRAME_SAMPLE_VISIBILITY (f); |
13667 | 13906 |
13668 type = x_icon_type (f); | 13907 type = x_icon_type (f); |
13669 if (!NILP (type)) | 13908 if (!NILP (type)) |
13670 x_bitmap_icon (f, type); | 13909 x_bitmap_icon (f, type); |
13910 | |
13911 #ifdef USE_GTK | |
13912 if (FRAME_GTK_OUTER_WIDGET (f)) | |
13913 { | |
13914 if (! FRAME_VISIBLE_P (f)) | |
13915 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); | |
13916 | |
13917 gtk_window_iconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); | |
13918 f->iconified = 1; | |
13919 f->visible = 1; | |
13920 f->async_iconified = 1; | |
13921 f->async_visible = 0; | |
13922 UNBLOCK_INPUT; | |
13923 return; | |
13924 } | |
13925 #endif | |
13671 | 13926 |
13672 #ifdef USE_X_TOOLKIT | 13927 #ifdef USE_X_TOOLKIT |
13673 | 13928 |
13674 if (! FRAME_VISIBLE_P (f)) | 13929 if (! FRAME_VISIBLE_P (f)) |
13675 { | 13930 { |
13801 else if (FRAME_X_WINDOW (f)) | 14056 else if (FRAME_X_WINDOW (f)) |
13802 XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | 14057 XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); |
13803 | 14058 |
13804 free_frame_menubar (f); | 14059 free_frame_menubar (f); |
13805 #else /* !USE_X_TOOLKIT */ | 14060 #else /* !USE_X_TOOLKIT */ |
14061 | |
14062 #ifdef USE_GTK | |
14063 /* In the GTK version, tooltips are normal X | |
14064 frames. We must check and free both types. */ | |
14065 if (FRAME_GTK_OUTER_WIDGET (f)) | |
14066 { | |
14067 gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); | |
14068 FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow below */ | |
14069 FRAME_GTK_OUTER_WIDGET (f) = 0; | |
14070 } | |
14071 #endif /* USE_GTK */ | |
14072 | |
13806 if (FRAME_X_WINDOW (f)) | 14073 if (FRAME_X_WINDOW (f)) |
13807 XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | 14074 XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); |
13808 #endif /* !USE_X_TOOLKIT */ | 14075 #endif /* !USE_X_TOOLKIT */ |
13809 | 14076 |
13810 unload_color (f, f->output_data.x->foreground_pixel); | 14077 unload_color (f, f->output_data.x->foreground_pixel); |
13886 | 14153 |
13887 /* Set the normal size hints for the window manager, for frame F. | 14154 /* Set the normal size hints for the window manager, for frame F. |
13888 FLAGS is the flags word to use--or 0 meaning preserve the flags | 14155 FLAGS is the flags word to use--or 0 meaning preserve the flags |
13889 that the window now has. | 14156 that the window now has. |
13890 If USER_POSITION is nonzero, we set the USPosition | 14157 If USER_POSITION is nonzero, we set the USPosition |
13891 flag (this is useful when FLAGS is 0). */ | 14158 flag (this is useful when FLAGS is 0). |
13892 | 14159 The GTK version is in gtkutils.c */ |
14160 | |
14161 #ifndef USE_GTK | |
13893 void | 14162 void |
13894 x_wm_set_size_hint (f, flags, user_position) | 14163 x_wm_set_size_hint (f, flags, user_position) |
13895 struct frame *f; | 14164 struct frame *f; |
13896 long flags; | 14165 long flags; |
13897 int user_position; | 14166 int user_position; |
13900 | 14169 |
13901 #ifdef USE_X_TOOLKIT | 14170 #ifdef USE_X_TOOLKIT |
13902 Arg al[2]; | 14171 Arg al[2]; |
13903 int ac = 0; | 14172 int ac = 0; |
13904 Dimension widget_width, widget_height; | 14173 Dimension widget_width, widget_height; |
13905 Window window = XtWindow (f->output_data.x->widget); | 14174 #endif |
13906 #else /* not USE_X_TOOLKIT */ | 14175 |
13907 Window window = FRAME_X_WINDOW (f); | 14176 Window window = FRAME_OUTER_WINDOW (f); |
13908 #endif /* not USE_X_TOOLKIT */ | |
13909 | 14177 |
13910 /* Setting PMaxSize caused various problems. */ | 14178 /* Setting PMaxSize caused various problems. */ |
13911 size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */; | 14179 size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */; |
13912 | 14180 |
13913 size_hints.x = f->output_data.x->left_pos; | 14181 size_hints.x = f->output_data.x->left_pos; |
14030 XSetWMNormalHints (FRAME_X_DISPLAY (f), window, &size_hints); | 14298 XSetWMNormalHints (FRAME_X_DISPLAY (f), window, &size_hints); |
14031 #else | 14299 #else |
14032 XSetNormalHints (FRAME_X_DISPLAY (f), window, &size_hints); | 14300 XSetNormalHints (FRAME_X_DISPLAY (f), window, &size_hints); |
14033 #endif | 14301 #endif |
14034 } | 14302 } |
14303 #endif /* not USE_GTK */ | |
14035 | 14304 |
14036 /* Used for IconicState or NormalState */ | 14305 /* Used for IconicState or NormalState */ |
14037 | 14306 |
14038 void | 14307 void |
14039 x_wm_set_window_state (f, state) | 14308 x_wm_set_window_state (f, state) |
14061 int pixmap_id; | 14330 int pixmap_id; |
14062 { | 14331 { |
14063 Pixmap icon_pixmap; | 14332 Pixmap icon_pixmap; |
14064 | 14333 |
14065 #ifndef USE_X_TOOLKIT | 14334 #ifndef USE_X_TOOLKIT |
14066 Window window = FRAME_X_WINDOW (f); | 14335 Window window = FRAME_OUTER_WINDOW (f); |
14067 #endif | 14336 #endif |
14068 | 14337 |
14069 if (pixmap_id > 0) | 14338 if (pixmap_id > 0) |
14070 { | 14339 { |
14071 icon_pixmap = x_bitmap_pixmap (f, pixmap_id); | 14340 icon_pixmap = x_bitmap_pixmap (f, pixmap_id); |
14862 { | 15131 { |
14863 x_initialize (); | 15132 x_initialize (); |
14864 x_initialized = 1; | 15133 x_initialized = 1; |
14865 } | 15134 } |
14866 | 15135 |
15136 #ifdef USE_GTK | |
15137 { | |
15138 #define NUM_ARGV 10 | |
15139 int argc; | |
15140 char *argv[NUM_ARGV]; | |
15141 char **argv2 = argv; | |
15142 GdkAtom atom; | |
15143 | |
15144 /* GTK 2.0 can only handle one display, GTK 2.2 can handle more | |
15145 than one, but this remains to be implemented. */ | |
15146 if (x_initialized > 1) | |
15147 return 0; | |
15148 | |
15149 x_initialized++; | |
15150 | |
15151 for (argc = 0; argc < NUM_ARGV; ++argc) | |
15152 argv[argc] = 0; | |
15153 | |
15154 argc = 0; | |
15155 argv[argc++] = initial_argv[0]; | |
15156 | |
15157 if (! NILP (display_name)) | |
15158 { | |
15159 argv[argc++] = "--display"; | |
15160 argv[argc++] = SDATA (display_name); | |
15161 } | |
15162 | |
15163 argv[argc++] = "--name"; | |
15164 argv[argc++] = resource_name; | |
15165 | |
15166 gtk_init (&argc, &argv2); | |
15167 | |
15168 /* gtk_init does set_locale. We must fix locale after calling it. */ | |
15169 fixup_locale (); | |
15170 xg_initialize (); | |
15171 | |
15172 dpy = GDK_DISPLAY (); | |
15173 | |
15174 /* NULL window -> events for all windows go to our function */ | |
15175 gdk_window_add_filter (NULL, event_handler_gdk, NULL); | |
15176 | |
15177 /* Load our own gtkrc if it exists. */ | |
15178 { | |
15179 struct gcpro gcpro1, gcpro2; | |
15180 char *file = "~/.emacs.d/gtkrc"; | |
15181 Lisp_Object s, abs_file; | |
15182 | |
15183 GCPRO2 (str, abs_file); | |
15184 s = make_string (file, strlen (file)); | |
15185 abs_file = Fexpand_file_name(s, Qnil); | |
15186 | |
15187 if (! NILP (abs_file) && Ffile_readable_p (abs_file)) | |
15188 gtk_rc_parse (SDATA (abs_file)); | |
15189 | |
15190 UNGCPRO; | |
15191 } | |
15192 | |
15193 XSetErrorHandler (x_error_handler); | |
15194 XSetIOErrorHandler (x_io_error_quitter); | |
15195 } | |
15196 #else /* not USE_GTK */ | |
14867 #ifdef USE_X_TOOLKIT | 15197 #ifdef USE_X_TOOLKIT |
14868 /* weiner@footloose.sps.mot.com reports that this causes | 15198 /* weiner@footloose.sps.mot.com reports that this causes |
14869 errors with X11R5: | 15199 errors with X11R5: |
14870 X protocol error: BadAtom (invalid Atom parameter) | 15200 X protocol error: BadAtom (invalid Atom parameter) |
14871 on protocol request 18skiloaf. | 15201 on protocol request 18skiloaf. |
14902 #ifdef HAVE_X11R5 | 15232 #ifdef HAVE_X11R5 |
14903 XSetLocaleModifiers (""); | 15233 XSetLocaleModifiers (""); |
14904 #endif | 15234 #endif |
14905 dpy = XOpenDisplay (SDATA (display_name)); | 15235 dpy = XOpenDisplay (SDATA (display_name)); |
14906 #endif /* not USE_X_TOOLKIT */ | 15236 #endif /* not USE_X_TOOLKIT */ |
15237 #endif /* not USE_GTK*/ | |
14907 | 15238 |
14908 /* Detect failure. */ | 15239 /* Detect failure. */ |
14909 if (dpy == 0) | 15240 if (dpy == 0) |
14910 { | 15241 { |
14911 UNBLOCK_INPUT; | 15242 UNBLOCK_INPUT; |
15361 start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0); | 15692 start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0); |
15362 } | 15693 } |
15363 #endif | 15694 #endif |
15364 | 15695 |
15365 #ifdef USE_TOOLKIT_SCROLL_BARS | 15696 #ifdef USE_TOOLKIT_SCROLL_BARS |
15697 #ifndef USE_GTK | |
15366 xaw3d_arrow_scroll = False; | 15698 xaw3d_arrow_scroll = False; |
15367 xaw3d_pick_top = True; | 15699 xaw3d_pick_top = True; |
15700 #endif | |
15368 #endif | 15701 #endif |
15369 | 15702 |
15370 /* Note that there is no real way portable across R3/R4 to get the | 15703 /* Note that there is no real way portable across R3/R4 to get the |
15371 original error handler. */ | 15704 original error handler. */ |
15372 XSetErrorHandler (x_error_handler); | 15705 XSetErrorHandler (x_error_handler); |
15443 #ifdef USE_TOOLKIT_SCROLL_BARS | 15776 #ifdef USE_TOOLKIT_SCROLL_BARS |
15444 #ifdef USE_MOTIF | 15777 #ifdef USE_MOTIF |
15445 Vx_toolkit_scroll_bars = intern ("motif"); | 15778 Vx_toolkit_scroll_bars = intern ("motif"); |
15446 #elif defined HAVE_XAW3D | 15779 #elif defined HAVE_XAW3D |
15447 Vx_toolkit_scroll_bars = intern ("xaw3d"); | 15780 Vx_toolkit_scroll_bars = intern ("xaw3d"); |
15781 #elif USE_GTK | |
15782 Vx_toolkit_scroll_bars = intern ("gtk"); | |
15448 #else | 15783 #else |
15449 Vx_toolkit_scroll_bars = intern ("xaw"); | 15784 Vx_toolkit_scroll_bars = intern ("xaw"); |
15450 #endif | 15785 #endif |
15451 #else | 15786 #else |
15452 Vx_toolkit_scroll_bars = Qnil; | 15787 Vx_toolkit_scroll_bars = Qnil; |